Browse Source

Merge branch 'master' of http://47.101.159.18:3000/Muchinfo/MTP2.0_WEB

huangbin 4 years ago
parent
commit
b54980392e
1 changed files with 65 additions and 45 deletions
  1. 65 45
      src/views/information/warehouse-info/list/normal-use/index.vue

+ 65 - 45
src/views/information/warehouse-info/list/normal-use/index.vue

@@ -10,7 +10,7 @@
     <a-table :columns="columns"
              :pagination="false"
              rowKey="key"
-             :data-source="wareHouseInfoList" />
+             :data-source="wareHouseInfos" />
   </div>
 </template>
 
@@ -21,69 +21,89 @@ import { initData } from '@/setup/methods/index';
 import { QueryWareHouse } from '@/goServiceAPI/ermcp/warehouse-info/index';
 import { ErmcpWareHouseInfo } from '@/goServiceAPI/ermcp/warehouse-info/interface';
 import { message } from 'ant-design-vue';
+import { getTableHead } from '@/services/bus/table';
+import { getUserId } from '@/services/bus/account';
 
 // 查询客户资料列表
 function getWarehouseInfoList() {
-    // const filteredInfo = ref();
-    // const sortedInfo = ref();
-    // const columns = computed(() => {
-    //     const filtered = filteredInfo.value || {};
-    //     const sorted = sortedInfo.value || {};
-    //     return [
-    //         {
-    //             title: '序号',
-    //             dataIndex: 'index',
-    //             key: 'index',
-    //             align: 'center',
-    //             width: 50,
-    //             customRender: (param: any) => `${param.index + 1}`,
-    //         },
-    //         {
-    //             title: 'Age',
-    //             dataIndex: 'age',
-    //             key: 'age',
-    //             sorter: (a: DataItem, b: DataItem) => a.age - b.age,
-    //             sortOrder: sorted.columnKey === 'age' && sorted.order,
-    //         },
-    //         {
-    //             title: 'Address',
-    //             dataIndex: 'address',
-    //             key: 'address',
-    //             filters: [
-    //                 { text: 'London', value: 'London' },
-    //                 { text: 'New York', value: 'New York' },
-    //             ],
-    //             filteredValue: filtered.address || null,
-    //             onFilter: (value: string, record: DataItem) => record.address.includes(value),
-    //             sorter: (a: DataItem, b: DataItem) => a.address.length - b.address.length,
-    //             sortOrder: sorted.columnKey === 'address' && sorted.order,
-    //             ellipsis: true,
-    //         },
-    //     ];
-    // });
+    interface ColumnType {
+        key: string;
+        dataIndex: string;
+        title: string;
+        onFilter?: Function;
+        sorter?: Function;
+    }
+
+    // 仓库数据
+    const wareHouseInfos = ref<ErmcpWareHouseInfo[]>([]);
+    // 列头
+    const columns = ref<ColumnType[]>([]);
+    // 过滤
+    const filteredInfo = ref();
+
+    // 获取表头
+    function getColumns() {
+        interface ColumnType {
+            key: string;
+            dataIndex: string;
+            title: string;
+            filteredValue?: string | null;
+            onFilter?: Function;
+            sorter?: Function;
+        }
+        const list = getTableHead('table_pcweb_warehouse');
+        console.log('list', list);
+
+        const filtered = filteredInfo.value || {};
+        columns.value.length = 0;
+        list.forEach((e, i) => {
+            const { columnfield, columntitle } = e;
+            const item: ColumnType = {
+                key: String(i),
+                dataIndex: columnfield,
+                title: columntitle,
+            };
+            columns.value.push(item);
+        });
+        console.log('columns', columns);
+    }
+
+    // 获取仓库信息
     const wareHouseInfoList = ref<ErmcpWareHouseInfo[]>([]);
     function actionQuery() {
-        const reqParam = { userid: 0,  status: "1"};
+        const reqParam = { userid: getUserId(),  status: "1"};
         QueryWareHouse(reqParam)
             .then((res) => {
-                console.log('L', res);
+                wareHouseInfos.value = res.map((e, i) => {
+                    return { ...e, key: String(i) };
+                });
+                console.log('查询仓库列表', wareHouseInfos);
             })
             .catch((err) => message.error(err));
     }
+    // 查询
+    function search(value: any) {
+        
+    }
+
+    return { wareHouseInfos, actionQuery, columns, getColumns, search };
+}
 
-    return { wareHouseInfoList, actionQuery };
+// 新增
+function add() {
+    console.log('add');
 }
 
 export default defineComponent({
     name: 'warehouse-info-normal',
     components: {},
     setup() {
-        const { wareHouseInfoList, actionQuery } = getWarehouseInfoList();
+        const { wareHouseInfos, actionQuery, columns, getColumns, search } = getWarehouseInfoList();
         initData(() => {
             actionQuery();
-            // 加载数据在这里
+            getColumns();
         });
-        return { wareHouseInfoList };
+        return { wareHouseInfos, add, columns, search };
     },
 });
 </script>
@@ -91,4 +111,4 @@ export default defineComponent({
 <style lang="less">
 .warehouse-info-normal {
 }
-</style>;
+</style>;