vxe-table 3.10.16 → 3.11.0

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.
Files changed (68) hide show
  1. package/README.md +1 -1
  2. package/es/style.css +1 -1
  3. package/es/style.min.css +1 -1
  4. package/es/table/module/custom/mixin.js +5 -1
  5. package/es/table/module/edit/mixin.js +24 -15
  6. package/es/table/src/body.js +40 -24
  7. package/es/table/src/cell.js +75 -32
  8. package/es/table/src/footer.js +159 -131
  9. package/es/table/src/header.js +128 -90
  10. package/es/table/src/methods.js +284 -65
  11. package/es/table/src/props.js +5 -1
  12. package/es/table/src/table.js +64 -20
  13. package/es/table/style.css +33 -20
  14. package/es/table/style.min.css +1 -1
  15. package/es/ui/index.js +9 -4
  16. package/es/ui/src/log.js +1 -1
  17. package/es/vxe-table/style.css +33 -20
  18. package/es/vxe-table/style.min.css +1 -1
  19. package/helper/vetur/attributes.json +1 -1
  20. package/helper/vetur/tags.json +1 -1
  21. package/lib/index.umd.js +906 -449
  22. package/lib/index.umd.min.js +1 -1
  23. package/lib/style.css +1 -1
  24. package/lib/style.min.css +1 -1
  25. package/lib/table/module/custom/mixin.js +5 -1
  26. package/lib/table/module/custom/mixin.min.js +1 -1
  27. package/lib/table/module/edit/mixin.js +24 -15
  28. package/lib/table/module/edit/mixin.min.js +1 -1
  29. package/lib/table/src/body.js +31 -15
  30. package/lib/table/src/body.min.js +1 -1
  31. package/lib/table/src/cell.js +82 -35
  32. package/lib/table/src/cell.min.js +1 -1
  33. package/lib/table/src/footer.js +198 -161
  34. package/lib/table/src/footer.min.js +1 -1
  35. package/lib/table/src/header.js +169 -128
  36. package/lib/table/src/header.min.js +1 -1
  37. package/lib/table/src/methods.js +313 -68
  38. package/lib/table/src/methods.min.js +1 -1
  39. package/lib/table/src/props.js +5 -1
  40. package/lib/table/src/props.min.js +1 -1
  41. package/lib/table/src/table.js +70 -20
  42. package/lib/table/src/table.min.js +1 -1
  43. package/lib/table/style/style.css +33 -20
  44. package/lib/table/style/style.min.css +1 -1
  45. package/lib/ui/index.js +9 -4
  46. package/lib/ui/index.min.js +1 -1
  47. package/lib/ui/src/log.js +1 -1
  48. package/lib/ui/src/log.min.js +1 -1
  49. package/lib/vxe-table/style/style.css +33 -20
  50. package/lib/vxe-table/style/style.min.css +1 -1
  51. package/package.json +3 -3
  52. package/packages/table/module/custom/mixin.ts +5 -1
  53. package/packages/table/module/edit/mixin.ts +24 -15
  54. package/packages/table/src/body.ts +43 -25
  55. package/packages/table/src/cell.ts +120 -67
  56. package/packages/table/src/footer.ts +164 -150
  57. package/packages/table/src/header.ts +136 -90
  58. package/packages/table/src/methods.ts +296 -67
  59. package/packages/table/src/props.ts +5 -1
  60. package/packages/table/src/table.ts +71 -19
  61. package/packages/ui/index.ts +8 -3
  62. package/styles/components/table.scss +42 -35
  63. /package/es/{iconfont.1731633464058.ttf → iconfont.1731890707082.ttf} +0 -0
  64. /package/es/{iconfont.1731633464058.woff → iconfont.1731890707082.woff} +0 -0
  65. /package/es/{iconfont.1731633464058.woff2 → iconfont.1731890707082.woff2} +0 -0
  66. /package/lib/{iconfont.1731633464058.ttf → iconfont.1731890707082.ttf} +0 -0
  67. /package/lib/{iconfont.1731633464058.woff → iconfont.1731890707082.woff} +0 -0
  68. /package/lib/{iconfont.1731633464058.woff2 → iconfont.1731890707082.woff2} +0 -0
@@ -1,4 +1,4 @@
1
- import { CreateElement } from 'vue'
1
+ import { CreateElement, VNode } from 'vue'
2
2
  import XEUtils from 'xe-utils'
3
3
  import { VxeUI } from '../../ui'
4
4
  import { getFuncText, isEnableConf, formatText, eqEmptyValue } from '../../ui/src/utils'
@@ -6,6 +6,8 @@ import { updateCellTitle } from '../../ui/src/dom'
6
6
  import { createColumn, getRowid } from './util'
7
7
  import { getSlotVNs } from '../../ui/src/vn'
8
8
 
9
+ import type { VxeTableDefines } from '../../../types'
10
+
9
11
  const { getI18n, getIcon, renderer, formats, renderEmptyElement } = VxeUI
10
12
 
11
13
  function renderTitlePrefixIcon (h: CreateElement, params: any) {
@@ -50,9 +52,12 @@ function renderTitleSuffixIcon (h: CreateElement, params: any) {
50
52
 
51
53
  function renderCellDragIcon (h: CreateElement, params: any) {
52
54
  const { $table } = params
53
- const dragOpts = $table.computeDragOpts
54
- const { rowIcon, rowDisabledMethod } = dragOpts
55
- const isDisabled = rowDisabledMethod && rowDisabledMethod(params)
55
+ const tableProps = $table
56
+ const { dragConfig } = tableProps
57
+ const rowDragOpts = $table.computeRowDragOpts
58
+ const { icon, disabledMethod } = rowDragOpts
59
+ const rDisabledMethod = disabledMethod || (dragConfig ? dragConfig.rowDisabledMethod : null)
60
+ const isDisabled = rDisabledMethod && rDisabledMethod(params)
56
61
  return h('span', {
57
62
  key: 'dg',
58
63
  class: ['vxe-cell--drag-handle', {
@@ -68,21 +73,22 @@ function renderCellDragIcon (h: CreateElement, params: any) {
68
73
  }
69
74
  }, [
70
75
  h('i', {
71
- class: rowIcon || getIcon().TABLE_DRAG_ROW
76
+ class: icon || (dragConfig ? dragConfig.rowIcon : '') || getIcon().TABLE_DRAG_ROW
72
77
  })
73
78
  ])
74
79
  }
75
80
 
76
81
  function renderCellBaseVNs (h: CreateElement, params: any, content: any) {
77
- const { $table, column, row, level } = params
82
+ const { $table, column, level } = params
78
83
  const { dragSort } = column
79
84
  const tableProps = $table
80
- const { treeConfig } = tableProps
85
+ const { treeConfig, dragConfig } = tableProps
81
86
  const rowOpts = $table.computeRowOpts
82
- const dragOpts = $table.computeDragOpts
83
- const { showRowIcon, rowVisibleMethod } = dragOpts
87
+ const rowDragOpts = $table.computeRowDragOpts
88
+ const { showIcon, visibleMethod } = rowDragOpts
89
+ const rVisibleMethod = visibleMethod || (dragConfig ? dragConfig.rowVisibleMethod : null)
84
90
  const vns: any[] = XEUtils.isArray(content) ? content : [content]
85
- if (dragSort && rowOpts.drag && (showRowIcon && (!rowVisibleMethod || rowVisibleMethod({ row, column })))) {
91
+ if (dragSort && rowOpts.drag && ((showIcon || (dragConfig ? dragConfig.showRowIcon : false)) && (!rVisibleMethod || rVisibleMethod(params)))) {
86
92
  if (!treeConfig || !level) {
87
93
  vns.unshift(
88
94
  renderCellDragIcon(h, params)
@@ -92,6 +98,47 @@ function renderCellBaseVNs (h: CreateElement, params: any, content: any) {
92
98
  return vns
93
99
  }
94
100
 
101
+ function renderHeaderCellDragIcon (h: CreateElement, params: VxeTableDefines.CellRenderHeaderParams) {
102
+ const { $table, column } = params
103
+ const columnOpts = $table.computeColumnOpts
104
+ const columnDragOpts = $table.computeColumnDragOpts
105
+ const { showIcon, icon, visibleMethod, disabledMethod } = columnDragOpts
106
+ const isDisabled = disabledMethod && disabledMethod(params)
107
+ if (columnOpts.drag && showIcon && (!visibleMethod || visibleMethod(params))) {
108
+ if (!(column.fixed || column.parentId)) {
109
+ return h('span', {
110
+ key: 'dg',
111
+ class: ['vxe-cell--drag-handle', {
112
+ 'is--disabled': isDisabled
113
+ }],
114
+ on: {
115
+ mousedown (evnt: MouseEvent) {
116
+ if (!isDisabled) {
117
+ $table.handleHeaderCellDragMousedownEvent(evnt, params)
118
+ }
119
+ },
120
+ mouseup: $table.handleHeaderCellDragMouseupEvent
121
+ }
122
+ }, [
123
+ h('i', {
124
+ class: icon || getIcon().TABLE_DRAG_COLUMN
125
+ })
126
+ ])
127
+ }
128
+ }
129
+ return renderEmptyElement($table)
130
+ }
131
+
132
+ function renderHeaderCellBaseVNs (h: CreateElement, params: VxeTableDefines.CellRenderHeaderParams, content: VNode | VNode[]) {
133
+ const vns = [
134
+ renderTitlePrefixIcon(h, params),
135
+ renderHeaderCellDragIcon(h, params),
136
+ ...(XEUtils.isArray(content) ? content : [content]),
137
+ renderTitleSuffixIcon(h, params)
138
+ ]
139
+ return vns
140
+ }
141
+
95
142
  function renderTitleContent (h: CreateElement, params: any, content: any) {
96
143
  const { $table, column } = params
97
144
  const { type, showHeaderOverflow } = column
@@ -252,7 +299,7 @@ export const Cell = {
252
299
  return createColumn($xetable, _vm, renMaps)
253
300
  },
254
301
  /**
255
- * 单元格
302
+ * 列头标题
256
303
  */
257
304
  renderHeaderTitle (h: any, params: any) {
258
305
  const { $table, column } = params
@@ -271,7 +318,7 @@ export const Cell = {
271
318
  return renderTitleContent(h, params, formatText(column.getTitle(), 1))
272
319
  },
273
320
  renderDefaultHeader (h: CreateElement, params: any) {
274
- return renderTitlePrefixIcon(h, params).concat(Cell.renderHeaderTitle(h, params)).concat(renderTitleSuffixIcon(h, params))
321
+ return renderHeaderCellBaseVNs(h, params, Cell.renderHeaderTitle(h, params))
275
322
  },
276
323
  renderDefaultCell (h: CreateElement, params: any) {
277
324
  const { $table, row, column } = params
@@ -380,12 +427,12 @@ export const Cell = {
380
427
  },
381
428
 
382
429
  /**
383
- * 索引
430
+ * 序号
384
431
  */
385
432
  renderSeqHeader (h: CreateElement, params: any) {
386
433
  const { $table, column } = params
387
434
  const { slots } = column
388
- return renderTitleContent(h, params, slots && slots.header ? $table.callSlot(slots.header, params, h) : formatText(column.getTitle(), 1))
435
+ return renderHeaderCellBaseVNs(h, params, renderTitleContent(h, params, slots && slots.header ? $table.callSlot(slots.header, params, h) : formatText(column.getTitle(), 1)))
389
436
  },
390
437
  renderSeqCell (h: CreateElement, params: any) {
391
438
  const { $table, column } = params
@@ -412,13 +459,15 @@ export const Cell = {
412
459
  const { slots } = column
413
460
  const headerSlot = slots ? slots.header : null
414
461
  const titleSlot = slots ? slots.title : null
415
- return renderTitleContent(h, params, headerSlot
416
- ? $table.callSlot(headerSlot, params, h)
417
- : [
418
- h('span', {
419
- class: 'vxe-radio--label'
420
- }, titleSlot ? $table.callSlot(titleSlot, params, h) : formatText(column.getTitle(), 1))
421
- ])
462
+ return renderHeaderCellBaseVNs(h, params,
463
+ renderTitleContent(h, params, headerSlot
464
+ ? $table.callSlot(headerSlot, params, h)
465
+ : [
466
+ h('span', {
467
+ class: 'vxe-radio--label'
468
+ }, titleSlot ? $table.callSlot(titleSlot, params, h) : formatText(column.getTitle(), 1))
469
+ ])
470
+ )
422
471
  },
423
472
  renderRadioCell (h: CreateElement, params: any) {
424
473
  const { $table, column, isHidden } = params
@@ -500,38 +549,40 @@ export const Cell = {
500
549
  }
501
550
  const checkboxParams = { ...params, checked: isAllCheckboxSelected, disabled: isAllCheckboxDisabled, indeterminate: isAllCheckboxIndeterminate }
502
551
  if (headerSlot) {
503
- return renderTitleContent(h, checkboxParams, $table.callSlot(headerSlot, checkboxParams, h))
552
+ return renderHeaderCellBaseVNs(h, params, renderTitleContent(h, checkboxParams, $table.callSlot(headerSlot, checkboxParams, h)))
504
553
  }
505
554
  if (checkboxOpts.checkStrictly ? !checkboxOpts.showHeader : checkboxOpts.showHeader === false) {
506
- return renderTitleContent(h, checkboxParams, [
555
+ return renderHeaderCellBaseVNs(h, params, renderTitleContent(h, checkboxParams, [
507
556
  h('span', {
508
557
  class: 'vxe-checkbox--label'
509
558
  }, titleSlot ? $table.callSlot(titleSlot, checkboxParams, h) : headerTitle)
510
- ])
559
+ ]))
511
560
  }
512
- return renderTitleContent(h, checkboxParams, [
513
- h('span', {
514
- class: ['vxe-cell--checkbox', {
515
- 'is--checked': isAllCheckboxSelected,
516
- 'is--disabled': isAllCheckboxDisabled,
517
- 'is--indeterminate': isAllCheckboxIndeterminate
518
- }],
519
- attrs: {
520
- title: getI18n('vxe.table.allTitle')
521
- },
522
- on
523
- }, [
561
+ return renderHeaderCellBaseVNs(h, params,
562
+ renderTitleContent(h, checkboxParams, [
524
563
  h('span', {
525
- class: ['vxe-checkbox--icon', isAllCheckboxIndeterminate ? getIcon().TABLE_CHECKBOX_INDETERMINATE : (isAllCheckboxSelected ? getIcon().TABLE_CHECKBOX_CHECKED : getIcon().TABLE_CHECKBOX_UNCHECKED)]
526
- })
527
- ].concat(titleSlot || headerTitle
528
- ? [
529
- h('span', {
530
- class: 'vxe-checkbox--label'
531
- }, titleSlot ? $table.callSlot(titleSlot, checkboxParams, h) : headerTitle)
532
- ]
533
- : []))
534
- ])
564
+ class: ['vxe-cell--checkbox', {
565
+ 'is--checked': isAllCheckboxSelected,
566
+ 'is--disabled': isAllCheckboxDisabled,
567
+ 'is--indeterminate': isAllCheckboxIndeterminate
568
+ }],
569
+ attrs: {
570
+ title: getI18n('vxe.table.allTitle')
571
+ },
572
+ on
573
+ }, [
574
+ h('span', {
575
+ class: ['vxe-checkbox--icon', isAllCheckboxIndeterminate ? getIcon().TABLE_CHECKBOX_INDETERMINATE : (isAllCheckboxSelected ? getIcon().TABLE_CHECKBOX_CHECKED : getIcon().TABLE_CHECKBOX_UNCHECKED)]
576
+ })
577
+ ].concat(titleSlot || headerTitle
578
+ ? [
579
+ h('span', {
580
+ class: 'vxe-checkbox--label'
581
+ }, titleSlot ? $table.callSlot(titleSlot, checkboxParams, h) : headerTitle)
582
+ ]
583
+ : []))
584
+ ])
585
+ )
535
586
  },
536
587
  renderCheckboxCell (h: CreateElement, params: any) {
537
588
  const { $table, row, column, isHidden } = params
@@ -748,16 +799,14 @@ export const Cell = {
748
799
  * 排序和筛选
749
800
  */
750
801
  renderSortAndFilterHeader (h: CreateElement, params: any) {
751
- return Cell.renderDefaultHeader(h, params)
752
- .concat(Cell.renderSortIcon(h, params))
753
- .concat(Cell.renderFilterIcon(h, params))
802
+ return renderHeaderCellBaseVNs(h, params, Cell.renderHeaderTitle(h, params).concat(Cell.renderSortIcon(h, params)))
754
803
  },
755
804
 
756
805
  /**
757
806
  * 排序
758
807
  */
759
808
  renderSortHeader (h: CreateElement, params: any) {
760
- return Cell.renderDefaultHeader(h, params).concat(Cell.renderSortIcon(h, params))
809
+ return renderHeaderCellBaseVNs(h, params, Cell.renderHeaderTitle(h, params).concat(Cell.renderSortIcon(h, params)))
761
810
  },
762
811
  renderSortIcon (h: CreateElement, params: any) {
763
812
  const { $table, column } = params
@@ -804,7 +853,7 @@ export const Cell = {
804
853
  * 筛选
805
854
  */
806
855
  renderFilterHeader (h: CreateElement, params: any) {
807
- return Cell.renderDefaultHeader(h, params).concat(Cell.renderFilterIcon(h, params))
856
+ return renderHeaderCellBaseVNs(h, params, Cell.renderHeaderTitle(h, params).concat(Cell.renderFilterIcon(h, params)))
808
857
  },
809
858
  renderFilterIcon (h: CreateElement, params: any) {
810
859
  const { $table, column, hasFilter } = params
@@ -849,22 +898,26 @@ export const Cell = {
849
898
  isRequired = columnRules.some((rule: any) => rule.required)
850
899
  }
851
900
  }
852
- return (isEnableConf(editConfig)
853
- ? [
854
- isRequired && editOpts.showAsterisk
855
- ? h('i', {
856
- class: 'vxe-cell--required-icon'
857
- })
858
- : null,
859
- isEnableConf(editRender) && editOpts.showIcon
860
- ? h('i', {
861
- class: ['vxe-cell--edit-icon', editOpts.icon || getIcon().TABLE_EDIT]
862
- })
863
- : null
864
- ]
865
- : []).concat(Cell.renderDefaultHeader(h, params))
866
- .concat(sortable || remoteSort ? Cell.renderSortIcon(h, params) : [])
867
- .concat(filters ? Cell.renderFilterIcon(h, params) : [])
901
+ let editIconVNs: VNode[] = []
902
+ if (isEnableConf(editConfig)) {
903
+ editIconVNs = [
904
+ isRequired && editOpts.showAsterisk
905
+ ? h('i', {
906
+ class: 'vxe-cell--required-icon'
907
+ })
908
+ : renderEmptyElement($table),
909
+ isEnableConf(editRender) && editOpts.showIcon
910
+ ? h('i', {
911
+ class: ['vxe-cell--edit-icon', editOpts.icon || getIcon().TABLE_EDIT]
912
+ })
913
+ : renderEmptyElement($table)
914
+ ]
915
+ }
916
+ return renderHeaderCellBaseVNs(h, params,
917
+ editIconVNs.concat(Cell.renderHeaderTitle(h, params))
918
+ .concat(sortable || remoteSort ? Cell.renderSortIcon(h, params) : [])
919
+ .concat(filters ? Cell.renderFilterIcon(h, params) : [])
920
+ )
868
921
  },
869
922
  // 行格编辑模式
870
923
  renderRowEdit (h: CreateElement, params: any) {
@@ -4,6 +4,8 @@ import { VxeUI } from '../../ui'
4
4
  import { getClass } from '../../ui/src/utils'
5
5
  import { updateCellTitle, setScrollLeft } from '../../ui/src/dom'
6
6
 
7
+ import type { VxeTableDefines } from '../../../types'
8
+
7
9
  const renderType = 'footer'
8
10
 
9
11
  const { renderer } = VxeUI
@@ -22,6 +24,166 @@ function mergeFooterMethod (mergeFooterList: any, _rowIndex: any, _columnIndex:
22
24
  }
23
25
  }
24
26
 
27
+ function renderRows (h: CreateElement, _vm: any, tableColumn: VxeTableDefines.ColumnInfo[], footerTableData: any[], row: any, $rowIndex: number, _rowIndex: number) {
28
+ const { $parent: $xetable, fixedType } = _vm
29
+ const { $listeners: tableListeners, footerCellClassName, footerCellStyle, footerAlign: allFooterAlign, mergeFooterList, footerSpanMethod, align: allAlign, scrollXLoad, columnKey, columnOpts, showFooterOverflow: allColumnFooterOverflow, currentColumn, overflowX, scrollbarWidth, tooltipOpts } = $xetable
30
+
31
+ return tableColumn.map((column: any, $columnIndex: any) => {
32
+ const { type, showFooterOverflow, footerAlign, align, footerClassName, editRender, cellRender } = column
33
+ const renderOpts = editRender || cellRender
34
+ const compConf = renderOpts ? renderer.get(renderOpts.name) : null
35
+ const showAllTip = tooltipOpts.showAll || tooltipOpts.enabled
36
+ const isColGroup = column.children && column.children.length
37
+ const fixedHiddenColumn = fixedType ? column.fixed !== fixedType && !isColGroup : column.fixed && overflowX
38
+ const footOverflow = XEUtils.isUndefined(showFooterOverflow) || XEUtils.isNull(showFooterOverflow) ? allColumnFooterOverflow : showFooterOverflow
39
+ const footAlign = footerAlign || (compConf ? compConf.tableFooterCellAlign : '') || allFooterAlign || align || (compConf ? compConf.tableCellAlign : '') || allAlign
40
+ let showEllipsis = footOverflow === 'ellipsis'
41
+ const showTitle = footOverflow === 'title'
42
+ const showTooltip = footOverflow === true || footOverflow === 'tooltip'
43
+ let hasEllipsis = showTitle || showTooltip || showEllipsis
44
+ const attrs: any = { colid: column.id }
45
+ const tfOns: any = {}
46
+ const columnIndex = $xetable.getColumnIndex(column)
47
+ const _columnIndex = $xetable.getVTColumnIndex(column)
48
+ const itemIndex = _columnIndex
49
+ const cellParams = {
50
+ $table: $xetable,
51
+ $grid: $xetable.xegrid,
52
+ row,
53
+ _rowIndex,
54
+ $rowIndex,
55
+ column,
56
+ columnIndex,
57
+ $columnIndex,
58
+ _columnIndex,
59
+ itemIndex,
60
+ items: row,
61
+ fixed: fixedType,
62
+ type: renderType,
63
+ data: footerTableData
64
+ }
65
+ // 虚拟滚动不支持动态高度
66
+ if (scrollXLoad && !hasEllipsis) {
67
+ showEllipsis = hasEllipsis = true
68
+ }
69
+ if (showTitle || showTooltip || showAllTip) {
70
+ tfOns.mouseenter = (evnt: any) => {
71
+ if (showTitle) {
72
+ updateCellTitle(evnt.currentTarget, column)
73
+ } else if (showTooltip || showAllTip) {
74
+ $xetable.triggerFooterTooltipEvent(evnt, cellParams)
75
+ }
76
+ }
77
+ }
78
+ if (showTooltip || showAllTip) {
79
+ tfOns.mouseleave = (evnt: any) => {
80
+ if (showTooltip || showAllTip) {
81
+ $xetable.handleTargetLeaveEvent(evnt)
82
+ }
83
+ }
84
+ }
85
+ if (tableListeners['footer-cell-click']) {
86
+ tfOns.click = (evnt: any) => {
87
+ $xetable.emitEvent('footer-cell-click', Object.assign({ cell: evnt.currentTarget }, cellParams), evnt)
88
+ }
89
+ }
90
+ if (tableListeners['footer-cell-dblclick']) {
91
+ tfOns.dblclick = (evnt: any) => {
92
+ $xetable.emitEvent('footer-cell-dblclick', Object.assign({ cell: evnt.currentTarget }, cellParams), evnt)
93
+ }
94
+ }
95
+ // 合并行或列
96
+ if (mergeFooterList.length) {
97
+ const spanRest = mergeFooterMethod(mergeFooterList, _rowIndex, _columnIndex)
98
+ if (spanRest) {
99
+ const { rowspan, colspan } = spanRest
100
+ if (!rowspan || !colspan) {
101
+ return null
102
+ }
103
+ if (rowspan > 1) {
104
+ attrs.rowspan = rowspan
105
+ }
106
+ if (colspan > 1) {
107
+ attrs.colspan = colspan
108
+ }
109
+ }
110
+ } else if (footerSpanMethod) {
111
+ // 自定义合并方法
112
+ const { rowspan = 1, colspan = 1 } = footerSpanMethod(cellParams) || {}
113
+ if (!rowspan || !colspan) {
114
+ return null
115
+ }
116
+ if (rowspan > 1) {
117
+ attrs.rowspan = rowspan
118
+ }
119
+ if (colspan > 1) {
120
+ attrs.colspan = colspan
121
+ }
122
+ }
123
+ return h('td', {
124
+ class: ['vxe-footer--column', column.id, {
125
+ [`col--${footAlign}`]: footAlign,
126
+ [`col--${type}`]: type,
127
+ 'col--last': $columnIndex === tableColumn.length - 1,
128
+ 'fixed--hidden': fixedHiddenColumn,
129
+ 'col--ellipsis': hasEllipsis,
130
+ 'col--current': currentColumn === column
131
+ }, getClass(footerClassName, cellParams), getClass(footerCellClassName, cellParams)],
132
+ attrs,
133
+ style: footerCellStyle ? (XEUtils.isFunction(footerCellStyle) ? footerCellStyle(cellParams) : footerCellStyle) : null,
134
+ on: tfOns,
135
+ key: columnKey || columnOpts.useKey || columnOpts.drag ? column.id : $columnIndex
136
+ }, [
137
+ h('div', {
138
+ class: ['vxe-cell', {
139
+ 'c--title': showTitle,
140
+ 'c--tooltip': showTooltip,
141
+ 'c--ellipsis': showEllipsis
142
+ }]
143
+ }, column.renderFooter(h, cellParams))
144
+ ])
145
+ }).concat(scrollbarWidth
146
+ ? [
147
+ h('td', {
148
+ key: `gr${$rowIndex}`,
149
+ class: 'vxe-footer--gutter col--gutter'
150
+ })
151
+ ]
152
+ : [])
153
+ }
154
+
155
+ function renderHeads (h: CreateElement, _vm: any, footerTableData: any[]) {
156
+ const { $parent: $xetable, fixedType, tableColumn } = _vm
157
+ const { footerRowClassName, footerRowStyle, isDragColMove } = $xetable
158
+ const columnOpts = $xetable.columnOpts
159
+
160
+ return footerTableData.map((row: any, $rowIndex: any) => {
161
+ const _rowIndex = $rowIndex
162
+ const rowParams = { $table: $xetable, row, _rowIndex, $rowIndex, fixed: fixedType, type: renderType }
163
+
164
+ if (columnOpts.drag) {
165
+ return h('transition-group', {
166
+ props: {
167
+ tag: 'tr',
168
+ name: `vxe-header--col-list${isDragColMove ? '' : '-disabled'}`,
169
+ class: [
170
+ 'vxe-footer--row',
171
+ footerRowClassName ? XEUtils.isFunction(footerRowClassName) ? footerRowClassName(rowParams) : footerRowClassName : ''
172
+ ],
173
+ style: footerRowStyle ? (XEUtils.isFunction(footerRowStyle) ? footerRowStyle(rowParams) : footerRowStyle) : null
174
+ }
175
+ }, renderRows(h, _vm, tableColumn, footerTableData, row, $rowIndex, _rowIndex))
176
+ }
177
+ return h('tr', {
178
+ class: [
179
+ 'vxe-footer--row',
180
+ footerRowClassName ? XEUtils.isFunction(footerRowClassName) ? footerRowClassName(rowParams) : footerRowClassName : ''
181
+ ],
182
+ style: footerRowStyle ? (XEUtils.isFunction(footerRowStyle) ? footerRowStyle(rowParams) : footerRowStyle) : null
183
+ }, renderRows(h, _vm, tableColumn, footerTableData, row, $rowIndex, _rowIndex))
184
+ })
185
+ }
186
+
25
187
  export default {
26
188
  name: 'VxeTableFooter',
27
189
  props: {
@@ -53,28 +215,7 @@ export default {
53
215
  },
54
216
  render (h: CreateElement) {
55
217
  let { _e, $parent: $xetable, fixedType, fixedColumn, tableColumn, footerTableData } = this
56
- const {
57
- $listeners: tableListeners,
58
- tId,
59
- footerRowClassName,
60
- footerCellClassName,
61
- footerRowStyle,
62
- footerCellStyle,
63
- footerAlign: allFooterAlign,
64
- mergeFooterList,
65
- footerSpanMethod,
66
- align: allAlign,
67
- scrollXLoad,
68
- columnKey,
69
- columnOpts,
70
- showFooterOverflow: allColumnFooterOverflow,
71
- currentColumn,
72
- overflowX,
73
- scrollbarWidth,
74
- tooltipOpts,
75
- visibleColumn,
76
- expandColumn
77
- } = $xetable
218
+ const { tId, mergeFooterList, footerSpanMethod, scrollXLoad, showFooterOverflow: allColumnFooterOverflow, scrollbarWidth, visibleColumn, expandColumn } = $xetable
78
219
  // 如果是使用优化模式
79
220
  if (fixedType) {
80
221
  // 如果存在展开行使用全量渲染
@@ -139,134 +280,7 @@ export default {
139
280
  */
140
281
  h('tfoot', {
141
282
  ref: 'tfoot'
142
- }, footerTableData.map((list: any, _rowIndex: any) => {
143
- const $rowIndex = _rowIndex
144
- const rowParams = { $table: $xetable, row: list, _rowIndex, $rowIndex, fixed: fixedType, type: renderType }
145
- return h('tr', {
146
- class: ['vxe-footer--row', footerRowClassName ? XEUtils.isFunction(footerRowClassName) ? footerRowClassName(rowParams) : footerRowClassName : ''],
147
- style: footerRowStyle ? (XEUtils.isFunction(footerRowStyle) ? footerRowStyle(rowParams) : footerRowStyle) : null
148
- }, tableColumn.map((column: any, $columnIndex: any) => {
149
- const { type, showFooterOverflow, footerAlign, align, footerClassName, editRender, cellRender } = column
150
- const renderOpts = editRender || cellRender
151
- const compConf = renderOpts ? renderer.get(renderOpts.name) : null
152
- const showAllTip = tooltipOpts.showAll || tooltipOpts.enabled
153
- const isColGroup = column.children && column.children.length
154
- const fixedHiddenColumn = fixedType ? column.fixed !== fixedType && !isColGroup : column.fixed && overflowX
155
- const footOverflow = XEUtils.isUndefined(showFooterOverflow) || XEUtils.isNull(showFooterOverflow) ? allColumnFooterOverflow : showFooterOverflow
156
- const footAlign = footerAlign || (compConf ? compConf.tableFooterCellAlign : '') || allFooterAlign || align || (compConf ? compConf.tableCellAlign : '') || allAlign
157
- let showEllipsis = footOverflow === 'ellipsis'
158
- const showTitle = footOverflow === 'title'
159
- const showTooltip = footOverflow === true || footOverflow === 'tooltip'
160
- let hasEllipsis = showTitle || showTooltip || showEllipsis
161
- const attrs: any = { colid: column.id }
162
- const tfOns: any = {}
163
- const columnIndex = $xetable.getColumnIndex(column)
164
- const _columnIndex = $xetable.getVTColumnIndex(column)
165
- const itemIndex = _columnIndex
166
- const cellParams = {
167
- $table: $xetable,
168
- $grid: $xetable.xegrid,
169
- row: list,
170
- _rowIndex,
171
- $rowIndex,
172
- column,
173
- columnIndex,
174
- $columnIndex,
175
- _columnIndex,
176
- itemIndex,
177
- items: list,
178
- fixed: fixedType,
179
- type: renderType,
180
- data: footerTableData
181
- }
182
- // 虚拟滚动不支持动态高度
183
- if (scrollXLoad && !hasEllipsis) {
184
- showEllipsis = hasEllipsis = true
185
- }
186
- if (showTitle || showTooltip || showAllTip) {
187
- tfOns.mouseenter = (evnt: any) => {
188
- if (showTitle) {
189
- updateCellTitle(evnt.currentTarget, column)
190
- } else if (showTooltip || showAllTip) {
191
- $xetable.triggerFooterTooltipEvent(evnt, cellParams)
192
- }
193
- }
194
- }
195
- if (showTooltip || showAllTip) {
196
- tfOns.mouseleave = (evnt: any) => {
197
- if (showTooltip || showAllTip) {
198
- $xetable.handleTargetLeaveEvent(evnt)
199
- }
200
- }
201
- }
202
- if (tableListeners['footer-cell-click']) {
203
- tfOns.click = (evnt: any) => {
204
- $xetable.emitEvent('footer-cell-click', Object.assign({ cell: evnt.currentTarget }, cellParams), evnt)
205
- }
206
- }
207
- if (tableListeners['footer-cell-dblclick']) {
208
- tfOns.dblclick = (evnt: any) => {
209
- $xetable.emitEvent('footer-cell-dblclick', Object.assign({ cell: evnt.currentTarget }, cellParams), evnt)
210
- }
211
- }
212
- // 合并行或列
213
- if (mergeFooterList.length) {
214
- const spanRest = mergeFooterMethod(mergeFooterList, _rowIndex, _columnIndex)
215
- if (spanRest) {
216
- const { rowspan, colspan } = spanRest
217
- if (!rowspan || !colspan) {
218
- return null
219
- }
220
- if (rowspan > 1) {
221
- attrs.rowspan = rowspan
222
- }
223
- if (colspan > 1) {
224
- attrs.colspan = colspan
225
- }
226
- }
227
- } else if (footerSpanMethod) {
228
- // 自定义合并方法
229
- const { rowspan = 1, colspan = 1 } = footerSpanMethod(cellParams) || {}
230
- if (!rowspan || !colspan) {
231
- return null
232
- }
233
- if (rowspan > 1) {
234
- attrs.rowspan = rowspan
235
- }
236
- if (colspan > 1) {
237
- attrs.colspan = colspan
238
- }
239
- }
240
- return h('td', {
241
- class: ['vxe-footer--column', column.id, {
242
- [`col--${footAlign}`]: footAlign,
243
- [`col--${type}`]: type,
244
- 'col--last': $columnIndex === tableColumn.length - 1,
245
- 'fixed--hidden': fixedHiddenColumn,
246
- 'col--ellipsis': hasEllipsis,
247
- 'col--current': currentColumn === column
248
- }, getClass(footerClassName, cellParams), getClass(footerCellClassName, cellParams)],
249
- attrs,
250
- style: footerCellStyle ? (XEUtils.isFunction(footerCellStyle) ? footerCellStyle(cellParams) : footerCellStyle) : null,
251
- on: tfOns,
252
- key: columnKey || columnOpts.useKey ? column.id : $columnIndex
253
- }, [
254
- h('div', {
255
- class: ['vxe-cell', {
256
- 'c--title': showTitle,
257
- 'c--tooltip': showTooltip,
258
- 'c--ellipsis': showEllipsis
259
- }]
260
- }, column.renderFooter(h, cellParams))
261
- ])
262
- }).concat(scrollbarWidth
263
- ? [
264
- h('td', {
265
- class: 'vxe-footer--gutter col--gutter'
266
- })
267
- ]
268
- : []))
269
- }))
283
+ }, renderHeads(h, this, footerTableData))
270
284
  ])
271
285
  ])
272
286
  },