Browse Source

修改员工分页

mork 6 days ago
parent
commit
081f0b03f0
4 changed files with 77 additions and 76 deletions
  1. 1 1
      src/components/LeftMenu.vue
  2. 53 31
      src/components/Map.vue
  3. 21 26
      src/components/Table.vue
  4. 2 18
      src/views/IndexView.vue

+ 1 - 1
src/components/LeftMenu.vue

@@ -168,7 +168,7 @@ export default {
           if (moreBtn) {
           if (moreBtn) {
             moreBtn.addEventListener('click', () => {
             moreBtn.addEventListener('click', () => {
               let pro = {properties:param}
               let pro = {properties:param}
-              that.$parent.handleMoreClick(pro.properties.GUID);
+              that.$parent.handleMoreClick(pro.properties.GUID,"",0);
             });
             });
           }
           }
         }, 0);
         }, 0);

+ 53 - 31
src/components/Map.vue

@@ -5,7 +5,18 @@
 
 
   <VueJsonEditor v-if="editWinFlag" :editDataList="editDataList"></VueJsonEditor>
   <VueJsonEditor v-if="editWinFlag" :editDataList="editDataList"></VueJsonEditor>
 
 
-  <Table :tableData="tableData" :columnModel="columnModel" :searchText="tableSearchText" v-if="tableShow" :isview="tableShow" :close="handleClose"></Table>
+  <Table 
+  v-if="tableShow"
+  :tableData="tableData" 
+  :columnModel="columnModel" 
+  :searchText="tableSearchText" 
+  :isview="tableShow" 
+  :close="handleClose"
+  :total="total"
+  :pageSize="pageSize"
+  :page="page"
+  :handlePageChange="handlePageChange"
+  ></Table>
 
 
   <editManage
   <editManage
     v-if="isContentShow"
     v-if="isContentShow"
@@ -116,7 +127,11 @@ export default {
       arrParam: ["补查查询串","补查相似度","补查原因","补查匹配地址","补查点坐标","补查匹配名称","补查buffer_m","补查状态"], //过滤字段
       arrParam: ["补查查询串","补查相似度","补查原因","补查匹配地址","补查点坐标","补查匹配名称","补查buffer_m","补查状态"], //过滤字段
       selectText: [],
       selectText: [],
       options: [],
       options: [],
-      fontText:["concat"]// "concat", ["get", "GUID"], "\n", ["get", "match_status"],"\n", ["get", "range_shape"]
+      fontText:["concat"],// "concat", ["get", "GUID"], "\n", ["get", "match_status"],"\n", ["get", "range_shape"]
+
+      pageSize: 10,
+      page: 0,
+      total: 0,
     };
     };
   },
   },
   mounted() {
   mounted() {
@@ -259,14 +274,7 @@ export default {
     //关闭编辑弹窗
     //关闭编辑弹窗
     handleEditClose() {
     handleEditClose() {
       let guid = sessionStorage.getItem('guid');
       let guid = sessionStorage.getItem('guid');
-      if(guid){
-        this.handleMoreClick(guid);
-      }else{
-        this.$parent.getDmsDataList();
-        this.isContentShow = false;
-        this.isContentView = false;
-        this.contentItem = {};
-      }
+      this.handleMoreClick(guid,this.tableSearchText,this.page);
     },
     },
     handleClose() {
     handleClose() {
       this.tableShow = false;
       this.tableShow = false;
@@ -539,37 +547,57 @@ export default {
           if (moreBtn) {
           if (moreBtn) {
             moreBtn.addEventListener('click', () => {
             moreBtn.addEventListener('click', () => {
               // that.tableShow = false;
               // that.tableShow = false;
-              that.handleMoreClick(fet.properties.GUID);
+              this.tableSearchText = "";
+              that.handleMoreClick(fet.properties.GUID,"",0);
               sessionStorage.setItem('guid', fet.properties.GUID);
               sessionStorage.setItem('guid', fet.properties.GUID);
             });
             });
           }
           }
         }, 0);
         }, 0);
       
       
     },
     },
+    handlePageChange(page, pageSize,text){
+      this.page = page;
+      this.pageSize = pageSize;
+      this.tableSearchText = text;
+      let guid = sessionStorage.getItem('guid');
+      this.handleMoreClick(guid,text,page);
+    },
     // 处理弹窗中"更多"按钮点击
     // 处理弹窗中"更多"按钮点击
-    handleMoreClick(guid) {
+    handleMoreClick(guid,text,page) {
       const that = this;
       const that = this;
+      that.page = page;
       //1743 项目数据  1742 申勤员工
       //1743 项目数据  1742 申勤员工
       // 排序条件orderByType  1 升序 2 降序
       // 排序条件orderByType  1 升序 2 降序
       let requestParams = {
       let requestParams = {
         columnId: webConfig.columnArr[0].id,
         columnId: webConfig.columnArr[0].id,
         states: "0,1,2,3",
         states: "0,1,2,3",
-        orderBy: JSON.stringify([{ field: "update_time", orderByType: 2 }]),
-        pageSize: 9999,
-        page: 0,
+        orderBy: JSON.stringify([{ field: "c_xm", orderByType: 2 }]),
+        pageSize: that.pageSize,
+        page: that.page,
       };
       };
       console.log("guid:", guid);
       console.log("guid:", guid);
-      requestParams.search = JSON.stringify([
-        ...(requestParams.search ? JSON.parse(requestParams.search) : []),
-        {
+      console.log("text:", text); 
+      let arr = [...(requestParams.search ? JSON.parse(requestParams.search) : [])];
+      if(guid){
+        arr.push({
           field: "c_xmguid",  // 申勤员工 c_xmguid   项目数据 c_guid
           field: "c_xmguid",  // 申勤员工 c_xmguid   项目数据 c_guid
           searchType: 2,
           searchType: 2,
           content: { value: guid },
           content: { value: guid },
-        },
-      ]);
+        });
+      }
+      if(text){
+        arr.push({
+          field: "c_xm",
+          searchType: 2,
+          content: { value: text },
+        });
+      }
+      requestParams.search = JSON.stringify(arr);
+       
       commonAPI.getDmsDataList(requestParams).then((res) => {
       commonAPI.getDmsDataList(requestParams).then((res) => {
         if (res.code == 200){
         if (res.code == 200){
           let data = res.content.data;
           let data = res.content.data;
+          that.total = res.content.count;
           data = data.map(item => {
           data = data.map(item => {
             // 给每个属性名称添加 c_ 前缀
             // 给每个属性名称添加 c_ 前缀
             const newItem = {};
             const newItem = {};
@@ -587,7 +615,7 @@ export default {
           // console.log("data:", data);
           // console.log("data:", data);
           that.tableData = data;
           that.tableData = data;
           that.tableData.sort((a, b) => a.c_xm.localeCompare(b.c_xm, 'zh-CN'))
           that.tableData.sort((a, b) => a.c_xm.localeCompare(b.c_xm, 'zh-CN'))
-          that.tableSearchText = "";
+          
           if(!that.tableShow){
           if(!that.tableShow){
             that.tableShow = true;
             that.tableShow = true;
           }
           }
@@ -597,26 +625,20 @@ export default {
           that.isContentView = false;
           that.isContentView = false;
 
 
         }else{
         }else{
+          that.tableData = [];
+          that.contentItem=[];
           this.$message({ message: '无员工数据', type: 'info' })
           this.$message({ message: '无员工数据', type: 'info' })
         }
         }
       });
       });
     },
     },
-    upTableData(data){
-      // console.log("data:", data);
-      const that = this;
-      that.tableData = data;
-      that.tableData.sort((a, b) => a.c_xm.localeCompare(b.c_xm, 'zh-CN'))
-    },
-    setTableShow(data,text){
-      // console.log("data:", data);
+    setTableShow(text){
       const that = this;
       const that = this;
       that.tableShow = false;
       that.tableShow = false;
       // 使用 $nextTick 确保组件先销毁再重建
       // 使用 $nextTick 确保组件先销毁再重建
       that.$nextTick(() => {
       that.$nextTick(() => {
         that.tableShow = true;
         that.tableShow = true;
         that.tableSearchText = text;
         that.tableSearchText = text;
-        that.tableData = data;
-        that.tableData.sort((a, b) => a.c_xm.localeCompare(b.c_xm, 'zh-CN'))
+        that.handlePageChange(0,that.pageSize,that.tableSearchText);
       });
       });
       // console.log("that.tableSearchText:", that.tableSearchText);
       // console.log("that.tableSearchText:", that.tableSearchText);
     },
     },

+ 21 - 26
src/components/Table.vue

@@ -4,7 +4,7 @@
     <div style="padding: 10px;">
     <div style="padding: 10px;">
         <el-input v-model="searchText2" style="color: #000 !important;" size="small" placeholder="请输入姓名搜索" clearable :clear-icon="CloseBold" />
         <el-input v-model="searchText2" style="color: #000 !important;" size="small" placeholder="请输入姓名搜索" clearable :clear-icon="CloseBold" />
     </div>
     </div>
-    <el-table :data="paginatedTableData" style="height: 500px; overflow: auto;" >
+    <el-table :data="tableData" style="height: 500px; overflow: auto;" >
         <el-table-column
         <el-table-column
           v-for="item in modelFieldList"
           v-for="item in modelFieldList"
           :key="item.id"
           :key="item.id"
@@ -50,7 +50,7 @@ export default {
             dialogTableVisible: false,
             dialogTableVisible: false,
             modelFieldList:[],
             modelFieldList:[],
             currentPage: 1,
             currentPage: 1,
-            pageSize: 10,
+            pageSize: this.pageSize,
             searchText2:"",
             searchText2:"",
         }
         }
     },
     },
@@ -72,22 +72,32 @@ export default {
             default: ''
             default: ''
         },
         },
         close: Function,
         close: Function,
+        total: Number,
+        pageSize: Number,
+        page: Number,
+        handlePageChange: Function,
     },
     },
     watch: {
     watch: {
         tableData: {
         tableData: {
             handler: function (newVal, oldVal) {
             handler: function (newVal, oldVal) {
-                // tableData 变化时重置分页到第一页
-                console.log("newVal:", newVal);
-                this.currentPage = 1;
+                // console.log("newVal:", newVal);
+                this.updateTableData();
             },
             },
             deep: true
             deep: true
         },
         },
+        searchText2: {
+            handler: function (newVal, oldVal) {
+               this.currentPage = 1;
+               this.handlePageChange(this.currentPage-1,this.pageSize,newVal);
+                
+            },
+            deep: true
+        }
     },
     },
     created() {
     created() {
         let that = this;
         let that = this;
         that.searchText2 = that.searchText;
         that.searchText2 = that.searchText;
         that.dialogTableVisible = that.isview;
         that.dialogTableVisible = that.isview;
-        // console.log("that.searchText:", that.searchText);
         let modelFields = JSON.parse(this.columnModel.fieldList);
         let modelFields = JSON.parse(this.columnModel.fieldList);
         // 无序
         // 无序
         let keys = Object.keys(modelFields);
         let keys = Object.keys(modelFields);
@@ -109,39 +119,25 @@ export default {
         });
         });
     },
     },
     mounted() {
     mounted() {
+        this.updateTableData();
     },
     },
-    computed: {
-        filteredTableData() {
+    methods: {
+        updateTableData(){
             this.tableData.forEach((data) => {
             this.tableData.forEach((data) => {
                 data.sfzhm = data.c_sfzhm;
                 data.sfzhm = data.c_sfzhm;
                 data.sjhm = data.c_sjhm;
                 data.sjhm = data.c_sjhm;
                 data.c_sfzhm = this.formatCardNumber(data.c_sfzhm);
                 data.c_sfzhm = this.formatCardNumber(data.c_sfzhm);
                 data.c_sjhm = this.formatPhoneNumber(data.c_sjhm);
                 data.c_sjhm = this.formatPhoneNumber(data.c_sjhm);
             })
             })
-            if (!this.searchText2) {
-                return this.tableData;
-            }
-            return this.tableData.filter((data) => {
-                const nameField = data.c_xm || data.name;
-                return nameField && nameField.toString().includes(this.searchText2);
-            });
-        },
-        total() {
-            return this.filteredTableData.length;
         },
         },
-        paginatedTableData() {
-            const start = (this.currentPage - 1) * this.pageSize;
-            const end = start + this.pageSize;
-            return this.filteredTableData.slice(start, end);
-        }
-    },
-    methods: {
         handleSizeChange(val) {
         handleSizeChange(val) {
             this.pageSize = val;
             this.pageSize = val;
             this.currentPage = 1;
             this.currentPage = 1;
+            this.handlePageChange(this.currentPage-1,this.pageSize,this.searchText2);
         },
         },
         handleCurrentChange(val) {
         handleCurrentChange(val) {
             this.currentPage = val;
             this.currentPage = val;
+            this.handlePageChange(this.currentPage-1,this.pageSize,this.searchText2);
         },
         },
         formatCardNumber(cardNumber) {
         formatCardNumber(cardNumber) {
             if (!cardNumber) return "";
             if (!cardNumber) return "";
@@ -152,7 +148,6 @@ export default {
             return phone.replace(/(\d{3})\d{4}(\d{4})/, "$1****$2");
             return phone.replace(/(\d{3})\d{4}(\d{4})/, "$1****$2");
         },
         },
         handleEditClick(row) {
         handleEditClick(row) {
-            // console.log(row);
             this.$parent.getContentById(row);
             this.$parent.getContentById(row);
         },
         },
         dialogBeforeClose() {
         dialogBeforeClose() {

+ 2 - 18
src/views/IndexView.vue

@@ -84,19 +84,10 @@ export default {
       let requestParams = {
       let requestParams = {
         columnId: webConfig.columnArr[0].id,
         columnId: webConfig.columnArr[0].id,
         states: "0,1,2,3",
         states: "0,1,2,3",
-        orderBy: JSON.stringify([{ field: "update_time", orderByType: 2 }]),
+        orderBy: JSON.stringify([{ field: "c_xm", orderByType: 2 }]),
         pageSize: 99999,
         pageSize: 99999,
         page: 0,
         page: 0,
       };
       };
-      // requestParams.search = JSON.stringify([
-      //   ...(requestParams.search ? JSON.parse(requestParams.search) : []),
-      //   {
-      //     field: "c_xm",  // 申勤员工 c_xmguid   项目数据 c_guid
-      //     searchType: 2,
-      //     content: { value: that.searchText },
-      //   },
-      // ]);
-      showLoading();
       commonAPI.getDmsDataList(requestParams).then((res) => {
       commonAPI.getDmsDataList(requestParams).then((res) => {
         if (res.code == 200){
         if (res.code == 200){
           let data = res.content.data;
           let data = res.content.data;
@@ -116,18 +107,11 @@ export default {
           })
           })
           // console.log("data:", data);
           // console.log("data:", data);
           that.dataList = data;
           that.dataList = data;
-          // 数据更新后立即刷新表格
-          that.upTableData();
-          hideLoading();
         }else{
         }else{
           this.$message({ message: '无员工数据', type: 'info' })
           this.$message({ message: '无员工数据', type: 'info' })
-          hideLoading();
         }
         }
       });
       });
     },
     },
-    upTableData(){
-      this.$refs.childRef.upTableData(this.dataList);
-    },
     selectMap(map){
     selectMap(map){
       this.baseMap = map;
       this.baseMap = map;
       if(map == 'zwb'){
       if(map == 'zwb'){
@@ -247,7 +231,7 @@ export default {
           }
           }
         }else{
         }else{
           sessionStorage.setItem('guid', "");
           sessionStorage.setItem('guid', "");
-          that.$refs.childRef.setTableShow(that.dataList,that.searchText)
+          that.$refs.childRef.setTableShow(that.searchText)
         }
         }
     },
     },