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