Explorar el Código

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

Tanimodori hace 2 años
padre
commit
3cc72d6791
Se han modificado 1 ficheros con 3 adiciones y 1 borrados
  1. 3 1
      src/components/Form/src/hooks/useFormEvents.ts

+ 3 - 1
src/components/Form/src/hooks/useFormEvents.ts

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