lilei 3 days ago
parent
commit
fc3c575078
2 changed files with 28 additions and 22 deletions
  1. 26 17
      src/views/power/role/menuModal.vue
  2. 2 5
      src/views/power/role/roleList.vue

+ 26 - 17
src/views/power/role/menuModal.vue

@@ -32,12 +32,11 @@
               @check="onCheck"
               @expand="onExpand"
               :expandedKeys="expandedKeys"
-              :defaultExpandAll="true"
               :autoExpandParent="autoExpandParent"
               v-model="checkedKeys"
               :treeData="treeData"
             >
-              <!-- <a-icon v-if="authType == 0" slot="switcherIcon" type="file" /> -->
+              <a-icon v-if="authType == 0" slot="switcherIcon" type="file" />
             </a-tree>
           </div>
           <a-form-model-item :label-col="{span: 0}" :wrapper-col="{span: 24}" style="text-align: center;margin: 18px 0 0;">
@@ -103,7 +102,9 @@ export default {
   methods: {
     // 展开/收起节点
     onExpand (expandedKeys) {
+      console.log(expandedKeys)
       this.expandedKeys = expandedKeys
+      // this.autoExpandParent = false
     },
     // 点击复选框
     onCheck (checkedKeys, info) {
@@ -319,24 +320,24 @@ export default {
         this.findPrice(treeData, this.checkedData)
         this.hasAllSelect()
       }
-      console.log(this.checkedKeys)
-      console.log(this.checkedData)
+      // console.log(this.checkedKeys)
+      // console.log(this.checkedData)
 
       this.treeData = treeData
 
-      // if (this.authType == 0) {
-      //   let leafNodes = []
-      //   setTimeout(() => {
-      //     if (leafNodes.length == 0) {
-      //       leafNodes = document.querySelectorAll('ul > li.leafNode:first-child')
-      //       for (let i = 0; i < leafNodes.length; i++) {
-      //         const cn = leafNodes[i].parentNode.className
-      //         leafNodes[i].parentNode.className += cn.indexOf('leafParent') < 0 ? ' leafParent' : ''
-      //         leafNodes[i].parentNode.parentNode.style.padding = '6px 0'
-      //       }
-      //     }
-      //   }, 100)
-      // }
+      if (this.authType == 0) {
+        let leafNodes = []
+        setTimeout(() => {
+          if (leafNodes.length == 0) {
+            leafNodes = document.querySelectorAll('ul > li.leafNode:first-child')
+            for (let i = 0; i < leafNodes.length; i++) {
+              const cn = leafNodes[i].parentNode.className
+              leafNodes[i].parentNode.className += cn.indexOf('leafParent') < 0 ? ' leafParent' : ''
+              leafNodes[i].parentNode.parentNode.style.padding = '6px 0'
+            }
+          }
+        }, 100)
+      }
     }
   },
   watch: {
@@ -358,6 +359,14 @@ export default {
       } else {
         this.priceOptions = this.$store.state.app.priceAuthOptions
       }
+    },
+    nowData: {
+      handler (newValue, oldValue) {
+        if (this.isshow && newValue) {
+          this.pageInit()
+        }
+      },
+      deep: true
     }
   }
 }

+ 2 - 5
src/views/power/role/roleList.vue

@@ -112,7 +112,7 @@
       <!-- 添加角色弹窗 -->
       <roleModal :visible="showModal" @refresh="$refs.table.refresh()" :nowData="itemData" @close="closeRole"></roleModal>
       <!-- 价格权限、功能权限弹窗 -->
-      <menuModal ref="menuModal" :visible="showMenuModal" @refresh="$refs.table.refresh()" :nowData="menuData" @close="showMenuModal = false"></menuModal>
+      <menuModal :visible="showMenuModal" @refresh="$refs.table.refresh()" :nowData="menuData" @close="showMenuModal = false"></menuModal>
     </a-card>
   </div>
 </template>
@@ -213,10 +213,7 @@ export default {
         if (res.status == 200) {
           _this.menuData = res.data
           _this.menuData.type = type
-          _this.showMenuModal = true
-          _this.$nextTick(() => {
-            _this.$refs.menuModal.pageInit()
-          })
+          this.showMenuModal = true
         }
       })
     },