feat(form): table 增加 beforeAddRow 钩子函数校验是否可增加行

This commit is contained in:
moonszhang 2023-12-20 14:29:02 +08:00 committed by roymondchen
parent 7c90b9339d
commit 2dcef449bf
2 changed files with 11 additions and 0 deletions

View File

@ -325,6 +325,15 @@ const newHandler = async (row?: any) => {
return;
}
if (typeof props.config.beforeAddRow === 'function') {
const beforeCheckRes = props.config.beforeAddRow(mForm, {
model: props.model[modelName.value],
formValue: mForm?.values,
prop: props.prop,
});
if (!beforeCheckRes) return;
}
const columns = props.config.items;
const enumValues = props.config.enum || [];
let enumV = [];

View File

@ -669,6 +669,8 @@ export interface TableConfig extends FormItem {
fixed?: boolean;
itemExtra?: string | FilterFunction<string>;
rowKey?: string;
/** table 新增行时前置回调 */
beforeAddRow?: (mForm: FormState | undefined, data: any) => boolean;
}
export interface GroupListConfig extends FormItem {