vben
2021-01-19 ca4f1a8faf7d588c0d57d0dc81f4dc04cd757380
src/components/Form/src/hooks/useFormValues.ts
@@ -1,4 +1,4 @@
import { isArray, isFunction, isObject, isString } from '/@/utils/is';
import { isArray, isFunction, isObject, isString, isNullOrUnDef } from '/@/utils/is';
import { dateUtil } from '/@/utils/dateUtil';
import { unref, nextTick } from 'vue';
@@ -78,9 +78,10 @@
    const schemas = unref(getSchema);
    const obj: Recordable = {};
    schemas.forEach((item) => {
      if (item.defaultValue) {
        obj[item.field] = item.defaultValue;
        formModel[item.field] = item.defaultValue;
      const { defaultValue } = item;
      if (!isNullOrUnDef(defaultValue)) {
        obj[item.field] = defaultValue;
        formModel[item.field] = defaultValue;
      }
    });
    defaultValueRef.value = obj;