chore: Revert "fix: form 表单不支持field.xxx.xx格式的defaultValue配置 (#4965)"

This reverts commliit 12f216c0e7.
This commit is contained in:
vben
2024-12-02 00:47:06 +08:00
parent 014e6d38a0
commit 24b9aa44d2
6 changed files with 20 additions and 55 deletions

View File

@@ -86,14 +86,12 @@
"dayjs": "catalog:",
"defu": "catalog:",
"lodash.clonedeep": "catalog:",
"lodash.set": "catalog:",
"nprogress": "catalog:",
"tailwind-merge": "catalog:",
"theme-colors": "catalog:"
},
"devDependencies": {
"@types/lodash.clonedeep": "catalog:",
"@types/lodash.set": "catalog:",
"@types/nprogress": "catalog:"
}
}

View File

@@ -15,4 +15,3 @@ export * from './update-css-variables';
export * from './util';
export * from './window';
export { default as cloneDeep } from 'lodash.clonedeep';
export { default as set } from 'lodash.set';

View File

@@ -3,7 +3,7 @@ import type { FormActions, VbenFormProps } from './types';
import { computed, type ComputedRef, unref, useSlots } from 'vue';
import { createContext } from '@vben-core/shadcn-ui';
import { isString, set } from '@vben-core/shared/utils';
import { isString } from '@vben-core/shared/utils';
import { useForm } from 'vee-validate';
import { object, type ZodRawShape } from 'zod';
@@ -41,9 +41,9 @@ export function useFormInitial(
const zodObject: ZodRawShape = {};
(unref(props).schema || []).forEach((item) => {
if (Reflect.has(item, 'defaultValue')) {
set(initialValues, item.fieldName, item.defaultValue);
initialValues[item.fieldName] = item.defaultValue;
} else if (item.rules && !isString(item.rules)) {
set(zodObject, item.fieldName, item.defaultValue);
zodObject[item.fieldName] = item.rules;
}
});