|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+- 表单组件配置参考下面内容
|
|
|
2
|
+```
|
|
|
3
|
+[
|
|
|
4
|
+ {
|
|
|
5
|
+ // 组件需要在 #/adapter.ts内注册,并加上类型
|
|
|
6
|
+ component: 'Input',
|
|
|
7
|
+ // 对应组件的参数
|
|
|
8
|
+ componentProps: {
|
|
|
9
|
+ placeholder: '请输入用户名',
|
|
|
10
|
+ },
|
|
|
11
|
+ // 字段名
|
|
|
12
|
+ fieldName: 'username',
|
|
|
13
|
+ // 界面显示的label
|
|
|
14
|
+ label: '字符串',
|
|
|
15
|
+ rules: 'required',
|
|
|
16
|
+ },
|
|
|
17
|
+ {
|
|
|
18
|
+ // 组件需要在 #/adapter.ts内注册,并加上类型
|
|
|
19
|
+ component: 'ApiSelect',
|
|
|
20
|
+ // 对应组件的参数
|
|
|
21
|
+ componentProps: {
|
|
|
22
|
+ // 菜单接口转options格式
|
|
|
23
|
+ afterFetch: (data: { name: string; path: string }[]) => {
|
|
|
24
|
+ return data.map((item: any) => ({
|
|
|
25
|
+ label: item.name,
|
|
|
26
|
+ value: item.path,
|
|
|
27
|
+ }));
|
|
|
28
|
+ },
|
|
|
29
|
+ // 菜单接口
|
|
|
30
|
+ api: getAllMenusApi,
|
|
|
31
|
+ },
|
|
|
32
|
+ // 字段名
|
|
|
33
|
+ fieldName: 'api',
|
|
|
34
|
+ // 界面显示的label
|
|
|
35
|
+ label: 'ApiSelect',
|
|
|
36
|
+ },
|
|
|
37
|
+ {
|
|
|
38
|
+ component: 'ApiSelect',
|
|
|
39
|
+ // 对应组件的参数
|
|
|
40
|
+ componentProps: () => {
|
|
|
41
|
+ return {
|
|
|
42
|
+ api: fetchRemoteOptions,
|
|
|
43
|
+ // 禁止本地过滤
|
|
|
44
|
+ filterOption: false,
|
|
|
45
|
+ // 如果正在获取数据,使用插槽显示一个loading
|
|
|
46
|
+ notFoundContent: fetching.value ? undefined : null,
|
|
|
47
|
+ // 搜索词变化时记录下来, 使用useDebounceFn防抖。
|
|
|
48
|
+ onSearch: useDebounceFn((value: string) => {
|
|
|
49
|
+ keyword.value = value;
|
|
|
50
|
+ }, 300),
|
|
|
51
|
+ // 远程搜索参数。当搜索词变化时,params也会更新
|
|
|
52
|
+ params: {
|
|
|
53
|
+ keyword: keyword.value || undefined,
|
|
|
54
|
+ },
|
|
|
55
|
+ showSearch: true,
|
|
|
56
|
+ };
|
|
|
57
|
+ },
|
|
|
58
|
+ // 字段名
|
|
|
59
|
+ fieldName: 'remoteSearch',
|
|
|
60
|
+ // 界面显示的label
|
|
|
61
|
+ label: '远程搜索',
|
|
|
62
|
+ renderComponentContent: () => {
|
|
|
63
|
+ return {
|
|
|
64
|
+ notFoundContent: fetching.value ? h(Spin) : undefined,
|
|
|
65
|
+ };
|
|
|
66
|
+ },
|
|
|
67
|
+ },
|
|
|
68
|
+ {
|
|
|
69
|
+ component: 'ApiTreeSelect',
|
|
|
70
|
+ // 对应组件的参数
|
|
|
71
|
+ componentProps: {
|
|
|
72
|
+ // 菜单接口
|
|
|
73
|
+ api: getAllMenusApi,
|
|
|
74
|
+ childrenField: 'children',
|
|
|
75
|
+ // 菜单接口转options格式
|
|
|
76
|
+ labelField: 'name',
|
|
|
77
|
+ valueField: 'path',
|
|
|
78
|
+ },
|
|
|
79
|
+ // 字段名
|
|
|
80
|
+ fieldName: 'apiTree',
|
|
|
81
|
+ // 界面显示的label
|
|
|
82
|
+ label: 'ApiTreeSelect',
|
|
|
83
|
+ },
|
|
|
84
|
+ {
|
|
|
85
|
+ component: 'InputPassword',
|
|
|
86
|
+ componentProps: {
|
|
|
87
|
+ placeholder: '请输入密码',
|
|
|
88
|
+ },
|
|
|
89
|
+ fieldName: 'password',
|
|
|
90
|
+ label: '密码',
|
|
|
91
|
+ },
|
|
|
92
|
+ {
|
|
|
93
|
+ component: 'InputNumber',
|
|
|
94
|
+ componentProps: {
|
|
|
95
|
+ placeholder: '请输入',
|
|
|
96
|
+ },
|
|
|
97
|
+ fieldName: 'number',
|
|
|
98
|
+ label: '数字(带后缀)',
|
|
|
99
|
+ suffix: () => '¥',
|
|
|
100
|
+ },
|
|
|
101
|
+ {
|
|
|
102
|
+ component: 'IconPicker',
|
|
|
103
|
+ fieldName: 'icon',
|
|
|
104
|
+ label: '图标',
|
|
|
105
|
+ },
|
|
|
106
|
+ {
|
|
|
107
|
+ component: 'Select',
|
|
|
108
|
+ componentProps: {
|
|
|
109
|
+ allowClear: true,
|
|
|
110
|
+ filterOption: true,
|
|
|
111
|
+ options: [
|
|
|
112
|
+ {
|
|
|
113
|
+ label: '选项1',
|
|
|
114
|
+ value: '1',
|
|
|
115
|
+ },
|
|
|
116
|
+ {
|
|
|
117
|
+ label: '选项2',
|
|
|
118
|
+ value: '2',
|
|
|
119
|
+ },
|
|
|
120
|
+ ],
|
|
|
121
|
+ placeholder: '请选择',
|
|
|
122
|
+ showSearch: true,
|
|
|
123
|
+ },
|
|
|
124
|
+ fieldName: 'options',
|
|
|
125
|
+ label: '下拉选',
|
|
|
126
|
+ },
|
|
|
127
|
+ {
|
|
|
128
|
+ component: 'RadioGroup',
|
|
|
129
|
+ componentProps: {
|
|
|
130
|
+ options: [
|
|
|
131
|
+ {
|
|
|
132
|
+ label: '选项1',
|
|
|
133
|
+ value: '1',
|
|
|
134
|
+ },
|
|
|
135
|
+ {
|
|
|
136
|
+ label: '选项2',
|
|
|
137
|
+ value: '2',
|
|
|
138
|
+ },
|
|
|
139
|
+ ],
|
|
|
140
|
+ },
|
|
|
141
|
+ fieldName: 'radioGroup',
|
|
|
142
|
+ label: '单选组',
|
|
|
143
|
+ },
|
|
|
144
|
+ {
|
|
|
145
|
+ component: 'Radio',
|
|
|
146
|
+ fieldName: 'radio',
|
|
|
147
|
+ label: '',
|
|
|
148
|
+ renderComponentContent: () => {
|
|
|
149
|
+ return {
|
|
|
150
|
+ default: () => ['Radio'],
|
|
|
151
|
+ };
|
|
|
152
|
+ },
|
|
|
153
|
+ },
|
|
|
154
|
+ {
|
|
|
155
|
+ component: 'CheckboxGroup',
|
|
|
156
|
+ componentProps: {
|
|
|
157
|
+ name: 'cname',
|
|
|
158
|
+ options: [
|
|
|
159
|
+ {
|
|
|
160
|
+ label: '选项1',
|
|
|
161
|
+ value: '1',
|
|
|
162
|
+ },
|
|
|
163
|
+ {
|
|
|
164
|
+ label: '选项2',
|
|
|
165
|
+ value: '2',
|
|
|
166
|
+ },
|
|
|
167
|
+ ],
|
|
|
168
|
+ },
|
|
|
169
|
+ fieldName: 'checkboxGroup',
|
|
|
170
|
+ label: '多选组',
|
|
|
171
|
+ },
|
|
|
172
|
+ {
|
|
|
173
|
+ component: 'Checkbox',
|
|
|
174
|
+ fieldName: 'checkbox',
|
|
|
175
|
+ label: '',
|
|
|
176
|
+ renderComponentContent: () => {
|
|
|
177
|
+ return {
|
|
|
178
|
+ default: () => ['我已阅读并同意'],
|
|
|
179
|
+ };
|
|
|
180
|
+ },
|
|
|
181
|
+ },
|
|
|
182
|
+ {
|
|
|
183
|
+ component: 'Mentions',
|
|
|
184
|
+ componentProps: {
|
|
|
185
|
+ options: [
|
|
|
186
|
+ {
|
|
|
187
|
+ label: 'afc163',
|
|
|
188
|
+ value: 'afc163',
|
|
|
189
|
+ },
|
|
|
190
|
+ {
|
|
|
191
|
+ label: 'zombieJ',
|
|
|
192
|
+ value: 'zombieJ',
|
|
|
193
|
+ },
|
|
|
194
|
+ ],
|
|
|
195
|
+ placeholder: '请输入',
|
|
|
196
|
+ },
|
|
|
197
|
+ fieldName: 'mentions',
|
|
|
198
|
+ label: '提及',
|
|
|
199
|
+ },
|
|
|
200
|
+ {
|
|
|
201
|
+ component: 'Rate',
|
|
|
202
|
+ fieldName: 'rate',
|
|
|
203
|
+ label: '评分',
|
|
|
204
|
+ },
|
|
|
205
|
+ {
|
|
|
206
|
+ component: 'Switch',
|
|
|
207
|
+ componentProps: {
|
|
|
208
|
+ class: 'w-auto',
|
|
|
209
|
+ },
|
|
|
210
|
+ fieldName: 'switch',
|
|
|
211
|
+ label: '开关',
|
|
|
212
|
+ },
|
|
|
213
|
+ {
|
|
|
214
|
+ component: 'DatePicker',
|
|
|
215
|
+ fieldName: 'datePicker',
|
|
|
216
|
+ label: '日期选择框',
|
|
|
217
|
+ },
|
|
|
218
|
+ {
|
|
|
219
|
+ component: 'RangePicker',
|
|
|
220
|
+ fieldName: 'rangePicker',
|
|
|
221
|
+ label: '范围选择器',
|
|
|
222
|
+ },
|
|
|
223
|
+ {
|
|
|
224
|
+ component: 'TimePicker',
|
|
|
225
|
+ fieldName: 'timePicker',
|
|
|
226
|
+ label: '时间选择框',
|
|
|
227
|
+ },
|
|
|
228
|
+ {
|
|
|
229
|
+ component: 'TreeSelect',
|
|
|
230
|
+ componentProps: {
|
|
|
231
|
+ allowClear: true,
|
|
|
232
|
+ placeholder: '请选择',
|
|
|
233
|
+ showSearch: true,
|
|
|
234
|
+ treeData: [
|
|
|
235
|
+ {
|
|
|
236
|
+ label: 'root 1',
|
|
|
237
|
+ value: 'root 1',
|
|
|
238
|
+ children: [
|
|
|
239
|
+ {
|
|
|
240
|
+ label: 'parent 1',
|
|
|
241
|
+ value: 'parent 1',
|
|
|
242
|
+ children: [
|
|
|
243
|
+ {
|
|
|
244
|
+ label: 'parent 1-0',
|
|
|
245
|
+ value: 'parent 1-0',
|
|
|
246
|
+ children: [
|
|
|
247
|
+ {
|
|
|
248
|
+ label: 'my leaf',
|
|
|
249
|
+ value: 'leaf1',
|
|
|
250
|
+ },
|
|
|
251
|
+ {
|
|
|
252
|
+ label: 'your leaf',
|
|
|
253
|
+ value: 'leaf2',
|
|
|
254
|
+ },
|
|
|
255
|
+ ],
|
|
|
256
|
+ },
|
|
|
257
|
+ {
|
|
|
258
|
+ label: 'parent 1-1',
|
|
|
259
|
+ value: 'parent 1-1',
|
|
|
260
|
+ },
|
|
|
261
|
+ ],
|
|
|
262
|
+ },
|
|
|
263
|
+ {
|
|
|
264
|
+ label: 'parent 2',
|
|
|
265
|
+ value: 'parent 2',
|
|
|
266
|
+ },
|
|
|
267
|
+ ],
|
|
|
268
|
+ },
|
|
|
269
|
+ ],
|
|
|
270
|
+ treeNodeFilterProp: 'label',
|
|
|
271
|
+ },
|
|
|
272
|
+ fieldName: 'treeSelect',
|
|
|
273
|
+ label: '树选择',
|
|
|
274
|
+ },
|
|
|
275
|
+ ]
|
|
|
276
|
+```
|