Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
monorepo
/
venus
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
1
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit fe236ea9
authored
Dec 05, 2024
by
huangxiaomin
Committed by
GitHub
Dec 05, 2024
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat: add submitOnChange props to vben form (#5032)
1 parent
05b4b61c
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
23 additions
and
1 deletions
docs/src/components/common-ui/vben-form.md
docs/src/demos/vben-vxe-table/form/index.vue
packages/@core/ui-kit/form-ui/src/form-api.ts
packages/@core/ui-kit/form-ui/src/types.ts
packages/@core/ui-kit/form-ui/src/vben-use-form.vue
playground/src/views/examples/vxe-table/form.vue
docs/src/components/common-ui/vben-form.md
View file @
fe236ea
...
@@ -316,6 +316,7 @@ useVbenForm 返回的第二个参数,是一个对象,包含了一些表单
...
@@ -316,6 +316,7 @@ useVbenForm 返回的第二个参数,是一个对象,包含了一些表单
| commonConfig | 表单项的通用配置,每个配置都会传递到每个表单项,表单项可覆盖 |
`FormCommonConfig`
| - |
| commonConfig | 表单项的通用配置,每个配置都会传递到每个表单项,表单项可覆盖 |
`FormCommonConfig`
| - |
| schema | 表单项的每一项配置 |
`FormSchema`
| - |
| schema | 表单项的每一项配置 |
`FormSchema`
| - |
| submitOnEnter | 按下回车健时提交表单 |
`boolean`
| false |
| submitOnEnter | 按下回车健时提交表单 |
`boolean`
| false |
| submitOnChange | 字段值改变时提交表单 |
`boolean`
| false |
### TS 类型说明
### TS 类型说明
...
...
docs/src/demos/vben-vxe-table/form/index.vue
View file @
fe236ea
...
@@ -76,6 +76,8 @@ const formOptions: VbenFormProps = {
...
@@ -76,6 +76,8 @@ const formOptions: VbenFormProps = {
submitButtonOptions
:
{
submitButtonOptions
:
{
content
:
'查询'
,
content
:
'查询'
,
},
},
// 是否在字段值改变时提交表单
submitOnChange
:
false
,
// 按下回车时是否提交表单
// 按下回车时是否提交表单
submitOnEnter
:
false
,
submitOnEnter
:
false
,
};
};
...
...
packages/@core/ui-kit/form-ui/src/form-api.ts
View file @
fe236ea
...
@@ -36,6 +36,7 @@ function getDefaultState(): VbenFormProps {
...
@@ -36,6 +36,7 @@ function getDefaultState(): VbenFormProps {
showCollapseButton
:
false
,
showCollapseButton
:
false
,
showDefaultActions
:
true
,
showDefaultActions
:
true
,
submitButtonOptions
:
{},
submitButtonOptions
:
{},
submitOnChange
:
false
,
submitOnEnter
:
false
,
submitOnEnter
:
false
,
wrapperClass
:
'grid-cols-1'
,
wrapperClass
:
'grid-cols-1'
,
};
};
...
...
packages/@core/ui-kit/form-ui/src/types.ts
View file @
fe236ea
...
@@ -343,6 +343,12 @@ export interface VbenFormProps<
...
@@ -343,6 +343,12 @@ export interface VbenFormProps<
submitButtonOptions
?:
ActionButtonOptions
;
submitButtonOptions
?:
ActionButtonOptions
;
/**
/**
* 是否在字段值改变时提交表单
* @default false
*/
submitOnChange
?:
boolean
;
/**
* 是否在回车时提交表单
* 是否在回车时提交表单
* @default false
* @default false
*/
*/
...
...
packages/@core/ui-kit/form-ui/src/vben-use-form.vue
View file @
fe236ea
...
@@ -6,7 +6,9 @@ import type { ExtendedFormApi, VbenFormProps } from './types';
...
@@ -6,7 +6,9 @@ import type { ExtendedFormApi, VbenFormProps } from './types';
import
{
useForwardPriorityValues
}
from
'@vben-core/composables'
;
import
{
useForwardPriorityValues
}
from
'@vben-core/composables'
;
// import { isFunction } from '@vben-core/shared/utils';
// import { isFunction } from '@vben-core/shared/utils';
import
{
useTemplateRef
}
from
'vue'
;
import
{
useTemplateRef
,
watch
}
from
'vue'
;
import
{
useDebounceFn
}
from
'@vueuse/core'
;
import
FormActions
from
'./components/form-actions.vue'
;
import
FormActions
from
'./components/form-actions.vue'
;
import
{
import
{
...
@@ -56,6 +58,14 @@ function handleKeyDownEnter(event: KeyboardEvent) {
...
@@ -56,6 +58,14 @@ function handleKeyDownEnter(event: KeyboardEvent) {
formActionsRef
.
value
?.
handleSubmit
?.();
formActionsRef
.
value
?.
handleSubmit
?.();
}
}
watch
(
()
=>
form
.
values
,
useDebounceFn
(()
=>
{
state
.
value
.
submitOnChange
&&
props
.
formApi
?.
submitForm
();
},
300
),
{
deep
:
true
},
);
</
script
>
</
script
>
<
template
>
<
template
>
...
...
playground/src/views/examples/vxe-table/form.vue
View file @
fe236ea
...
@@ -65,6 +65,8 @@ const formOptions: VbenFormProps = {
...
@@ -65,6 +65,8 @@ const formOptions: VbenFormProps = {
],
],
// 控制表单是否显示折叠按钮
// 控制表单是否显示折叠按钮
showCollapseButton
:
true
,
showCollapseButton
:
true
,
// 是否在字段值改变时提交表单
submitOnChange
:
true
,
// 按下回车时是否提交表单
// 按下回车时是否提交表单
submitOnEnter
:
false
,
submitOnEnter
:
false
,
};
};
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment