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.
Files changed (73) hide show
  1. package/es/grid/src/grid.js +6 -2
  2. package/es/index.css +1 -1
  3. package/es/index.min.css +1 -1
  4. package/es/style.css +1 -1
  5. package/es/style.min.css +1 -1
  6. package/es/table/module/menu/hook.js +4 -2
  7. package/es/table/src/body.js +12 -14
  8. package/es/table/src/column.js +2 -0
  9. package/es/table/src/columnInfo.js +1 -0
  10. package/es/table/src/emits.js +3 -0
  11. package/es/table/src/header.js +47 -16
  12. package/es/table/src/props.js +11 -3
  13. package/es/table/src/table.js +257 -51
  14. package/es/table/src/util.js +70 -2
  15. package/es/table/style.css +11 -21
  16. package/es/table/style.min.css +1 -1
  17. package/es/ui/index.js +2 -2
  18. package/es/ui/src/log.js +1 -1
  19. package/es/vxe-table/style.css +11 -21
  20. package/es/vxe-table/style.min.css +1 -1
  21. package/lib/grid/src/grid.js +7 -1
  22. package/lib/grid/src/grid.min.js +1 -1
  23. package/lib/index.css +1 -1
  24. package/lib/index.min.css +1 -1
  25. package/lib/index.umd.js +204 -51
  26. package/lib/index.umd.min.js +1 -1
  27. package/lib/style.css +1 -1
  28. package/lib/style.min.css +1 -1
  29. package/lib/table/module/menu/hook.js +6 -0
  30. package/lib/table/module/menu/hook.min.js +1 -1
  31. package/lib/table/src/body.js +11 -13
  32. package/lib/table/src/body.min.js +1 -1
  33. package/lib/table/src/column.js +2 -0
  34. package/lib/table/src/column.min.js +1 -1
  35. package/lib/table/src/columnInfo.js +1 -0
  36. package/lib/table/src/columnInfo.min.js +1 -1
  37. package/lib/table/src/emits.js +1 -1
  38. package/lib/table/src/emits.min.js +1 -1
  39. package/lib/table/src/header.js +62 -13
  40. package/lib/table/src/header.min.js +1 -1
  41. package/lib/table/src/props.js +11 -3
  42. package/lib/table/src/props.min.js +1 -1
  43. package/lib/table/src/table.js +24 -13
  44. package/lib/table/src/table.min.js +1 -1
  45. package/lib/table/src/util.js +74 -2
  46. package/lib/table/src/util.min.js +1 -1
  47. package/lib/table/style/style.css +11 -21
  48. package/lib/table/style/style.min.css +1 -1
  49. package/lib/ui/index.js +2 -2
  50. package/lib/ui/index.min.js +1 -1
  51. package/lib/ui/src/log.js +1 -1
  52. package/lib/ui/src/log.min.js +1 -1
  53. package/lib/vxe-table/style/style.css +11 -21
  54. package/lib/vxe-table/style/style.min.css +1 -1
  55. package/package.json +2 -2
  56. package/packages/grid/src/grid.ts +6 -2
  57. package/packages/table/module/menu/hook.ts +5 -2
  58. package/packages/table/src/body.ts +11 -13
  59. package/packages/table/src/column.ts +2 -0
  60. package/packages/table/src/columnInfo.ts +1 -0
  61. package/packages/table/src/emits.ts +4 -0
  62. package/packages/table/src/header.ts +49 -17
  63. package/packages/table/src/props.ts +11 -3
  64. package/packages/table/src/table.ts +258 -50
  65. package/packages/table/src/util.ts +76 -2
  66. package/packages/ui/index.ts +1 -1
  67. package/styles/components/table.scss +33 -56
  68. /package/es/{iconfont.1756272578850.ttf → iconfont.1756629730733.ttf} +0 -0
  69. /package/es/{iconfont.1756272578850.woff → iconfont.1756629730733.woff} +0 -0
  70. /package/es/{iconfont.1756272578850.woff2 → iconfont.1756629730733.woff2} +0 -0
  71. /package/lib/{iconfont.1756272578850.ttf → iconfont.1756629730733.ttf} +0 -0
  72. /package/lib/{iconfont.1756272578850.woff → iconfont.1756629730733.woff} +0 -0
  73. /package/lib/{iconfont.1756272578850.woff2 → iconfont.1756629730733.woff2} +0 -0
@@ -146,6 +146,8 @@ hooks.add('tableMenuModule', {
146
146
  * 快捷菜单事件处理
147
147
  */
148
148
  handleGlobalContextmenuEvent(evnt) {
149
+ const $xeGrid = $xeTable.xeGrid;
150
+ const $xeGantt = $xeTable.xeGantt;
149
151
  const { mouseConfig, menuConfig } = props;
150
152
  const { editStore, ctxMenuStore } = reactData;
151
153
  const { visibleColumn } = internalData;
@@ -163,7 +165,7 @@ hooks.add('tableMenuModule', {
163
165
  }
164
166
  if (internalData._keyCtx) {
165
167
  const type = 'body';
166
- const params = { type, $table: $xeTable, keyboard: true, columns: visibleColumn.slice(0), $event: evnt };
168
+ const params = { type, $table: $xeTable, $grid: $xeGrid, $gantt: $xeGantt, keyboard: true, columns: visibleColumn.slice(0), $event: evnt };
167
169
  // 如果开启单元格区域
168
170
  if (mouseConfig && mouseOpts.area) {
169
171
  const activeArea = $xeTable.getActiveCellArea();
@@ -191,7 +193,7 @@ hooks.add('tableMenuModule', {
191
193
  // target=td|th,直接向上找 table 去匹配即可
192
194
  return target.parentNode.parentNode.parentNode.getAttribute('xid') === xID;
193
195
  });
194
- const params = { type: layout, $table: $xeTable, columns: visibleColumn.slice(0), $event: evnt };
196
+ const params = { type: layout, $table: $xeTable, $grid: $xeGrid, $gantt: $xeGantt, columns: visibleColumn.slice(0), $event: evnt };
195
197
  if (columnTargetNode.flag) {
196
198
  const cell = columnTargetNode.targetElem;
197
199
  const columnNodeRest = $xeTable.getColumnNode(cell);
@@ -167,15 +167,14 @@ export default defineVxeComponent({
167
167
  // hover 进入事件
168
168
  if (showTitle || showTooltip || showAllTip || tooltipConfig) {
169
169
  tdOns.onMouseenter = (evnt) => {
170
- if (isVMScrollProcess()) {
171
- return;
172
- }
173
- if (showTitle) {
174
- updateCellTitle(evnt.currentTarget, column);
175
- }
176
- else if (showTooltip || showAllTip) {
177
- // 如果配置了显示 tooltip
178
- $xeTable.triggerBodyTooltipEvent(evnt, cellParams);
170
+ if (!isVMScrollProcess()) {
171
+ if (showTitle) {
172
+ updateCellTitle(evnt.currentTarget, column);
173
+ }
174
+ else if (showTooltip || showAllTip) {
175
+ // 如果配置了显示 tooltip
176
+ $xeTable.triggerBodyTooltipEvent(evnt, cellParams);
177
+ }
179
178
  }
180
179
  $xeTable.dispatchEvent('cell-mouseenter', Object.assign({ cell: evnt.currentTarget }, cellParams), evnt);
181
180
  };
@@ -183,11 +182,10 @@ export default defineVxeComponent({
183
182
  // hover 退出事件
184
183
  if (showTooltip || showAllTip || tooltipConfig) {
185
184
  tdOns.onMouseleave = (evnt) => {
186
- if (isVMScrollProcess()) {
187
- return;
188
- }
189
- if (showTooltip || showAllTip) {
190
- $xeTable.handleTargetLeaveEvent(evnt);
185
+ if (!isVMScrollProcess()) {
186
+ if (showTooltip || showAllTip) {
187
+ $xeTable.handleTargetLeaveEvent(evnt);
188
+ }
191
189
  }
192
190
  $xeTable.dispatchEvent('cell-mouseleave', Object.assign({ cell: evnt.currentTarget }, cellParams), evnt);
193
191
  };
@@ -53,6 +53,8 @@ export const columnProps = {
53
53
  footerClassName: [String, Function],
54
54
  // 格式化显示内容
55
55
  formatter: [Function, Array, String],
56
+ // 格式化表头显示内容
57
+ headerFormatter: [Function, Array, String],
56
58
  // 格式化表尾显示内容
57
59
  footerFormatter: [Function, Array, String],
58
60
  // 是否显示间距
@@ -80,6 +80,7 @@ export class ColumnInfo {
80
80
  headerClassName: _vm.headerClassName,
81
81
  footerClassName: _vm.footerClassName,
82
82
  formatter: formatter,
83
+ headerFormatter: _vm.headerFormatter,
83
84
  footerFormatter: _vm.footerFormatter,
84
85
  padding: _vm.padding,
85
86
  verticalAlign: _vm.verticalAlign,
@@ -6,6 +6,9 @@ export const tableEmits = [
6
6
  'paste',
7
7
  'copy',
8
8
  'cut',
9
+ 'columns-change',
10
+ 'data-change',
11
+ 'footer-data-change',
9
12
  'current-change',
10
13
  'current-row-change',
11
14
  'current-row-disabled',
@@ -2,7 +2,7 @@ import { h, ref, inject, nextTick, watch, onMounted, onUnmounted } from 'vue';
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
  const { renderer, renderEmptyElement } = VxeUI;
7
7
  const renderType = 'header';
8
8
  export default defineVxeComponent({
@@ -30,16 +30,26 @@ export default defineVxeComponent({
30
30
  const refHeaderXSpace = ref();
31
31
  const refHeaderBorderRepair = ref();
32
32
  const uploadColumn = () => {
33
+ const { showCustomHeader } = tableProps;
34
+ const { collectColumn, visibleColumn } = tableInternalData;
35
+ const { tableGroupColumn } = props;
33
36
  const { isGroup } = tableReactData;
34
- headerColumn.value = isGroup ? convertHeaderColumnToRows(props.tableGroupColumn) : [];
37
+ let spanColumns = isGroup ? convertHeaderColumnToRows(tableGroupColumn) : [];
38
+ let visibleColgroups = [];
39
+ if (showCustomHeader && spanColumns.length > 1) {
40
+ visibleColgroups = convertHeaderToGridRows(spanColumns);
41
+ spanColumns = visibleColgroups;
42
+ }
43
+ headerColumn.value = spanColumns;
44
+ $xeTable.dispatchEvent('columns-change', { visibleColgroups, collectColumn, visibleColumn }, null);
35
45
  };
36
- const renderRows = (isGroup, isOptimizeMode, cols, $rowIndex) => {
46
+ const renderRows = (isGroup, isOptimizeMode, headerGroups, $rowIndex, cols) => {
37
47
  const $xeGrid = $xeTable.xeGrid;
38
48
  const $xeGantt = $xeTable.xeGantt;
39
49
  const { fixedType } = props;
40
- const { resizable: allResizable, columnKey, headerCellClassName, headerCellStyle, showHeaderOverflow: allColumnHeaderOverflow, headerAlign: allHeaderAlign, align: allAlign, mouseConfig } = tableProps;
41
- const { currentColumn, dragCol, scrollXLoad, scrollYLoad, overflowX, tableColumn } = tableReactData;
42
- const { fullColumnIdData, scrollXStore } = tableInternalData;
50
+ const { resizable: allResizable, columnKey, showCustomHeader, headerCellClassName, headerCellStyle, showHeaderOverflow: allColumnHeaderOverflow, headerAlign: allHeaderAlign, align: allAlign, mouseConfig } = tableProps;
51
+ const { currentColumn, dragCol, scrollXLoad, scrollYLoad, overflowX, mergeHeadFlag, tableColumn } = tableReactData;
52
+ const { fullColumnIdData, scrollXStore, mergeHeaderList, mergeHeaderCellMaps } = tableInternalData;
43
53
  const virtualXOpts = computeVirtualXOpts.value;
44
54
  const columnOpts = computeColumnOpts.value;
45
55
  const columnDragOpts = computeColumnDragOpts.value;
@@ -48,6 +58,7 @@ export default defineVxeComponent({
48
58
  const headerCellOpts = computeHeaderCellOpts.value;
49
59
  const currCellHeight = getCalcHeight(headerCellOpts.height) || defaultRowHeight;
50
60
  const { disabledMethod: dragDisabledMethod, isCrossDrag, isPeerDrag } = columnDragOpts;
61
+ const isLastRow = $rowIndex === headerGroups.length - 1;
51
62
  return cols.map((column, $columnIndex) => {
52
63
  const { type, showHeaderOverflow, headerAlign, align, filters, headerClassName, editRender, cellRender } = column;
53
64
  const colid = column.id;
@@ -87,10 +98,31 @@ export default defineVxeComponent({
87
98
  hasFilter
88
99
  };
89
100
  const thAttrs = {
90
- colid,
91
- colspan: column.colSpan > 1 ? column.colSpan : null,
92
- rowspan: column.rowSpan > 1 ? column.rowSpan : null
101
+ colid
93
102
  };
103
+ let isMergeCell = false;
104
+ // 合并行或列
105
+ if (!showCustomHeader) {
106
+ thAttrs.colspan = column.colSpan > 1 ? column.colSpan : null;
107
+ thAttrs.rowspan = column.rowSpan > 1 ? column.rowSpan : null;
108
+ }
109
+ if (mergeHeadFlag && mergeHeaderList.length && (showCustomHeader || isLastRow)) {
110
+ const spanRest = mergeHeaderCellMaps[`${$rowIndex}:${showCustomHeader ? $columnIndex : _columnIndex}`];
111
+ if (spanRest) {
112
+ const { rowspan, colspan } = spanRest;
113
+ if (!rowspan || !colspan) {
114
+ return null;
115
+ }
116
+ if (rowspan > 1) {
117
+ isMergeCell = true;
118
+ thAttrs.rowspan = rowspan;
119
+ }
120
+ if (colspan > 1) {
121
+ isMergeCell = true;
122
+ thAttrs.colspan = colspan;
123
+ }
124
+ }
125
+ }
94
126
  const thOns = {
95
127
  onClick: (evnt) => $xeTable.triggerHeaderCellClickEvent(evnt, cellParams),
96
128
  onDblclick: (evnt) => $xeTable.triggerHeaderCellDblclickEvent(evnt, cellParams)
@@ -117,7 +149,7 @@ export default defineVxeComponent({
117
149
  const showResizable = (XEUtils.isBoolean(column.resizable) ? column.resizable : (columnOpts.resizable || allResizable));
118
150
  const isAutoCellWidth = !column.resizeWidth && (column.minWidth === 'auto' || column.width === 'auto');
119
151
  let isVNPreEmptyStatus = false;
120
- if (isOptimizeMode && overflowX && !isGroup) {
152
+ if (isOptimizeMode && overflowX && !isGroup && !isMergeCell) {
121
153
  if (!dragCol || dragCol.id !== colid) {
122
154
  if (scrollXLoad && tableColumn.length > 10 && !column.fixed && !virtualXOpts.immediate && (_columnIndex < scrollXStore.visibleStartIndex - scrollXStore.preloadSize || _columnIndex > scrollXStore.visibleEndIndex + scrollXStore.preloadSize)) {
123
155
  isVNPreEmptyStatus = true;
@@ -131,7 +163,7 @@ export default defineVxeComponent({
131
163
  else {
132
164
  tcStyle.minHeight = `${currCellHeight}px`;
133
165
  }
134
- return h('th', Object.assign(Object.assign(Object.assign({ class: ['vxe-table--column vxe-header--column', colid, {
166
+ return h('th', Object.assign(Object.assign(Object.assign({ class: ['vxe-table--column vxe-header--column', colid, fixedHiddenColumn ? 'fixed--hidden' : 'fixed--visible', {
135
167
  [`col--${headAlign}`]: headAlign,
136
168
  [`col--${type}`]: type,
137
169
  'col--last': isLastColumn,
@@ -139,7 +171,6 @@ export default defineVxeComponent({
139
171
  'col--group': isColGroup,
140
172
  'col--ellipsis': hasEllipsis,
141
173
  'fixed--width': !isAutoCellWidth,
142
- 'fixed--hidden': fixedHiddenColumn,
143
174
  'is--padding': isPadding,
144
175
  'is--sortable': column.sortable,
145
176
  'col--filter': !!filters,
@@ -150,7 +181,7 @@ export default defineVxeComponent({
150
181
  },
151
182
  headerClassName ? (XEUtils.isFunction(headerClassName) ? headerClassName(cellParams) : headerClassName) : '',
152
183
  headerCellClassName ? (XEUtils.isFunction(headerCellClassName) ? headerCellClassName(cellParams) : headerCellClassName) : ''
153
- ], style: headerCellStyle ? (XEUtils.isFunction(headerCellStyle) ? headerCellStyle(cellParams) : headerCellStyle) : null }, thAttrs), thOns), { key: columnKey || scrollXLoad || scrollYLoad || columnOpts.useKey || columnOpts.drag || isColGroup ? colid : $columnIndex }), [
184
+ ], style: headerCellStyle ? (XEUtils.isFunction(headerCellStyle) ? headerCellStyle(cellParams) : headerCellStyle) : null }, thAttrs), thOns), { key: showCustomHeader ? `${colid}${$columnIndex}` : (columnKey || scrollXLoad || scrollYLoad || columnOpts.useKey || columnOpts.drag || isColGroup ? colid : $columnIndex) }), [
154
185
  h('div', {
155
186
  class: ['vxe-cell', {
156
187
  'c--title': showTitle,
@@ -169,7 +200,7 @@ export default defineVxeComponent({
169
200
  /**
170
201
  * 列宽拖动
171
202
  */
172
- !fixedHiddenColumn && showResizable
203
+ !fixedHiddenColumn && showResizable && (!showCustomHeader || isLastRow)
173
204
  ? h('div', {
174
205
  class: 'vxe-cell--col-resizable',
175
206
  onMousedown: (evnt) => $xeTable.handleColResizeMousedownEvent(evnt, fixedType, cellParams),
@@ -191,7 +222,7 @@ export default defineVxeComponent({
191
222
  headerRowClassName ? (XEUtils.isFunction(headerRowClassName) ? headerRowClassName(params) : headerRowClassName) : ''
192
223
  ],
193
224
  style: headerRowStyle ? (XEUtils.isFunction(headerRowStyle) ? headerRowStyle(params) : headerRowStyle) : null
194
- }, renderRows(isGroup, isOptimizeMode, cols, $rowIndex));
225
+ }, renderRows(isGroup, isOptimizeMode, headerGroups, $rowIndex, cols));
195
226
  });
196
227
  };
197
228
  const renderVN = () => {
@@ -200,7 +231,7 @@ export default defineVxeComponent({
200
231
  const { isGroup, isColLoading, overflowX, scrollXLoad, dragCol } = tableReactData;
201
232
  const { visibleColumn, fullColumnIdData } = tableInternalData;
202
233
  const mouseOpts = computeMouseOpts.value;
203
- let renderHeaderList = headerColumn.value;
234
+ let renderHeaderList = headerColumn.value || [];
204
235
  let renderColumnList = tableColumn;
205
236
  let isOptimizeMode = false;
206
237
  if (isGroup) {
@@ -10,7 +10,7 @@ export const tableProps = {
10
10
  // 表格的最小高度
11
11
  minHeight: {
12
12
  type: [Number, String],
13
- default: () => getConfig().table.minHeight
13
+ default: () => null
14
14
  },
15
15
  // 表格的最大高度
16
16
  maxHeight: [Number, String],
@@ -129,9 +129,17 @@ export const tableProps = {
129
129
  headerRowStyle: [Object, Function],
130
130
  // 给表尾行附加样式
131
131
  footerRowStyle: [Object, Function],
132
- // 合并指定单元格
132
+ // 用于分组表头,显示为自定义列头,配合 mergeHeaderCells 灵活实现自定义合并
133
+ showCustomHeader: {
134
+ type: Boolean,
135
+ default: () => getConfig().table.showCustomHeader
136
+ },
137
+ // 临时合并指定的表头单元格
138
+ mergeHeaderCells: Array,
139
+ // 临时合并指定的单元格
133
140
  mergeCells: Array,
134
- // 合并指定的表尾
141
+ // 临时合并指定的表尾单元格
142
+ mergeFooterCells: Array,
135
143
  mergeFooterItems: Array,
136
144
  // 自定义合并行或列的方法
137
145
  spanMethod: Function,