Browse Source

修改客户资料

huangbin 4 years ago
parent
commit
13f9435173

+ 14 - 0
src/services/bus/table.ts

@@ -1,6 +1,20 @@
 import { Column, TableDefineRsp } from '@/goServiceAPI/commonService/interface';
 import APP from '@/services';
 
+interface CustomRender {
+    customRender: string;
+}
+// 动态表头类型
+export interface ColumnType {
+    key: string;
+    dataIndex: string;
+    title: string;
+    align: string;  //  AlignType 对齐方式 - 1:居中对齐 2:左对齐 3:右对齐
+    filteredValue?: string | null;
+    slots?: CustomRender;
+    onFilter?: Function;
+    sorter?: Function;
+}
 interface TableKey {
     table_pcweb_delivery: string; // 现货合同
     table_pcweb_userinfo: string; // 客户资料

+ 1 - 1
src/services/socket/login/index.ts

@@ -30,7 +30,7 @@ export const loginAction = (logidCode: String, password: String, ClientSystemInf
             },
         };
         if (ClientSystemInfo.length) {  // 与qt交互消息
-            Object.assign(params.reqParams, { ClientSystemInfo })
+            Object.assign(params.reqParams, { ClientSystemInfo, ClientAppID: 'muchinfo_mtpclient_5.0.1' })
         }
         const package50 = buildProtoReq50(params);
         APP.sendTradingServer(package50, undefined, {

+ 27 - 28
src/views/information/custom/list/normal-use/index.vue

@@ -1,61 +1,55 @@
 <template>
   <!-- 客户信息: 正常 -->
-  <div class="custom-normal">
+  <div class="custom-normal"
+       :loading="loading">
     <filterCustomTable @add="add"
                        @search="search" />
     <a-table :columns="columns"
              :pagination="false"
              rowKey="key"
-             :data-source="customList" />
+             :data-source="customList">
+      <template #userinfotype="{ text }">
+        <a>{{ text === '2' ? '企业' : '个人'}}</a>
+      </template>
+    </a-table>
   </div>
 </template>
 
 <script lang="ts">
-import { computed, defineComponent, ref } from 'vue';
+import { defineComponent, Ref, ref } from 'vue';
 
 import { initData } from '@/setup/methods/index';
 import { QueryCustomInfo } from '@/goServiceAPI/ermcp/customInfo/index';
 import { QueryCustomInfoType } from '@/goServiceAPI/ermcp/customInfo/interface';
 import filterCustomTable from '@/views/information/custom/compoments/filterTable/index.vue';
-import { getTableHead } from '@/services/bus/table';
+import { getTableHead, ColumnType } from '@/services/bus/table';
 import { TableState, TableStateFilters } from 'ant-design-vue/es/table/interface';
 import { message } from 'ant-design-vue';
 
 // 查询客户资料列表
 function getCustomList() {
-    interface ColumnType {
-        key: string;
-        dataIndex: string;
-        title: string;
-        onFilter?: Function;
-        sorter?: Function;
-    }
-
+    // 表格数据
     const customList = ref<QueryCustomInfoType[]>([]);
+    // 表头数据
     const columns = ref<ColumnType[]>([]);
+    // 过滤项
     const filteredInfo = ref();
+    const loading = ref<boolean>(false);
     // 获取表头
     function getColumns() {
-        interface ColumnType {
-            key: string;
-            dataIndex: string;
-            title: string;
-            filteredValue?: string | null;
-            onFilter?: Function;
-            sorter?: Function;
-        }
         const list = getTableHead('table_pcweb_userinfo');
-        console.log('list', list);
-
         const filtered = filteredInfo.value || {};
         columns.value.length = 0;
         list.forEach((e, i) => {
-            const { columnfield, columntitle } = e;
+            const { columnfield, columntitle, aligntype } = e;
             const item: ColumnType = {
                 key: String(i),
-                dataIndex: columnfield,
+                dataIndex: columnfield, // 表格数据对应的key
                 title: columntitle,
+                align: aligntype === 1 ? 'center' : aligntype === 2 ? 'left' : 'right',
+                slots: { customRender: columnfield },
             };
+            // 以下添加过滤数据对应的方法
             if (e.columntitle === '客户类型') {
                 item.onFilter = (value: string, record: QueryCustomInfoType) => record.userinfotype.includes(String(value));
                 item.filteredValue = filtered.userinfotype || null;
@@ -83,14 +77,19 @@ function getCustomList() {
     }
     // 查询列表
     function actionQuery() {
+        loading.value = true;
         QueryCustomInfo(3)
             .then((res) => {
                 customList.value = res.map((e, i) => {
                     return { ...e, key: String(i) };
                 });
+                loading.value = false;
                 console.log('查询列表', customList);
             })
-            .catch((err) => message.error(err));
+            .catch((err) => {
+                message.error(err);
+                loading.value = false;
+            });
     }
     // 查询
     function search(value: any) {
@@ -98,7 +97,7 @@ function getCustomList() {
         getColumns();
         console.log('search', value);
     }
-    return { customList, actionQuery, columns, filteredInfo, getColumns, search };
+    return { customList, actionQuery, columns, filteredInfo, getColumns, search, loading };
 }
 
 function add() {
@@ -111,13 +110,13 @@ export default defineComponent({
         filterCustomTable,
     },
     setup() {
-        const { customList, actionQuery, columns, getColumns, search } = getCustomList();
+        const { customList, actionQuery, columns, getColumns, search, loading } = getCustomList();
         initData(() => {
             actionQuery();
             getColumns();
             // 加载数据在这里
         });
-        return { customList, add, columns, search };
+        return { customList, add, columns, search, loading };
     },
 });
 </script>