vxe-table 4.8.16 → 4.9.0

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 (82) hide show
  1. package/README.en.md +1 -1
  2. package/README.md +1 -1
  3. package/README.zh-TW.md +1 -1
  4. package/es/style.css +1 -1
  5. package/es/style.min.css +1 -1
  6. package/es/table/module/custom/hook.js +4 -0
  7. package/es/table/module/edit/hook.js +46 -34
  8. package/es/table/module/filter/hook.js +2 -3
  9. package/es/table/module/keyboard/hook.js +2 -2
  10. package/es/table/src/body.js +31 -24
  11. package/es/table/src/cell.js +99 -59
  12. package/es/table/src/emits.js +3 -0
  13. package/es/table/src/footer.js +177 -147
  14. package/es/table/src/header.js +144 -107
  15. package/es/table/src/props.js +5 -1
  16. package/es/table/src/table.js +346 -108
  17. package/es/table/src/util.js +9 -0
  18. package/es/table/style.css +33 -20
  19. package/es/table/style.min.css +1 -1
  20. package/es/ui/index.js +9 -4
  21. package/es/ui/src/log.js +1 -1
  22. package/es/vxe-table/style.css +33 -20
  23. package/es/vxe-table/style.min.css +1 -1
  24. package/helper/vetur/attributes.json +1 -1
  25. package/helper/vetur/tags.json +1 -1
  26. package/lib/index.umd.js +1032 -580
  27. package/lib/index.umd.min.js +1 -1
  28. package/lib/style.css +1 -1
  29. package/lib/style.min.css +1 -1
  30. package/lib/table/module/custom/hook.js +4 -0
  31. package/lib/table/module/custom/hook.min.js +1 -1
  32. package/lib/table/module/edit/hook.js +54 -42
  33. package/lib/table/module/edit/hook.min.js +1 -1
  34. package/lib/table/module/filter/hook.js +1 -2
  35. package/lib/table/module/filter/hook.min.js +1 -1
  36. package/lib/table/module/keyboard/hook.js +2 -2
  37. package/lib/table/module/keyboard/hook.min.js +1 -1
  38. package/lib/table/src/body.js +34 -21
  39. package/lib/table/src/body.min.js +1 -1
  40. package/lib/table/src/cell.js +110 -51
  41. package/lib/table/src/cell.min.js +1 -1
  42. package/lib/table/src/emits.js +1 -1
  43. package/lib/table/src/emits.min.js +1 -1
  44. package/lib/table/src/footer.js +222 -183
  45. package/lib/table/src/footer.min.js +1 -1
  46. package/lib/table/src/header.js +188 -150
  47. package/lib/table/src/header.min.js +1 -1
  48. package/lib/table/src/props.js +5 -1
  49. package/lib/table/src/props.min.js +1 -1
  50. package/lib/table/src/table.js +380 -110
  51. package/lib/table/src/table.min.js +1 -1
  52. package/lib/table/src/util.js +10 -0
  53. package/lib/table/src/util.min.js +1 -1
  54. package/lib/table/style/style.css +33 -20
  55. package/lib/table/style/style.min.css +1 -1
  56. package/lib/ui/index.js +9 -4
  57. package/lib/ui/index.min.js +1 -1
  58. package/lib/ui/src/log.js +1 -1
  59. package/lib/ui/src/log.min.js +1 -1
  60. package/lib/vxe-table/style/style.css +33 -20
  61. package/lib/vxe-table/style/style.min.css +1 -1
  62. package/package.json +3 -3
  63. package/packages/table/module/custom/hook.ts +4 -0
  64. package/packages/table/module/edit/hook.ts +47 -34
  65. package/packages/table/module/filter/hook.ts +2 -3
  66. package/packages/table/module/keyboard/hook.ts +2 -2
  67. package/packages/table/src/body.ts +46 -31
  68. package/packages/table/src/cell.ts +140 -92
  69. package/packages/table/src/emits.ts +3 -0
  70. package/packages/table/src/footer.ts +189 -152
  71. package/packages/table/src/header.ts +157 -116
  72. package/packages/table/src/props.ts +5 -1
  73. package/packages/table/src/table.ts +358 -109
  74. package/packages/table/src/util.ts +10 -0
  75. package/packages/ui/index.ts +8 -3
  76. package/styles/components/table.scss +42 -35
  77. /package/es/{iconfont.1731633504443.ttf → iconfont.1731895336421.ttf} +0 -0
  78. /package/es/{iconfont.1731633504443.woff → iconfont.1731895336421.woff} +0 -0
  79. /package/es/{iconfont.1731633504443.woff2 → iconfont.1731895336421.woff2} +0 -0
  80. /package/lib/{iconfont.1731633504443.ttf → iconfont.1731895336421.ttf} +0 -0
  81. /package/lib/{iconfont.1731633504443.woff → iconfont.1731895336421.woff} +0 -0
  82. /package/lib/{iconfont.1731633504443.woff2 → iconfont.1731895336421.woff2} +0 -0
@@ -1,4 +1,4 @@
1
- import { createCommentVNode, defineComponent, h, ref, inject, nextTick, onMounted, onUnmounted } from 'vue';
1
+ import { createCommentVNode, defineComponent, TransitionGroup, h, ref, inject, nextTick, onMounted, onUnmounted } from 'vue';
2
2
  import XEUtils from 'xe-utils';
3
3
  import { VxeUI } from '../../ui';
4
4
  import { updateCellTitle, getPropClass, setScrollLeft } from '../../ui/src/dom';
@@ -76,35 +76,163 @@ export default defineComponent({
76
76
  });
77
77
  }
78
78
  };
79
- onMounted(() => {
80
- nextTick(() => {
81
- const { fixedType } = props;
82
- const { elemStore } = tableInternalData;
83
- const prefix = `${fixedType || 'main'}-footer-`;
84
- elemStore[`${prefix}wrapper`] = refElem;
85
- elemStore[`${prefix}table`] = refFooterTable;
86
- elemStore[`${prefix}colgroup`] = refFooterColgroup;
87
- elemStore[`${prefix}list`] = refFooterTFoot;
88
- elemStore[`${prefix}xSpace`] = refFooterXSpace;
89
- });
90
- });
91
- onUnmounted(() => {
79
+ const renderRows = (tableColumn, footerTableData, row, $rowIndex, _rowIndex) => {
92
80
  const { fixedType } = props;
93
- const { elemStore } = tableInternalData;
94
- const prefix = `${fixedType || 'main'}-footer-`;
95
- elemStore[`${prefix}wrapper`] = null;
96
- elemStore[`${prefix}table`] = null;
97
- elemStore[`${prefix}colgroup`] = null;
98
- elemStore[`${prefix}list`] = null;
99
- elemStore[`${prefix}xSpace`] = null;
100
- });
101
- const renderVN = () => {
102
- let { fixedType, fixedColumn, tableColumn, footerTableData } = props;
103
- const { footerRowClassName, footerCellClassName, footerRowStyle, footerCellStyle, footerAlign: allFooterAlign, footerSpanMethod, align: allAlign, columnKey, showFooterOverflow: allColumnFooterOverflow } = tableProps;
104
- const { visibleColumn } = tableInternalData;
81
+ const { footerCellClassName, footerCellStyle, footerAlign: allFooterAlign, footerSpanMethod, align: allAlign, columnKey, showFooterOverflow: allColumnFooterOverflow } = tableProps;
105
82
  const { scrollXLoad, overflowX, scrollbarWidth, currentColumn, mergeFooterList } = tableReactData;
106
83
  const tooltipOpts = computeTooltipOpts.value;
107
84
  const columnOpts = computeColumnOpts.value;
85
+ return tableColumn.map((column, $columnIndex) => {
86
+ const { type, showFooterOverflow, footerAlign, align, footerClassName, editRender, cellRender } = column;
87
+ const renderOpts = editRender || cellRender;
88
+ const compConf = renderOpts ? renderer.get(renderOpts.name) : null;
89
+ const showAllTip = tooltipOpts.showAll;
90
+ const isColGroup = column.children && column.children.length;
91
+ const fixedHiddenColumn = fixedType ? column.fixed !== fixedType && !isColGroup : column.fixed && overflowX;
92
+ const footOverflow = XEUtils.eqNull(showFooterOverflow) ? allColumnFooterOverflow : showFooterOverflow;
93
+ const footAlign = footerAlign || (compConf ? compConf.tableFooterCellAlign : '') || allFooterAlign || align || (compConf ? compConf.tableCellAlign : '') || allAlign;
94
+ let showEllipsis = footOverflow === 'ellipsis';
95
+ const showTitle = footOverflow === 'title';
96
+ const showTooltip = footOverflow === true || footOverflow === 'tooltip';
97
+ let hasEllipsis = showTitle || showTooltip || showEllipsis;
98
+ const attrs = { colid: column.id };
99
+ const tfOns = {};
100
+ const columnIndex = $xeTable.getColumnIndex(column);
101
+ const _columnIndex = $xeTable.getVTColumnIndex(column);
102
+ const itemIndex = _columnIndex;
103
+ const cellParams = {
104
+ $table: $xeTable,
105
+ $grid: $xeTable.xegrid,
106
+ row,
107
+ rowIndex: _rowIndex,
108
+ _rowIndex,
109
+ $rowIndex,
110
+ column,
111
+ columnIndex,
112
+ $columnIndex,
113
+ _columnIndex,
114
+ itemIndex,
115
+ items: row,
116
+ fixed: fixedType,
117
+ type: renderType,
118
+ data: footerTableData
119
+ };
120
+ // 纵向虚拟滚动不支持动态行高
121
+ if (scrollXLoad && !hasEllipsis) {
122
+ showEllipsis = hasEllipsis = true;
123
+ }
124
+ if (showTitle || showTooltip || showAllTip) {
125
+ tfOns.onMouseenter = (evnt) => {
126
+ if (showTitle) {
127
+ updateCellTitle(evnt.currentTarget, column);
128
+ }
129
+ else if (showTooltip || showAllTip) {
130
+ $xeTable.triggerFooterTooltipEvent(evnt, cellParams);
131
+ }
132
+ };
133
+ }
134
+ if (showTooltip || showAllTip) {
135
+ tfOns.onMouseleave = (evnt) => {
136
+ if (showTooltip || showAllTip) {
137
+ $xeTable.handleTargetLeaveEvent(evnt);
138
+ }
139
+ };
140
+ }
141
+ tfOns.onClick = (evnt) => {
142
+ $xeTable.dispatchEvent('footer-cell-click', Object.assign({ cell: evnt.currentTarget }, cellParams), evnt);
143
+ };
144
+ tfOns.onDblclick = (evnt) => {
145
+ $xeTable.dispatchEvent('footer-cell-dblclick', Object.assign({ cell: evnt.currentTarget }, cellParams), evnt);
146
+ };
147
+ // 合并行或列
148
+ if (mergeFooterList.length) {
149
+ const spanRest = mergeFooterMethod(mergeFooterList, _rowIndex, _columnIndex);
150
+ if (spanRest) {
151
+ const { rowspan, colspan } = spanRest;
152
+ if (!rowspan || !colspan) {
153
+ return null;
154
+ }
155
+ if (rowspan > 1) {
156
+ attrs.rowspan = rowspan;
157
+ }
158
+ if (colspan > 1) {
159
+ attrs.colspan = colspan;
160
+ }
161
+ }
162
+ }
163
+ else if (footerSpanMethod) {
164
+ // 自定义合并方法
165
+ const { rowspan = 1, colspan = 1 } = footerSpanMethod(cellParams) || {};
166
+ if (!rowspan || !colspan) {
167
+ return null;
168
+ }
169
+ if (rowspan > 1) {
170
+ attrs.rowspan = rowspan;
171
+ }
172
+ if (colspan > 1) {
173
+ attrs.colspan = colspan;
174
+ }
175
+ }
176
+ return h('td', Object.assign(Object.assign(Object.assign(Object.assign({ class: ['vxe-footer--column', column.id, {
177
+ [`col--${footAlign}`]: footAlign,
178
+ [`col--${type}`]: type,
179
+ 'col--last': $columnIndex === tableColumn.length - 1,
180
+ 'fixed--hidden': fixedHiddenColumn,
181
+ 'col--ellipsis': hasEllipsis,
182
+ 'col--current': currentColumn === column
183
+ }, getPropClass(footerClassName, cellParams), getPropClass(footerCellClassName, cellParams)] }, attrs), { style: footerCellStyle ? (XEUtils.isFunction(footerCellStyle) ? footerCellStyle(cellParams) : footerCellStyle) : null }), tfOns), { key: columnKey || columnOpts.useKey || columnOpts.drag ? column.id : $columnIndex }), [
184
+ h('div', {
185
+ class: ['vxe-cell', {
186
+ 'c--title': showTitle,
187
+ 'c--tooltip': showTooltip,
188
+ 'c--ellipsis': showEllipsis
189
+ }]
190
+ }, column.renderFooter(cellParams))
191
+ ]);
192
+ }).concat(scrollbarWidth
193
+ ? [
194
+ h('td', {
195
+ key: `gr${$rowIndex}`,
196
+ class: 'vxe-footer--gutter col--gutter'
197
+ })
198
+ ]
199
+ : []);
200
+ };
201
+ const renderHeads = (footerTableData) => {
202
+ const { fixedType, tableColumn } = props;
203
+ const { footerRowClassName, footerRowStyle } = tableProps;
204
+ const { isDragColMove } = tableReactData;
205
+ const columnOpts = computeColumnOpts.value;
206
+ return footerTableData.map((row, $rowIndex) => {
207
+ const _rowIndex = $rowIndex;
208
+ const rowParams = { $table: $xeTable, row, _rowIndex, $rowIndex, fixed: fixedType, type: renderType };
209
+ if (columnOpts.drag) {
210
+ return h(TransitionGroup, {
211
+ name: `vxe-header--col-list${isDragColMove ? '' : '-disabled'}`,
212
+ tag: 'tr',
213
+ class: [
214
+ 'vxe-footer--row',
215
+ footerRowClassName ? XEUtils.isFunction(footerRowClassName) ? footerRowClassName(rowParams) : footerRowClassName : ''
216
+ ],
217
+ style: footerRowStyle ? (XEUtils.isFunction(footerRowStyle) ? footerRowStyle(rowParams) : footerRowStyle) : null
218
+ }, {
219
+ default: () => renderRows(tableColumn, footerTableData, row, $rowIndex, _rowIndex)
220
+ });
221
+ }
222
+ return h('tr', {
223
+ class: [
224
+ 'vxe-footer--row',
225
+ footerRowClassName ? XEUtils.isFunction(footerRowClassName) ? footerRowClassName(rowParams) : footerRowClassName : ''
226
+ ],
227
+ style: footerRowStyle ? (XEUtils.isFunction(footerRowStyle) ? footerRowStyle(rowParams) : footerRowStyle) : null
228
+ }, renderRows(tableColumn, footerTableData, row, $rowIndex, _rowIndex));
229
+ });
230
+ };
231
+ const renderVN = () => {
232
+ let { fixedType, fixedColumn, tableColumn, footerTableData } = props;
233
+ const { footerSpanMethod, showFooterOverflow: allColumnFooterOverflow } = tableProps;
234
+ const { visibleColumn } = tableInternalData;
235
+ const { scrollXLoad, scrollbarWidth, mergeFooterList } = tableReactData;
108
236
  // 如果是使用优化模式
109
237
  if (fixedType) {
110
238
  // 如果存在展开行使用全量渲染
@@ -162,130 +290,32 @@ export default defineComponent({
162
290
  */
163
291
  h('tfoot', {
164
292
  ref: refFooterTFoot
165
- }, footerTableData.map((list, _rowIndex) => {
166
- const $rowIndex = _rowIndex;
167
- const rowParams = { $table: $xeTable, row: list, _rowIndex, $rowIndex, fixed: fixedType, type: renderType };
168
- return h('tr', {
169
- class: ['vxe-footer--row', footerRowClassName ? XEUtils.isFunction(footerRowClassName) ? footerRowClassName(rowParams) : footerRowClassName : ''],
170
- style: footerRowStyle ? (XEUtils.isFunction(footerRowStyle) ? footerRowStyle(rowParams) : footerRowStyle) : null
171
- }, tableColumn.map((column, $columnIndex) => {
172
- const { type, showFooterOverflow, footerAlign, align, footerClassName, editRender, cellRender } = column;
173
- const renderOpts = editRender || cellRender;
174
- const compConf = renderOpts ? renderer.get(renderOpts.name) : null;
175
- const showAllTip = tooltipOpts.showAll;
176
- const isColGroup = column.children && column.children.length;
177
- const fixedHiddenColumn = fixedType ? column.fixed !== fixedType && !isColGroup : column.fixed && overflowX;
178
- const footOverflow = XEUtils.eqNull(showFooterOverflow) ? allColumnFooterOverflow : showFooterOverflow;
179
- const footAlign = footerAlign || (compConf ? compConf.tableFooterCellAlign : '') || allFooterAlign || align || (compConf ? compConf.tableCellAlign : '') || allAlign;
180
- let showEllipsis = footOverflow === 'ellipsis';
181
- const showTitle = footOverflow === 'title';
182
- const showTooltip = footOverflow === true || footOverflow === 'tooltip';
183
- let hasEllipsis = showTitle || showTooltip || showEllipsis;
184
- const attrs = { colid: column.id };
185
- const tfOns = {};
186
- const columnIndex = $xeTable.getColumnIndex(column);
187
- const _columnIndex = $xeTable.getVTColumnIndex(column);
188
- const itemIndex = _columnIndex;
189
- const cellParams = {
190
- $table: $xeTable,
191
- $grid: $xeTable.xegrid,
192
- row: list,
193
- rowIndex: _rowIndex,
194
- _rowIndex,
195
- $rowIndex,
196
- column,
197
- columnIndex,
198
- $columnIndex,
199
- _columnIndex,
200
- itemIndex,
201
- items: list,
202
- fixed: fixedType,
203
- type: renderType,
204
- data: footerTableData
205
- };
206
- // 纵向虚拟滚动不支持动态行高
207
- if (scrollXLoad && !hasEllipsis) {
208
- showEllipsis = hasEllipsis = true;
209
- }
210
- if (showTitle || showTooltip || showAllTip) {
211
- tfOns.onMouseenter = (evnt) => {
212
- if (showTitle) {
213
- updateCellTitle(evnt.currentTarget, column);
214
- }
215
- else if (showTooltip || showAllTip) {
216
- $xeTable.triggerFooterTooltipEvent(evnt, cellParams);
217
- }
218
- };
219
- }
220
- if (showTooltip || showAllTip) {
221
- tfOns.onMouseleave = (evnt) => {
222
- if (showTooltip || showAllTip) {
223
- $xeTable.handleTargetLeaveEvent(evnt);
224
- }
225
- };
226
- }
227
- tfOns.onClick = (evnt) => {
228
- $xeTable.dispatchEvent('footer-cell-click', Object.assign({ cell: evnt.currentTarget }, cellParams), evnt);
229
- };
230
- tfOns.onDblclick = (evnt) => {
231
- $xeTable.dispatchEvent('footer-cell-dblclick', Object.assign({ cell: evnt.currentTarget }, cellParams), evnt);
232
- };
233
- // 合并行或列
234
- if (mergeFooterList.length) {
235
- const spanRest = mergeFooterMethod(mergeFooterList, _rowIndex, _columnIndex);
236
- if (spanRest) {
237
- const { rowspan, colspan } = spanRest;
238
- if (!rowspan || !colspan) {
239
- return null;
240
- }
241
- if (rowspan > 1) {
242
- attrs.rowspan = rowspan;
243
- }
244
- if (colspan > 1) {
245
- attrs.colspan = colspan;
246
- }
247
- }
248
- }
249
- else if (footerSpanMethod) {
250
- // 自定义合并方法
251
- const { rowspan = 1, colspan = 1 } = footerSpanMethod(cellParams) || {};
252
- if (!rowspan || !colspan) {
253
- return null;
254
- }
255
- if (rowspan > 1) {
256
- attrs.rowspan = rowspan;
257
- }
258
- if (colspan > 1) {
259
- attrs.colspan = colspan;
260
- }
261
- }
262
- return h('td', Object.assign(Object.assign(Object.assign(Object.assign({ class: ['vxe-footer--column', column.id, {
263
- [`col--${footAlign}`]: footAlign,
264
- [`col--${type}`]: type,
265
- 'col--last': $columnIndex === tableColumn.length - 1,
266
- 'fixed--hidden': fixedHiddenColumn,
267
- 'col--ellipsis': hasEllipsis,
268
- 'col--current': currentColumn === column
269
- }, getPropClass(footerClassName, cellParams), getPropClass(footerCellClassName, cellParams)] }, attrs), { style: footerCellStyle ? (XEUtils.isFunction(footerCellStyle) ? footerCellStyle(cellParams) : footerCellStyle) : null }), tfOns), { key: columnKey || columnOpts.useKey ? column.id : $columnIndex }), [
270
- h('div', {
271
- class: ['vxe-cell', {
272
- 'c--title': showTitle,
273
- 'c--tooltip': showTooltip,
274
- 'c--ellipsis': showEllipsis
275
- }]
276
- }, column.renderFooter(cellParams))
277
- ]);
278
- }).concat(scrollbarWidth
279
- ? [
280
- h('td', {
281
- class: 'vxe-footer--gutter col--gutter'
282
- })
283
- ]
284
- : []));
285
- }))
293
+ }, renderHeads(footerTableData))
286
294
  ])
287
295
  ]);
288
296
  };
297
+ onMounted(() => {
298
+ nextTick(() => {
299
+ const { fixedType } = props;
300
+ const { elemStore } = tableInternalData;
301
+ const prefix = `${fixedType || 'main'}-footer-`;
302
+ elemStore[`${prefix}wrapper`] = refElem;
303
+ elemStore[`${prefix}table`] = refFooterTable;
304
+ elemStore[`${prefix}colgroup`] = refFooterColgroup;
305
+ elemStore[`${prefix}list`] = refFooterTFoot;
306
+ elemStore[`${prefix}xSpace`] = refFooterXSpace;
307
+ });
308
+ });
309
+ onUnmounted(() => {
310
+ const { fixedType } = props;
311
+ const { elemStore } = tableInternalData;
312
+ const prefix = `${fixedType || 'main'}-footer-`;
313
+ elemStore[`${prefix}wrapper`] = null;
314
+ elemStore[`${prefix}table`] = null;
315
+ elemStore[`${prefix}colgroup`] = null;
316
+ elemStore[`${prefix}list`] = null;
317
+ elemStore[`${prefix}xSpace`] = null;
318
+ });
289
319
  return renderVN;
290
320
  }
291
321
  });
@@ -1,4 +1,4 @@
1
- import { createCommentVNode, defineComponent, h, ref, inject, nextTick, watch, onMounted, onUnmounted } from 'vue';
1
+ import { createCommentVNode, defineComponent, TransitionGroup, h, ref, inject, nextTick, watch, onMounted, onUnmounted } from 'vue';
2
2
  import XEUtils from 'xe-utils';
3
3
  import { VxeUI } from '../../ui';
4
4
  import { convertHeaderColumnToRows, getColReMinWidth } from './util';
@@ -124,40 +124,124 @@ export default defineComponent({
124
124
  $xeTable.closeMenu();
125
125
  }
126
126
  };
127
- watch(() => props.tableColumn, uploadColumn);
128
- onMounted(() => {
129
- nextTick(() => {
130
- const { fixedType } = props;
131
- const { internalData } = $xeTable;
132
- const { elemStore } = internalData;
133
- const prefix = `${fixedType || 'main'}-header-`;
134
- elemStore[`${prefix}wrapper`] = refElem;
135
- elemStore[`${prefix}table`] = refHeaderTable;
136
- elemStore[`${prefix}colgroup`] = refHeaderColgroup;
137
- elemStore[`${prefix}list`] = refHeaderTHead;
138
- elemStore[`${prefix}xSpace`] = refHeaderXSpace;
139
- elemStore[`${prefix}repair`] = refHeaderBorderRepair;
140
- uploadColumn();
141
- });
142
- });
143
- onUnmounted(() => {
127
+ const renderRows = (cols, $rowIndex) => {
144
128
  const { fixedType } = props;
145
- const { internalData } = $xeTable;
146
- const { elemStore } = internalData;
147
- const prefix = `${fixedType || 'main'}-header-`;
148
- elemStore[`${prefix}wrapper`] = null;
149
- elemStore[`${prefix}table`] = null;
150
- elemStore[`${prefix}colgroup`] = null;
151
- elemStore[`${prefix}list`] = null;
152
- elemStore[`${prefix}xSpace`] = null;
153
- elemStore[`${prefix}repair`] = null;
154
- });
129
+ const { resizable: allResizable, border, columnKey, headerCellClassName, headerCellStyle, showHeaderOverflow: allColumnHeaderOverflow, headerAlign: allHeaderAlign, align: allAlign, mouseConfig } = tableProps;
130
+ const { currentColumn, scrollXLoad, overflowX, scrollbarWidth } = tableReactData;
131
+ const columnOpts = computeColumnOpts.value;
132
+ return cols.map((column, $columnIndex) => {
133
+ const { type, showHeaderOverflow, headerAlign, align, headerClassName, editRender, cellRender } = column;
134
+ const colid = column.id;
135
+ const renderOpts = editRender || cellRender;
136
+ const compConf = renderOpts ? renderer.get(renderOpts.name) : null;
137
+ const isColGroup = column.children && column.children.length;
138
+ const fixedHiddenColumn = fixedType ? (column.fixed !== fixedType && !isColGroup) : !!column.fixed && overflowX;
139
+ const headOverflow = XEUtils.eqNull(showHeaderOverflow) ? allColumnHeaderOverflow : showHeaderOverflow;
140
+ const headAlign = headerAlign || (compConf ? compConf.tableHeaderCellAlign : '') || allHeaderAlign || align || (compConf ? compConf.tableCellAlign : '') || allAlign;
141
+ let showEllipsis = headOverflow === 'ellipsis';
142
+ const showTitle = headOverflow === 'title';
143
+ const showTooltip = headOverflow === true || headOverflow === 'tooltip';
144
+ let hasEllipsis = showTitle || showTooltip || showEllipsis;
145
+ const hasFilter = column.filters && column.filters.some((item) => item.checked);
146
+ const columnIndex = $xeTable.getColumnIndex(column);
147
+ const _columnIndex = $xeTable.getVTColumnIndex(column);
148
+ const params = { $table: $xeTable, $grid: $xeTable.xegrid, $rowIndex, column, columnIndex, $columnIndex, _columnIndex, fixed: fixedType, type: renderType, isHidden: fixedHiddenColumn, hasFilter };
149
+ const thOns = {
150
+ onClick: (evnt) => $xeTable.triggerHeaderCellClickEvent(evnt, params),
151
+ onDblclick: (evnt) => $xeTable.triggerHeaderCellDblclickEvent(evnt, params)
152
+ };
153
+ // 横向虚拟滚动不支持动态行高
154
+ if (scrollXLoad && !hasEllipsis) {
155
+ showEllipsis = hasEllipsis = true;
156
+ }
157
+ // 按下事件处理
158
+ if (mouseConfig) {
159
+ thOns.onMousedown = (evnt) => $xeTable.triggerHeaderCellMousedownEvent(evnt, params);
160
+ }
161
+ // 拖拽行事件
162
+ if (columnOpts.drag && !column.parentId) {
163
+ thOns.onDragstart = $xeTable.handleHeaderCellDragDragstartEvent;
164
+ thOns.onDragend = $xeTable.handleHeaderCellDragDragendEvent;
165
+ thOns.onDragover = $xeTable.handleHeaderCellDragDragoverEvent;
166
+ }
167
+ return h('th', Object.assign(Object.assign({ class: ['vxe-header--column', colid, {
168
+ [`col--${headAlign}`]: headAlign,
169
+ [`col--${type}`]: type,
170
+ 'col--last': $columnIndex === cols.length - 1,
171
+ 'col--fixed': column.fixed,
172
+ 'col--group': isColGroup,
173
+ 'col--ellipsis': hasEllipsis,
174
+ 'fixed--hidden': fixedHiddenColumn,
175
+ 'is--sortable': column.sortable,
176
+ 'col--filter': !!column.filters,
177
+ 'is--filter-active': hasFilter,
178
+ 'col--current': currentColumn === column
179
+ },
180
+ headerClassName ? (XEUtils.isFunction(headerClassName) ? headerClassName(params) : headerClassName) : '',
181
+ headerCellClassName ? (XEUtils.isFunction(headerCellClassName) ? headerCellClassName(params) : headerCellClassName) : ''
182
+ ], colid, colspan: column.colSpan > 1 ? column.colSpan : null, rowspan: column.rowSpan > 1 ? column.rowSpan : null, style: headerCellStyle ? (XEUtils.isFunction(headerCellStyle) ? headerCellStyle(params) : headerCellStyle) : null }, thOns), { key: columnKey || columnOpts.useKey || columnOpts.drag || isColGroup ? colid : $columnIndex }), [
183
+ h('div', {
184
+ class: ['vxe-cell', {
185
+ 'c--title': showTitle,
186
+ 'c--tooltip': showTooltip,
187
+ 'c--ellipsis': showEllipsis
188
+ }]
189
+ }, column.renderHeader(params)),
190
+ /**
191
+ * 列宽拖动
192
+ */
193
+ !fixedHiddenColumn && !isColGroup && (XEUtils.isBoolean(column.resizable) ? column.resizable : (columnOpts.resizable || allResizable))
194
+ ? h('div', {
195
+ class: ['vxe-resizable', {
196
+ 'is--line': !border || border === 'none'
197
+ }],
198
+ onMousedown: (evnt) => resizeMousedown(evnt, params)
199
+ })
200
+ : null
201
+ ]);
202
+ }).concat(scrollbarWidth
203
+ ? [
204
+ h('th', {
205
+ key: `gr${$rowIndex}`,
206
+ class: 'vxe-header--gutter col--gutter'
207
+ })
208
+ ]
209
+ : []);
210
+ };
211
+ const renderHeads = (headerGroups) => {
212
+ const { fixedType } = props;
213
+ const { headerRowClassName, headerRowStyle } = tableProps;
214
+ const { isDragColMove } = tableReactData;
215
+ const columnOpts = computeColumnOpts.value;
216
+ return headerGroups.map((cols, $rowIndex) => {
217
+ const params = { $table: $xeTable, $rowIndex, fixed: fixedType, type: renderType };
218
+ if (columnOpts.drag) {
219
+ return h(TransitionGroup, {
220
+ name: `vxe-header--col-list${isDragColMove ? '' : '-disabled'}`,
221
+ tag: 'tr',
222
+ class: [
223
+ 'vxe-header--row',
224
+ headerRowClassName ? (XEUtils.isFunction(headerRowClassName) ? headerRowClassName(params) : headerRowClassName) : ''
225
+ ],
226
+ style: headerRowStyle ? (XEUtils.isFunction(headerRowStyle) ? headerRowStyle(params) : headerRowStyle) : null
227
+ }, {
228
+ default: () => renderRows(cols, $rowIndex)
229
+ });
230
+ }
231
+ return h('tr', {
232
+ class: [
233
+ 'vxe-header--row',
234
+ headerRowClassName ? (XEUtils.isFunction(headerRowClassName) ? headerRowClassName(params) : headerRowClassName) : ''
235
+ ],
236
+ style: headerRowStyle ? (XEUtils.isFunction(headerRowStyle) ? headerRowStyle(params) : headerRowStyle) : null
237
+ }, renderRows(cols, $rowIndex));
238
+ });
239
+ };
155
240
  const renderVN = () => {
156
241
  const { fixedType, fixedColumn, tableColumn } = props;
157
- const { resizable: allResizable, border, columnKey, headerRowClassName, headerCellClassName, headerRowStyle, headerCellStyle, showHeaderOverflow: allColumnHeaderOverflow, headerAlign: allHeaderAlign, align: allAlign, mouseConfig } = tableProps;
158
- const { isGroup, currentColumn, scrollXLoad, overflowX, scrollbarWidth } = tableReactData;
242
+ const { showHeaderOverflow: allColumnHeaderOverflow } = tableProps;
243
+ const { isGroup, scrollXLoad, scrollbarWidth } = tableReactData;
159
244
  const { visibleColumn } = tableInternalData;
160
- const columnOpts = computeColumnOpts.value;
161
245
  let headerGroups = headerColumn.value;
162
246
  let renderColumnList = tableColumn;
163
247
  if (isGroup) {
@@ -213,82 +297,7 @@ export default defineComponent({
213
297
  */
214
298
  h('thead', {
215
299
  ref: refHeaderTHead
216
- }, headerGroups.map((cols, $rowIndex) => {
217
- return h('tr', {
218
- class: ['vxe-header--row', headerRowClassName ? (XEUtils.isFunction(headerRowClassName) ? headerRowClassName({ $table: $xeTable, $rowIndex, fixed: fixedType, type: renderType }) : headerRowClassName) : ''],
219
- style: headerRowStyle ? (XEUtils.isFunction(headerRowStyle) ? headerRowStyle({ $table: $xeTable, $rowIndex, fixed: fixedType, type: renderType }) : headerRowStyle) : null
220
- }, cols.map((column, $columnIndex) => {
221
- const { type, showHeaderOverflow, headerAlign, align, headerClassName, editRender, cellRender } = column;
222
- const colid = column.id;
223
- const renderOpts = editRender || cellRender;
224
- const compConf = renderOpts ? renderer.get(renderOpts.name) : null;
225
- const isColGroup = column.children && column.children.length;
226
- const fixedHiddenColumn = fixedType ? (column.fixed !== fixedType && !isColGroup) : !!column.fixed && overflowX;
227
- const headOverflow = XEUtils.eqNull(showHeaderOverflow) ? allColumnHeaderOverflow : showHeaderOverflow;
228
- const headAlign = headerAlign || (compConf ? compConf.tableHeaderCellAlign : '') || allHeaderAlign || align || (compConf ? compConf.tableCellAlign : '') || allAlign;
229
- let showEllipsis = headOverflow === 'ellipsis';
230
- const showTitle = headOverflow === 'title';
231
- const showTooltip = headOverflow === true || headOverflow === 'tooltip';
232
- let hasEllipsis = showTitle || showTooltip || showEllipsis;
233
- const hasFilter = column.filters && column.filters.some((item) => item.checked);
234
- const columnIndex = $xeTable.getColumnIndex(column);
235
- const _columnIndex = $xeTable.getVTColumnIndex(column);
236
- const params = { $table: $xeTable, $grid: $xeTable.xegrid, $rowIndex, column, columnIndex, $columnIndex, _columnIndex, fixed: fixedType, type: renderType, isHidden: fixedHiddenColumn, hasFilter };
237
- const thOns = {
238
- onClick: (evnt) => $xeTable.triggerHeaderCellClickEvent(evnt, params),
239
- onDblclick: (evnt) => $xeTable.triggerHeaderCellDblclickEvent(evnt, params)
240
- };
241
- // 横向虚拟滚动不支持动态行高
242
- if (scrollXLoad && !hasEllipsis) {
243
- showEllipsis = hasEllipsis = true;
244
- }
245
- // 按下事件处理
246
- if (mouseConfig) {
247
- thOns.onMousedown = (evnt) => $xeTable.triggerHeaderCellMousedownEvent(evnt, params);
248
- }
249
- return h('th', Object.assign(Object.assign({ class: ['vxe-header--column', colid, {
250
- [`col--${headAlign}`]: headAlign,
251
- [`col--${type}`]: type,
252
- 'col--last': $columnIndex === cols.length - 1,
253
- 'col--fixed': column.fixed,
254
- 'col--group': isColGroup,
255
- 'col--ellipsis': hasEllipsis,
256
- 'fixed--hidden': fixedHiddenColumn,
257
- 'is--sortable': column.sortable,
258
- 'col--filter': !!column.filters,
259
- 'is--filter-active': hasFilter,
260
- 'col--current': currentColumn === column
261
- },
262
- headerClassName ? (XEUtils.isFunction(headerClassName) ? headerClassName(params) : headerClassName) : '',
263
- headerCellClassName ? (XEUtils.isFunction(headerCellClassName) ? headerCellClassName(params) : headerCellClassName) : ''
264
- ], colid, colspan: column.colSpan > 1 ? column.colSpan : null, rowspan: column.rowSpan > 1 ? column.rowSpan : null, style: headerCellStyle ? (XEUtils.isFunction(headerCellStyle) ? headerCellStyle(params) : headerCellStyle) : null }, thOns), { key: columnKey || columnOpts.useKey || isColGroup ? colid : $columnIndex }), [
265
- h('div', {
266
- class: ['vxe-cell', {
267
- 'c--title': showTitle,
268
- 'c--tooltip': showTooltip,
269
- 'c--ellipsis': showEllipsis
270
- }]
271
- }, column.renderHeader(params)),
272
- /**
273
- * 列宽拖动
274
- */
275
- !fixedHiddenColumn && !isColGroup && (XEUtils.isBoolean(column.resizable) ? column.resizable : (columnOpts.resizable || allResizable))
276
- ? h('div', {
277
- class: ['vxe-resizable', {
278
- 'is--line': !border || border === 'none'
279
- }],
280
- onMousedown: (evnt) => resizeMousedown(evnt, params)
281
- })
282
- : null
283
- ]);
284
- }).concat(scrollbarWidth
285
- ? [
286
- h('th', {
287
- class: 'vxe-header--gutter col--gutter'
288
- })
289
- ]
290
- : []));
291
- }))
300
+ }, renderHeads(headerGroups))
292
301
  ]),
293
302
  /**
294
303
  * 其他
@@ -299,6 +308,34 @@ export default defineComponent({
299
308
  })
300
309
  ]);
301
310
  };
311
+ watch(() => props.tableColumn, uploadColumn);
312
+ onMounted(() => {
313
+ nextTick(() => {
314
+ const { fixedType } = props;
315
+ const { internalData } = $xeTable;
316
+ const { elemStore } = internalData;
317
+ const prefix = `${fixedType || 'main'}-header-`;
318
+ elemStore[`${prefix}wrapper`] = refElem;
319
+ elemStore[`${prefix}table`] = refHeaderTable;
320
+ elemStore[`${prefix}colgroup`] = refHeaderColgroup;
321
+ elemStore[`${prefix}list`] = refHeaderTHead;
322
+ elemStore[`${prefix}xSpace`] = refHeaderXSpace;
323
+ elemStore[`${prefix}repair`] = refHeaderBorderRepair;
324
+ uploadColumn();
325
+ });
326
+ });
327
+ onUnmounted(() => {
328
+ const { fixedType } = props;
329
+ const { internalData } = $xeTable;
330
+ const { elemStore } = internalData;
331
+ const prefix = `${fixedType || 'main'}-header-`;
332
+ elemStore[`${prefix}wrapper`] = null;
333
+ elemStore[`${prefix}table`] = null;
334
+ elemStore[`${prefix}colgroup`] = null;
335
+ elemStore[`${prefix}list`] = null;
336
+ elemStore[`${prefix}xSpace`] = null;
337
+ elemStore[`${prefix}repair`] = null;
338
+ });
302
339
  return renderVN;
303
340
  }
304
341
  });
@@ -180,8 +180,12 @@ export default {
180
180
  cellConfig: Object,
181
181
  // 行配置信息
182
182
  rowConfig: Object,
183
- // 可拖拽配置项
183
+ // 已废弃,被 rowDragConfig 替换
184
184
  dragConfig: Object,
185
+ // 行拖拽排序配置项
186
+ rowDragConfig: Object,
187
+ // 列拖拽排序配置项
188
+ columnDragConfig: Object,
185
189
  // 列调整配置项
186
190
  resizableConfig: Object,
187
191
  // 序号配置项