1
This commit is contained in:
parent
29fb84621d
commit
5f924a2f7d
@ -29,16 +29,6 @@ const NodeConfigDrawer: React.FC<NodeConfigDrawerProps> = ({
|
|||||||
onCancel,
|
onCancel,
|
||||||
}) => {
|
}) => {
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (visible && node && nodeDefinition) {
|
|
||||||
const currentConfig = node.getProp('config') || {};
|
|
||||||
if (!currentConfig.name) {
|
|
||||||
currentConfig.name = nodeDefinition.nodeName;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, [visible, node, nodeDefinition, form]);
|
|
||||||
|
|
||||||
// 在组件挂载或 nodeDefinition 更新时设置表单初始值
|
// 在组件挂载或 nodeDefinition 更新时设置表单初始值
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!nodeDefinition) return;
|
if (!nodeDefinition) return;
|
||||||
@ -81,12 +71,13 @@ const NodeConfigDrawer: React.FC<NodeConfigDrawerProps> = ({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
onOk({
|
const updatedNodeDefinition = {
|
||||||
uiVariables: nodeDefinition?.uiVariables || {},
|
...nodeDefinition,
|
||||||
panelVariables,
|
panelVariables: panelVariables,
|
||||||
localVariables,
|
localVariables: localVariables
|
||||||
formVariablesSchema: nodeDefinition?.formVariablesSchema || {}
|
};
|
||||||
});
|
// 返回更新后的完整节点定义
|
||||||
|
onOk(updatedNodeDefinition);
|
||||||
// form.resetFields();
|
// form.resetFields();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Validation failed:', error);
|
console.error('Validation failed:', error);
|
||||||
|
|||||||
@ -554,8 +554,16 @@ const WorkflowDesign: React.FC = () => {
|
|||||||
// 从节点定义列表中找到对应的定义
|
// 从节点定义列表中找到对应的定义
|
||||||
const nodeDefinition = nodeDefinitions.find(def => def.nodeType === nodeType);
|
const nodeDefinition = nodeDefinitions.find(def => def.nodeType === nodeType);
|
||||||
if (nodeDefinition) {
|
if (nodeDefinition) {
|
||||||
|
// 获取已保存的配置
|
||||||
|
const savedConfig = node.getProp('workflowDefinitionNode');
|
||||||
|
// 合并节点定义和已保存的配置
|
||||||
|
const mergedNodeDefinition = {
|
||||||
|
...nodeDefinition, // 基础定义
|
||||||
|
...savedConfig, // 已保存的配置(从后端加载的)
|
||||||
|
...node.getProp('graph') || {} // 当前会话中的修改(如果有)
|
||||||
|
};
|
||||||
setSelectedNode(node);
|
setSelectedNode(node);
|
||||||
setSelectedNodeDefinition(nodeDefinition);
|
setSelectedNodeDefinition(mergedNodeDefinition);
|
||||||
setConfigModalVisible(true);
|
setConfigModalVisible(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -1038,6 +1046,7 @@ const WorkflowDesign: React.FC = () => {
|
|||||||
const handleNodeConfigUpdate = (values: any) => {
|
const handleNodeConfigUpdate = (values: any) => {
|
||||||
if (!selectedNode) return;
|
if (!selectedNode) return;
|
||||||
const nodeDefinition = selectedNode.getProp('nodeDefinition');
|
const nodeDefinition = selectedNode.getProp('nodeDefinition');
|
||||||
|
console.log(values)
|
||||||
|
|
||||||
// 设置节点的 graph 属性,将所有数据统一放在 graph 下
|
// 设置节点的 graph 属性,将所有数据统一放在 graph 下
|
||||||
selectedNode.setProp('graph', {
|
selectedNode.setProp('graph', {
|
||||||
@ -1046,11 +1055,6 @@ const WorkflowDesign: React.FC = () => {
|
|||||||
localVariables: values.localVariables,
|
localVariables: values.localVariables,
|
||||||
formVariablesSchema: nodeDefinition?.formVariablesSchema || {}
|
formVariablesSchema: nodeDefinition?.formVariablesSchema || {}
|
||||||
});
|
});
|
||||||
|
|
||||||
// 为了向后兼容,同时也设置顶层属性
|
|
||||||
selectedNode.setProp('panelVariables', values.panelVariables);
|
|
||||||
selectedNode.setProp('localVariables', values.localVariables);
|
|
||||||
|
|
||||||
// 更新节点显示名称(如果存在)
|
// 更新节点显示名称(如果存在)
|
||||||
if (values.panelVariables?.name) {
|
if (values.panelVariables?.name) {
|
||||||
selectedNode.attr('label/text', values.panelVariables.name);
|
selectedNode.attr('label/text', values.panelVariables.name);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user