Ver Fonte

修改bug

chenrui há 1 ano atrás
pai
commit
f63ae1ca00
1 ficheiros alterados com 62 adições e 37 exclusões
  1. 62 37
      src/views/power/role/menuModal.vue

+ 62 - 37
src/views/power/role/menuModal.vue

@@ -1,35 +1,35 @@
 <template>
   <a-modal
-        centered
-        class="modalBox"
-        :title="roleName"
-        v-model="isshow"
-        @cancel="cancel"
-        :maskClosable="false">
-        <div style="min-height: 100px;">
-          <a-spin :spinning="spinning" tip="Loading...">
-            <a-form class="form-box" style="max-height: 600px;" :form="form" @submit="handleSubmit">
-            <a-tree
-              checkable
-              @check="onCheck"
-              @expand="onExpand"
-              :expandedKeys="expandedKeys"
-              :autoExpandParent="autoExpandParent"
-              v-model="checkedKeys"
-              :treeData="treeData"
-            />
-          </a-form>
-          <a-form-item :wrapper-col="{ offset: 15 }">
-            <a-button type="primary" @click="handleSubmit()" id="menuModal-handleSubmit">
-              保存
-            </a-button>
-            <a-button :style="{ marginLeft: '8px' }" @click="cancel" id="menuModal-handleCancel">
-              取消
-            </a-button>
-          </a-form-item>
-          </a-spin>
-        </div>
-      </a-modal>
+    centered
+    class="modalBox"
+    :title="roleName"
+    v-model="isshow"
+    @cancel="cancel"
+    :maskClosable="false">
+    <div style="min-height: 100px;">
+      <a-spin :spinning="spinning" tip="Loading...">
+        <a-form class="form-box" style="max-height: 600px;" :form="form" @submit="handleSubmit">
+          <a-tree
+            checkable
+            @check="onCheck"
+            @expand="onExpand"
+            :expandedKeys="expandedKeys"
+            :autoExpandParent="autoExpandParent"
+            v-model="checkedKeys"
+            :treeData="treeData"
+          />
+        </a-form>
+        <a-form-item :wrapper-col="{ offset: 15 }">
+          <a-button type="primary" @click="handleSubmit()" id="menuModal-handleSubmit">
+            保存
+          </a-button>
+          <a-button :style="{ marginLeft: '8px' }" @click="cancel" id="menuModal-handleCancel">
+            取消
+          </a-button>
+        </a-form-item>
+      </a-spin>
+    </div>
+  </a-modal>
 </template>
 
 <script>
@@ -44,7 +44,7 @@ export default {
     visible: {
       type: Boolean,
       default: false
-    },
+    }
   },
   data () {
     return {
@@ -126,27 +126,32 @@ export default {
         }
       }
     },
-    getmenuData(id){
+    getmenuData (id) {
       this.spinning = true
       getMenuList({
         id: id
       }).then(res => {
         if (res.status == 200) {
-          if(res.data.role){
+          if (res.data.role) {
             this.setmenuData(res.data)
-          }else{
-            this.$message.error("获取数据失败,请重试!")
+          } else {
+            this.$message.error('获取数据失败,请重试!')
             this.isshow = false
           }
         }
         this.spinning = false
       })
     },
-    setmenuData(newValue){
+    setmenuData (newValue) {
       this.menuData = newValue
       console.log(this.menuData)
       if (newValue) { // 编辑
-        this.treeData = this.menuData.allMenuList
+        if (this.$store.state.user.isShowSpecialPrice == 1) { // 特约经销商
+          const newChilderArr = this.filterTree(newValue.allMenuList)
+          this.treeData = newChilderArr
+        } else {
+          this.treeData = this.menuData.allMenuList
+        }
         this.id = this.menuData.role.id
         this.roleName = '分配权限' + '(' + this.menuData.role.name + ')'
         if (this.menuData.role.menuIds) {
@@ -157,6 +162,26 @@ export default {
         }
       }
     },
+    // 筛选子级中的不含市级价的树
+    filterTree (tree) {
+      return tree.map(node => {
+        // 创建当前节点的副本,避免直接修改原节点
+        const newNode = { ...node }
+        // 递归删除子节点中 name 等于 '市级价' 的节点
+        if (newNode.children) {
+          newNode.children = newNode.children.filter(child => {
+            // 如果子节点有子级,则递归处理
+            if (child.children && child.children.length > 0) {
+              child.children = this.filterTree(child.children)
+            }
+            // 返回不符合删除条件的子节点
+            return child.name != '市级价'
+          })
+        }
+        // 返回处理后的节点
+        return newNode
+      })
+    }
   },
   beforeCreate () {
     this.form = this.$form.createForm(this, { name: 'menuModal' })