1
This commit is contained in:
parent
1914c67566
commit
31b07edfd4
@ -39,9 +39,10 @@ const ExpressionModal: React.FC<ExpressionModalProps> = ({
|
||||
<Form
|
||||
form={form}
|
||||
layout="vertical"
|
||||
initialValues={currentCondition || {
|
||||
type: 'EXPRESSION',
|
||||
priority: 10
|
||||
initialValues={{
|
||||
type: currentCondition?.type || 'EXPRESSION',
|
||||
expression: currentCondition?.expression || '',
|
||||
priority: currentCondition?.priority || 10
|
||||
}}
|
||||
>
|
||||
<Form.Item
|
||||
|
||||
@ -16,7 +16,7 @@ import {
|
||||
ZoomInOutlined,
|
||||
ZoomOutOutlined,
|
||||
} from '@ant-design/icons';
|
||||
import {Graph, Cell} from '@antv/x6';
|
||||
import {Graph, Cell, Edge} from '@antv/x6';
|
||||
import '@antv/x6-plugin-snapline';
|
||||
import '@antv/x6-plugin-selection';
|
||||
import '@antv/x6-plugin-keyboard';
|
||||
@ -854,7 +854,7 @@ const WorkflowDesign: React.FC = () => {
|
||||
]);
|
||||
});
|
||||
|
||||
// <EFBFBD><EFBFBD><EFBFBD>线工具移除
|
||||
// 线工具移除
|
||||
graph.on('edge:unselected', ({edge}) => {
|
||||
edge.removeTools();
|
||||
});
|
||||
@ -969,7 +969,7 @@ const WorkflowDesign: React.FC = () => {
|
||||
setNodeDefinitions(data);
|
||||
setIsNodeDefinitionsLoaded(true);
|
||||
} catch (error) {
|
||||
console.error('加载节点定义<EFBFBD><EFBFBD><EFBFBD>败:', 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,19 +1188,31 @@ const WorkflowDesign: React.FC = () => {
|
||||
}
|
||||
|
||||
// 获取所有节点和边的数据
|
||||
const nodes = graph.getNodes().map(node => ({
|
||||
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: node.getProp('nodeType'),
|
||||
nodeType: node.getProp('nodeType'),
|
||||
nodeCode: nodeType,
|
||||
nodeType: nodeType,
|
||||
nodeName: node.attr('label/text'),
|
||||
uiVariables: {
|
||||
...node.getProp('graph')?.uiVariables,
|
||||
position: node.getPosition()
|
||||
...uiVariables,
|
||||
position: position
|
||||
},
|
||||
panelVariables: node.getProp('graph')?.panelVariables,
|
||||
localVariables: node.getProp('graph')?.localVariables,
|
||||
formVariablesSchema: node.getProp('graph')?.formVariablesSchema
|
||||
}));
|
||||
panelVariables,
|
||||
localVariables,
|
||||
formVariablesSchema
|
||||
};
|
||||
});
|
||||
|
||||
const edges = graph.getEdges().map(edge => {
|
||||
const sourceNode = graph.getCellById(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;
|
||||
}
|
||||
|
||||
// 打印当前选择状态
|
||||
// 打印当前<EFBFBD><EFBFBD><EFBFBD>择状态
|
||||
console.log('Current selection before reset:', graph.getSelectedCells());
|
||||
graph.resetSelection();
|
||||
console.log('Selection after reset:', graph.getSelectedCells());
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user