fix: 更新Schema时默认值不应覆盖已有值,fix #1997 (#2003)

This commit is contained in:
Tanimodori 2022-06-26 12:47:53 +08:00 committed by GitHub
parent fbcba766ae
commit 3cc72d6791
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -230,12 +230,14 @@ export function useFormEvents({
} }
const obj: Recordable = {}; const obj: Recordable = {};
const currentFieldsValue = getFieldsValue();
schemas.forEach((item) => { schemas.forEach((item) => {
if ( if (
item.component != 'Divider' && item.component != 'Divider' &&
Reflect.has(item, 'field') && Reflect.has(item, 'field') &&
item.field && item.field &&
!isNullOrUnDef(item.defaultValue) !isNullOrUnDef(item.defaultValue) &&
!(item.field in currentFieldsValue)
) { ) {
obj[item.field] = item.defaultValue; obj[item.field] = item.defaultValue;
} }