Prechádzať zdrojové kódy

添加nextStep 事件

肖阳 3 rokov pred
rodič
commit
6fc8845ed8

+ 10 - 1
src/components/DrawFlow/src/DrawFlow.vue

@@ -34,6 +34,14 @@ export default {
       default() {
         return [];
       }
+    },
+    nextSteup: {
+      type: Function,
+      default() {
+        return () => {
+          return true;
+        };
+      }
     }
   },
   watch: {
@@ -130,7 +138,8 @@ export default {
     transformTree(data) {
       return transToTreeDat(data);
     },
-    clickSelectBox(nextNode) {
+    clickSelectBox(nextNode, pidNode) {
+      if (!this.nextSteup(nextNode, pidNode)) return;
       let { node, selfConfig } = this.getNodeFactory(nextNode);
       this.selfConfig = selfConfig.concat(node);
     },

+ 2 - 2
src/components/DrawFlow/src/components/AddNodeBtn.vue

@@ -28,9 +28,9 @@ export default {
       let el = document.getElementsByClassName("dingflow-design")[0];
       return el;
     },
-    clickSelectBox(nextNode) {
+    clickSelectBox(nextNode, pidNode) {
       this.popoVisible = false;
-      this.$emit("clickSelectBox", nextNode);
+      this.$emit("clickSelectBox", nextNode, pidNode);
     }
   },
   mounted() {},

+ 7 - 6
src/components/DrawFlow/src/components/DrawAddSelectBox/DrawAddBox.vue

@@ -43,7 +43,7 @@ export default {
         },
         {
           type: "6",
-          value: "流转至",
+          value: "阻止创建分支",
           isRow: false,
           calssName: "route",
           icon: "el-icon-s-operation"
@@ -57,12 +57,13 @@ export default {
     },
     getNexttBox(item) {
       const nodeConfig = this.nodeConfig;
-      if (item.value === "流转至") {
-        this.nodeConfig.isFlowTo = true;
-      }
-      let { id, prevId, type, isRow, title } = Object.assign(nodeConfig, item);
+      let { id, prevId, type, isRow, title } = Object.assign(
+        {},
+        nodeConfig,
+        item
+      );
       let nextNode = new NextNode({ id, prevId, type, isRow, title });
-      this.$emit("clickSelectBox", nextNode);
+      this.$emit("clickSelectBox", nextNode, nodeConfig);
     },
     renderAddSBox() {
       return (

+ 0 - 9
src/components/DrawFlow/src/utils/index.js

@@ -42,8 +42,6 @@ export function getColNode(colNodeArrs) {
       groupId: map[groupId][0].groupPid,
       type: "route",
       isRow: true,
-      // TODO "流转至" 应单独写配置文件
-      isFlowTo: map[groupId][0].type === "6",
       conditionNodes: map[groupId]
     };
     colNodesArr.push(obj);
@@ -161,13 +159,6 @@ export function transTree(arr) {
     p.isParent = true;
     p.childNode || (p.childNode = {});
     p.childNode = lis;
-    if (
-      p.childNode.conditionNodes &&
-      // TODO "流转至" 应单独写配置文件
-      p.childNode.conditionNodes[0].type === "6"
-    ) {
-      p.isFlowTo = true;
-    }
   }
   return nodes;
 }

+ 8 - 0
src/views/Home.vue

@@ -5,6 +5,7 @@
     <FactoryDrawFlow
       @clickNode="clickNode"
       ref="flow"
+      :nextSteup="nextSteup"
       :FlowConfig="FlowConfig"
     ></FactoryDrawFlow>
   </div>
@@ -96,6 +97,13 @@ export default {
     this.init();
   },
   methods: {
+    nextSteup(nextNode, pidNode) {
+      console.log(nextNode, pidNode, "nextNode");
+      if (nextNode.type === "6") {
+        return false;
+      }
+      return true;
+    },
     getData() {
       console.log(this.$refs.flow);
       let res = this.$refs.flow.getResData();