浏览代码

文件一览图更改递归逻辑

QuietShadow 3 年之前
父节点
当前提交
3d5e20ec77

+ 78 - 2
src/views/energyOperationSupport/components/securitys/pic1.vue

@@ -467,6 +467,7 @@
         } else {
           // this.chart.option.title.text = node.label;
         }
+        node.collapsed = false;
         this.graph.changeData(JSON.parse(JSON.stringify(node)));
         this.graph.fitView([140,40,20,40]);
       },
@@ -486,13 +487,14 @@
             if (res.code === '0') {
               let arr = [];
               // that.chart.height = res.data.length * 100 + 'px';
-              arr = that.treeDataUtil(res.data, '');
+              arr = that.treeDataUtil1(res.data, '1');
+              console.log(arr);
               // arr = that.getParentNodes(res.data, 1)
               arr[0].style = {
                 fill: '#f79646'
               };
               arr[0].id = '1';
-              arr[0].collapsed = false,
+              arr[0].collapsed = false;
                 that.chart.option.series[0].data = arr;
               // that.setGraphical();
               that.createGraphic();
@@ -749,6 +751,80 @@
           that.loading = false;
         })
       },
+      treeDataUtil1(treeData, id) {
+        let that = this;
+        let data = [];
+        let children = [];
+        let children1 = [];
+        let i = 0;
+        let k = 0;
+        let j = 0;
+        let g = 0;
+        let name = '';
+        let style = {};
+        let labelCfg = {};
+        switch (id.toString().split("-").length) {
+          case 2:
+          style = {
+            fill: '#e6b9b8',
+          };
+          break;
+          case 3:
+          style = {
+            fill: '#ffff66',
+          };
+          break;
+          case 4:
+          style = {
+            fill: '#d9d9d9',
+          };
+          break;
+          default:
+          break;
+        };
+        for (let item of treeData) {
+          i++;
+          if(item.children !== null) {
+            if(id === ''){
+              children = that.treeDataUtil1(item.children,i);
+            } else{
+              children = that.treeDataUtil1(item.children,id+'-'+ i);
+            }
+            name = item.createMan;
+          }
+          if(name===''){
+            name = item.createMan;
+          }
+          if(item.fileName != null && item.createMan === name) {
+            g++;
+            children.push({
+              id: id + '-' + (children.length+1),
+              label: item.fileName,
+              value: item.fileUrl,
+              children: [],
+            });
+          }
+          if( i < treeData.length-1 && treeData[i].createMan === name){
+            continue;
+          }
+            data.push({
+                collapsed: true,
+                id: id + '-' + i,
+                nodeType: 'node',
+                isCollapsed: true,
+                label: item.createMan,
+                children: children,
+                style: style,
+                labelCfg: labelCfg,
+              });
+            children = [];
+            name = '';
+        }
+        for (let ch of data) {
+          ch.id = ch.id.slice(2);
+        }
+        return data;
+      },
     },
   };
 </script>

+ 4 - 0
src/views/energyOperationSupport/components/securitys/register-node.js

@@ -24,13 +24,16 @@ export default G6 => {
       let textAlign = 'left'
       let content = cfg.label;
       let textFill = '#000000'
+      if(isNodeStyle) {
       switch (cfg.id.toString().split("-").length-1) {
         case 2:
           textFill = '#ff0000';
         break;
         default:
+        textFill = '#000000'
         break;
       };
+      }
       if (cfg.id === '1'){
         textFill = '#ffffff'
         fontSize = 22;
@@ -78,6 +81,7 @@ export default G6 => {
             markerFill = '#ff0000';
           break;
           default:
+          markerFill = '#181818';
           break;
         };
         const circleX = !isNodeStyle && style.width > size[0] ? (-style.width / 2 + size[0] + 22) : (attrs.width /