vxe-table 4.18.7 → 4.18.9

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