Commit 3cc72d67913c3fc44a774bd0da6430c45d9b3d9d

Authored by Tanimodori
Committed by GitHub
1 parent fbcba766

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

src/components/Form/src/hooks/useFormEvents.ts
@@ -230,12 +230,14 @@ export function useFormEvents({ @@ -230,12 +230,14 @@ export function useFormEvents({
230 } 230 }
231 231
232 const obj: Recordable = {}; 232 const obj: Recordable = {};
  233 + const currentFieldsValue = getFieldsValue();
233 schemas.forEach((item) => { 234 schemas.forEach((item) => {
234 if ( 235 if (
235 item.component != 'Divider' && 236 item.component != 'Divider' &&
236 Reflect.has(item, 'field') && 237 Reflect.has(item, 'field') &&
237 item.field && 238 item.field &&
238 - !isNullOrUnDef(item.defaultValue) 239 + !isNullOrUnDef(item.defaultValue) &&
  240 + !(item.field in currentFieldsValue)
239 ) { 241 ) {
240 obj[item.field] = item.defaultValue; 242 obj[item.field] = item.defaultValue;
241 } 243 }