Skip to content

Commit

Permalink
chore: Revert "fix: form 表单不支持field.xxx.xx格式的defaultValue配置 (#4965)"
Browse files Browse the repository at this point in the history
This reverts commliit 12f216c.
  • Loading branch information
anncwb committed Dec 1, 2024
1 parent 014e6d3 commit 24b9aa4
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 55 deletions.
2 changes: 0 additions & 2 deletions packages/@core/base/shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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:"
}
}
1 change: 0 additions & 1 deletion packages/@core/base/shared/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
6 changes: 3 additions & 3 deletions packages/@core/ui-kit/form-ui/src/use-form-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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;
}
});

Expand Down
6 changes: 0 additions & 6 deletions playground/src/views/examples/form/basic.vue
Original file line number Diff line number Diff line change
Expand Up @@ -291,12 +291,6 @@ const [CustomLayoutForm] = useVbenForm({
formItemClass: 'col-start-1',
label: '字符串',
},
{
component: 'Input',
defaultValue: 'field4.path',
fieldName: 'field4.path',
label: 'field4.path',
},
],
// 一共三列
wrapperClass: 'grid-cols-3',
Expand Down
54 changes: 15 additions & 39 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ catalog:
'@types/html-minifier-terser': ^7.0.2
'@types/jsonwebtoken': ^9.0.7
'@types/lodash.clonedeep': ^4.5.9
'@types/node': ^22.10.1
'@types/lodash.set': ^4.3.9
'@types/node': ^22.10.0
'@types/nprogress': ^0.2.3
'@types/postcss-import': ^14.0.3
'@types/qrcode': ^1.5.5
Expand Down Expand Up @@ -113,8 +112,7 @@ catalog:
jsonwebtoken: ^9.0.2
lint-staged: ^15.2.10
lodash.clonedeep: ^4.5.0
lucide-vue-next: ^0.462.0
lodash.set: ^4.3.2
lucide-vue-next: ^0.461.0
medium-zoom: ^1.1.0
naive-ui: ^2.40.2
nitropack: ^2.10.4
Expand Down

0 comments on commit 24b9aa4

Please sign in to comment.