提交 | 用户 | age
|
faf3f4
|
1 |
import { FormProps, FormSchema } from '/@/components/Table'; |
陈 |
2 |
import { BasicColumn } from '/@/components/Table/src/types/table'; |
|
3 |
|
|
4 |
export function getBasicColumns(): BasicColumn[] { |
|
5 |
return [ |
|
6 |
{ |
|
7 |
title: 'ID', |
|
8 |
width: 150, |
|
9 |
dataIndex: 'id', |
|
10 |
}, |
|
11 |
{ |
|
12 |
title: '姓名', |
|
13 |
dataIndex: 'name', |
|
14 |
width: 120, |
|
15 |
}, |
|
16 |
{ |
|
17 |
title: '地址', |
|
18 |
dataIndex: 'address', |
|
19 |
}, |
|
20 |
{ |
|
21 |
title: '编号', |
|
22 |
dataIndex: 'no', |
|
23 |
width: 80, |
|
24 |
}, |
|
25 |
{ |
|
26 |
title: '开始时间', |
|
27 |
dataIndex: 'beginTime', |
|
28 |
}, |
|
29 |
{ |
|
30 |
title: '结束时间', |
|
31 |
sorter: true, |
|
32 |
dataIndex: 'endTime', |
|
33 |
}, |
|
34 |
]; |
|
35 |
} |
|
36 |
|
|
37 |
export function getBasicShortColumns(): BasicColumn[] { |
|
38 |
return [ |
|
39 |
{ |
|
40 |
title: 'ID', |
|
41 |
width: 150, |
|
42 |
dataIndex: 'id', |
|
43 |
}, |
|
44 |
{ |
|
45 |
title: '姓名', |
|
46 |
dataIndex: 'name', |
|
47 |
width: 120, |
|
48 |
}, |
|
49 |
{ |
|
50 |
title: '地址', |
|
51 |
dataIndex: 'address', |
|
52 |
}, |
|
53 |
{ |
|
54 |
title: '编号', |
|
55 |
dataIndex: 'no', |
|
56 |
width: 80, |
|
57 |
}, |
|
58 |
]; |
|
59 |
} |
|
60 |
|
|
61 |
export function getMultipleHeaderColumns(): BasicColumn[] { |
|
62 |
return [ |
|
63 |
{ |
|
64 |
title: 'ID', |
|
65 |
dataIndex: 'id', |
|
66 |
width: 200, |
|
67 |
}, |
|
68 |
{ |
|
69 |
title: '姓名', |
|
70 |
dataIndex: 'name', |
|
71 |
width: 120, |
|
72 |
}, |
|
73 |
{ |
|
74 |
title: '地址', |
|
75 |
dataIndex: 'address', |
|
76 |
sorter: true, |
|
77 |
children: [ |
|
78 |
{ |
|
79 |
title: '编号', |
|
80 |
dataIndex: 'no', |
|
81 |
width: 120, |
|
82 |
filters: [ |
69af37
|
83 |
{ text: 'Male', value: 'male', children: [] }, |
V |
84 |
{ text: 'Female', value: 'female', children: [] }, |
faf3f4
|
85 |
], |
陈 |
86 |
}, |
|
87 |
|
|
88 |
{ |
|
89 |
title: '开始时间', |
|
90 |
dataIndex: 'beginTime', |
|
91 |
width: 120, |
|
92 |
}, |
|
93 |
{ |
|
94 |
title: '结束时间', |
|
95 |
dataIndex: 'endTime', |
|
96 |
width: 120, |
|
97 |
}, |
|
98 |
], |
|
99 |
}, |
|
100 |
]; |
|
101 |
} |
|
102 |
|
|
103 |
export function getCustomHeaderColumns(): BasicColumn[] { |
|
104 |
return [ |
|
105 |
{ |
|
106 |
title: 'ID', |
|
107 |
dataIndex: 'id', |
|
108 |
width: 200, |
|
109 |
}, |
|
110 |
{ |
|
111 |
// title: '姓名', |
|
112 |
dataIndex: 'name', |
|
113 |
width: 120, |
|
114 |
slots: { title: 'customTitle' }, |
|
115 |
}, |
|
116 |
{ |
|
117 |
// title: '地址', |
|
118 |
dataIndex: 'address', |
|
119 |
slots: { title: 'customAddress' }, |
|
120 |
sorter: true, |
|
121 |
}, |
|
122 |
|
|
123 |
{ |
|
124 |
title: '编号', |
|
125 |
dataIndex: 'no', |
|
126 |
width: 120, |
|
127 |
filters: [ |
69af37
|
128 |
{ text: 'Male', value: 'male', children: [] }, |
V |
129 |
{ text: 'Female', value: 'female', children: [] }, |
faf3f4
|
130 |
], |
陈 |
131 |
}, |
|
132 |
{ |
|
133 |
title: '开始时间', |
|
134 |
dataIndex: 'beginTime', |
|
135 |
width: 120, |
|
136 |
}, |
|
137 |
{ |
|
138 |
title: '结束时间', |
|
139 |
dataIndex: 'endTime', |
|
140 |
width: 120, |
|
141 |
}, |
|
142 |
]; |
|
143 |
} |
|
144 |
const renderContent = ({ text, index }: { text: any; index: number }) => { |
|
145 |
const obj: any = { |
|
146 |
children: text, |
|
147 |
attrs: {}, |
|
148 |
}; |
|
149 |
if (index === 9) { |
|
150 |
obj.attrs.colSpan = 0; |
|
151 |
} |
|
152 |
return obj; |
|
153 |
}; |
|
154 |
export function getMergeHeaderColumns(): BasicColumn[] { |
|
155 |
return [ |
|
156 |
{ |
|
157 |
title: 'ID', |
|
158 |
dataIndex: 'id', |
|
159 |
width: 300, |
|
160 |
customRender: renderContent, |
|
161 |
}, |
|
162 |
{ |
|
163 |
title: '姓名', |
|
164 |
dataIndex: 'name', |
|
165 |
width: 300, |
|
166 |
customRender: renderContent, |
|
167 |
}, |
|
168 |
{ |
|
169 |
title: '地址', |
|
170 |
dataIndex: 'address', |
|
171 |
colSpan: 2, |
|
172 |
width: 120, |
|
173 |
sorter: true, |
|
174 |
customRender: ({ text, index }: { text: any; index: number }) => { |
|
175 |
const obj: any = { |
|
176 |
children: text, |
|
177 |
attrs: {}, |
|
178 |
}; |
|
179 |
if (index === 2) { |
|
180 |
obj.attrs.rowSpan = 2; |
|
181 |
} |
|
182 |
if (index === 3) { |
|
183 |
obj.attrs.colSpan = 0; |
|
184 |
} |
|
185 |
return obj; |
|
186 |
}, |
|
187 |
}, |
|
188 |
{ |
|
189 |
title: '编号', |
|
190 |
dataIndex: 'no', |
|
191 |
colSpan: 0, |
|
192 |
filters: [ |
69af37
|
193 |
{ text: 'Male', value: 'male', children: [] }, |
V |
194 |
{ text: 'Female', value: 'female', children: [] }, |
faf3f4
|
195 |
], |
陈 |
196 |
customRender: renderContent, |
|
197 |
}, |
|
198 |
{ |
|
199 |
title: '开始时间', |
|
200 |
dataIndex: 'beginTime', |
|
201 |
width: 200, |
|
202 |
customRender: renderContent, |
|
203 |
}, |
|
204 |
{ |
|
205 |
title: '结束时间', |
|
206 |
dataIndex: 'endTime', |
|
207 |
width: 200, |
|
208 |
customRender: renderContent, |
|
209 |
}, |
|
210 |
]; |
|
211 |
} |
|
212 |
export const getAdvanceSchema = (itemNumber = 6): FormSchema[] => { |
|
213 |
const arr: any = []; |
|
214 |
for (let index = 0; index < itemNumber; index++) { |
|
215 |
arr.push({ |
|
216 |
field: `field${index}`, |
|
217 |
label: `字段${index}`, |
|
218 |
component: 'Input', |
|
219 |
colProps: { |
|
220 |
xl: 12, |
|
221 |
xxl: 8, |
|
222 |
}, |
|
223 |
}); |
|
224 |
} |
|
225 |
return arr; |
|
226 |
}; |
|
227 |
export function getFormConfig(): Partial<FormProps> { |
|
228 |
return { |
|
229 |
labelWidth: 100, |
1c075a
|
230 |
schemas: [ |
V |
231 |
...getAdvanceSchema(5), |
|
232 |
{ |
|
233 |
field: `field11`, |
|
234 |
label: `字段33`, |
|
235 |
component: 'Select', |
|
236 |
defaultValue: '1', |
|
237 |
componentProps: { |
|
238 |
options: [ |
|
239 |
{ |
|
240 |
label: '选项1', |
|
241 |
value: '1', |
|
242 |
}, |
|
243 |
{ |
|
244 |
label: '选项2', |
|
245 |
value: '2', |
|
246 |
}, |
|
247 |
], |
|
248 |
}, |
|
249 |
colProps: { |
|
250 |
xl: 12, |
|
251 |
xxl: 8, |
|
252 |
}, |
|
253 |
}, |
|
254 |
], |
faf3f4
|
255 |
}; |
陈 |
256 |
} |
|
257 |
export function getBasicData() { |
|
258 |
const data: any = (() => { |
|
259 |
const arr: any = []; |
|
260 |
for (let index = 0; index < 40; index++) { |
|
261 |
arr.push({ |
|
262 |
id: `${index}`, |
|
263 |
name: 'John Brown', |
|
264 |
age: `1${index}`, |
|
265 |
no: `${index + 10}`, |
|
266 |
address: 'New York No. 1 Lake ParkNew York No. 1 Lake Park', |
|
267 |
beginTime: new Date().toLocaleString(), |
|
268 |
endTime: new Date().toLocaleString(), |
|
269 |
}); |
|
270 |
} |
|
271 |
return arr; |
|
272 |
})(); |
|
273 |
return data; |
|
274 |
} |
|
275 |
|
|
276 |
export function getTreeTableData() { |
|
277 |
const data: any = (() => { |
|
278 |
const arr: any = []; |
|
279 |
for (let index = 0; index < 40; index++) { |
|
280 |
arr.push({ |
|
281 |
id: `${index}`, |
|
282 |
name: 'John Brown', |
|
283 |
age: `1${index}`, |
|
284 |
no: `${index + 10}`, |
|
285 |
address: 'New York No. 1 Lake ParkNew York No. 1 Lake Park', |
|
286 |
beginTime: new Date().toLocaleString(), |
|
287 |
endTime: new Date().toLocaleString(), |
|
288 |
children: [ |
|
289 |
{ |
|
290 |
id: `l2-${index}`, |
|
291 |
name: 'John Brown', |
|
292 |
age: `1${index}`, |
|
293 |
no: `${index + 10}`, |
|
294 |
address: 'New York No. 1 Lake ParkNew York No. 1 Lake Park', |
|
295 |
beginTime: new Date().toLocaleString(), |
|
296 |
endTime: new Date().toLocaleString(), |
|
297 |
children: [ |
|
298 |
{ |
|
299 |
id: `l3-${index}`, |
|
300 |
name: 'John Brown', |
|
301 |
age: `1${index}`, |
|
302 |
no: `${index + 10}`, |
|
303 |
address: 'New York No. 1 Lake ParkNew York No. 1 Lake Park', |
|
304 |
beginTime: new Date().toLocaleString(), |
|
305 |
endTime: new Date().toLocaleString(), |
|
306 |
}, |
|
307 |
], |
|
308 |
}, |
|
309 |
], |
|
310 |
}); |
|
311 |
} |
|
312 |
return arr; |
|
313 |
})(); |
|
314 |
|
|
315 |
return data; |
|
316 |
} |