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