import { v4 } from "uuid"; import {ConditionMode, NodeDataStruct, NodePortStruct, NodeStruct, NodeType} from "@/views/workflow/types"; import rootNodeDefault from "@/views/workflow/instance/root/default"; import answerNodeDefault from "@/views/workflow/instance/answer/default"; import ifElseNodeDefault from "@/views/workflow/instance/if-else/default"; import testNodeDefault from "@/views/workflow/instance/test/default"; export const lineStyle = { line: { stroke: '#8f8f8f', strokeWidth: 1, targetMarker: null }, } export const portStyle = { attrs: { fo: { width: 12, height: 12, x: -9, y: -9, magnet: true, }, }, } export const nodeDefault = { [NodeType.Test]: () => ({ x: 0, y: 0, data: { id: v4(), title: '测试节点', subTitle: '', ...testNodeDefault.defaultValue } }), [NodeType.Root]: () => ({ x: 0, y: 0, data: { id: v4(), title: '开始', subTitle: '', ...rootNodeDefault.defaultValue, } }), [NodeType.Answer]: () => ({ x: 0, y: 0, data: { id: v4(), title: '直接回复', subTitle: '', ...answerNodeDefault.defaultValue, } }), [NodeType.IfElse]: () => ({ x: 0, y: 0, data: { id: v4(), title: '条件分支', subTitle: '', ...ifElseNodeDefault.defaultValue, ports: [ { id: v4(), ...ifElseNodeDefault.caseValue }, { id: v4(), isElse: true }, ], } }), } export const getNodeDefault = (type: NodeType) => { const node = nodeDefault[type]() node.id = node.data.id node.data.type = type return node }