fix: form 表单不支持field.xxx.xx格式的defaultValue配置 (#4965)
* fix: form 表单不支持field.xxx.xx格式的defaultValue配置 * chore: 修复代码规范问题
This commit is contained in:
@@ -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 } from '@vben-core/shared/utils';
|
||||
import { isString, set } 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')) {
|
||||
initialValues[item.fieldName] = item.defaultValue;
|
||||
set(initialValues, item.fieldName, item.defaultValue);
|
||||
} else if (item.rules && !isString(item.rules)) {
|
||||
zodObject[item.fieldName] = item.rules;
|
||||
set(zodObject, item.fieldName, item.defaultValue);
|
||||
}
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user