CzRger 3 months ago
parent
commit
f318721e6d

+ 0 - 1
src/views/workflow/config.ts

@@ -21,7 +21,6 @@ export const portStyle = {
 }
 
 export const nodeDefault = {
-
   test: <NodeStruct>{
     id: '',
     x: 0,

+ 36 - 28
src/views/workflow/handle.ts

@@ -3,13 +3,19 @@ import {merge} from "lodash";
 import {lineStyle, portStyle} from "@/views/workflow/config";
 import { v4 } from "uuid";
 
-export const handleNode = (data, graph) => {
+export const handleNode = (no, graph) => {
   const id = v4()
-  if (!data.id) {
-    data.id = id
+  if (!no.id) {
+    no.id = id
   }
   const node: any = {
-    ...data,
+    id: no.id,
+    x: no.x,
+    y: no.y,
+    data: {
+      ...no.data,
+      id: no.id
+    },
     shape: 'workflow-node',
     portMarkup: [Markup.getForeignObjectMarkup()],
     ports: {
@@ -24,56 +30,67 @@ export const handleNode = (data, graph) => {
       {
         name: 'contextmenu',
         args: {
-          data,
+          data: no,
           graph,
         }
       }
     ]
   }
-  node.data.id = data.id
-  if (data.data.type !== 'root') {
+  if (node.data.type !== 'root') {
     node.ports.items.push({
-      id: `${data.id}_start`,
+      id: `${node.id}_start`,
       group: 'start',
       args: {
         type: 'start',
-        nodeId: data.id,
+        nodeId: node.id,
       }
     })
   }
-  if (data.data.ports?.length > 0) {
-    data.data.ports.forEach((p, pI) => {
+  if (node.data.ports?.length > 0) {
+    node.data.ports.forEach((p, pI) => {
       node.ports.items.push({
         id: p.id,
         group: 'more',
         args: {
           type: 'more',
           portId: p.id,
-          nodeId: data.id,
+          nodeId: node.id,
           dy: 0
         }
       })
     })
   } else {
     node.ports.items.push({
-      id: `${data.id}_end`,
+      id: `${node.id}_end`,
       group: 'end',
       args: {
         type: 'end',
-        nodeId: data.id,
+        nodeId: node.id,
       }
     })
   }
   return node
 }
 
-export const handleEdge = (data, graph) => {
+export const handleEdge = (ed, graph) => {
   const id = v4()
-  if (!data.id) {
-    data.id = id
+  if (!ed.id) {
+    ed.id = id
   }
   const edge = {
-    ...data,
+    id: ed.id,
+    source: {
+      cell: ed.source,
+      port: ed.port || `${ed.source}_end`
+    },
+    target: {
+      cell: ed.target,
+      port: `${ed.target}_start`
+    },
+    data: {
+      ...ed.data,
+      id: ed.id
+    },
     shape: 'edge',
     attrs: lineStyle,
     router: {
@@ -87,20 +104,11 @@ export const handleEdge = (data, graph) => {
       {
         name: 'contextmenu',
         args: {
-          data,
+          data: ed,
           graph,
         }
       }
     ]
   }
-  edge.id = data.id
-  edge.source = {
-    cell: data.source,
-    port: data.port || `${data.source}_end`
-  }
-  edge.target = {
-    cell: data.target,
-    port: `${data.target}_start`
-  }
   return edge
 }

+ 1 - 1
src/views/workflow/panel/index.vue

@@ -3,7 +3,7 @@
     <div class="panel" v-if="show">
       <div class="panel-header">
         <h3>{{ nodeDataCpt.title }}</h3>
-        <button @click="$emit('update:show', false)">×</button>
+        <div class="__hover" @click="$emit('update:show', false)">×</div>
       </div>
       <div class="panel-content">
         <template v-if="nodeDataCpt.type === 'root'">

+ 6 - 0
src/views/workflow/panel/root/default.ts

@@ -0,0 +1,6 @@
+const nodeDefault = {
+  defaultValue: {
+
+  }
+}
+export default nodeDefault