From 698daf46c74700a69a7b4c6961fb05dbef4cb933 Mon Sep 17 00:00:00 2001 From: Netfan Date: Sat, 14 Dec 2024 17:42:13 +0800 Subject: [PATCH] fix: form component events bind (#5137) * fix: from component events bind * chore: update docs * chore: default value and docs sync --- apps/web-ele/src/adapter/form.ts | 2 -- apps/web-naive/src/adapter/form.ts | 2 -- docs/src/_env/adapter/form.ts | 2 -- packages/@core/ui-kit/form-ui/src/config.ts | 4 ++-- packages/@core/ui-kit/form-ui/src/form-render/form.vue | 4 ++-- packages/@core/ui-kit/form-ui/src/types.ts | 4 ++-- 6 files changed, 6 insertions(+), 12 deletions(-) diff --git a/apps/web-ele/src/adapter/form.ts b/apps/web-ele/src/adapter/form.ts index 214b8d8bc..13ae9c428 100644 --- a/apps/web-ele/src/adapter/form.ts +++ b/apps/web-ele/src/adapter/form.ts @@ -14,8 +14,6 @@ setupVbenForm({ Upload: 'fileList', CheckboxGroup: 'model-value', }, - // select等组件的筛选功能会抛出input事件,需要禁用表单的input事件监听以免错误地更新了组件值 - disabledOnInputListener: true, }, defineRules: { required: (value, _params, ctx) => { diff --git a/apps/web-naive/src/adapter/form.ts b/apps/web-naive/src/adapter/form.ts index 2c3cee875..2f2ed2abe 100644 --- a/apps/web-naive/src/adapter/form.ts +++ b/apps/web-naive/src/adapter/form.ts @@ -10,8 +10,6 @@ import { $t } from '@vben/locales'; setupVbenForm({ config: { - // naive-ui组件不接受onChang事件,所以需要禁用 - disabledOnChangeListener: true, // naive-ui组件的空值为null,不能是undefined,否则重置表单时不生效 emptyStateValue: null, baseModelPropName: 'value', diff --git a/docs/src/_env/adapter/form.ts b/docs/src/_env/adapter/form.ts index 67e2483e5..d8b51c254 100644 --- a/docs/src/_env/adapter/form.ts +++ b/docs/src/_env/adapter/form.ts @@ -14,8 +14,6 @@ initComponentAdapter(); setupVbenForm({ config: { baseModelPropName: 'value', - // naive-ui组件不接受onChang事件,所以需要禁用 - disabledOnChangeListener: true, // naive-ui组件的空值为null,不能是undefined,否则重置表单时不生效 emptyStateValue: null, modelPropNameMap: { diff --git a/packages/@core/ui-kit/form-ui/src/config.ts b/packages/@core/ui-kit/form-ui/src/config.ts index 5dec2c3bd..9e82cffe1 100644 --- a/packages/@core/ui-kit/form-ui/src/config.ts +++ b/packages/@core/ui-kit/form-ui/src/config.ts @@ -45,8 +45,8 @@ export function setupVbenForm< const { config, defineRules } = options; const { - disabledOnChangeListener = false, - disabledOnInputListener = false, + disabledOnChangeListener = true, + disabledOnInputListener = true, emptyStateValue = undefined, } = (config || {}) as FormCommonConfig; diff --git a/packages/@core/ui-kit/form-ui/src/form-render/form.vue b/packages/@core/ui-kit/form-ui/src/form-render/form.vue index 4b727416a..f97096c9b 100644 --- a/packages/@core/ui-kit/form-ui/src/form-render/form.vue +++ b/packages/@core/ui-kit/form-ui/src/form-render/form.vue @@ -89,8 +89,8 @@ const computedSchema = computed( componentProps = {}, controlClass = '', disabled, - disabledOnChangeListener = false, - disabledOnInputListener = false, + disabledOnChangeListener = true, + disabledOnInputListener = true, emptyStateValue = undefined, formFieldProps = {}, formItemClass = '', diff --git a/packages/@core/ui-kit/form-ui/src/types.ts b/packages/@core/ui-kit/form-ui/src/types.ts index 9e3004a27..9cff3893d 100644 --- a/packages/@core/ui-kit/form-ui/src/types.ts +++ b/packages/@core/ui-kit/form-ui/src/types.ts @@ -151,12 +151,12 @@ export interface FormCommonConfig { disabled?: boolean; /** * 是否禁用所有表单项的change事件监听 - * @default false + * @default true */ disabledOnChangeListener?: boolean; /** * 是否禁用所有表单项的input事件监听 - * @default false + * @default true */ disabledOnInputListener?: boolean; /**