diff --git a/frontend/src/pages/Workflow/Definition/Designer/validate.ts b/frontend/src/pages/Workflow/Definition/Designer/validate.ts index e91a7867..a14ff809 100644 --- a/frontend/src/pages/Workflow/Definition/Designer/validate.ts +++ b/frontend/src/pages/Workflow/Definition/Designer/validate.ts @@ -15,7 +15,7 @@ export const validateFlow = (graph: Graph): ValidationResult => { const edges = graph.getEdges(); // 验证开始节点 - const startNodes = nodes.filter(node => node.getData()?.type === 'START'); + const startNodes = nodes.filter(node => node.getData()?.type === 'startEvent'); if (startNodes.length === 0) { result.errors.push('流程必须包含一个开始节点'); result.valid = false; @@ -25,7 +25,7 @@ export const validateFlow = (graph: Graph): ValidationResult => { } // 验证结束节点 - const endNodes = nodes.filter(node => node.getData()?.type === 'END'); + const endNodes = nodes.filter(node => node.getData()?.type === 'endEvent'); if (endNodes.length === 0) { result.errors.push('流程必须包含至少一个结束节点'); result.valid = false; @@ -39,17 +39,17 @@ export const validateFlow = (graph: Graph): ValidationResult => { const nodeType = nodeData?.type; const nodeName = nodeData?.name || '未命名'; - if (nodeType === 'START' && incomingEdges.length > 0) { + if (nodeType === 'startEvent' && incomingEdges.length > 0) { result.errors.push('开始节点不能有入边'); result.valid = false; } - if (nodeType === 'END' && outgoingEdges.length > 0) { + if (nodeType === 'endEvent' && outgoingEdges.length > 0) { result.errors.push('结束节点不能有出边'); result.valid = false; } - if (nodeType !== 'START' && nodeType !== 'END' && + if (nodeType !== 'startEvent' && nodeType !== 'endEvent' && (incomingEdges.length === 0 || outgoingEdges.length === 0)) { result.errors.push(`节点 "${nodeName}" 未完全连接`); result.valid = false; @@ -58,19 +58,23 @@ export const validateFlow = (graph: Graph): ValidationResult => { // 验证网关配对 const validateGatewayPairs = () => { - const gatewayNodes = nodes.filter(node => node.getData()?.type === 'GATEWAY'); + const gatewayNodes = nodes.filter(node => node.getData()?.type === 'exclusiveGateway'); gatewayNodes.forEach(gateway => { const outgoingEdges = graph.getOutgoingEdges(gateway) || []; const incomingEdges = graph.getIncomingEdges(gateway) || []; const gatewayData = gateway.getData(); const gatewayName = gatewayData?.name || '未命名'; - if (gatewayData?.config?.type === 'PARALLEL' || - gatewayData?.config?.type === 'INCLUSIVE') { - if (outgoingEdges.length < 2) { - result.errors.push(`并行/包容网关 "${gatewayName}" 必须有至少两个出口`); - result.valid = false; - } + // 排他网关必须至少有一个出口 + if (outgoingEdges.length < 1) { + result.errors.push(`排他网关 "${gatewayName}" 必须至少有一个出口`); + result.valid = false; + } + + // 排他网关必须有入口 + if (incomingEdges.length < 1) { + result.errors.push(`排他网关 "${gatewayName}" 必须至少有一个入口`); + result.valid = false; } }); };