Prechádzať zdrojové kódy

2022.7.13 客户管理排序

ggooalice 2 rokov pred
rodič
commit
81314da99a

+ 30 - 6
fhKeeper/formulahousekeeper/timesheet/src/views/customer/list.vue

@@ -21,13 +21,13 @@
         </el-col>
 
         <!--列表-->
-        <el-table :data="list" highlight-current-row v-loading="listLoading" :height="tableHeight" style="width: 100%;" @selection-change="selectionChange">
+        <el-table :data="list" highlight-current-row v-loading="listLoading" :height="tableHeight" style="width: 100%;" @selection-change="selectionChange" @sort-change="tableSort">
             <el-table-column type="selection" width="60">
                 <!-- <template slot-scope="scope" >
                         {{scope.$index+1+(page-1)*size}}
                     </template> -->
             </el-table-column>
-            <el-table-column prop="customerCode" label="客户编码"  width="120"></el-table-column>
+            <el-table-column prop="customerCode" label="客户编码"  width="120" sortable="custom"></el-table-column>
             <el-table-column prop="customerName" label="客户名称" >
             </el-table-column>
             <el-table-column prop="contactName" label="联系人"  width="120">
@@ -36,7 +36,7 @@
             </el-table-column>
             <el-table-column prop="email" label="邮箱"  width="180">
             </el-table-column>
-            <el-table-column prop="address" label="地址" >
+            <el-table-column prop="address" label="地址" sortable="custom">
             </el-table-column>
             
             <el-table-column label="操作" width="150">
@@ -170,7 +170,9 @@
                 importResultMsg:null,
                 showImportResult:false,
                 selectArr: [],
-                delLoading: false
+                delLoading: false,
+                sortOrder: null,
+                sortProp: ''
             };
         },
         // 过滤器
@@ -442,14 +444,36 @@
                 this.getList();
             },
 
+            tableSort({column, prop, order}){
+                if(prop == 'customerCode' || prop == 'address'){
+                    this.sortOrder = order
+                    this.sortProp = prop
+                    this.getList()
+                }
+            },
+
             //获取项目列表
             getList() {
                 this.listLoading = true;
-                this.http.post('/customer-info/list', {
+                let parameter = {
                     pageIndex: this.page,
                     pageSize: this.size,
                     keyword:this.keyword
-                },
+                }
+                if(this.sortOrder){
+                    if(this.sortProp == 'customerCode'){
+                        parameter.sortProp = 'customer_code'
+                    }else if(this.sortProp == 'address'){
+                        parameter.sortProp = 'address'
+                    }
+
+                    if(this.sortOrder == 'descending'){
+                        parameter.sortOrder = 0
+                    }else if(this.sortOrder == 'ascending'){
+                        parameter.sortOrder = 1
+                    }
+                }
+                this.http.post('/customer-info/list', parameter,
                 res => {
                     this.listLoading = false;
                     if (res.code == "ok") {