vxe-table 3.12.9 → 3.12.10-beta.1

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 (90) hide show
  1. package/es/grid/src/grid.js +6 -1
  2. package/es/index.css +1 -1
  3. package/es/index.min.css +1 -1
  4. package/es/locale/lang/ko-KR.js +515 -515
  5. package/es/style.css +1 -1
  6. package/es/style.min.css +1 -1
  7. package/es/table/module/export/mixin.js +3 -3
  8. package/es/table/module/filter/mixin.js +3 -3
  9. package/es/table/module/keyboard/mixin.js +4 -4
  10. package/es/table/module/menu/mixin.js +2 -2
  11. package/es/table/module/validator/mixin.js +2 -2
  12. package/es/table/src/body.js +247 -351
  13. package/es/table/src/footer.js +135 -154
  14. package/es/table/src/header.js +120 -100
  15. package/es/table/src/methods.js +1192 -797
  16. package/es/table/src/props.js +9 -3
  17. package/es/table/src/table.js +187 -103
  18. package/es/table/src/util.js +16 -7
  19. package/es/table/style.css +146 -63
  20. package/es/table/style.min.css +1 -1
  21. package/es/ui/index.js +14 -4
  22. package/es/ui/src/log.js +1 -1
  23. package/es/vxe-table/style.css +146 -63
  24. package/es/vxe-table/style.min.css +1 -1
  25. package/lib/grid/src/grid.js +4 -1
  26. package/lib/grid/src/grid.min.js +1 -1
  27. package/lib/index.css +1 -1
  28. package/lib/index.min.css +1 -1
  29. package/lib/index.umd.js +1917 -1550
  30. package/lib/index.umd.min.js +1 -1
  31. package/lib/locale/lang/ko-KR.js +515 -515
  32. package/lib/locale/lang/ko-KR.min.js +1 -1
  33. package/lib/locale/lang/ko-KR.umd.js +515 -515
  34. package/lib/style.css +1 -1
  35. package/lib/style.min.css +1 -1
  36. package/lib/table/module/export/mixin.js +3 -3
  37. package/lib/table/module/export/mixin.min.js +1 -1
  38. package/lib/table/module/filter/mixin.js +4 -4
  39. package/lib/table/module/filter/mixin.min.js +1 -1
  40. package/lib/table/module/keyboard/mixin.js +5 -5
  41. package/lib/table/module/keyboard/mixin.min.js +1 -1
  42. package/lib/table/module/menu/mixin.js +2 -2
  43. package/lib/table/module/menu/mixin.min.js +1 -1
  44. package/lib/table/module/validator/mixin.js +2 -2
  45. package/lib/table/module/validator/mixin.min.js +1 -1
  46. package/lib/table/src/body.js +185 -365
  47. package/lib/table/src/body.min.js +1 -1
  48. package/lib/table/src/footer.js +124 -151
  49. package/lib/table/src/footer.min.js +1 -1
  50. package/lib/table/src/header.js +97 -74
  51. package/lib/table/src/header.min.js +1 -1
  52. package/lib/table/src/methods.js +1282 -840
  53. package/lib/table/src/methods.min.js +1 -1
  54. package/lib/table/src/props.js +9 -3
  55. package/lib/table/src/props.min.js +1 -1
  56. package/lib/table/src/table.js +171 -90
  57. package/lib/table/src/table.min.js +1 -1
  58. package/lib/table/src/util.js +17 -7
  59. package/lib/table/src/util.min.js +1 -1
  60. package/lib/table/style/style.css +146 -63
  61. package/lib/table/style/style.min.css +1 -1
  62. package/lib/ui/index.js +14 -4
  63. package/lib/ui/index.min.js +1 -1
  64. package/lib/ui/src/log.js +1 -1
  65. package/lib/ui/src/log.min.js +1 -1
  66. package/lib/vxe-table/style/style.css +146 -63
  67. package/lib/vxe-table/style/style.min.css +1 -1
  68. package/package.json +2 -2
  69. package/packages/grid/src/grid.ts +6 -1
  70. package/packages/locale/lang/ko-KR.ts +515 -515
  71. package/packages/table/module/export/mixin.ts +3 -3
  72. package/packages/table/module/filter/mixin.ts +3 -3
  73. package/packages/table/module/keyboard/mixin.ts +4 -4
  74. package/packages/table/module/menu/mixin.ts +2 -2
  75. package/packages/table/module/validator/mixin.ts +2 -2
  76. package/packages/table/src/body.ts +281 -427
  77. package/packages/table/src/footer.ts +148 -164
  78. package/packages/table/src/header.ts +135 -111
  79. package/packages/table/src/methods.ts +1271 -858
  80. package/packages/table/src/props.ts +9 -3
  81. package/packages/table/src/table.ts +195 -146
  82. package/packages/table/src/util.ts +17 -7
  83. package/packages/ui/index.ts +13 -3
  84. package/styles/components/table.scss +164 -74
  85. /package/es/{iconfont.1736414871619.ttf → iconfont.1736690657500.ttf} +0 -0
  86. /package/es/{iconfont.1736414871619.woff → iconfont.1736690657500.woff} +0 -0
  87. /package/es/{iconfont.1736414871619.woff2 → iconfont.1736690657500.woff2} +0 -0
  88. /package/lib/{iconfont.1736414871619.ttf → iconfont.1736690657500.ttf} +0 -0
  89. /package/lib/{iconfont.1736414871619.woff → iconfont.1736690657500.woff} +0 -0
  90. /package/lib/{iconfont.1736414871619.woff2 → iconfont.1736690657500.woff2} +0 -0
@@ -1,21 +1,13 @@
1
1
  import XEUtils from 'xe-utils';
2
- import { browse, getTpImg, isPx, isScale, hasClass, addClass, removeClass, getEventTargetNode, getPaddingTopBottomSize, setScrollTop, setScrollLeft, isNodeElement } from '../../ui/src/dom';
2
+ import { browse, getTpImg, isPx, isScale, hasClass, addClass, removeClass, getEventTargetNode, getPaddingTopBottomSize, setScrollTop, setScrollLeft } from '../../ui/src/dom';
3
3
  import { getLastZIndex, nextZIndex, hasChildrenList, getFuncText, isEnableConf, formatText, eqEmptyValue } from '../../ui/src/utils';
4
4
  import { VxeUI } from '../../ui';
5
5
  import Cell from './cell';
6
- import { getRowUniqueId, clearTableAllStatus, getRowkey, getRowid, rowToVisible, colToVisible, getCellValue, setCellValue, handleFieldOrColumn, toTreePathSeq, restoreScrollLocation, getRootColumn, getColReMinWidth } from './util';
6
+ import { getRowUniqueId, clearTableAllStatus, getRowkey, getRowid, rowToVisible, colToVisible, getCellValue, setCellValue, handleFieldOrColumn, toTreePathSeq, restoreScrollLocation, getRootColumn, getColReMinWidth, getRefElem } from './util';
7
7
  import { getSlotVNs } from '../../ui/src/vn';
8
8
  import { warnLog, errLog } from '../../ui/src/log';
9
9
  const { getConfig, getI18n, renderer, formats, interceptor, createEvent } = VxeUI;
10
10
  const customStorageKey = 'VXE_CUSTOM_STORE';
11
- // 获取所有的列,排除分组
12
- const getColumnList = (columns) => {
13
- const result = [];
14
- columns.forEach((column) => {
15
- result.push(...(column.children && column.children.length ? getColumnList(column.children) : [column]));
16
- });
17
- return result;
18
- };
19
11
  function eqCellValue(row1, row2, field) {
20
12
  const val1 = XEUtils.get(row1, field);
21
13
  const val2 = XEUtils.get(row2, field);
@@ -68,18 +60,20 @@ function handleReserveRow(_vm, reserveRowMap) {
68
60
  }
69
61
  function handleVirtualXVisible($xeTable) {
70
62
  const internalData = $xeTable;
71
- const { visibleColumn } = internalData;
72
- const tableBody = $xeTable.$refs.tableBody;
73
- const tableBodyElem = tableBody ? tableBody.$el : null;
74
- if (tableBodyElem) {
75
- const { scrollLeft, clientWidth } = tableBodyElem;
76
- const endWidth = scrollLeft + clientWidth;
63
+ const { elemStore, visibleColumn } = internalData;
64
+ const leftFixedWidth = $xeTable.computeLeftFixedWidth;
65
+ const rightFixedWidth = $xeTable.computeRightFixedWidth;
66
+ const bodyScrollElem = getRefElem(elemStore['main-body-scroll']);
67
+ if (bodyScrollElem) {
68
+ const { scrollLeft, clientWidth } = bodyScrollElem;
69
+ const startWidth = scrollLeft + leftFixedWidth;
70
+ const endWidth = scrollLeft + clientWidth - rightFixedWidth;
77
71
  let toVisibleIndex = -1;
78
72
  let cWidth = 0;
79
73
  let visibleSize = 0;
80
74
  for (let colIndex = 0, colLen = visibleColumn.length; colIndex < colLen; colIndex++) {
81
75
  cWidth += visibleColumn[colIndex].renderWidth;
82
- if (toVisibleIndex === -1 && scrollLeft < cWidth) {
76
+ if (toVisibleIndex === -1 && startWidth < cWidth) {
83
77
  toVisibleIndex = colIndex;
84
78
  }
85
79
  if (toVisibleIndex >= 0) {
@@ -89,14 +83,87 @@ function handleVirtualXVisible($xeTable) {
89
83
  }
90
84
  }
91
85
  }
92
- return { toVisibleIndex: Math.max(0, toVisibleIndex), visibleSize: Math.max(6, visibleSize) };
86
+ return { toVisibleIndex: Math.max(0, toVisibleIndex), visibleSize: Math.max(1, visibleSize) };
93
87
  }
94
88
  return { toVisibleIndex: 0, visibleSize: 6 };
95
89
  }
90
+ function handleCustomRestore($xeTable, storeData) {
91
+ const reactData = $xeTable;
92
+ const internalData = $xeTable;
93
+ let { collectColumn } = internalData;
94
+ const { resizableData, sortData, visibleData, fixedData } = storeData;
95
+ let hasCustomSort = false;
96
+ // 处理还原
97
+ if (resizableData || sortData || visibleData || fixedData) {
98
+ XEUtils.eachTree(collectColumn, (column, index, items, path, parentColumn) => {
99
+ const colKey = column.getKey();
100
+ // 支持一级
101
+ if (!parentColumn) {
102
+ if (fixedData && fixedData[colKey] !== undefined) {
103
+ column.fixed = fixedData[colKey];
104
+ }
105
+ if (sortData && XEUtils.isNumber(sortData[colKey])) {
106
+ hasCustomSort = true;
107
+ column.renderSortNumber = sortData[colKey];
108
+ }
109
+ }
110
+ if (resizableData && XEUtils.isNumber(resizableData[colKey])) {
111
+ column.resizeWidth = resizableData[colKey];
112
+ }
113
+ if (visibleData && XEUtils.isBoolean(visibleData[colKey])) {
114
+ column.visible = visibleData[colKey];
115
+ }
116
+ });
117
+ // 如果自定义了顺序
118
+ if (hasCustomSort) {
119
+ collectColumn = XEUtils.orderBy(collectColumn, 'renderSortNumber');
120
+ internalData.collectColumn = collectColumn;
121
+ internalData.tableFullColumn = getColumnList(collectColumn);
122
+ }
123
+ reactData.isCustomStatus = true;
124
+ }
125
+ else {
126
+ reactData.isCustomStatus = false;
127
+ }
128
+ }
129
+ /**
130
+ * 还原自定义列操作状态
131
+ */
132
+ function restoreCustomStorage($xeTable) {
133
+ const props = $xeTable;
134
+ const { customConfig } = props;
135
+ const tableId = $xeTable.computeTableId;
136
+ const customOpts = $xeTable.computeCustomOpts;
137
+ const { storage, restoreStore } = customOpts;
138
+ const isAllCustom = storage === true;
139
+ const storageOpts = isAllCustom ? {} : Object.assign({}, storage || {});
140
+ const isCustomResizable = isAllCustom || storageOpts.resizable;
141
+ const isCustomVisible = isAllCustom || storageOpts.visible;
142
+ const isCustomFixed = isAllCustom || storageOpts.fixed;
143
+ const isCustomSort = isAllCustom || storageOpts.sort;
144
+ if ((customConfig ? isEnableConf(customOpts) : customOpts.enabled) && (isCustomResizable || isCustomVisible || isCustomFixed || isCustomSort)) {
145
+ if (!tableId) {
146
+ errLog('vxe.error.reqProp', ['id']);
147
+ return;
148
+ }
149
+ const storeData = getCustomStorageMap(tableId);
150
+ if (restoreStore) {
151
+ return Promise.resolve(restoreStore({ id: tableId, type: 'restore', storeData })).then(storeData => {
152
+ if (!storeData) {
153
+ return;
154
+ }
155
+ return handleCustomRestore($xeTable, storeData);
156
+ }).catch(e => e);
157
+ }
158
+ else {
159
+ return handleCustomRestore($xeTable, storeData);
160
+ }
161
+ }
162
+ }
96
163
  /**
97
- * 更新数据列的 Map
98
- * 牺牲数据组装的耗时,用来换取使用过程中的流畅
99
- */
164
+ * 更新数据列的 Map
165
+ * 牺牲数据组装的耗时,用来换取使用过程中的流畅
166
+ */
100
167
  function cacheColumnMap($xeTable) {
101
168
  const props = $xeTable;
102
169
  const reactData = $xeTable;
@@ -129,7 +196,7 @@ function cacheColumnMap($xeTable) {
129
196
  fullColumnFieldData[field] = rest;
130
197
  }
131
198
  else {
132
- if (storage || isCrossDrag || isSelfToChildDrag) {
199
+ if (storage || (columnOpts.drag && (isCrossDrag || isSelfToChildDrag))) {
133
200
  errLog('vxe.error.reqProp', [`${column.getTitle() || type || ''} -> column.field`]);
134
201
  }
135
202
  }
@@ -262,12 +329,323 @@ function handleVirtualTreeToList($xeTable) {
262
329
  }
263
330
  return internalData.afterFullData;
264
331
  }
332
+ function updateStyle($xeTable) {
333
+ const props = $xeTable;
334
+ const reactData = $xeTable;
335
+ const internalData = $xeTable;
336
+ const { border, showOverflow: allColumnOverflow, showHeaderOverflow: allColumnHeaderOverflow, showFooterOverflow: allColumnFooterOverflow, mouseConfig, spanMethod, footerSpanMethod } = props;
337
+ const { isGroup, currentRow, tableColumn, scrollXLoad, scrollYLoad, scrollbarWidth, scrollbarHeight, columnStore, editStore, isAllOverflow, expandColumn } = reactData;
338
+ const { visibleColumn, fullColumnIdData, tableHeight, tableWidth, headerHeight, footerHeight, elemStore, customHeight, customMinHeight, customMaxHeight } = internalData;
339
+ const el = $xeTable.$refs.refElem;
340
+ if (!el) {
341
+ return;
342
+ }
343
+ const containerList = ['main', 'left', 'right'];
344
+ const emptyPlaceholderElem = $xeTable.$refs.refEmptyPlaceholder;
345
+ const cellOffsetWidth = $xeTable.computeCellOffsetWidth;
346
+ const mouseOpts = $xeTable.computeMouseOpts;
347
+ const bodyWrapperElem = getRefElem(elemStore['main-body-wrapper']);
348
+ const bodyTableElem = getRefElem(elemStore['main-body-table']);
349
+ if (emptyPlaceholderElem) {
350
+ emptyPlaceholderElem.style.top = `${headerHeight}px`;
351
+ emptyPlaceholderElem.style.height = bodyWrapperElem ? `${bodyWrapperElem.offsetHeight - scrollbarHeight}px` : '';
352
+ }
353
+ let bodyHeight = 0;
354
+ let bodyMaxHeight = 0;
355
+ const bodyMinHeight = customMinHeight - headerHeight - footerHeight - scrollbarHeight;
356
+ if (customMaxHeight) {
357
+ bodyMaxHeight = Math.max(bodyMinHeight, customMaxHeight - headerHeight - footerHeight - scrollbarHeight);
358
+ }
359
+ if (customHeight) {
360
+ bodyHeight = customHeight - headerHeight - footerHeight - scrollbarHeight;
361
+ }
362
+ if (!bodyHeight) {
363
+ if (bodyTableElem) {
364
+ bodyHeight = bodyTableElem.clientHeight;
365
+ }
366
+ }
367
+ if (bodyHeight) {
368
+ if (bodyMaxHeight) {
369
+ bodyHeight = Math.min(bodyMaxHeight, bodyHeight);
370
+ }
371
+ bodyHeight = Math.max(bodyMinHeight, bodyHeight);
372
+ }
373
+ const scrollXVirtualEl = $xeTable.$refs.refScrollXVirtualElem;
374
+ if (scrollXVirtualEl) {
375
+ scrollXVirtualEl.style.height = `${scrollbarHeight}px`;
376
+ scrollXVirtualEl.style.visibility = scrollbarHeight ? 'visible' : 'hidden';
377
+ }
378
+ const xHandleEl = $xeTable.$refs.refScrollXHandleElem;
379
+ if (xHandleEl) {
380
+ xHandleEl.style.width = `${el.clientWidth - scrollbarWidth}px`;
381
+ }
382
+ const xRightCornerEl = $xeTable.$refs.refScrollXRightCornerElem;
383
+ if (xRightCornerEl) {
384
+ xRightCornerEl.style.width = `${scrollbarWidth}px`;
385
+ xRightCornerEl.style.display = scrollbarWidth && scrollbarHeight ? 'block' : '';
386
+ }
387
+ const scrollYVirtualEl = $xeTable.$refs.refScrollYVirtualElem;
388
+ if (scrollYVirtualEl) {
389
+ scrollYVirtualEl.style.width = `${scrollbarWidth}px`;
390
+ scrollYVirtualEl.style.height = `${bodyHeight + headerHeight + footerHeight}px`;
391
+ scrollYVirtualEl.style.visibility = scrollbarWidth ? 'visible' : 'hidden';
392
+ }
393
+ const yTopCornerEl = $xeTable.$refs.refScrollYTopCornerElem;
394
+ if (yTopCornerEl) {
395
+ yTopCornerEl.style.height = `${headerHeight}px`;
396
+ yTopCornerEl.style.display = headerHeight ? 'block' : '';
397
+ }
398
+ const yHandleEl = $xeTable.$refs.refScrollYHandleElem;
399
+ if (yHandleEl) {
400
+ yHandleEl.style.height = `${bodyHeight}px`;
401
+ yHandleEl.style.top = `${headerHeight}px`;
402
+ }
403
+ const yBottomCornerEl = $xeTable.$refs.refScrollYBottomCornerElem;
404
+ if (yBottomCornerEl) {
405
+ yBottomCornerEl.style.height = `${footerHeight}px`;
406
+ yBottomCornerEl.style.top = `${headerHeight + bodyHeight}px`;
407
+ yBottomCornerEl.style.display = footerHeight ? 'block' : '';
408
+ }
409
+ containerList.forEach((name, index) => {
410
+ const fixedType = index > 0 ? name : '';
411
+ const layoutList = ['header', 'body', 'footer'];
412
+ const isFixedLeft = fixedType === 'left';
413
+ let fixedColumn = [];
414
+ let fixedWrapperElem;
415
+ if (fixedType) {
416
+ fixedColumn = isFixedLeft ? columnStore.leftList : columnStore.rightList;
417
+ fixedWrapperElem = (isFixedLeft ? $xeTable.$refs.refLeftContainer : $xeTable.$refs.refRightContainer);
418
+ }
419
+ layoutList.forEach(layout => {
420
+ const wrapperElem = getRefElem(elemStore[`${name}-${layout}-wrapper`]);
421
+ const currScrollElem = getRefElem(elemStore[`${name}-${layout}-scroll`]);
422
+ const tableElem = getRefElem(elemStore[`${name}-${layout}-table`]);
423
+ if (layout === 'header') {
424
+ // 表头体样式处理
425
+ // 横向滚动渲染
426
+ let tWidth = tableWidth;
427
+ let renderColumnList = tableColumn;
428
+ let isOptimizeMode = false;
429
+ if (isGroup) {
430
+ renderColumnList = visibleColumn;
431
+ if (fixedType) {
432
+ if (wrapperElem) {
433
+ wrapperElem.style.width = tWidth ? `${tWidth}px` : '';
434
+ }
435
+ }
436
+ }
437
+ else {
438
+ // 如果是使用优化模式
439
+ if (scrollXLoad || scrollYLoad || allColumnHeaderOverflow) {
440
+ if (spanMethod || footerSpanMethod) {
441
+ // 如果不支持优化模式
442
+ }
443
+ else {
444
+ isOptimizeMode = true;
445
+ }
446
+ }
447
+ if (fixedType) {
448
+ renderColumnList = visibleColumn;
449
+ // 如果是使用优化模式
450
+ if (isOptimizeMode) {
451
+ renderColumnList = fixedColumn || [];
452
+ }
453
+ if (!isOptimizeMode) {
454
+ if (wrapperElem) {
455
+ wrapperElem.style.width = tWidth ? `${tWidth}px` : '';
456
+ }
457
+ }
458
+ }
459
+ }
460
+ tWidth = renderColumnList.reduce((previous, column) => previous + column.renderWidth, 0);
461
+ if (currScrollElem) {
462
+ currScrollElem.style.height = `${headerHeight}px`;
463
+ }
464
+ if (tableElem) {
465
+ tableElem.style.width = tWidth ? `${tWidth}px` : '';
466
+ }
467
+ const repairElem = getRefElem(elemStore[`${name}-${layout}-repair`]);
468
+ if (repairElem) {
469
+ repairElem.style.width = `${tableWidth}px`;
470
+ }
471
+ const listElem = getRefElem(elemStore[`${name}-${layout}-list`]);
472
+ if (isGroup && listElem) {
473
+ XEUtils.arrayEach(listElem.querySelectorAll('.col--group'), (thElem) => {
474
+ const colNode = $xeTable.getColumnNode(thElem);
475
+ if (colNode) {
476
+ const column = colNode.item;
477
+ const { showHeaderOverflow } = column;
478
+ const cellOverflow = XEUtils.isBoolean(showHeaderOverflow) ? showHeaderOverflow : allColumnHeaderOverflow;
479
+ const showEllipsis = cellOverflow === 'ellipsis';
480
+ const showTitle = cellOverflow === 'title';
481
+ const showTooltip = cellOverflow === true || cellOverflow === 'tooltip';
482
+ const hasEllipsis = showTitle || showTooltip || showEllipsis;
483
+ let childWidth = 0;
484
+ let countChild = 0;
485
+ if (hasEllipsis) {
486
+ XEUtils.eachTree(column.children, (item) => {
487
+ if (!item.children || !column.children.length) {
488
+ countChild++;
489
+ }
490
+ childWidth += item.renderWidth;
491
+ }, { children: 'children' });
492
+ }
493
+ thElem.style.width = hasEllipsis ? `${childWidth - countChild - (border ? 2 : 0)}px` : '';
494
+ }
495
+ });
496
+ }
497
+ }
498
+ else if (layout === 'body') {
499
+ if (currScrollElem) {
500
+ currScrollElem.style.maxHeight = customMaxHeight ? `${bodyMaxHeight}px` : '';
501
+ currScrollElem.style.height = customHeight ? `${bodyHeight}px` : '';
502
+ currScrollElem.style.minHeight = `${bodyMinHeight}px`;
503
+ }
504
+ // 如果是固定列
505
+ if (fixedWrapperElem) {
506
+ if (wrapperElem) {
507
+ wrapperElem.style.top = `${headerHeight}px`;
508
+ }
509
+ fixedWrapperElem.style.height = `${customHeight > 0 ? customHeight : (tableHeight + headerHeight + footerHeight + scrollbarHeight)}px`;
510
+ fixedWrapperElem.style.width = `${fixedColumn.reduce((previous, column) => previous + column.renderWidth, 0)}px`;
511
+ }
512
+ let tWidth = tableWidth;
513
+ let renderColumnList = tableColumn;
514
+ let isOptimizeMode = false;
515
+ // 如果是使用优化模式
516
+ if (scrollXLoad || scrollYLoad || (allColumnOverflow && isAllOverflow)) {
517
+ if (expandColumn || spanMethod || footerSpanMethod) {
518
+ // 如果不支持优化模式
519
+ }
520
+ else {
521
+ isOptimizeMode = true;
522
+ }
523
+ }
524
+ if (fixedType) {
525
+ renderColumnList = visibleColumn;
526
+ if (isOptimizeMode) {
527
+ renderColumnList = fixedColumn || [];
528
+ }
529
+ if (!isOptimizeMode) {
530
+ if (wrapperElem) {
531
+ wrapperElem.style.width = tWidth ? `${tWidth}px` : '';
532
+ }
533
+ }
534
+ }
535
+ tWidth = renderColumnList.reduce((previous, column) => previous + column.renderWidth, 0);
536
+ if (tableElem) {
537
+ tableElem.style.width = tWidth ? `${tWidth}px` : '';
538
+ // 兼容性处理
539
+ tableElem.style.paddingRight = scrollbarWidth && fixedType && (browse['-moz'] || browse.safari) ? `${scrollbarWidth}px` : '';
540
+ }
541
+ const emptyBlockElem = getRefElem(elemStore[`${name}-${layout}-emptyBlock`]);
542
+ if (emptyBlockElem) {
543
+ emptyBlockElem.style.width = tWidth ? `${tWidth}px` : '';
544
+ }
545
+ }
546
+ else if (layout === 'footer') {
547
+ let tWidth = tableWidth;
548
+ let renderColumnList = tableColumn;
549
+ let isOptimizeMode = false;
550
+ // 如果是使用优化模式
551
+ if (scrollXLoad || scrollYLoad || allColumnFooterOverflow) {
552
+ if (spanMethod || footerSpanMethod) {
553
+ // 如果不支持优化模式
554
+ }
555
+ else {
556
+ isOptimizeMode = true;
557
+ }
558
+ }
559
+ if (fixedType) {
560
+ renderColumnList = visibleColumn;
561
+ if (isOptimizeMode) {
562
+ renderColumnList = fixedColumn || [];
563
+ }
564
+ if (!isOptimizeMode) {
565
+ if (wrapperElem) {
566
+ wrapperElem.style.width = tWidth ? `${tWidth}px` : '';
567
+ }
568
+ }
569
+ }
570
+ tWidth = renderColumnList.reduce((previous, column) => previous + column.renderWidth, 0);
571
+ if (currScrollElem) {
572
+ currScrollElem.style.height = `${footerHeight}px`;
573
+ // 如果是固定列
574
+ if (fixedWrapperElem) {
575
+ if (wrapperElem) {
576
+ wrapperElem.style.top = `${customHeight > 0 ? customHeight - footerHeight - scrollbarHeight : tableHeight + headerHeight}px`;
577
+ }
578
+ }
579
+ }
580
+ if (tableElem) {
581
+ tableElem.style.width = tWidth ? `${tWidth}px` : '';
582
+ }
583
+ }
584
+ const colgroupElem = getRefElem(elemStore[`${name}-${layout}-colgroup`]);
585
+ if (colgroupElem) {
586
+ XEUtils.arrayEach(colgroupElem.children, (colElem) => {
587
+ const colid = colElem.getAttribute('name');
588
+ if (fullColumnIdData[colid]) {
589
+ const colRest = fullColumnIdData[colid];
590
+ const column = colRest.column;
591
+ const { showHeaderOverflow, showFooterOverflow, showOverflow } = column;
592
+ let cellOverflow;
593
+ colElem.style.width = `${column.renderWidth}px`;
594
+ if (layout === 'header') {
595
+ cellOverflow = XEUtils.isUndefined(showHeaderOverflow) || XEUtils.isNull(showHeaderOverflow) ? allColumnHeaderOverflow : showHeaderOverflow;
596
+ }
597
+ else if (layout === 'footer') {
598
+ cellOverflow = XEUtils.isUndefined(showFooterOverflow) || XEUtils.isNull(showFooterOverflow) ? allColumnFooterOverflow : showFooterOverflow;
599
+ }
600
+ else {
601
+ cellOverflow = XEUtils.isUndefined(showOverflow) || XEUtils.isNull(showOverflow) ? allColumnOverflow : showOverflow;
602
+ }
603
+ const showEllipsis = cellOverflow === 'ellipsis';
604
+ const showTitle = cellOverflow === 'title';
605
+ const showTooltip = cellOverflow === true || cellOverflow === 'tooltip';
606
+ let hasEllipsis = showTitle || showTooltip || showEllipsis;
607
+ const listElem = getRefElem(elemStore[`${name}-${layout}-list`]);
608
+ // 纵向虚拟滚动不支持动态行高
609
+ if (scrollYLoad && !hasEllipsis) {
610
+ hasEllipsis = true;
611
+ }
612
+ if (listElem) {
613
+ XEUtils.arrayEach(listElem.querySelectorAll(`.${column.id}`), (elem) => {
614
+ const colspan = parseInt(elem.getAttribute('colspan') || 1);
615
+ const cellElem = elem.querySelector('.vxe-cell');
616
+ let colWidth = column.renderWidth;
617
+ if (cellElem) {
618
+ if (colspan > 1) {
619
+ const columnIndex = $xeTable.getColumnIndex(column);
620
+ for (let index = 1; index < colspan; index++) {
621
+ const nextColumn = $xeTable.getColumns(columnIndex + index);
622
+ if (nextColumn) {
623
+ colWidth += nextColumn.renderWidth;
624
+ }
625
+ }
626
+ }
627
+ cellElem.style.width = hasEllipsis ? `${colWidth - (cellOffsetWidth * colspan)}px` : '';
628
+ }
629
+ });
630
+ }
631
+ }
632
+ });
633
+ }
634
+ });
635
+ });
636
+ if (currentRow) {
637
+ $xeTable.setCurrentRow(currentRow);
638
+ }
639
+ if (mouseConfig && mouseOpts.selected && editStore.selected.row && editStore.selected.column) {
640
+ $xeTable.addCellSelectedClass();
641
+ }
642
+ return $xeTable.$nextTick();
643
+ }
265
644
  function computeRowHeight($xeTable) {
266
- const tableHeader = $xeTable.$refs.tableHeader;
267
- const tableBody = $xeTable.$refs.tableBody;
645
+ const tableHeader = $xeTable.$refs.refTableHeader;
646
+ const tableBody = $xeTable.$refs.refTableBody;
268
647
  const tableBodyElem = tableBody ? tableBody.$el : null;
269
- const vSize = $xeTable.computeSize;
270
- const rowHeightMaps = $xeTable.computeRowHeightMaps;
648
+ const defaultRowHeight = $xeTable.computeDefaultRowHeight;
271
649
  let rowHeight = 0;
272
650
  if (tableBodyElem) {
273
651
  const tableHeaderElem = tableHeader ? tableHeader.$el : null;
@@ -281,21 +659,21 @@ function computeRowHeight($xeTable) {
281
659
  }
282
660
  }
283
661
  if (!rowHeight) {
284
- rowHeight = rowHeightMaps[vSize || 'default'];
662
+ rowHeight = defaultRowHeight;
285
663
  }
286
664
  // 最低支持 18px 行高
287
665
  return Math.max(18, rowHeight);
288
666
  }
289
667
  function handleVirtualYVisible($xeTable) {
290
668
  const props = $xeTable;
669
+ const reactData = $xeTable;
291
670
  const internalData = $xeTable;
292
671
  const { showOverflow } = props;
293
- const { scrollYStore, afterFullData, fullAllDataRowIdData } = internalData;
294
- const tableBody = $xeTable.$refs.tableBody;
295
- const tableBodyElem = tableBody ? tableBody.$el : null;
296
- const { rowHeight } = scrollYStore;
297
- if (tableBodyElem) {
298
- const { scrollTop, clientHeight } = tableBodyElem;
672
+ const { rowHeight } = reactData;
673
+ const { elemStore, afterFullData, fullAllDataRowIdData } = internalData;
674
+ const bodyScrollElem = getRefElem(elemStore['main-body-scroll']);
675
+ if (bodyScrollElem) {
676
+ const { scrollTop, clientHeight } = bodyScrollElem;
299
677
  const endHeight = scrollTop + clientHeight;
300
678
  let toVisibleIndex = -1;
301
679
  let offsetTop = 0;
@@ -321,9 +699,9 @@ function handleVirtualYVisible($xeTable) {
321
699
  }
322
700
  }
323
701
  }
324
- return { toVisibleIndex: Math.max(0, toVisibleIndex), visibleSize: Math.max(8, visibleSize) };
702
+ return { toVisibleIndex: Math.max(0, toVisibleIndex), visibleSize: Math.max(6, visibleSize) };
325
703
  }
326
- return { toVisibleIndex: 0, visibleSize: 8 };
704
+ return { toVisibleIndex: 0, visibleSize: 6 };
327
705
  }
328
706
  function calculateMergerOffsetIndex(list, offsetItem, type) {
329
707
  for (let mcIndex = 0, len = list.length; mcIndex < len; mcIndex++) {
@@ -457,18 +835,24 @@ function autoCellWidth($xeTable) {
457
835
  const props = $xeTable;
458
836
  const reactData = $xeTable;
459
837
  const internalData = $xeTable;
460
- const tableHeader = $xeTable.$refs.tableHeader;
461
- const tableBody = $xeTable.$refs.tableBody;
462
- const tableFooter = $xeTable.$refs.tableFooter;
838
+ const { elemStore } = internalData;
839
+ const scrollbarOpts = $xeTable.computeScrollbarOpts;
840
+ const tableBody = $xeTable.$refs.refTableBody;
463
841
  const bodyElem = tableBody ? tableBody.$el : null;
464
- const headerElem = tableHeader ? tableHeader.$el : null;
465
- const footerElem = tableFooter ? tableFooter.$el : null;
466
842
  if (!bodyElem) {
467
843
  return;
468
844
  }
845
+ const yHandleEl = $xeTable.$refs.refScrollYHandleElem;
846
+ if (!yHandleEl) {
847
+ return;
848
+ }
849
+ const xHandleEl = $xeTable.$refs.refScrollXHandleElem;
850
+ if (!xHandleEl) {
851
+ return;
852
+ }
469
853
  let tableWidth = 0;
470
854
  const minCellWidth = 40; // 列宽最少限制 40px
471
- const bodyWidth = bodyElem.clientWidth - 1;
855
+ const bodyWidth = bodyElem.clientWidth;
472
856
  let remainWidth = bodyWidth;
473
857
  let meanWidth = remainWidth / 100;
474
858
  const { fit } = props;
@@ -537,16 +921,16 @@ function autoCellWidth($xeTable) {
537
921
  });
538
922
  if (fit) {
539
923
  /**
540
- * 偏移量算法
541
- * 如果所有列足够放的情况下,从最后动态列开始分配
542
- */
924
+ * 偏移量算法
925
+ * 如果所有列足够放的情况下,从最后动态列开始分配
926
+ */
543
927
  const dynamicList = scaleList.concat(scaleMinList).concat(pxMinList).concat(autoMinList).concat(remainList);
544
928
  let dynamicSize = dynamicList.length - 1;
545
929
  if (dynamicSize > 0) {
546
- let odiffer = bodyWidth - tableWidth;
547
- if (odiffer > 0) {
548
- while (odiffer > 0 && dynamicSize >= 0) {
549
- odiffer--;
930
+ let i = bodyWidth - tableWidth;
931
+ if (i > 0) {
932
+ while (i > 0 && dynamicSize >= 0) {
933
+ i--;
550
934
  dynamicList[dynamicSize--].renderWidth++;
551
935
  }
552
936
  tableWidth = bodyWidth;
@@ -554,41 +938,20 @@ function autoCellWidth($xeTable) {
554
938
  }
555
939
  }
556
940
  const tableHeight = bodyElem.offsetHeight;
557
- const overflowY = bodyElem.scrollHeight > bodyElem.clientHeight;
558
- let scrollbarWidth = 0;
559
- if (overflowY) {
560
- scrollbarWidth = Math.max(bodyElem.offsetWidth - bodyElem.clientWidth, 0);
561
- }
562
- reactData.scrollbarWidth = scrollbarWidth;
941
+ const overflowY = yHandleEl.scrollHeight > yHandleEl.clientHeight;
942
+ reactData.scrollbarWidth = overflowY ? Math.max(scrollbarOpts.width || 0, yHandleEl.offsetWidth - yHandleEl.clientWidth) : 0;
563
943
  reactData.overflowY = overflowY;
564
944
  internalData.tableWidth = tableWidth;
565
945
  internalData.tableHeight = tableHeight;
566
- let headerHeight = 0;
567
- if (headerElem) {
568
- headerHeight = headerElem.clientHeight;
569
- $xeTable.$nextTick(() => {
570
- // 检测是否同步滚动
571
- if (headerElem && bodyElem && headerElem.scrollLeft !== bodyElem.scrollLeft) {
572
- headerElem.scrollLeft = bodyElem.scrollLeft;
573
- }
574
- });
575
- }
946
+ const headerTableElem = getRefElem(elemStore['main-header-table']);
947
+ const footerTableElem = getRefElem(elemStore['main-footer-table']);
948
+ const headerHeight = headerTableElem ? headerTableElem.clientHeight : 0;
949
+ const overflowX = tableWidth > bodyWidth;
950
+ const footerHeight = footerTableElem ? footerTableElem.clientHeight : 0;
951
+ reactData.scrollbarHeight = overflowX ? Math.max(scrollbarOpts.height || 0, xHandleEl.offsetHeight - xHandleEl.clientHeight) : 0;
576
952
  internalData.headerHeight = headerHeight;
577
- let overflowX = false;
578
- let footerHeight = 0;
579
- let scrollbarHeight = 0;
580
- if (footerElem) {
581
- footerHeight = footerElem.offsetHeight;
582
- overflowX = tableWidth > footerElem.clientWidth;
583
- scrollbarHeight = Math.max(footerHeight - footerElem.clientHeight, 0);
584
- }
585
- else {
586
- overflowX = tableWidth > bodyWidth;
587
- scrollbarHeight = Math.max(tableHeight - bodyElem.clientHeight, 0);
588
- }
589
953
  internalData.footerHeight = footerHeight;
590
954
  reactData.overflowX = overflowX;
591
- reactData.scrollbarHeight = scrollbarHeight;
592
955
  updateHeight($xeTable);
593
956
  reactData.parentHeight = Math.max(internalData.headerHeight + footerHeight + 20, $xeTable.getParentHeight());
594
957
  if (overflowX) {
@@ -802,9 +1165,9 @@ function showDropTip($xeTable, evnt, trEl, thEl, showLine, dragPos) {
802
1165
  const cdLineEl = $xeTable.$refs.refDragColLineElem;
803
1166
  if (cdLineEl) {
804
1167
  if (showLine) {
805
- const leftContainerElem = $xeTable.$refs.leftContainer;
1168
+ const leftContainerElem = $xeTable.$refs.refLeftContainer;
806
1169
  const leftContainerWidth = leftContainerElem ? leftContainerElem.clientWidth : 0;
807
- const rightContainerElem = $xeTable.$refs.rightContainer;
1170
+ const rightContainerElem = $xeTable.$refs.refRightContainer;
808
1171
  const rightContainerWidth = rightContainerElem ? rightContainerElem.clientWidth : 0;
809
1172
  const thRect = thEl.getBoundingClientRect();
810
1173
  let thWidth = thEl.clientWidth;
@@ -879,11 +1242,14 @@ function computeScrollLoad($xeTable) {
879
1242
  const sXOpts = $xeTable.computeSXOpts;
880
1243
  // 计算 X 逻辑
881
1244
  if (scrollXLoad) {
882
- const { visibleSize: visibleXSize } = handleVirtualXVisible($xeTable);
883
- const offsetXSize = Math.max(0, sXOpts.oSize ? XEUtils.toNumber(sXOpts.oSize) : (browse.edge ? 5 : 0));
1245
+ const { toVisibleIndex: toXVisibleIndex, visibleSize: visibleXSize } = handleVirtualXVisible($xeTable);
1246
+ const offsetXSize = Math.max(0, sXOpts.oSize ? XEUtils.toNumber(sXOpts.oSize) : 0);
1247
+ scrollXStore.preloadSize = 4;
884
1248
  scrollXStore.offsetSize = offsetXSize;
885
1249
  scrollXStore.visibleSize = visibleXSize;
886
1250
  scrollXStore.endIndex = Math.max(scrollXStore.startIndex + scrollXStore.visibleSize + offsetXSize, scrollXStore.endIndex);
1251
+ scrollXStore.visibleStartIndex = Math.max(scrollXStore.startIndex, toXVisibleIndex);
1252
+ scrollXStore.visibleEndIndex = Math.min(scrollXStore.endIndex, toXVisibleIndex + visibleXSize);
887
1253
  $xeTable.updateScrollXData().then(() => {
888
1254
  loadScrollXData($xeTable);
889
1255
  });
@@ -896,12 +1262,15 @@ function computeScrollLoad($xeTable) {
896
1262
  const rowHeight = computeRowHeight($xeTable);
897
1263
  scrollYStore.rowHeight = rowHeight;
898
1264
  reactData.rowHeight = rowHeight;
899
- const { visibleSize: visibleYSize } = handleVirtualYVisible($xeTable);
1265
+ const { toVisibleIndex: toYVisibleIndex, visibleSize: visibleYSize } = handleVirtualYVisible($xeTable);
900
1266
  if (scrollYLoad) {
901
- const offsetYSize = Math.max(0, sYOpts.oSize ? XEUtils.toNumber(sYOpts.oSize) : (browse.edge ? 10 : 0));
1267
+ const offsetYSize = Math.max(0, sYOpts.oSize ? XEUtils.toNumber(sYOpts.oSize) : 0);
1268
+ scrollYStore.preloadSize = 2;
902
1269
  scrollYStore.offsetSize = offsetYSize;
903
1270
  scrollYStore.visibleSize = visibleYSize;
904
1271
  scrollYStore.endIndex = Math.max(scrollYStore.startIndex + visibleYSize + offsetYSize, scrollYStore.endIndex);
1272
+ scrollYStore.visibleStartIndex = Math.max(scrollYStore.startIndex, toYVisibleIndex);
1273
+ scrollYStore.visibleEndIndex = Math.min(scrollYStore.endIndex, toYVisibleIndex + visibleYSize);
905
1274
  $xeTable.updateScrollYData().then(() => {
906
1275
  loadScrollYData($xeTable);
907
1276
  });
@@ -910,7 +1279,7 @@ function computeScrollLoad($xeTable) {
910
1279
  $xeTable.updateScrollYSpace();
911
1280
  }
912
1281
  $xeTable.$nextTick(() => {
913
- $xeTable.updateStyle();
1282
+ updateStyle($xeTable);
914
1283
  });
915
1284
  });
916
1285
  }
@@ -933,17 +1302,42 @@ function handleRecalculateLayout($xeTable, reFull) {
933
1302
  }
934
1303
  });
935
1304
  }
1305
+ function handleTableColumn($xeTable) {
1306
+ const reactData = $xeTable;
1307
+ const internalData = $xeTable;
1308
+ const { scrollXLoad } = reactData;
1309
+ const { visibleColumn, scrollXStore, fullColumnIdData } = internalData;
1310
+ const tableColumn = scrollXLoad ? visibleColumn.slice(scrollXStore.startIndex, scrollXStore.endIndex) : visibleColumn.slice(0);
1311
+ tableColumn.forEach((column, $index) => {
1312
+ const colid = column.id;
1313
+ const colRest = fullColumnIdData[colid];
1314
+ if (colRest) {
1315
+ colRest.$index = $index;
1316
+ }
1317
+ });
1318
+ reactData.tableColumn = tableColumn;
1319
+ }
1320
+ function handleUpdateColumn($xeTable) {
1321
+ const internalData = $xeTable;
1322
+ const columnList = XEUtils.orderBy(internalData.collectColumn, 'renderSortNumber');
1323
+ internalData.collectColumn = columnList;
1324
+ const tableFullColumn = getColumnList(columnList);
1325
+ internalData.tableFullColumn = tableFullColumn;
1326
+ cacheColumnMap($xeTable);
1327
+ }
936
1328
  function loadScrollXData($xeTable) {
937
1329
  const reactData = $xeTable;
938
1330
  const internalData = $xeTable;
939
1331
  const { mergeList, mergeFooterList } = reactData;
940
1332
  const { scrollXStore } = internalData;
941
- const { startIndex, endIndex, offsetSize } = scrollXStore;
1333
+ const { preloadSize, startIndex, endIndex, offsetSize } = scrollXStore;
942
1334
  const { toVisibleIndex, visibleSize } = handleVirtualXVisible($xeTable);
943
1335
  const offsetItem = {
944
- startIndex: Math.max(0, toVisibleIndex - 1 - offsetSize),
945
- endIndex: toVisibleIndex + visibleSize + offsetSize
1336
+ startIndex: Math.max(0, toVisibleIndex - 1 - offsetSize - preloadSize),
1337
+ endIndex: toVisibleIndex + visibleSize + offsetSize + preloadSize
946
1338
  };
1339
+ scrollXStore.visibleStartIndex = toVisibleIndex;
1340
+ scrollXStore.visibleEndIndex = toVisibleIndex + visibleSize;
947
1341
  calculateMergerOffsetIndex(mergeList.concat(mergeFooterList), offsetItem, 'col');
948
1342
  const { startIndex: offsetStartIndex, endIndex: offsetEndIndex } = offsetItem;
949
1343
  if (toVisibleIndex <= startIndex || toVisibleIndex >= endIndex - visibleSize - 1) {
@@ -955,6 +1349,198 @@ function loadScrollXData($xeTable) {
955
1349
  }
956
1350
  $xeTable.closeTooltip();
957
1351
  }
1352
+ // 获取所有的列,排除分组
1353
+ function getColumnList(columns) {
1354
+ const result = [];
1355
+ columns.forEach((column) => {
1356
+ result.push(...(column.children && column.children.length ? getColumnList(column.children) : [column]));
1357
+ });
1358
+ return result;
1359
+ }
1360
+ function parseColumns($xeTable, isReset) {
1361
+ const props = $xeTable;
1362
+ const reactData = $xeTable;
1363
+ const internalData = $xeTable;
1364
+ const { showOverflow } = props;
1365
+ const rowOpts = $xeTable.computeRowOpts;
1366
+ const leftList = [];
1367
+ const centerList = [];
1368
+ const rightList = [];
1369
+ const { isGroup, columnStore } = reactData;
1370
+ const sXOpts = $xeTable.computeSXOpts;
1371
+ const { collectColumn, tableFullColumn, scrollXStore, fullColumnIdData } = internalData;
1372
+ // 如果是分组表头,如果子列全部被隐藏,则根列也隐藏
1373
+ if (isGroup) {
1374
+ const leftGroupList = [];
1375
+ const centerGroupList = [];
1376
+ const rightGroupList = [];
1377
+ XEUtils.eachTree(collectColumn, (column, index, items, path, parentColumn) => {
1378
+ const isColGroup = hasChildrenList(column);
1379
+ // 如果是分组,必须按组设置固定列,不允许给子列设置固定
1380
+ if (parentColumn && parentColumn.fixed) {
1381
+ column.fixed = parentColumn.fixed;
1382
+ }
1383
+ if (parentColumn && column.fixed !== parentColumn.fixed) {
1384
+ errLog('vxe.error.groupFixed');
1385
+ }
1386
+ if (isColGroup) {
1387
+ column.visible = !!XEUtils.findTree(column.children, (subColumn) => hasChildrenList(subColumn) ? false : subColumn.visible);
1388
+ }
1389
+ else if (column.visible) {
1390
+ if (column.fixed === 'left') {
1391
+ leftList.push(column);
1392
+ }
1393
+ else if (column.fixed === 'right') {
1394
+ rightList.push(column);
1395
+ }
1396
+ else {
1397
+ centerList.push(column);
1398
+ }
1399
+ }
1400
+ });
1401
+ collectColumn.forEach((column) => {
1402
+ if (column.visible) {
1403
+ if (column.fixed === 'left') {
1404
+ leftGroupList.push(column);
1405
+ }
1406
+ else if (column.fixed === 'right') {
1407
+ rightGroupList.push(column);
1408
+ }
1409
+ else {
1410
+ centerGroupList.push(column);
1411
+ }
1412
+ }
1413
+ });
1414
+ reactData.tableGroupColumn = leftGroupList.concat(centerGroupList).concat(rightGroupList);
1415
+ }
1416
+ else {
1417
+ // 重新分配列
1418
+ tableFullColumn.forEach((column) => {
1419
+ if (column.visible) {
1420
+ if (column.fixed === 'left') {
1421
+ leftList.push(column);
1422
+ }
1423
+ else if (column.fixed === 'right') {
1424
+ rightList.push(column);
1425
+ }
1426
+ else {
1427
+ centerList.push(column);
1428
+ }
1429
+ }
1430
+ });
1431
+ }
1432
+ const visibleColumn = leftList.concat(centerList).concat(rightList);
1433
+ // 如果gt为0,则总是启用
1434
+ const scrollXLoad = !!sXOpts.enabled && sXOpts.gt > -1 && (sXOpts.gt === 0 || sXOpts.gt < tableFullColumn.length);
1435
+ reactData.hasFixedColumn = leftList.length > 0 || rightList.length > 0;
1436
+ Object.assign(columnStore, { leftList, centerList, rightList });
1437
+ if (scrollXLoad) {
1438
+ if (showOverflow) {
1439
+ if (!rowOpts.height) {
1440
+ const errColumn = internalData.tableFullColumn.find(column => column.showOverflow === false);
1441
+ if (errColumn) {
1442
+ errLog('vxe.error.errProp', [`column[field="${errColumn.field}"].show-overflow=false`, 'show-overflow=true']);
1443
+ }
1444
+ }
1445
+ }
1446
+ if (process.env.NODE_ENV === 'development') {
1447
+ // if (props.showHeader && !props.showHeaderOverflow) {
1448
+ // warnLog('vxe.error.reqProp', ['show-header-overflow'])
1449
+ // }
1450
+ // if (props.showFooter && !props.showFooterOverflow) {
1451
+ // warnLog('vxe.error.reqProp', ['show-footer-overflow'])
1452
+ // }
1453
+ if (props.spanMethod) {
1454
+ warnLog('vxe.error.scrollErrProp', ['span-method']);
1455
+ }
1456
+ if (props.footerSpanMethod) {
1457
+ warnLog('vxe.error.scrollErrProp', ['footer-span-method']);
1458
+ }
1459
+ }
1460
+ if (isReset) {
1461
+ const { visibleSize } = handleVirtualXVisible($xeTable);
1462
+ scrollXStore.startIndex = 0;
1463
+ scrollXStore.endIndex = visibleSize;
1464
+ scrollXStore.visibleSize = visibleSize;
1465
+ scrollXStore.visibleStartIndex = 0;
1466
+ scrollXStore.visibleEndIndex = visibleSize;
1467
+ }
1468
+ }
1469
+ // 如果列被显示/隐藏,则清除合并状态
1470
+ // 如果列被设置为固定,则清除合并状态
1471
+ if (visibleColumn.length !== internalData.visibleColumn.length || !internalData.visibleColumn.every((column, index) => column === visibleColumn[index])) {
1472
+ $xeTable.clearMergeCells();
1473
+ $xeTable.clearMergeFooterItems();
1474
+ }
1475
+ reactData.scrollXLoad = scrollXLoad;
1476
+ visibleColumn.forEach((column, index) => {
1477
+ const colid = column.id;
1478
+ const colRest = fullColumnIdData[colid];
1479
+ if (colRest) {
1480
+ colRest._index = index;
1481
+ }
1482
+ });
1483
+ internalData.visibleColumn = visibleColumn;
1484
+ handleTableColumn($xeTable);
1485
+ if (isReset) {
1486
+ return $xeTable.updateFooter().then(() => {
1487
+ return $xeTable.recalculate();
1488
+ }).then(() => {
1489
+ $xeTable.updateCellAreas();
1490
+ return $xeTable.recalculate();
1491
+ });
1492
+ }
1493
+ return $xeTable.updateFooter();
1494
+ }
1495
+ function initColumnSort($xeTable) {
1496
+ const internalData = $xeTable;
1497
+ const { collectColumn } = internalData;
1498
+ collectColumn.forEach((column, index) => {
1499
+ const sortIndex = index + 1;
1500
+ column.sortNumber = sortIndex;
1501
+ column.renderSortNumber = sortIndex;
1502
+ });
1503
+ }
1504
+ function handleColumn($xeTable, collectColumn) {
1505
+ const $xeToolbar = $xeTable.$refs.$xeToolbar;
1506
+ const reactData = $xeTable;
1507
+ const internalData = $xeTable;
1508
+ internalData.collectColumn = collectColumn;
1509
+ const tableFullColumn = getColumnList(collectColumn);
1510
+ internalData.tableFullColumn = tableFullColumn;
1511
+ reactData.isLoading = true;
1512
+ reactData.isDragColMove = false;
1513
+ initColumnSort($xeTable);
1514
+ return Promise.resolve(restoreCustomStorage($xeTable)).then(() => {
1515
+ reactData.isLoading = false;
1516
+ cacheColumnMap($xeTable);
1517
+ parseColumns($xeTable, true).then(() => {
1518
+ if (reactData.scrollXLoad) {
1519
+ loadScrollXData($xeTable);
1520
+ }
1521
+ });
1522
+ $xeTable.clearMergeCells();
1523
+ $xeTable.clearMergeFooterItems();
1524
+ $xeTable.handleTableData(true);
1525
+ if (process.env.NODE_ENV === 'development') {
1526
+ if ((reactData.scrollXLoad || reactData.scrollYLoad) && reactData.expandColumn) {
1527
+ warnLog('vxe.error.scrollErrProp', ['column.type=expand']);
1528
+ }
1529
+ }
1530
+ return $xeTable.$nextTick().then(() => {
1531
+ if ($xeToolbar) {
1532
+ $xeToolbar.syncUpdate({
1533
+ collectColumn: internalData.collectColumn,
1534
+ $table: $xeTable
1535
+ });
1536
+ }
1537
+ if ($xeTable.handleUpdateCustomColumn) {
1538
+ $xeTable.handleUpdateCustomColumn();
1539
+ }
1540
+ return $xeTable.recalculate();
1541
+ });
1542
+ });
1543
+ }
958
1544
  /**
959
1545
  * 纵向 Y 可视渲染处理
960
1546
  */
@@ -964,14 +1550,16 @@ function loadScrollYData($xeTable) {
964
1550
  const internalData = $xeTable;
965
1551
  const { showOverflow } = props;
966
1552
  const { mergeList } = reactData;
967
- const { tableHeight, scrollYStore } = internalData;
968
- const { startIndex, endIndex, offsetSize } = scrollYStore;
969
- const autoOffsetYSize = showOverflow ? offsetSize : offsetSize + Math.min(8, Math.ceil(tableHeight / 200));
1553
+ const { scrollYStore } = internalData;
1554
+ const { preloadSize, startIndex, endIndex, offsetSize } = scrollYStore;
1555
+ const autoOffsetYSize = showOverflow ? offsetSize : offsetSize + 1;
970
1556
  const { toVisibleIndex, visibleSize } = handleVirtualYVisible($xeTable);
971
1557
  const offsetItem = {
972
- startIndex: Math.max(0, toVisibleIndex - 1 - offsetSize),
973
- endIndex: toVisibleIndex + visibleSize + autoOffsetYSize
1558
+ startIndex: Math.max(0, toVisibleIndex - 1 - offsetSize - preloadSize),
1559
+ endIndex: toVisibleIndex + visibleSize + autoOffsetYSize + preloadSize
974
1560
  };
1561
+ scrollYStore.visibleStartIndex = toVisibleIndex;
1562
+ scrollYStore.visibleEndIndex = toVisibleIndex + visibleSize;
975
1563
  calculateMergerOffsetIndex(mergeList, offsetItem, 'row');
976
1564
  const { startIndex: offsetStartIndex, endIndex: offsetEndIndex } = offsetItem;
977
1565
  if (toVisibleIndex <= startIndex || toVisibleIndex >= endIndex - visibleSize - 1) {
@@ -994,16 +1582,20 @@ function checkLastSyncScroll($xeTable, isRollX, isRollY) {
994
1582
  internalData.lcsRunTime = Date.now();
995
1583
  internalData.lcsTimeout = undefined;
996
1584
  internalData.inVirtualScroll = false;
1585
+ internalData.inWheelScroll = false;
1586
+ internalData.inHeaderScroll = false;
997
1587
  internalData.inBodyScroll = false;
998
1588
  internalData.inFooterScroll = false;
999
- internalData.bodyScrollType = '';
1589
+ internalData.scrollRenderType = '';
1000
1590
  if (isRollX && scrollXLoad) {
1001
1591
  $xeTable.updateScrollXData().then(() => {
1592
+ calcCellHeight($xeTable);
1002
1593
  loadScrollXData($xeTable);
1003
1594
  });
1004
1595
  }
1005
1596
  if (isRollY && scrollYLoad) {
1006
1597
  $xeTable.updateScrollYData().then(() => {
1598
+ calcCellHeight($xeTable);
1007
1599
  loadScrollYData($xeTable);
1008
1600
  });
1009
1601
  }
@@ -1271,7 +1863,7 @@ const Methods = {
1271
1863
  this.updateFooter();
1272
1864
  return this.$nextTick().then(() => {
1273
1865
  updateHeight($xeTable);
1274
- this.updateStyle();
1866
+ updateStyle($xeTable);
1275
1867
  }).then(() => {
1276
1868
  computeScrollLoad($xeTable);
1277
1869
  }).then(() => {
@@ -1296,10 +1888,18 @@ const Methods = {
1296
1888
  }
1297
1889
  // 是否变更虚拟滚动
1298
1890
  if (oldScrollYLoad === sYLoad) {
1299
- restoreScrollLocation(this, targetScrollLeft, targetScrollTop).then(resolve);
1891
+ restoreScrollLocation(this, targetScrollLeft, targetScrollTop)
1892
+ .then(() => {
1893
+ resolve();
1894
+ });
1300
1895
  }
1301
1896
  else {
1302
- setTimeout(() => restoreScrollLocation(this, targetScrollLeft, targetScrollTop).then(resolve));
1897
+ setTimeout(() => {
1898
+ restoreScrollLocation(this, targetScrollLeft, targetScrollTop)
1899
+ .then(() => {
1900
+ resolve();
1901
+ });
1902
+ });
1303
1903
  }
1304
1904
  });
1305
1905
  });
@@ -1387,8 +1987,9 @@ const Methods = {
1387
1987
  * @param {ColumnInfo} columns 列配置
1388
1988
  */
1389
1989
  loadColumn(columns) {
1990
+ const $xeTable = this;
1390
1991
  const collectColumn = XEUtils.mapTree(columns, column => Cell.createColumn(this, column), { children: 'children' });
1391
- return this.handleColumn(collectColumn);
1992
+ return handleColumn($xeTable, collectColumn);
1392
1993
  },
1393
1994
  /**
1394
1995
  * 加载列配置并恢复到初始状态
@@ -1400,51 +2001,9 @@ const Methods = {
1400
2001
  return this.loadColumn(columns);
1401
2002
  });
1402
2003
  },
1403
- initColumnSort() {
1404
- const { collectColumn } = this;
1405
- collectColumn.forEach((column, index) => {
1406
- const sortIndex = index + 1;
1407
- column.sortNumber = sortIndex;
1408
- column.renderSortNumber = sortIndex;
1409
- });
1410
- },
1411
2004
  handleColumn(collectColumn) {
1412
2005
  const $xeTable = this;
1413
- this.collectColumn = collectColumn;
1414
- const tableFullColumn = getColumnList(collectColumn);
1415
- this.tableFullColumn = tableFullColumn;
1416
- this._isLoading = true;
1417
- this.isDragColMove = false;
1418
- this.initColumnSort();
1419
- return Promise.resolve(this.restoreCustomStorage()).then(() => {
1420
- this._isLoading = false;
1421
- cacheColumnMap($xeTable);
1422
- this.parseColumns(true).then(() => {
1423
- if (this.scrollXLoad) {
1424
- loadScrollXData($xeTable);
1425
- }
1426
- });
1427
- this.clearMergeCells();
1428
- this.clearMergeFooterItems();
1429
- this.handleTableData(true);
1430
- if (process.env.NODE_ENV === 'development') {
1431
- if ((this.scrollXLoad || this.scrollYLoad) && this.expandColumn) {
1432
- warnLog('vxe.error.scrollErrProp', ['column.type=expand']);
1433
- }
1434
- }
1435
- return this.$nextTick().then(() => {
1436
- if (this.$toolbar) {
1437
- this.$toolbar.syncUpdate({
1438
- collectColumn: this.collectColumn,
1439
- $table: this
1440
- });
1441
- }
1442
- if ($xeTable.handleUpdateCustomColumn) {
1443
- $xeTable.handleUpdateCustomColumn();
1444
- }
1445
- return this.recalculate();
1446
- });
1447
- });
2006
+ return handleColumn($xeTable, collectColumn);
1448
2007
  },
1449
2008
  /**
1450
2009
  * 更新数据行的 Map
@@ -1909,7 +2468,7 @@ const Methods = {
1909
2468
  const rowid = getRowid(this, row);
1910
2469
  let bodyElem = null;
1911
2470
  if (column) {
1912
- bodyElem = $refs[`${column.fixed || 'table'}Body`] || $refs.tableBody;
2471
+ bodyElem = $refs[`${column.fixed || 'table'}Body`] || $refs.refTableBody;
1913
2472
  }
1914
2473
  if (bodyElem && bodyElem.$el) {
1915
2474
  return bodyElem.$el.querySelector(`.vxe-body--row[rowid="${rowid}"] .${column.id}`);
@@ -2325,14 +2884,18 @@ const Methods = {
2325
2884
  * 只对 tree-config 有效,获取行的父级
2326
2885
  */
2327
2886
  getTreeParentRow(rowOrRowid) {
2328
- const { treeConfig, fullDataRowIdData } = this;
2887
+ const $xeTable = this;
2888
+ const props = $xeTable;
2889
+ const internalData = $xeTable;
2890
+ const { treeConfig } = props;
2891
+ const { fullDataRowIdData } = internalData;
2329
2892
  if (rowOrRowid && treeConfig) {
2330
2893
  let rowid;
2331
2894
  if (XEUtils.isString(rowOrRowid)) {
2332
2895
  rowid = rowOrRowid;
2333
2896
  }
2334
2897
  else {
2335
- rowid = getRowid(this, rowOrRowid);
2898
+ rowid = getRowid($xeTable, rowOrRowid);
2336
2899
  }
2337
2900
  if (rowid) {
2338
2901
  const rest = fullDataRowIdData[rowid];
@@ -2359,10 +2922,12 @@ const Methods = {
2359
2922
  * 根据行获取行的唯一主键
2360
2923
  * @param {Row} row 行对象
2361
2924
  */
2362
- getRowid(row) {
2925
+ getRowid(cellValue) {
2363
2926
  const $xeTable = this;
2364
- const rowid = XEUtils.get(row, getRowkey($xeTable));
2365
- return XEUtils.eqNull(rowid) ? '' : encodeURIComponent(rowid);
2927
+ const internalData = $xeTable;
2928
+ const { fullDataRowIdData } = internalData;
2929
+ const rowid = XEUtils.eqNull(cellValue) ? '' : encodeURIComponent(cellValue || '');
2930
+ return fullDataRowIdData[rowid] ? fullDataRowIdData[rowid].row : null;
2366
2931
  },
2367
2932
  /**
2368
2933
  * 获取处理后的表格数据
@@ -2389,12 +2954,17 @@ const Methods = {
2389
2954
  const { tableFullData, tableFullTreeData } = internalData;
2390
2955
  if (treeConfig) {
2391
2956
  const treeOpts = $xeTable.computeTreeOpts;
2392
- const { transform, mapChildrenField } = treeOpts;
2957
+ const { transform, mapChildrenField, rowField, parentField } = treeOpts;
2393
2958
  const childrenField = treeOpts.children || treeOpts.childrenField;
2394
2959
  if (transform) {
2395
2960
  return XEUtils.toArrayTree(XEUtils.toTreeArray(tableFullTreeData, {
2396
2961
  children: mapChildrenField
2397
- }), { children: childrenField });
2962
+ }), {
2963
+ key: rowField,
2964
+ parentKey: parentField,
2965
+ children: childrenField,
2966
+ mapChildren: mapChildrenField
2967
+ });
2398
2968
  }
2399
2969
  return tableFullTreeData.slice(0);
2400
2970
  }
@@ -2550,8 +3120,8 @@ const Methods = {
2550
3120
  const colWidth = XEUtils.toInteger(width);
2551
3121
  let rdWidth = colWidth;
2552
3122
  if (isScale(width)) {
2553
- const tableBody = $xeTable.$refs.tableBody;
2554
- const bodyElem = tableBody ? tableBody.$el : null;
3123
+ const refTableBody = $xeTable.$refs.refTableBody;
3124
+ const bodyElem = refTableBody ? refTableBody.$el : null;
2555
3125
  const bodyWidth = bodyElem ? bodyElem.clientWidth - 1 : 0;
2556
3126
  rdWidth = Math.floor(colWidth * bodyWidth);
2557
3127
  }
@@ -2797,150 +3367,16 @@ const Methods = {
2797
3367
  * 刷新列配置
2798
3368
  */
2799
3369
  refreshColumn(initSort) {
3370
+ const $xeTable = this;
2800
3371
  if (initSort) {
2801
- this.handleUpdateColumn();
3372
+ handleUpdateColumn($xeTable);
2802
3373
  }
2803
- return this.parseColumns(true).then(() => {
3374
+ return parseColumns($xeTable, true).then(() => {
2804
3375
  return this.refreshScroll();
2805
3376
  }).then(() => {
2806
3377
  return this.recalculate();
2807
3378
  });
2808
3379
  },
2809
- /**
2810
- * 刷新列信息
2811
- * 将固定的列左边、右边分别靠边
2812
- */
2813
- parseColumns(isReset) {
2814
- const $xeTable = this;
2815
- const props = $xeTable;
2816
- const internalData = $xeTable;
2817
- const { showOverflow } = props;
2818
- const rowOpts = $xeTable.computeRowOpts;
2819
- const leftList = [];
2820
- const centerList = [];
2821
- const rightList = [];
2822
- const { collectColumn, tableFullColumn, isGroup, columnStore, sXOpts, scrollXStore, fullColumnIdData } = this;
2823
- // 如果是分组表头,如果子列全部被隐藏,则根列也隐藏
2824
- if (isGroup) {
2825
- const leftGroupList = [];
2826
- const centerGroupList = [];
2827
- const rightGroupList = [];
2828
- XEUtils.eachTree(collectColumn, (column, index, items, path, parentColumn) => {
2829
- const isColGroup = hasChildrenList(column);
2830
- // 如果是分组,必须按组设置固定列,不允许给子列设置固定
2831
- if (parentColumn && parentColumn.fixed) {
2832
- column.fixed = parentColumn.fixed;
2833
- }
2834
- if (parentColumn && column.fixed !== parentColumn.fixed) {
2835
- errLog('vxe.error.groupFixed');
2836
- }
2837
- if (isColGroup) {
2838
- column.visible = !!XEUtils.findTree(column.children, (subColumn) => hasChildrenList(subColumn) ? null : subColumn.visible);
2839
- }
2840
- else if (column.visible) {
2841
- if (column.fixed === 'left') {
2842
- leftList.push(column);
2843
- }
2844
- else if (column.fixed === 'right') {
2845
- rightList.push(column);
2846
- }
2847
- else {
2848
- centerList.push(column);
2849
- }
2850
- }
2851
- });
2852
- collectColumn.forEach((column) => {
2853
- if (column.visible) {
2854
- if (column.fixed === 'left') {
2855
- leftGroupList.push(column);
2856
- }
2857
- else if (column.fixed === 'right') {
2858
- rightGroupList.push(column);
2859
- }
2860
- else {
2861
- centerGroupList.push(column);
2862
- }
2863
- }
2864
- });
2865
- this.tableGroupColumn = leftGroupList.concat(centerGroupList).concat(rightGroupList);
2866
- }
2867
- else {
2868
- // 重新分配列
2869
- tableFullColumn.forEach((column) => {
2870
- if (column.visible) {
2871
- if (column.fixed === 'left') {
2872
- leftList.push(column);
2873
- }
2874
- else if (column.fixed === 'right') {
2875
- rightList.push(column);
2876
- }
2877
- else {
2878
- centerList.push(column);
2879
- }
2880
- }
2881
- });
2882
- }
2883
- const visibleColumn = leftList.concat(centerList).concat(rightList);
2884
- // 如果gt为0,则总是启用
2885
- const scrollXLoad = sXOpts.enabled && sXOpts.gt > -1 && (sXOpts.gt === 0 || sXOpts.gt <= tableFullColumn.length);
2886
- this.hasFixedColumn = leftList.length > 0 || rightList.length > 0;
2887
- Object.assign(columnStore, { leftList, centerList, rightList });
2888
- if (scrollXLoad) {
2889
- if (showOverflow) {
2890
- if (!rowOpts.height) {
2891
- const errColumn = internalData.tableFullColumn.find((column) => column.showOverflow === false);
2892
- if (errColumn) {
2893
- errLog('vxe.error.errProp', [`column[field="${errColumn.field}"].show-overflow=false`, 'show-overflow=true']);
2894
- }
2895
- }
2896
- }
2897
- if (process.env.NODE_ENV === 'development') {
2898
- // if (this.showHeader && !this.showHeaderOverflow) {
2899
- // warnLog('vxe.error.reqProp', ['show-header-overflow'])
2900
- // }
2901
- // if (this.showFooter && !this.showFooterOverflow) {
2902
- // warnLog('vxe.error.reqProp', ['show-footer-overflow'])
2903
- // }
2904
- if (this.spanMethod) {
2905
- warnLog('vxe.error.scrollErrProp', ['span-method']);
2906
- }
2907
- if (this.footerSpanMethod) {
2908
- warnLog('vxe.error.scrollErrProp', ['footer-span-method']);
2909
- }
2910
- }
2911
- if (isReset) {
2912
- const { visibleSize } = handleVirtualXVisible(this);
2913
- scrollXStore.startIndex = 0;
2914
- scrollXStore.endIndex = visibleSize;
2915
- scrollXStore.visibleSize = visibleSize;
2916
- }
2917
- }
2918
- // 如果列被显示/隐藏,则清除合并状态
2919
- // 如果列被设置为固定,则清除合并状态
2920
- if (visibleColumn.length !== this.visibleColumn.length || !this.visibleColumn.every((column, index) => column === visibleColumn[index])) {
2921
- this.clearMergeCells();
2922
- this.clearMergeFooterItems();
2923
- }
2924
- this.scrollXLoad = scrollXLoad;
2925
- visibleColumn.forEach((column, index) => {
2926
- const colid = column.id;
2927
- const colRest = fullColumnIdData[colid];
2928
- if (colRest) {
2929
- colRest._index = index;
2930
- }
2931
- });
2932
- this.visibleColumn = visibleColumn;
2933
- this.handleTableColumn();
2934
- if (isReset) {
2935
- return this.updateFooter().then(() => {
2936
- return this.recalculate();
2937
- }).then(() => {
2938
- this.updateCellAreas();
2939
- return this.recalculate();
2940
- });
2941
- }
2942
- return this.updateFooter();
2943
- },
2944
3380
  /**
2945
3381
  * 指定列宽的列进行拆分
2946
3382
  */
@@ -3019,377 +3455,115 @@ const Methods = {
3019
3455
  $xeTable.saveCustomStore('update:visible');
3020
3456
  $xeTable.updateCellAreas();
3021
3457
  $xeTable.dispatchEvent('resizable-change', Object.assign(Object.assign({}, params), { resizeWidth }), evnt);
3022
- setTimeout(() => $xeTable.recalculate(true), 300);
3023
- });
3024
- }
3025
- },
3026
- /**
3027
- * 刷新滚动操作,手动同步滚动相关位置(对于某些特殊的操作,比如滚动条错位、固定列不同步)
3028
- */
3029
- refreshScroll() {
3030
- const { lastScrollLeft, lastScrollTop } = this;
3031
- const { $refs } = this;
3032
- const { tableBody, leftBody, rightBody, tableFooter } = $refs;
3033
- const tableBodyElem = tableBody ? tableBody.$el : null;
3034
- const leftBodyElem = leftBody ? leftBody.$el : null;
3035
- const rightBodyElem = rightBody ? rightBody.$el : null;
3036
- const tableFooterElem = tableFooter ? tableFooter.$el : null;
3037
- return new Promise(resolve => {
3038
- // 还原滚动条位置
3039
- if (lastScrollLeft || lastScrollTop) {
3040
- return restoreScrollLocation(this, lastScrollLeft, lastScrollTop).then(() => {
3041
- // 存在滚动行为未结束情况
3042
- setTimeout(resolve, 30);
3043
- });
3044
- }
3045
- // 重置
3046
- setScrollTop(tableBodyElem, lastScrollTop);
3047
- setScrollTop(leftBodyElem, lastScrollTop);
3048
- setScrollTop(rightBodyElem, lastScrollTop);
3049
- setScrollLeft(tableFooterElem, lastScrollLeft);
3050
- // 存在滚动行为未结束情况
3051
- setTimeout(resolve, 30);
3052
- });
3053
- },
3054
- /**
3055
- * 重新渲染布局
3056
- * 刷新布局
3057
- */
3058
- recalculate(reFull) {
3059
- const $xeTable = this;
3060
- const internalData = $xeTable;
3061
- return new Promise(resolve => {
3062
- const { rceTimeout, rceRunTime } = internalData;
3063
- const resizeOpts = $xeTable.computeResizeOpts;
3064
- const refreshDelay = resizeOpts.refreshDelay || 20;
3065
- const el = $xeTable.$refs.refElem;
3066
- if (el && el.clientWidth) {
3067
- autoCellWidth($xeTable);
3068
- }
3069
- if (rceTimeout) {
3070
- clearTimeout(rceTimeout);
3071
- if (rceRunTime && rceRunTime + (refreshDelay - 5) < Date.now()) {
3072
- resolve(handleRecalculateLayout($xeTable, !!reFull));
3073
- }
3074
- else {
3075
- $xeTable.$nextTick(() => {
3076
- resolve();
3077
- });
3078
- }
3079
- }
3080
- else {
3081
- resolve(handleRecalculateLayout($xeTable, !!reFull));
3082
- }
3083
- internalData.rceTimeout = setTimeout(() => {
3084
- internalData.rceTimeout = undefined;
3085
- handleRecalculateLayout($xeTable, !!reFull);
3086
- }, refreshDelay);
3087
- });
3088
- },
3089
- updateStyle() {
3090
- const $xeTable = this;
3091
- let { $refs, isGroup, fullColumnIdData, tableColumn, customHeight, customMinHeight, customMaxHeight, border, headerHeight, showFooter, showOverflow: allColumnOverflow, showHeaderOverflow: allColumnHeaderOverflow, showFooterOverflow: allColumnFooterOverflow, footerHeight, tableHeight, tableWidth, scrollbarHeight, scrollbarWidth, scrollXLoad, scrollYLoad, overflowX, cellOffsetWidth, columnStore, elemStore, editStore, currentRow, mouseConfig, spanMethod, expandColumn, footerSpanMethod, isAllOverflow, visibleColumn } = $xeTable;
3092
- const containerList = ['main', 'left', 'right'];
3093
- const emptyPlaceholderElem = $refs.emptyPlaceholder;
3094
- const bodyWrapperElem = elemStore['main-body-wrapper'];
3095
- if (emptyPlaceholderElem) {
3096
- emptyPlaceholderElem.style.top = `${headerHeight}px`;
3097
- emptyPlaceholderElem.style.height = bodyWrapperElem ? `${bodyWrapperElem.offsetHeight - scrollbarHeight}px` : '';
3098
- }
3099
- if (customHeight > 0) {
3100
- if (showFooter) {
3101
- customHeight += scrollbarHeight;
3102
- }
3103
- }
3104
- const scrollXVirtualEl = $xeTable.$refs.refScrollXVirtualElem;
3105
- if (scrollXVirtualEl) {
3106
- scrollXVirtualEl.style.height = `${scrollbarHeight}px`;
3107
- }
3108
- const scrollYVirtualEl = $xeTable.$refs.refScrollYVirtualElem;
3109
- if (scrollYVirtualEl) {
3110
- let bodyHeight = 0;
3111
- let bodyMaxHeight = 0;
3112
- const bodyMinHeight = customMinHeight - headerHeight - footerHeight;
3113
- if (customMaxHeight) {
3114
- bodyMaxHeight = customMaxHeight - headerHeight - footerHeight;
3115
- bodyMaxHeight = Math.max(bodyMinHeight, bodyMaxHeight);
3116
- }
3117
- if (customHeight) {
3118
- bodyHeight = customHeight - headerHeight - footerHeight;
3119
- if (bodyMaxHeight) {
3120
- bodyHeight = Math.min(bodyMaxHeight, bodyHeight);
3121
- }
3122
- bodyHeight = Math.max(bodyMinHeight, bodyHeight);
3123
- }
3124
- scrollYVirtualEl.style.top = `${headerHeight}px`;
3125
- scrollYVirtualEl.style.width = `${scrollbarWidth}px`;
3126
- scrollYVirtualEl.style.height = `${bodyHeight + (overflowX ? -Math.max(1, scrollbarHeight) : 0)}px`;
3127
- }
3128
- containerList.forEach((name, index) => {
3129
- const fixedType = index > 0 ? name : '';
3130
- const layoutList = ['header', 'body', 'footer'];
3131
- const fixedColumn = columnStore[`${fixedType}List`];
3132
- const fixedWrapperElem = $refs[`${fixedType}Container`];
3133
- layoutList.forEach(layout => {
3134
- const wrapperElem = elemStore[`${name}-${layout}-wrapper`];
3135
- const tableElem = elemStore[`${name}-${layout}-table`];
3136
- if (layout === 'header') {
3137
- // 表头体样式处理
3138
- // 横向滚动渲染
3139
- let tWidth = tableWidth;
3140
- let renderColumnList = tableColumn;
3141
- if (isGroup) {
3142
- renderColumnList = visibleColumn;
3143
- }
3144
- else {
3145
- if (fixedType) {
3146
- // 如果是使用优化模式
3147
- if (scrollXLoad || scrollYLoad || allColumnHeaderOverflow) {
3148
- // 如果不支持优化模式
3149
- if (spanMethod || footerSpanMethod) {
3150
- renderColumnList = visibleColumn;
3151
- }
3152
- else {
3153
- renderColumnList = fixedColumn || [];
3154
- }
3155
- }
3156
- else {
3157
- renderColumnList = visibleColumn;
3158
- }
3159
- }
3160
- }
3161
- tWidth = renderColumnList.reduce((previous, column) => previous + column.renderWidth, 0);
3162
- if (tableElem) {
3163
- tableElem.style.width = tWidth ? `${tWidth + scrollbarWidth}px` : '';
3164
- // 修复 IE 中高度无法自适应问题
3165
- if (browse.msie) {
3166
- XEUtils.arrayEach(tableElem.querySelectorAll('.vxe-resizable'), (resizeElem) => {
3167
- resizeElem.style.height = `${resizeElem.parentNode.offsetHeight}px`;
3168
- });
3169
- }
3170
- }
3171
- const repairElem = elemStore[`${name}-${layout}-repair`];
3172
- if (repairElem) {
3173
- repairElem.style.width = `${tableWidth}px`;
3174
- }
3175
- const listElem = elemStore[`${name}-${layout}-list`];
3176
- if (isGroup && listElem) {
3177
- XEUtils.arrayEach(listElem.querySelectorAll('.col--group'), (thElem) => {
3178
- const colNode = this.getColumnNode(thElem);
3179
- if (colNode) {
3180
- const column = colNode.item;
3181
- const { showHeaderOverflow } = column;
3182
- const cellOverflow = XEUtils.isBoolean(showHeaderOverflow) ? showHeaderOverflow : allColumnHeaderOverflow;
3183
- const showEllipsis = cellOverflow === 'ellipsis';
3184
- const showTitle = cellOverflow === 'title';
3185
- const showTooltip = cellOverflow === true || cellOverflow === 'tooltip';
3186
- const hasEllipsis = showTitle || showTooltip || showEllipsis;
3187
- let childWidth = 0;
3188
- let countChild = 0;
3189
- if (hasEllipsis) {
3190
- XEUtils.eachTree(column.children, item => {
3191
- if (!item.children || !column.children.length) {
3192
- countChild++;
3193
- }
3194
- childWidth += item.renderWidth;
3195
- });
3196
- }
3197
- thElem.style.width = hasEllipsis ? `${childWidth - countChild - (border ? 2 : 0)}px` : '';
3198
- }
3199
- });
3200
- }
3201
- }
3202
- else if (layout === 'body') {
3203
- const emptyBlockElem = elemStore[`${name}-${layout}-emptyBlock`];
3204
- if (isNodeElement(wrapperElem)) {
3205
- let bodyMaxHeight = 0;
3206
- const bodyMinHeight = customMinHeight - headerHeight - footerHeight;
3207
- if (customMaxHeight) {
3208
- bodyMaxHeight = customMaxHeight - headerHeight - footerHeight;
3209
- // 如果是固定列
3210
- if (fixedType) {
3211
- bodyMaxHeight -= (showFooter ? 0 : scrollbarHeight);
3212
- }
3213
- bodyMaxHeight = Math.max(bodyMinHeight, bodyMaxHeight);
3214
- wrapperElem.style.maxHeight = `${bodyMaxHeight}px`;
3215
- }
3216
- if (customHeight) {
3217
- let bodyHeight = customHeight - headerHeight - footerHeight;
3218
- // 如果是固定列
3219
- if (fixedType) {
3220
- bodyHeight -= (showFooter ? 0 : scrollbarHeight);
3221
- }
3222
- if (bodyMaxHeight) {
3223
- bodyHeight = Math.min(bodyMaxHeight, bodyHeight);
3224
- }
3225
- wrapperElem.style.height = `${Math.max(bodyMinHeight, bodyHeight)}px`;
3226
- }
3227
- else {
3228
- wrapperElem.style.height = '';
3229
- }
3230
- wrapperElem.style.minHeight = `${bodyMinHeight}px`;
3231
- }
3232
- // 如果是固定列
3233
- if (fixedWrapperElem) {
3234
- const isRightFixed = fixedType === 'right';
3235
- const fixedColumn = columnStore[`${fixedType}List`];
3236
- if (isNodeElement(wrapperElem)) {
3237
- wrapperElem.style.top = `${headerHeight}px`;
3238
- }
3239
- fixedWrapperElem.style.height = `${(customHeight > 0 ? customHeight - headerHeight - footerHeight : tableHeight) + headerHeight + footerHeight - scrollbarHeight * (showFooter ? 2 : 1)}px`;
3240
- fixedWrapperElem.style.width = `${fixedColumn.reduce((previous, column) => previous + column.renderWidth, isRightFixed ? scrollbarWidth : 0)}px`;
3241
- }
3242
- let tWidth = tableWidth;
3243
- let renderColumnList = tableColumn;
3244
- if (fixedType) {
3245
- // 如果是使用优化模式
3246
- if (scrollXLoad || scrollYLoad || (allColumnOverflow && isAllOverflow)) {
3247
- // 如果不支持优化模式
3248
- if (expandColumn || spanMethod || footerSpanMethod) {
3249
- renderColumnList = visibleColumn;
3250
- }
3251
- else {
3252
- renderColumnList = fixedColumn || [];
3253
- }
3254
- }
3255
- else {
3256
- renderColumnList = visibleColumn;
3257
- }
3258
- }
3259
- tWidth = renderColumnList.reduce((previous, column) => previous + column.renderWidth, 0);
3260
- if (tableElem) {
3261
- tableElem.style.width = tWidth ? `${tWidth}px` : '';
3262
- // 兼容性处理
3263
- tableElem.style.paddingRight = scrollbarWidth && fixedType && (browse['-moz'] || browse.safari) ? `${scrollbarWidth}px` : '';
3264
- }
3265
- if (emptyBlockElem) {
3266
- emptyBlockElem.style.width = tWidth ? `${tWidth}px` : '';
3267
- }
3268
- }
3269
- else if (layout === 'footer') {
3270
- let tWidth = tableWidth;
3271
- let renderColumnList = tableColumn;
3272
- if (fixedType) {
3273
- // 如果是使用优化模式
3274
- if (scrollXLoad || scrollYLoad || allColumnFooterOverflow) {
3275
- // 如果不支持优化模式
3276
- if (spanMethod || footerSpanMethod) {
3277
- renderColumnList = visibleColumn;
3278
- }
3279
- else {
3280
- renderColumnList = fixedColumn || [];
3281
- }
3282
- }
3283
- else {
3284
- renderColumnList = visibleColumn;
3285
- }
3286
- }
3287
- tWidth = renderColumnList.reduce((previous, column) => previous + column.renderWidth, 0);
3288
- if (isNodeElement(wrapperElem)) {
3289
- // 如果是固定列
3290
- if (fixedWrapperElem) {
3291
- wrapperElem.style.top = `${customHeight > 0 ? customHeight - footerHeight : tableHeight + headerHeight}px`;
3292
- }
3293
- wrapperElem.style.marginTop = `${-scrollbarHeight}px`;
3294
- }
3295
- if (tableElem) {
3296
- tableElem.style.width = tWidth ? `${tWidth + scrollbarWidth}px` : '';
3297
- }
3458
+ setTimeout(() => $xeTable.recalculate(true), 300);
3459
+ });
3460
+ }
3461
+ },
3462
+ /**
3463
+ * 刷新滚动操作,手动同步滚动相关位置(对于某些特殊的操作,比如滚动条错位、固定列不同步)
3464
+ */
3465
+ refreshScroll() {
3466
+ const $xeTable = this;
3467
+ const internalData = $xeTable;
3468
+ const { elemStore, lastScrollLeft, lastScrollTop } = internalData;
3469
+ const headerScrollElem = getRefElem(elemStore['main-header-scroll']);
3470
+ const bodyScrollElem = getRefElem(elemStore['main-body-scroll']);
3471
+ const footerScrollElem = getRefElem(elemStore['main-footer-scroll']);
3472
+ const leftScrollElem = getRefElem(elemStore['left-body-scroll']);
3473
+ const rightScrollElem = getRefElem(elemStore['right-body-scroll']);
3474
+ const xHandleEl = $xeTable.$refs.refScrollXHandleElem;
3475
+ const yHandleEl = $xeTable.$refs.refScrollYHandleElem;
3476
+ return new Promise(resolve => {
3477
+ // 还原滚动条位置
3478
+ if (lastScrollLeft || lastScrollTop) {
3479
+ return restoreScrollLocation($xeTable, lastScrollLeft, lastScrollTop).then().then(() => {
3480
+ // 存在滚动行为未结束情况
3481
+ setTimeout(resolve, 10);
3482
+ });
3483
+ }
3484
+ internalData.intoRunScroll = true;
3485
+ // 重置
3486
+ setScrollTop(yHandleEl, lastScrollTop);
3487
+ setScrollTop(bodyScrollElem, lastScrollTop);
3488
+ setScrollTop(leftScrollElem, lastScrollTop);
3489
+ setScrollTop(rightScrollElem, lastScrollTop);
3490
+ setScrollLeft(xHandleEl, lastScrollLeft);
3491
+ setScrollLeft(bodyScrollElem, lastScrollLeft);
3492
+ setScrollLeft(headerScrollElem, lastScrollLeft);
3493
+ setScrollLeft(footerScrollElem, lastScrollLeft);
3494
+ // 存在滚动行为未结束情况
3495
+ setTimeout(() => {
3496
+ internalData.intoRunScroll = false;
3497
+ resolve();
3498
+ }, 10);
3499
+ });
3500
+ },
3501
+ /**
3502
+ * 重新渲染布局
3503
+ * 刷新布局
3504
+ */
3505
+ recalculate(reFull) {
3506
+ const $xeTable = this;
3507
+ const internalData = $xeTable;
3508
+ return new Promise(resolve => {
3509
+ const { rceTimeout, rceRunTime } = internalData;
3510
+ const resizeOpts = $xeTable.computeResizeOpts;
3511
+ const refreshDelay = resizeOpts.refreshDelay || 20;
3512
+ const el = $xeTable.$refs.refElem;
3513
+ if (el && el.clientWidth) {
3514
+ autoCellWidth($xeTable);
3515
+ }
3516
+ if (rceTimeout) {
3517
+ clearTimeout(rceTimeout);
3518
+ if (rceRunTime && rceRunTime + (refreshDelay - 5) < Date.now()) {
3519
+ resolve(handleRecalculateLayout($xeTable, !!reFull));
3298
3520
  }
3299
- const colgroupElem = elemStore[`${name}-${layout}-colgroup`];
3300
- if (colgroupElem) {
3301
- XEUtils.arrayEach(colgroupElem.children, (colElem) => {
3302
- const colid = colElem.getAttribute('name');
3303
- if (colid === 'col_gutter') {
3304
- colElem.style.width = `${scrollbarWidth}px`;
3305
- }
3306
- if (fullColumnIdData[colid]) {
3307
- const colRest = fullColumnIdData[colid];
3308
- const column = colRest.column;
3309
- const { showHeaderOverflow, showFooterOverflow, showOverflow } = column;
3310
- let cellOverflow;
3311
- colElem.style.width = `${column.renderWidth}px`;
3312
- if (layout === 'header') {
3313
- cellOverflow = XEUtils.isUndefined(showHeaderOverflow) || XEUtils.isNull(showHeaderOverflow) ? allColumnHeaderOverflow : showHeaderOverflow;
3314
- }
3315
- else if (layout === 'footer') {
3316
- cellOverflow = XEUtils.isUndefined(showFooterOverflow) || XEUtils.isNull(showFooterOverflow) ? allColumnFooterOverflow : showFooterOverflow;
3317
- }
3318
- else {
3319
- cellOverflow = XEUtils.isUndefined(showOverflow) || XEUtils.isNull(showOverflow) ? allColumnOverflow : showOverflow;
3320
- }
3321
- const showEllipsis = cellOverflow === 'ellipsis';
3322
- const showTitle = cellOverflow === 'title';
3323
- const showTooltip = cellOverflow === true || cellOverflow === 'tooltip';
3324
- let hasEllipsis = showTitle || showTooltip || showEllipsis;
3325
- const listElem = elemStore[`${name}-${layout}-list`];
3326
- // 滚动的渲染不支持动态行高
3327
- if (layout === 'header' || layout === 'footer') {
3328
- if (scrollXLoad && !hasEllipsis) {
3329
- hasEllipsis = true;
3330
- }
3331
- }
3332
- else {
3333
- if ((scrollXLoad || scrollYLoad) && !hasEllipsis) {
3334
- hasEllipsis = true;
3335
- }
3336
- }
3337
- if (listElem) {
3338
- XEUtils.arrayEach(listElem.querySelectorAll(`.${column.id}`), (elem) => {
3339
- const colspan = parseInt(elem.getAttribute('colspan') || 1);
3340
- const cellElem = elem.querySelector('.vxe-cell');
3341
- let colWidth = column.renderWidth;
3342
- if (cellElem) {
3343
- if (colspan > 1) {
3344
- const columnIndex = this.getColumnIndex(column);
3345
- for (let index = 1; index < colspan; index++) {
3346
- const nextColumn = this.getColumns(columnIndex + index);
3347
- if (nextColumn) {
3348
- colWidth += nextColumn.renderWidth;
3349
- }
3350
- }
3351
- }
3352
- cellElem.style.width = hasEllipsis ? `${colWidth - (cellOffsetWidth * colspan)}px` : '';
3353
- }
3354
- });
3355
- }
3356
- }
3521
+ else {
3522
+ $xeTable.$nextTick(() => {
3523
+ resolve();
3357
3524
  });
3358
3525
  }
3359
- });
3526
+ }
3527
+ else {
3528
+ resolve(handleRecalculateLayout($xeTable, !!reFull));
3529
+ }
3530
+ internalData.rceTimeout = setTimeout(() => {
3531
+ internalData.rceTimeout = undefined;
3532
+ handleRecalculateLayout($xeTable, !!reFull);
3533
+ }, refreshDelay);
3360
3534
  });
3361
- if (currentRow) {
3362
- this.setCurrentRow(currentRow);
3363
- }
3364
- if (mouseConfig && mouseConfig.selected && editStore.selected.row && editStore.selected.column) {
3365
- this.addColSdCls();
3366
- }
3367
- return this.$nextTick();
3535
+ },
3536
+ updateStyle() {
3537
+ const $xeTable = this;
3538
+ return updateStyle($xeTable);
3368
3539
  },
3369
3540
  /**
3370
3541
  * 处理固定列的显示状态
3371
3542
  */
3372
3543
  checkScrolling() {
3373
3544
  const $xeTable = this;
3374
- const { tableBody, leftContainer, rightContainer } = $xeTable.$refs;
3375
- const bodyElem = tableBody ? tableBody.$el : null;
3545
+ const internalData = $xeTable;
3546
+ const { elemStore } = internalData;
3547
+ const bodyScrollElem = getRefElem(elemStore['main-body-scroll']);
3548
+ const leftContainerElem = $xeTable.$refs.refLeftContainer;
3549
+ const rightContainerElem = $xeTable.$refs.refRightContainer;
3376
3550
  const xHandleEl = $xeTable.$refs.refScrollXHandleElem;
3377
- const bodtTargetEl = xHandleEl || bodyElem;
3551
+ const bodtTargetEl = xHandleEl || bodyScrollElem;
3378
3552
  if (bodtTargetEl) {
3379
- if (leftContainer) {
3553
+ if (leftContainerElem) {
3380
3554
  if (bodtTargetEl.scrollLeft > 0) {
3381
- addClass(leftContainer, 'scrolling--middle');
3555
+ addClass(leftContainerElem, 'scrolling--middle');
3382
3556
  }
3383
3557
  else {
3384
- removeClass(leftContainer, 'scrolling--middle');
3558
+ removeClass(leftContainerElem, 'scrolling--middle');
3385
3559
  }
3386
3560
  }
3387
- if (rightContainer) {
3561
+ if (rightContainerElem) {
3388
3562
  if (bodtTargetEl.clientWidth < bodtTargetEl.scrollWidth - Math.ceil(bodtTargetEl.scrollLeft)) {
3389
- addClass(rightContainer, 'scrolling--middle');
3563
+ addClass(rightContainerElem, 'scrolling--middle');
3390
3564
  }
3391
3565
  else {
3392
- removeClass(rightContainer, 'scrolling--middle');
3566
+ removeClass(rightContainerElem, 'scrolling--middle');
3393
3567
  }
3394
3568
  }
3395
3569
  }
@@ -3423,7 +3597,7 @@ const Methods = {
3423
3597
  handleGlobalMousedownEvent(evnt) {
3424
3598
  const { $el, $refs, $xegrid, $toolbar, mouseConfig, editStore, ctxMenuStore, editRules, editOpts, validOpts, areaOpts, filterStore, customStore, getRowNode } = this;
3425
3599
  const { actived } = editStore;
3426
- const { ctxWrapper, filterWrapper, customWrapper, validTip } = $refs;
3600
+ const { refTableMenu, filterWrapper, customWrapper, refValidTooltip } = $refs;
3427
3601
  // 筛选
3428
3602
  if (filterWrapper) {
3429
3603
  if (getEventTargetNode(evnt, $el, 'vxe-cell--filter').flag) {
@@ -3458,7 +3632,7 @@ const Methods = {
3458
3632
  // 如果是激活状态,点击了单元格之外
3459
3633
  const cell = actived.args.cell;
3460
3634
  if ((!cell || !getEventTargetNode(evnt, cell).flag)) {
3461
- if (validTip && getEventTargetNode(evnt, validTip.$el).flag) {
3635
+ if (refValidTooltip && getEventTargetNode(evnt, refValidTooltip.$el).flag) {
3462
3636
  // 如果是激活状态,且点击了校验提示框
3463
3637
  }
3464
3638
  else if (!this.lastCallTime || this.lastCallTime + 50 < Date.now()) {
@@ -3509,7 +3683,7 @@ const Methods = {
3509
3683
  }
3510
3684
  }
3511
3685
  else if (mouseConfig) {
3512
- if (!getEventTargetNode(evnt, $el).flag && !($xegrid && getEventTargetNode(evnt, $xegrid.$el).flag) && !(ctxWrapper && getEventTargetNode(evnt, ctxWrapper.$el).flag) && !($toolbar && getEventTargetNode(evnt, $toolbar.$el).flag)) {
3686
+ if (!getEventTargetNode(evnt, $el).flag && !($xegrid && getEventTargetNode(evnt, $xegrid.$el).flag) && !(refTableMenu && getEventTargetNode(evnt, refTableMenu.$el).flag) && !($toolbar && getEventTargetNode(evnt, $toolbar.$el).flag)) {
3513
3687
  if (this.clearSelected) {
3514
3688
  this.clearSelected();
3515
3689
  }
@@ -3528,7 +3702,7 @@ const Methods = {
3528
3702
  }
3529
3703
  }
3530
3704
  // 如果配置了快捷菜单且,点击了其他地方则关闭
3531
- if (ctxMenuStore.visible && ctxWrapper && !getEventTargetNode(evnt, ctxWrapper.$el).flag) {
3705
+ if (ctxMenuStore.visible && refTableMenu && !getEventTargetNode(evnt, refTableMenu.$el).flag) {
3532
3706
  this.closeMenu();
3533
3707
  }
3534
3708
  const isActivated = getEventTargetNode(evnt, ($xegrid || this).$el).flag;
@@ -3665,8 +3839,8 @@ const Methods = {
3665
3839
  else if (isContextMenu) {
3666
3840
  // 如果按下上下文键
3667
3841
  this._keyCtx = selected.row && selected.column && bodyCtxMenu.length;
3668
- clearTimeout(this.keyCtxTimeout);
3669
- this.keyCtxTimeout = setTimeout(() => {
3842
+ clearTimeout(internalData.keyCtxTimeout);
3843
+ internalData.keyCtxTimeout = setTimeout(() => {
3670
3844
  this._keyCtx = false;
3671
3845
  }, 1000);
3672
3846
  }
@@ -4031,6 +4205,10 @@ const Methods = {
4031
4205
  * @param {Row} row 行对象
4032
4206
  */
4033
4207
  handleTooltip(evnt, cell, overflowElem, tipElem, params) {
4208
+ const $xeTable = this;
4209
+ if (!overflowElem) {
4210
+ return $xeTable.$nextTick();
4211
+ }
4034
4212
  params.cell = cell;
4035
4213
  const { $refs, tooltipOpts, tooltipStore } = this;
4036
4214
  const { column, row } = params;
@@ -4057,7 +4235,7 @@ const Methods = {
4057
4235
  },
4058
4236
  openTooltip(target, content) {
4059
4237
  const { $refs } = this;
4060
- const commTip = $refs.commTip;
4238
+ const commTip = $refs.refCommTooltip;
4061
4239
  if (commTip) {
4062
4240
  return commTip.open(target, content);
4063
4241
  }
@@ -4069,7 +4247,7 @@ const Methods = {
4069
4247
  closeTooltip() {
4070
4248
  const { $refs, tooltipStore } = this;
4071
4249
  const tooltip = $refs.tooltip;
4072
- const commTip = $refs.commTip;
4250
+ const commTip = $refs.refCommTooltip;
4073
4251
  if (tooltipStore.visible) {
4074
4252
  Object.assign(tooltipStore, {
4075
4253
  row: null,
@@ -5250,6 +5428,7 @@ const Methods = {
5250
5428
  this.emitEvent('cell-dblclick', params, evnt);
5251
5429
  },
5252
5430
  handleDefaultSort() {
5431
+ const $xeTable = this;
5253
5432
  const { sortConfig, sortOpts } = this;
5254
5433
  let { defaultSort } = sortOpts;
5255
5434
  if (defaultSort) {
@@ -5268,7 +5447,7 @@ const Methods = {
5268
5447
  }
5269
5448
  });
5270
5449
  if (!sortOpts.remote) {
5271
- this.handleTableData(true).then(this.updateStyle);
5450
+ this.handleTableData(true).then(() => updateStyle($xeTable));
5272
5451
  }
5273
5452
  }
5274
5453
  }
@@ -5689,8 +5868,8 @@ const Methods = {
5689
5868
  },
5690
5869
  handleColDragSwapColumn() {
5691
5870
  const $xeTable = this;
5692
- $xeTable.handleUpdateColumn();
5693
- $xeTable.parseColumns(false).then(() => {
5871
+ handleUpdateColumn($xeTable);
5872
+ parseColumns($xeTable, false).then(() => {
5694
5873
  $xeTable.updateCellAreas();
5695
5874
  $xeTable.saveCustomStore('update:sort');
5696
5875
  });
@@ -5916,15 +6095,15 @@ const Methods = {
5916
6095
  return;
5917
6096
  }
5918
6097
  const xHandleEl = $xeTable.$refs.refScrollXHandleElem;
5919
- const tableBody = $xeTable.$refs.tableBody;
5920
- const tableBodyElem = tableBody ? tableBody.$el : null;
6098
+ const refTableBody = $xeTable.$refs.refTableBody;
6099
+ const tableBodyElem = refTableBody ? refTableBody.$el : null;
5921
6100
  const scrollTargetEl = xHandleEl || tableBodyElem;
5922
6101
  if (scrollTargetEl) {
5923
6102
  const wrapperRect = el.getBoundingClientRect();
5924
6103
  const tableWidth = el.clientWidth;
5925
- const leftContainerElem = $xeTable.$refs.leftContainer;
6104
+ const leftContainerElem = $xeTable.$refs.refLeftContainer;
5926
6105
  const leftContainerWidth = leftContainerElem ? leftContainerElem.clientWidth : 0;
5927
- const rightContainerElem = $xeTable.$refs.rightContainer;
6106
+ const rightContainerElem = $xeTable.$refs.refRightContainer;
5928
6107
  const rightContainerWidth = rightContainerElem ? rightContainerElem.clientWidth : 0;
5929
6108
  const srartX = wrapperRect.x + leftContainerWidth;
5930
6109
  const endX = wrapperRect.x + tableWidth - rightContainerWidth;
@@ -6048,6 +6227,7 @@ const Methods = {
6048
6227
  return this.$nextTick();
6049
6228
  },
6050
6229
  sort(sortConfs, sortOrder) {
6230
+ const $xeTable = this;
6051
6231
  const { sortOpts } = this;
6052
6232
  const { multiple, remote, orders } = sortOpts;
6053
6233
  if (sortConfs) {
@@ -6090,7 +6270,7 @@ const Methods = {
6090
6270
  }
6091
6271
  return this.$nextTick().then(() => {
6092
6272
  this.updateCellAreas();
6093
- return this.updateStyle();
6273
+ return updateStyle($xeTable);
6094
6274
  });
6095
6275
  }
6096
6276
  return this.$nextTick();
@@ -6135,7 +6315,7 @@ const Methods = {
6135
6315
  }
6136
6316
  return $xeTable.$nextTick().then(() => {
6137
6317
  $xeTable.updateCellAreas();
6138
- return $xeTable.updateStyle();
6318
+ return updateStyle($xeTable);
6139
6319
  });
6140
6320
  }
6141
6321
  return $xeTable.$nextTick();
@@ -6146,6 +6326,7 @@ const Methods = {
6146
6326
  * @param {String} column 列或字段名
6147
6327
  */
6148
6328
  clearSort(fieldOrColumn) {
6329
+ const $xeTable = this;
6149
6330
  const { sortOpts } = this;
6150
6331
  if (fieldOrColumn) {
6151
6332
  const column = handleFieldOrColumn(this, fieldOrColumn);
@@ -6159,7 +6340,7 @@ const Methods = {
6159
6340
  if (!sortOpts.remote) {
6160
6341
  this.handleTableData(true);
6161
6342
  }
6162
- return this.$nextTick().then(this.updateStyle);
6343
+ return this.$nextTick().then(() => updateStyle($xeTable));
6163
6344
  },
6164
6345
  // 在 v3 中废弃
6165
6346
  getSortColumn() {
@@ -6864,7 +7045,7 @@ const Methods = {
6864
7045
  */
6865
7046
  getScroll() {
6866
7047
  const { $refs, scrollXLoad, scrollYLoad } = this;
6867
- const bodyElem = $refs.tableBody.$el;
7048
+ const bodyElem = $refs.refTableBody.$el;
6868
7049
  return {
6869
7050
  virtualX: scrollXLoad,
6870
7051
  virtualY: scrollYLoad,
@@ -6879,15 +7060,18 @@ const Methods = {
6879
7060
  const internalData = $xeTable;
6880
7061
  const { highlightHoverRow } = props;
6881
7062
  const { lastScrollLeft, lastScrollTop } = internalData;
6882
- const tableBody = $xeTable.$refs.tableBody;
6883
- const bodyElem = tableBody ? tableBody.$el : null;
7063
+ const xHandleEl = $xeTable.$refs.refScrollXHandleElem;
7064
+ const yHandleEl = $xeTable.$refs.refScrollYHandleElem;
7065
+ if (!xHandleEl || !yHandleEl) {
7066
+ return;
7067
+ }
6884
7068
  const rowOpts = $xeTable.computeRowOpts;
6885
- const validTip = $xeTable.$refs.validTip;
6886
- const tooltip = $xeTable.$refs.tooltip;
6887
- const bodyHeight = bodyElem ? bodyElem.clientHeight : 0;
6888
- const bodyWidth = bodyElem ? bodyElem.clientWidth : 0;
6889
- const scrollHeight = bodyElem ? bodyElem.scrollHeight : 0;
6890
- const scrollWidth = bodyElem ? bodyElem.scrollWidth : 0;
7069
+ const validTip = $xeTable.$refs.refValidTooltip;
7070
+ const tooltip = $xeTable.$refs.refTooltip;
7071
+ const bodyHeight = yHandleEl.clientHeight;
7072
+ const bodyWidth = xHandleEl.clientWidth;
7073
+ const scrollHeight = yHandleEl.scrollHeight;
7074
+ const scrollWidth = xHandleEl.scrollWidth;
6891
7075
  let isTop = false;
6892
7076
  let isBottom = false;
6893
7077
  let isLeft = false;
@@ -6955,10 +7139,10 @@ const Methods = {
6955
7139
  if (rowOpts.isHover || highlightHoverRow) {
6956
7140
  $xeTable.clearHoverRow();
6957
7141
  }
6958
- if (validTip && validTip.visible) {
7142
+ if (validTip && validTip.reactData.visible) {
6959
7143
  validTip.close();
6960
7144
  }
6961
- if (tooltip && tooltip.visible) {
7145
+ if (tooltip && tooltip.reactData.visible) {
6962
7146
  tooltip.close();
6963
7147
  }
6964
7148
  if (isBottomBoundary || isTopBoundary || isRightBoundary || isLeftBoundary) {
@@ -6971,7 +7155,7 @@ const Methods = {
6971
7155
  const internalData = $xeTable;
6972
7156
  const { lxTimeout, lxRunTime, scrollXStore } = internalData;
6973
7157
  const { visibleSize } = scrollXStore;
6974
- const fpsTime = Math.min(80, Math.floor(visibleSize * 3));
7158
+ const fpsTime = Math.max(5, Math.min(80, Math.floor(visibleSize * 3)));
6975
7159
  if (lxTimeout) {
6976
7160
  clearTimeout(lxTimeout);
6977
7161
  }
@@ -6987,10 +7171,12 @@ const Methods = {
6987
7171
  },
6988
7172
  lazyScrollYData() {
6989
7173
  const $xeTable = this;
7174
+ const props = $xeTable;
6990
7175
  const internalData = $xeTable;
7176
+ const { showOverflow } = props;
6991
7177
  const { lyTimeout, lyRunTime, scrollYStore } = internalData;
6992
7178
  const { visibleSize } = scrollYStore;
6993
- const fpsTime = Math.min(80, Math.floor(visibleSize));
7179
+ const fpsTime = showOverflow ? 5 : Math.max(5, Math.min(80, Math.floor(visibleSize / 2)));
6994
7180
  if (lyTimeout) {
6995
7181
  clearTimeout(lyTimeout);
6996
7182
  }
@@ -7030,28 +7216,254 @@ const Methods = {
7030
7216
  $xeTable.lazyScrollYData();
7031
7217
  }
7032
7218
  },
7033
- scrollXEvent(evnt) {
7219
+ triggerBodyScrollEvent(evnt, fixedType) {
7034
7220
  const $xeTable = this;
7035
7221
  const internalData = $xeTable;
7036
- const { intoRunScroll, inFooterScroll, inBodyScroll, lastScrollTop } = internalData;
7037
- if (!intoRunScroll) {
7038
- if (inFooterScroll) {
7222
+ const { elemStore, lastScrollTop, lastScrollLeft, inWheelScroll, inVirtualScroll, inHeaderScroll, inBodyScroll, scrollRenderType, inFooterScroll } = internalData;
7223
+ const xHandleEl = $xeTable.$refs.refScrollXHandleElem;
7224
+ const yHandleEl = $xeTable.$refs.refScrollYHandleElem;
7225
+ const leftScrollElem = getRefElem(elemStore['left-body-scroll']);
7226
+ const bodyScrollElem = getRefElem(elemStore['main-body-scroll']);
7227
+ const rightScrollElem = getRefElem(elemStore['right-body-scroll']);
7228
+ const headerScrollElem = getRefElem(elemStore['main-header-scroll']);
7229
+ const footerScrollElem = getRefElem(elemStore['main-footer-scroll']);
7230
+ if (inWheelScroll || inVirtualScroll || inHeaderScroll || inFooterScroll) {
7231
+ return;
7232
+ }
7233
+ if (!bodyScrollElem) {
7234
+ return;
7235
+ }
7236
+ if (!xHandleEl) {
7237
+ return;
7238
+ }
7239
+ if (!yHandleEl) {
7240
+ return;
7241
+ }
7242
+ if (inBodyScroll) {
7243
+ if (scrollRenderType !== fixedType) {
7039
7244
  return;
7040
7245
  }
7041
- if (inBodyScroll) {
7042
- return;
7246
+ }
7247
+ let scrollTop = yHandleEl.scrollTop;
7248
+ let scrollLeft = xHandleEl.scrollLeft;
7249
+ if (leftScrollElem && fixedType === 'left') {
7250
+ scrollTop = leftScrollElem.scrollTop;
7251
+ }
7252
+ else if (rightScrollElem && fixedType === 'right') {
7253
+ scrollTop = rightScrollElem.scrollTop;
7254
+ }
7255
+ else {
7256
+ scrollTop = bodyScrollElem.scrollTop;
7257
+ scrollLeft = bodyScrollElem.scrollLeft;
7258
+ }
7259
+ const isRollX = scrollLeft !== lastScrollLeft;
7260
+ const isRollY = scrollTop !== lastScrollTop;
7261
+ internalData.inBodyScroll = true;
7262
+ internalData.scrollRenderType = fixedType;
7263
+ if (isRollY) {
7264
+ if (fixedType === 'left') {
7265
+ setScrollTop(bodyScrollElem, scrollTop);
7266
+ setScrollTop(rightScrollElem, scrollTop);
7267
+ }
7268
+ else if (fixedType === 'right') {
7269
+ setScrollTop(bodyScrollElem, scrollTop);
7270
+ setScrollTop(leftScrollElem, scrollTop);
7271
+ }
7272
+ else {
7273
+ setScrollTop(leftScrollElem, scrollTop);
7274
+ setScrollTop(rightScrollElem, scrollTop);
7043
7275
  }
7276
+ setScrollTop(yHandleEl, scrollTop);
7277
+ $xeTable.triggerScrollYEvent(evnt);
7278
+ }
7279
+ if (isRollX) {
7280
+ setScrollLeft(xHandleEl, scrollLeft);
7281
+ setScrollLeft(headerScrollElem, scrollLeft);
7282
+ setScrollLeft(footerScrollElem, scrollLeft);
7283
+ $xeTable.triggerScrollXEvent(evnt);
7284
+ }
7285
+ $xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
7286
+ type: 'body',
7287
+ fixed: fixedType
7288
+ });
7289
+ },
7290
+ triggerHeaderScrollEvent(evnt, fixedType) {
7291
+ const $xeTable = this;
7292
+ const internalData = $xeTable;
7293
+ const { elemStore, inWheelScroll, inVirtualScroll, inBodyScroll, inFooterScroll } = internalData;
7294
+ const xHandleEl = $xeTable.$refs.refScrollXHandleElem;
7295
+ const yHandleEl = $xeTable.$refs.refScrollYHandleElem;
7296
+ const bodyScrollElem = getRefElem(elemStore['main-body-scroll']);
7297
+ const headerScrollElem = getRefElem(elemStore['main-header-scroll']);
7298
+ const footerScrollElem = getRefElem(elemStore['main-footer-scroll']);
7299
+ if (inWheelScroll) {
7300
+ return;
7301
+ }
7302
+ if (inVirtualScroll) {
7303
+ return;
7304
+ }
7305
+ if (inBodyScroll) {
7306
+ return;
7307
+ }
7308
+ if (inFooterScroll) {
7309
+ return;
7310
+ }
7311
+ if (!headerScrollElem) {
7312
+ return;
7313
+ }
7314
+ if (!xHandleEl) {
7315
+ return;
7316
+ }
7317
+ if (!yHandleEl) {
7318
+ return;
7319
+ }
7320
+ const scrollTop = yHandleEl.scrollTop;
7321
+ const scrollLeft = headerScrollElem.scrollLeft;
7322
+ const isRollX = true;
7323
+ const isRollY = false;
7324
+ internalData.inHeaderScroll = true;
7325
+ setScrollLeft(xHandleEl, scrollLeft);
7326
+ setScrollLeft(footerScrollElem, scrollLeft);
7327
+ setScrollLeft(bodyScrollElem, scrollLeft);
7328
+ $xeTable.triggerScrollXEvent(evnt);
7329
+ $xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
7330
+ type: 'header',
7331
+ fixed: fixedType
7332
+ });
7333
+ },
7334
+ triggerFooterScrollEvent(evnt, fixedType) {
7335
+ const $xeTable = this;
7336
+ const internalData = $xeTable;
7337
+ const { elemStore, inWheelScroll, inVirtualScroll, inHeaderScroll, inBodyScroll } = internalData;
7338
+ const xHandleEl = $xeTable.$refs.refScrollXHandleElem;
7339
+ const yHandleEl = $xeTable.$refs.refScrollYHandleElem;
7340
+ const bodyScrollElem = getRefElem(elemStore['main-body-scroll']);
7341
+ const headerScrollElem = getRefElem(elemStore['main-header-scroll']);
7342
+ const footerScrollElem = getRefElem(elemStore['main-footer-scroll']);
7343
+ if (inWheelScroll) {
7344
+ return;
7345
+ }
7346
+ if (inVirtualScroll) {
7347
+ return;
7348
+ }
7349
+ if (inHeaderScroll) {
7350
+ return;
7351
+ }
7352
+ if (inBodyScroll) {
7353
+ return;
7354
+ }
7355
+ if (!footerScrollElem) {
7356
+ return;
7357
+ }
7358
+ if (!xHandleEl) {
7359
+ return;
7360
+ }
7361
+ if (!yHandleEl) {
7362
+ return;
7363
+ }
7364
+ const scrollTop = yHandleEl.scrollTop;
7365
+ const scrollLeft = footerScrollElem.scrollLeft;
7366
+ const isRollX = true;
7367
+ const isRollY = false;
7368
+ internalData.inFooterScroll = true;
7369
+ setScrollLeft(xHandleEl, scrollLeft);
7370
+ setScrollLeft(headerScrollElem, scrollLeft);
7371
+ setScrollLeft(bodyScrollElem, scrollLeft);
7372
+ $xeTable.triggerScrollXEvent(evnt);
7373
+ $xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
7374
+ type: 'footer',
7375
+ fixed: fixedType
7376
+ });
7377
+ },
7378
+ triggerBodyWheelEvent(evnt) {
7379
+ const $xeTable = this;
7380
+ const tableProps = $xeTable;
7381
+ const reactData = $xeTable;
7382
+ const internalData = $xeTable;
7383
+ const { deltaY, deltaX } = evnt;
7384
+ const { highlightHoverRow } = tableProps;
7385
+ const { elemStore, lastScrollTop, lastScrollLeft } = internalData;
7386
+ const rowOpts = $xeTable.computeRowOpts;
7387
+ const xHandleEl = $xeTable.$refs.refScrollXHandleElem;
7388
+ const yHandleEl = $xeTable.$refs.refScrollYHandleElem;
7389
+ const leftScrollElem = getRefElem(elemStore['left-body-scroll']);
7390
+ const bodyScrollElem = getRefElem(elemStore['main-body-scroll']);
7391
+ const rightScrollElem = getRefElem(elemStore['right-body-scroll']);
7392
+ if (!xHandleEl) {
7393
+ return;
7394
+ }
7395
+ if (!yHandleEl) {
7396
+ return;
7397
+ }
7398
+ if (!bodyScrollElem) {
7399
+ return;
7400
+ }
7401
+ let multiple = 1;
7402
+ if (reactData.lastScrollTime + 25 > Date.now()) {
7403
+ multiple = 1.18;
7404
+ }
7405
+ else if (reactData.lastScrollTime + 30 > Date.now()) {
7406
+ multiple = 1.15;
7407
+ }
7408
+ else if (reactData.lastScrollTime + 40 > Date.now()) {
7409
+ multiple = 1.12;
7410
+ }
7411
+ else if (reactData.lastScrollTime + 55 > Date.now()) {
7412
+ multiple = 1.09;
7413
+ }
7414
+ else if (reactData.lastScrollTime + 75 > Date.now()) {
7415
+ multiple = 1.06;
7416
+ }
7417
+ else if (reactData.lastScrollTime + 100 > Date.now()) {
7418
+ multiple = 1.03;
7419
+ }
7420
+ const deltaTop = deltaY * multiple;
7421
+ const deltaLeft = deltaX * multiple;
7422
+ const isTopWheel = deltaTop < 0;
7423
+ const currScrollTop = yHandleEl.scrollTop;
7424
+ // 如果滚动位置已经是顶部或底部,则不需要触发
7425
+ if (isTopWheel ? currScrollTop <= 0 : currScrollTop >= yHandleEl.scrollHeight - yHandleEl.clientHeight) {
7426
+ return;
7427
+ }
7428
+ const scrollTop = bodyScrollElem.scrollTop + deltaTop;
7429
+ const scrollLeft = bodyScrollElem.scrollLeft + deltaLeft;
7430
+ const isRollX = scrollLeft !== lastScrollLeft;
7431
+ const isRollY = scrollTop !== lastScrollTop;
7432
+ // 用于鼠标纵向滚轮处理
7433
+ if (isRollY) {
7434
+ evnt.preventDefault();
7435
+ if (rowOpts.isHover || highlightHoverRow) {
7436
+ $xeTable.clearHoverRow();
7437
+ }
7438
+ internalData.inWheelScroll = true;
7439
+ setScrollTop(yHandleEl, scrollTop);
7440
+ setScrollTop(bodyScrollElem, scrollTop);
7441
+ setScrollTop(leftScrollElem, scrollTop);
7442
+ setScrollTop(rightScrollElem, scrollTop);
7443
+ $xeTable.triggerScrollYEvent(evnt);
7444
+ $xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
7445
+ type: 'footer',
7446
+ fixed: ''
7447
+ });
7448
+ }
7449
+ },
7450
+ scrollXEvent(evnt) {
7451
+ const $xeTable = this;
7452
+ const internalData = $xeTable;
7453
+ const { elemStore, inWheelScroll, lastScrollTop, inHeaderScroll, inBodyScroll, inFooterScroll } = internalData;
7454
+ if (inHeaderScroll || inBodyScroll || inFooterScroll) {
7455
+ return;
7456
+ }
7457
+ if (inWheelScroll) {
7458
+ return;
7044
7459
  }
7045
- const tableHeader = $xeTable.$refs.tableHeader;
7046
- const tableBody = $xeTable.$refs.tableBody;
7047
- const tableFooter = $xeTable.$refs.tableFooter;
7048
- const bodyElem = tableBody.$el;
7049
- const headerElem = tableHeader ? tableHeader.$el : null;
7050
- const footerElem = tableFooter ? tableFooter.$el : null;
7460
+ const headerScrollElem = getRefElem(elemStore['main-header-scroll']);
7461
+ const bodyScrollElem = getRefElem(elemStore['main-body-scroll']);
7462
+ const footerScrollElem = getRefElem(elemStore['main-footer-scroll']);
7051
7463
  const yHandleEl = $xeTable.$refs.refScrollYHandleElem;
7052
7464
  const wrapperEl = evnt.currentTarget;
7053
7465
  const { scrollLeft } = wrapperEl;
7054
- const yBodyEl = yHandleEl || bodyElem;
7466
+ const yBodyEl = yHandleEl || bodyScrollElem;
7055
7467
  let scrollTop = 0;
7056
7468
  if (yBodyEl) {
7057
7469
  scrollTop = yBodyEl.scrollTop;
@@ -7059,9 +7471,9 @@ const Methods = {
7059
7471
  const isRollX = true;
7060
7472
  const isRollY = scrollTop !== lastScrollTop;
7061
7473
  internalData.inVirtualScroll = true;
7062
- setScrollLeft(bodyElem, scrollLeft);
7063
- setScrollLeft(headerElem, scrollLeft);
7064
- setScrollLeft(footerElem, scrollLeft);
7474
+ setScrollLeft(bodyScrollElem, scrollLeft);
7475
+ setScrollLeft(headerScrollElem, scrollLeft);
7476
+ setScrollLeft(footerScrollElem, scrollLeft);
7065
7477
  $xeTable.triggerScrollXEvent(evnt);
7066
7478
  $xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
7067
7479
  type: 'table',
@@ -7071,25 +7483,20 @@ const Methods = {
7071
7483
  scrollYEvent(evnt) {
7072
7484
  const $xeTable = this;
7073
7485
  const internalData = $xeTable;
7074
- const { intoRunScroll, inFooterScroll, inBodyScroll, lastScrollLeft } = internalData;
7075
- if (!intoRunScroll) {
7076
- if (inFooterScroll) {
7077
- return;
7078
- }
7079
- if (inBodyScroll) {
7080
- return;
7081
- }
7486
+ const { elemStore, inWheelScroll, lastScrollLeft, inHeaderScroll, inBodyScroll, inFooterScroll } = internalData;
7487
+ if (inHeaderScroll || inBodyScroll || inFooterScroll) {
7488
+ return;
7489
+ }
7490
+ if (inWheelScroll) {
7491
+ return;
7082
7492
  }
7083
- const tableBody = $xeTable.$refs.tableBody;
7084
- const leftBody = $xeTable.$refs.leftBody;
7085
- const rightBody = $xeTable.$refs.rightBody;
7086
- const bodyElem = tableBody.$el;
7087
- const leftElem = leftBody ? leftBody.$el : null;
7088
- const rightElem = rightBody ? rightBody.$el : null;
7493
+ const leftScrollElem = getRefElem(elemStore['left-body-scroll']);
7494
+ const bodyScrollElem = getRefElem(elemStore['main-body-scroll']);
7495
+ const rightScrollElem = getRefElem(elemStore['right-body-scroll']);
7089
7496
  const xHandleEl = $xeTable.$refs.refScrollXHandleElem;
7090
7497
  const wrapperEl = evnt.currentTarget;
7091
7498
  const { scrollTop } = wrapperEl;
7092
- const xBodyEl = xHandleEl || bodyElem;
7499
+ const xBodyEl = xHandleEl || bodyScrollElem;
7093
7500
  let scrollLeft = 0;
7094
7501
  if (xBodyEl) {
7095
7502
  scrollLeft = xBodyEl.scrollLeft;
@@ -7097,45 +7504,24 @@ const Methods = {
7097
7504
  const isRollX = scrollLeft !== lastScrollLeft;
7098
7505
  const isRollY = true;
7099
7506
  internalData.inVirtualScroll = true;
7100
- setScrollTop(bodyElem, scrollTop);
7101
- setScrollTop(leftElem, scrollTop);
7102
- setScrollTop(rightElem, scrollTop);
7507
+ setScrollTop(bodyScrollElem, scrollTop);
7508
+ setScrollTop(leftScrollElem, scrollTop);
7509
+ setScrollTop(rightScrollElem, scrollTop);
7103
7510
  $xeTable.triggerScrollYEvent(evnt);
7104
7511
  $xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
7105
7512
  type: 'table',
7106
7513
  fixed: ''
7107
7514
  });
7108
7515
  },
7109
- handleTableColumn() {
7110
- const { scrollXLoad, visibleColumn, scrollXStore, fullColumnIdData } = this;
7111
- const tableColumn = scrollXLoad ? visibleColumn.slice(scrollXStore.startIndex, scrollXStore.endIndex) : visibleColumn.slice(0);
7112
- tableColumn.forEach((column, $index) => {
7113
- const colid = column.id;
7114
- const colRest = fullColumnIdData[colid];
7115
- if (colRest) {
7116
- colRest.$index = $index;
7117
- }
7118
- });
7119
- this.tableColumn = tableColumn;
7120
- },
7121
- handleUpdateColumn() {
7122
- const $xeTable = this;
7123
- const internalData = $xeTable;
7124
- const columnList = XEUtils.orderBy(internalData.collectColumn, 'renderSortNumber');
7125
- internalData.collectColumn = columnList;
7126
- const tableFullColumn = getColumnList(columnList);
7127
- internalData.tableFullColumn = tableFullColumn;
7128
- cacheColumnMap($xeTable);
7129
- },
7130
7516
  updateScrollXData() {
7131
7517
  const $xeTable = this;
7132
7518
  const props = $xeTable;
7133
7519
  const { showOverflow } = props;
7134
- $xeTable.handleTableColumn();
7135
- calcCellHeight($xeTable);
7520
+ handleTableColumn($xeTable);
7521
+ // calcCellHeight()
7136
7522
  return $xeTable.$nextTick().then(() => {
7137
- calcCellHeight($xeTable);
7138
- $xeTable.handleTableColumn();
7523
+ // calcCellHeight()
7524
+ handleTableColumn($xeTable);
7139
7525
  $xeTable.updateScrollXSpace();
7140
7526
  if (!showOverflow) {
7141
7527
  $xeTable.updateScrollYSpace();
@@ -7145,8 +7531,13 @@ const Methods = {
7145
7531
  // 更新横向 X 可视渲染上下剩余空间大小
7146
7532
  updateScrollXSpace() {
7147
7533
  const $xeTable = this;
7148
- const { $refs, isGroup, elemStore, visibleColumn, scrollXStore, scrollXLoad, tableWidth, scrollbarWidth } = $xeTable;
7149
- const { tableHeader, tableBody, tableFooter } = $refs;
7534
+ const reactData = $xeTable;
7535
+ const internalData = $xeTable;
7536
+ const { isGroup, scrollXLoad } = reactData;
7537
+ const { visibleColumn, scrollXStore, elemStore, tableWidth } = internalData;
7538
+ const tableHeader = $xeTable.$refs.refTableHeader;
7539
+ const tableBody = $xeTable.$refs.refTableBody;
7540
+ const tableFooter = $xeTable.$refs.refTableFooter;
7150
7541
  const tableBodyElem = tableBody ? tableBody.$el : null;
7151
7542
  if (tableBodyElem) {
7152
7543
  const tableHeaderElem = tableHeader ? tableHeader.$el : null;
@@ -7170,25 +7561,27 @@ const Methods = {
7170
7561
  containerList.forEach(name => {
7171
7562
  const layoutList = ['header', 'body', 'footer'];
7172
7563
  layoutList.forEach(layout => {
7173
- const xSpaceElem = elemStore[`${name}-${layout}-xSpace`];
7564
+ const xSpaceElem = getRefElem(elemStore[`${name}-${layout}-xSpace`]);
7174
7565
  if (xSpaceElem) {
7175
- xSpaceElem.style.width = scrollXLoad ? `${tableWidth + (layout === 'header' ? scrollbarWidth : 0)}px` : '';
7566
+ xSpaceElem.style.width = scrollXLoad ? `${tableWidth}px` : '';
7176
7567
  }
7177
7568
  });
7178
7569
  });
7179
7570
  const scrollXSpaceEl = $xeTable.$refs.refScrollXSpaceElem;
7180
7571
  if (scrollXSpaceEl) {
7181
- scrollXSpaceEl.style.width = `${tableWidth + scrollbarWidth}px`;
7572
+ scrollXSpaceEl.style.width = `${tableWidth}px`;
7182
7573
  }
7183
- this.$nextTick(this.updateStyle);
7574
+ $xeTable.$nextTick(() => {
7575
+ updateStyle($xeTable);
7576
+ });
7184
7577
  }
7185
7578
  },
7186
7579
  updateScrollYData() {
7187
7580
  const $xeTable = this;
7188
7581
  $xeTable.handleTableData();
7189
- calcCellHeight($xeTable);
7582
+ // calcCellHeight()
7190
7583
  return $xeTable.$nextTick().then(() => {
7191
- calcCellHeight($xeTable);
7584
+ // calcCellHeight()
7192
7585
  $xeTable.handleTableData();
7193
7586
  $xeTable.updateScrollYSpace();
7194
7587
  });
@@ -7196,16 +7589,20 @@ const Methods = {
7196
7589
  // 更新纵向 Y 可视渲染上下剩余空间大小
7197
7590
  updateScrollYSpace() {
7198
7591
  const $xeTable = this;
7199
- const { showOverflow, elemStore, scrollYStore, scrollYLoad, afterFullData, fullAllDataRowIdData } = this;
7200
- const { startIndex, rowHeight } = scrollYStore;
7201
- let bodyHeight = 0;
7202
- let topSpaceHeight = 0;
7592
+ const props = $xeTable;
7593
+ const reactData = $xeTable;
7594
+ const internalData = $xeTable;
7595
+ const { showOverflow } = props;
7596
+ const { scrollYLoad, rowHeight } = reactData;
7597
+ const { scrollYStore, elemStore, afterFullData, fullAllDataRowIdData } = internalData;
7598
+ const { startIndex } = scrollYStore;
7599
+ const bodyTableElem = getRefElem(elemStore['main-body-table']);
7203
7600
  const containerList = ['main', 'left', 'right'];
7204
- let marginTop = '';
7205
- let ySpaceHeight = '';
7601
+ let topSpaceHeight = 0;
7602
+ let ySpaceHeight = 0;
7206
7603
  if (scrollYLoad) {
7207
7604
  if (showOverflow) {
7208
- bodyHeight = afterFullData.length * rowHeight;
7605
+ ySpaceHeight = afterFullData.length * rowHeight;
7209
7606
  topSpaceHeight = Math.max(0, startIndex * rowHeight);
7210
7607
  }
7211
7608
  else {
@@ -7214,7 +7611,7 @@ const Methods = {
7214
7611
  const rowid = getRowid($xeTable, row);
7215
7612
  const rowRest = fullAllDataRowIdData[rowid];
7216
7613
  if (rowRest) {
7217
- bodyHeight += rowRest.height || rowHeight;
7614
+ ySpaceHeight += rowRest.height || rowHeight;
7218
7615
  }
7219
7616
  }
7220
7617
  for (let i = 0; i < startIndex; i++) {
@@ -7226,27 +7623,32 @@ const Methods = {
7226
7623
  }
7227
7624
  }
7228
7625
  }
7229
- marginTop = `${topSpaceHeight}px`;
7230
- ySpaceHeight = `${bodyHeight}px`;
7626
+ }
7627
+ else {
7628
+ if (bodyTableElem) {
7629
+ ySpaceHeight = bodyTableElem.clientHeight;
7630
+ }
7231
7631
  }
7232
7632
  containerList.forEach(name => {
7233
7633
  const layoutList = ['header', 'body', 'footer'];
7234
- const tableElem = elemStore[`${name}-body-table`];
7634
+ const tableElem = getRefElem(elemStore[`${name}-body-table`]);
7235
7635
  if (tableElem) {
7236
- tableElem.style.marginTop = marginTop;
7636
+ tableElem.style.marginTop = topSpaceHeight ? `${topSpaceHeight}px` : '';
7237
7637
  }
7238
7638
  layoutList.forEach(layout => {
7239
- const ySpaceElem = elemStore[`${name}-${layout}-ySpace`];
7639
+ const ySpaceElem = getRefElem(elemStore[`${name}-${layout}-ySpace`]);
7240
7640
  if (ySpaceElem) {
7241
- ySpaceElem.style.height = ySpaceHeight;
7641
+ ySpaceElem.style.height = ySpaceHeight ? `${ySpaceHeight}px` : '';
7242
7642
  }
7243
7643
  });
7244
7644
  });
7245
7645
  const scrollYSpaceEl = $xeTable.$refs.refScrollYSpaceElem;
7246
7646
  if (scrollYSpaceEl) {
7247
- scrollYSpaceEl.style.height = ySpaceHeight;
7647
+ scrollYSpaceEl.style.height = ySpaceHeight ? `${ySpaceHeight}px` : '';
7248
7648
  }
7249
- this.$nextTick(this.updateStyle);
7649
+ $xeTable.$nextTick(() => {
7650
+ updateStyle($xeTable);
7651
+ });
7250
7652
  },
7251
7653
  updateScrollYStatus() {
7252
7654
  const $xeTable = this;
@@ -7261,12 +7663,12 @@ const Methods = {
7261
7663
  const $xeTable = this;
7262
7664
  const internalData = $xeTable;
7263
7665
  const { $refs } = this;
7264
- const { tableBody, tableHeader, leftBody, rightBody, tableFooter } = $refs;
7265
- const tableBodyElem = tableBody ? tableBody.$el : null;
7666
+ const { refTableBody, refTableHeader, leftBody, rightBody, refTableFooter } = $refs;
7667
+ const tableBodyElem = refTableBody ? refTableBody.$el : null;
7266
7668
  const leftBodyElem = leftBody ? leftBody.$el : null;
7267
7669
  const rightBodyElem = rightBody ? rightBody.$el : null;
7268
- const tableHeaderElem = tableHeader ? tableHeader.$el : null;
7269
- const tableFooterElem = tableFooter ? tableFooter.$el : null;
7670
+ const tableHeaderElem = refTableHeader ? refTableHeader.$el : null;
7671
+ const tableFooterElem = refTableFooter ? refTableFooter.$el : null;
7270
7672
  internalData.intoRunScroll = true;
7271
7673
  if (XEUtils.isNumber(scrollLeft)) {
7272
7674
  const xHandleEl = $xeTable.$refs.refScrollXHandleElem;
@@ -7371,46 +7773,33 @@ const Methods = {
7371
7773
  clearScroll() {
7372
7774
  const $xeTable = this;
7373
7775
  const internalData = $xeTable;
7374
- const { scrollXStore, scrollYStore } = internalData;
7375
- const tableBody = $xeTable.$refs.tableBody;
7376
- const tableHeader = $xeTable.$refs.tableHeader;
7377
- const tableFooter = $xeTable.$refs.tableFooter;
7378
- const leftBody = $xeTable.$refs.leftBody;
7379
- const rightBody = $xeTable.$refs.rightBody;
7380
- const leftBodyElem = leftBody ? leftBody.$el : null;
7381
- const tableBodyElem = tableBody ? tableBody.$el : null;
7382
- const rightBodyElem = rightBody ? rightBody.$el : null;
7383
- const tableHeaderElem = tableHeader ? tableHeader.$el : null;
7384
- const tableFooterElem = tableFooter ? tableFooter.$el : null;
7776
+ const { elemStore, scrollXStore, scrollYStore } = internalData;
7777
+ const headerScrollElem = getRefElem(elemStore['main-header-scroll']);
7778
+ const bodyScrollElem = getRefElem(elemStore['main-body-scroll']);
7779
+ const footerScrollElem = getRefElem(elemStore['main-footer-scroll']);
7780
+ const leftScrollElem = getRefElem(elemStore['left-body-scroll']);
7781
+ const rightScrollElem = getRefElem(elemStore['right-body-scroll']);
7385
7782
  const xHandleEl = $xeTable.$refs.refScrollXHandleElem;
7386
- if (xHandleEl) {
7387
- setScrollLeft(xHandleEl, 0);
7388
- }
7389
- else {
7390
- setScrollLeft(tableBodyElem, 0);
7391
- setScrollLeft(tableHeaderElem, 0);
7392
- setScrollLeft(tableFooterElem, 0);
7393
- }
7394
7783
  const yHandleEl = $xeTable.$refs.refScrollYHandleElem;
7395
- if (yHandleEl) {
7396
- setScrollTop(yHandleEl, 0);
7397
- }
7398
- else {
7399
- setScrollTop(tableBodyElem, 0);
7400
- setScrollTop(leftBodyElem, 0);
7401
- setScrollTop(rightBodyElem, 0);
7402
- }
7784
+ internalData.intoRunScroll = true;
7785
+ setScrollLeft(xHandleEl, 0);
7786
+ setScrollLeft(bodyScrollElem, 0);
7787
+ setScrollLeft(headerScrollElem, 0);
7788
+ setScrollLeft(footerScrollElem, 0);
7789
+ setScrollTop(yHandleEl, 0);
7790
+ setScrollTop(bodyScrollElem, 0);
7791
+ setScrollTop(leftScrollElem, 0);
7792
+ setScrollTop(rightScrollElem, 0);
7403
7793
  scrollXStore.startIndex = 0;
7794
+ scrollXStore.visibleStartIndex = 0;
7404
7795
  scrollXStore.endIndex = scrollXStore.visibleSize;
7796
+ scrollXStore.visibleEndIndex = scrollXStore.visibleSize;
7405
7797
  scrollYStore.startIndex = 0;
7798
+ scrollYStore.visibleStartIndex = 0;
7406
7799
  scrollYStore.endIndex = scrollYStore.visibleSize;
7800
+ scrollYStore.visibleEndIndex = scrollYStore.visibleSize;
7407
7801
  return $xeTable.$nextTick().then(() => {
7408
- setScrollLeft(tableBodyElem, 0);
7409
- setScrollLeft(tableHeaderElem, 0);
7410
- setScrollLeft(tableFooterElem, 0);
7411
- setScrollTop(tableBodyElem, 0);
7412
- setScrollTop(leftBodyElem, 0);
7413
- setScrollTop(rightBodyElem, 0);
7802
+ internalData.intoRunScroll = false;
7414
7803
  });
7415
7804
  },
7416
7805
  /**
@@ -7437,8 +7826,8 @@ const Methods = {
7437
7826
  const customVal = !XEUtils.isUndefined(cellValue);
7438
7827
  return this.$nextTick().then(() => {
7439
7828
  const { $refs, editRules, validStore } = this;
7440
- const tableBody = $refs.tableBody;
7441
- if (slotParams && tableBody && editRules) {
7829
+ const refTableBody = $refs.refTableBody;
7830
+ if (slotParams && refTableBody && editRules) {
7442
7831
  const { row, column } = slotParams;
7443
7832
  const type = 'change';
7444
7833
  if (this.hasCellRules) {
@@ -7472,13 +7861,14 @@ const Methods = {
7472
7861
  * @param {TableMergeConfig[]} merges { row: Row|number, column: ColumnInfo|number, rowspan: number, colspan: number }
7473
7862
  */
7474
7863
  setMergeCells(merges) {
7864
+ const $xeTable = this;
7475
7865
  if (this.spanMethod) {
7476
7866
  errLog('vxe.error.errConflicts', ['merge-cells', 'span-method']);
7477
7867
  }
7478
7868
  setMerges(this, merges, this.mergeList, this.afterFullData);
7479
7869
  return this.$nextTick().then(() => {
7480
7870
  this.updateCellAreas();
7481
- return this.updateStyle();
7871
+ return updateStyle($xeTable);
7482
7872
  });
7483
7873
  },
7484
7874
  /**
@@ -7486,13 +7876,14 @@ const Methods = {
7486
7876
  * @param {TableMergeConfig[]} merges 多个或数组 [{row:Row|number, col:ColumnInfo|number}]
7487
7877
  */
7488
7878
  removeMergeCells(merges) {
7879
+ const $xeTable = this;
7489
7880
  if (this.spanMethod) {
7490
7881
  errLog('vxe.error.errConflicts', ['merge-cells', 'span-method']);
7491
7882
  }
7492
7883
  const rest = removeMerges(this, merges, this.mergeList, this.afterFullData);
7493
7884
  return this.$nextTick().then(() => {
7494
7885
  this.updateCellAreas();
7495
- this.updateStyle();
7886
+ updateStyle($xeTable);
7496
7887
  return rest;
7497
7888
  });
7498
7889
  },
@@ -7506,32 +7897,35 @@ const Methods = {
7506
7897
  * 清除所有单元格合并
7507
7898
  */
7508
7899
  clearMergeCells() {
7900
+ const $xeTable = this;
7509
7901
  this.mergeList = [];
7510
7902
  return this.$nextTick().then(() => {
7511
- return this.updateStyle();
7903
+ return updateStyle($xeTable);
7512
7904
  });
7513
7905
  },
7514
7906
  handleDefaultMergeFooterItems() {
7515
7907
  this.setMergeFooterItems(this.mergeFooterItems);
7516
7908
  },
7517
7909
  setMergeFooterItems(merges) {
7910
+ const $xeTable = this;
7518
7911
  if (this.footerSpanMethod) {
7519
7912
  errLog('vxe.error.errConflicts', ['merge-footer-items', 'footer-span-method']);
7520
7913
  }
7521
7914
  setMerges(this, merges, this.mergeFooterList, null);
7522
7915
  return this.$nextTick().then(() => {
7523
7916
  this.updateCellAreas();
7524
- return this.updateStyle();
7917
+ return updateStyle($xeTable);
7525
7918
  });
7526
7919
  },
7527
7920
  removeMergeFooterItems(merges) {
7921
+ const $xeTable = this;
7528
7922
  if (this.footerSpanMethod) {
7529
7923
  errLog('vxe.error.errConflicts', ['merge-footer-items', 'footer-span-method']);
7530
7924
  }
7531
7925
  const rest = removeMerges(this, merges, this.mergeFooterList, null);
7532
7926
  return this.$nextTick().then(() => {
7533
7927
  this.updateCellAreas();
7534
- this.updateStyle();
7928
+ updateStyle($xeTable);
7535
7929
  return rest;
7536
7930
  });
7537
7931
  },
@@ -7545,9 +7939,10 @@ const Methods = {
7545
7939
  * 清除所有表尾合并
7546
7940
  */
7547
7941
  clearMergeFooterItems() {
7942
+ const $xeTable = this;
7548
7943
  this.mergeFooterList = [];
7549
7944
  return this.$nextTick().then(() => {
7550
- return this.updateStyle();
7945
+ return updateStyle($xeTable);
7551
7946
  });
7552
7947
  },
7553
7948
  updateZindex() {