优化FormItemsRenderer

master
LiuJiaNan 2025-10-30 16:42:59 +08:00
parent 959859e668
commit 431e3cbc37
1 changed files with 32 additions and 30 deletions

View File

@ -297,14 +297,7 @@ const FormItemsRenderer = ({
return ( return (
option.customizeRender option.customizeRender
? (renderFormControl(option)) ? (renderFormControl(option))
: ( : (() => {
<Col key={option.name || index} span={itemSpan} style={style}>
<Form.Item
noStyle
shouldUpdate={option.shouldUpdate ?? option?.componentProps?.shouldUpdate}
dependencies={option.dependencies || option?.componentProps?.dependencies}
>
{() => {
// 支持动态计算 hidden // 支持动态计算 hidden
const hidden = typeof option.hidden === "function" const hidden = typeof option.hidden === "function"
? option.hidden(getFormValues()) ? option.hidden(getFormValues())
@ -313,6 +306,14 @@ const FormItemsRenderer = ({
if (hidden) if (hidden)
return null; return null;
return (
<Col key={option.name || index} span={itemSpan} style={style}>
<Form.Item
noStyle
shouldUpdate={option.shouldUpdate ?? option?.componentProps?.shouldUpdate}
dependencies={option.dependencies || option?.componentProps?.dependencies}
>
{() => {
return ( return (
<Form.Item <Form.Item
name={option.name} name={option.name}
@ -328,7 +329,8 @@ const FormItemsRenderer = ({
}} }}
</Form.Item> </Form.Item>
</Col> </Col>
) );
})()
); );
} }