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
1 changed files with 2 additions and 4 deletions

View File

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