@vxe-ui/plugin-render-antd 4.3.1 → 4.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -20
- package/README.md +171 -171
- package/dist/index.umd.js +117 -19
- package/dist/index.umd.min.js +1 -1
- package/es/index.esm.js +3 -3
- package/es/index.js +3 -3
- package/es/table/index.js +92 -4
- package/lib/index.common.js +3 -3
- package/lib/index.js +3 -3
- package/lib/index.umd.js +117 -19
- package/lib/index.umd.min.js +1 -1
- package/lib/table/index.js +109 -11
- package/package.json +76 -77
- package/src/form/index.ts +313 -313
- package/src/form-design/checkbox-widget.ts +165 -165
- package/src/form-design/date-picker-widget.ts +145 -145
- package/src/form-design/index.ts +101 -101
- package/src/form-design/input-widget.ts +145 -145
- package/src/form-design/number-input-widget.ts +145 -145
- package/src/form-design/radio-widget.ts +165 -165
- package/src/form-design/select-widget.ts +157 -157
- package/src/form-design/switch-widget.ts +141 -141
- package/src/form-design/textarea-widget.ts +149 -149
- package/src/form-design/use.ts +255 -255
- package/src/index.ts +118 -118
- package/src/store/index.ts +5 -5
- package/src/table/index.ts +631 -544
- package/src/util/comp.ts +10 -10
- package/types/index.d.ts +19 -19
package/src/table/index.ts
CHANGED
|
@@ -1,544 +1,631 @@
|
|
|
1
|
-
import { h, ComponentOptions } from 'vue'
|
|
2
|
-
import { getCurrComponent } from '../util/comp'
|
|
3
|
-
import XEUtils from 'xe-utils'
|
|
4
|
-
|
|
5
|
-
import type { VxeUIExport, VxeGlobalRendererHandles } from 'vxe-pc-ui'
|
|
6
|
-
import type { VxeTableDefines, VxeColumnPropTypes } from 'vxe-table'
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* 表格 - 渲染器
|
|
10
|
-
*/
|
|
11
|
-
export function defineTableRender (VxeUI: VxeUIExport) {
|
|
12
|
-
function isEmptyValue (cellValue: any) {
|
|
13
|
-
return cellValue === null || cellValue === undefined || cellValue === ''
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function getOnName (type: string) {
|
|
17
|
-
return 'on' + type.substring(0, 1).toLocaleUpperCase() + type.substring(1)
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function getModelProp (renderOpts: VxeGlobalRendererHandles.RenderOptions) {
|
|
21
|
-
let prop = 'value'
|
|
22
|
-
switch (renderOpts.name) {
|
|
23
|
-
case 'ASwitch':
|
|
24
|
-
prop = 'checked'
|
|
25
|
-
break
|
|
26
|
-
}
|
|
27
|
-
return prop
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function getModelEvent (renderOpts: VxeGlobalRendererHandles.RenderOptions) {
|
|
31
|
-
let type = 'update:value'
|
|
32
|
-
switch (renderOpts.name) {
|
|
33
|
-
case 'ASwitch':
|
|
34
|
-
type = 'update:checked'
|
|
35
|
-
break
|
|
36
|
-
}
|
|
37
|
-
return type
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function dateFormatToVxeFormat (format: string) {
|
|
41
|
-
if (format) {
|
|
42
|
-
return `${format}`.replace('YYYY', 'yyyy').replace('DD', 'dd')
|
|
43
|
-
}
|
|
44
|
-
return format
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function getChangeEvent (renderOpts: VxeGlobalRendererHandles.RenderOptions) {
|
|
48
|
-
return 'change'
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function getCellEditFilterProps (renderOpts: any, params: VxeGlobalRendererHandles.RenderEditParams | VxeGlobalRendererHandles.RenderFilterParams, value: any, defaultProps?: { [prop: string]: any }) {
|
|
52
|
-
return XEUtils.assign({}, defaultProps, renderOpts.props, { [getModelProp(renderOpts)]: value })
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function formatText (cellValue: any) {
|
|
56
|
-
return '' + (isEmptyValue(cellValue) ? '' : cellValue)
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function getCellLabelVNs (renderOpts: VxeColumnPropTypes.EditRender, params: VxeGlobalRendererHandles.RenderCellParams, cellLabel: any) {
|
|
60
|
-
const { placeholder } = renderOpts
|
|
61
|
-
return [
|
|
62
|
-
h('span', {
|
|
63
|
-
class: 'vxe-cell--label'
|
|
64
|
-
}, placeholder && isEmptyValue(cellLabel)
|
|
65
|
-
? [
|
|
66
|
-
h('span', {
|
|
67
|
-
class: 'vxe-cell--placeholder'
|
|
68
|
-
}, formatText(placeholder))
|
|
69
|
-
]
|
|
70
|
-
: formatText(cellLabel))
|
|
71
|
-
]
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function getOns (renderOpts: VxeGlobalRendererHandles.RenderOptions, params: VxeGlobalRendererHandles.RenderParams, inputFunc?: Function, changeFunc?: Function) {
|
|
75
|
-
const { events } = renderOpts
|
|
76
|
-
const modelEvent = getModelEvent(renderOpts)
|
|
77
|
-
const changeEvent = getChangeEvent(renderOpts)
|
|
78
|
-
const isSameEvent = changeEvent === modelEvent
|
|
79
|
-
const ons: { [type: string]: Function } = {}
|
|
80
|
-
XEUtils.objectEach(events, (func: Function, key: string) => {
|
|
81
|
-
ons[getOnName(key)] = function (...args: any[]) {
|
|
82
|
-
func(params, ...args)
|
|
83
|
-
}
|
|
84
|
-
})
|
|
85
|
-
if (inputFunc) {
|
|
86
|
-
ons[getOnName(modelEvent)] = function (targetEvnt: any) {
|
|
87
|
-
inputFunc(targetEvnt)
|
|
88
|
-
if (events && events[modelEvent]) {
|
|
89
|
-
events[modelEvent](params, targetEvnt)
|
|
90
|
-
}
|
|
91
|
-
if (isSameEvent && changeFunc) {
|
|
92
|
-
changeFunc(targetEvnt)
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
if (!isSameEvent && changeFunc) {
|
|
97
|
-
ons[getOnName(changeEvent)] = function (...args: any[]) {
|
|
98
|
-
changeFunc(...args)
|
|
99
|
-
if (events && events[changeEvent]) {
|
|
100
|
-
events[changeEvent](params, ...args)
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
return ons
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
function getEditOns (renderOpts: VxeGlobalRendererHandles.RenderOptions, params: VxeGlobalRendererHandles.RenderEditParams) {
|
|
108
|
-
const { $table, row, column } = params
|
|
109
|
-
return getOns(renderOpts, params, (value: any) => {
|
|
110
|
-
// 处理 model 值双向绑定
|
|
111
|
-
XEUtils.set(row, column.field, value)
|
|
112
|
-
}, () => {
|
|
113
|
-
// 处理 change 事件相关逻辑
|
|
114
|
-
$table.updateStatus(params)
|
|
115
|
-
})
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
function getFilterOns (renderOpts: any, params: VxeGlobalRendererHandles.RenderFilterParams, option: VxeTableDefines.FilterOption, changeFunc: Function) {
|
|
119
|
-
return getOns(renderOpts, params, (value: any) => {
|
|
120
|
-
// 处理 model 值双向绑定
|
|
121
|
-
option.data = value
|
|
122
|
-
}, changeFunc)
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
function matchCascaderData (index: number, list: any[], values: any[], labels: any[]) {
|
|
126
|
-
const val = values[index]
|
|
127
|
-
if (list && values.length > index) {
|
|
128
|
-
XEUtils.each(list, (item) => {
|
|
129
|
-
if (item.value === val) {
|
|
130
|
-
labels.push(item.label)
|
|
131
|
-
matchCascaderData(++index, item.children, values, labels)
|
|
132
|
-
}
|
|
133
|
-
})
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
function formatDatePicker (defaultFormat?: string) {
|
|
138
|
-
return function (renderOpts: VxeColumnPropTypes.EditRender, params: VxeGlobalRendererHandles.RenderCellParams) {
|
|
139
|
-
return getCellLabelVNs(renderOpts, params, getDatePickerCellValue(renderOpts, params, defaultFormat))
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
function formatTimePicker (defaultFormat?: string) {
|
|
144
|
-
return function (renderOpts: VxeColumnPropTypes.EditRender, params: VxeGlobalRendererHandles.RenderCellParams) {
|
|
145
|
-
const { props = {} } = renderOpts
|
|
146
|
-
const { row, column } = params
|
|
147
|
-
let cellValue = XEUtils.get(row, column.field)
|
|
148
|
-
try {
|
|
149
|
-
if (cellValue) {
|
|
150
|
-
if (!XEUtils.isString(cellValue)) {
|
|
151
|
-
cellValue = cellValue.format ? cellValue.format(props.format || props.valueFormat || defaultFormat) : XEUtils.toDateString(cellValue, dateFormatToVxeFormat(props.format || props.valueFormat || defaultFormat))
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
} catch (e) {}
|
|
155
|
-
return getCellLabelVNs(renderOpts, params, cellValue)
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
function
|
|
160
|
-
const {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
const
|
|
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
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
const
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
return
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
}
|
|
283
|
-
return
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
function
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
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
|
-
const
|
|
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
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
const
|
|
448
|
-
const
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
return
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
},
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
tableFilterDefaultMethod
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
}
|
|
1
|
+
import { h, ComponentOptions } from 'vue'
|
|
2
|
+
import { getCurrComponent } from '../util/comp'
|
|
3
|
+
import XEUtils from 'xe-utils'
|
|
4
|
+
|
|
5
|
+
import type { VxeUIExport, VxeGlobalRendererHandles } from 'vxe-pc-ui'
|
|
6
|
+
import type { VxeTableDefines, VxeColumnPropTypes } from 'vxe-table'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* 表格 - 渲染器
|
|
10
|
+
*/
|
|
11
|
+
export function defineTableRender (VxeUI: VxeUIExport) {
|
|
12
|
+
function isEmptyValue (cellValue: any) {
|
|
13
|
+
return cellValue === null || cellValue === undefined || cellValue === ''
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function getOnName (type: string) {
|
|
17
|
+
return 'on' + type.substring(0, 1).toLocaleUpperCase() + type.substring(1)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function getModelProp (renderOpts: VxeGlobalRendererHandles.RenderOptions) {
|
|
21
|
+
let prop = 'value'
|
|
22
|
+
switch (renderOpts.name) {
|
|
23
|
+
case 'ASwitch':
|
|
24
|
+
prop = 'checked'
|
|
25
|
+
break
|
|
26
|
+
}
|
|
27
|
+
return prop
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function getModelEvent (renderOpts: VxeGlobalRendererHandles.RenderOptions) {
|
|
31
|
+
let type = 'update:value'
|
|
32
|
+
switch (renderOpts.name) {
|
|
33
|
+
case 'ASwitch':
|
|
34
|
+
type = 'update:checked'
|
|
35
|
+
break
|
|
36
|
+
}
|
|
37
|
+
return type
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function dateFormatToVxeFormat (format: string) {
|
|
41
|
+
if (format) {
|
|
42
|
+
return `${format}`.replace('YYYY', 'yyyy').replace('DD', 'dd')
|
|
43
|
+
}
|
|
44
|
+
return format
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function getChangeEvent (renderOpts: VxeGlobalRendererHandles.RenderOptions) {
|
|
48
|
+
return 'change'
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function getCellEditFilterProps (renderOpts: any, params: VxeGlobalRendererHandles.RenderEditParams | VxeGlobalRendererHandles.RenderFilterParams, value: any, defaultProps?: { [prop: string]: any }) {
|
|
52
|
+
return XEUtils.assign({}, defaultProps, renderOpts.props, { [getModelProp(renderOpts)]: value })
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function formatText (cellValue: any) {
|
|
56
|
+
return '' + (isEmptyValue(cellValue) ? '' : cellValue)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function getCellLabelVNs (renderOpts: VxeColumnPropTypes.EditRender, params: VxeGlobalRendererHandles.RenderCellParams, cellLabel: any) {
|
|
60
|
+
const { placeholder } = renderOpts
|
|
61
|
+
return [
|
|
62
|
+
h('span', {
|
|
63
|
+
class: 'vxe-cell--label'
|
|
64
|
+
}, placeholder && isEmptyValue(cellLabel)
|
|
65
|
+
? [
|
|
66
|
+
h('span', {
|
|
67
|
+
class: 'vxe-cell--placeholder'
|
|
68
|
+
}, formatText(placeholder))
|
|
69
|
+
]
|
|
70
|
+
: formatText(cellLabel))
|
|
71
|
+
]
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function getOns (renderOpts: VxeGlobalRendererHandles.RenderOptions, params: VxeGlobalRendererHandles.RenderParams, inputFunc?: Function, changeFunc?: Function) {
|
|
75
|
+
const { events } = renderOpts
|
|
76
|
+
const modelEvent = getModelEvent(renderOpts)
|
|
77
|
+
const changeEvent = getChangeEvent(renderOpts)
|
|
78
|
+
const isSameEvent = changeEvent === modelEvent
|
|
79
|
+
const ons: { [type: string]: Function } = {}
|
|
80
|
+
XEUtils.objectEach(events, (func: Function, key: string) => {
|
|
81
|
+
ons[getOnName(key)] = function (...args: any[]) {
|
|
82
|
+
func(params, ...args)
|
|
83
|
+
}
|
|
84
|
+
})
|
|
85
|
+
if (inputFunc) {
|
|
86
|
+
ons[getOnName(modelEvent)] = function (targetEvnt: any) {
|
|
87
|
+
inputFunc(targetEvnt)
|
|
88
|
+
if (events && events[modelEvent]) {
|
|
89
|
+
events[modelEvent](params, targetEvnt)
|
|
90
|
+
}
|
|
91
|
+
if (isSameEvent && changeFunc) {
|
|
92
|
+
changeFunc(targetEvnt)
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if (!isSameEvent && changeFunc) {
|
|
97
|
+
ons[getOnName(changeEvent)] = function (...args: any[]) {
|
|
98
|
+
changeFunc(...args)
|
|
99
|
+
if (events && events[changeEvent]) {
|
|
100
|
+
events[changeEvent](params, ...args)
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return ons
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function getEditOns (renderOpts: VxeGlobalRendererHandles.RenderOptions, params: VxeGlobalRendererHandles.RenderEditParams) {
|
|
108
|
+
const { $table, row, column } = params
|
|
109
|
+
return getOns(renderOpts, params, (value: any) => {
|
|
110
|
+
// 处理 model 值双向绑定
|
|
111
|
+
XEUtils.set(row, column.field, value)
|
|
112
|
+
}, () => {
|
|
113
|
+
// 处理 change 事件相关逻辑
|
|
114
|
+
$table.updateStatus(params)
|
|
115
|
+
})
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function getFilterOns (renderOpts: any, params: VxeGlobalRendererHandles.RenderFilterParams, option: VxeTableDefines.FilterOption, changeFunc: Function) {
|
|
119
|
+
return getOns(renderOpts, params, (value: any) => {
|
|
120
|
+
// 处理 model 值双向绑定
|
|
121
|
+
option.data = value
|
|
122
|
+
}, changeFunc)
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function matchCascaderData (index: number, list: any[], values: any[], labels: any[]) {
|
|
126
|
+
const val = values[index]
|
|
127
|
+
if (list && values.length > index) {
|
|
128
|
+
XEUtils.each(list, (item) => {
|
|
129
|
+
if (item.value === val) {
|
|
130
|
+
labels.push(item.label)
|
|
131
|
+
matchCascaderData(++index, item.children, values, labels)
|
|
132
|
+
}
|
|
133
|
+
})
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function formatDatePicker (defaultFormat?: string) {
|
|
138
|
+
return function (renderOpts: VxeColumnPropTypes.EditRender, params: VxeGlobalRendererHandles.RenderCellParams) {
|
|
139
|
+
return getCellLabelVNs(renderOpts, params, getDatePickerCellValue(renderOpts, params, defaultFormat))
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function formatTimePicker (defaultFormat?: string) {
|
|
144
|
+
return function (renderOpts: VxeColumnPropTypes.EditRender, params: VxeGlobalRendererHandles.RenderCellParams) {
|
|
145
|
+
const { props = {} } = renderOpts
|
|
146
|
+
const { row, column } = params
|
|
147
|
+
let cellValue = XEUtils.get(row, column.field)
|
|
148
|
+
try {
|
|
149
|
+
if (cellValue) {
|
|
150
|
+
if (!XEUtils.isString(cellValue)) {
|
|
151
|
+
cellValue = cellValue.format ? cellValue.format(props.format || props.valueFormat || defaultFormat) : XEUtils.toDateString(cellValue, dateFormatToVxeFormat(props.format || props.valueFormat || defaultFormat))
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
} catch (e) {}
|
|
155
|
+
return getCellLabelVNs(renderOpts, params, cellValue)
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function handleFormatSelect (renderOpts: VxeGlobalRendererHandles.RenderTableDefaultOptions, renderParams: VxeGlobalRendererHandles.TableCellFormatterParams | VxeGlobalRendererHandles.TableCellCopyMethodParams) {
|
|
160
|
+
const { cellValue } = renderParams
|
|
161
|
+
return handleSelectCellValue(cellValue, renderOpts)
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function handleSetSelectValue (renderOpts: VxeGlobalRendererHandles.RenderTableDefaultOptions, renderParams: VxeGlobalRendererHandles.TableCellFormatterParams | VxeGlobalRendererHandles.TableCellCopyMethodParams) {
|
|
165
|
+
const { row, column, cellValue } = renderParams
|
|
166
|
+
const { field } = column
|
|
167
|
+
if (field) {
|
|
168
|
+
const { options, optionGroups, optionProps = {}, optionGroupProps = {}, props } = renderOpts
|
|
169
|
+
if (isEmptyValue(cellValue)) {
|
|
170
|
+
XEUtils.set(row, field, props && props.mode === 'multiple' ? [] : null)
|
|
171
|
+
return
|
|
172
|
+
}
|
|
173
|
+
const isMultiVal = XEUtils.indexOf(`${cellValue}`, ',') > -1
|
|
174
|
+
const labelProp = optionProps.label || 'label'
|
|
175
|
+
const valueProp = optionProps.value || 'value'
|
|
176
|
+
const labelMpas: Record<string, any> = {}
|
|
177
|
+
if (optionGroups && optionGroups.length) {
|
|
178
|
+
const groupOptions = optionGroupProps.options || 'options'
|
|
179
|
+
for (let i = 0; i < optionGroups.length; i++) {
|
|
180
|
+
const opts = optionGroups[i][groupOptions] || {}
|
|
181
|
+
for (let j = 0; j < opts.length; j++) {
|
|
182
|
+
const item = opts[j]
|
|
183
|
+
if (isMultiVal) {
|
|
184
|
+
labelMpas[item[labelProp]] = item
|
|
185
|
+
/* eslint-disable eqeqeq */
|
|
186
|
+
} else if (item[labelProp] == cellValue) {
|
|
187
|
+
XEUtils.set(row, field, item[valueProp])
|
|
188
|
+
return
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
} else {
|
|
193
|
+
if (options) {
|
|
194
|
+
for (let i = 0; i < options.length; i++) {
|
|
195
|
+
const item = options[i]
|
|
196
|
+
if (isMultiVal) {
|
|
197
|
+
labelMpas[item[labelProp]] = item
|
|
198
|
+
/* eslint-disable eqeqeq */
|
|
199
|
+
} else if (item[labelProp] == cellValue) {
|
|
200
|
+
XEUtils.set(row, field, item[valueProp])
|
|
201
|
+
return
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
if (isMultiVal) {
|
|
207
|
+
XEUtils.set(row, field, (isMultiVal
|
|
208
|
+
? cellValue.split(',')
|
|
209
|
+
: [cellValue]).map((label: any) => {
|
|
210
|
+
const item = labelMpas[label]
|
|
211
|
+
return item ? item[valueProp] : label
|
|
212
|
+
}))
|
|
213
|
+
} else {
|
|
214
|
+
XEUtils.set(row, field, cellValue)
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
function handleSelectCellValue (cellValue: any, renderOpts: VxeGlobalRendererHandles.RenderTableCellOptions) {
|
|
220
|
+
const { options = [], optionGroups, props = {}, optionProps = {}, optionGroupProps = {} } = renderOpts
|
|
221
|
+
const labelProp = optionProps.label || 'label'
|
|
222
|
+
const valueProp = optionProps.value || 'value'
|
|
223
|
+
const groupOptions = optionGroupProps.options || 'options'
|
|
224
|
+
if (!isEmptyValue(cellValue)) {
|
|
225
|
+
return XEUtils.map(props.mode === 'multiple' ? cellValue : [cellValue], optionGroups
|
|
226
|
+
? (value) => {
|
|
227
|
+
let selectItem
|
|
228
|
+
for (let index = 0; index < optionGroups.length; index++) {
|
|
229
|
+
selectItem = XEUtils.find(optionGroups[index][groupOptions], (item) => item[valueProp] === value)
|
|
230
|
+
if (selectItem) {
|
|
231
|
+
break
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
return selectItem ? selectItem[labelProp] : value
|
|
235
|
+
}
|
|
236
|
+
: (value) => {
|
|
237
|
+
const selectItem = XEUtils.find(options, (item) => item[valueProp] === value)
|
|
238
|
+
return selectItem ? selectItem[labelProp] : value
|
|
239
|
+
}).join(', ')
|
|
240
|
+
}
|
|
241
|
+
return ''
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
function getSelectCellValue (renderOpts: VxeColumnPropTypes.EditRender, params: VxeGlobalRendererHandles.RenderCellParams) {
|
|
245
|
+
const { row, column } = params
|
|
246
|
+
const cellValue = XEUtils.get(row, column.field)
|
|
247
|
+
return handleSelectCellValue(cellValue, renderOpts)
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
function getCascaderCellValue (renderOpts: VxeGlobalRendererHandles.RenderOptions, params: VxeGlobalRendererHandles.RenderCellParams | VxeGlobalRendererHandles.ExportMethodParams) {
|
|
251
|
+
const { props = {} } = renderOpts
|
|
252
|
+
const { row, column } = params
|
|
253
|
+
const cellValue = XEUtils.get(row, column.field)
|
|
254
|
+
const values = cellValue || []
|
|
255
|
+
const labels: Array<any> = []
|
|
256
|
+
matchCascaderData(0, props.options, values, labels)
|
|
257
|
+
return (props.showAllLevels === false ? labels.slice(labels.length - 1, labels.length) : labels).join(` ${props.separator || '/'} `)
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
function getRangePickerCellValue (renderOpts: VxeColumnPropTypes.EditRender, params: VxeGlobalRendererHandles.RenderCellParams | VxeGlobalRendererHandles.RenderEditParams) {
|
|
261
|
+
const { props = {} } = renderOpts
|
|
262
|
+
const { row, column } = params
|
|
263
|
+
let cellValue = XEUtils.get(row, column.field)
|
|
264
|
+
if (cellValue) {
|
|
265
|
+
cellValue = XEUtils.map(cellValue, (date: any) => {
|
|
266
|
+
return date && date.format ? date.format(props.format || 'YYYY-MM-DD') : XEUtils.toDateString(date, dateFormatToVxeFormat(props.format || 'YYYY-MM-DD'))
|
|
267
|
+
}).join(' ~ ')
|
|
268
|
+
}
|
|
269
|
+
return cellValue
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
function getTreeSelectCellValue (renderOpts: VxeGlobalRendererHandles.RenderOptions, params: VxeGlobalRendererHandles.RenderCellParams | VxeGlobalRendererHandles.RenderEditParams) {
|
|
273
|
+
const { props = {} } = renderOpts
|
|
274
|
+
const { treeData, treeCheckable } = props
|
|
275
|
+
const { row, column } = params
|
|
276
|
+
const cellValue = XEUtils.get(row, column.field)
|
|
277
|
+
if (!isEmptyValue(cellValue)) {
|
|
278
|
+
return XEUtils.map(treeCheckable ? cellValue : [cellValue], (value) => {
|
|
279
|
+
const matchObj = XEUtils.findTree(treeData, (item: any) => item.value === value, { children: 'children' })
|
|
280
|
+
return matchObj ? matchObj.item.title : value
|
|
281
|
+
}).join(', ')
|
|
282
|
+
}
|
|
283
|
+
return cellValue
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
function getDatePickerCellValue (renderOpts: VxeGlobalRendererHandles.RenderOptions, params: VxeGlobalRendererHandles.RenderCellParams | VxeGlobalRendererHandles.ExportMethodParams, defaultFormat?: string) {
|
|
287
|
+
const { props = {} } = renderOpts
|
|
288
|
+
const { row, column } = params
|
|
289
|
+
let cellValue = XEUtils.get(row, column.field)
|
|
290
|
+
try {
|
|
291
|
+
if (cellValue) {
|
|
292
|
+
if (!defaultFormat) {
|
|
293
|
+
if (renderOpts.name === 'ADatePicker') {
|
|
294
|
+
switch (props.picker) {
|
|
295
|
+
case 'week':
|
|
296
|
+
defaultFormat = 'YYYY-WW周'
|
|
297
|
+
break
|
|
298
|
+
case 'month':
|
|
299
|
+
defaultFormat = 'YYYY-MM'
|
|
300
|
+
break
|
|
301
|
+
case 'year':
|
|
302
|
+
defaultFormat = 'YYYY'
|
|
303
|
+
break
|
|
304
|
+
default:
|
|
305
|
+
defaultFormat = props.showTime ? 'YYYY-MM-DD HH:mm:ss' : 'YYYY-MM-DD'
|
|
306
|
+
break
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
cellValue = cellValue.format ? cellValue.format(props.format || defaultFormat) : XEUtils.toDateString(cellValue, dateFormatToVxeFormat(props.format || defaultFormat))
|
|
311
|
+
}
|
|
312
|
+
} catch (e) {}
|
|
313
|
+
return cellValue
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
function createEditRender (defaultProps?: { [key: string]: any }) {
|
|
317
|
+
return function (renderOpts: VxeColumnPropTypes.EditRender & { name: string }, params: VxeGlobalRendererHandles.RenderEditParams) {
|
|
318
|
+
const { row, column } = params
|
|
319
|
+
const { name, attrs } = renderOpts
|
|
320
|
+
const cellValue = XEUtils.get(row, column.field)
|
|
321
|
+
return [
|
|
322
|
+
h(getCurrComponent(name), {
|
|
323
|
+
...attrs,
|
|
324
|
+
...getCellEditFilterProps(renderOpts, params, cellValue, defaultProps),
|
|
325
|
+
...getEditOns(renderOpts, params)
|
|
326
|
+
})
|
|
327
|
+
]
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
function defaultButtonEditRender (renderOpts: VxeColumnPropTypes.EditRender, params: VxeGlobalRendererHandles.RenderEditParams) {
|
|
332
|
+
const { attrs } = renderOpts
|
|
333
|
+
return [
|
|
334
|
+
h(getCurrComponent('a-button'), {
|
|
335
|
+
...attrs,
|
|
336
|
+
...getCellEditFilterProps(renderOpts, params, null),
|
|
337
|
+
...getOns(renderOpts, params)
|
|
338
|
+
}, cellText(renderOpts.content))
|
|
339
|
+
]
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
function defaultButtonsEditRender (renderOpts: VxeColumnPropTypes.EditRender, params: VxeGlobalRendererHandles.RenderEditParams) {
|
|
343
|
+
const { children } = renderOpts
|
|
344
|
+
if (children) {
|
|
345
|
+
return children.map((childRenderOpts: VxeColumnPropTypes.EditRender) => defaultButtonEditRender(childRenderOpts, params)[0])
|
|
346
|
+
}
|
|
347
|
+
return []
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
function createFilterRender (defaultProps?: { [key: string]: any }) {
|
|
351
|
+
return function (renderOpts: VxeColumnPropTypes.FilterRender & { name: string }, params: VxeGlobalRendererHandles.RenderFilterParams) {
|
|
352
|
+
const { column } = params
|
|
353
|
+
const { name, attrs } = renderOpts
|
|
354
|
+
return [
|
|
355
|
+
h('div', {
|
|
356
|
+
class: 'vxe-table--filter-antd-wrapper'
|
|
357
|
+
}, column.filters.map((option, oIndex) => {
|
|
358
|
+
const optionValue = option.data
|
|
359
|
+
return h(getCurrComponent(name), {
|
|
360
|
+
key: oIndex,
|
|
361
|
+
...attrs,
|
|
362
|
+
...getCellEditFilterProps(renderOpts, params, optionValue, defaultProps),
|
|
363
|
+
...getFilterOns(renderOpts, params, option, () => {
|
|
364
|
+
// 处理 change 事件相关逻辑
|
|
365
|
+
handleConfirmFilter(params, !!option.data, option)
|
|
366
|
+
})
|
|
367
|
+
})
|
|
368
|
+
}))
|
|
369
|
+
]
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
function handleConfirmFilter (params: VxeGlobalRendererHandles.RenderFilterParams, checked: boolean, option: VxeTableDefines.FilterOption) {
|
|
374
|
+
const { $panel } = params
|
|
375
|
+
$panel.changeOption(null, checked, option)
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* 模糊匹配
|
|
380
|
+
* @param params
|
|
381
|
+
*/
|
|
382
|
+
function defaultFuzzyFilterMethod (params: VxeGlobalRendererHandles.FilterMethodParams) {
|
|
383
|
+
const { option, row, column } = params
|
|
384
|
+
const { data } = option
|
|
385
|
+
const cellValue = XEUtils.get(row, column.field)
|
|
386
|
+
return XEUtils.toValueString(cellValue).indexOf(data) > -1
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* 精确匹配
|
|
391
|
+
* @param params
|
|
392
|
+
*/
|
|
393
|
+
function defaultExactFilterMethod (params: VxeGlobalRendererHandles.FilterMethodParams) {
|
|
394
|
+
const { option, row, column } = params
|
|
395
|
+
const { data } = option
|
|
396
|
+
const cellValue = XEUtils.get(row, column.field)
|
|
397
|
+
/* eslint-disable eqeqeq */
|
|
398
|
+
return cellValue === data
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
function cellText (cellValue: any): string[] {
|
|
402
|
+
return [formatText(cellValue)]
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
function createDatePickerExportMethod (defaultFormat?: string) {
|
|
406
|
+
return function (params: VxeGlobalRendererHandles.ExportMethodParams) {
|
|
407
|
+
const { row, column, options } = params
|
|
408
|
+
return options && options.original ? XEUtils.get(row, column.field) : getDatePickerCellValue(column.editRender || column.cellRender, params, defaultFormat)
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
function createExportMethod (getExportCellValue: Function) {
|
|
413
|
+
return function (params: VxeGlobalRendererHandles.ExportMethodParams) {
|
|
414
|
+
const { row, column, options } = params
|
|
415
|
+
return options && options.original ? XEUtils.get(row, column.field) : getExportCellValue(column.editRender || column.cellRender, params)
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
VxeUI.renderer.mixin({
|
|
420
|
+
AAutoComplete: {
|
|
421
|
+
tableAutoFocus: 'input',
|
|
422
|
+
renderTableDefault: createEditRender(),
|
|
423
|
+
renderTableEdit: createEditRender(),
|
|
424
|
+
renderTableFilter: createFilterRender(),
|
|
425
|
+
tableFilterDefaultMethod: defaultExactFilterMethod
|
|
426
|
+
},
|
|
427
|
+
AInput: {
|
|
428
|
+
tableAutoFocus: 'input',
|
|
429
|
+
renderTableDefault: createEditRender(),
|
|
430
|
+
renderTableEdit: createEditRender(),
|
|
431
|
+
renderTableFilter: createFilterRender(),
|
|
432
|
+
tableFilterDefaultMethod: defaultFuzzyFilterMethod
|
|
433
|
+
},
|
|
434
|
+
AInputNumber: {
|
|
435
|
+
tableAutoFocus: 'input',
|
|
436
|
+
renderTableDefault: createEditRender(),
|
|
437
|
+
renderTableEdit: createEditRender(),
|
|
438
|
+
renderTableFilter: createFilterRender(),
|
|
439
|
+
tableFilterDefaultMethod: defaultFuzzyFilterMethod
|
|
440
|
+
},
|
|
441
|
+
ASelect: {
|
|
442
|
+
renderTableEdit (renderOpts, params) {
|
|
443
|
+
const { options, optionGroups } = renderOpts
|
|
444
|
+
const { row, column } = params
|
|
445
|
+
const { attrs } = renderOpts
|
|
446
|
+
const cellValue = XEUtils.get(row, column.field)
|
|
447
|
+
const props = getCellEditFilterProps(renderOpts, params, cellValue)
|
|
448
|
+
const ons = getEditOns(renderOpts, params)
|
|
449
|
+
if (optionGroups) {
|
|
450
|
+
return [
|
|
451
|
+
h(getCurrComponent('a-select') as ComponentOptions, {
|
|
452
|
+
...props,
|
|
453
|
+
...attrs,
|
|
454
|
+
options: optionGroups,
|
|
455
|
+
...ons
|
|
456
|
+
})
|
|
457
|
+
]
|
|
458
|
+
}
|
|
459
|
+
return [
|
|
460
|
+
h(getCurrComponent('a-select') as ComponentOptions, {
|
|
461
|
+
...props,
|
|
462
|
+
...attrs,
|
|
463
|
+
options: props.options || options,
|
|
464
|
+
...ons
|
|
465
|
+
})
|
|
466
|
+
]
|
|
467
|
+
},
|
|
468
|
+
renderTableCell (renderOpts, params) {
|
|
469
|
+
const { options, optionGroups } = renderOpts
|
|
470
|
+
const { $table, row, column } = params
|
|
471
|
+
const opSize = options ? options.length : null
|
|
472
|
+
const ogSize = optionGroups ? optionGroups.length : null
|
|
473
|
+
if ($table.effectCellData) {
|
|
474
|
+
const { cellResult } = $table.effectCellData(row, column, {
|
|
475
|
+
key: 'render_table_cell',
|
|
476
|
+
isChanged ({ oldValue, cellValue }) {
|
|
477
|
+
return oldValue && oldValue[0] === cellValue && oldValue[1] === opSize && oldValue[2] === ogSize
|
|
478
|
+
},
|
|
479
|
+
setValue ({ cellValue }) {
|
|
480
|
+
return [cellValue, opSize, ogSize]
|
|
481
|
+
},
|
|
482
|
+
getResult ({ cellValue }) {
|
|
483
|
+
return handleSelectCellValue(cellValue, renderOpts)
|
|
484
|
+
}
|
|
485
|
+
})
|
|
486
|
+
return getCellLabelVNs(renderOpts, params, cellResult)
|
|
487
|
+
}
|
|
488
|
+
const cellResult = getSelectCellValue(renderOpts, params)
|
|
489
|
+
return getCellLabelVNs(renderOpts, params, cellResult)
|
|
490
|
+
},
|
|
491
|
+
renderTableFilter (renderOpts, params) {
|
|
492
|
+
const { options = [], optionGroups, optionGroupProps = {} } = renderOpts
|
|
493
|
+
const groupOptions = optionGroupProps.options || 'options'
|
|
494
|
+
const { column } = params
|
|
495
|
+
const { attrs } = renderOpts
|
|
496
|
+
return [
|
|
497
|
+
h('div', {
|
|
498
|
+
class: 'vxe-table--filter-antd-wrapper'
|
|
499
|
+
}, optionGroups
|
|
500
|
+
? column.filters.map((option, oIndex) => {
|
|
501
|
+
const optionValue = option.data
|
|
502
|
+
const props = getCellEditFilterProps(renderOpts, params, optionValue)
|
|
503
|
+
return h(getCurrComponent('a-select') as ComponentOptions, {
|
|
504
|
+
key: oIndex,
|
|
505
|
+
...attrs,
|
|
506
|
+
...props,
|
|
507
|
+
options: groupOptions,
|
|
508
|
+
...getFilterOns(renderOpts, params, option, () => {
|
|
509
|
+
// 处理 change 事件相关逻辑
|
|
510
|
+
handleConfirmFilter(params, props.mode === 'multiple' ? (option.data && option.data.length > 0) : !XEUtils.eqNull(option.data), option)
|
|
511
|
+
})
|
|
512
|
+
})
|
|
513
|
+
})
|
|
514
|
+
: column.filters.map((option, oIndex) => {
|
|
515
|
+
const optionValue = option.data
|
|
516
|
+
const props = getCellEditFilterProps(renderOpts, params, optionValue)
|
|
517
|
+
return h(getCurrComponent('a-select') as ComponentOptions, {
|
|
518
|
+
key: oIndex,
|
|
519
|
+
...attrs,
|
|
520
|
+
...props,
|
|
521
|
+
options: props.options || options,
|
|
522
|
+
...getFilterOns(renderOpts, params, option, () => {
|
|
523
|
+
// 处理 change 事件相关逻辑
|
|
524
|
+
handleConfirmFilter(params, props.mode === 'multiple' ? (option.data && option.data.length > 0) : !XEUtils.eqNull(option.data), option)
|
|
525
|
+
})
|
|
526
|
+
})
|
|
527
|
+
}))
|
|
528
|
+
]
|
|
529
|
+
},
|
|
530
|
+
tableCellFormatter: handleFormatSelect,
|
|
531
|
+
tableCellCopyMethod: handleFormatSelect,
|
|
532
|
+
tableCellPasteMethod: handleSetSelectValue,
|
|
533
|
+
tableFilterDefaultMethod (params) {
|
|
534
|
+
const { option, row, column } = params
|
|
535
|
+
const { data } = option
|
|
536
|
+
const { field, filterRender: renderOpts } = column
|
|
537
|
+
const { props = {} } = renderOpts
|
|
538
|
+
const cellValue = XEUtils.get(row, field)
|
|
539
|
+
if (props.mode === 'multiple') {
|
|
540
|
+
if (XEUtils.isArray(cellValue)) {
|
|
541
|
+
return XEUtils.includeArrays(cellValue, data)
|
|
542
|
+
}
|
|
543
|
+
return data.indexOf(cellValue) > -1
|
|
544
|
+
}
|
|
545
|
+
/* eslint-disable eqeqeq */
|
|
546
|
+
return cellValue == data
|
|
547
|
+
},
|
|
548
|
+
tableExportMethod: createExportMethod(getSelectCellValue)
|
|
549
|
+
},
|
|
550
|
+
ACascader: {
|
|
551
|
+
renderTableEdit: createEditRender(),
|
|
552
|
+
renderTableCell (renderOpts, params) {
|
|
553
|
+
return getCellLabelVNs(renderOpts, params, getCascaderCellValue(renderOpts, params))
|
|
554
|
+
},
|
|
555
|
+
tableExportMethod: createExportMethod(getCascaderCellValue)
|
|
556
|
+
},
|
|
557
|
+
ADatePicker: {
|
|
558
|
+
renderTableEdit: createEditRender(),
|
|
559
|
+
renderTableCell: formatDatePicker(),
|
|
560
|
+
tableExportMethod: createDatePickerExportMethod()
|
|
561
|
+
},
|
|
562
|
+
AMonthPicker: {
|
|
563
|
+
renderTableEdit: createEditRender(),
|
|
564
|
+
renderTableCell: formatDatePicker('YYYY-MM'),
|
|
565
|
+
tableExportMethod: createDatePickerExportMethod('YYYY-MM')
|
|
566
|
+
},
|
|
567
|
+
ARangePicker: {
|
|
568
|
+
renderTableEdit: createEditRender(),
|
|
569
|
+
renderTableCell (renderOpts, params) {
|
|
570
|
+
return getCellLabelVNs(renderOpts, params, getRangePickerCellValue(renderOpts, params))
|
|
571
|
+
},
|
|
572
|
+
tableExportMethod: createExportMethod(getRangePickerCellValue)
|
|
573
|
+
},
|
|
574
|
+
AWeekPicker: {
|
|
575
|
+
renderTableEdit: createEditRender(),
|
|
576
|
+
renderTableCell: formatDatePicker('YYYY-WW周'),
|
|
577
|
+
tableExportMethod: createDatePickerExportMethod('YYYY-WW周')
|
|
578
|
+
},
|
|
579
|
+
ATimePicker: {
|
|
580
|
+
renderTableEdit: createEditRender(),
|
|
581
|
+
renderTableCell: formatTimePicker('HH:mm:ss'),
|
|
582
|
+
tableExportMethod: createDatePickerExportMethod('HH:mm:ss')
|
|
583
|
+
},
|
|
584
|
+
ATreeSelect: {
|
|
585
|
+
renderTableEdit: createEditRender(),
|
|
586
|
+
renderTableCell (renderOpts, params) {
|
|
587
|
+
return getCellLabelVNs(renderOpts, params, getTreeSelectCellValue(renderOpts, params))
|
|
588
|
+
},
|
|
589
|
+
tableExportMethod: createExportMethod(getTreeSelectCellValue)
|
|
590
|
+
},
|
|
591
|
+
ARate: {
|
|
592
|
+
renderTableDefault: createEditRender(),
|
|
593
|
+
renderTableEdit: createEditRender(),
|
|
594
|
+
renderTableFilter: createFilterRender(),
|
|
595
|
+
tableFilterDefaultMethod: defaultExactFilterMethod
|
|
596
|
+
},
|
|
597
|
+
ASwitch: {
|
|
598
|
+
renderTableDefault: createEditRender(),
|
|
599
|
+
renderTableEdit: createEditRender(),
|
|
600
|
+
renderTableFilter (renderOpts, params) {
|
|
601
|
+
const { column } = params
|
|
602
|
+
const { name, attrs } = renderOpts
|
|
603
|
+
return [
|
|
604
|
+
h('div', {
|
|
605
|
+
class: 'vxe-table--filter-antd-wrapper'
|
|
606
|
+
}, column.filters.map((option, oIndex) => {
|
|
607
|
+
const optionValue = option.data
|
|
608
|
+
return h(name as string, {
|
|
609
|
+
key: oIndex,
|
|
610
|
+
...attrs,
|
|
611
|
+
...getCellEditFilterProps(renderOpts, params, optionValue),
|
|
612
|
+
...getFilterOns(renderOpts, params, option, () => {
|
|
613
|
+
// 处理 change 事件相关逻辑
|
|
614
|
+
handleConfirmFilter(params, XEUtils.isBoolean(option.data), option)
|
|
615
|
+
})
|
|
616
|
+
})
|
|
617
|
+
}))
|
|
618
|
+
]
|
|
619
|
+
},
|
|
620
|
+
tableFilterDefaultMethod: defaultExactFilterMethod
|
|
621
|
+
},
|
|
622
|
+
AButton: {
|
|
623
|
+
renderTableEdit: defaultButtonEditRender,
|
|
624
|
+
renderTableDefault: defaultButtonEditRender
|
|
625
|
+
},
|
|
626
|
+
AButtons: {
|
|
627
|
+
renderTableEdit: defaultButtonsEditRender,
|
|
628
|
+
renderTableDefault: defaultButtonsEditRender
|
|
629
|
+
}
|
|
630
|
+
})
|
|
631
|
+
}
|