1
This commit is contained in:
parent
1914c67566
commit
31b07edfd4
@ -39,9 +39,10 @@ const ExpressionModal: React.FC<ExpressionModalProps> = ({
|
|||||||
<Form
|
<Form
|
||||||
form={form}
|
form={form}
|
||||||
layout="vertical"
|
layout="vertical"
|
||||||
initialValues={currentCondition || {
|
initialValues={{
|
||||||
type: 'EXPRESSION',
|
type: currentCondition?.type || 'EXPRESSION',
|
||||||
priority: 10
|
expression: currentCondition?.expression || '',
|
||||||
|
priority: currentCondition?.priority || 10
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Form.Item
|
<Form.Item
|
||||||
|
|||||||
@ -16,7 +16,7 @@ import {
|
|||||||
ZoomInOutlined,
|
ZoomInOutlined,
|
||||||
ZoomOutOutlined,
|
ZoomOutOutlined,
|
||||||
} from '@ant-design/icons';
|
} 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-snapline';
|
||||||
import '@antv/x6-plugin-selection';
|
import '@antv/x6-plugin-selection';
|
||||||
import '@antv/x6-plugin-keyboard';
|
import '@antv/x6-plugin-keyboard';
|
||||||
@ -854,7 +854,7 @@ const WorkflowDesign: React.FC = () => {
|
|||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
// <EFBFBD><EFBFBD><EFBFBD>线工具移除
|
// 线工具移除
|
||||||
graph.on('edge:unselected', ({edge}) => {
|
graph.on('edge:unselected', ({edge}) => {
|
||||||
edge.removeTools();
|
edge.removeTools();
|
||||||
});
|
});
|
||||||
@ -969,7 +969,7 @@ const WorkflowDesign: React.FC = () => {
|
|||||||
setNodeDefinitions(data);
|
setNodeDefinitions(data);
|
||||||
setIsNodeDefinitionsLoaded(true);
|
setIsNodeDefinitionsLoaded(true);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('加载节点定义<EFBFBD><EFBFBD><EFBFBD>败:', error);
|
console.error('加载节点定义失败:', error);
|
||||||
message.error('加载节点定义失败');
|
message.error('加载节点定义失败');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -1028,7 +1028,7 @@ const WorkflowDesign: React.FC = () => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
graphInstance.addEdge({
|
const newEdge = graphInstance.addEdge({
|
||||||
source: {
|
source: {
|
||||||
cell: sourceNode.id,
|
cell: sourceNode.id,
|
||||||
port: sourcePort,
|
port: sourcePort,
|
||||||
@ -1048,9 +1048,19 @@ const WorkflowDesign: React.FC = () => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
labels: [{
|
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 => ({
|
const nodes = graph.getNodes().map(node => {
|
||||||
id: node.id,
|
const nodeType = node.getProp('nodeType');
|
||||||
nodeCode: node.getProp('nodeType'),
|
const graphData = node.getProp('graph') || {};
|
||||||
nodeType: node.getProp('nodeType'),
|
const position = node.getPosition();
|
||||||
nodeName: node.attr('label/text'),
|
const {
|
||||||
uiVariables: {
|
uiVariables,
|
||||||
...node.getProp('graph')?.uiVariables,
|
panelVariables,
|
||||||
position: node.getPosition()
|
localVariables,
|
||||||
},
|
formVariablesSchema,
|
||||||
panelVariables: node.getProp('graph')?.panelVariables,
|
...rest
|
||||||
localVariables: node.getProp('graph')?.localVariables,
|
} = graphData;
|
||||||
formVariablesSchema: node.getProp('graph')?.formVariablesSchema
|
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 edges = graph.getEdges().map(edge => {
|
||||||
const sourceNode = graph.getCellById(edge.getSourceCellId());
|
const sourceNode = graph.getCellById(edge.getSourceCellId());
|
||||||
const condition = edge.getProp('condition');
|
const condition = edge.getProp('condition');
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: edge.id,
|
id: edge.id,
|
||||||
from: edge.getSourceCellId(),
|
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 = {
|
const saveData = {
|
||||||
...definitionData,
|
...definitionData,
|
||||||
graph: {
|
graph: {
|
||||||
nodes,
|
nodes,
|
||||||
edges
|
edges
|
||||||
}
|
},
|
||||||
|
formVariablesSchema: mergedFormSchema
|
||||||
};
|
};
|
||||||
|
|
||||||
// 调用保存接口
|
// 调用保存接口
|
||||||
@ -1356,7 +1383,7 @@ const WorkflowDesign: React.FC = () => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 打印当前选择状态
|
// 打印当前<EFBFBD><EFBFBD><EFBFBD>择状态
|
||||||
console.log('Current selection before reset:', graph.getSelectedCells());
|
console.log('Current selection before reset:', graph.getSelectedCells());
|
||||||
graph.resetSelection();
|
graph.resetSelection();
|
||||||
console.log('Selection after reset:', graph.getSelectedCells());
|
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 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 {
|
export interface NodeDefinition {
|
||||||
id: number;
|
id: number;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user