1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
| <script lang="ts" setup>
| import { h } from 'vue';
|
| import { Page } from '@vben/common-ui';
|
| import { Card } from 'ant-design-vue';
|
| import { useVbenForm } from '#/adapter/form';
|
| import DocButton from '../doc-button.vue';
|
| const [CustomLayoutForm] = useVbenForm({
| // 所有表单项共用,可单独在表单内覆盖
| commonConfig: {
| // 所有表单项
| componentProps: {
| class: 'w-full',
| },
| },
| layout: 'horizontal',
| schema: [
| {
| component: 'Select',
| fieldName: 'field1',
| label: '字符串',
| },
| {
| component: 'TreeSelect',
| fieldName: 'field2',
| label: '字符串',
| },
| {
| component: 'Mentions',
| fieldName: 'field3',
| label: '字符串',
| },
| {
| component: 'Input',
| fieldName: 'field4',
| label: '字符串',
| },
| {
| component: 'InputNumber',
| fieldName: 'field5',
| // 从第三列开始 相当于中间空了一列
| formItemClass: 'col-start-3',
| label: '前面空了一列',
| },
| {
| component: 'Divider',
| fieldName: '_divider',
| formItemClass: 'col-span-3',
| hideLabel: true,
| renderComponentContent: () => {
| return {
| default: () => h('div', '分割线'),
| };
| },
| },
| {
| component: 'Textarea',
| fieldName: 'field6',
| // 占满三列空间 基线对齐
| formItemClass: 'col-span-3 items-baseline',
| label: '占满三列',
| },
| {
| component: 'Input',
| fieldName: 'field7',
| // 占满2列空间 从第二列开始 相当于前面空了一列
| formItemClass: 'col-span-2 col-start-2',
| label: '占满2列',
| },
| {
| component: 'Input',
| fieldName: 'field8',
| // 左右留空
| formItemClass: 'col-start-2',
| label: '左右留空',
| },
| {
| component: 'InputPassword',
| fieldName: 'field9',
| formItemClass: 'col-start-1',
| label: '字符串',
| },
| ],
| // 一共三列
| wrapperClass: 'grid-cols-3',
| });
| </script>
|
| <template>
| <Page
| content-class="flex flex-col gap-4"
| description="使用tailwind自定义表单项的布局"
| title="表单自定义布局"
| >
| <template #description>
| <div class="text-muted-foreground">
| <p>使用tailwind自定义表单项的布局,使用Divider分割表单。</p>
| </div>
| </template>
| <template #extra>
| <DocButton class="mb-2" path="/components/common-ui/vben-form" />
| </template>
| <Card title="使用tailwind自定义布局">
| <CustomLayoutForm />
| </Card>
| </Page>
| </template>
|
|