优化FormItemsRenderer
parent
a875bda0d7
commit
d92cbe0b9e
|
|
@ -79,6 +79,8 @@ export interface FormOption {
|
||||||
shouldUpdate?: boolean | ((prevValues: FormValues, nextValues: FormValues, info: { source?: string }) => boolean);
|
shouldUpdate?: boolean | ((prevValues: FormValues, nextValues: FormValues, info: { source?: string }) => boolean);
|
||||||
/** 依赖字段(用于表单联动) */
|
/** 依赖字段(用于表单联动) */
|
||||||
dependencies?: NamePath[];
|
dependencies?: NamePath[];
|
||||||
|
/** 是否仅用于保存标签,不渲染到页面上,只在表单中保存数据,默认 false */
|
||||||
|
onlyForLabel?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -272,6 +272,20 @@ const FormItemsRenderer = ({
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{options.map((option, index) => {
|
{options.map((option, index) => {
|
||||||
|
// 如果是 onlyForLabel 类型,不渲染任何UI,只在表单中保存数据
|
||||||
|
if (option.onlyForLabel) {
|
||||||
|
return (
|
||||||
|
<Form.Item
|
||||||
|
key={getKey(option) || index}
|
||||||
|
name={option.name}
|
||||||
|
noStyle
|
||||||
|
preserve={false}
|
||||||
|
>
|
||||||
|
<input type="hidden" />
|
||||||
|
</Form.Item>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// 列数
|
// 列数
|
||||||
const itemSpan = option.render === FORM_ITEM_RENDER_ENUM.DIVIDER ? 24 : option.span ?? span;
|
const itemSpan = option.render === FORM_ITEM_RENDER_ENUM.DIVIDER ? 24 : option.span ?? span;
|
||||||
const itemLabelCol = option.labelCol ?? (itemSpan === 24 ? { span: labelCol.span / 2 } : labelCol);
|
const itemLabelCol = option.labelCol ?? (itemSpan === 24 ? { span: labelCol.span / 2 } : labelCol);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue