diff --git a/apps/web-ele/src/api/core/auth.ts b/apps/web-ele/src/api/core/auth.ts index 53b8366d..71d9f994 100644 --- a/apps/web-ele/src/api/core/auth.ts +++ b/apps/web-ele/src/api/core/auth.ts @@ -3,8 +3,8 @@ import { baseRequestClient, requestClient } from '#/api/request'; export namespace AuthApi { /** 登录接口参数 */ export interface LoginParams { - password: string; - username: string; + password?: string; + username?: string; } /** 登录接口返回值 */ diff --git a/apps/web-naive/src/adapter/form.ts b/apps/web-naive/src/adapter/form.ts index 1c051b4a..eb765476 100644 --- a/apps/web-naive/src/adapter/form.ts +++ b/apps/web-naive/src/adapter/form.ts @@ -84,7 +84,10 @@ setupVbenForm({ Upload: NUpload, }, config: { + // naive-ui组件不接受onChang事件,所以需要禁用 disabledOnChangeListener: true, + // naive-ui组件的空值为null,不能是undefined,否则重置表单时不生效 + emptyStateValue: null, baseModelPropName: 'value', modelPropNameMap: { Checkbox: 'checked', diff --git a/apps/web-naive/src/api/core/auth.ts b/apps/web-naive/src/api/core/auth.ts index 53b8366d..71d9f994 100644 --- a/apps/web-naive/src/api/core/auth.ts +++ b/apps/web-naive/src/api/core/auth.ts @@ -3,8 +3,8 @@ import { baseRequestClient, requestClient } from '#/api/request'; export namespace AuthApi { /** 登录接口参数 */ export interface LoginParams { - password: string; - username: string; + password?: string; + username?: string; } /** 登录接口返回值 */ diff --git a/packages/@core/ui-kit/form-ui/src/components/form-actions.vue b/packages/@core/ui-kit/form-ui/src/components/form-actions.vue index 3c03c757..25c54d7c 100644 --- a/packages/@core/ui-kit/form-ui/src/components/form-actions.vue +++ b/packages/@core/ui-kit/form-ui/src/components/form-actions.vue @@ -30,12 +30,12 @@ const submitButtonOptions = computed(() => { }; }); -const isQueryForm = computed(() => { - return !!unref(rootProps).showCollapseButton; -}); +// const isQueryForm = computed(() => { +// return !!unref(rootProps).showCollapseButton; +// }); const queryFormStyle = computed(() => { - if (isQueryForm.value) { + if (!unref(rootProps).actionWrapperClass) { return { 'grid-column': `-2 / -1`, marginLeft: 'auto', diff --git a/packages/@core/ui-kit/form-ui/src/config.ts b/packages/@core/ui-kit/form-ui/src/config.ts index aec2642d..33ddc60d 100644 --- a/packages/@core/ui-kit/form-ui/src/config.ts +++ b/packages/@core/ui-kit/form-ui/src/config.ts @@ -45,8 +45,13 @@ export function setupVbenForm< >(options: VbenFormAdapterOptions) { const { components, config, defineRules } = options; - DEFAULT_FORM_COMMON_CONFIG.disabledOnChangeListener = - config?.disabledOnChangeListener ?? false; + const { disabledOnChangeListener = false, emptyStateValue = undefined } = + (config || {}) as FormCommonConfig; + + Object.assign(DEFAULT_FORM_COMMON_CONFIG, { + disabledOnChangeListener, + emptyStateValue, + }); if (defineRules) { for (const key of Object.keys(defineRules)) { diff --git a/packages/@core/ui-kit/form-ui/src/form-render/form-field.vue b/packages/@core/ui-kit/form-ui/src/form-render/form-field.vue index c116d49c..f66a4bb6 100644 --- a/packages/@core/ui-kit/form-ui/src/form-render/form-field.vue +++ b/packages/@core/ui-kit/form-ui/src/form-render/form-field.vue @@ -33,6 +33,7 @@ const { description, disabled, disabledOnChangeListener, + emptyStateValue, fieldName, formFieldProps, label, @@ -55,7 +56,7 @@ const formApi = formRenderProps.form; const isInValid = computed(() => errors.value?.length > 0); -const fieldComponent = computed(() => { +const FieldComponent = computed(() => { const finalComponent = isString(component) ? componentMap.value[component] : component; @@ -213,7 +214,7 @@ function fieldBindEvent(slotProps: Record) { if (bindEventField) { return { [`onUpdate:${bindEventField}`]: handler, - [bindEventField]: value, + [bindEventField]: value === undefined ? emptyStateValue : value, onChange: disabledOnChangeListener ? undefined : (e: Record) => { @@ -300,7 +301,7 @@ function autofocus() { }" > diff --git a/packages/stores/src/modules/user.ts b/packages/stores/src/modules/user.ts index 3c8d8794..afc974a2 100644 --- a/packages/stores/src/modules/user.ts +++ b/packages/stores/src/modules/user.ts @@ -1,6 +1,7 @@ import { acceptHMRUpdate, defineStore } from 'pinia'; interface BasicUserInfo { + [key: string]: any; /** * 头像 */ diff --git a/packages/utils/src/index.ts b/packages/utils/src/index.ts index 9bf575c3..80263b6a 100644 --- a/packages/utils/src/index.ts +++ b/packages/utils/src/index.ts @@ -1,3 +1,4 @@ export * from './helpers'; +export * from '@vben-core/shared/cache'; export * from '@vben-core/shared/color'; export * from '@vben-core/shared/utils'; diff --git a/playground/src/api/core/auth.ts b/playground/src/api/core/auth.ts index 53b8366d..71d9f994 100644 --- a/playground/src/api/core/auth.ts +++ b/playground/src/api/core/auth.ts @@ -3,8 +3,8 @@ import { baseRequestClient, requestClient } from '#/api/request'; export namespace AuthApi { /** 登录接口参数 */ export interface LoginParams { - password: string; - username: string; + password?: string; + username?: string; } /** 登录接口返回值 */ diff --git a/playground/src/locales/langs/zh-CN.json b/playground/src/locales/langs/zh-CN.json index 26f87a03..727d6262 100644 --- a/playground/src/locales/langs/zh-CN.json +++ b/playground/src/locales/langs/zh-CN.json @@ -92,7 +92,7 @@ "editCell": "单元格编辑", "editRow": "行编辑", "custom-cell": "自定义单元格", - "form": "开启搜索表单" + "form": "搜索表单" }, "captcha": { "title": "验证码",