This commit is contained in:
dengqichen 2024-12-20 14:30:26 +08:00
parent a6f0fb89a0
commit 7045d6ccf7

View File

@ -55,6 +55,7 @@ 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: (
@ -68,6 +69,7 @@ const NodeConfigDrawer: React.FC<NodeConfigDrawerProps> = ({
</Space> </Space>
), ),
rules: [{required, message: `请输入${property.title}`}], rules: [{required, message: `请输入${property.title}`}],
initialValue: property.default // 添加默认值支持
}; };
if (isReadOnly) { if (isReadOnly) {
@ -164,24 +166,27 @@ const NodeConfigDrawer: React.FC<NodeConfigDrawerProps> = ({
</Space> </Space>
} }
> >
<Tabs> <Form form={form} layout="vertical">
{nodeDefinition?.panelVariablesSchema && ( <Tabs>
<Tabs.TabPane tab="面板变量" key="panel"> {nodeDefinition?.panelVariablesSchema && (
{Object.entries(nodeDefinition.panelVariablesSchema.properties).map(([key, property]) => { <Tabs.TabPane tab="面板变量" key="panel">
const required = nodeDefinition.panelVariablesSchema?.properties.required?.includes(key) || false; {Object.entries(nodeDefinition.panelVariablesSchema.properties).map(([key, property]) => {
return renderFormItem(key, property as SchemaProperty, required, false); const required = nodeDefinition.panelVariablesSchema?.properties.required?.includes(key) || false;
})} return renderFormItem(key, property as SchemaProperty, required, false);
</Tabs.TabPane> })}
)} </Tabs.TabPane>
{nodeDefinition?.localVariablesSchema && ( )}
<Tabs.TabPane tab="环境变量" key="local"> {nodeDefinition?.localVariablesSchema && (
{Object.entries(nodeDefinition.localVariablesSchema.properties).map(([key, property]) => { <Tabs.TabPane tab="环境变量" key="local">
const required = nodeDefinition.localVariablesSchema?.properties.required?.includes(key) || false; {Object.entries(nodeDefinition.localVariablesSchema.properties).map(([key, property]) => {
return renderFormItem(key, property as SchemaProperty, required, true); console.log('NodeConfigModal - Local Schema Property:', key, property);
})} const required = nodeDefinition.localVariablesSchema?.properties.required?.includes(key) || false;
</Tabs.TabPane> return renderFormItem(key, property as SchemaProperty, required, true);
)} })}
</Tabs> </Tabs.TabPane>
)}
</Tabs>
</Form>
</Drawer> </Drawer>
); );
}; };