瀏覽代碼

账号组管理修改

zhongxiaoyu 3 年之前
父節點
當前提交
bd8c332d12
共有 2 個文件被更改,包括 38 次插入45 次删除
  1. 14 9
      src/components/rolelist/index.vue
  2. 24 36
      src/views/accountGroupManagement/components/accountGroupEdit.vue

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

@@ -142,6 +142,9 @@ export default {
     },
     roleType: {
       handler (msg) {
+        if (msg === 'group') {
+          return
+        }
         const obj = {}
         obj[msg] = msg
         this.msgDatas.push(obj)
@@ -158,7 +161,6 @@ export default {
     },
     checkBoxList: {
       handler (arr) {
-        console.log(arr)
         if (arr && arr.length) {
           this.asyncData.push(true)
         }
@@ -179,7 +181,10 @@ export default {
       deep: true
     },
     GroupIds: {
-      handler () {
+      handler (val) {
+        if (val.length === 1 && val[0] === -1) {
+          return
+        }
         const obj = {}
         obj['GroupIds'] = 'GroupIds'
         this.msgDatas.push(obj)
@@ -188,20 +193,20 @@ export default {
     },
     msgDatas: {
       handler (arr) {
+        if (this.roleType === 'group' && this.GroupIds.length) {
+          this.getRoleDataByUpId()
+          return
+        } else if (this.roleType === 'onlyRole' && this.GroupIds.length === 1 && this.GroupIds[0] === -1) {
+          this.getRoleData('RoleId', 'RoleName')
+          return
+        }
         if (arr && arr.length >= 2) {
-          if (this.queryAll) {
-            this.getRoleData('RoleId', 'RoleName')
-          } else {
             this.getRoleDataByUpId()
-          }
         } else {
           if (this.roleType == 'account') {
             this.getRoleData('UserId', 'UserName')
           }
           if (!this.OpenGroup || this.needType) {
-            if (this.roleType == 'roleByUpId') {
-              this.getRoleDataByUpId('roleId')
-            }
             if (this.roleType == 'onlyRole') {
               this.getRoleData('RoleId', 'RoleName')
             }

+ 24 - 36
src/views/accountGroupManagement/components/accountGroupEdit.vue

@@ -67,8 +67,6 @@
               <RoleList
                 title="角色列表"
                 :role-type="roleType"
-                :needType="needType"
-                :queryAll="queryAll"
                 :group-ids="groupIds"
                 :check-box-list="roleListCheckedList"
                 :number="8"
@@ -174,9 +172,7 @@ export default {
       permissionTreeChckedTemp: [], // 权限树当前勾选项
       rulesOfCompetency: null, // 当前编辑的权限规则
       queryType: '',
-      queryAll: '',
       roleType: '',
-      needType: '',
       groupIds: [],
       queryIds: [],
       currentSelectedRoleId: -1,
@@ -219,18 +215,20 @@ export default {
     // console.log(obj)
     const { OpenRole } = obj
     this.openRole = OpenRole
-    this.accountGroupTreeCheckedTemp.push(this.GroupUpId)
-    this.queryIds.push(this.GroupUpId)
+    this.accountGroupTreeCheckedTemp = [this.GroupUpId]
+    this.queryIds = [this.GroupUpId]
     this.doesGroupExist && (this.GroupId = parseInt(this.$route.query.GroupId))
   },
   mounted() {
-    this.GroupUpId !== -1 && this.groupIds.push(this.GroupUpId)
+    if (this.GroupUpId !== -1) {
+      this.groupIds = [this.GroupUpId]
+      this.roleType = 'group'
+      } else {
+        this.groupIds = [-1]
+        this.roleType = 'onlyRole'
+    }
     if (this.doesGroupExist) {
       this.getGroupDetails()
-    } else {
-      this.roleType = 'onlyRole'
-      this.needType = 'yes'
-      this.queryType = 'all'
     }
     this.accountGroupTreeCheckedList = [this.GroupUpId]
   },
@@ -262,14 +260,6 @@ export default {
               this.permissionTreeChckedKeys.push(auth.AuthId)
               this.permissionTreeChckedTemp.push(auth)
             })
-          if (this.GroupUpId === -1) {
-            this.needType = 'yes'
-            this.roleType = 'onlyRole'
-            this.queryType = 'all'
-          } else {
-            this.roleType = 'roleByUpId'
-            this.queryType = 'group'
-          }
         } else {
           this.$message.error(res.message)
         }
@@ -294,24 +284,23 @@ export default {
     },
     // 获取当前勾选的岗位
     getAccountGroupChecked(arr) {
-      if (arr.length === 1 && arr[0] !== -1) {
-        console.log(arr[0])
-        const GroupIds = arr.map(item => item.GroupId)
-        this.accountGroupTreeCheckedTemp = GroupIds
-        this.needType = ''
-        this.queryAll = ''
-        this.roleType = 'groups'
-        this.groupIds = GroupIds
-        this.queryType = 'group'
-        this.queryIds = GroupIds
+      if (arr.length === 1) {
+        if (arr[0].GroupId === -1) {
+          this.groupIds = [-1]
+          this.accountGroupTreeCheckedTemp = [-1]
+          this.roleType = 'onlyRole'
+          this.queryType = 'all'
+        } else {
+          const GroupIds = arr.map(item => item.GroupId)
+          this.accountGroupTreeCheckedTemp = GroupIds
+          this.roleType = 'group'
+          this.groupIds = GroupIds
+          this.queryType = 'group'
+          this.queryIds = GroupIds
+          }
       } else if (arr.length === 0) {
-        this.accountGroupTreeCheckedTemp = [-1]
         this.accountGroupTreeCheckedList = [-1]
-        this.queryAll = 'yes'
-        this.needType = 'yes'
-        this.roleType = 'onlyRole'
-        this.roleListCheckedList = this.roleListCheckedCopy.map(role => role.RoleId)
-        this.queryType = 'all'
+        
       }
     },
     // 角色选取
@@ -385,7 +374,6 @@ export default {
         GroupUpid: this.accountGroupTreeCheckedTemp[0],
         RoleList: this.roleListCheckedTemp
       }
-
       if (this.doesGroupExist) {
         this.saveEditGroup({
           ...params,