|
@@ -1,8 +1,13 @@
|
|
import {Markup} from "@antv/x6";
|
|
import {Markup} from "@antv/x6";
|
|
import {merge} from "lodash";
|
|
import {merge} from "lodash";
|
|
import {lineStyle, portStyle} from "@/views/workflow/config";
|
|
import {lineStyle, portStyle} from "@/views/workflow/config";
|
|
|
|
+import { v4 } from "uuid";
|
|
|
|
|
|
-export const handleNode = (data) => {
|
|
|
|
|
|
+export const handleNode = (data, graph) => {
|
|
|
|
+ const id = v4()
|
|
|
|
+ if (!data.id) {
|
|
|
|
+ data.id = id
|
|
|
|
+ }
|
|
const node: any = {
|
|
const node: any = {
|
|
...data,
|
|
...data,
|
|
shape: 'workflow-node',
|
|
shape: 'workflow-node',
|
|
@@ -19,7 +24,8 @@ export const handleNode = (data) => {
|
|
{
|
|
{
|
|
name: 'contextmenu',
|
|
name: 'contextmenu',
|
|
args: {
|
|
args: {
|
|
- data
|
|
|
|
|
|
+ data,
|
|
|
|
+ graph,
|
|
}
|
|
}
|
|
}
|
|
}
|
|
]
|
|
]
|
|
@@ -61,7 +67,11 @@ export const handleNode = (data) => {
|
|
return node
|
|
return node
|
|
}
|
|
}
|
|
|
|
|
|
-export const handleEdge = (data) => {
|
|
|
|
|
|
+export const handleEdge = (data, graph) => {
|
|
|
|
+ const id = v4()
|
|
|
|
+ if (!data.id) {
|
|
|
|
+ data.id = id
|
|
|
|
+ }
|
|
const edge = {
|
|
const edge = {
|
|
...data,
|
|
...data,
|
|
shape: 'edge',
|
|
shape: 'edge',
|
|
@@ -77,11 +87,13 @@ export const handleEdge = (data) => {
|
|
{
|
|
{
|
|
name: 'contextmenu',
|
|
name: 'contextmenu',
|
|
args: {
|
|
args: {
|
|
- data
|
|
|
|
|
|
+ data,
|
|
|
|
+ graph,
|
|
}
|
|
}
|
|
}
|
|
}
|
|
]
|
|
]
|
|
}
|
|
}
|
|
|
|
+ edge.id = data.id
|
|
edge.source = {
|
|
edge.source = {
|
|
cell: data.source,
|
|
cell: data.source,
|
|
port: data.port || `${data.source}_end`
|
|
port: data.port || `${data.source}_end`
|