1
This commit is contained in:
parent
8cdf4ff318
commit
57fb736bfd
@ -39,10 +39,48 @@ const NodeConfigDrawer: React.FC<NodeConfigDrawerProps> = ({
|
|||||||
}
|
}
|
||||||
}, [visible, node, nodeDefinition, form]);
|
}, [visible, node, nodeDefinition, form]);
|
||||||
|
|
||||||
|
// 在组件挂载或 nodeDefinition 更新时设置表单初始值
|
||||||
|
useEffect(() => {
|
||||||
|
if (!nodeDefinition) return;
|
||||||
|
|
||||||
|
const initialValues = {
|
||||||
|
...nodeDefinition.panelVariables,
|
||||||
|
...nodeDefinition.localVariables
|
||||||
|
};
|
||||||
|
|
||||||
|
console.log('设置表单初始值:', initialValues);
|
||||||
|
form.setFieldsValue(initialValues);
|
||||||
|
}, [nodeDefinition, form]);
|
||||||
|
|
||||||
const handleOk = async () => {
|
const handleOk = async () => {
|
||||||
try {
|
try {
|
||||||
const values = await form.validateFields();
|
const values = await form.validateFields();
|
||||||
onOk(values);
|
// 将表单数据分离为 panelVariables 和 localVariables
|
||||||
|
const panelVariables = {};
|
||||||
|
const localVariables = {};
|
||||||
|
|
||||||
|
// 处理 panelVariablesSchema 中定义的字段
|
||||||
|
if (nodeDefinition?.panelVariablesSchema?.properties) {
|
||||||
|
Object.keys(nodeDefinition.panelVariablesSchema.properties).forEach(key => {
|
||||||
|
if (values[key] !== undefined) {
|
||||||
|
panelVariables[key] = values[key];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理 localVariablesSchema 中定义的字段
|
||||||
|
if (nodeDefinition?.localVariablesSchema?.properties) {
|
||||||
|
Object.keys(nodeDefinition.localVariablesSchema.properties).forEach(key => {
|
||||||
|
if (values[key] !== undefined) {
|
||||||
|
localVariables[key] = values[key];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
onOk({
|
||||||
|
panelVariables,
|
||||||
|
localVariables
|
||||||
|
});
|
||||||
form.resetFields();
|
form.resetFields();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Validation failed:', error);
|
console.error('Validation failed:', error);
|
||||||
@ -55,7 +93,6 @@ const NodeConfigDrawer: React.FC<NodeConfigDrawerProps> = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const renderFormItem = (key: string, property: SchemaProperty, required: boolean, isReadOnly: boolean) => {
|
const renderFormItem = (key: string, property: SchemaProperty, required: boolean, isReadOnly: boolean) => {
|
||||||
console.log('NodeConfigModal - renderFormItem:', { key, property, required, isReadOnly, default: property.default });
|
|
||||||
const baseProps = {
|
const baseProps = {
|
||||||
name: key,
|
name: key,
|
||||||
label: (
|
label: (
|
||||||
@ -154,7 +191,6 @@ const NodeConfigDrawer: React.FC<NodeConfigDrawerProps> = ({
|
|||||||
key: 'local',
|
key: 'local',
|
||||||
label: '环境变量',
|
label: '环境变量',
|
||||||
children: Object.entries(nodeDefinition.localVariablesSchema.properties).map(([key, property]) => {
|
children: Object.entries(nodeDefinition.localVariablesSchema.properties).map(([key, property]) => {
|
||||||
console.log('NodeConfigModal - Local Schema Property:', key, property);
|
|
||||||
const required = nodeDefinition.localVariablesSchema?.properties.required?.includes(key) || false;
|
const required = nodeDefinition.localVariablesSchema?.properties.required?.includes(key) || false;
|
||||||
return renderFormItem(key, property as SchemaProperty, required, true);
|
return renderFormItem(key, property as SchemaProperty, required, true);
|
||||||
})
|
})
|
||||||
|
|||||||
@ -1038,12 +1038,17 @@ const WorkflowDesign: React.FC = () => {
|
|||||||
// 处理节点配置更新
|
// 处理节点配置更新
|
||||||
const handleNodeConfigUpdate = (values: any) => {
|
const handleNodeConfigUpdate = (values: any) => {
|
||||||
if (!selectedNode) return;
|
if (!selectedNode) return;
|
||||||
|
|
||||||
// 更新节点配置
|
// 更新节点配置
|
||||||
console.log("// 更新节点配置", values);
|
console.log("更新节点配置", values);
|
||||||
selectedNode.setProp('config', values);
|
|
||||||
// 更新节点显示名称
|
// 更新 panelVariables 和 localVariables
|
||||||
if (values.name) {
|
selectedNode.setProp('panelVariables', values.panelVariables);
|
||||||
selectedNode.attr('label/text', values.name);
|
selectedNode.setProp('localVariables', values.localVariables);
|
||||||
|
|
||||||
|
// 更新节点显示名称(如果存在)
|
||||||
|
if (values.panelVariables?.name) {
|
||||||
|
selectedNode.attr('label/text', values.panelVariables.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
setConfigModalVisible(false);
|
setConfigModalVisible(false);
|
||||||
@ -1085,9 +1090,9 @@ const WorkflowDesign: React.FC = () => {
|
|||||||
// x: position.x,
|
// x: position.x,
|
||||||
// y: position.y
|
// y: position.y
|
||||||
// }
|
// }
|
||||||
uiVariables: nodeDefinition.uiVariables
|
// uiVariables: nodeDefinition.uiVariables
|
||||||
},
|
},
|
||||||
config: node.getProp('config') || {}
|
// config: node.getProp('config') || {}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user