1
2
3
4
5
6
7
8
import { FormProps, FormSchema } from '/@/components/Table';
import { BasicColumn } from '/@/components/Table/src/types/table';
export function getBasicColumns(): BasicColumn[] {
return [
{
title: 'ID',
dataIndex: 'id',
vben
authored
5 years ago
9
fixed: 'left',
vben
authored
5 years ago
10
width: 200,
11
12
13
14
},
{
title: '姓名',
dataIndex: 'name',
vben
authored
5 years ago
15
width: 150,
vben
authored
5 years ago
16
17
18
19
filters: [
{ text: 'Male', value: 'male' },
{ text: 'Female', value: 'female' },
],
20
21
22
23
24
25
26
27
},
{
title: '地址',
dataIndex: 'address',
},
{
title: '编号',
dataIndex: 'no',
vben
authored
5 years ago
28
width: 150,
vben
authored
5 years ago
29
sorter: true,
vben
authored
5 years ago
30
defaultHidden: true,
31
32
33
},
{
title: '开始时间',
34
width: 150,
vben
authored
5 years ago
35
sorter: true,
36
37
38
39
dataIndex: 'beginTime',
},
{
title: '结束时间',
40
width: 150,
41
42
43
44
45
46
47
48
49
50
51
52
sorter: true,
dataIndex: 'endTime',
},
];
}
export function getBasicShortColumns(): BasicColumn[] {
return [
{
title: 'ID',
width: 150,
dataIndex: 'id',
vben
authored
5 years ago
53
54
sorter: true,
sortOrder: 'ascend',
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
},
{
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
95
96
{ text: 'Male', value: 'male', children: [] },
{ text: 'Female', value: 'female', children: [] },
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
],
},
{
title: '开始时间',
dataIndex: 'beginTime',
width: 120,
},
{
title: '结束时间',
dataIndex: 'endTime',
width: 120,
},
],
},
];
}
export function getCustomHeaderColumns(): BasicColumn[] {
return [
{
title: 'ID',
dataIndex: 'id',
120
helpMessage: 'headerHelpMessage方式1',
121
122
123
124
125
126
width: 200,
},
{
// title: '姓名',
dataIndex: 'name',
width: 120,
127
// slots: { title: 'customTitle' },
128
129
130
131
},
{
// title: '地址',
dataIndex: 'address',
vben
authored
5 years ago
132
width: 120,
133
// slots: { title: 'customAddress' },
134
135
136
137
138
139
140
141
sorter: true,
},
{
title: '编号',
dataIndex: 'no',
width: 120,
filters: [
vben
authored
5 years ago
142
143
{ text: 'Male', value: 'male', children: [] },
{ text: 'Female', value: 'female', children: [] },
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
],
},
{
title: '开始时间',
dataIndex: 'beginTime',
width: 120,
},
{
title: '结束时间',
dataIndex: 'endTime',
width: 120,
},
];
}
const renderContent = ({ text, index }: { text: any; index: number }) => {
const obj: any = {
children: text,
attrs: {},
};
if (index === 9) {
obj.attrs.colSpan = 0;
}
return obj;
};
export function getMergeHeaderColumns(): BasicColumn[] {
return [
{
title: 'ID',
dataIndex: 'id',
width: 300,
customRender: renderContent,
},
{
title: '姓名',
dataIndex: 'name',
width: 300,
customRender: renderContent,
},
{
title: '地址',
dataIndex: 'address',
colSpan: 2,
width: 120,
sorter: true,
customRender: ({ text, index }: { text: any; index: number }) => {
const obj: any = {
children: text,
attrs: {},
};
if (index === 2) {
obj.attrs.rowSpan = 2;
}
if (index === 3) {
obj.attrs.colSpan = 0;
}
return obj;
},
},
{
title: '编号',
dataIndex: 'no',
colSpan: 0,
filters: [
vben
authored
5 years ago
207
208
{ text: 'Male', value: 'male', children: [] },
{ text: 'Female', value: 'female', children: [] },
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
],
customRender: renderContent,
},
{
title: '开始时间',
dataIndex: 'beginTime',
width: 200,
customRender: renderContent,
},
{
title: '结束时间',
dataIndex: 'endTime',
width: 200,
customRender: renderContent,
},
];
}
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
244
245
246
247
schemas: [
...getAdvanceSchema(5),
{
field: `field11`,
Vben
authored
4 years ago
248
label: `Slot示例`,
vben
authored
5 years ago
249
component: 'Select',
vben
authored
5 years ago
250
slot: 'custom',
vben
authored
5 years ago
251
252
253
254
255
256
colProps: {
xl: 12,
xxl: 8,
},
},
],
257
258
259
};
}
export function getBasicData() {
260
return (() => {
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
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() {
278
return (() => {
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
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;
})();
}