vxe-table 3.18.1 → 3.18.2

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 (63) hide show
  1. package/es/index.css +1 -1
  2. package/es/index.min.css +1 -1
  3. package/es/style.css +1 -1
  4. package/es/style.min.css +1 -1
  5. package/es/table/src/column.js +2 -0
  6. package/es/table/src/columnInfo.js +1 -0
  7. package/es/table/src/footer.js +7 -5
  8. package/es/table/src/header.js +67 -28
  9. package/es/table/src/methods.js +233 -39
  10. package/es/table/src/props.js +23 -6
  11. package/es/table/src/table.js +43 -19
  12. package/es/table/src/util.js +70 -2
  13. package/es/table/style.css +11 -17
  14. package/es/table/style.min.css +1 -1
  15. package/es/ui/index.js +1 -1
  16. package/es/ui/src/log.js +1 -1
  17. package/es/vxe-table/style.css +11 -17
  18. package/es/vxe-table/style.min.css +1 -1
  19. package/lib/index.css +1 -1
  20. package/lib/index.min.css +1 -1
  21. package/lib/index.umd.js +482 -94
  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/src/column.js +2 -0
  26. package/lib/table/src/column.min.js +1 -1
  27. package/lib/table/src/columnInfo.js +1 -0
  28. package/lib/table/src/columnInfo.min.js +1 -1
  29. package/lib/table/src/footer.js +7 -5
  30. package/lib/table/src/header.js +82 -25
  31. package/lib/table/src/header.min.js +1 -1
  32. package/lib/table/src/methods.js +259 -42
  33. package/lib/table/src/methods.min.js +1 -1
  34. package/lib/table/src/props.js +11 -3
  35. package/lib/table/src/props.min.js +1 -1
  36. package/lib/table/src/table.js +46 -16
  37. package/lib/table/src/table.min.js +1 -1
  38. package/lib/table/src/util.js +74 -2
  39. package/lib/table/src/util.min.js +1 -1
  40. package/lib/table/style/style.css +11 -17
  41. package/lib/table/style/style.min.css +1 -1
  42. package/lib/ui/index.js +1 -1
  43. package/lib/ui/index.min.js +1 -1
  44. package/lib/ui/src/log.js +1 -1
  45. package/lib/ui/src/log.min.js +1 -1
  46. package/lib/vxe-table/style/style.css +11 -17
  47. package/lib/vxe-table/style/style.min.css +1 -1
  48. package/package.json +1 -1
  49. package/packages/table/src/column.ts +4 -2
  50. package/packages/table/src/columnInfo.ts +1 -0
  51. package/packages/table/src/footer.ts +11 -9
  52. package/packages/table/src/header.ts +76 -34
  53. package/packages/table/src/methods.ts +245 -40
  54. package/packages/table/src/props.ts +29 -12
  55. package/packages/table/src/table.ts +53 -16
  56. package/packages/table/src/util.ts +76 -2
  57. package/styles/components/table.scss +33 -55
  58. /package/es/{iconfont.1756272539382.ttf → iconfont.1756452257212.ttf} +0 -0
  59. /package/es/{iconfont.1756272539382.woff → iconfont.1756452257212.woff} +0 -0
  60. /package/es/{iconfont.1756272539382.woff2 → iconfont.1756452257212.woff2} +0 -0
  61. /package/lib/{iconfont.1756272539382.ttf → iconfont.1756452257212.ttf} +0 -0
  62. /package/lib/{iconfont.1756272539382.woff → iconfont.1756452257212.woff} +0 -0
  63. /package/lib/{iconfont.1756272539382.woff2 → iconfont.1756452257212.woff2} +0 -0
@@ -34,7 +34,7 @@ function renderRows (h: CreateElement, _vm: any, isOptimizeMode: boolean, tableC
34
34
  const footerCellOpts = $xeTable.computeFooterCellOpts
35
35
  const currCellHeight = getCalcHeight(footerCellOpts.height) || defaultRowHeight
36
36
 
37
- return tableColumn.map((column: any, $columnIndex: any) => {
37
+ return tableColumn.map((column, $columnIndex) => {
38
38
  const { type, showFooterOverflow, footerAlign, align, footerClassName, editRender, cellRender } = column
39
39
  const colid = column.id
40
40
  const colRest = fullColumnIdData[colid] || {}
@@ -240,8 +240,8 @@ export default {
240
240
  default: null
241
241
  }
242
242
  },
243
- mounted (this: any) {
244
- const _vm = this
243
+ mounted () {
244
+ const _vm = this as any
245
245
  const props = _vm
246
246
  const $xeTable = _vm.$parent as VxeTableConstructor & VxeTablePrivateMethods
247
247
  const tableInternalData = $xeTable as unknown as TableInternalData
@@ -257,8 +257,9 @@ export default {
257
257
  elemStore[`${prefix}xSpace`] = _vm.$refs.refFooterXSpace
258
258
  },
259
259
  destroyed () {
260
- const props = this
261
- const $xeTable = this.$parent as VxeTableConstructor & VxeTablePrivateMethods
260
+ const _vm = this as any
261
+ const props = _vm
262
+ const $xeTable = _vm.$parent as VxeTableConstructor & VxeTablePrivateMethods
262
263
  const tableInternalData = $xeTable as unknown as TableInternalData
263
264
 
264
265
  const { fixedType } = props
@@ -272,8 +273,9 @@ export default {
272
273
  elemStore[`${prefix}xSpace`] = null
273
274
  },
274
275
  render (h: CreateElement) {
275
- const props = this
276
- const $xeTable = this.$parent as VxeTableConstructor & VxeTablePrivateMethods
276
+ const _vm = this as any
277
+ const props = _vm
278
+ const $xeTable = _vm.$parent as VxeTableConstructor & VxeTablePrivateMethods
277
279
  const tableProps = $xeTable
278
280
  const tableReactData = $xeTable as unknown as TableReactData
279
281
  const tableInternalData = $xeTable as unknown as TableInternalData
@@ -385,9 +387,9 @@ export default {
385
387
  */
386
388
  h('tfoot', {
387
389
  ref: 'refFooterTFoot'
388
- }, renderHeads(h, this, isOptimizeMode, renderColumnList))
390
+ }, renderHeads(h, _vm, isOptimizeMode, renderColumnList))
389
391
  ])
390
392
  ])
391
393
  ])
392
394
  }
393
- } as any
395
+ }
@@ -2,7 +2,7 @@ import { PropType, CreateElement } from 'vue'
2
2
  import XEUtils from 'xe-utils'
3
3
  import { VxeUI } from '../../ui'
4
4
  import { getClass } from '../../ui/src/utils'
5
- import { getCalcHeight, convertHeaderColumnToRows } from './util'
5
+ import { getCalcHeight, convertHeaderColumnToRows, convertHeaderToGridRows } from './util'
6
6
 
7
7
  import type { VxeTableDefines, VxeTableConstructor, VxeTablePrivateMethods, VxeColumnPropTypes, TableReactData, TableInternalData, VxeComponentStyleType } from '../../../types'
8
8
 
@@ -10,7 +10,7 @@ const { renderer, renderEmptyElement } = VxeUI
10
10
 
11
11
  const cellType = 'header'
12
12
 
13
- const renderRows = (h: CreateElement, _vm: any, isGroup: boolean, isOptimizeMode: boolean, cols: VxeTableDefines.ColumnInfo[], $rowIndex: number) => {
13
+ function renderRows (h: CreateElement, _vm: any, isGroup: boolean, isOptimizeMode: boolean, headerGroups: VxeTableDefines.ColumnInfo[][], $rowIndex: number, cols: VxeTableDefines.ColumnInfo[]) {
14
14
  const props = _vm
15
15
  const $xeTable = _vm.$parent as VxeTableConstructor & VxeTablePrivateMethods
16
16
  const $xeGrid = $xeTable.$xeGrid
@@ -20,9 +20,9 @@ const renderRows = (h: CreateElement, _vm: any, isGroup: boolean, isOptimizeMode
20
20
  const tableInternalData = $xeTable as unknown as TableInternalData
21
21
 
22
22
  const { fixedType } = props
23
- const { resizable: allResizable, columnKey, headerCellClassName, headerCellStyle, showHeaderOverflow: allColumnHeaderOverflow, headerAlign: allHeaderAlign, align: allAlign, mouseConfig } = tableProps
24
- const { currentColumn, dragCol, scrollXLoad, scrollYLoad, overflowX, tableColumn } = tableReactData
25
- const { fullColumnIdData, scrollXStore } = tableInternalData
23
+ const { resizable: allResizable, columnKey, showCustomHeader, headerCellClassName, headerCellStyle, showHeaderOverflow: allColumnHeaderOverflow, headerAlign: allHeaderAlign, align: allAlign, mouseConfig } = tableProps
24
+ const { currentColumn, dragCol, scrollXLoad, scrollYLoad, overflowX, mergeHeadFlag, tableColumn } = tableReactData
25
+ const { fullColumnIdData, scrollXStore, mergeHeaderList, mergeHeaderCellMaps } = tableInternalData
26
26
  const virtualXOpts = $xeTable.computeVirtualXOpts
27
27
  const columnOpts = $xeTable.computeColumnOpts
28
28
  const columnDragOpts = $xeTable.computeColumnDragOpts
@@ -31,7 +31,9 @@ const renderRows = (h: CreateElement, _vm: any, isGroup: boolean, isOptimizeMode
31
31
  const headerCellOpts = $xeTable.computeHeaderCellOpts
32
32
  const currCellHeight = getCalcHeight(headerCellOpts.height) || defaultRowHeight
33
33
  const { disabledMethod: dragDisabledMethod, isCrossDrag, isPeerDrag } = columnDragOpts
34
- return cols.map((column: any, $columnIndex: any) => {
34
+ const isLastRow = $rowIndex === headerGroups.length - 1
35
+
36
+ return cols.map((column, $columnIndex) => {
35
37
  const { type, showHeaderOverflow, headerAlign, align, filters, headerClassName, editRender, cellRender } = column
36
38
  // const { enabled } = tooltipOpts
37
39
  const colid = column.id
@@ -54,7 +56,7 @@ const renderRows = (h: CreateElement, _vm: any, isGroup: boolean, isOptimizeMode
54
56
  hasFilter = filters.some((item: VxeColumnPropTypes.FilterItem) => item.checked)
55
57
  }
56
58
  const columnIndex = colRest.index
57
- const _columnIndex = colRest._index
59
+ const _columnIndex = showCustomHeader ? $columnIndex : colRest._index
58
60
  const cellParams: VxeTableDefines.CellRenderHeaderParams & {
59
61
  $table: VxeTableConstructor & VxeTablePrivateMethods
60
62
  } = {
@@ -73,9 +75,30 @@ const renderRows = (h: CreateElement, _vm: any, isGroup: boolean, isOptimizeMode
73
75
  hasFilter
74
76
  }
75
77
  const thAttrs: Record<string, string | number | null> = {
76
- colid,
77
- colspan: column.colSpan > 1 ? column.colSpan : null,
78
- rowspan: column.rowSpan > 1 ? column.rowSpan : null
78
+ colid
79
+ }
80
+ let isMergeCell = false
81
+ // 合并行或列
82
+ if (!showCustomHeader) {
83
+ thAttrs.colspan = column.colSpan > 1 ? column.colSpan : null
84
+ thAttrs.rowspan = column.rowSpan > 1 ? column.rowSpan : null
85
+ }
86
+ if (mergeHeadFlag && mergeHeaderList.length && (showCustomHeader || isLastRow)) {
87
+ const spanRest = mergeHeaderCellMaps[`${$rowIndex}:${showCustomHeader ? $columnIndex : _columnIndex}`]
88
+ if (spanRest) {
89
+ const { rowspan, colspan } = spanRest
90
+ if (!rowspan || !colspan) {
91
+ return null
92
+ }
93
+ if (rowspan > 1) {
94
+ isMergeCell = true
95
+ thAttrs.rowspan = rowspan
96
+ }
97
+ if (colspan > 1) {
98
+ isMergeCell = true
99
+ thAttrs.colspan = colspan
100
+ }
101
+ }
79
102
  }
80
103
  const thOns: any = {
81
104
  click: (evnt: MouseEvent) => $xeTable.triggerHeaderCellClickEvent(evnt, cellParams),
@@ -104,7 +127,7 @@ const renderRows = (h: CreateElement, _vm: any, isGroup: boolean, isOptimizeMode
104
127
  const isAutoCellWidth = !column.resizeWidth && (column.minWidth === 'auto' || column.width === 'auto')
105
128
 
106
129
  let isVNPreEmptyStatus = false
107
- if (isOptimizeMode && overflowX && !isGroup) {
130
+ if (isOptimizeMode && overflowX && !isGroup && !isMergeCell) {
108
131
  if (!dragCol || dragCol.id !== colid) {
109
132
  if (scrollXLoad && tableColumn.length > 10 && !column.fixed && !virtualXOpts.immediate && (_columnIndex < scrollXStore.visibleStartIndex - scrollXStore.preloadSize || _columnIndex > scrollXStore.visibleEndIndex + scrollXStore.preloadSize)) {
110
133
  isVNPreEmptyStatus = true
@@ -120,7 +143,7 @@ const renderRows = (h: CreateElement, _vm: any, isGroup: boolean, isOptimizeMode
120
143
  }
121
144
 
122
145
  return h('th', {
123
- class: ['vxe-table--column vxe-header--column', colid, {
146
+ class: ['vxe-table--column vxe-header--column', colid, fixedHiddenColumn ? 'fixed--hidden' : 'fixed--visible', {
124
147
  [`col--${headAlign}`]: headAlign,
125
148
  [`col--${type}`]: type,
126
149
  'col--last': isLastColumn,
@@ -128,7 +151,6 @@ const renderRows = (h: CreateElement, _vm: any, isGroup: boolean, isOptimizeMode
128
151
  'col--group': isColGroup,
129
152
  'col--ellipsis': hasEllipsis,
130
153
  'fixed--width': !isAutoCellWidth,
131
- 'fixed--hidden': fixedHiddenColumn,
132
154
  'is--padding': isPadding,
133
155
  'is--sortable': column.sortable,
134
156
  'col--filter': !!filters,
@@ -140,7 +162,7 @@ const renderRows = (h: CreateElement, _vm: any, isGroup: boolean, isOptimizeMode
140
162
  attrs: thAttrs,
141
163
  style: headerCellStyle ? (XEUtils.isFunction(headerCellStyle) ? headerCellStyle(cellParams) : headerCellStyle) as VxeComponentStyleType : undefined,
142
164
  on: thOns,
143
- key: columnKey || scrollXLoad || scrollYLoad || columnOpts.useKey || columnOpts.drag || isColGroup ? colid : $columnIndex
165
+ key: showCustomHeader ? `${colid}${$columnIndex}` : (columnKey || scrollXLoad || scrollYLoad || columnOpts.useKey || columnOpts.drag || isColGroup ? colid : $columnIndex)
144
166
  }, [
145
167
  h('div', {
146
168
  class: ['vxe-cell', {
@@ -160,9 +182,9 @@ const renderRows = (h: CreateElement, _vm: any, isGroup: boolean, isOptimizeMode
160
182
  }, column.renderHeader(h, cellParams))
161
183
  ]),
162
184
  /**
163
- * 列宽拖动
164
- */
165
- !fixedHiddenColumn && showResizable
185
+ * 列宽拖动
186
+ */
187
+ !fixedHiddenColumn && showResizable && (!showCustomHeader || isLastRow)
166
188
  ? h('div', {
167
189
  class: 'vxe-cell--col-resizable',
168
190
  on: {
@@ -175,7 +197,7 @@ const renderRows = (h: CreateElement, _vm: any, isGroup: boolean, isOptimizeMode
175
197
  })
176
198
  }
177
199
 
178
- function renderHeads (h: CreateElement, _vm: any, isGroup: boolean, isOptimizeMode: boolean, headerGroups: any[]) {
200
+ function renderHeads (h: CreateElement, _vm: any, isGroup: boolean, isOptimizeMode: boolean, headerGroups: VxeTableDefines.ColumnInfo[][]) {
179
201
  const props = _vm
180
202
  const $xeTable = _vm.$parent as VxeTableConstructor & VxeTablePrivateMethods
181
203
  const tableProps = $xeTable
@@ -194,7 +216,7 @@ function renderHeads (h: CreateElement, _vm: any, isGroup: boolean, isOptimizeMo
194
216
  headerRowClassName ? XEUtils.isFunction(headerRowClassName) ? headerRowClassName(params) : headerRowClassName : ''
195
217
  ],
196
218
  style: headerRowStyle ? (XEUtils.isFunction(headerRowStyle) ? headerRowStyle(params) : headerRowStyle) as VxeComponentStyleType : undefined
197
- }, renderRows(h, _vm, isGroup, isOptimizeMode, cols, $rowIndex))
219
+ }, renderRows(h, _vm, isGroup, isOptimizeMode, headerGroups, $rowIndex, cols))
198
220
  })
199
221
  }
200
222
 
@@ -216,15 +238,18 @@ export default {
216
238
  }
217
239
  },
218
240
  watch: {
219
- tableColumn (this: any) {
220
- this.uploadColumn()
241
+ tableColumn () {
242
+ const _vm = this as any
243
+
244
+ _vm.uploadColumn()
221
245
  }
222
246
  },
223
- created (this: any) {
224
- this.uploadColumn()
247
+ created () {
248
+ const _vm = this as any
249
+ _vm.uploadColumn()
225
250
  },
226
251
  mounted () {
227
- const _vm = this
252
+ const _vm = this as any
228
253
  const props = _vm
229
254
  const $xeTable = _vm.$parent as VxeTableConstructor & VxeTablePrivateMethods
230
255
  const internalData = $xeTable as unknown as TableInternalData
@@ -241,8 +266,9 @@ export default {
241
266
  elemStore[`${prefix}repair`] = _vm.$refs.refHeaderBorderRepair
242
267
  },
243
268
  destroyed () {
244
- const props = this
245
- const $xeTable = this.$parent as VxeTableConstructor & VxeTablePrivateMethods
269
+ const _vm = this as any
270
+ const props = _vm
271
+ const $xeTable = _vm.$parent as VxeTableConstructor & VxeTablePrivateMethods
246
272
  const internalData = $xeTable as unknown as TableInternalData
247
273
 
248
274
  const { fixedType } = props
@@ -257,15 +283,16 @@ export default {
257
283
  elemStore[`${prefix}repair`] = null
258
284
  },
259
285
  render (h: CreateElement) {
260
- const props = this
261
- const $xeTable = this.$parent as VxeTableConstructor & VxeTablePrivateMethods
286
+ const _vm = this as any
287
+ const props = _vm
288
+ const $xeTable = _vm.$parent as VxeTableConstructor & VxeTablePrivateMethods
262
289
  const tableProps = $xeTable
263
290
  const tableReactData = $xeTable as unknown as TableReactData
264
291
  const tableInternalData = $xeTable as unknown as TableInternalData
265
292
 
266
293
  const { xID } = $xeTable
267
294
  const { fixedType, fixedColumn, tableColumn } = props
268
- const { headerColumn } = this
295
+ const { headerColumn } = _vm
269
296
 
270
297
  const { mouseConfig, showHeaderOverflow: allColumnHeaderOverflow, spanMethod, footerSpanMethod } = tableProps
271
298
  const { isGroup, isColLoading, overflowX, scrollXLoad, dragCol } = tableReactData
@@ -382,7 +409,7 @@ export default {
382
409
  */
383
410
  h('thead', {
384
411
  ref: 'refHeaderTHead'
385
- }, renderHeads(h, this, isGroup, isOptimizeMode, renderHeaderList))
412
+ }, renderHeads(h, _vm, isGroup, isOptimizeMode, renderHeaderList))
386
413
  ]),
387
414
  mouseConfig && mouseOpts.area
388
415
  ? h('div', {
@@ -413,11 +440,26 @@ export default {
413
440
  },
414
441
  methods: {
415
442
  uploadColumn () {
416
- const $xeTable = this.$parent as VxeTableConstructor & VxeTablePrivateMethods
443
+ const _vm = this as any
444
+ const $xeTable = _vm.$parent as VxeTableConstructor & VxeTablePrivateMethods
445
+ const tableProps = $xeTable
417
446
  const tableReactData = $xeTable as unknown as TableReactData
447
+ const tableInternalData = $xeTable as unknown as TableInternalData
418
448
 
449
+ const props = _vm
450
+
451
+ const { showCustomHeader } = tableProps
452
+ const { collectColumn, visibleColumn } = tableInternalData
453
+ const { tableGroupColumn } = props
419
454
  const { isGroup } = tableReactData
420
- this.headerColumn = isGroup ? convertHeaderColumnToRows(this.tableGroupColumn) : []
455
+ let spanColumns: VxeTableDefines.ColumnInfo[][] = isGroup ? convertHeaderColumnToRows(tableGroupColumn) : []
456
+ let visibleColgroups: VxeTableDefines.ColumnInfo[][] = []
457
+ if (showCustomHeader && spanColumns.length > 1) {
458
+ visibleColgroups = convertHeaderToGridRows(spanColumns)
459
+ spanColumns = visibleColgroups
460
+ }
461
+ _vm.headerColumn = spanColumns
462
+ $xeTable.dispatchEvent('columns-change', { visibleColgroups, collectColumn, visibleColumn }, null)
421
463
  }
422
- } as any
423
- } as any
464
+ }
465
+ }