vxe-table 4.23.18 → 4.23.20

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 (135) hide show
  1. package/dist/all.esm.js +301 -274
  2. package/dist/all.esm.min.js +3 -3
  3. package/dist/style.css +4 -1
  4. package/dist/style.mini.css +1 -1
  5. package/es/components.d.ts +1 -3
  6. package/es/components.js +1 -2
  7. package/es/esm.index.d.ts +7 -0
  8. package/es/esm.index.js +8 -0
  9. package/es/style.css +4 -1
  10. package/es/style.mini.css +1 -1
  11. package/es/table/module/edit/hook.js +2 -4
  12. package/es/table/module/export/export-panel.js +5 -5
  13. package/es/table/module/export/hook.js +8 -10
  14. package/es/table/module/export/import-panel.js +5 -5
  15. package/es/table/src/table.js +0 -1
  16. package/es/table/style.css +4 -1
  17. package/es/table/style.mini.css +1 -1
  18. package/es/ui/abandon.d.ts +82 -0
  19. package/es/ui/abandon.js +90 -0
  20. package/es/ui/index.d.ts +1 -82
  21. package/es/ui/index.js +2 -88
  22. package/es/ui/src/log.js +1 -1
  23. package/es/vxe-table/style.css +4 -1
  24. package/es/vxe-table/style.mini.css +1 -1
  25. package/lib/components.d.ts +1 -3
  26. package/lib/components.js +1 -2
  27. package/lib/esm.index.d.ts +7 -0
  28. package/lib/esm.index.js +39 -0
  29. package/lib/index.umd.js +266 -270
  30. package/lib/index.umd.min.js +3 -3
  31. package/lib/style.css +4 -1
  32. package/lib/style.mini.css +1 -1
  33. package/lib/table/module/edit/hook.js +2 -4
  34. package/lib/table/module/export/export-panel.js +5 -5
  35. package/lib/table/module/export/hook.js +8 -10
  36. package/lib/table/module/export/import-panel.js +5 -5
  37. package/lib/table/src/table.js +0 -1
  38. package/lib/table/style/style.css +4 -1
  39. package/lib/table/style/style.mini.css +1 -1
  40. package/lib/ui/abandon.d.ts +82 -0
  41. package/lib/ui/abandon.js +110 -0
  42. package/lib/ui/index.d.ts +1 -82
  43. package/lib/ui/index.js +3 -88
  44. package/lib/ui/src/log.js +1 -1
  45. package/lib/vxe-table/style/style.css +4 -1
  46. package/lib/vxe-table/style/style.mini.css +1 -1
  47. package/package.json +2 -2
  48. package/packages/colgroup/index.ts +22 -22
  49. package/packages/column/index.ts +22 -22
  50. package/packages/components.ts +42 -45
  51. package/packages/esm.index.ts +10 -0
  52. package/packages/grid/index.ts +18 -18
  53. package/packages/grid/src/emits.ts +5 -5
  54. package/packages/grid/src/grid.ts +2220 -2220
  55. package/packages/grid/src/props.ts +22 -22
  56. package/packages/index.ts +13 -13
  57. package/packages/locale/lang/ar-EG.ts +914 -914
  58. package/packages/locale/lang/de-DE.ts +914 -914
  59. package/packages/locale/lang/en-US.ts +914 -914
  60. package/packages/locale/lang/es-ES.ts +914 -914
  61. package/packages/locale/lang/fr-FR.ts +914 -914
  62. package/packages/locale/lang/hu-HU.ts +914 -914
  63. package/packages/locale/lang/hy-AM.ts +914 -914
  64. package/packages/locale/lang/id-ID.ts +914 -914
  65. package/packages/locale/lang/it-IT.ts +914 -914
  66. package/packages/locale/lang/ja-JP.ts +914 -914
  67. package/packages/locale/lang/ko-KR.ts +914 -914
  68. package/packages/locale/lang/ms-MY.ts +914 -914
  69. package/packages/locale/lang/nb-NO.ts +914 -914
  70. package/packages/locale/lang/pt-BR.ts +914 -914
  71. package/packages/locale/lang/ru-RU.ts +914 -914
  72. package/packages/locale/lang/th-TH.ts +914 -914
  73. package/packages/locale/lang/ug-CN.ts +914 -914
  74. package/packages/locale/lang/uk-UA.ts +914 -914
  75. package/packages/locale/lang/uz-UZ.ts +914 -914
  76. package/packages/locale/lang/vi-VN.ts +914 -914
  77. package/packages/locale/lang/zh-CHT.ts +914 -914
  78. package/packages/locale/lang/zh-CN.ts +914 -914
  79. package/packages/locale/lang/zh-HK.ts +914 -914
  80. package/packages/locale/lang/zh-MO.ts +914 -914
  81. package/packages/locale/lang/zh-TC.ts +914 -914
  82. package/packages/locale/lang/zh-TW.ts +914 -914
  83. package/packages/table/index.ts +26 -26
  84. package/packages/table/module/custom/hook.ts +510 -510
  85. package/packages/table/module/custom/panel.ts +2002 -2002
  86. package/packages/table/module/edit/hook.ts +1232 -1235
  87. package/packages/table/module/export/export-panel.ts +697 -697
  88. package/packages/table/module/export/hook.ts +2158 -2160
  89. package/packages/table/module/export/import-panel.ts +319 -319
  90. package/packages/table/module/export/util.ts +25 -25
  91. package/packages/table/module/filter/hook.ts +505 -505
  92. package/packages/table/module/filter/panel.ts +368 -368
  93. package/packages/table/module/keyboard/hook.ts +498 -498
  94. package/packages/table/module/menu/hook.ts +330 -330
  95. package/packages/table/module/menu/panel.ts +272 -272
  96. package/packages/table/module/validator/hook.ts +653 -653
  97. package/packages/table/render/index.ts +1819 -1819
  98. package/packages/table/src/body.ts +1078 -1078
  99. package/packages/table/src/cell.ts +1524 -1524
  100. package/packages/table/src/column.ts +192 -192
  101. package/packages/table/src/columnInfo.ts +232 -232
  102. package/packages/table/src/emits.ts +134 -134
  103. package/packages/table/src/footer.ts +425 -425
  104. package/packages/table/src/group.ts +67 -67
  105. package/packages/table/src/header.ts +661 -661
  106. package/packages/table/src/props.ts +336 -336
  107. package/packages/table/src/store.ts +14 -14
  108. package/packages/table/src/table.ts +0 -1
  109. package/packages/table/src/use/cell-view.ts +41 -41
  110. package/packages/table/src/use/index.ts +1 -1
  111. package/packages/table/src/util.ts +1206 -1206
  112. package/packages/toolbar/index.ts +18 -18
  113. package/packages/toolbar/src/toolbar.ts +768 -768
  114. package/packages/ui/abandon.ts +136 -0
  115. package/packages/ui/index.ts +404 -520
  116. package/packages/ui/src/anime.ts +51 -51
  117. package/packages/ui/src/comp.ts +3 -3
  118. package/packages/ui/src/dom.ts +466 -466
  119. package/packages/ui/src/log.ts +19 -19
  120. package/packages/ui/src/utils.ts +66 -66
  121. package/packages/ui/src/vn.ts +55 -55
  122. package/packages/v-x-e-table/index.d.ts +3 -3
  123. package/packages/v-x-e-table/index.ts +3 -3
  124. package/styles/components/table.scss +2 -1
  125. package/types/all.d.ts +76 -76
  126. package/types/index.d.ts +4 -4
  127. /package/dist/{iconfont.1794366305845.ttf → iconfont.1794633824975.ttf} +0 -0
  128. /package/dist/{iconfont.1794366305845.woff → iconfont.1794633824975.woff} +0 -0
  129. /package/dist/{iconfont.1794366305845.woff2 → iconfont.1794633824975.woff2} +0 -0
  130. /package/es/{iconfont.1794366305845.ttf → iconfont.1794633824975.ttf} +0 -0
  131. /package/es/{iconfont.1794366305845.woff → iconfont.1794633824975.woff} +0 -0
  132. /package/es/{iconfont.1794366305845.woff2 → iconfont.1794633824975.woff2} +0 -0
  133. /package/lib/{iconfont.1794366305845.ttf → iconfont.1794633824975.ttf} +0 -0
  134. /package/lib/{iconfont.1794366305845.woff → iconfont.1794633824975.woff} +0 -0
  135. /package/lib/{iconfont.1794366305845.woff2 → iconfont.1794633824975.woff2} +0 -0
@@ -1,661 +1,661 @@
1
- import { h, ref, Ref, PropType, inject, nextTick, watch, onMounted, onUnmounted, VNode } from 'vue'
2
- import { defineVxeComponent } from '../../ui/src/comp'
3
- import XEUtils from 'xe-utils'
4
- import { VxeUI } from '@vxe-ui/core'
5
- import { getDefaultConfig, hasEnableConf, isEnableConf } from '../../ui/src/utils'
6
- import { getCalcHeight, convertHeaderColumnToRows, convertHeaderToGridRows } from './util'
7
- import { getSlotVNs } from '../../ui/src/vn'
8
-
9
- import type { VxeTablePrivateMethods, VxeTableConstructor, VxeTableMethods, VxeTableDefines, VxeGlobalRendererHandles } from '../../../types'
10
-
11
- const { renderer, renderEmptyElement } = VxeUI
12
-
13
- const sourceType = 'table'
14
- const renderType = 'header'
15
-
16
- export default /* define-vxe-component start */ defineVxeComponent({
17
- name: 'VxeTableHeader',
18
- props: {
19
- tableData: Array as PropType<any[]>,
20
- tableColumn: Array as PropType<VxeTableDefines.ColumnInfo[]>,
21
- tableGroupColumn: Array as PropType<VxeTableDefines.ColumnInfo[]>,
22
- fixedColumn: Array as PropType<VxeTableDefines.ColumnInfo[]>,
23
- fixedType: {
24
- type: String as PropType<'right' | 'left' | ''>,
25
- default: null
26
- }
27
- },
28
- setup(props) {
29
- const $xeTable = inject('$xeTable', {} as VxeTableConstructor & VxeTableMethods & VxeTablePrivateMethods)
30
-
31
- const { xID, props: tableProps, reactData: tableReactData, internalData: tableInternalData } = $xeTable
32
- const { computeColumnOpts, computeColumnDragOpts, computeCellOpts, computeMouseOpts, computeHeaderCellOpts, computeDefaultRowHeight, computeVirtualXOpts, computeFloatingFilterOpts, computeIsHeaderRenderOptimize, computeHeaderTooltipOpts, computeRendererOpts } = $xeTable.getComputeMaps()
33
-
34
- const headerColumn = ref<VxeTableDefines.ColumnInfo[][]>([])
35
-
36
- const refElem = ref() as Ref<HTMLDivElement>
37
- const refHeaderScroll = ref() as Ref<HTMLDivElement>
38
- const refHeaderTable = ref() as Ref<HTMLTableElement>
39
- const refHeaderColgroup = ref() as Ref<HTMLTableColElement>
40
- const refHeaderTHead = ref() as Ref<HTMLTableSectionElement>
41
- const refHeaderXSpace = ref() as Ref<HTMLDivElement>
42
- const refHeaderBorderRepair = ref() as Ref<HTMLDivElement>
43
-
44
- const uploadColumn = () => {
45
- const { showCustomHeader } = tableProps
46
- const { collectColumn, visibleColumn } = tableInternalData
47
- const { tableGroupColumn } = props
48
- const { isGroup } = tableReactData
49
- let spanColumns: VxeTableDefines.ColumnInfo[][] = isGroup ? convertHeaderColumnToRows(tableGroupColumn) : []
50
- let visibleColgroups: VxeTableDefines.ColumnInfo[][] = []
51
- if (showCustomHeader && spanColumns.length > 1) {
52
- visibleColgroups = convertHeaderToGridRows(spanColumns)
53
- spanColumns = visibleColgroups
54
- }
55
- headerColumn.value = spanColumns
56
- nextTick(() => {
57
- $xeTable.dispatchEvent('columns-change', { visibleColgroups, collectColumn, visibleColumn }, null)
58
- })
59
- }
60
-
61
- const renderRows = (isGroup: boolean, isOptimizeMode: boolean, headerGroups: VxeTableDefines.ColumnInfo[][], _rowIndex: number, cols: VxeTableDefines.ColumnInfo[]) => {
62
- const $xeGrid = $xeTable.xeGrid
63
- const $xeGantt = $xeTable.xeGantt
64
-
65
- const { fixedType } = props
66
- const { resizable: allResizable, columnKey, showCustomHeader, headerCellClassName, headerCellStyle, showHeaderOverflow: allColumnHeaderOverflow, headerAlign: allHeaderAlign, align: allAlign, mouseConfig } = tableProps
67
- const { dragCol, scrollXLoad, scrollYLoad, overflowX, mergeHeadFlag, tableColumn, currColFlag } = tableReactData
68
- const { fullColumnIdData, scrollXStore, mergeHeaderList, mergeHeaderCellMaps, currentCol } = tableInternalData
69
- const virtualXOpts = computeVirtualXOpts.value
70
- const columnOpts = computeColumnOpts.value
71
- const columnDragOpts = computeColumnDragOpts.value
72
- const headerTooltipOpts = computeHeaderTooltipOpts.value
73
- const cellOpts = computeCellOpts.value
74
- const defaultRowHeight = computeDefaultRowHeight.value
75
- const headerCellOpts = computeHeaderCellOpts.value
76
- const rendererOpts = computeRendererOpts.value
77
- const mouseOpts = computeMouseOpts.value
78
- const currCellHeight = getCalcHeight(headerCellOpts.height) || defaultRowHeight
79
- const { disabledMethod: dragDisabledMethod, isCrossDrag, isPeerDrag } = columnDragOpts
80
- const isLastRow = _rowIndex === headerGroups.length - 1
81
-
82
- return cols.map((column, $columnIndex) => {
83
- const { type, showHeaderOverflow, headerAlign, align, filters, headerClassName, editRender, cellRender } = column
84
- const colid = column.id
85
- const colRest = fullColumnIdData[colid] || {}
86
- const renderOpts = editRender || cellRender
87
- const compConf = renderOpts && renderOpts.name ? rendererOpts[renderOpts.name] || renderer.get(renderOpts.name) : null
88
- const isColGroup = column.children && column.children.length
89
- const fixedHiddenColumn = overflowX && !isColGroup && (fixedType ? column.fixed !== fixedType : !!column.fixed)
90
-
91
- const cellPadding = getDefaultConfig(headerCellOpts.padding, cellOpts.padding)
92
- const isAllCellPadding = cellPadding === true
93
- const isCellPaddingTop = cellPadding ? isAllCellPadding || cellPadding.top !== false : false
94
- const isCellPaddingBottom = cellPadding ? isAllCellPadding || cellPadding.bottom !== false : false
95
- const isCellPaddingLeft = cellPadding ? isAllCellPadding || cellPadding.left !== false : false
96
- const isCellPaddingRight = cellPadding ? isAllCellPadding || cellPadding.right !== false : false
97
-
98
- const headOverflow = getDefaultConfig(showHeaderOverflow, allColumnHeaderOverflow)
99
- const headAlign = headerAlign || (compConf ? compConf.tableHeaderCellAlign : '') || allHeaderAlign || align || (compConf ? compConf.tableCellAlign : '') || allAlign
100
- const showEllipsis = (headOverflow === true ? headerTooltipOpts.mode : headOverflow) === 'ellipsis'
101
- const showTitle = (headOverflow === true ? headerTooltipOpts.mode : headOverflow) === 'title'
102
- const showTooltip = (headOverflow === true ? headerTooltipOpts.mode : headOverflow) === 'tooltip'
103
- const hasEllipsis = showTitle || showTooltip || showEllipsis
104
- let hasFilter = false
105
- let firstFilterOption: VxeTableDefines.FilterOption | null = null
106
- if (filters) {
107
- firstFilterOption = filters[0] as VxeTableDefines.FilterOption
108
- hasFilter = filters.some((item) => item.checked)
109
- }
110
- const columnIndex = colRest.index
111
- const _columnIndex = colRest._index
112
- const cellParams: VxeTableDefines.CellRenderHeaderParams & {
113
- $table: VxeTableConstructor & VxeTablePrivateMethods
114
- } = {
115
- $table: $xeTable,
116
- $grid: $xeGrid,
117
- $gantt: $xeGantt,
118
- rowIndex: _rowIndex,
119
- _rowIndex,
120
- $rowIndex: _rowIndex,
121
- column,
122
- columnIndex,
123
- $columnIndex,
124
- _columnIndex,
125
- firstFilterOption: firstFilterOption as VxeTableDefines.FilterOption,
126
- fixed: fixedType,
127
- source: sourceType,
128
- type: renderType,
129
- isHidden: fixedHiddenColumn,
130
- hasFilter
131
- }
132
- const thAttrs: Record<string, string | number | null> = {
133
- colid
134
- }
135
- let isMergeCell = false
136
- // 合并行或列
137
- if (!showCustomHeader) {
138
- thAttrs.colspan = column.colSpan > 1 ? column.colSpan : null
139
- thAttrs.rowspan = column.rowSpan > 1 ? column.rowSpan : null
140
- }
141
- if (mergeHeadFlag && mergeHeaderList.length && (showCustomHeader || isLastRow)) {
142
- const spanRest = mergeHeaderCellMaps[`${_rowIndex}:${showCustomHeader ? $columnIndex : _columnIndex}`]
143
- if (spanRest) {
144
- const { rowspan, colspan } = spanRest
145
- if (!rowspan || !colspan) {
146
- return null
147
- }
148
- if (rowspan > 1) {
149
- isMergeCell = true
150
- thAttrs.rowspan = rowspan
151
- }
152
- if (colspan > 1) {
153
- isMergeCell = true
154
- thAttrs.colspan = colspan
155
- }
156
- }
157
- }
158
-
159
- const thOns: any = {
160
- onClick: (evnt: MouseEvent) => $xeTable.triggerHeaderCellClickEvent(evnt, cellParams),
161
- onDblclick: (evnt: MouseEvent) => $xeTable.triggerHeaderCellDblclickEvent(evnt, cellParams)
162
- }
163
- const isColDragCell = columnOpts.drag && columnDragOpts.trigger === 'cell'
164
- let isDisabledDrag = false
165
- if (isColDragCell) {
166
- isDisabledDrag = !!(dragDisabledMethod && dragDisabledMethod(cellParams))
167
- }
168
- // 按下事件处理
169
- if (hasEnableConf(mouseConfig, mouseOpts) || isColDragCell) {
170
- thOns.onMousedown = (evnt: MouseEvent) => $xeTable.triggerHeaderCellMousedownEvent(evnt, cellParams)
171
- }
172
- // 拖拽列事件
173
- if (columnOpts.drag) {
174
- thOns.onDragstart = $xeTable.handleHeaderCellDragDragstartEvent
175
- thOns.onDragend = $xeTable.handleHeaderCellDragDragendEvent
176
- thOns.onDragover = $xeTable.handleHeaderCellDragDragoverEvent
177
- if (isColDragCell) {
178
- thOns.onMouseup = $xeTable.handleHeaderCellDragMouseupEvent
179
- }
180
- }
181
- const isLastColumn = $columnIndex === cols.length - 1
182
- const showResizable = XEUtils.isBoolean(column.resizable) ? column.resizable : columnOpts.resizable || allResizable
183
- const isAutoCellWidth = !column.resizeWidth && (column.minWidth === 'auto' || column.width === 'auto')
184
-
185
- let isVNPreEmptyStatus = false
186
- if (isOptimizeMode && overflowX && !isGroup && !isMergeCell) {
187
- if (!dragCol || dragCol.id !== colid) {
188
- if (scrollXLoad && tableColumn.length > 10 && !column.fixed && !virtualXOpts.immediate && (_columnIndex < scrollXStore.visibleStartIndex - scrollXStore.preloadSize || _columnIndex > scrollXStore.visibleEndIndex + scrollXStore.preloadSize)) {
189
- isVNPreEmptyStatus = true
190
- }
191
- }
192
- }
193
-
194
- const tcStyle: Record<string, string> = {}
195
- if (hasEllipsis) {
196
- tcStyle.height = `${currCellHeight}px`
197
- } else {
198
- tcStyle.minHeight = `${currCellHeight}px`
199
- }
200
-
201
- if (showCustomHeader) {
202
- // custom
203
- } else if (isColGroup && !isLastRow) {
204
- let childWidth = 0
205
- XEUtils.eachTree(column.children, (childRow) => {
206
- if (childRow.visible && (!childRow.children || !childRow.children.length)) {
207
- childWidth += childRow.renderWidth
208
- }
209
- })
210
- tcStyle.width = `${childWidth}px`
211
- }
212
-
213
- return h(
214
- 'th',
215
- {
216
- class: [
217
- 'vxe-table--column vxe-header--column',
218
- colid,
219
- fixedHiddenColumn ? 'fixed--hidden' : 'fixed--visible',
220
- {
221
- [`col--${headAlign}`]: headAlign,
222
- [`col--${type}`]: type,
223
- 'col--last': isLastColumn,
224
- 'col--fixed': column.fixed,
225
- 'col--group': isColGroup,
226
- 'col--ellipsis': hasEllipsis,
227
- 'fixed--width': !isAutoCellWidth,
228
- 'is--pg-top': isCellPaddingTop,
229
- 'is--pg-bottom': isCellPaddingBottom,
230
- 'is--pg-left': isCellPaddingLeft,
231
- 'is--pg-right': isCellPaddingRight,
232
- 'is--sortable': column.sortable,
233
- 'col--filter': !!filters,
234
- 'is--filter-active': hasFilter,
235
- 'is--drag-active': columnOpts.drag && !column.fixed && !isDisabledDrag && (isCrossDrag || isPeerDrag || !column.parentId),
236
- 'is--drag-disabled': columnOpts.drag && isDisabledDrag,
237
- 'col--current': currColFlag && currentCol === column
238
- },
239
- headerClassName ? (XEUtils.isFunction(headerClassName) ? headerClassName(cellParams) : headerClassName) : '',
240
- headerCellClassName ? (XEUtils.isFunction(headerCellClassName) ? headerCellClassName(cellParams) : headerCellClassName) : ''
241
- ],
242
- style: headerCellStyle ? (XEUtils.isFunction(headerCellStyle) ? headerCellStyle(cellParams) : headerCellStyle) : null,
243
- ...thAttrs,
244
- ...thOns,
245
- key: showCustomHeader ? `${colid}${$columnIndex}` : columnKey || scrollXLoad || scrollYLoad || columnOpts.useKey || columnOpts.drag || isColGroup ? colid : $columnIndex
246
- },
247
- [
248
- h(
249
- 'div',
250
- {
251
- class: [
252
- 'vxe-cell',
253
- {
254
- 'c--title': showTitle,
255
- 'c--tooltip': showTooltip,
256
- 'c--ellipsis': showEllipsis
257
- }
258
- ],
259
- style: tcStyle
260
- },
261
- isVNPreEmptyStatus || (isOptimizeMode && fixedHiddenColumn)
262
- ? []
263
- : [
264
- h(
265
- 'div',
266
- {
267
- colid,
268
- class: 'vxe-cell--wrapper vxe-header-cell--wrapper'
269
- },
270
- column.renderHeader(cellParams)
271
- )
272
- ]
273
- ),
274
- /**
275
- * 列宽拖动
276
- */
277
- !fixedHiddenColumn && showResizable && (!showCustomHeader || isLastRow)
278
- ? h('div', {
279
- class: 'vxe-cell--col-resizable',
280
- onMousedown: (evnt: MouseEvent) => $xeTable.handleColResizeMousedownEvent(evnt, fixedType, cellParams),
281
- onDblclick: (evnt: MouseEvent) => $xeTable.handleColResizeDblclickEvent(evnt, cellParams)
282
- })
283
- : renderEmptyElement($xeTable)
284
- ]
285
- )
286
- })
287
- }
288
-
289
- const renderFilterRows = (isOptimizeMode: boolean, cols: VxeTableDefines.ColumnInfo[]) => {
290
- const $xeGrid = $xeTable.xeGrid
291
- const $xeGantt = $xeTable.xeGantt
292
-
293
- const { fixedType } = props
294
- const { showHeaderOverflow: allColumnHeaderOverflow, headerAlign: allHeaderAlign, align: allAlign } = tableProps
295
- const { overflowX, currColFlag } = tableReactData
296
- const { fullColumnIdData, currentCol } = tableInternalData
297
- const headerTooltipOpts = computeHeaderTooltipOpts.value
298
- const cellOpts = computeCellOpts.value
299
- const defaultRowHeight = computeDefaultRowHeight.value
300
- const headerCellOpts = computeHeaderCellOpts.value
301
- const floatingFilterOpts = computeFloatingFilterOpts.value
302
- const rendererOpts = computeRendererOpts.value
303
- const { cellClassName } = floatingFilterOpts
304
- const currCellHeight = getCalcHeight(headerCellOpts.height) || defaultRowHeight
305
-
306
- return cols.map((column, $columnIndex) => {
307
- const { type, showHeaderOverflow, headerAlign, align, filters, editRender, cellRender, floatingFilters, filterRender, slots } = column
308
- const colid = column.id
309
- const colRest = fullColumnIdData[colid] || {}
310
- const renderOpts = editRender || cellRender
311
- const flSlot = slots ? slots.floatingFilter || slots['floating-filter'] : null
312
- const compConf = renderOpts && renderOpts.name ? rendererOpts[renderOpts.name] || renderer.get(renderOpts.name) : null
313
- const flCompConf = isEnableConf(filterRender) && filterRender.name ? rendererOpts[filterRender.name] || renderer.get(filterRender.name) : null
314
- const rtFloatingFilter = flCompConf ? flCompConf.renderTableFloatingFilter : null
315
- const fixedHiddenColumn = overflowX && (fixedType ? column.fixed !== fixedType : !!column.fixed)
316
-
317
- const cellPadding = getDefaultConfig(headerCellOpts.padding, cellOpts.padding)
318
- const isAllCellPadding = cellPadding === true
319
- const isCellPaddingTop = cellPadding ? isAllCellPadding || cellPadding.top !== false : false
320
- const isCellPaddingBottom = cellPadding ? isAllCellPadding || cellPadding.bottom !== false : false
321
- const isCellPaddingLeft = cellPadding ? isAllCellPadding || cellPadding.left !== false : false
322
- const isCellPaddingRight = cellPadding ? isAllCellPadding || cellPadding.right !== false : false
323
- const headOverflow = XEUtils.eqNull(showHeaderOverflow) ? allColumnHeaderOverflow : showHeaderOverflow
324
-
325
- const headAlign = headerAlign || (compConf ? compConf.tableHeaderCellAlign : '') || allHeaderAlign || align || (compConf ? compConf.tableCellAlign : '') || allAlign
326
- const showEllipsis = headOverflow === 'ellipsis'
327
- const showTitle = headOverflow === 'title'
328
- const showTooltip = headOverflow === true ? headerTooltipOpts.mode === 'tooltip' : headOverflow === 'tooltip'
329
- const hasEllipsis = showTitle || showTooltip || showEllipsis
330
- let hasFilter = false
331
- let firstFilterOption: VxeTableDefines.FilterOption | null = null
332
- if (filters) {
333
- firstFilterOption = filters[0] as VxeTableDefines.FilterOption
334
- hasFilter = filters.some((item) => item.checked)
335
- }
336
- const columnIndex = colRest.index
337
- const _columnIndex = colRest._index
338
- const cellParams: VxeTableDefines.CellFloatingFilterParams & {
339
- $table: VxeTableConstructor & VxeTablePrivateMethods
340
- } = {
341
- $table: $xeTable,
342
- $grid: $xeGrid,
343
- $gantt: $xeGantt,
344
- column,
345
- columnIndex,
346
- $columnIndex,
347
- _columnIndex,
348
- option: firstFilterOption as VxeTableDefines.FilterOption,
349
- fixed: fixedType,
350
- source: sourceType,
351
- type: renderType,
352
- isHidden: fixedHiddenColumn,
353
- hasFilter
354
- }
355
- const thAttrs: Record<string, string | number | null> = {
356
- colid
357
- }
358
-
359
- const isLastColumn = $columnIndex === cols.length - 1
360
- const isAutoCellWidth = !column.resizeWidth && (column.minWidth === 'auto' || column.width === 'auto')
361
-
362
- const tcStyle: Record<string, string> = {}
363
- if (hasEllipsis) {
364
- tcStyle.height = `${currCellHeight}px`
365
- } else {
366
- tcStyle.minHeight = `${currCellHeight}px`
367
- }
368
-
369
- return h(
370
- 'th',
371
- {
372
- class: [
373
- 'vxe-table--column vxe-header--column is--floating-filters',
374
- colid,
375
- fixedHiddenColumn ? 'fixed--hidden' : 'fixed--visible',
376
- {
377
- [`col--${headAlign}`]: headAlign,
378
- [`col--${type}`]: type,
379
- 'col--last': isLastColumn,
380
- 'col--fixed': column.fixed,
381
- 'col--ellipsis': hasEllipsis,
382
- 'fixed--width': !isAutoCellWidth,
383
- 'is--pg-top': isCellPaddingTop,
384
- 'is--pg-bottom': isCellPaddingBottom,
385
- 'is--pg-left': isCellPaddingLeft,
386
- 'is--pg-right': isCellPaddingRight,
387
- 'is--sortable': column.sortable,
388
- 'col--filter': !!filters,
389
- 'is--filter-active': hasFilter,
390
- 'col--current': currColFlag && currentCol === column
391
- }
392
- ],
393
- key: colid,
394
- ...thAttrs
395
- },
396
- [
397
- h(
398
- 'div',
399
- {
400
- class: [
401
- 'vxe-cell',
402
- '' + (cellClassName || ''),
403
- {
404
- 'c--title': showTitle,
405
- 'c--tooltip': showTooltip,
406
- 'c--ellipsis': showEllipsis
407
- }
408
- ],
409
- style: tcStyle
410
- },
411
- isOptimizeMode && fixedHiddenColumn && !floatingFilters
412
- ? []
413
- : [
414
- h(
415
- 'div',
416
- {
417
- colid,
418
- class: 'vxe-cell--wrapper vxe-header-cell--wrapper'
419
- },
420
- flSlot ? $xeTable.callSlot(flSlot, cellParams) : rtFloatingFilter && firstFilterOption ? getSlotVNs(rtFloatingFilter(filterRender, cellParams as unknown as VxeGlobalRendererHandles.RenderTableFloatingFilterParams)) : []
421
- )
422
- ]
423
- )
424
- ]
425
- )
426
- })
427
- }
428
-
429
- const renderHeads = (isGroup: boolean, isOptimizeMode: boolean, headerGroups: VxeTableDefines.ColumnInfo[][], renderColumnList: VxeTableDefines.ColumnInfo[]) => {
430
- const { fixedType } = props
431
-
432
- const { headerRowClassName, headerRowStyle } = tableProps
433
- const floatingFilterOpts = computeFloatingFilterOpts.value
434
- const isFFEnabled = floatingFilterOpts.enabled
435
- const isFFTop = floatingFilterOpts.position === 'top'
436
- const rowVNs: VNode[] = []
437
-
438
- if (isFFEnabled && isFFTop) {
439
- rowVNs.push(
440
- h('tr', {
441
- key: 'fft',
442
- class: ['vxe-header--row is--floating-filters', '' + (floatingFilterOpts.rowClassName || '')]
443
- }, renderFilterRows(isOptimizeMode, renderColumnList))
444
- )
445
- }
446
-
447
- headerGroups.forEach((cols, _rowIndex) => {
448
- const params = { $table: $xeTable, rowIndex: _rowIndex, _rowIndex, $rowIndex: _rowIndex, fixed: fixedType, type: renderType }
449
- rowVNs.push(
450
- h('tr', {
451
- key: _rowIndex,
452
- class: ['vxe-header--row', headerRowClassName ? (XEUtils.isFunction(headerRowClassName) ? headerRowClassName(params) : headerRowClassName) : ''],
453
- style: headerRowStyle ? (XEUtils.isFunction(headerRowStyle) ? headerRowStyle(params) : headerRowStyle) : null
454
- }, renderRows(isGroup, isOptimizeMode, headerGroups, _rowIndex, cols))
455
- )
456
- })
457
-
458
- if (isFFEnabled && !isFFTop) {
459
- rowVNs.push(
460
- h('tr', {
461
- key: 'ffb',
462
- class: ['vxe-header--row is--floating-filters', '' + (floatingFilterOpts.rowClassName || '')]
463
- }, renderFilterRows(isOptimizeMode, renderColumnList))
464
- )
465
- }
466
-
467
- return rowVNs
468
- }
469
-
470
- const renderVN = () => {
471
- const { fixedType, fixedColumn, tableColumn } = props
472
- const { mouseConfig } = tableProps
473
- const { isGroup, isColLoading, overflowX, scrollXLoad, dragCol } = tableReactData
474
- const { visibleColumn, fullColumnIdData } = tableInternalData
475
-
476
- const mouseOpts = computeMouseOpts.value
477
- const isHeaderRenderOptimize = computeIsHeaderRenderOptimize.value
478
- let renderHeaderList = headerColumn.value || []
479
- let renderColumnList = tableColumn as VxeTableDefines.ColumnInfo[]
480
- const isOptimizeMode = isHeaderRenderOptimize
481
-
482
- if (isGroup) {
483
- renderColumnList = visibleColumn
484
- } else {
485
- if (!isOptimizeMode || (!isColLoading && (fixedType || !overflowX))) {
486
- renderColumnList = visibleColumn
487
- }
488
-
489
- if (fixedType) {
490
- // 如果是使用优化模式
491
- if (isOptimizeMode) {
492
- renderColumnList = fixedColumn || []
493
- }
494
- }
495
- renderHeaderList = [renderColumnList]
496
- }
497
-
498
- if (!fixedType && !isGroup) {
499
- // 列拖拽
500
- if (scrollXLoad && dragCol) {
501
- if (renderColumnList.length > 2) {
502
- const dCowRest = fullColumnIdData[dragCol.id]
503
- if (dCowRest) {
504
- const dcIndex = dCowRest._index
505
- const firstCol = renderColumnList[0]
506
- const lastCol = renderColumnList[renderColumnList.length - 1]
507
- const firstColRest = fullColumnIdData[firstCol.id]
508
- const lastColRest = fullColumnIdData[lastCol.id]
509
- if (firstColRest && lastColRest) {
510
- const fcIndex = firstColRest._index
511
- const lcIndex = lastColRest._index
512
- if (dcIndex < fcIndex) {
513
- renderColumnList = [dragCol].concat(renderColumnList)
514
- renderHeaderList = [[dragCol].concat(renderHeaderList[0])].concat(renderHeaderList.slice(1))
515
- } else if (dcIndex > lcIndex) {
516
- renderColumnList = renderColumnList.concat([dragCol])
517
- renderHeaderList = [renderHeaderList[0].concat([dragCol])].concat(renderHeaderList.slice(1))
518
- }
519
- }
520
- }
521
- }
522
- }
523
- }
524
-
525
- return h(
526
- 'div',
527
- {
528
- ref: refElem,
529
- class: ['vxe-table--header-wrapper', fixedType ? `fixed-${fixedType}--wrapper` : 'body--wrapper'],
530
- xid: xID
531
- },
532
- [
533
- h(
534
- 'div',
535
- {
536
- ref: refHeaderScroll,
537
- class: 'vxe-table--header-inner-wrapper',
538
- onScroll(evnt) {
539
- $xeTable.triggerHeaderScrollEvent(evnt, fixedType)
540
- }
541
- },
542
- [
543
- fixedType
544
- ? renderEmptyElement($xeTable)
545
- : h('div', {
546
- ref: refHeaderXSpace,
547
- class: 'vxe-body--x-space'
548
- }),
549
- h(
550
- 'table',
551
- {
552
- ref: refHeaderTable,
553
- class: 'vxe-table--header',
554
- xid: xID,
555
- cellspacing: 0,
556
- cellpadding: 0,
557
- border: 0,
558
- xvm: isOptimizeMode ? '1' : null
559
- },
560
- [
561
- /**
562
- * 列宽
563
- */
564
- h(
565
- 'colgroup',
566
- {
567
- ref: refHeaderColgroup
568
- },
569
- renderColumnList.map((column, $columnIndex) => {
570
- return h('col', {
571
- name: column.id,
572
- key: $columnIndex,
573
- style: {
574
- width: `${column.renderWidth}px`
575
- }
576
- })
577
- })
578
- ),
579
- /**
580
- * 头部
581
- */
582
- h(
583
- 'thead',
584
- {
585
- ref: refHeaderTHead
586
- },
587
- renderHeads(isGroup, isOptimizeMode, renderHeaderList, renderColumnList)
588
- )
589
- ]
590
- ),
591
- hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area
592
- ? h(
593
- 'div',
594
- {
595
- class: 'vxe-table--cell-area',
596
- xid: xID
597
- },
598
- [
599
- h('span', {
600
- class: 'vxe-table--cell-main-area'
601
- }),
602
- h('span', {
603
- class: 'vxe-table--cell-clip-area'
604
- }),
605
- h('span', {
606
- class: 'vxe-table--cell-extend-area'
607
- }),
608
- h('span', {
609
- class: 'vxe-table--cell-multi-area'
610
- }),
611
- h('span', {
612
- class: 'vxe-table--cell-active-area'
613
- }),
614
- h('span', {
615
- class: 'vxe-table--cell-col-status-area'
616
- })
617
- ]
618
- )
619
- : renderEmptyElement($xeTable)
620
- ]
621
- )
622
- ]
623
- )
624
- }
625
-
626
- watch(() => props.tableColumn, uploadColumn)
627
-
628
- onMounted(() => {
629
- nextTick(() => {
630
- const { fixedType } = props
631
- const { internalData } = $xeTable
632
- const { elemStore } = internalData
633
- const prefix = `${fixedType || 'main'}-header-`
634
- elemStore[`${prefix}wrapper`] = refElem
635
- elemStore[`${prefix}scroll`] = refHeaderScroll
636
- elemStore[`${prefix}table`] = refHeaderTable
637
- elemStore[`${prefix}colgroup`] = refHeaderColgroup
638
- elemStore[`${prefix}list`] = refHeaderTHead
639
- elemStore[`${prefix}xSpace`] = refHeaderXSpace
640
- elemStore[`${prefix}repair`] = refHeaderBorderRepair
641
- uploadColumn()
642
- })
643
- })
644
-
645
- onUnmounted(() => {
646
- const { fixedType } = props
647
- const { internalData } = $xeTable
648
- const { elemStore } = internalData
649
- const prefix = `${fixedType || 'main'}-header-`
650
- elemStore[`${prefix}wrapper`] = null
651
- elemStore[`${prefix}scroll`] = null
652
- elemStore[`${prefix}table`] = null
653
- elemStore[`${prefix}colgroup`] = null
654
- elemStore[`${prefix}list`] = null
655
- elemStore[`${prefix}xSpace`] = null
656
- elemStore[`${prefix}repair`] = null
657
- })
658
-
659
- return renderVN
660
- }
661
- }) /* define-vxe-component end */
1
+ import { h, ref, Ref, PropType, inject, nextTick, watch, onMounted, onUnmounted, VNode } from 'vue'
2
+ import { defineVxeComponent } from '../../ui/src/comp'
3
+ import XEUtils from 'xe-utils'
4
+ import { VxeUI } from '@vxe-ui/core'
5
+ import { getDefaultConfig, hasEnableConf, isEnableConf } from '../../ui/src/utils'
6
+ import { getCalcHeight, convertHeaderColumnToRows, convertHeaderToGridRows } from './util'
7
+ import { getSlotVNs } from '../../ui/src/vn'
8
+
9
+ import type { VxeTablePrivateMethods, VxeTableConstructor, VxeTableMethods, VxeTableDefines, VxeGlobalRendererHandles } from '../../../types'
10
+
11
+ const { renderer, renderEmptyElement } = VxeUI
12
+
13
+ const sourceType = 'table'
14
+ const renderType = 'header'
15
+
16
+ export default /* define-vxe-component start */ defineVxeComponent({
17
+ name: 'VxeTableHeader',
18
+ props: {
19
+ tableData: Array as PropType<any[]>,
20
+ tableColumn: Array as PropType<VxeTableDefines.ColumnInfo[]>,
21
+ tableGroupColumn: Array as PropType<VxeTableDefines.ColumnInfo[]>,
22
+ fixedColumn: Array as PropType<VxeTableDefines.ColumnInfo[]>,
23
+ fixedType: {
24
+ type: String as PropType<'right' | 'left' | ''>,
25
+ default: null
26
+ }
27
+ },
28
+ setup(props) {
29
+ const $xeTable = inject('$xeTable', {} as VxeTableConstructor & VxeTableMethods & VxeTablePrivateMethods)
30
+
31
+ const { xID, props: tableProps, reactData: tableReactData, internalData: tableInternalData } = $xeTable
32
+ const { computeColumnOpts, computeColumnDragOpts, computeCellOpts, computeMouseOpts, computeHeaderCellOpts, computeDefaultRowHeight, computeVirtualXOpts, computeFloatingFilterOpts, computeIsHeaderRenderOptimize, computeHeaderTooltipOpts, computeRendererOpts } = $xeTable.getComputeMaps()
33
+
34
+ const headerColumn = ref<VxeTableDefines.ColumnInfo[][]>([])
35
+
36
+ const refElem = ref() as Ref<HTMLDivElement>
37
+ const refHeaderScroll = ref() as Ref<HTMLDivElement>
38
+ const refHeaderTable = ref() as Ref<HTMLTableElement>
39
+ const refHeaderColgroup = ref() as Ref<HTMLTableColElement>
40
+ const refHeaderTHead = ref() as Ref<HTMLTableSectionElement>
41
+ const refHeaderXSpace = ref() as Ref<HTMLDivElement>
42
+ const refHeaderBorderRepair = ref() as Ref<HTMLDivElement>
43
+
44
+ const uploadColumn = () => {
45
+ const { showCustomHeader } = tableProps
46
+ const { collectColumn, visibleColumn } = tableInternalData
47
+ const { tableGroupColumn } = props
48
+ const { isGroup } = tableReactData
49
+ let spanColumns: VxeTableDefines.ColumnInfo[][] = isGroup ? convertHeaderColumnToRows(tableGroupColumn) : []
50
+ let visibleColgroups: VxeTableDefines.ColumnInfo[][] = []
51
+ if (showCustomHeader && spanColumns.length > 1) {
52
+ visibleColgroups = convertHeaderToGridRows(spanColumns)
53
+ spanColumns = visibleColgroups
54
+ }
55
+ headerColumn.value = spanColumns
56
+ nextTick(() => {
57
+ $xeTable.dispatchEvent('columns-change', { visibleColgroups, collectColumn, visibleColumn }, null)
58
+ })
59
+ }
60
+
61
+ const renderRows = (isGroup: boolean, isOptimizeMode: boolean, headerGroups: VxeTableDefines.ColumnInfo[][], _rowIndex: number, cols: VxeTableDefines.ColumnInfo[]) => {
62
+ const $xeGrid = $xeTable.xeGrid
63
+ const $xeGantt = $xeTable.xeGantt
64
+
65
+ const { fixedType } = props
66
+ const { resizable: allResizable, columnKey, showCustomHeader, headerCellClassName, headerCellStyle, showHeaderOverflow: allColumnHeaderOverflow, headerAlign: allHeaderAlign, align: allAlign, mouseConfig } = tableProps
67
+ const { dragCol, scrollXLoad, scrollYLoad, overflowX, mergeHeadFlag, tableColumn, currColFlag } = tableReactData
68
+ const { fullColumnIdData, scrollXStore, mergeHeaderList, mergeHeaderCellMaps, currentCol } = tableInternalData
69
+ const virtualXOpts = computeVirtualXOpts.value
70
+ const columnOpts = computeColumnOpts.value
71
+ const columnDragOpts = computeColumnDragOpts.value
72
+ const headerTooltipOpts = computeHeaderTooltipOpts.value
73
+ const cellOpts = computeCellOpts.value
74
+ const defaultRowHeight = computeDefaultRowHeight.value
75
+ const headerCellOpts = computeHeaderCellOpts.value
76
+ const rendererOpts = computeRendererOpts.value
77
+ const mouseOpts = computeMouseOpts.value
78
+ const currCellHeight = getCalcHeight(headerCellOpts.height) || defaultRowHeight
79
+ const { disabledMethod: dragDisabledMethod, isCrossDrag, isPeerDrag } = columnDragOpts
80
+ const isLastRow = _rowIndex === headerGroups.length - 1
81
+
82
+ return cols.map((column, $columnIndex) => {
83
+ const { type, showHeaderOverflow, headerAlign, align, filters, headerClassName, editRender, cellRender } = column
84
+ const colid = column.id
85
+ const colRest = fullColumnIdData[colid] || {}
86
+ const renderOpts = editRender || cellRender
87
+ const compConf = renderOpts && renderOpts.name ? rendererOpts[renderOpts.name] || renderer.get(renderOpts.name) : null
88
+ const isColGroup = column.children && column.children.length
89
+ const fixedHiddenColumn = overflowX && !isColGroup && (fixedType ? column.fixed !== fixedType : !!column.fixed)
90
+
91
+ const cellPadding = getDefaultConfig(headerCellOpts.padding, cellOpts.padding)
92
+ const isAllCellPadding = cellPadding === true
93
+ const isCellPaddingTop = cellPadding ? isAllCellPadding || cellPadding.top !== false : false
94
+ const isCellPaddingBottom = cellPadding ? isAllCellPadding || cellPadding.bottom !== false : false
95
+ const isCellPaddingLeft = cellPadding ? isAllCellPadding || cellPadding.left !== false : false
96
+ const isCellPaddingRight = cellPadding ? isAllCellPadding || cellPadding.right !== false : false
97
+
98
+ const headOverflow = getDefaultConfig(showHeaderOverflow, allColumnHeaderOverflow)
99
+ const headAlign = headerAlign || (compConf ? compConf.tableHeaderCellAlign : '') || allHeaderAlign || align || (compConf ? compConf.tableCellAlign : '') || allAlign
100
+ const showEllipsis = (headOverflow === true ? headerTooltipOpts.mode : headOverflow) === 'ellipsis'
101
+ const showTitle = (headOverflow === true ? headerTooltipOpts.mode : headOverflow) === 'title'
102
+ const showTooltip = (headOverflow === true ? headerTooltipOpts.mode : headOverflow) === 'tooltip'
103
+ const hasEllipsis = showTitle || showTooltip || showEllipsis
104
+ let hasFilter = false
105
+ let firstFilterOption: VxeTableDefines.FilterOption | null = null
106
+ if (filters) {
107
+ firstFilterOption = filters[0] as VxeTableDefines.FilterOption
108
+ hasFilter = filters.some((item) => item.checked)
109
+ }
110
+ const columnIndex = colRest.index
111
+ const _columnIndex = colRest._index
112
+ const cellParams: VxeTableDefines.CellRenderHeaderParams & {
113
+ $table: VxeTableConstructor & VxeTablePrivateMethods
114
+ } = {
115
+ $table: $xeTable,
116
+ $grid: $xeGrid,
117
+ $gantt: $xeGantt,
118
+ rowIndex: _rowIndex,
119
+ _rowIndex,
120
+ $rowIndex: _rowIndex,
121
+ column,
122
+ columnIndex,
123
+ $columnIndex,
124
+ _columnIndex,
125
+ firstFilterOption: firstFilterOption as VxeTableDefines.FilterOption,
126
+ fixed: fixedType,
127
+ source: sourceType,
128
+ type: renderType,
129
+ isHidden: fixedHiddenColumn,
130
+ hasFilter
131
+ }
132
+ const thAttrs: Record<string, string | number | null> = {
133
+ colid
134
+ }
135
+ let isMergeCell = false
136
+ // 合并行或列
137
+ if (!showCustomHeader) {
138
+ thAttrs.colspan = column.colSpan > 1 ? column.colSpan : null
139
+ thAttrs.rowspan = column.rowSpan > 1 ? column.rowSpan : null
140
+ }
141
+ if (mergeHeadFlag && mergeHeaderList.length && (showCustomHeader || isLastRow)) {
142
+ const spanRest = mergeHeaderCellMaps[`${_rowIndex}:${showCustomHeader ? $columnIndex : _columnIndex}`]
143
+ if (spanRest) {
144
+ const { rowspan, colspan } = spanRest
145
+ if (!rowspan || !colspan) {
146
+ return null
147
+ }
148
+ if (rowspan > 1) {
149
+ isMergeCell = true
150
+ thAttrs.rowspan = rowspan
151
+ }
152
+ if (colspan > 1) {
153
+ isMergeCell = true
154
+ thAttrs.colspan = colspan
155
+ }
156
+ }
157
+ }
158
+
159
+ const thOns: any = {
160
+ onClick: (evnt: MouseEvent) => $xeTable.triggerHeaderCellClickEvent(evnt, cellParams),
161
+ onDblclick: (evnt: MouseEvent) => $xeTable.triggerHeaderCellDblclickEvent(evnt, cellParams)
162
+ }
163
+ const isColDragCell = columnOpts.drag && columnDragOpts.trigger === 'cell'
164
+ let isDisabledDrag = false
165
+ if (isColDragCell) {
166
+ isDisabledDrag = !!(dragDisabledMethod && dragDisabledMethod(cellParams))
167
+ }
168
+ // 按下事件处理
169
+ if (hasEnableConf(mouseConfig, mouseOpts) || isColDragCell) {
170
+ thOns.onMousedown = (evnt: MouseEvent) => $xeTable.triggerHeaderCellMousedownEvent(evnt, cellParams)
171
+ }
172
+ // 拖拽列事件
173
+ if (columnOpts.drag) {
174
+ thOns.onDragstart = $xeTable.handleHeaderCellDragDragstartEvent
175
+ thOns.onDragend = $xeTable.handleHeaderCellDragDragendEvent
176
+ thOns.onDragover = $xeTable.handleHeaderCellDragDragoverEvent
177
+ if (isColDragCell) {
178
+ thOns.onMouseup = $xeTable.handleHeaderCellDragMouseupEvent
179
+ }
180
+ }
181
+ const isLastColumn = $columnIndex === cols.length - 1
182
+ const showResizable = XEUtils.isBoolean(column.resizable) ? column.resizable : columnOpts.resizable || allResizable
183
+ const isAutoCellWidth = !column.resizeWidth && (column.minWidth === 'auto' || column.width === 'auto')
184
+
185
+ let isVNPreEmptyStatus = false
186
+ if (isOptimizeMode && overflowX && !isGroup && !isMergeCell) {
187
+ if (!dragCol || dragCol.id !== colid) {
188
+ if (scrollXLoad && tableColumn.length > 10 && !column.fixed && !virtualXOpts.immediate && (_columnIndex < scrollXStore.visibleStartIndex - scrollXStore.preloadSize || _columnIndex > scrollXStore.visibleEndIndex + scrollXStore.preloadSize)) {
189
+ isVNPreEmptyStatus = true
190
+ }
191
+ }
192
+ }
193
+
194
+ const tcStyle: Record<string, string> = {}
195
+ if (hasEllipsis) {
196
+ tcStyle.height = `${currCellHeight}px`
197
+ } else {
198
+ tcStyle.minHeight = `${currCellHeight}px`
199
+ }
200
+
201
+ if (showCustomHeader) {
202
+ // custom
203
+ } else if (isColGroup && !isLastRow) {
204
+ let childWidth = 0
205
+ XEUtils.eachTree(column.children, (childRow) => {
206
+ if (childRow.visible && (!childRow.children || !childRow.children.length)) {
207
+ childWidth += childRow.renderWidth
208
+ }
209
+ })
210
+ tcStyle.width = `${childWidth}px`
211
+ }
212
+
213
+ return h(
214
+ 'th',
215
+ {
216
+ class: [
217
+ 'vxe-table--column vxe-header--column',
218
+ colid,
219
+ fixedHiddenColumn ? 'fixed--hidden' : 'fixed--visible',
220
+ {
221
+ [`col--${headAlign}`]: headAlign,
222
+ [`col--${type}`]: type,
223
+ 'col--last': isLastColumn,
224
+ 'col--fixed': column.fixed,
225
+ 'col--group': isColGroup,
226
+ 'col--ellipsis': hasEllipsis,
227
+ 'fixed--width': !isAutoCellWidth,
228
+ 'is--pg-top': isCellPaddingTop,
229
+ 'is--pg-bottom': isCellPaddingBottom,
230
+ 'is--pg-left': isCellPaddingLeft,
231
+ 'is--pg-right': isCellPaddingRight,
232
+ 'is--sortable': column.sortable,
233
+ 'col--filter': !!filters,
234
+ 'is--filter-active': hasFilter,
235
+ 'is--drag-active': columnOpts.drag && !column.fixed && !isDisabledDrag && (isCrossDrag || isPeerDrag || !column.parentId),
236
+ 'is--drag-disabled': columnOpts.drag && isDisabledDrag,
237
+ 'col--current': currColFlag && currentCol === column
238
+ },
239
+ headerClassName ? (XEUtils.isFunction(headerClassName) ? headerClassName(cellParams) : headerClassName) : '',
240
+ headerCellClassName ? (XEUtils.isFunction(headerCellClassName) ? headerCellClassName(cellParams) : headerCellClassName) : ''
241
+ ],
242
+ style: headerCellStyle ? (XEUtils.isFunction(headerCellStyle) ? headerCellStyle(cellParams) : headerCellStyle) : null,
243
+ ...thAttrs,
244
+ ...thOns,
245
+ key: showCustomHeader ? `${colid}${$columnIndex}` : columnKey || scrollXLoad || scrollYLoad || columnOpts.useKey || columnOpts.drag || isColGroup ? colid : $columnIndex
246
+ },
247
+ [
248
+ h(
249
+ 'div',
250
+ {
251
+ class: [
252
+ 'vxe-cell',
253
+ {
254
+ 'c--title': showTitle,
255
+ 'c--tooltip': showTooltip,
256
+ 'c--ellipsis': showEllipsis
257
+ }
258
+ ],
259
+ style: tcStyle
260
+ },
261
+ isVNPreEmptyStatus || (isOptimizeMode && fixedHiddenColumn)
262
+ ? []
263
+ : [
264
+ h(
265
+ 'div',
266
+ {
267
+ colid,
268
+ class: 'vxe-cell--wrapper vxe-header-cell--wrapper'
269
+ },
270
+ column.renderHeader(cellParams)
271
+ )
272
+ ]
273
+ ),
274
+ /**
275
+ * 列宽拖动
276
+ */
277
+ !fixedHiddenColumn && showResizable && (!showCustomHeader || isLastRow)
278
+ ? h('div', {
279
+ class: 'vxe-cell--col-resizable',
280
+ onMousedown: (evnt: MouseEvent) => $xeTable.handleColResizeMousedownEvent(evnt, fixedType, cellParams),
281
+ onDblclick: (evnt: MouseEvent) => $xeTable.handleColResizeDblclickEvent(evnt, cellParams)
282
+ })
283
+ : renderEmptyElement($xeTable)
284
+ ]
285
+ )
286
+ })
287
+ }
288
+
289
+ const renderFilterRows = (isOptimizeMode: boolean, cols: VxeTableDefines.ColumnInfo[]) => {
290
+ const $xeGrid = $xeTable.xeGrid
291
+ const $xeGantt = $xeTable.xeGantt
292
+
293
+ const { fixedType } = props
294
+ const { showHeaderOverflow: allColumnHeaderOverflow, headerAlign: allHeaderAlign, align: allAlign } = tableProps
295
+ const { overflowX, currColFlag } = tableReactData
296
+ const { fullColumnIdData, currentCol } = tableInternalData
297
+ const headerTooltipOpts = computeHeaderTooltipOpts.value
298
+ const cellOpts = computeCellOpts.value
299
+ const defaultRowHeight = computeDefaultRowHeight.value
300
+ const headerCellOpts = computeHeaderCellOpts.value
301
+ const floatingFilterOpts = computeFloatingFilterOpts.value
302
+ const rendererOpts = computeRendererOpts.value
303
+ const { cellClassName } = floatingFilterOpts
304
+ const currCellHeight = getCalcHeight(headerCellOpts.height) || defaultRowHeight
305
+
306
+ return cols.map((column, $columnIndex) => {
307
+ const { type, showHeaderOverflow, headerAlign, align, filters, editRender, cellRender, floatingFilters, filterRender, slots } = column
308
+ const colid = column.id
309
+ const colRest = fullColumnIdData[colid] || {}
310
+ const renderOpts = editRender || cellRender
311
+ const flSlot = slots ? slots.floatingFilter || slots['floating-filter'] : null
312
+ const compConf = renderOpts && renderOpts.name ? rendererOpts[renderOpts.name] || renderer.get(renderOpts.name) : null
313
+ const flCompConf = isEnableConf(filterRender) && filterRender.name ? rendererOpts[filterRender.name] || renderer.get(filterRender.name) : null
314
+ const rtFloatingFilter = flCompConf ? flCompConf.renderTableFloatingFilter : null
315
+ const fixedHiddenColumn = overflowX && (fixedType ? column.fixed !== fixedType : !!column.fixed)
316
+
317
+ const cellPadding = getDefaultConfig(headerCellOpts.padding, cellOpts.padding)
318
+ const isAllCellPadding = cellPadding === true
319
+ const isCellPaddingTop = cellPadding ? isAllCellPadding || cellPadding.top !== false : false
320
+ const isCellPaddingBottom = cellPadding ? isAllCellPadding || cellPadding.bottom !== false : false
321
+ const isCellPaddingLeft = cellPadding ? isAllCellPadding || cellPadding.left !== false : false
322
+ const isCellPaddingRight = cellPadding ? isAllCellPadding || cellPadding.right !== false : false
323
+ const headOverflow = XEUtils.eqNull(showHeaderOverflow) ? allColumnHeaderOverflow : showHeaderOverflow
324
+
325
+ const headAlign = headerAlign || (compConf ? compConf.tableHeaderCellAlign : '') || allHeaderAlign || align || (compConf ? compConf.tableCellAlign : '') || allAlign
326
+ const showEllipsis = headOverflow === 'ellipsis'
327
+ const showTitle = headOverflow === 'title'
328
+ const showTooltip = headOverflow === true ? headerTooltipOpts.mode === 'tooltip' : headOverflow === 'tooltip'
329
+ const hasEllipsis = showTitle || showTooltip || showEllipsis
330
+ let hasFilter = false
331
+ let firstFilterOption: VxeTableDefines.FilterOption | null = null
332
+ if (filters) {
333
+ firstFilterOption = filters[0] as VxeTableDefines.FilterOption
334
+ hasFilter = filters.some((item) => item.checked)
335
+ }
336
+ const columnIndex = colRest.index
337
+ const _columnIndex = colRest._index
338
+ const cellParams: VxeTableDefines.CellFloatingFilterParams & {
339
+ $table: VxeTableConstructor & VxeTablePrivateMethods
340
+ } = {
341
+ $table: $xeTable,
342
+ $grid: $xeGrid,
343
+ $gantt: $xeGantt,
344
+ column,
345
+ columnIndex,
346
+ $columnIndex,
347
+ _columnIndex,
348
+ option: firstFilterOption as VxeTableDefines.FilterOption,
349
+ fixed: fixedType,
350
+ source: sourceType,
351
+ type: renderType,
352
+ isHidden: fixedHiddenColumn,
353
+ hasFilter
354
+ }
355
+ const thAttrs: Record<string, string | number | null> = {
356
+ colid
357
+ }
358
+
359
+ const isLastColumn = $columnIndex === cols.length - 1
360
+ const isAutoCellWidth = !column.resizeWidth && (column.minWidth === 'auto' || column.width === 'auto')
361
+
362
+ const tcStyle: Record<string, string> = {}
363
+ if (hasEllipsis) {
364
+ tcStyle.height = `${currCellHeight}px`
365
+ } else {
366
+ tcStyle.minHeight = `${currCellHeight}px`
367
+ }
368
+
369
+ return h(
370
+ 'th',
371
+ {
372
+ class: [
373
+ 'vxe-table--column vxe-header--column is--floating-filters',
374
+ colid,
375
+ fixedHiddenColumn ? 'fixed--hidden' : 'fixed--visible',
376
+ {
377
+ [`col--${headAlign}`]: headAlign,
378
+ [`col--${type}`]: type,
379
+ 'col--last': isLastColumn,
380
+ 'col--fixed': column.fixed,
381
+ 'col--ellipsis': hasEllipsis,
382
+ 'fixed--width': !isAutoCellWidth,
383
+ 'is--pg-top': isCellPaddingTop,
384
+ 'is--pg-bottom': isCellPaddingBottom,
385
+ 'is--pg-left': isCellPaddingLeft,
386
+ 'is--pg-right': isCellPaddingRight,
387
+ 'is--sortable': column.sortable,
388
+ 'col--filter': !!filters,
389
+ 'is--filter-active': hasFilter,
390
+ 'col--current': currColFlag && currentCol === column
391
+ }
392
+ ],
393
+ key: colid,
394
+ ...thAttrs
395
+ },
396
+ [
397
+ h(
398
+ 'div',
399
+ {
400
+ class: [
401
+ 'vxe-cell',
402
+ '' + (cellClassName || ''),
403
+ {
404
+ 'c--title': showTitle,
405
+ 'c--tooltip': showTooltip,
406
+ 'c--ellipsis': showEllipsis
407
+ }
408
+ ],
409
+ style: tcStyle
410
+ },
411
+ isOptimizeMode && fixedHiddenColumn && !floatingFilters
412
+ ? []
413
+ : [
414
+ h(
415
+ 'div',
416
+ {
417
+ colid,
418
+ class: 'vxe-cell--wrapper vxe-header-cell--wrapper'
419
+ },
420
+ flSlot ? $xeTable.callSlot(flSlot, cellParams) : rtFloatingFilter && firstFilterOption ? getSlotVNs(rtFloatingFilter(filterRender, cellParams as unknown as VxeGlobalRendererHandles.RenderTableFloatingFilterParams)) : []
421
+ )
422
+ ]
423
+ )
424
+ ]
425
+ )
426
+ })
427
+ }
428
+
429
+ const renderHeads = (isGroup: boolean, isOptimizeMode: boolean, headerGroups: VxeTableDefines.ColumnInfo[][], renderColumnList: VxeTableDefines.ColumnInfo[]) => {
430
+ const { fixedType } = props
431
+
432
+ const { headerRowClassName, headerRowStyle } = tableProps
433
+ const floatingFilterOpts = computeFloatingFilterOpts.value
434
+ const isFFEnabled = floatingFilterOpts.enabled
435
+ const isFFTop = floatingFilterOpts.position === 'top'
436
+ const rowVNs: VNode[] = []
437
+
438
+ if (isFFEnabled && isFFTop) {
439
+ rowVNs.push(
440
+ h('tr', {
441
+ key: 'fft',
442
+ class: ['vxe-header--row is--floating-filters', '' + (floatingFilterOpts.rowClassName || '')]
443
+ }, renderFilterRows(isOptimizeMode, renderColumnList))
444
+ )
445
+ }
446
+
447
+ headerGroups.forEach((cols, _rowIndex) => {
448
+ const params = { $table: $xeTable, rowIndex: _rowIndex, _rowIndex, $rowIndex: _rowIndex, fixed: fixedType, type: renderType }
449
+ rowVNs.push(
450
+ h('tr', {
451
+ key: _rowIndex,
452
+ class: ['vxe-header--row', headerRowClassName ? (XEUtils.isFunction(headerRowClassName) ? headerRowClassName(params) : headerRowClassName) : ''],
453
+ style: headerRowStyle ? (XEUtils.isFunction(headerRowStyle) ? headerRowStyle(params) : headerRowStyle) : null
454
+ }, renderRows(isGroup, isOptimizeMode, headerGroups, _rowIndex, cols))
455
+ )
456
+ })
457
+
458
+ if (isFFEnabled && !isFFTop) {
459
+ rowVNs.push(
460
+ h('tr', {
461
+ key: 'ffb',
462
+ class: ['vxe-header--row is--floating-filters', '' + (floatingFilterOpts.rowClassName || '')]
463
+ }, renderFilterRows(isOptimizeMode, renderColumnList))
464
+ )
465
+ }
466
+
467
+ return rowVNs
468
+ }
469
+
470
+ const renderVN = () => {
471
+ const { fixedType, fixedColumn, tableColumn } = props
472
+ const { mouseConfig } = tableProps
473
+ const { isGroup, isColLoading, overflowX, scrollXLoad, dragCol } = tableReactData
474
+ const { visibleColumn, fullColumnIdData } = tableInternalData
475
+
476
+ const mouseOpts = computeMouseOpts.value
477
+ const isHeaderRenderOptimize = computeIsHeaderRenderOptimize.value
478
+ let renderHeaderList = headerColumn.value || []
479
+ let renderColumnList = tableColumn as VxeTableDefines.ColumnInfo[]
480
+ const isOptimizeMode = isHeaderRenderOptimize
481
+
482
+ if (isGroup) {
483
+ renderColumnList = visibleColumn
484
+ } else {
485
+ if (!isOptimizeMode || (!isColLoading && (fixedType || !overflowX))) {
486
+ renderColumnList = visibleColumn
487
+ }
488
+
489
+ if (fixedType) {
490
+ // 如果是使用优化模式
491
+ if (isOptimizeMode) {
492
+ renderColumnList = fixedColumn || []
493
+ }
494
+ }
495
+ renderHeaderList = [renderColumnList]
496
+ }
497
+
498
+ if (!fixedType && !isGroup) {
499
+ // 列拖拽
500
+ if (scrollXLoad && dragCol) {
501
+ if (renderColumnList.length > 2) {
502
+ const dCowRest = fullColumnIdData[dragCol.id]
503
+ if (dCowRest) {
504
+ const dcIndex = dCowRest._index
505
+ const firstCol = renderColumnList[0]
506
+ const lastCol = renderColumnList[renderColumnList.length - 1]
507
+ const firstColRest = fullColumnIdData[firstCol.id]
508
+ const lastColRest = fullColumnIdData[lastCol.id]
509
+ if (firstColRest && lastColRest) {
510
+ const fcIndex = firstColRest._index
511
+ const lcIndex = lastColRest._index
512
+ if (dcIndex < fcIndex) {
513
+ renderColumnList = [dragCol].concat(renderColumnList)
514
+ renderHeaderList = [[dragCol].concat(renderHeaderList[0])].concat(renderHeaderList.slice(1))
515
+ } else if (dcIndex > lcIndex) {
516
+ renderColumnList = renderColumnList.concat([dragCol])
517
+ renderHeaderList = [renderHeaderList[0].concat([dragCol])].concat(renderHeaderList.slice(1))
518
+ }
519
+ }
520
+ }
521
+ }
522
+ }
523
+ }
524
+
525
+ return h(
526
+ 'div',
527
+ {
528
+ ref: refElem,
529
+ class: ['vxe-table--header-wrapper', fixedType ? `fixed-${fixedType}--wrapper` : 'body--wrapper'],
530
+ xid: xID
531
+ },
532
+ [
533
+ h(
534
+ 'div',
535
+ {
536
+ ref: refHeaderScroll,
537
+ class: 'vxe-table--header-inner-wrapper',
538
+ onScroll(evnt) {
539
+ $xeTable.triggerHeaderScrollEvent(evnt, fixedType)
540
+ }
541
+ },
542
+ [
543
+ fixedType
544
+ ? renderEmptyElement($xeTable)
545
+ : h('div', {
546
+ ref: refHeaderXSpace,
547
+ class: 'vxe-body--x-space'
548
+ }),
549
+ h(
550
+ 'table',
551
+ {
552
+ ref: refHeaderTable,
553
+ class: 'vxe-table--header',
554
+ xid: xID,
555
+ cellspacing: 0,
556
+ cellpadding: 0,
557
+ border: 0,
558
+ xvm: isOptimizeMode ? '1' : null
559
+ },
560
+ [
561
+ /**
562
+ * 列宽
563
+ */
564
+ h(
565
+ 'colgroup',
566
+ {
567
+ ref: refHeaderColgroup
568
+ },
569
+ renderColumnList.map((column, $columnIndex) => {
570
+ return h('col', {
571
+ name: column.id,
572
+ key: $columnIndex,
573
+ style: {
574
+ width: `${column.renderWidth}px`
575
+ }
576
+ })
577
+ })
578
+ ),
579
+ /**
580
+ * 头部
581
+ */
582
+ h(
583
+ 'thead',
584
+ {
585
+ ref: refHeaderTHead
586
+ },
587
+ renderHeads(isGroup, isOptimizeMode, renderHeaderList, renderColumnList)
588
+ )
589
+ ]
590
+ ),
591
+ hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area
592
+ ? h(
593
+ 'div',
594
+ {
595
+ class: 'vxe-table--cell-area',
596
+ xid: xID
597
+ },
598
+ [
599
+ h('span', {
600
+ class: 'vxe-table--cell-main-area'
601
+ }),
602
+ h('span', {
603
+ class: 'vxe-table--cell-clip-area'
604
+ }),
605
+ h('span', {
606
+ class: 'vxe-table--cell-extend-area'
607
+ }),
608
+ h('span', {
609
+ class: 'vxe-table--cell-multi-area'
610
+ }),
611
+ h('span', {
612
+ class: 'vxe-table--cell-active-area'
613
+ }),
614
+ h('span', {
615
+ class: 'vxe-table--cell-col-status-area'
616
+ })
617
+ ]
618
+ )
619
+ : renderEmptyElement($xeTable)
620
+ ]
621
+ )
622
+ ]
623
+ )
624
+ }
625
+
626
+ watch(() => props.tableColumn, uploadColumn)
627
+
628
+ onMounted(() => {
629
+ nextTick(() => {
630
+ const { fixedType } = props
631
+ const { internalData } = $xeTable
632
+ const { elemStore } = internalData
633
+ const prefix = `${fixedType || 'main'}-header-`
634
+ elemStore[`${prefix}wrapper`] = refElem
635
+ elemStore[`${prefix}scroll`] = refHeaderScroll
636
+ elemStore[`${prefix}table`] = refHeaderTable
637
+ elemStore[`${prefix}colgroup`] = refHeaderColgroup
638
+ elemStore[`${prefix}list`] = refHeaderTHead
639
+ elemStore[`${prefix}xSpace`] = refHeaderXSpace
640
+ elemStore[`${prefix}repair`] = refHeaderBorderRepair
641
+ uploadColumn()
642
+ })
643
+ })
644
+
645
+ onUnmounted(() => {
646
+ const { fixedType } = props
647
+ const { internalData } = $xeTable
648
+ const { elemStore } = internalData
649
+ const prefix = `${fixedType || 'main'}-header-`
650
+ elemStore[`${prefix}wrapper`] = null
651
+ elemStore[`${prefix}scroll`] = null
652
+ elemStore[`${prefix}table`] = null
653
+ elemStore[`${prefix}colgroup`] = null
654
+ elemStore[`${prefix}list`] = null
655
+ elemStore[`${prefix}xSpace`] = null
656
+ elemStore[`${prefix}repair`] = null
657
+ })
658
+
659
+ return renderVN
660
+ }
661
+ }) /* define-vxe-component end */