vxe-table 4.16.1 → 4.16.3
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/es/grid/src/grid.js +6 -2
- package/es/index.css +1 -1
- package/es/index.min.css +1 -1
- package/es/style.css +1 -1
- package/es/style.min.css +1 -1
- package/es/table/module/menu/hook.js +4 -2
- package/es/table/src/body.js +12 -14
- package/es/table/src/column.js +2 -0
- package/es/table/src/columnInfo.js +1 -0
- package/es/table/src/emits.js +3 -0
- package/es/table/src/header.js +47 -16
- package/es/table/src/props.js +11 -3
- package/es/table/src/table.js +257 -51
- package/es/table/src/util.js +70 -2
- package/es/table/style.css +11 -21
- package/es/table/style.min.css +1 -1
- package/es/ui/index.js +2 -2
- package/es/ui/src/log.js +1 -1
- package/es/vxe-table/style.css +11 -21
- package/es/vxe-table/style.min.css +1 -1
- package/lib/grid/src/grid.js +7 -1
- package/lib/grid/src/grid.min.js +1 -1
- package/lib/index.css +1 -1
- package/lib/index.min.css +1 -1
- package/lib/index.umd.js +204 -51
- package/lib/index.umd.min.js +1 -1
- package/lib/style.css +1 -1
- package/lib/style.min.css +1 -1
- package/lib/table/module/menu/hook.js +6 -0
- package/lib/table/module/menu/hook.min.js +1 -1
- package/lib/table/src/body.js +11 -13
- package/lib/table/src/body.min.js +1 -1
- package/lib/table/src/column.js +2 -0
- package/lib/table/src/column.min.js +1 -1
- package/lib/table/src/columnInfo.js +1 -0
- package/lib/table/src/columnInfo.min.js +1 -1
- package/lib/table/src/emits.js +1 -1
- package/lib/table/src/emits.min.js +1 -1
- package/lib/table/src/header.js +62 -13
- package/lib/table/src/header.min.js +1 -1
- package/lib/table/src/props.js +11 -3
- package/lib/table/src/props.min.js +1 -1
- package/lib/table/src/table.js +24 -13
- package/lib/table/src/table.min.js +1 -1
- package/lib/table/src/util.js +74 -2
- package/lib/table/src/util.min.js +1 -1
- package/lib/table/style/style.css +11 -21
- package/lib/table/style/style.min.css +1 -1
- package/lib/ui/index.js +2 -2
- package/lib/ui/index.min.js +1 -1
- package/lib/ui/src/log.js +1 -1
- package/lib/ui/src/log.min.js +1 -1
- package/lib/vxe-table/style/style.css +11 -21
- package/lib/vxe-table/style/style.min.css +1 -1
- package/package.json +2 -2
- package/packages/grid/src/grid.ts +6 -2
- package/packages/table/module/menu/hook.ts +5 -2
- package/packages/table/src/body.ts +11 -13
- package/packages/table/src/column.ts +2 -0
- package/packages/table/src/columnInfo.ts +1 -0
- package/packages/table/src/emits.ts +4 -0
- package/packages/table/src/header.ts +49 -17
- package/packages/table/src/props.ts +11 -3
- package/packages/table/src/table.ts +258 -50
- package/packages/table/src/util.ts +76 -2
- package/packages/ui/index.ts +1 -1
- package/styles/components/table.scss +33 -56
- /package/es/{iconfont.1756272578850.ttf → iconfont.1756629730733.ttf} +0 -0
- /package/es/{iconfont.1756272578850.woff → iconfont.1756629730733.woff} +0 -0
- /package/es/{iconfont.1756272578850.woff2 → iconfont.1756629730733.woff2} +0 -0
- /package/lib/{iconfont.1756272578850.ttf → iconfont.1756629730733.ttf} +0 -0
- /package/lib/{iconfont.1756272578850.woff → iconfont.1756629730733.woff} +0 -0
- /package/lib/{iconfont.1756272578850.woff2 → iconfont.1756629730733.woff2} +0 -0
|
@@ -148,6 +148,9 @@ hooks.add('tableMenuModule', {
|
|
|
148
148
|
* 快捷菜单事件处理
|
|
149
149
|
*/
|
|
150
150
|
handleGlobalContextmenuEvent (evnt) {
|
|
151
|
+
const $xeGrid = $xeTable.xeGrid
|
|
152
|
+
const $xeGantt = $xeTable.xeGantt
|
|
153
|
+
|
|
151
154
|
const { mouseConfig, menuConfig } = props
|
|
152
155
|
const { editStore, ctxMenuStore } = reactData
|
|
153
156
|
const { visibleColumn } = internalData
|
|
@@ -165,7 +168,7 @@ hooks.add('tableMenuModule', {
|
|
|
165
168
|
}
|
|
166
169
|
if (internalData._keyCtx) {
|
|
167
170
|
const type = 'body'
|
|
168
|
-
const params: any = { type, $table: $xeTable, keyboard: true, columns: visibleColumn.slice(0), $event: evnt }
|
|
171
|
+
const params: any = { type, $table: $xeTable, $grid: $xeGrid, $gantt: $xeGantt, keyboard: true, columns: visibleColumn.slice(0), $event: evnt }
|
|
169
172
|
// 如果开启单元格区域
|
|
170
173
|
if (mouseConfig && mouseOpts.area) {
|
|
171
174
|
const activeArea = $xeTable.getActiveCellArea()
|
|
@@ -192,7 +195,7 @@ hooks.add('tableMenuModule', {
|
|
|
192
195
|
// target=td|th,直接向上找 table 去匹配即可
|
|
193
196
|
return target.parentNode.parentNode.parentNode.getAttribute('xid') === xID
|
|
194
197
|
})
|
|
195
|
-
const params: any = { type: layout, $table: $xeTable, columns: visibleColumn.slice(0), $event: evnt }
|
|
198
|
+
const params: any = { type: layout, $table: $xeTable, $grid: $xeGrid, $gantt: $xeGantt, columns: visibleColumn.slice(0), $event: evnt }
|
|
196
199
|
if (columnTargetNode.flag) {
|
|
197
200
|
const cell = columnTargetNode.targetElem
|
|
198
201
|
const columnNodeRest = $xeTable.getColumnNode(cell)
|
|
@@ -194,14 +194,13 @@ export default defineVxeComponent({
|
|
|
194
194
|
// hover 进入事件
|
|
195
195
|
if (showTitle || showTooltip || showAllTip || tooltipConfig) {
|
|
196
196
|
tdOns.onMouseenter = (evnt: MouseEvent) => {
|
|
197
|
-
if (isVMScrollProcess()) {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
$xeTable.triggerBodyTooltipEvent(evnt, cellParams)
|
|
197
|
+
if (!isVMScrollProcess()) {
|
|
198
|
+
if (showTitle) {
|
|
199
|
+
updateCellTitle(evnt.currentTarget, column)
|
|
200
|
+
} else if (showTooltip || showAllTip) {
|
|
201
|
+
// 如果配置了显示 tooltip
|
|
202
|
+
$xeTable.triggerBodyTooltipEvent(evnt, cellParams)
|
|
203
|
+
}
|
|
205
204
|
}
|
|
206
205
|
$xeTable.dispatchEvent('cell-mouseenter', Object.assign({ cell: evnt.currentTarget }, cellParams), evnt)
|
|
207
206
|
}
|
|
@@ -209,11 +208,10 @@ export default defineVxeComponent({
|
|
|
209
208
|
// hover 退出事件
|
|
210
209
|
if (showTooltip || showAllTip || tooltipConfig) {
|
|
211
210
|
tdOns.onMouseleave = (evnt: MouseEvent) => {
|
|
212
|
-
if (isVMScrollProcess()) {
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
$xeTable.handleTargetLeaveEvent(evnt)
|
|
211
|
+
if (!isVMScrollProcess()) {
|
|
212
|
+
if (showTooltip || showAllTip) {
|
|
213
|
+
$xeTable.handleTargetLeaveEvent(evnt)
|
|
214
|
+
}
|
|
217
215
|
}
|
|
218
216
|
$xeTable.dispatchEvent('cell-mouseleave', Object.assign({ cell: evnt.currentTarget }, cellParams), evnt)
|
|
219
217
|
}
|
|
@@ -56,6 +56,8 @@ export const columnProps = {
|
|
|
56
56
|
footerClassName: [String, Function] as PropType<VxeColumnPropTypes.FooterClassName>,
|
|
57
57
|
// 格式化显示内容
|
|
58
58
|
formatter: [Function, Array, String] as PropType<VxeColumnPropTypes.Formatter<any>>,
|
|
59
|
+
// 格式化表头显示内容
|
|
60
|
+
headerFormatter: [Function, Array, String] as PropType<VxeColumnPropTypes.HeaderFormatter>,
|
|
59
61
|
// 格式化表尾显示内容
|
|
60
62
|
footerFormatter: [Function, Array, String] as PropType<VxeColumnPropTypes.FooterFormatter>,
|
|
61
63
|
// 是否显示间距
|
|
@@ -87,6 +87,7 @@ export class ColumnInfo {
|
|
|
87
87
|
headerClassName: _vm.headerClassName,
|
|
88
88
|
footerClassName: _vm.footerClassName,
|
|
89
89
|
formatter: formatter,
|
|
90
|
+
headerFormatter: _vm.headerFormatter,
|
|
90
91
|
footerFormatter: _vm.footerFormatter,
|
|
91
92
|
padding: _vm.padding,
|
|
92
93
|
verticalAlign: _vm.verticalAlign,
|
|
@@ -2,7 +2,7 @@ import { h, ref, Ref, PropType, inject, nextTick, watch, onMounted, onUnmounted
|
|
|
2
2
|
import { defineVxeComponent } from '../../ui/src/comp'
|
|
3
3
|
import XEUtils from 'xe-utils'
|
|
4
4
|
import { VxeUI } from '../../ui'
|
|
5
|
-
import { getCalcHeight, convertHeaderColumnToRows } from './util'
|
|
5
|
+
import { getCalcHeight, convertHeaderColumnToRows, convertHeaderToGridRows } from './util'
|
|
6
6
|
|
|
7
7
|
import type { VxeTablePrivateMethods, VxeTableConstructor, VxeTableMethods, VxeTableDefines, VxeColumnPropTypes } from '../../../types'
|
|
8
8
|
|
|
@@ -28,7 +28,7 @@ export default defineVxeComponent({
|
|
|
28
28
|
const { xID, props: tableProps, reactData: tableReactData, internalData: tableInternalData } = $xeTable
|
|
29
29
|
const { computeColumnOpts, computeColumnDragOpts, computeCellOpts, computeMouseOpts, computeHeaderCellOpts, computeDefaultRowHeight, computeVirtualXOpts } = $xeTable.getComputeMaps()
|
|
30
30
|
|
|
31
|
-
const headerColumn = ref
|
|
31
|
+
const headerColumn = ref<VxeTableDefines.ColumnInfo[][]>([])
|
|
32
32
|
|
|
33
33
|
const refElem = ref() as Ref<HTMLDivElement>
|
|
34
34
|
const refHeaderScroll = ref() as Ref<HTMLDivElement>
|
|
@@ -39,18 +39,28 @@ export default defineVxeComponent({
|
|
|
39
39
|
const refHeaderBorderRepair = ref() as Ref<HTMLDivElement>
|
|
40
40
|
|
|
41
41
|
const uploadColumn = () => {
|
|
42
|
+
const { showCustomHeader } = tableProps
|
|
43
|
+
const { collectColumn, visibleColumn } = tableInternalData
|
|
44
|
+
const { tableGroupColumn } = props
|
|
42
45
|
const { isGroup } = tableReactData
|
|
43
|
-
|
|
46
|
+
let spanColumns: VxeTableDefines.ColumnInfo[][] = isGroup ? convertHeaderColumnToRows(tableGroupColumn) : []
|
|
47
|
+
let visibleColgroups: VxeTableDefines.ColumnInfo[][] = []
|
|
48
|
+
if (showCustomHeader && spanColumns.length > 1) {
|
|
49
|
+
visibleColgroups = convertHeaderToGridRows(spanColumns)
|
|
50
|
+
spanColumns = visibleColgroups
|
|
51
|
+
}
|
|
52
|
+
headerColumn.value = spanColumns
|
|
53
|
+
$xeTable.dispatchEvent('columns-change', { visibleColgroups, collectColumn, visibleColumn }, null)
|
|
44
54
|
}
|
|
45
55
|
|
|
46
|
-
const renderRows = (isGroup: boolean, isOptimizeMode: boolean,
|
|
56
|
+
const renderRows = (isGroup: boolean, isOptimizeMode: boolean, headerGroups: VxeTableDefines.ColumnInfo[][], $rowIndex: number, cols: VxeTableDefines.ColumnInfo[]) => {
|
|
47
57
|
const $xeGrid = $xeTable.xeGrid
|
|
48
58
|
const $xeGantt = $xeTable.xeGantt
|
|
49
59
|
|
|
50
60
|
const { fixedType } = props
|
|
51
|
-
const { resizable: allResizable, columnKey, headerCellClassName, headerCellStyle, showHeaderOverflow: allColumnHeaderOverflow, headerAlign: allHeaderAlign, align: allAlign, mouseConfig } = tableProps
|
|
52
|
-
const { currentColumn, dragCol, scrollXLoad, scrollYLoad, overflowX, tableColumn } = tableReactData
|
|
53
|
-
const { fullColumnIdData, scrollXStore } = tableInternalData
|
|
61
|
+
const { resizable: allResizable, columnKey, showCustomHeader, headerCellClassName, headerCellStyle, showHeaderOverflow: allColumnHeaderOverflow, headerAlign: allHeaderAlign, align: allAlign, mouseConfig } = tableProps
|
|
62
|
+
const { currentColumn, dragCol, scrollXLoad, scrollYLoad, overflowX, mergeHeadFlag, tableColumn } = tableReactData
|
|
63
|
+
const { fullColumnIdData, scrollXStore, mergeHeaderList, mergeHeaderCellMaps } = tableInternalData
|
|
54
64
|
const virtualXOpts = computeVirtualXOpts.value
|
|
55
65
|
const columnOpts = computeColumnOpts.value
|
|
56
66
|
const columnDragOpts = computeColumnDragOpts.value
|
|
@@ -59,6 +69,7 @@ export default defineVxeComponent({
|
|
|
59
69
|
const headerCellOpts = computeHeaderCellOpts.value
|
|
60
70
|
const currCellHeight = getCalcHeight(headerCellOpts.height) || defaultRowHeight
|
|
61
71
|
const { disabledMethod: dragDisabledMethod, isCrossDrag, isPeerDrag } = columnDragOpts
|
|
72
|
+
const isLastRow = $rowIndex === headerGroups.length - 1
|
|
62
73
|
|
|
63
74
|
return cols.map((column, $columnIndex) => {
|
|
64
75
|
const { type, showHeaderOverflow, headerAlign, align, filters, headerClassName, editRender, cellRender } = column
|
|
@@ -101,10 +112,32 @@ export default defineVxeComponent({
|
|
|
101
112
|
hasFilter
|
|
102
113
|
}
|
|
103
114
|
const thAttrs: Record<string, string | number | null> = {
|
|
104
|
-
colid
|
|
105
|
-
|
|
106
|
-
|
|
115
|
+
colid
|
|
116
|
+
}
|
|
117
|
+
let isMergeCell = false
|
|
118
|
+
// 合并行或列
|
|
119
|
+
if (!showCustomHeader) {
|
|
120
|
+
thAttrs.colspan = column.colSpan > 1 ? column.colSpan : null
|
|
121
|
+
thAttrs.rowspan = column.rowSpan > 1 ? column.rowSpan : null
|
|
122
|
+
}
|
|
123
|
+
if (mergeHeadFlag && mergeHeaderList.length && (showCustomHeader || isLastRow)) {
|
|
124
|
+
const spanRest = mergeHeaderCellMaps[`${$rowIndex}:${showCustomHeader ? $columnIndex : _columnIndex}`]
|
|
125
|
+
if (spanRest) {
|
|
126
|
+
const { rowspan, colspan } = spanRest
|
|
127
|
+
if (!rowspan || !colspan) {
|
|
128
|
+
return null
|
|
129
|
+
}
|
|
130
|
+
if (rowspan > 1) {
|
|
131
|
+
isMergeCell = true
|
|
132
|
+
thAttrs.rowspan = rowspan
|
|
133
|
+
}
|
|
134
|
+
if (colspan > 1) {
|
|
135
|
+
isMergeCell = true
|
|
136
|
+
thAttrs.colspan = colspan
|
|
137
|
+
}
|
|
138
|
+
}
|
|
107
139
|
}
|
|
140
|
+
|
|
108
141
|
const thOns: any = {
|
|
109
142
|
onClick: (evnt: MouseEvent) => $xeTable.triggerHeaderCellClickEvent(evnt, cellParams),
|
|
110
143
|
onDblclick: (evnt: MouseEvent) => $xeTable.triggerHeaderCellDblclickEvent(evnt, cellParams)
|
|
@@ -132,7 +165,7 @@ export default defineVxeComponent({
|
|
|
132
165
|
const isAutoCellWidth = !column.resizeWidth && (column.minWidth === 'auto' || column.width === 'auto')
|
|
133
166
|
|
|
134
167
|
let isVNPreEmptyStatus = false
|
|
135
|
-
if (isOptimizeMode && overflowX && !isGroup) {
|
|
168
|
+
if (isOptimizeMode && overflowX && !isGroup && !isMergeCell) {
|
|
136
169
|
if (!dragCol || dragCol.id !== colid) {
|
|
137
170
|
if (scrollXLoad && tableColumn.length > 10 && !column.fixed && !virtualXOpts.immediate && (_columnIndex < scrollXStore.visibleStartIndex - scrollXStore.preloadSize || _columnIndex > scrollXStore.visibleEndIndex + scrollXStore.preloadSize)) {
|
|
138
171
|
isVNPreEmptyStatus = true
|
|
@@ -148,7 +181,7 @@ export default defineVxeComponent({
|
|
|
148
181
|
}
|
|
149
182
|
|
|
150
183
|
return h('th', {
|
|
151
|
-
class: ['vxe-table--column vxe-header--column', colid, {
|
|
184
|
+
class: ['vxe-table--column vxe-header--column', colid, fixedHiddenColumn ? 'fixed--hidden' : 'fixed--visible', {
|
|
152
185
|
[`col--${headAlign}`]: headAlign,
|
|
153
186
|
[`col--${type}`]: type,
|
|
154
187
|
'col--last': isLastColumn,
|
|
@@ -156,7 +189,6 @@ export default defineVxeComponent({
|
|
|
156
189
|
'col--group': isColGroup,
|
|
157
190
|
'col--ellipsis': hasEllipsis,
|
|
158
191
|
'fixed--width': !isAutoCellWidth,
|
|
159
|
-
'fixed--hidden': fixedHiddenColumn,
|
|
160
192
|
'is--padding': isPadding,
|
|
161
193
|
'is--sortable': column.sortable,
|
|
162
194
|
'col--filter': !!filters,
|
|
@@ -171,7 +203,7 @@ export default defineVxeComponent({
|
|
|
171
203
|
style: headerCellStyle ? (XEUtils.isFunction(headerCellStyle) ? headerCellStyle(cellParams) : headerCellStyle) : null,
|
|
172
204
|
...thAttrs,
|
|
173
205
|
...thOns,
|
|
174
|
-
key: columnKey || scrollXLoad || scrollYLoad || columnOpts.useKey || columnOpts.drag || isColGroup ? colid : $columnIndex
|
|
206
|
+
key: showCustomHeader ? `${colid}${$columnIndex}` : (columnKey || scrollXLoad || scrollYLoad || columnOpts.useKey || columnOpts.drag || isColGroup ? colid : $columnIndex)
|
|
175
207
|
}, [
|
|
176
208
|
h('div', {
|
|
177
209
|
class: ['vxe-cell', {
|
|
@@ -191,7 +223,7 @@ export default defineVxeComponent({
|
|
|
191
223
|
/**
|
|
192
224
|
* 列宽拖动
|
|
193
225
|
*/
|
|
194
|
-
!fixedHiddenColumn && showResizable
|
|
226
|
+
!fixedHiddenColumn && showResizable && (!showCustomHeader || isLastRow)
|
|
195
227
|
? h('div', {
|
|
196
228
|
class: 'vxe-cell--col-resizable',
|
|
197
229
|
onMousedown: (evnt: MouseEvent) => $xeTable.handleColResizeMousedownEvent(evnt, fixedType, cellParams),
|
|
@@ -216,7 +248,7 @@ export default defineVxeComponent({
|
|
|
216
248
|
headerRowClassName ? (XEUtils.isFunction(headerRowClassName) ? headerRowClassName(params) : headerRowClassName) : ''
|
|
217
249
|
],
|
|
218
250
|
style: headerRowStyle ? (XEUtils.isFunction(headerRowStyle) ? headerRowStyle(params) : headerRowStyle) : null
|
|
219
|
-
}, renderRows(isGroup, isOptimizeMode,
|
|
251
|
+
}, renderRows(isGroup, isOptimizeMode, headerGroups, $rowIndex, cols))
|
|
220
252
|
})
|
|
221
253
|
}
|
|
222
254
|
|
|
@@ -227,7 +259,7 @@ export default defineVxeComponent({
|
|
|
227
259
|
const { visibleColumn, fullColumnIdData } = tableInternalData
|
|
228
260
|
|
|
229
261
|
const mouseOpts = computeMouseOpts.value
|
|
230
|
-
let renderHeaderList = headerColumn.value
|
|
262
|
+
let renderHeaderList = headerColumn.value || []
|
|
231
263
|
let renderColumnList = tableColumn as VxeTableDefines.ColumnInfo[]
|
|
232
264
|
let isOptimizeMode = false
|
|
233
265
|
|
|
@@ -15,7 +15,7 @@ export const tableProps = {
|
|
|
15
15
|
// 表格的最小高度
|
|
16
16
|
minHeight: {
|
|
17
17
|
type: [Number, String] as PropType<VxeTablePropTypes.MinHeight>,
|
|
18
|
-
default: () =>
|
|
18
|
+
default: () => null
|
|
19
19
|
},
|
|
20
20
|
// 表格的最大高度
|
|
21
21
|
maxHeight: [Number, String] as PropType<VxeTablePropTypes.MaxHeight>,
|
|
@@ -134,9 +134,17 @@ export const tableProps = {
|
|
|
134
134
|
headerRowStyle: [Object, Function] as PropType<VxeTablePropTypes.HeaderRowStyle>,
|
|
135
135
|
// 给表尾行附加样式
|
|
136
136
|
footerRowStyle: [Object, Function] as PropType<VxeTablePropTypes.FooterRowStyle>,
|
|
137
|
-
//
|
|
137
|
+
// 用于分组表头,显示为自定义列头,配合 mergeHeaderCells 灵活实现自定义合并
|
|
138
|
+
showCustomHeader: {
|
|
139
|
+
type: Boolean as PropType<VxeTablePropTypes.ShowCustomHeader>,
|
|
140
|
+
default: () => getConfig().table.showCustomHeader
|
|
141
|
+
},
|
|
142
|
+
// 临时合并指定的表头单元格
|
|
143
|
+
mergeHeaderCells: Array as PropType<VxeTablePropTypes.MergeHeaderCells>,
|
|
144
|
+
// 临时合并指定的单元格
|
|
138
145
|
mergeCells: Array as PropType<VxeTablePropTypes.MergeCells>,
|
|
139
|
-
//
|
|
146
|
+
// 临时合并指定的表尾单元格
|
|
147
|
+
mergeFooterCells: Array as PropType<VxeTablePropTypes.MergeFooterCells>,
|
|
140
148
|
mergeFooterItems: Array as PropType<VxeTablePropTypes.MergeFooterItems>,
|
|
141
149
|
// 自定义合并行或列的方法
|
|
142
150
|
spanMethod: Function as PropType<VxeTablePropTypes.SpanMethod>,
|