diff --git a/frontend/src/pages/Workflow/Definition/Design/components/ExpressionModal.tsx b/frontend/src/pages/Workflow/Definition/Design/components/ExpressionModal.tsx index 839bb92c..e1c2b0c8 100644 --- a/frontend/src/pages/Workflow/Definition/Design/components/ExpressionModal.tsx +++ b/frontend/src/pages/Workflow/Definition/Design/components/ExpressionModal.tsx @@ -39,9 +39,10 @@ const ExpressionModal: React.FC = ({
{ ]); }); - // ���线工具移除 + // 线工具移除 graph.on('edge:unselected', ({edge}) => { edge.removeTools(); }); @@ -969,7 +969,7 @@ const WorkflowDesign: React.FC = () => { setNodeDefinitions(data); setIsNodeDefinitionsLoaded(true); } catch (error) { - console.error('加载节点定义���败:', error); + console.error('加载节点定义失败:', error); message.error('加载节点定义失败'); } }; @@ -1028,7 +1028,7 @@ const WorkflowDesign: React.FC = () => { return; } - graphInstance.addEdge({ + const newEdge = graphInstance.addEdge({ source: { cell: sourceNode.id, port: sourcePort, @@ -1048,9 +1048,19 @@ const WorkflowDesign: React.FC = () => { }, }, labels: [{ - attrs: {label: {text: edge.name || ''}} + attrs: { + label: { + text: edge.config?.condition?.expression || edge.name || '' + } + } }] }); + console.log(response.graph) + // 设置边的条件属性 + if (edge.config?.condition) { + newEdge.setProp('condition', edge.config.condition); + console.log('Setting edge condition:', edge.config.condition); + } } }); @@ -1178,24 +1188,36 @@ const WorkflowDesign: React.FC = () => { } // 获取所有节点和边的数据 - const nodes = graph.getNodes().map(node => ({ - id: node.id, - nodeCode: node.getProp('nodeType'), - nodeType: node.getProp('nodeType'), - nodeName: node.attr('label/text'), - uiVariables: { - ...node.getProp('graph')?.uiVariables, - position: node.getPosition() - }, - panelVariables: node.getProp('graph')?.panelVariables, - localVariables: node.getProp('graph')?.localVariables, - formVariablesSchema: node.getProp('graph')?.formVariablesSchema - })); + const nodes = graph.getNodes().map(node => { + const nodeType = node.getProp('nodeType'); + const graphData = node.getProp('graph') || {}; + const position = node.getPosition(); + const { + uiVariables, + panelVariables, + localVariables, + formVariablesSchema, + ...rest + } = graphData; + return { + id: node.id, + nodeCode: nodeType, + nodeType: nodeType, + nodeName: node.attr('label/text'), + uiVariables: { + ...uiVariables, + position: position + }, + panelVariables, + localVariables, + formVariablesSchema + }; + }); const edges = graph.getEdges().map(edge => { const sourceNode = graph.getCellById(edge.getSourceCellId()); const condition = edge.getProp('condition'); - + return { id: edge.id, from: edge.getSourceCellId(), @@ -1208,13 +1230,18 @@ const WorkflowDesign: React.FC = () => { }; }); + // 收集并合并所有节点的 formVariablesSchema + const allFormSchemas = nodes.map(node => node.formVariablesSchema).filter(schema => schema); // 过滤掉空值 + const mergedFormSchema = mergeFormVariablesSchemas(allFormSchemas); + // 构建保存数据 const saveData = { ...definitionData, graph: { nodes, edges - } + }, + formVariablesSchema: mergedFormSchema }; // 调用保存接口 @@ -1356,7 +1383,7 @@ const WorkflowDesign: React.FC = () => { return; } - // 打印当前选择状态 + // 打印当前���择状态 console.log('Current selection before reset:', graph.getSelectedCells()); graph.resetSelection(); console.log('Selection after reset:', graph.getSelectedCells()); diff --git a/frontend/src/pages/Workflow/Definition/Design/types.ts b/frontend/src/pages/Workflow/Definition/Design/types.ts index 96f3d931..fa34e1e3 100644 --- a/frontend/src/pages/Workflow/Definition/Design/types.ts +++ b/frontend/src/pages/Workflow/Definition/Design/types.ts @@ -1,9 +1,26 @@ // 节点类型 -export type NodeType = 'START_EVENT' | 'END_EVENT' | 'USER_TASK' | 'SERVICE_TASK' | 'SCRIPT_TASK' | 'EXCLUSIVE_GATEWAY' | 'PARALLEL_GATEWAY' | 'SUB_PROCESS' | 'CALL_ACTIVITY'; +export type NodeType = 'START_EVENT' | 'END_EVENT' | 'USER_TASK' | 'SERVICE_TASK' | 'SCRIPT_TASK' | 'GATEWAY_NODE' | 'SUB_PROCESS' | 'CALL_ACTIVITY'; // 节点分类 export type NodeCategory = 'EVENT' | 'TASK' | 'GATEWAY' | 'CONTAINER'; +// 条件类型 +export type ConditionType = 'EXPRESSION' | 'SCRIPT' | 'DEFAULT'; + +// 边的条件配置 +export interface EdgeCondition { + type: ConditionType; + expression?: string; + script?: string; + priority: number; +} + +// 边的配置 +export interface EdgeConfig { + type: 'sequence'; + condition?: EdgeCondition; +} + // 节点定义 export interface NodeDefinition { id: number;