Browse Source

修改职员选中

zhaoke 3 years ago
parent
commit
5834cc23e5

+ 45 - 9
src/components/rolelist/index.vue

@@ -128,6 +128,8 @@ export default {
       loading: false,
       asyncData: [],
       msgDatas: [],
+      capDatas: [],
+      grpDatas: [],
       OpenGroup: null
     }
   },
@@ -156,6 +158,7 @@ export default {
     },
     checkBoxList: {
       handler (arr) {
+        console.log(arr)
         if (arr && arr.length) {
           this.asyncData.push(true)
         }
@@ -168,9 +171,9 @@ export default {
           if (this.roleType == 'account') {
             this.checkBoxs('UserId')
           }
-          if (this.roleType == 'onlyRole' || this.roleType == 'roleByUpId' || this.roleType === 'groups') {
-            this.checkBoxs('RoleId')
-          }
+          // if (this.roleType == 'onlyRole' || this.roleType == 'roleByUpId' || this.roleType === 'groups') {
+          //   this.checkBoxs('RoleId')
+          // }
         }
       },
       deep: true
@@ -180,9 +183,6 @@ export default {
         const obj = {}
         obj['GroupIds'] = 'GroupIds'
         this.msgDatas.push(obj)
-        // if (this.roleType == 'q') {
-        //   this.checkList = []
-        // }
       },
       deep: true
     },
@@ -216,7 +216,7 @@ export default {
           this.msg = -1
         }
       }
-    }
+    },
   },
   computed: {
     noMore () {
@@ -240,6 +240,11 @@ export default {
     //多选框
     checkChange (arr) {
       const datas = this.formatChecks(arr)
+      const arrs = []
+      arr.forEach(item => {
+        arrs.push(this.dataList[item])
+      })
+      this.capDatas = arrs
       // if (this.roleType == 'account') {
       //   datas = this.formatChecks(arr, 'UserId');
       // }
@@ -342,7 +347,18 @@ export default {
         this.loading = false
       }
     },
-
+    formatCheckBox () {
+      const caps = []
+      const arrs = this.capDatas.concat(this.checkBoxList)
+      this.dataList.forEach((item, index) => {
+        arrs.forEach(p => {
+          if (item['RoleId'] == p['RoleId']) {
+            caps.push(index)
+          }
+        })
+      })
+      this.checkList = caps
+    },
     //获取列表2
     async getRoleDataByUpId () {
       try {
@@ -350,6 +366,7 @@ export default {
         const obj = {
           GroupIds: this.GroupIds
         }
+        this.grpDatas.push(this.GroupIds)
         const result = await GetRoleByGroup(obj)
         if (result.code === 0) {
           const datas = result.returnData
@@ -366,7 +383,26 @@ export default {
             this.dataList = msgs
           }
           this.$emit('role-list-change', msgs)
-          // this.checkBoxs(this.dataList, "RoleId");
+          if (this.dataList.length) {
+            this.formatCheckBox()
+            const grpDatasTs = this.grpDatas;
+            if (grpDatasTs.length > 1) {
+              if (grpDatasTs[grpDatasTs.length - 1].length < grpDatasTs[grpDatasTs.length - 2].length) {
+                const wts = []
+                this.dataList.forEach(item => {
+                  this.capDatas.forEach(p => {
+                    if (item.RoleId == p.RoleId) {
+                      wts.push(item)
+                    }
+                  })
+                })
+                this.capDatas = wts
+              }
+            }
+          } else {
+            this.capDatas = []
+            this.msg = null
+          }
           this.loading = false
         } else {
           this.$message.error(result.message)

+ 16 - 8
src/views/staffManagement/compontents/staffAdd.vue

@@ -400,15 +400,16 @@ export default {
     //组织新增保存
     async saveOrgan () {
       try {
-        if (this.JobId) {
-          if (!this.AppId) {
-            this.$message.error("请选中一个组织后再新增");
-            return false;
-          }
-        }
+        // if (this.JobId) {
+        //   if (!this.AppId) {
+        //     this.$message.error("请选中一个组织后再新增");
+        //     return false;
+        //   }
+        // }
         const datas = [];
         const checks = [];
         const GroupIds = [];
+        const arrs = [];
         if (this.checkTrees.length) {
           this.checkTrees.forEach((item) => {
             datas.push(item.AuthList);
@@ -428,6 +429,14 @@ export default {
             checks.push(item);
           });
         }
+        if (this.lessData.length) {
+          this.lessData.forEach(item => {
+            const obj = {
+              JobId: item.OrganId || item.organId
+            }
+            arrs.push(obj);
+          });
+        }
         const res = await newstaff({
           OfficerName: this.form.name,
           OfficerDesc: this.form.app,
@@ -437,10 +446,9 @@ export default {
           RoleList: checks.length ? checks : [],
           AuthList: this.openRole ? [] : datas,
           TacList: this.loginCheckBoxs,
-          DepJobList: this.lessChecksData,
           GroupList: GroupIds.length ? GroupIds : [],
           JobId: this.JobId,
-          DepJobList: this.lessData,
+          DepJobList: arrs.length ? arrs : [],
           Status: 1,
           OrganId: this.AppId,
           OfficerId: this.OfficerId,

+ 11 - 3
src/views/staffManagement/compontents/staffEdit.vue

@@ -336,7 +336,7 @@ export default {
           if (DepJobList && DepJobList.length) {
             const datas = [];
             DepJobList.forEach(item => {
-              datas.push(item.organId);
+              datas.push(item.JobId);
             })
             this.checkedKeysDuo = datas;
           }
@@ -545,6 +545,7 @@ export default {
         const datas = [];
         const checks = [];
         const GroupIds = [];
+        const arrs = [];
         if (this.checkTrees.length) {
           this.checkTrees.forEach((item) => {
             datas.push(item.AuthList);
@@ -564,6 +565,14 @@ export default {
             checks.push(item);
           });
         }
+        if (this.lessData.length) {
+          this.lessData.forEach(item => {
+            const obj = {
+              JobId: item.OrganId || item.organId
+            }
+            arrs.push(obj);
+          });
+        }
         const res = await newstaffmod({
           OfficerName: this.form.name,
           OfficerDesc: this.form.app,
@@ -573,11 +582,10 @@ export default {
           RoleList: checks.length ? checks : [],
           AuthList: this.openRole ? [] : datas,
           TacList: this.loginCheckBoxs,
-          DepJobList: this.lessChecksData,
           GroupList: GroupIds.length ? GroupIds : [],
           JobId: this.JobId,
           Status: Number(this.Status),
-          DepJobList: this.lessData,
+          DepJobList: arrs.length ? arrs : [],
           OrganId: this.AppId,
           OfficerId: this.OfficerId,
           UserList: this.OpenAuthData ? this.checkBoxList : []