Bladeren bron

树形结构

panxiandiao_i 5 jaren geleden
bovenliggende
commit
5c7de833a3
1 gewijzigde bestanden met toevoegingen van 18 en 0 verwijderingen
  1. 18 0
      src/views/quality/qualityMeasurement.vue

+ 18 - 0
src/views/quality/qualityMeasurement.vue

@@ -523,6 +523,7 @@ export default {
         this.dealWithBusinessDate = JSON.parse(JSON.stringify(this.businessData)) // 深拷贝
         this.dealWithBusinessDate = processFunc(this.dealWithBusinessDate)
         this.pauseTreeNode = this.businessData[0] ? this.businessData[0] : ''
+        this.treeGuide(this.businessData, this.pauseTreeNode.id)
         this.pauseKey = 0
       })
       this.allCountAndProlemGet()
@@ -621,6 +622,23 @@ export default {
       })
       window.open(href, '_blank')
     },
+    // 树形结构导航
+    treeGuide(myArr, id) {
+      let res
+      // path,存储路径
+      const getPath = (arr, id, path = []) => {
+        return arr.reduce((a, c) => {
+          if (c.id === id) {
+            res = [...path, c.name]
+          }
+          if (c.children) {
+            return getPath(c.children, id, [...path, c.name])
+          }
+        }, [])
+      }
+      getPath(myArr, id)
+      console.log(res)
+    },
     // 业务树
     handleNodeClick(data) {
       this.loadingOnlineProcess = true