1
This commit is contained in:
parent
c5dd9d00c2
commit
29fb84621d
@ -42,12 +42,10 @@ const NodeConfigDrawer: React.FC<NodeConfigDrawerProps> = ({
|
||||
// 在组件挂载或 nodeDefinition 更新时设置表单初始值
|
||||
useEffect(() => {
|
||||
if (!nodeDefinition) return;
|
||||
|
||||
const initialValues = {
|
||||
...nodeDefinition.panelVariables,
|
||||
...nodeDefinition.localVariables
|
||||
};
|
||||
|
||||
console.log('设置表单初始值:', initialValues);
|
||||
form.setFieldsValue(initialValues);
|
||||
}, [nodeDefinition, form]);
|
||||
@ -83,12 +81,13 @@ const NodeConfigDrawer: React.FC<NodeConfigDrawerProps> = ({
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
onOk({
|
||||
uiVariables: nodeDefinition?.uiVariables || {},
|
||||
panelVariables,
|
||||
localVariables
|
||||
localVariables,
|
||||
formVariablesSchema: nodeDefinition?.formVariablesSchema || {}
|
||||
});
|
||||
form.resetFields();
|
||||
// form.resetFields();
|
||||
} catch (error) {
|
||||
console.error('Validation failed:', error);
|
||||
}
|
||||
|
||||
@ -550,7 +550,7 @@ const WorkflowDesign: React.FC = () => {
|
||||
|
||||
// 节点双击事件
|
||||
graph.on('node:dblclick', ({node}) => {
|
||||
const nodeType = node.getProp('type');
|
||||
const nodeType = node.getProp('nodeType');
|
||||
// 从节点定义列表中找到对应的定义
|
||||
const nodeDefinition = nodeDefinitions.find(def => def.nodeType === nodeType);
|
||||
if (nodeDefinition) {
|
||||
@ -1037,11 +1037,17 @@ const WorkflowDesign: React.FC = () => {
|
||||
// 处理节点配置更新
|
||||
const handleNodeConfigUpdate = (values: any) => {
|
||||
if (!selectedNode) return;
|
||||
const nodeDefinition = selectedNode.getProp('nodeDefinition');
|
||||
|
||||
// 更新节点配置
|
||||
console.log("更新节点配置", values);
|
||||
// 设置节点的 graph 属性,将所有数据统一放在 graph 下
|
||||
selectedNode.setProp('graph', {
|
||||
uiVariables: nodeDefinition?.uiVariables || {},
|
||||
panelVariables: values.panelVariables,
|
||||
localVariables: values.localVariables,
|
||||
formVariablesSchema: nodeDefinition?.formVariablesSchema || {}
|
||||
});
|
||||
|
||||
// 更新 panelVariables 和 localVariables
|
||||
// 为了向后兼容,同时也设置顶层属性
|
||||
selectedNode.setProp('panelVariables', values.panelVariables);
|
||||
selectedNode.setProp('localVariables', values.localVariables);
|
||||
|
||||
@ -1060,38 +1066,21 @@ const WorkflowDesign: React.FC = () => {
|
||||
|
||||
try {
|
||||
// 校验流程图
|
||||
const validationResult = validateWorkflow(graph);
|
||||
if (!validationResult.valid) {
|
||||
message.error(validationResult.message);
|
||||
return;
|
||||
}
|
||||
// const validationResult = validateWorkflow(graph);
|
||||
// if (!validationResult.valid) {
|
||||
// message.error(validationResult.message);
|
||||
// return;
|
||||
// }
|
||||
|
||||
// 获取所有节点和边的数据
|
||||
const nodes = graph.getNodes().map(node => {
|
||||
const nodeDefinition = node.getProp('nodeDefinition');
|
||||
const nodeType = node.getProp('type');
|
||||
const position = node.getPosition();
|
||||
|
||||
const nodeType = node.getProp('nodeType');
|
||||
return {
|
||||
id: node.id,
|
||||
code: nodeType,
|
||||
type: nodeType,
|
||||
name: node.attr('label/text'),
|
||||
graph: {
|
||||
// shape: nodeDefinition?.graphConfig.uiSchema.shape,
|
||||
// size: {
|
||||
// width: node.size().width,
|
||||
// height: node.size().height
|
||||
// },
|
||||
// style: nodeDefinition?.graphConfig.uiSchema.style,
|
||||
// ports: nodeDefinition?.graphConfig.uiSchema.ports,
|
||||
// position: {
|
||||
// x: position.x,
|
||||
// y: position.y
|
||||
// }
|
||||
// uiVariables: nodeDefinition.uiVariables
|
||||
},
|
||||
// config: node.getProp('config') || {}
|
||||
nodeCode: nodeType,
|
||||
nodeType: nodeType,
|
||||
nodeName: node.attr('label/text'),
|
||||
...node.getProp('graph'),
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@ export const addNodeToGraph = (
|
||||
position?: { x: number; y: number }
|
||||
) => {
|
||||
let nodeDefinition = allNodeDefinitions.find(def => def.nodeType === currentNodeDefinition.nodeType);
|
||||
let uiVariables = isNew ? nodeDefinition.uiVariables : currentNodeDefinition.graph.uiVariables;
|
||||
let uiVariables = isNew ? nodeDefinition.uiVariables : currentNodeDefinition.uiVariables;
|
||||
// 根据形状类型设置正确的 shape
|
||||
let shape = 'rect'; // 默认使用矩形
|
||||
if (uiVariables.shape === 'circle') {
|
||||
@ -40,12 +40,12 @@ export const addNodeToGraph = (
|
||||
} : {})
|
||||
},
|
||||
label: {
|
||||
text: isNew ? nodeDefinition.nodeName : currentNodeDefinition.name
|
||||
text: isNew ? nodeDefinition.nodeName : currentNodeDefinition.nodeName
|
||||
},
|
||||
},
|
||||
shape,
|
||||
type: isNew ? nodeDefinition.nodeType : currentNodeDefinition.type,
|
||||
code: nodeDefinition.nodeCode,
|
||||
nodeType: isNew ? nodeDefinition.nodeType : currentNodeDefinition.nodeType,
|
||||
nodeCode: nodeDefinition.nodeCode,
|
||||
ports: convertPortConfig(uiVariables.ports),
|
||||
nodeDefinition: nodeDefinition
|
||||
};
|
||||
|
||||
@ -20,9 +20,9 @@ export interface WorkflowDefinition extends BaseResponse {
|
||||
|
||||
export interface WorkflowDefinitionNode {
|
||||
id: number;
|
||||
code: string;
|
||||
type: string;
|
||||
name: string;
|
||||
nodeCode: string;
|
||||
nodeType: string;
|
||||
nodeName: string;
|
||||
uiVariables: JSON;
|
||||
panelVariables: JSON;
|
||||
localVariables: JSON;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user