fix: form component events bind (#5137)

* fix: from component events bind

* chore: update docs

* chore: default value and docs sync
dev-v5
Netfan 2024-12-14 17:42:13 +08:00 committed by GitHub
parent 0410f1e1be
commit 698daf46c7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 6 additions and 12 deletions

View File

@ -14,8 +14,6 @@ setupVbenForm<ComponentType>({
Upload: 'fileList', Upload: 'fileList',
CheckboxGroup: 'model-value', CheckboxGroup: 'model-value',
}, },
// select等组件的筛选功能会抛出input事件需要禁用表单的input事件监听以免错误地更新了组件值
disabledOnInputListener: true,
}, },
defineRules: { defineRules: {
required: (value, _params, ctx) => { required: (value, _params, ctx) => {

View File

@ -10,8 +10,6 @@ import { $t } from '@vben/locales';
setupVbenForm<ComponentType>({ setupVbenForm<ComponentType>({
config: { config: {
// naive-ui组件不接受onChang事件所以需要禁用
disabledOnChangeListener: true,
// naive-ui组件的空值为null,不能是undefined否则重置表单时不生效 // naive-ui组件的空值为null,不能是undefined否则重置表单时不生效
emptyStateValue: null, emptyStateValue: null,
baseModelPropName: 'value', baseModelPropName: 'value',

View File

@ -14,8 +14,6 @@ initComponentAdapter();
setupVbenForm<ComponentType>({ setupVbenForm<ComponentType>({
config: { config: {
baseModelPropName: 'value', baseModelPropName: 'value',
// naive-ui组件不接受onChang事件所以需要禁用
disabledOnChangeListener: true,
// naive-ui组件的空值为null,不能是undefined否则重置表单时不生效 // naive-ui组件的空值为null,不能是undefined否则重置表单时不生效
emptyStateValue: null, emptyStateValue: null,
modelPropNameMap: { modelPropNameMap: {

View File

@ -45,8 +45,8 @@ export function setupVbenForm<
const { config, defineRules } = options; const { config, defineRules } = options;
const { const {
disabledOnChangeListener = false, disabledOnChangeListener = true,
disabledOnInputListener = false, disabledOnInputListener = true,
emptyStateValue = undefined, emptyStateValue = undefined,
} = (config || {}) as FormCommonConfig; } = (config || {}) as FormCommonConfig;

View File

@ -89,8 +89,8 @@ const computedSchema = computed(
componentProps = {}, componentProps = {},
controlClass = '', controlClass = '',
disabled, disabled,
disabledOnChangeListener = false, disabledOnChangeListener = true,
disabledOnInputListener = false, disabledOnInputListener = true,
emptyStateValue = undefined, emptyStateValue = undefined,
formFieldProps = {}, formFieldProps = {},
formItemClass = '', formItemClass = '',

View File

@ -151,12 +151,12 @@ export interface FormCommonConfig {
disabled?: boolean; disabled?: boolean;
/** /**
* change * change
* @default false * @default true
*/ */
disabledOnChangeListener?: boolean; disabledOnChangeListener?: boolean;
/** /**
* input * input
* @default false * @default true
*/ */
disabledOnInputListener?: boolean; disabledOnInputListener?: boolean;
/** /**