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 b22d900e
authored
Dec 17, 2024
by
Netfan
Committed by
GitHub
Dec 17, 2024
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat: form compact mode support (#5165)
1 parent
181e3873
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
26 additions
and
4 deletions
docs/src/components/common-ui/vben-form.md
packages/@core/ui-kit/form-ui/src/components/form-actions.vue
packages/@core/ui-kit/form-ui/src/form-render/form-field.vue
packages/@core/ui-kit/form-ui/src/types.ts
packages/effects/plugins/src/vxe-table/use-vxe-grid.vue
docs/src/components/common-ui/vben-form.md
View file @
b22d900
...
@@ -358,6 +358,13 @@ export interface FormCommonConfig {
...
@@ -358,6 +358,13 @@ export interface FormCommonConfig {
*/
*/
componentProps
?:
ComponentProps
;
componentProps
?:
ComponentProps
;
/**
/**
* 是否紧凑模式(移除表单底部为显示校验错误信息所预留的空间)。
* 在有设置校验规则的场景下,建议不要将其设置为true
* 默认为false。但用作表格的搜索表单时,默认为true
* @default false
*/
compact
?:
boolean
;
/**
* 所有表单项的控件样式
* 所有表单项的控件样式
*/
*/
controlClass
?:
string
;
controlClass
?:
string
;
...
...
packages/@core/ui-kit/form-ui/src/components/form-actions.vue
View file @
b22d900
...
@@ -138,7 +138,11 @@ defineExpose({
...
@@ -138,7 +138,11 @@ defineExpose({
<
template
>
<
template
>
<div
<div
:class=
"
:class=
"
cn('col-span-full w-full pb-6 text-right', rootProps.actionWrapperClass)
cn(
'col-span-full w-full text-right',
rootProps.compact ? 'pb-2' : 'pb-6',
rootProps.actionWrapperClass,
)
"
"
:style=
"queryFormStyle"
:style=
"queryFormStyle"
>
>
...
...
packages/@core/ui-kit/form-ui/src/form-render/form-field.vue
View file @
b22d900
...
@@ -55,7 +55,7 @@ const values = useFormValues();
...
@@ -55,7 +55,7 @@ const values = useFormValues();
const
errors
=
useFieldError
(
fieldName
);
const
errors
=
useFieldError
(
fieldName
);
const
fieldComponentRef
=
useTemplateRef
<
HTMLInputElement
>
(
'fieldComponentRef'
);
const
fieldComponentRef
=
useTemplateRef
<
HTMLInputElement
>
(
'fieldComponentRef'
);
const
formApi
=
formRenderProps
.
form
;
const
formApi
=
formRenderProps
.
form
;
const
compact
=
formRenderProps
.
compact
;
const
isInValid
=
computed
(()
=>
errors
.
value
?.
length
>
0
);
const
isInValid
=
computed
(()
=>
errors
.
value
?.
length
>
0
);
const
FieldComponent
=
computed
(()
=>
{
const
FieldComponent
=
computed
(()
=>
{
...
@@ -281,8 +281,10 @@ function autofocus() {
...
@@ -281,8 +281,10 @@ function autofocus() {
'form-valid-error': isInValid,
'form-valid-error': isInValid,
'flex-col': isVertical,
'flex-col': isVertical,
'flex-row items-center': !isVertical,
'flex-row items-center': !isVertical,
'pb-6': !compact,
'pb-2': compact,
}"
}"
class="flex
pb-6
"
class="flex"
v-bind="$attrs"
v-bind="$attrs"
>
>
<FormLabel
<FormLabel
...
...
packages/@core/ui-kit/form-ui/src/types.ts
View file @
b22d900
...
@@ -274,6 +274,10 @@ export interface FormRenderProps<
...
@@ -274,6 +274,10 @@ export interface FormRenderProps<
*/
*/
commonConfig
?:
FormCommonConfig
;
commonConfig
?:
FormCommonConfig
;
/**
/**
* 紧凑模式(移除表单每一项底部为校验信息预留的空间)
*/
compact
?:
boolean
;
/**
* 组件v-model事件绑定
* 组件v-model事件绑定
*/
*/
componentBindEventMap
?:
Partial
<
Record
<
BaseFormComponentType
,
string
>>
;
componentBindEventMap
?:
Partial
<
Record
<
BaseFormComponentType
,
string
>>
;
...
...
packages/effects/plugins/src/vxe-table/use-vxe-grid.vue
View file @
b22d900
...
@@ -68,6 +68,7 @@ const { isMobile } = usePreferences();
...
@@ -68,6 +68,7 @@ const { isMobile } = usePreferences();
const
slots
=
useSlots
();
const
slots
=
useSlots
();
const
[
Form
,
formApi
]
=
useTableForm
({
const
[
Form
,
formApi
]
=
useTableForm
({
compact
:
true
,
handleSubmit
:
async
()
=>
{
handleSubmit
:
async
()
=>
{
const
formValues
=
formApi
.
form
.
values
;
const
formValues
=
formApi
.
form
.
values
;
formApi
.
setLatestSubmissionValues
(
toRaw
(
formValues
));
formApi
.
setLatestSubmissionValues
(
toRaw
(
formValues
));
...
@@ -284,6 +285,10 @@ watch(
...
@@ -284,6 +285,10 @@ watch(
},
},
);
);
const
isCompactForm
=
computed
(()
=>
{
return
formApi
.
getState
()?.
compact
;
});
onMounted
(()
=>
{
onMounted
(()
=>
{
props
.
api
?.
mount
?.(
gridRef
.
value
,
formApi
);
props
.
api
?.
mount
?.(
gridRef
.
value
,
formApi
);
init
();
init
();
...
@@ -338,7 +343,7 @@ onUnmounted(() => {
...
@@ -338,7 +343,7 @@ onUnmounted(() => {
<div
<div
v-if=
"formOptions"
v-if=
"formOptions"
v-show=
"showSearchForm !== false"
v-show=
"showSearchForm !== false"
class=
"relative rounded py-3 pb-4
"
:class=
"cn('relative rounded py-3', isCompactForm ? 'pb-6' : 'pb-4')
"
>
>
<slot
name=
"form"
>
<slot
name=
"form"
>
<Form>
<Form>
...
...
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