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 1e6417f9
authored
Aug 16, 2025
by
ming4762
Committed by
GitHub
Aug 16, 2025
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat: vBenForm add layout: inline (#6644)
1 parent
e147a9d2
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
69 additions
and
7 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.vue
packages/@core/ui-kit/form-ui/src/types.ts
playground/src/views/examples/form/query.vue
docs/src/components/common-ui/vben-form.md
View file @
1e6417f
...
@@ -304,7 +304,7 @@ useVbenForm 返回的第二个参数,是一个对象,包含了一些表单
...
@@ -304,7 +304,7 @@ useVbenForm 返回的第二个参数,是一个对象,包含了一些表单
| 属性名 | 描述 | 类型 | 默认值 |
| 属性名 | 描述 | 类型 | 默认值 |
| --- | --- | --- | --- |
| --- | --- | --- | --- |
| layout | 表单项布局 |
`'horizontal' \| 'vertical'`
|
`horizontal`
|
| layout | 表单项布局 |
`'horizontal' \| 'vertical'
\| 'inline'
`
|
`horizontal`
|
| showCollapseButton | 是否显示折叠按钮 |
`boolean`
|
`false`
|
| showCollapseButton | 是否显示折叠按钮 |
`boolean`
|
`false`
|
| wrapperClass | 表单的布局,基于tailwindcss |
`any`
| - |
| wrapperClass | 表单的布局,基于tailwindcss |
`any`
| - |
| actionWrapperClass | 表单操作区域class |
`any`
| - |
| actionWrapperClass | 表单操作区域class |
`any`
| - |
...
...
packages/@core/ui-kit/form-ui/src/components/form-actions.vue
View file @
1e6417f
...
@@ -82,11 +82,11 @@ const actionWrapperClass = computed(() => {
...
@@ -82,11 +82,11 @@ const actionWrapperClass = computed(() => {
const
cls
=
[
const
cls
=
[
'flex'
,
'flex'
,
'w-full'
,
'items-center'
,
'items-center'
,
'gap-3'
,
'gap-3'
,
props
.
compact
?
'pb-2'
:
'pb-4'
,
props
.
compact
?
'pb-2'
:
'pb-4'
,
props
.
layout
===
'vertical'
?
'self-end'
:
'self-center'
,
props
.
layout
===
'vertical'
?
'self-end'
:
'self-center'
,
props
.
layout
===
'inline'
?
''
:
'w-full'
,
props
.
actionWrapperClass
,
props
.
actionWrapperClass
,
];
];
...
...
packages/@core/ui-kit/form-ui/src/form-render/form.vue
View file @
1e6417f
...
@@ -42,11 +42,13 @@ const emits = defineEmits<{
...
@@ -42,11 +42,13 @@ const emits = defineEmits<{
}
>
();
}
>
();
const
wrapperClass
=
computed
(()
=>
{
const
wrapperClass
=
computed
(()
=>
{
const
cls
=
[
'flex
flex-col
'
];
const
cls
=
[
'flex'
];
if
(
props
.
layout
===
'vertical'
)
{
if
(
props
.
layout
===
'vertical'
)
{
cls
.
push
(
props
.
compact
?
'gap-x-2'
:
'gap-x-4'
);
cls
.
push
(
props
.
compact
?
'gap-x-2'
:
'gap-x-4'
,
'flex-col grid'
);
}
else
if
(
props
.
layout
===
'inline'
)
{
cls
.
push
(
'flex-wrap gap-2'
);
}
else
{
}
else
{
cls
.
push
(
'gap-2'
);
cls
.
push
(
'gap-2
flex-col grid
'
);
}
}
return
cn
(...
cls
,
props
.
wrapperClass
);
return
cn
(...
cls
,
props
.
wrapperClass
);
});
});
...
@@ -170,7 +172,7 @@ const computedSchema = computed(
...
@@ -170,7 +172,7 @@ const computedSchema = computed(
<
template
>
<
template
>
<component
:is=
"formComponent"
v-bind=
"formComponentProps"
>
<component
:is=
"formComponent"
v-bind=
"formComponentProps"
>
<div
ref=
"wrapperRef"
:class=
"wrapperClass"
class=
"grid"
>
<div
ref=
"wrapperRef"
:class=
"wrapperClass"
>
<template
v-for=
"cSchema in computedSchema"
:key=
"cSchema.fieldName"
>
<template
v-for=
"cSchema in computedSchema"
:key=
"cSchema.fieldName"
>
<!--
<div
v-if=
"$slots[cSchema.fieldName]"
:class=
"cSchema.formItemClass"
>
<!--
<div
v-if=
"$slots[cSchema.fieldName]"
:class=
"cSchema.formItemClass"
>
<slot
:definition=
"cSchema"
:name=
"cSchema.fieldName"
>
</slot>
<slot
:definition=
"cSchema"
:name=
"cSchema.fieldName"
>
</slot>
...
...
packages/@core/ui-kit/form-ui/src/types.ts
View file @
1e6417f
...
@@ -8,7 +8,7 @@ import type { ClassType, MaybeComputedRef } from '@vben-core/typings';
...
@@ -8,7 +8,7 @@ import type { ClassType, MaybeComputedRef } from '@vben-core/typings';
import
type
{
FormApi
}
from
'./form-api'
;
import
type
{
FormApi
}
from
'./form-api'
;
export
type
FormLayout
=
'horizontal'
|
'vertical'
;
export
type
FormLayout
=
'horizontal'
|
'
inline'
|
'
vertical'
;
export
type
BaseFormComponentType
=
export
type
BaseFormComponentType
=
|
'DefaultButton'
|
'DefaultButton'
...
...
playground/src/views/examples/form/query.vue
View file @
1e6417f
...
@@ -86,6 +86,62 @@ const [QueryForm] = useVbenForm({
...
@@ -86,6 +86,62 @@ const [QueryForm] = useVbenForm({
wrapperClass
:
'grid-cols-1 md:grid-cols-2 lg:grid-cols-3'
,
wrapperClass
:
'grid-cols-1 md:grid-cols-2 lg:grid-cols-3'
,
});
});
const
[
InlineForm
]
=
useVbenForm
({
layout
:
'inline'
,
schema
:
[
{
// 组件需要在 #/adapter.ts内注册,并加上类型
component
:
'Input'
,
// 对应组件的参数
componentProps
:
{
placeholder
:
'请输入用户名'
,
},
// 字段名
fieldName
:
'username'
,
// 界面显示的label
label
:
'字符串'
,
},
{
component
:
'InputPassword'
,
componentProps
:
{
placeholder
:
'请输入密码'
,
},
fieldName
:
'password'
,
label
:
'密码'
,
},
{
component
:
'InputNumber'
,
componentProps
:
{
placeholder
:
'请输入'
,
},
fieldName
:
'number'
,
label
:
'数字(带后缀)'
,
suffix
:
()
=>
'¥'
,
},
{
component
:
'Select'
,
componentProps
:
{
allowClear
:
true
,
filterOption
:
true
,
options
:
[
{
label
:
'选项1'
,
value
:
'1'
,
},
{
label
:
'选项2'
,
value
:
'2'
,
},
],
placeholder
:
'请选择'
,
showSearch
:
true
,
},
fieldName
:
'options'
,
label
:
'下拉选'
,
},
],
});
const
[
QueryForm1
]
=
useVbenForm
({
const
[
QueryForm1
]
=
useVbenForm
({
// 默认展开
// 默认展开
collapsed
:
true
,
collapsed
:
true
,
...
@@ -205,6 +261,10 @@ function onSubmit(values: Record<string, any>) {
...
@@ -205,6 +261,10 @@ function onSubmit(values: Record<string, any>) {
<QueryForm
/>
<QueryForm
/>
</Card>
</Card>
<Card
class=
"mb-5"
title=
"查询表单,单行表单"
>
<InlineForm
/>
</Card>
<Card
class=
"mb-5"
title=
"查询表单,默认展开,垂直布局"
>
<Card
class=
"mb-5"
title=
"查询表单,默认展开,垂直布局"
>
<QueryForm2
/>
<QueryForm2
/>
</Card>
</Card>
...
...
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