12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- 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]: () => (<NodeStruct>{
- x: 0,
- y: 0,
- data: <NodeDataStruct>{
- id: v4(),
- title: '测试节点',
- subTitle: '',
- ...testNodeDefault.defaultValue
- }
- }),
- [NodeType.Root]: () => (<NodeStruct>{
- x: 0,
- y: 0,
- data: <NodeDataStruct>{
- id: v4(),
- title: '开始',
- subTitle: '',
- ...rootNodeDefault.defaultValue,
- }
- }),
- [NodeType.Answer]: () => (<NodeStruct>{
- x: 0,
- y: 0,
- data: <NodeDataStruct>{
- id: v4(),
- title: '直接回复',
- subTitle: '',
- ...answerNodeDefault.defaultValue,
- }
- }),
- [NodeType.IfElse]: () => (<NodeStruct>{
- x: 0,
- y: 0,
- data: <NodeDataStruct>{
- id: v4(),
- title: '条件分支',
- subTitle: '',
- ...ifElseNodeDefault.defaultValue,
- ports: <NodePortStruct[]>[
- {
- 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
- }
|