Эх сурвалжийг харах

处理isshow父节点不显示所以子节点也不显示

shenqilong 1 жил өмнө
parent
commit
7289827443

+ 9 - 3
src/business/platform/cat/type/tree.vue

@@ -122,12 +122,18 @@ export default {
         this.loadTreeData()
         this.loadTreeData()
     },
     },
     methods: {
     methods: {
-        loadTreeData() {
+        loadTreeData () {
             findTreeData({ categoryKey: this.categoryKey }).then(response => {
             findTreeData({ categoryKey: this.categoryKey }).then(response => {
-                this.treeData = response.data || []
+                const data = response.data || []
                 if (this.hasPermission) {
                 if (this.hasPermission) {
-                    this.treeData = this.treeData.filter(i => i.isShow !== '1')
+                    // this.treeData = this.treeData.filter(i => i.isShow !== '1')
+                    // 处理isShow,父级节点不显示子节点都不显示
+                    const noData = data.filter(item => item.isShow === '1')
+                    const noIdList = noData.map((obj, index) => { return obj.id }).join(',').split(',')
+                    const tree = data.filter(item => item.isShow !== '1' && !noIdList.includes(item.parentId))
+                    this.treeData = tree
                 }
                 }
+
                 this.$emit('treeData', response.data)
                 this.$emit('treeData', response.data)
             })
             })
         },
         },