lilei 4 年 前
コミット
654d409fc4

+ 4 - 9
src/views/SupervisionAuth/role/menuModal.vue

@@ -102,6 +102,7 @@ export default {
       this.id = ''
       this.checkedKeys = []
     },
+    // 查找叶子节点
     findLeaf (data, arr) {
       for (let i = 0; i < data.length; i++) {
         const node = data[i]
@@ -112,6 +113,7 @@ export default {
             return item == node.id
           })
           if (hasNode) {
+            this.expandedKeys.push(node.id)
             this.checkedKeys.push(node.id)
           }
         }
@@ -131,19 +133,12 @@ export default {
           console.log(this.data)
           this.treeData = this.data.allMenuList
           this.id = this.data.role.id
-
           this.roleName = '分配权限' + '(' + this.data.role.name + ')'
           if (this.data.role.menuIds) {
             const arr = this.data.role.menuIds.split(',')
-            const temp = []
-            arr.map(item => {
-              temp.push(Number(item))
-            })
-            this.checkedData = temp
-            this.expandedKeys = temp
+            this.checkedData = arr
             // 找出叶子节点
-            this.findLeaf(this.treeData, temp)
-            console.log(this.treeData, '-----梳妆')
+            this.findLeaf(this.treeData, arr)
           }
         }
       } else {

+ 4 - 9
src/views/power/role/menuModal.vue

@@ -59,8 +59,6 @@ export default {
   },
   methods: {
     onExpand (expandedKeys) {
-      // if not set autoExpandParent to false, if children expanded, parent can not collapse.
-      // or, you can remove all expanded children keys.
       this.expandedKeys = expandedKeys
       this.autoExpandParent = false
     },
@@ -103,6 +101,7 @@ export default {
       this.id = ''
       this.checkedKeys = []
     },
+    // 查找叶子节点
     findLeaf (data, arr) {
       for (let i = 0; i < data.length; i++) {
         const node = data[i]
@@ -113,6 +112,7 @@ export default {
             return item == node.id
           })
           if (hasNode) {
+            this.expandedKeys.push(node.id)
             this.checkedKeys.push(node.id)
           }
         }
@@ -134,14 +134,9 @@ export default {
           this.roleName = '分配权限' + '(' + this.data.role.name + ')'
           if (this.data.role.menuIds) {
             const arr = this.data.role.menuIds.split(',')
-            const temp = []
-            arr.map(item => {
-              temp.push(Number(item))
-            })
-            this.checkedData = temp
-            this.expandedKeys = temp
+            this.checkedData = arr
             // 找出叶子节点
-            this.findLeaf(this.treeData, temp)
+            this.findLeaf(this.treeData, arr)
           }
         }
       } else {