Browse Source

修复连续两个条件框删除其中一个,会导致全部删除的bug

肖阳 4 years ago
parent
commit
48e68c4bcc
1 changed files with 18 additions and 9 deletions
  1. 18 9
      src/components/DrawFlow/src/DrawFlow.vue

+ 18 - 9
src/components/DrawFlow/src/DrawFlow.vue

@@ -46,7 +46,6 @@ export default {
       },
       isColList: ["3", "5"],
       selfConfig: null,
-      selfTreeData: [],
       currentNode: null
     };
   },
@@ -78,7 +77,7 @@ export default {
     getResData() {
       let list = JSON.parse(JSON.stringify(this.selfConfig));
       getPidArr(list);
-      return { list, treeData: this.selfTreeData };
+      return list;
     },
     /**
      * 初始化 数据私有化
@@ -176,12 +175,10 @@ export default {
         repickConfig.id = node.id;
         let selfConfig = JSON.parse(JSON.stringify(this.selfConfig));
         this.selfConfig = this.deleteNode(selfConfig, node);
+        this.repickDeleteArr(repickConfig);
       } else {
-        repickConfig.groupId = node.groupPid;
-        repickConfig.id = node.groupId;
-        this.selfConfig = this.deleteColNode(node);
+        this.deleteColNode(node);
       }
-      this.selfConfig = this.repickDeleteArr(repickConfig);
     },
     // 删除节点
     deleteNode(selfConfig, node) {
@@ -195,10 +192,15 @@ export default {
         i => i.groupId === node.groupId && !i.isRow
       );
       let deleteArr = [];
+      let repickConfig;
       if (nodeArr.length > 2) {
         //递归删除所有关联子节点
         deleteArr = [node];
         this.deleteLoop(selfConfig, node, deleteArr);
+        repickConfig = {
+          id: node.id,
+          groupId: node.groupId
+        };
       } else {
         //删除整个group
         let allCol = selfConfig
@@ -208,14 +210,21 @@ export default {
         allCol.forEach(i => {
           this.deleteLoop(selfConfig, i, deleteArr);
         });
+        repickConfig = {
+          id: node.groupId,
+          groupId: node.groupPid
+        };
       }
       deleteArr.forEach(i => {
         selfConfig = this.deleteNode(selfConfig, i);
       });
+      this.selfConfig = selfConfig;
+      this.repickDeleteArr(repickConfig);
       return selfConfig;
     },
     // 循环遍历删除组下关联节点
     deleteLoop(selfConfig, node, deleteArr) {
+      console.log(selfConfig, node, "selfConfig");
       let currentDeleteArr = selfConfig.filter(i => {
         if (i.isRow) {
           return i.groupId === node.id;
@@ -242,11 +251,12 @@ export default {
       selfConfig.forEach(i => {
         if (i.isRow && i.groupId === repickConfig.id) {
           i.groupId = repickConfig.groupId;
-        } else if (i.groupPid === repickConfig.id) {
+        } else if (!i.isRow && i.groupPid === repickConfig.id) {
           i.groupPid = repickConfig.groupId;
         }
       });
-      return selfConfig;
+      this.selfConfig = selfConfig;
+      console.log(selfConfig, repickConfig, "groupPid");
     },
     //绘制body
     drawBody(h, node) {
@@ -264,7 +274,6 @@ export default {
     // this.init();
     let FlowConfig = this.selfConfig;
     FlowConfig = this.transformTree(FlowConfig);
-    this.selfTreeData = FlowConfig;
     const root = JSON.parse(JSON.stringify(this.selfConfig[0]));
     return (
       <div class="design-engine">