fix(useFormEvent): 修复表单项存在defaultValue时,updateSchema方法会将setFieldsValue设置的值覆盖问题 (#3287)

This commit is contained in:
zhang 2023-11-17 11:56:04 +08:00 committed by GitHub
parent 3b2760ca3a
commit 72ef3df57f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,7 +2,7 @@ import type { ComputedRef, Ref } from 'vue';
import type { FormProps, FormSchemaInner as FormSchema, FormActionType } from '../types/form';
import type { NamePath } from 'ant-design-vue/lib/form/interface';
import { unref, toRaw, nextTick } from 'vue';
import { isArray, isFunction, isObject, isString, isDef, isNil, isEmpty } from '/@/utils/is';
import { isArray, isFunction, isObject, isString, isDef, isNil } from '/@/utils/is';
import { deepMerge } from '/@/utils';
import { dateItemType, handleInputNumberValue, defaultValueComponents } from '../helper';
import { dateUtil } from '/@/utils/dateUtil';
@ -310,9 +310,7 @@ export function useFormEvents({
Reflect.has(item, 'field') &&
item.field &&
!isNil(item.defaultValue) &&
(!(item.field in currentFieldsValue) ||
isNil(currentFieldsValue[item.field]) ||
isEmpty(currentFieldsValue[item.field]))
(!(item.field in currentFieldsValue) || isNil(currentFieldsValue[item.field]))
) {
obj[item.field] = item.defaultValue;
}