vxe-table 4.23.7 → 4.23.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.
- package/dist/all.esm.js +5859 -4018
- package/es/colgroup/index.js +1 -1
- package/es/column/index.js +1 -1
- package/es/components.d.ts +3 -0
- package/es/components.js +4 -8
- package/es/grid/index.js +1 -1
- package/es/grid/src/emits.js +1 -15
- package/es/grid/src/grid.js +398 -121
- package/es/grid/src/props.js +1 -1
- package/es/index.esm.js +6 -0
- package/es/index.js +6 -0
- package/es/table/index.js +1 -1
- package/es/table/module/custom/hook.js +50 -43
- package/es/table/module/custom/panel.js +778 -528
- package/es/table/module/edit/hook.js +141 -63
- package/es/table/module/export/export-panel.js +400 -317
- package/es/table/module/export/hook.js +396 -338
- package/es/table/module/export/import-panel.js +153 -124
- package/es/table/module/filter/hook.js +17 -3
- package/es/table/module/filter/panel.js +147 -85
- package/es/table/module/keyboard/hook.js +9 -5
- package/es/table/module/menu/hook.js +1 -1
- package/es/table/module/menu/panel.js +198 -127
- package/es/table/module/validator/hook.js +1 -1
- package/es/table/render/index.js +152 -99
- package/es/table/src/body.js +356 -234
- package/es/table/src/cell.js +427 -270
- package/es/table/src/columnInfo.js +2 -1
- package/es/table/src/footer.js +145 -100
- package/es/table/src/group.js +7 -3
- package/es/table/src/header.js +230 -173
- package/es/table/src/props.js +1 -1
- package/es/table/src/table.js +1504 -1031
- package/es/table/src/util.js +15 -19
- package/es/toolbar/index.js +1 -1
- package/es/toolbar/src/toolbar.js +133 -76
- package/es/ui/index.d.ts +0 -1
- package/es/ui/index.js +1 -2
- package/es/ui/src/dom.js +9 -6
- package/es/ui/src/log.js +1 -1
- package/es/ui/src/utils.d.ts +1 -1
- package/es/v-x-e-table/index.d.ts +0 -1
- package/es/v-x-e-table/index.js +0 -1
- package/lib/colgroup/index.js +5 -5
- package/lib/column/index.js +5 -5
- package/lib/components.js +8 -12
- package/lib/grid/index.js +4 -4
- package/lib/grid/src/emits.js +1 -15
- package/lib/grid/src/grid.js +419 -142
- package/lib/grid/src/props.js +2 -2
- package/lib/index.common.js +6 -0
- package/lib/index.js +6 -0
- package/lib/index.umd.js +5825 -3945
- package/lib/index.umd.min.js +3 -3
- package/lib/table/index.js +5 -5
- package/lib/table/module/custom/hook.js +51 -44
- package/lib/table/module/custom/panel.js +790 -540
- package/lib/table/module/edit/hook.js +142 -64
- package/lib/table/module/export/export-panel.js +406 -323
- package/lib/table/module/export/hook.js +419 -361
- package/lib/table/module/export/import-panel.js +157 -128
- package/lib/table/module/filter/hook.js +18 -4
- package/lib/table/module/filter/panel.js +149 -87
- package/lib/table/module/keyboard/hook.js +10 -6
- package/lib/table/module/menu/hook.js +2 -2
- package/lib/table/module/menu/panel.js +199 -128
- package/lib/table/module/validator/hook.js +2 -2
- package/lib/table/render/index.js +153 -100
- package/lib/table/src/body.js +357 -235
- package/lib/table/src/cell.js +428 -271
- package/lib/table/src/columnInfo.js +3 -2
- package/lib/table/src/footer.js +146 -101
- package/lib/table/src/group.js +7 -3
- package/lib/table/src/header.js +231 -174
- package/lib/table/src/props.js +2 -2
- package/lib/table/src/table.js +1487 -1045
- package/lib/table/src/util.js +15 -19
- package/lib/toolbar/index.js +4 -4
- package/lib/toolbar/src/toolbar.js +135 -78
- package/lib/ui/index.js +1 -3
- package/lib/ui/src/dom.js +9 -6
- package/lib/ui/src/log.js +1 -1
- package/lib/v-x-e-table/index.js +0 -2
- package/package.json +8 -3
- package/packages/colgroup/index.ts +22 -22
- package/packages/column/index.ts +22 -22
- package/packages/components.ts +41 -43
- package/packages/grid/index.ts +18 -18
- package/packages/grid/src/emits.ts +5 -19
- package/packages/grid/src/grid.ts +2229 -1925
- package/packages/grid/src/props.ts +22 -23
- package/packages/index.ts +11 -4
- package/packages/locale/lang/fr-FR.ts +15 -15
- package/packages/locale/lang/it-IT.ts +4 -4
- package/packages/locale/lang/uk-UA.ts +1 -1
- package/packages/locale/lang/uz-UZ.ts +13 -13
- package/packages/locale/lang/zh-CN.ts +907 -907
- package/packages/table/index.ts +26 -26
- package/packages/table/module/custom/hook.ts +510 -503
- package/packages/table/module/custom/panel.ts +2002 -1743
- package/packages/table/module/edit/hook.ts +1224 -1131
- package/packages/table/module/export/export-panel.ts +697 -611
- package/packages/table/module/export/hook.ts +2160 -2059
- package/packages/table/module/export/import-panel.ts +319 -279
- package/packages/table/module/export/util.ts +25 -24
- package/packages/table/module/filter/hook.ts +519 -501
- package/packages/table/module/filter/panel.ts +368 -304
- package/packages/table/module/keyboard/hook.ts +498 -494
- package/packages/table/module/menu/hook.ts +330 -330
- package/packages/table/module/menu/panel.ts +272 -201
- package/packages/table/module/validator/hook.ts +653 -635
- package/packages/table/render/index.ts +1819 -1744
- package/packages/table/src/body.ts +1078 -955
- package/packages/table/src/cell.ts +1524 -1359
- package/packages/table/src/column.ts +192 -192
- package/packages/table/src/columnInfo.ts +232 -232
- package/packages/table/src/emits.ts +134 -134
- package/packages/table/src/footer.ts +425 -380
- package/packages/table/src/group.ts +67 -63
- package/packages/table/src/header.ts +642 -581
- package/packages/table/src/props.ts +336 -336
- package/packages/table/src/store.ts +14 -14
- package/packages/table/src/table.ts +16011 -15454
- package/packages/table/src/use/cell-view.ts +41 -44
- package/packages/table/src/use/index.ts +1 -1
- package/packages/table/src/util.ts +1206 -1216
- package/packages/toolbar/index.ts +18 -18
- package/packages/toolbar/src/toolbar.ts +768 -706
- package/packages/ui/index.ts +519 -521
- package/packages/ui/src/anime.ts +51 -52
- package/packages/ui/src/comp.ts +3 -3
- package/packages/ui/src/dom.ts +466 -463
- package/packages/ui/src/log.ts +19 -19
- package/packages/ui/src/utils.ts +66 -66
- package/packages/ui/src/vn.ts +55 -55
- package/packages/v-x-e-table/index.d.ts +3 -4
- package/packages/v-x-e-table/index.ts +3 -4
- package/types/all.d.ts +76 -76
- package/types/index.d.ts +4 -4
- /package/dist/{iconfont.1792979665397.ttf → iconfont.1793009263429.ttf} +0 -0
- /package/dist/{iconfont.1792979665397.woff → iconfont.1793009263429.woff} +0 -0
- /package/dist/{iconfont.1792979665397.woff2 → iconfont.1793009263429.woff2} +0 -0
- /package/es/{iconfont.1792979665397.ttf → iconfont.1793009263429.ttf} +0 -0
- /package/es/{iconfont.1792979665397.woff → iconfont.1793009263429.woff} +0 -0
- /package/es/{iconfont.1792979665397.woff2 → iconfont.1793009263429.woff2} +0 -0
- /package/lib/{iconfont.1792979665397.ttf → iconfont.1793009263429.ttf} +0 -0
- /package/lib/{iconfont.1792979665397.woff → iconfont.1793009263429.woff} +0 -0
- /package/lib/{iconfont.1792979665397.woff2 → iconfont.1793009263429.woff2} +0 -0
|
@@ -1,581 +1,642 @@
|
|
|
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 '
|
|
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 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
|
|
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 ?
|
|
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 ?
|
|
94
|
-
const isCellPaddingBottom = cellPadding ?
|
|
95
|
-
const isCellPaddingLeft = cellPadding ?
|
|
96
|
-
const isCellPaddingRight = cellPadding ?
|
|
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 =
|
|
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
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
}
|
|
310
|
-
const
|
|
311
|
-
const
|
|
312
|
-
const
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
hasFilter
|
|
328
|
-
}
|
|
329
|
-
const
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
const {
|
|
419
|
-
|
|
420
|
-
const
|
|
421
|
-
const
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
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 '@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 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
|
+
const isPadding = XEUtils.isBoolean(headerCellOpts.padding) ? headerCellOpts.padding : cellOpts.padding
|
|
317
|
+
const headOverflow = XEUtils.eqNull(showHeaderOverflow) ? allColumnHeaderOverflow : showHeaderOverflow
|
|
318
|
+
const headAlign = headerAlign || (compConf ? compConf.tableHeaderCellAlign : '') || allHeaderAlign || align || (compConf ? compConf.tableCellAlign : '') || allAlign
|
|
319
|
+
const showEllipsis = headOverflow === 'ellipsis'
|
|
320
|
+
const showTitle = headOverflow === 'title'
|
|
321
|
+
const showTooltip = headOverflow === true ? headerTooltipOpts.mode === 'tooltip' : headOverflow === 'tooltip'
|
|
322
|
+
const hasEllipsis = showTitle || showTooltip || showEllipsis
|
|
323
|
+
let hasFilter = false
|
|
324
|
+
let firstFilterOption: VxeTableDefines.FilterOption | null = null
|
|
325
|
+
if (filters) {
|
|
326
|
+
firstFilterOption = filters[0] as VxeTableDefines.FilterOption
|
|
327
|
+
hasFilter = filters.some((item) => item.checked)
|
|
328
|
+
}
|
|
329
|
+
const columnIndex = colRest.index
|
|
330
|
+
const _columnIndex = colRest._index
|
|
331
|
+
const cellParams: VxeTableDefines.CellFloatingFilterParams & {
|
|
332
|
+
$table: VxeTableConstructor & VxeTablePrivateMethods
|
|
333
|
+
} = {
|
|
334
|
+
$table: $xeTable,
|
|
335
|
+
$grid: $xeGrid,
|
|
336
|
+
$gantt: $xeGantt,
|
|
337
|
+
column,
|
|
338
|
+
columnIndex,
|
|
339
|
+
$columnIndex,
|
|
340
|
+
_columnIndex,
|
|
341
|
+
option: firstFilterOption as VxeTableDefines.FilterOption,
|
|
342
|
+
fixed: fixedType,
|
|
343
|
+
source: sourceType,
|
|
344
|
+
type: renderType,
|
|
345
|
+
isHidden: fixedHiddenColumn,
|
|
346
|
+
hasFilter
|
|
347
|
+
}
|
|
348
|
+
const thAttrs: Record<string, string | number | null> = {
|
|
349
|
+
colid
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
const isLastColumn = $columnIndex === cols.length - 1
|
|
353
|
+
const isAutoCellWidth = !column.resizeWidth && (column.minWidth === 'auto' || column.width === 'auto')
|
|
354
|
+
|
|
355
|
+
const tcStyle: Record<string, string> = {}
|
|
356
|
+
if (hasEllipsis) {
|
|
357
|
+
tcStyle.height = `${currCellHeight}px`
|
|
358
|
+
} else {
|
|
359
|
+
tcStyle.minHeight = `${currCellHeight}px`
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
return h(
|
|
363
|
+
'th',
|
|
364
|
+
{
|
|
365
|
+
class: [
|
|
366
|
+
'vxe-table--column vxe-header--column is--floating-filters',
|
|
367
|
+
colid,
|
|
368
|
+
fixedHiddenColumn ? 'fixed--hidden' : 'fixed--visible',
|
|
369
|
+
{
|
|
370
|
+
[`col--${headAlign}`]: headAlign,
|
|
371
|
+
[`col--${type}`]: type,
|
|
372
|
+
'col--last': isLastColumn,
|
|
373
|
+
'col--fixed': column.fixed,
|
|
374
|
+
'col--ellipsis': hasEllipsis,
|
|
375
|
+
'fixed--width': !isAutoCellWidth,
|
|
376
|
+
'is--padding': isPadding,
|
|
377
|
+
'is--sortable': column.sortable,
|
|
378
|
+
'col--current': currColFlag && currentCol === column
|
|
379
|
+
}
|
|
380
|
+
],
|
|
381
|
+
key: colid,
|
|
382
|
+
...thAttrs
|
|
383
|
+
},
|
|
384
|
+
[
|
|
385
|
+
h(
|
|
386
|
+
'div',
|
|
387
|
+
{
|
|
388
|
+
class: [
|
|
389
|
+
'vxe-cell',
|
|
390
|
+
'' + (cellClassName || ''),
|
|
391
|
+
{
|
|
392
|
+
'c--title': showTitle,
|
|
393
|
+
'c--tooltip': showTooltip,
|
|
394
|
+
'c--ellipsis': showEllipsis
|
|
395
|
+
}
|
|
396
|
+
],
|
|
397
|
+
style: tcStyle
|
|
398
|
+
},
|
|
399
|
+
isOptimizeMode && fixedHiddenColumn && !floatingFilters
|
|
400
|
+
? []
|
|
401
|
+
: [
|
|
402
|
+
h(
|
|
403
|
+
'div',
|
|
404
|
+
{
|
|
405
|
+
colid,
|
|
406
|
+
class: 'vxe-cell--wrapper vxe-header-cell--wrapper'
|
|
407
|
+
},
|
|
408
|
+
flSlot ? $xeTable.callSlot(flSlot, cellParams) : rtFloatingFilter && firstFilterOption ? getSlotVNs(rtFloatingFilter(filterRender, cellParams as unknown as VxeGlobalRendererHandles.RenderTableFloatingFilterParams)) : []
|
|
409
|
+
)
|
|
410
|
+
]
|
|
411
|
+
)
|
|
412
|
+
]
|
|
413
|
+
)
|
|
414
|
+
})
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
const renderHeads = (isGroup: boolean, isOptimizeMode: boolean, headerGroups: VxeTableDefines.ColumnInfo[][], renderColumnList: VxeTableDefines.ColumnInfo[]) => {
|
|
418
|
+
const { fixedType } = props
|
|
419
|
+
|
|
420
|
+
const { headerRowClassName, headerRowStyle } = tableProps
|
|
421
|
+
const floatingFilterOpts = computeFloatingFilterOpts.value
|
|
422
|
+
const rowVNs = headerGroups.map((cols, _rowIndex) => {
|
|
423
|
+
const params = { $table: $xeTable, rowIndex: _rowIndex, _rowIndex, $rowIndex: _rowIndex, fixed: fixedType, type: renderType }
|
|
424
|
+
return h(
|
|
425
|
+
'tr',
|
|
426
|
+
{
|
|
427
|
+
key: _rowIndex,
|
|
428
|
+
class: ['vxe-header--row', headerRowClassName ? (XEUtils.isFunction(headerRowClassName) ? headerRowClassName(params) : headerRowClassName) : ''],
|
|
429
|
+
style: headerRowStyle ? (XEUtils.isFunction(headerRowStyle) ? headerRowStyle(params) : headerRowStyle) : null
|
|
430
|
+
},
|
|
431
|
+
renderRows(isGroup, isOptimizeMode, headerGroups, _rowIndex, cols)
|
|
432
|
+
)
|
|
433
|
+
})
|
|
434
|
+
|
|
435
|
+
if (floatingFilterOpts.enabled) {
|
|
436
|
+
rowVNs.push(
|
|
437
|
+
h(
|
|
438
|
+
'tr',
|
|
439
|
+
{
|
|
440
|
+
key: 'ff',
|
|
441
|
+
class: ['vxe-header--row is--floating-filters', '' + (floatingFilterOpts.rowClassName || '')]
|
|
442
|
+
},
|
|
443
|
+
renderFilterRows(isOptimizeMode, renderColumnList)
|
|
444
|
+
)
|
|
445
|
+
)
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
return rowVNs
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
const renderVN = () => {
|
|
452
|
+
const { fixedType, fixedColumn, tableColumn } = props
|
|
453
|
+
const { mouseConfig } = tableProps
|
|
454
|
+
const { isGroup, isColLoading, overflowX, scrollXLoad, dragCol } = tableReactData
|
|
455
|
+
const { visibleColumn, fullColumnIdData } = tableInternalData
|
|
456
|
+
|
|
457
|
+
const mouseOpts = computeMouseOpts.value
|
|
458
|
+
const isHeaderRenderOptimize = computeIsHeaderRenderOptimize.value
|
|
459
|
+
let renderHeaderList = headerColumn.value || []
|
|
460
|
+
let renderColumnList = tableColumn as VxeTableDefines.ColumnInfo[]
|
|
461
|
+
const isOptimizeMode = isHeaderRenderOptimize
|
|
462
|
+
|
|
463
|
+
if (isGroup) {
|
|
464
|
+
renderColumnList = visibleColumn
|
|
465
|
+
} else {
|
|
466
|
+
if (!isOptimizeMode || (!isColLoading && (fixedType || !overflowX))) {
|
|
467
|
+
renderColumnList = visibleColumn
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
if (fixedType) {
|
|
471
|
+
// 如果是使用优化模式
|
|
472
|
+
if (isOptimizeMode) {
|
|
473
|
+
renderColumnList = fixedColumn || []
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
renderHeaderList = [renderColumnList]
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
if (!fixedType && !isGroup) {
|
|
480
|
+
// 列拖拽
|
|
481
|
+
if (scrollXLoad && dragCol) {
|
|
482
|
+
if (renderColumnList.length > 2) {
|
|
483
|
+
const dCowRest = fullColumnIdData[dragCol.id]
|
|
484
|
+
if (dCowRest) {
|
|
485
|
+
const dcIndex = dCowRest._index
|
|
486
|
+
const firstCol = renderColumnList[0]
|
|
487
|
+
const lastCol = renderColumnList[renderColumnList.length - 1]
|
|
488
|
+
const firstColRest = fullColumnIdData[firstCol.id]
|
|
489
|
+
const lastColRest = fullColumnIdData[lastCol.id]
|
|
490
|
+
if (firstColRest && lastColRest) {
|
|
491
|
+
const fcIndex = firstColRest._index
|
|
492
|
+
const lcIndex = lastColRest._index
|
|
493
|
+
if (dcIndex < fcIndex) {
|
|
494
|
+
renderColumnList = [dragCol].concat(renderColumnList)
|
|
495
|
+
renderHeaderList = [[dragCol].concat(renderHeaderList[0])].concat(renderHeaderList.slice(1))
|
|
496
|
+
} else if (dcIndex > lcIndex) {
|
|
497
|
+
renderColumnList = renderColumnList.concat([dragCol])
|
|
498
|
+
renderHeaderList = [renderHeaderList[0].concat([dragCol])].concat(renderHeaderList.slice(1))
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
return h(
|
|
507
|
+
'div',
|
|
508
|
+
{
|
|
509
|
+
ref: refElem,
|
|
510
|
+
class: ['vxe-table--header-wrapper', fixedType ? `fixed-${fixedType}--wrapper` : 'body--wrapper'],
|
|
511
|
+
xid: xID
|
|
512
|
+
},
|
|
513
|
+
[
|
|
514
|
+
h(
|
|
515
|
+
'div',
|
|
516
|
+
{
|
|
517
|
+
ref: refHeaderScroll,
|
|
518
|
+
class: 'vxe-table--header-inner-wrapper',
|
|
519
|
+
onScroll(evnt) {
|
|
520
|
+
$xeTable.triggerHeaderScrollEvent(evnt, fixedType)
|
|
521
|
+
}
|
|
522
|
+
},
|
|
523
|
+
[
|
|
524
|
+
fixedType
|
|
525
|
+
? renderEmptyElement($xeTable)
|
|
526
|
+
: h('div', {
|
|
527
|
+
ref: refHeaderXSpace,
|
|
528
|
+
class: 'vxe-body--x-space'
|
|
529
|
+
}),
|
|
530
|
+
h(
|
|
531
|
+
'table',
|
|
532
|
+
{
|
|
533
|
+
ref: refHeaderTable,
|
|
534
|
+
class: 'vxe-table--header',
|
|
535
|
+
xid: xID,
|
|
536
|
+
cellspacing: 0,
|
|
537
|
+
cellpadding: 0,
|
|
538
|
+
border: 0,
|
|
539
|
+
xvm: isOptimizeMode ? '1' : null
|
|
540
|
+
},
|
|
541
|
+
[
|
|
542
|
+
/**
|
|
543
|
+
* 列宽
|
|
544
|
+
*/
|
|
545
|
+
h(
|
|
546
|
+
'colgroup',
|
|
547
|
+
{
|
|
548
|
+
ref: refHeaderColgroup
|
|
549
|
+
},
|
|
550
|
+
renderColumnList.map((column, $columnIndex) => {
|
|
551
|
+
return h('col', {
|
|
552
|
+
name: column.id,
|
|
553
|
+
key: $columnIndex,
|
|
554
|
+
style: {
|
|
555
|
+
width: `${column.renderWidth}px`
|
|
556
|
+
}
|
|
557
|
+
})
|
|
558
|
+
})
|
|
559
|
+
),
|
|
560
|
+
/**
|
|
561
|
+
* 头部
|
|
562
|
+
*/
|
|
563
|
+
h(
|
|
564
|
+
'thead',
|
|
565
|
+
{
|
|
566
|
+
ref: refHeaderTHead
|
|
567
|
+
},
|
|
568
|
+
renderHeads(isGroup, isOptimizeMode, renderHeaderList, renderColumnList)
|
|
569
|
+
)
|
|
570
|
+
]
|
|
571
|
+
),
|
|
572
|
+
hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area
|
|
573
|
+
? h(
|
|
574
|
+
'div',
|
|
575
|
+
{
|
|
576
|
+
class: 'vxe-table--cell-area',
|
|
577
|
+
xid: xID
|
|
578
|
+
},
|
|
579
|
+
[
|
|
580
|
+
h('span', {
|
|
581
|
+
class: 'vxe-table--cell-main-area'
|
|
582
|
+
}),
|
|
583
|
+
h('span', {
|
|
584
|
+
class: 'vxe-table--cell-clip-area'
|
|
585
|
+
}),
|
|
586
|
+
h('span', {
|
|
587
|
+
class: 'vxe-table--cell-extend-area'
|
|
588
|
+
}),
|
|
589
|
+
h('span', {
|
|
590
|
+
class: 'vxe-table--cell-multi-area'
|
|
591
|
+
}),
|
|
592
|
+
h('span', {
|
|
593
|
+
class: 'vxe-table--cell-active-area'
|
|
594
|
+
}),
|
|
595
|
+
h('span', {
|
|
596
|
+
class: 'vxe-table--cell-col-status-area'
|
|
597
|
+
})
|
|
598
|
+
]
|
|
599
|
+
)
|
|
600
|
+
: renderEmptyElement($xeTable)
|
|
601
|
+
]
|
|
602
|
+
)
|
|
603
|
+
]
|
|
604
|
+
)
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
watch(() => props.tableColumn, uploadColumn)
|
|
608
|
+
|
|
609
|
+
onMounted(() => {
|
|
610
|
+
nextTick(() => {
|
|
611
|
+
const { fixedType } = props
|
|
612
|
+
const { internalData } = $xeTable
|
|
613
|
+
const { elemStore } = internalData
|
|
614
|
+
const prefix = `${fixedType || 'main'}-header-`
|
|
615
|
+
elemStore[`${prefix}wrapper`] = refElem
|
|
616
|
+
elemStore[`${prefix}scroll`] = refHeaderScroll
|
|
617
|
+
elemStore[`${prefix}table`] = refHeaderTable
|
|
618
|
+
elemStore[`${prefix}colgroup`] = refHeaderColgroup
|
|
619
|
+
elemStore[`${prefix}list`] = refHeaderTHead
|
|
620
|
+
elemStore[`${prefix}xSpace`] = refHeaderXSpace
|
|
621
|
+
elemStore[`${prefix}repair`] = refHeaderBorderRepair
|
|
622
|
+
uploadColumn()
|
|
623
|
+
})
|
|
624
|
+
})
|
|
625
|
+
|
|
626
|
+
onUnmounted(() => {
|
|
627
|
+
const { fixedType } = props
|
|
628
|
+
const { internalData } = $xeTable
|
|
629
|
+
const { elemStore } = internalData
|
|
630
|
+
const prefix = `${fixedType || 'main'}-header-`
|
|
631
|
+
elemStore[`${prefix}wrapper`] = null
|
|
632
|
+
elemStore[`${prefix}scroll`] = null
|
|
633
|
+
elemStore[`${prefix}table`] = null
|
|
634
|
+
elemStore[`${prefix}colgroup`] = null
|
|
635
|
+
elemStore[`${prefix}list`] = null
|
|
636
|
+
elemStore[`${prefix}xSpace`] = null
|
|
637
|
+
elemStore[`${prefix}repair`] = null
|
|
638
|
+
})
|
|
639
|
+
|
|
640
|
+
return renderVN
|
|
641
|
+
}
|
|
642
|
+
})
|