1
import { optionsListApi } from '/@/api/demo/select';
2
3
import { FormProps, FormSchema } from '/@/components/Table';
import { BasicColumn } from '/@/components/Table/src/types/table';
4
import { VxeFormItemProps, VxeGridPropTypes } from '/@/components/VxeTable';
5
6
7
8
9
10
export function getBasicColumns(): BasicColumn[] {
return [
{
title: 'ID',
dataIndex: 'id',
vben
authored
5 years ago
11
fixed: 'left',
vben
authored
5 years ago
12
width: 200,
13
14
15
16
},
{
title: '姓名',
dataIndex: 'name',
vben
authored
5 years ago
17
width: 150,
vben
authored
5 years ago
18
19
20
21
filters: [
{ text: 'Male', value: 'male' },
{ text: 'Female', value: 'female' },
],
22
23
24
25
26
27
28
29
},
{
title: '地址',
dataIndex: 'address',
},
{
title: '编号',
dataIndex: 'no',
vben
authored
5 years ago
30
width: 150,
vben
authored
5 years ago
31
sorter: true,
vben
authored
5 years ago
32
defaultHidden: true,
33
34
35
},
{
title: '开始时间',
36
width: 150,
vben
authored
5 years ago
37
sorter: true,
38
39
40
41
dataIndex: 'beginTime',
},
{
title: '结束时间',
42
width: 150,
43
44
45
46
47
48
49
50
51
52
53
54
sorter: true,
dataIndex: 'endTime',
},
];
}
export function getBasicShortColumns(): BasicColumn[] {
return [
{
title: 'ID',
width: 150,
dataIndex: 'id',
vben
authored
5 years ago
55
56
sorter: true,
sortOrder: 'ascend',
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
},
{
title: '姓名',
dataIndex: 'name',
width: 120,
},
{
title: '地址',
dataIndex: 'address',
},
{
title: '编号',
dataIndex: 'no',
width: 80,
},
];
}
export function getMultipleHeaderColumns(): BasicColumn[] {
return [
{
title: 'ID',
dataIndex: 'id',
width: 200,
},
{
title: '姓名',
dataIndex: 'name',
width: 120,
},
{
title: '地址',
dataIndex: 'address',
sorter: true,
children: [
{
title: '编号',
dataIndex: 'no',
width: 120,
filters: [
vben
authored
5 years ago
97
98
{ text: 'Male', value: 'male', children: [] },
{ text: 'Female', value: 'female', children: [] },
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
],
},
{
title: '开始时间',
dataIndex: 'beginTime',
width: 120,
},
{
title: '结束时间',
dataIndex: 'endTime',
width: 120,
},
],
},
];
}
export function getCustomHeaderColumns(): BasicColumn[] {
return [
{
title: 'ID',
dataIndex: 'id',
122
helpMessage: 'headerHelpMessage方式1',
123
124
125
126
127
128
width: 200,
},
{
// title: '姓名',
dataIndex: 'name',
width: 120,
129
// slots: { title: 'customTitle' },
130
131
132
133
},
{
// title: '地址',
dataIndex: 'address',
vben
authored
5 years ago
134
width: 120,
135
// slots: { title: 'customAddress' },
136
137
138
139
140
141
142
143
sorter: true,
},
{
title: '编号',
dataIndex: 'no',
width: 120,
filters: [
vben
authored
5 years ago
144
145
{ text: 'Male', value: 'male', children: [] },
{ text: 'Female', value: 'female', children: [] },
146
147
148
149
150
151
152
153
154
155
156
157
158
159
],
},
{
title: '开始时间',
dataIndex: 'beginTime',
width: 120,
},
{
title: '结束时间',
dataIndex: 'endTime',
width: 120,
},
];
}
160
161
162
163
164
const cellContent = (_, index) => ({
colSpan: index === 9 ? 0 : 1,
});
165
166
167
168
169
170
export function getMergeHeaderColumns(): BasicColumn[] {
return [
{
title: 'ID',
dataIndex: 'id',
width: 300,
171
172
173
customCell: (_, index) => ({
colSpan: index === 9 ? 6 : 1,
}),
174
175
176
177
178
},
{
title: '姓名',
dataIndex: 'name',
width: 300,
179
customCell: cellContent,
180
181
182
183
184
185
186
},
{
title: '地址',
dataIndex: 'address',
colSpan: 2,
width: 120,
sorter: true,
187
188
189
190
customCell: (_, index) => ({
rowSpan: index === 2 ? 2 : 1,
colSpan: index === 3 || index === 9 ? 0 : 1,
}),
191
192
193
194
195
196
},
{
title: '编号',
dataIndex: 'no',
colSpan: 0,
filters: [
vben
authored
5 years ago
197
198
{ text: 'Male', value: 'male', children: [] },
{ text: 'Female', value: 'female', children: [] },
199
],
200
customCell: cellContent,
201
202
203
204
205
},
{
title: '开始时间',
dataIndex: 'beginTime',
width: 200,
206
customCell: cellContent,
207
208
209
210
211
},
{
title: '结束时间',
dataIndex: 'endTime',
width: 200,
212
customCell: cellContent,
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
},
];
}
export const getAdvanceSchema = (itemNumber = 6): FormSchema[] => {
const arr: any = [];
for (let index = 0; index < itemNumber; index++) {
arr.push({
field: `field${index}`,
label: `字段${index}`,
component: 'Input',
colProps: {
xl: 12,
xxl: 8,
},
});
}
return arr;
};
export function getFormConfig(): Partial<FormProps> {
return {
labelWidth: 100,
vben
authored
5 years ago
234
235
236
237
schemas: [
...getAdvanceSchema(5),
{
field: `field11`,
Vben
authored
4 years ago
238
label: `Slot示例`,
vben
authored
5 years ago
239
component: 'Select',
vben
authored
5 years ago
240
slot: 'custom',
vben
authored
5 years ago
241
242
243
244
245
246
colProps: {
xl: 12,
xxl: 8,
},
},
],
247
248
249
};
}
export function getBasicData() {
250
return (() => {
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
const arr: any = [];
for (let index = 0; index < 40; index++) {
arr.push({
id: `${index}`,
name: 'John Brown',
age: `1${index}`,
no: `${index + 10}`,
address: 'New York No. 1 Lake ParkNew York No. 1 Lake Park',
beginTime: new Date().toLocaleString(),
endTime: new Date().toLocaleString(),
});
}
return arr;
})();
}
export function getTreeTableData() {
268
return (() => {
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
const arr: any = [];
for (let index = 0; index < 40; index++) {
arr.push({
id: `${index}`,
name: 'John Brown',
age: `1${index}`,
no: `${index + 10}`,
address: 'New York No. 1 Lake ParkNew York No. 1 Lake Park',
beginTime: new Date().toLocaleString(),
endTime: new Date().toLocaleString(),
children: [
{
id: `l2-${index}`,
name: 'John Brown',
age: `1${index}`,
no: `${index + 10}`,
address: 'New York No. 1 Lake ParkNew York No. 1 Lake Park',
beginTime: new Date().toLocaleString(),
endTime: new Date().toLocaleString(),
},
],
});
}
return arr;
})();
}
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
export const vxeTableColumns: VxeGridPropTypes.Columns = [
{
title: '序号',
type: 'seq',
fixed: 'left',
width: '50',
align: 'center',
},
{
title: '固定列',
field: 'name',
width: 150,
showOverflow: 'tooltip',
fixed: 'left',
},
{
title: '自适应列',
field: 'address',
},
{
title: '自定义列(自定义导出)',
field: 'no',
width: 200,
showOverflow: 'tooltip',
align: 'center',
slots: {
default: ({ row }) => {
const text = `自定义${row.no}`;
return [<div class="text-red-500">{text}</div>];
},
},
exportMethod: ({ row }) => {
return `自定义${row.no}导出`;
},
},
{
title: '自定义编辑',
width: 150,
field: 'name1',
align: 'center',
editRender: {
name: 'AInput',
placeholder: '请点击输入',
},
},
{
title: '开始时间',
width: 150,
field: 'beginTime',
showOverflow: 'tooltip',
align: 'center',
},
{
title: '结束时间',
width: 150,
field: 'endTime',
showOverflow: 'tooltip',
align: 'center',
},
{
width: 160,
title: '操作',
align: 'center',
slots: { default: 'action' },
fixed: 'right',
},
];
export const vxeTableFormSchema: VxeFormItemProps[] = [
{
field: 'field0',
title: 'field0',
itemRender: {
name: 'AInput',
},
span: 6,
},
{
field: 'field1',
title: 'field1',
itemRender: {
name: 'AApiSelect',
props: {
api: optionsListApi,
resultField: 'list',
labelField: 'name',
valueField: 'id',
},
},
span: 6,
},
{
span: 12,
align: 'right',
className: '!pr-0',
itemRender: {
name: 'AButtonGroup',
children: [
{
props: { type: 'primary', content: '查询', htmlType: 'submit' },
attrs: { class: 'mr-2' },
},
{ props: { type: 'default', htmlType: 'reset', content: '重置' } },
],
},
},
];