Просмотр исходного кода

refactor(staffSelection): 统一重置页码和优化加载更多逻辑

liujt 5 месяцев назад
Родитель
Сommit
791fc83899

+ 7 - 6
src/views/documentManagement/certificateManagement/components/staffSelection.vue

@@ -182,7 +182,7 @@
       //选择分类
       handleNodeClick(data) {
         this.staffList = [];
-
+        this.pageNum = 1;
         this.form.groupId = data.id;
         let params = {
           pageNum: 1,
@@ -195,11 +195,7 @@
       async getStaffList(params) {
         let res = await getUserPage(params);
         let list = res.list;
-        if (this.staffList.length < res.count) {
-          this.isMore = true;
-        } else {
-          this.isMore = false;
-        }
+        
         list.forEach((el) => {
           let _index = this.selectStafflist.findIndex((n) => n.id == el.id);
           if (_index !== -1) {
@@ -209,6 +205,11 @@
           }
         });
         this.staffList = [...this.staffList, ...list];
+        if (this.staffList.length < res.count) {
+          this.isMore = true;
+        } else {
+          this.isMore = false;
+        }
         // this.pageNum = res.pageNum;
       },
       //查询更多员工

+ 7 - 6
src/views/enterpriseModel/dept/components/staffSelection.vue

@@ -190,7 +190,7 @@
       //选择分类
       handleNodeClick(data) {
         this.staffList = [];
-
+        this.pageNum = 1;
         this.form.groupId = data.id;
         let params = {
           pageNum: 1,
@@ -203,11 +203,7 @@
       async getStaffList(params) {
         let res = await getUserPage(params);
         let list = res.list;
-        if (this.staffList.length < res.count) {
-          this.isMore = true;
-        } else {
-          this.isMore = false;
-        }
+        
         list.forEach((el) => {
           let _index = this.selectStafflist.findIndex((n) => n.id == el.id);
           if (_index !== -1) {
@@ -217,6 +213,11 @@
           }
         });
         this.staffList = [...this.staffList, ...list];
+        if (this.staffList.length < res.count) {
+          this.isMore = true;
+        } else {
+          this.isMore = false;
+        }
         // this.pageNum = res.pageNum;
       },
       //查询更多员工

+ 7 - 6
src/views/factoryModel/qualificationManagement/components/staffSelection.vue

@@ -177,7 +177,7 @@
       //选择分类
       handleNodeClick(data) {
         this.staffList = [];
-
+        this.pageNum = 1;
         this.form.groupId = data.id;
         let params = {
           pageNum: 1,
@@ -190,11 +190,7 @@
       async getStaffList(params) {
         let res = await getUserPage(params);
         let list = res.list;
-        if (list.length < res.count) {
-          this.isMore = true;
-        } else {
-          this.isMore = false;
-        }
+        
         list.forEach((el) => {
           let _index = this.selectStafflist.findIndex((n) => n.id == el.id);
           if (_index !== -1) {
@@ -204,6 +200,11 @@
           }
         });
         this.staffList = [...this.staffList, ...list];
+        if (this.staffList.length < res.count) {
+          this.isMore = true;
+        } else {
+          this.isMore = false;
+        }
         // this.pageNum = res.pageNum;
       },
       //查询更多员工

+ 8 - 6
src/views/factoryModel/station/components/staffSelection.vue

@@ -179,6 +179,7 @@ export default {
     //选择分类
     handleNodeClick(data) {
       this.currentTree = data;
+      this.pageNum = 1;
       let params = {
         pageNum: 1,
         size: this.size,
@@ -192,11 +193,7 @@ export default {
     async getStaffList(params) {
       let res = await getAssetList(params);
       let list = res.list;
-      if (list.length < res.count) {
-        this.isMore = true;
-      } else {
-        this.isMore = false;
-      }
+      
       list.forEach((el) => {
         let _index = this.selectStafflist.findIndex((n) => n.id == el.id);
         if (_index !== -1) {
@@ -206,7 +203,12 @@ export default {
         }
       });
       this.staffList = [...this.staffList, ...list];
-      this.pageNum = res.pageNum;
+      if (this.staffList.length < res.count) {
+        this.isMore = true;
+      } else {
+        this.isMore = false;
+      }
+      // this.pageNum = res.pageNum;
     },
     //查询更多设备
     async getMore() {

+ 7 - 6
src/views/system/organization/components/staffSelection.vue

@@ -177,7 +177,7 @@ export default {
     //选择分类
     handleNodeClick(data) {
       this.staffList = [];
-
+      this.pageNum = 1;
       this.form.groupId = data.id;
       let params = {
         pageNum: 1,
@@ -190,11 +190,7 @@ export default {
     async getStaffList(params) {
       let res = await getUserPage(params);
       let list = res.list;
-      if (list.length < res.count) {
-        this.isMore = true;
-      } else {
-        this.isMore = false;
-      }
+      
       list.forEach((el) => {
         let _index = this.selectStafflist.findIndex((n) => n.id == el.id);
         if (_index !== -1) {
@@ -204,6 +200,11 @@ export default {
         }
       });
       this.staffList = [...this.staffList, ...list];
+      if (this.staffList.length < res.count) {
+        this.isMore = true;
+      } else {
+        this.isMore = false;
+      }
       // this.pageNum = res.pageNum;
     },
     //查询更多员工

+ 8 - 7
src/views/system/threeMembers/components/staffSelection.vue

@@ -203,7 +203,7 @@ export default {
     handleNodeClick(data) {
       this.currentData = data
       this.staffList = [];
-
+      this.pageNum = 1;
       this.form.groupId = data.id;
       let params = {
         pageNum: 1,
@@ -215,7 +215,7 @@ export default {
     },
     changeUserName() {
       this.staffList = [];
-
+      this.pageNum = 1;
       this.form.groupId = this.currentData.id;
       let params = {
         pageNum: 1,
@@ -229,11 +229,7 @@ export default {
     async getStaffList(params) {
       let res = await getUserPage(params);
       let list = res.list;
-      if (list.length < res.count) {
-        this.isMore = true;
-      } else {
-        this.isMore = false;
-      }
+      
       list.forEach((el) => {
         let _index = this.selectStafflist.findIndex((n) => n.id == el.id);
         if (_index !== -1) {
@@ -243,6 +239,11 @@ export default {
         }
       });
       this.staffList = [...this.staffList, ...list];
+      if (this.staffList.length < res.count) {
+        this.isMore = true;
+      } else {
+        this.isMore = false;
+      }
       // this.pageNum = res.pageNum;
     },
     //查询更多员工

+ 11 - 8
src/views/workforceManagement/team/components/staffSelection.vue

@@ -224,7 +224,7 @@
     handleNodeClick(data) {
       this.currentData = data
       this.staffList = [];
-
+      this.pageNum = 1;
       this.form.groupId = data.id;
       let params = {
         pageNum: 1,
@@ -236,7 +236,7 @@
     },
       changeUserName() {
         this.staffList = [];
-
+        this.pageNum = 1;
         this.form.groupId = this.currentData.id;
         let params = {
           pageNum: 1,
@@ -255,11 +255,7 @@
         }
       let res = await getUserPage(params);
       let list = res.list;
-      if (this.staffList.length < res.count) {
-        this.isMore = true;
-      } else {
-        this.isMore = false;
-      }
+      
       list.forEach((el) => {
         let _index = this.selectStafflist.findIndex((n) => n.id == el.id);
         if (_index !== -1) {
@@ -269,6 +265,12 @@
         }
       });
       this.staffList = [...this.staffList, ...list];
+      
+      if (this.staffList.length < res.count) {
+        this.isMore = true;
+      } else {
+        this.isMore = false;
+      }
       // this.pageNum = res.pageNum;
     },
     //查询更多员工
@@ -277,7 +279,8 @@
       let params = {
         pageNum:this.pageNum,
         size: this.size,
-        groupId: this.form.groupId
+        groupId: this.form.groupId,
+        name: this.userName
       };
       this.getStaffList(params);
     },