Forráskód Böngészése

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

shenqilong 1 éve
szülő
commit
7289827443
1 módosított fájl, 9 hozzáadás és 3 törlés
  1. 9 3
      src/business/platform/cat/type/tree.vue

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

@@ -122,12 +122,18 @@ export default {
         this.loadTreeData()
     },
     methods: {
-        loadTreeData() {
+        loadTreeData () {
             findTreeData({ categoryKey: this.categoryKey }).then(response => {
-                this.treeData = response.data || []
+                const data = response.data || []
                 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)
             })
         },