优化FormBuilder对Form.List支持

master
LiuJiaNan 2025-12-03 08:39:54 +08:00
parent b7758526de
commit 23b7e1beab
2 changed files with 5 additions and 6 deletions

View File

@ -52,7 +52,7 @@ export interface FormListUniqueProps {
/** 删除按钮的文本,默认 '删除' */
removeButtonText?: string;
/** 表单配置项 */
options: FormOption[] | ((field: FormListFieldData) => FormOption[]);
options: (field: FormListFieldData) => FormOption[];
/** 点击新增按钮时的默认值 */
addDefaultValue?: FormValues;
/** 点击新增按钮时插入的索引位置 */

View File

@ -385,14 +385,14 @@ const FormItemsRenderer = ({
};
// 渲染普通表单项
const renderFormItem = ({ option, style, col, index, name }) => {
const renderFormItem = ({ option, style, col, index }) => {
if (getHidden(option.hidden))
return null;
return (
<Col key={getKey(option) || index} span={col.span} style={style}>
<Form.Item
name={name || option.name}
name={option.name}
label={renderLabel(option)}
rules={getRules(option)}
labelCol={col.labelCol}
@ -407,7 +407,7 @@ const FormItemsRenderer = ({
};
// 渲染特殊类型的表单项
const renderOtherTypeItem = ({ option, style, col, index, name }) => {
const renderOtherTypeItem = ({ option, style, col, index }) => {
// 如果是 customizeRender 类型,完全交给外部控制渲染
if (option.customizeRender) {
return (
@ -422,7 +422,7 @@ const FormItemsRenderer = ({
return (
<Form.Item
key={getKey(option) || index}
name={name || option.name}
name={option.name}
noStyle
preserve={false}
>
@ -463,7 +463,6 @@ const FormItemsRenderer = ({
style,
col,
index: `${fieldIndex}_${listIndex}`,
name: [field.name, listOption.name],
};
const otherTypeItem = renderOtherTypeItem(params);
if (otherTypeItem)