Browse Source

权限项管理权限树展开修改

zhongxiaoyu 3 years ago
parent
commit
dc4412d894

+ 23 - 9
src/components/organization/index.vue

@@ -150,17 +150,31 @@ export default {
       handler (val) {
         if (val.every(v => v)) {
           this.defaultExpandedKeys = [-1]
-          this.checkedKeys.forEach(key => {
-            if (key !== -1) {
-              const org = this.orgList.find(item => item.OrganId == key)
-              if (org) {
-                const OrganUpid = org.OrganUpid
-                if (!this.defaultExpandedKeys.includes(OrganUpid)) {
-                  this.defaultExpandedKeys.push(OrganUpid)
+          if (this.orgType === 'org') {
+            this.checkedKeys.forEach(key => {
+              if (key !== -1) {
+                const org = this.orgList.find(item => item.OrganId == key)
+                if (org) {
+                  const OrganUpid = org.OrganUpid
+                  if (!this.defaultExpandedKeys.includes(OrganUpid)) {
+                    this.defaultExpandedKeys.push(OrganUpid)
+                  }
                 }
               }
-            }
-          })
+            })
+          } else if (this.orgType === 'auth') {
+            this.checkedKeys.forEach(key => {
+              if (key !== -1) {
+                const auth = this.orgList.find(item => item.AuthId == key)
+                if (auth) {
+                  const UpAuthId = auth.UpAuthId
+                  if (!this.defaultExpandedKeys.includes(UpAuthId)) {
+                    this.defaultExpandedKeys.push(UpAuthId)
+                  }
+                }
+              }
+            })
+          }
         }
       },
       deep: true

+ 4 - 3
src/views/authorityManagement/components/authorityPowerAdd.vue

@@ -1,7 +1,7 @@
 <!--
  * @Author: your name
  * @Date: 2021-11-29 11:26:07
- * @LastEditTime: 2022-03-16 17:08:03
+ * @LastEditTime: 2022-03-17 12:06:54
  * @LastEditors: your name
  * @Description:权限项
  * @FilePath: \Foshan4A2.0\src\views\authorityManagement\components\authorityPower.vue
@@ -40,7 +40,7 @@
     </div>
     <div class="power-content flex-wrap">
       <div :class="!openRole && !OpenGroup ? '' : 'r24'" class="flex1 part">
-        <Organization :defaultProps="defaultProps" :checkedKeys="checkedKeys" @getTreeData="getTreeData" :orgType="orgType" :data="data" nodekey="AuthId" title="上级权限项" />
+        <Organization :defaultProps="defaultProps" :checkedKeys="checkedKeys" @getTreeData="getTreeData" :orgType="orgType" :orgList="orgList" :data="data" nodekey="AuthId" title="上级权限项" />
       </div>
       <!--有角色-->
       <template v-if="openRole">
@@ -124,7 +124,8 @@ export default {
       roleType: '',
       orgType: '',
       checkedKeys: [],
-      disabled: true
+      disabled: true,
+      orgList: []
     };
   },
   computed: {

+ 4 - 3
src/views/authorityManagement/components/authorityPowerEdit.vue

@@ -1,7 +1,7 @@
 <!--
  * @Author: your name
  * @Date: 2021-11-29 11:26:07
- * @LastEditTime: 2022-03-17 11:14:25
+ * @LastEditTime: 2022-03-17 12:05:58
  * @LastEditors: your name
  * @Description:权限项
  * @FilePath: \Foshan4A2.0\src\views\authorityManagement\components\authorityPower.vue
@@ -40,7 +40,7 @@
     </div>
     <div class="power-content flex-wrap">
       <div :class="!openRole && !OpenGroup ? '' : 'r24'" class="flex1 part">
-        <Organization :defaultProps="defaultProps" :checkedKeys="checkedKeys" @getTreeData="getTreeData" :orgType="orgType" :data="data" nodekey="AuthId" title="上级权限项" />
+        <Organization :defaultProps="defaultProps" :checkedKeys="checkedKeys" @getTreeData="getTreeData" :orgType="orgType" :orgList="orgList" :data="data" nodekey="AuthId" title="上级权限项" />
       </div>
       <!--有角色-->
       <template v-if="openRole">
@@ -124,7 +124,8 @@ export default {
       roleType: '',
       orgType: '',
       checkedKeys: [],
-      disabled: true
+      disabled: true,
+      orgList: []
     };
   },
   computed: {

+ 3 - 2
src/views/authorityManagement/minixs/treeData.js

@@ -1,8 +1,8 @@
 /*
  * @Author: your name
  * @Date: 2021-12-22 17:00:22
- * @LastEditTime: 2022-02-15 10:16:36
- * @LastEditors: Please set LastEditors
+ * @LastEditTime: 2022-03-17 12:05:21
+ * @LastEditors: your name
  * @Description: 获取权限树
  * @FilePath: \Foshan4A2.0\src\views\authorityManagement\minixs\treeData.js
  */
@@ -40,6 +40,7 @@ export default {
             disabled: true,
             children: translateDataToTreeAll(result.returnData, 'UpAuthId', 'AuthId')
           }
+          this.orgList = result.returnData
           this.dataList = obj
           this.dataArr = result.returnData;
           this.dataArr.push({

+ 13 - 3
src/views/organizationManagement/components/organizationAdd.vue

@@ -1,7 +1,7 @@
 <!--
  * @Author: your name
  * @Date: 2021-11-29 11:26:07
- * @LastEditTime: 2022-03-16 15:27:34
+ * @LastEditTime: 2022-03-17 11:40:21
  * @LastEditors: your name
  * @Description:新增组织
  * @FilePath: \Foshan4A2.0\src\views\authorityManagement\components\authorityPower.vue
@@ -52,7 +52,7 @@
     </div>
     <div class="power-content flex-wrap">
       <div class="flex1 part">
-        <Organization :defaultProps="defaultProps" :data="data" nodekey="OrganId" :checkedKeys="checkedKeys" title="上级组织" />
+        <Organization :defaultProps="defaultProps" :data="data" nodekey="OrganId" @getTreeData="getTreeData" :checkedKeys="checkedKeys" :orgList="orgList" title="上级组织" />
       </div>
     </div>
   </div>
@@ -129,6 +129,7 @@ export default {
       checkRoles: [], //选中的角色
       checkTrees: [], //上级权限选中树数据
       rulesObj: {}, //权限规则数据
+      orgList: []
     };
   },
   computed: {
@@ -140,7 +141,7 @@ export default {
       handler (val) {
         const arr = [val];
         this.decompose(arr, this.AppId);
-        this.data = [this.dataObj];
+        this.data = arr
         this.checkedKeys = [this.AppId];
       },
       deep: true,
@@ -159,6 +160,15 @@ export default {
     this.getOrganTree();
   },
   methods: {
+    //获取选中的树数据
+    getTreeData (arr) {
+      if (arr.length === 1) {
+        const { OrganId } = arr[0];
+        this.AppId = OrganId;
+      } else if (arr.length === 0) {
+        this.AppId = -1
+      }
+    },
     //获取指定数据
     decompose (data, id) {
       for (let i = 0; i < data.length; i++) {