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
@@ -22,14 +22,6 @@ const {
22
22
  createEvent
23
23
  } = _ui.VxeUI;
24
24
  const customStorageKey = 'VXE_CUSTOM_STORE';
25
- // 获取所有的列,排除分组
26
- const getColumnList = columns => {
27
- const result = [];
28
- columns.forEach(column => {
29
- result.push(...(column.children && column.children.length ? getColumnList(column.children) : [column]));
30
- });
31
- return result;
32
- };
33
25
  function eqCellValue(row1, row2, field) {
34
26
  const val1 = _xeUtils.default.get(row1, field);
35
27
  const val2 = _xeUtils.default.get(row2, field);
@@ -89,22 +81,25 @@ function handleReserveRow(_vm, reserveRowMap) {
89
81
  function handleVirtualXVisible($xeTable) {
90
82
  const internalData = $xeTable;
91
83
  const {
84
+ elemStore,
92
85
  visibleColumn
93
86
  } = internalData;
94
- const tableBody = $xeTable.$refs.tableBody;
95
- const tableBodyElem = tableBody ? tableBody.$el : null;
96
- if (tableBodyElem) {
87
+ const leftFixedWidth = $xeTable.computeLeftFixedWidth;
88
+ const rightFixedWidth = $xeTable.computeRightFixedWidth;
89
+ const bodyScrollElem = (0, _util.getRefElem)(elemStore['main-body-scroll']);
90
+ if (bodyScrollElem) {
97
91
  const {
98
92
  scrollLeft,
99
93
  clientWidth
100
- } = tableBodyElem;
101
- const endWidth = scrollLeft + clientWidth;
94
+ } = bodyScrollElem;
95
+ const startWidth = scrollLeft + leftFixedWidth;
96
+ const endWidth = scrollLeft + clientWidth - rightFixedWidth;
102
97
  let toVisibleIndex = -1;
103
98
  let cWidth = 0;
104
99
  let visibleSize = 0;
105
100
  for (let colIndex = 0, colLen = visibleColumn.length; colIndex < colLen; colIndex++) {
106
101
  cWidth += visibleColumn[colIndex].renderWidth;
107
- if (toVisibleIndex === -1 && scrollLeft < cWidth) {
102
+ if (toVisibleIndex === -1 && startWidth < cWidth) {
108
103
  toVisibleIndex = colIndex;
109
104
  }
110
105
  if (toVisibleIndex >= 0) {
@@ -116,7 +111,7 @@ function handleVirtualXVisible($xeTable) {
116
111
  }
117
112
  return {
118
113
  toVisibleIndex: Math.max(0, toVisibleIndex),
119
- visibleSize: Math.max(6, visibleSize)
114
+ visibleSize: Math.max(1, visibleSize)
120
115
  };
121
116
  }
122
117
  return {
@@ -124,10 +119,97 @@ function handleVirtualXVisible($xeTable) {
124
119
  visibleSize: 6
125
120
  };
126
121
  }
122
+ function handleCustomRestore($xeTable, storeData) {
123
+ const reactData = $xeTable;
124
+ const internalData = $xeTable;
125
+ let {
126
+ collectColumn
127
+ } = internalData;
128
+ const {
129
+ resizableData,
130
+ sortData,
131
+ visibleData,
132
+ fixedData
133
+ } = storeData;
134
+ let hasCustomSort = false;
135
+ // 处理还原
136
+ if (resizableData || sortData || visibleData || fixedData) {
137
+ _xeUtils.default.eachTree(collectColumn, (column, index, items, path, parentColumn) => {
138
+ const colKey = column.getKey();
139
+ // 支持一级
140
+ if (!parentColumn) {
141
+ if (fixedData && fixedData[colKey] !== undefined) {
142
+ column.fixed = fixedData[colKey];
143
+ }
144
+ if (sortData && _xeUtils.default.isNumber(sortData[colKey])) {
145
+ hasCustomSort = true;
146
+ column.renderSortNumber = sortData[colKey];
147
+ }
148
+ }
149
+ if (resizableData && _xeUtils.default.isNumber(resizableData[colKey])) {
150
+ column.resizeWidth = resizableData[colKey];
151
+ }
152
+ if (visibleData && _xeUtils.default.isBoolean(visibleData[colKey])) {
153
+ column.visible = visibleData[colKey];
154
+ }
155
+ });
156
+ // 如果自定义了顺序
157
+ if (hasCustomSort) {
158
+ collectColumn = _xeUtils.default.orderBy(collectColumn, 'renderSortNumber');
159
+ internalData.collectColumn = collectColumn;
160
+ internalData.tableFullColumn = getColumnList(collectColumn);
161
+ }
162
+ reactData.isCustomStatus = true;
163
+ } else {
164
+ reactData.isCustomStatus = false;
165
+ }
166
+ }
127
167
  /**
128
- * 更新数据列的 Map
129
- * 牺牲数据组装的耗时,用来换取使用过程中的流畅
130
- */
168
+ * 还原自定义列操作状态
169
+ */
170
+ function restoreCustomStorage($xeTable) {
171
+ const props = $xeTable;
172
+ const {
173
+ customConfig
174
+ } = props;
175
+ const tableId = $xeTable.computeTableId;
176
+ const customOpts = $xeTable.computeCustomOpts;
177
+ const {
178
+ storage,
179
+ restoreStore
180
+ } = customOpts;
181
+ const isAllCustom = storage === true;
182
+ const storageOpts = isAllCustom ? {} : Object.assign({}, storage || {});
183
+ const isCustomResizable = isAllCustom || storageOpts.resizable;
184
+ const isCustomVisible = isAllCustom || storageOpts.visible;
185
+ const isCustomFixed = isAllCustom || storageOpts.fixed;
186
+ const isCustomSort = isAllCustom || storageOpts.sort;
187
+ if ((customConfig ? (0, _utils.isEnableConf)(customOpts) : customOpts.enabled) && (isCustomResizable || isCustomVisible || isCustomFixed || isCustomSort)) {
188
+ if (!tableId) {
189
+ (0, _log.errLog)('vxe.error.reqProp', ['id']);
190
+ return;
191
+ }
192
+ const storeData = getCustomStorageMap(tableId);
193
+ if (restoreStore) {
194
+ return Promise.resolve(restoreStore({
195
+ id: tableId,
196
+ type: 'restore',
197
+ storeData
198
+ })).then(storeData => {
199
+ if (!storeData) {
200
+ return;
201
+ }
202
+ return handleCustomRestore($xeTable, storeData);
203
+ }).catch(e => e);
204
+ } else {
205
+ return handleCustomRestore($xeTable, storeData);
206
+ }
207
+ }
208
+ }
209
+ /**
210
+ * 更新数据列的 Map
211
+ * 牺牲数据组装的耗时,用来换取使用过程中的流畅
212
+ */
131
213
  function cacheColumnMap($xeTable) {
132
214
  const props = $xeTable;
133
215
  const reactData = $xeTable;
@@ -182,7 +264,7 @@ function cacheColumnMap($xeTable) {
182
264
  }
183
265
  fullColumnFieldData[field] = rest;
184
266
  } else {
185
- if (storage || isCrossDrag || isSelfToChildDrag) {
267
+ if (storage || columnOpts.drag && (isCrossDrag || isSelfToChildDrag)) {
186
268
  (0, _log.errLog)('vxe.error.reqProp', [`${column.getTitle() || type || ''} -> column.field`]);
187
269
  }
188
270
  }
@@ -324,12 +406,354 @@ function handleVirtualTreeToList($xeTable) {
324
406
  }
325
407
  return internalData.afterFullData;
326
408
  }
409
+ function updateStyle($xeTable) {
410
+ const props = $xeTable;
411
+ const reactData = $xeTable;
412
+ const internalData = $xeTable;
413
+ const {
414
+ border,
415
+ showOverflow: allColumnOverflow,
416
+ showHeaderOverflow: allColumnHeaderOverflow,
417
+ showFooterOverflow: allColumnFooterOverflow,
418
+ mouseConfig,
419
+ spanMethod,
420
+ footerSpanMethod
421
+ } = props;
422
+ const {
423
+ isGroup,
424
+ currentRow,
425
+ tableColumn,
426
+ scrollXLoad,
427
+ scrollYLoad,
428
+ scrollbarWidth,
429
+ scrollbarHeight,
430
+ columnStore,
431
+ editStore,
432
+ isAllOverflow,
433
+ expandColumn
434
+ } = reactData;
435
+ const {
436
+ visibleColumn,
437
+ fullColumnIdData,
438
+ tableHeight,
439
+ tableWidth,
440
+ headerHeight,
441
+ footerHeight,
442
+ elemStore,
443
+ customHeight,
444
+ customMinHeight,
445
+ customMaxHeight
446
+ } = internalData;
447
+ const el = $xeTable.$refs.refElem;
448
+ if (!el) {
449
+ return;
450
+ }
451
+ const containerList = ['main', 'left', 'right'];
452
+ const emptyPlaceholderElem = $xeTable.$refs.refEmptyPlaceholder;
453
+ const cellOffsetWidth = $xeTable.computeCellOffsetWidth;
454
+ const mouseOpts = $xeTable.computeMouseOpts;
455
+ const bodyWrapperElem = (0, _util.getRefElem)(elemStore['main-body-wrapper']);
456
+ const bodyTableElem = (0, _util.getRefElem)(elemStore['main-body-table']);
457
+ if (emptyPlaceholderElem) {
458
+ emptyPlaceholderElem.style.top = `${headerHeight}px`;
459
+ emptyPlaceholderElem.style.height = bodyWrapperElem ? `${bodyWrapperElem.offsetHeight - scrollbarHeight}px` : '';
460
+ }
461
+ let bodyHeight = 0;
462
+ let bodyMaxHeight = 0;
463
+ const bodyMinHeight = customMinHeight - headerHeight - footerHeight - scrollbarHeight;
464
+ if (customMaxHeight) {
465
+ bodyMaxHeight = Math.max(bodyMinHeight, customMaxHeight - headerHeight - footerHeight - scrollbarHeight);
466
+ }
467
+ if (customHeight) {
468
+ bodyHeight = customHeight - headerHeight - footerHeight - scrollbarHeight;
469
+ }
470
+ if (!bodyHeight) {
471
+ if (bodyTableElem) {
472
+ bodyHeight = bodyTableElem.clientHeight;
473
+ }
474
+ }
475
+ if (bodyHeight) {
476
+ if (bodyMaxHeight) {
477
+ bodyHeight = Math.min(bodyMaxHeight, bodyHeight);
478
+ }
479
+ bodyHeight = Math.max(bodyMinHeight, bodyHeight);
480
+ }
481
+ const scrollXVirtualEl = $xeTable.$refs.refScrollXVirtualElem;
482
+ if (scrollXVirtualEl) {
483
+ scrollXVirtualEl.style.height = `${scrollbarHeight}px`;
484
+ scrollXVirtualEl.style.visibility = scrollbarHeight ? 'visible' : 'hidden';
485
+ }
486
+ const xHandleEl = $xeTable.$refs.refScrollXHandleElem;
487
+ if (xHandleEl) {
488
+ xHandleEl.style.width = `${el.clientWidth - scrollbarWidth}px`;
489
+ }
490
+ const xRightCornerEl = $xeTable.$refs.refScrollXRightCornerElem;
491
+ if (xRightCornerEl) {
492
+ xRightCornerEl.style.width = `${scrollbarWidth}px`;
493
+ xRightCornerEl.style.display = scrollbarWidth && scrollbarHeight ? 'block' : '';
494
+ }
495
+ const scrollYVirtualEl = $xeTable.$refs.refScrollYVirtualElem;
496
+ if (scrollYVirtualEl) {
497
+ scrollYVirtualEl.style.width = `${scrollbarWidth}px`;
498
+ scrollYVirtualEl.style.height = `${bodyHeight + headerHeight + footerHeight}px`;
499
+ scrollYVirtualEl.style.visibility = scrollbarWidth ? 'visible' : 'hidden';
500
+ }
501
+ const yTopCornerEl = $xeTable.$refs.refScrollYTopCornerElem;
502
+ if (yTopCornerEl) {
503
+ yTopCornerEl.style.height = `${headerHeight}px`;
504
+ yTopCornerEl.style.display = headerHeight ? 'block' : '';
505
+ }
506
+ const yHandleEl = $xeTable.$refs.refScrollYHandleElem;
507
+ if (yHandleEl) {
508
+ yHandleEl.style.height = `${bodyHeight}px`;
509
+ yHandleEl.style.top = `${headerHeight}px`;
510
+ }
511
+ const yBottomCornerEl = $xeTable.$refs.refScrollYBottomCornerElem;
512
+ if (yBottomCornerEl) {
513
+ yBottomCornerEl.style.height = `${footerHeight}px`;
514
+ yBottomCornerEl.style.top = `${headerHeight + bodyHeight}px`;
515
+ yBottomCornerEl.style.display = footerHeight ? 'block' : '';
516
+ }
517
+ containerList.forEach((name, index) => {
518
+ const fixedType = index > 0 ? name : '';
519
+ const layoutList = ['header', 'body', 'footer'];
520
+ const isFixedLeft = fixedType === 'left';
521
+ let fixedColumn = [];
522
+ let fixedWrapperElem;
523
+ if (fixedType) {
524
+ fixedColumn = isFixedLeft ? columnStore.leftList : columnStore.rightList;
525
+ fixedWrapperElem = isFixedLeft ? $xeTable.$refs.refLeftContainer : $xeTable.$refs.refRightContainer;
526
+ }
527
+ layoutList.forEach(layout => {
528
+ const wrapperElem = (0, _util.getRefElem)(elemStore[`${name}-${layout}-wrapper`]);
529
+ const currScrollElem = (0, _util.getRefElem)(elemStore[`${name}-${layout}-scroll`]);
530
+ const tableElem = (0, _util.getRefElem)(elemStore[`${name}-${layout}-table`]);
531
+ if (layout === 'header') {
532
+ // 表头体样式处理
533
+ // 横向滚动渲染
534
+ let tWidth = tableWidth;
535
+ let renderColumnList = tableColumn;
536
+ let isOptimizeMode = false;
537
+ if (isGroup) {
538
+ renderColumnList = visibleColumn;
539
+ if (fixedType) {
540
+ if (wrapperElem) {
541
+ wrapperElem.style.width = tWidth ? `${tWidth}px` : '';
542
+ }
543
+ }
544
+ } else {
545
+ // 如果是使用优化模式
546
+ if (scrollXLoad || scrollYLoad || allColumnHeaderOverflow) {
547
+ if (spanMethod || footerSpanMethod) {
548
+ // 如果不支持优化模式
549
+ } else {
550
+ isOptimizeMode = true;
551
+ }
552
+ }
553
+ if (fixedType) {
554
+ renderColumnList = visibleColumn;
555
+ // 如果是使用优化模式
556
+ if (isOptimizeMode) {
557
+ renderColumnList = fixedColumn || [];
558
+ }
559
+ if (!isOptimizeMode) {
560
+ if (wrapperElem) {
561
+ wrapperElem.style.width = tWidth ? `${tWidth}px` : '';
562
+ }
563
+ }
564
+ }
565
+ }
566
+ tWidth = renderColumnList.reduce((previous, column) => previous + column.renderWidth, 0);
567
+ if (currScrollElem) {
568
+ currScrollElem.style.height = `${headerHeight}px`;
569
+ }
570
+ if (tableElem) {
571
+ tableElem.style.width = tWidth ? `${tWidth}px` : '';
572
+ }
573
+ const repairElem = (0, _util.getRefElem)(elemStore[`${name}-${layout}-repair`]);
574
+ if (repairElem) {
575
+ repairElem.style.width = `${tableWidth}px`;
576
+ }
577
+ const listElem = (0, _util.getRefElem)(elemStore[`${name}-${layout}-list`]);
578
+ if (isGroup && listElem) {
579
+ _xeUtils.default.arrayEach(listElem.querySelectorAll('.col--group'), thElem => {
580
+ const colNode = $xeTable.getColumnNode(thElem);
581
+ if (colNode) {
582
+ const column = colNode.item;
583
+ const {
584
+ showHeaderOverflow
585
+ } = column;
586
+ const cellOverflow = _xeUtils.default.isBoolean(showHeaderOverflow) ? showHeaderOverflow : allColumnHeaderOverflow;
587
+ const showEllipsis = cellOverflow === 'ellipsis';
588
+ const showTitle = cellOverflow === 'title';
589
+ const showTooltip = cellOverflow === true || cellOverflow === 'tooltip';
590
+ const hasEllipsis = showTitle || showTooltip || showEllipsis;
591
+ let childWidth = 0;
592
+ let countChild = 0;
593
+ if (hasEllipsis) {
594
+ _xeUtils.default.eachTree(column.children, item => {
595
+ if (!item.children || !column.children.length) {
596
+ countChild++;
597
+ }
598
+ childWidth += item.renderWidth;
599
+ }, {
600
+ children: 'children'
601
+ });
602
+ }
603
+ thElem.style.width = hasEllipsis ? `${childWidth - countChild - (border ? 2 : 0)}px` : '';
604
+ }
605
+ });
606
+ }
607
+ } else if (layout === 'body') {
608
+ if (currScrollElem) {
609
+ currScrollElem.style.maxHeight = customMaxHeight ? `${bodyMaxHeight}px` : '';
610
+ currScrollElem.style.height = customHeight ? `${bodyHeight}px` : '';
611
+ currScrollElem.style.minHeight = `${bodyMinHeight}px`;
612
+ }
613
+ // 如果是固定列
614
+ if (fixedWrapperElem) {
615
+ if (wrapperElem) {
616
+ wrapperElem.style.top = `${headerHeight}px`;
617
+ }
618
+ fixedWrapperElem.style.height = `${customHeight > 0 ? customHeight : tableHeight + headerHeight + footerHeight + scrollbarHeight}px`;
619
+ fixedWrapperElem.style.width = `${fixedColumn.reduce((previous, column) => previous + column.renderWidth, 0)}px`;
620
+ }
621
+ let tWidth = tableWidth;
622
+ let renderColumnList = tableColumn;
623
+ let isOptimizeMode = false;
624
+ // 如果是使用优化模式
625
+ if (scrollXLoad || scrollYLoad || allColumnOverflow && isAllOverflow) {
626
+ if (expandColumn || spanMethod || footerSpanMethod) {
627
+ // 如果不支持优化模式
628
+ } else {
629
+ isOptimizeMode = true;
630
+ }
631
+ }
632
+ if (fixedType) {
633
+ renderColumnList = visibleColumn;
634
+ if (isOptimizeMode) {
635
+ renderColumnList = fixedColumn || [];
636
+ }
637
+ if (!isOptimizeMode) {
638
+ if (wrapperElem) {
639
+ wrapperElem.style.width = tWidth ? `${tWidth}px` : '';
640
+ }
641
+ }
642
+ }
643
+ tWidth = renderColumnList.reduce((previous, column) => previous + column.renderWidth, 0);
644
+ if (tableElem) {
645
+ tableElem.style.width = tWidth ? `${tWidth}px` : '';
646
+ // 兼容性处理
647
+ tableElem.style.paddingRight = scrollbarWidth && fixedType && (_dom.browse['-moz'] || _dom.browse.safari) ? `${scrollbarWidth}px` : '';
648
+ }
649
+ const emptyBlockElem = (0, _util.getRefElem)(elemStore[`${name}-${layout}-emptyBlock`]);
650
+ if (emptyBlockElem) {
651
+ emptyBlockElem.style.width = tWidth ? `${tWidth}px` : '';
652
+ }
653
+ } else if (layout === 'footer') {
654
+ let tWidth = tableWidth;
655
+ let renderColumnList = tableColumn;
656
+ let isOptimizeMode = false;
657
+ // 如果是使用优化模式
658
+ if (scrollXLoad || scrollYLoad || allColumnFooterOverflow) {
659
+ if (spanMethod || footerSpanMethod) {
660
+ // 如果不支持优化模式
661
+ } else {
662
+ isOptimizeMode = true;
663
+ }
664
+ }
665
+ if (fixedType) {
666
+ renderColumnList = visibleColumn;
667
+ if (isOptimizeMode) {
668
+ renderColumnList = fixedColumn || [];
669
+ }
670
+ if (!isOptimizeMode) {
671
+ if (wrapperElem) {
672
+ wrapperElem.style.width = tWidth ? `${tWidth}px` : '';
673
+ }
674
+ }
675
+ }
676
+ tWidth = renderColumnList.reduce((previous, column) => previous + column.renderWidth, 0);
677
+ if (currScrollElem) {
678
+ currScrollElem.style.height = `${footerHeight}px`;
679
+ // 如果是固定列
680
+ if (fixedWrapperElem) {
681
+ if (wrapperElem) {
682
+ wrapperElem.style.top = `${customHeight > 0 ? customHeight - footerHeight - scrollbarHeight : tableHeight + headerHeight}px`;
683
+ }
684
+ }
685
+ }
686
+ if (tableElem) {
687
+ tableElem.style.width = tWidth ? `${tWidth}px` : '';
688
+ }
689
+ }
690
+ const colgroupElem = (0, _util.getRefElem)(elemStore[`${name}-${layout}-colgroup`]);
691
+ if (colgroupElem) {
692
+ _xeUtils.default.arrayEach(colgroupElem.children, colElem => {
693
+ const colid = colElem.getAttribute('name');
694
+ if (fullColumnIdData[colid]) {
695
+ const colRest = fullColumnIdData[colid];
696
+ const column = colRest.column;
697
+ const {
698
+ showHeaderOverflow,
699
+ showFooterOverflow,
700
+ showOverflow
701
+ } = column;
702
+ let cellOverflow;
703
+ colElem.style.width = `${column.renderWidth}px`;
704
+ if (layout === 'header') {
705
+ cellOverflow = _xeUtils.default.isUndefined(showHeaderOverflow) || _xeUtils.default.isNull(showHeaderOverflow) ? allColumnHeaderOverflow : showHeaderOverflow;
706
+ } else if (layout === 'footer') {
707
+ cellOverflow = _xeUtils.default.isUndefined(showFooterOverflow) || _xeUtils.default.isNull(showFooterOverflow) ? allColumnFooterOverflow : showFooterOverflow;
708
+ } else {
709
+ cellOverflow = _xeUtils.default.isUndefined(showOverflow) || _xeUtils.default.isNull(showOverflow) ? allColumnOverflow : showOverflow;
710
+ }
711
+ const showEllipsis = cellOverflow === 'ellipsis';
712
+ const showTitle = cellOverflow === 'title';
713
+ const showTooltip = cellOverflow === true || cellOverflow === 'tooltip';
714
+ let hasEllipsis = showTitle || showTooltip || showEllipsis;
715
+ const listElem = (0, _util.getRefElem)(elemStore[`${name}-${layout}-list`]);
716
+ // 纵向虚拟滚动不支持动态行高
717
+ if (scrollYLoad && !hasEllipsis) {
718
+ hasEllipsis = true;
719
+ }
720
+ if (listElem) {
721
+ _xeUtils.default.arrayEach(listElem.querySelectorAll(`.${column.id}`), elem => {
722
+ const colspan = parseInt(elem.getAttribute('colspan') || 1);
723
+ const cellElem = elem.querySelector('.vxe-cell');
724
+ let colWidth = column.renderWidth;
725
+ if (cellElem) {
726
+ if (colspan > 1) {
727
+ const columnIndex = $xeTable.getColumnIndex(column);
728
+ for (let index = 1; index < colspan; index++) {
729
+ const nextColumn = $xeTable.getColumns(columnIndex + index);
730
+ if (nextColumn) {
731
+ colWidth += nextColumn.renderWidth;
732
+ }
733
+ }
734
+ }
735
+ cellElem.style.width = hasEllipsis ? `${colWidth - cellOffsetWidth * colspan}px` : '';
736
+ }
737
+ });
738
+ }
739
+ }
740
+ });
741
+ }
742
+ });
743
+ });
744
+ if (currentRow) {
745
+ $xeTable.setCurrentRow(currentRow);
746
+ }
747
+ if (mouseConfig && mouseOpts.selected && editStore.selected.row && editStore.selected.column) {
748
+ $xeTable.addCellSelectedClass();
749
+ }
750
+ return $xeTable.$nextTick();
751
+ }
327
752
  function computeRowHeight($xeTable) {
328
- const tableHeader = $xeTable.$refs.tableHeader;
329
- const tableBody = $xeTable.$refs.tableBody;
753
+ const tableHeader = $xeTable.$refs.refTableHeader;
754
+ const tableBody = $xeTable.$refs.refTableBody;
330
755
  const tableBodyElem = tableBody ? tableBody.$el : null;
331
- const vSize = $xeTable.computeSize;
332
- const rowHeightMaps = $xeTable.computeRowHeightMaps;
756
+ const defaultRowHeight = $xeTable.computeDefaultRowHeight;
333
757
  let rowHeight = 0;
334
758
  if (tableBodyElem) {
335
759
  const tableHeaderElem = tableHeader ? tableHeader.$el : null;
@@ -343,32 +767,32 @@ function computeRowHeight($xeTable) {
343
767
  }
344
768
  }
345
769
  if (!rowHeight) {
346
- rowHeight = rowHeightMaps[vSize || 'default'];
770
+ rowHeight = defaultRowHeight;
347
771
  }
348
772
  // 最低支持 18px 行高
349
773
  return Math.max(18, rowHeight);
350
774
  }
351
775
  function handleVirtualYVisible($xeTable) {
352
776
  const props = $xeTable;
777
+ const reactData = $xeTable;
353
778
  const internalData = $xeTable;
354
779
  const {
355
780
  showOverflow
356
781
  } = props;
357
782
  const {
358
- scrollYStore,
783
+ rowHeight
784
+ } = reactData;
785
+ const {
786
+ elemStore,
359
787
  afterFullData,
360
788
  fullAllDataRowIdData
361
789
  } = internalData;
362
- const tableBody = $xeTable.$refs.tableBody;
363
- const tableBodyElem = tableBody ? tableBody.$el : null;
364
- const {
365
- rowHeight
366
- } = scrollYStore;
367
- if (tableBodyElem) {
790
+ const bodyScrollElem = (0, _util.getRefElem)(elemStore['main-body-scroll']);
791
+ if (bodyScrollElem) {
368
792
  const {
369
793
  scrollTop,
370
794
  clientHeight
371
- } = tableBodyElem;
795
+ } = bodyScrollElem;
372
796
  const endHeight = scrollTop + clientHeight;
373
797
  let toVisibleIndex = -1;
374
798
  let offsetTop = 0;
@@ -395,12 +819,12 @@ function handleVirtualYVisible($xeTable) {
395
819
  }
396
820
  return {
397
821
  toVisibleIndex: Math.max(0, toVisibleIndex),
398
- visibleSize: Math.max(8, visibleSize)
822
+ visibleSize: Math.max(6, visibleSize)
399
823
  };
400
824
  }
401
825
  return {
402
826
  toVisibleIndex: 0,
403
- visibleSize: 8
827
+ visibleSize: 6
404
828
  };
405
829
  }
406
830
  function calculateMergerOffsetIndex(list, offsetItem, type) {
@@ -551,18 +975,26 @@ function autoCellWidth($xeTable) {
551
975
  const props = $xeTable;
552
976
  const reactData = $xeTable;
553
977
  const internalData = $xeTable;
554
- const tableHeader = $xeTable.$refs.tableHeader;
555
- const tableBody = $xeTable.$refs.tableBody;
556
- const tableFooter = $xeTable.$refs.tableFooter;
978
+ const {
979
+ elemStore
980
+ } = internalData;
981
+ const scrollbarOpts = $xeTable.computeScrollbarOpts;
982
+ const tableBody = $xeTable.$refs.refTableBody;
557
983
  const bodyElem = tableBody ? tableBody.$el : null;
558
- const headerElem = tableHeader ? tableHeader.$el : null;
559
- const footerElem = tableFooter ? tableFooter.$el : null;
560
984
  if (!bodyElem) {
561
985
  return;
562
986
  }
987
+ const yHandleEl = $xeTable.$refs.refScrollYHandleElem;
988
+ if (!yHandleEl) {
989
+ return;
990
+ }
991
+ const xHandleEl = $xeTable.$refs.refScrollXHandleElem;
992
+ if (!xHandleEl) {
993
+ return;
994
+ }
563
995
  let tableWidth = 0;
564
996
  const minCellWidth = 40; // 列宽最少限制 40px
565
- const bodyWidth = bodyElem.clientWidth - 1;
997
+ const bodyWidth = bodyElem.clientWidth;
566
998
  let remainWidth = bodyWidth;
567
999
  let meanWidth = remainWidth / 100;
568
1000
  const {
@@ -643,16 +1075,16 @@ function autoCellWidth($xeTable) {
643
1075
  });
644
1076
  if (fit) {
645
1077
  /**
646
- * 偏移量算法
647
- * 如果所有列足够放的情况下,从最后动态列开始分配
648
- */
1078
+ * 偏移量算法
1079
+ * 如果所有列足够放的情况下,从最后动态列开始分配
1080
+ */
649
1081
  const dynamicList = scaleList.concat(scaleMinList).concat(pxMinList).concat(autoMinList).concat(remainList);
650
1082
  let dynamicSize = dynamicList.length - 1;
651
1083
  if (dynamicSize > 0) {
652
- let odiffer = bodyWidth - tableWidth;
653
- if (odiffer > 0) {
654
- while (odiffer > 0 && dynamicSize >= 0) {
655
- odiffer--;
1084
+ let i = bodyWidth - tableWidth;
1085
+ if (i > 0) {
1086
+ while (i > 0 && dynamicSize >= 0) {
1087
+ i--;
656
1088
  dynamicList[dynamicSize--].renderWidth++;
657
1089
  }
658
1090
  tableWidth = bodyWidth;
@@ -660,40 +1092,20 @@ function autoCellWidth($xeTable) {
660
1092
  }
661
1093
  }
662
1094
  const tableHeight = bodyElem.offsetHeight;
663
- const overflowY = bodyElem.scrollHeight > bodyElem.clientHeight;
664
- let scrollbarWidth = 0;
665
- if (overflowY) {
666
- scrollbarWidth = Math.max(bodyElem.offsetWidth - bodyElem.clientWidth, 0);
667
- }
668
- reactData.scrollbarWidth = scrollbarWidth;
1095
+ const overflowY = yHandleEl.scrollHeight > yHandleEl.clientHeight;
1096
+ reactData.scrollbarWidth = overflowY ? Math.max(scrollbarOpts.width || 0, yHandleEl.offsetWidth - yHandleEl.clientWidth) : 0;
669
1097
  reactData.overflowY = overflowY;
670
1098
  internalData.tableWidth = tableWidth;
671
1099
  internalData.tableHeight = tableHeight;
672
- let headerHeight = 0;
673
- if (headerElem) {
674
- headerHeight = headerElem.clientHeight;
675
- $xeTable.$nextTick(() => {
676
- // 检测是否同步滚动
677
- if (headerElem && bodyElem && headerElem.scrollLeft !== bodyElem.scrollLeft) {
678
- headerElem.scrollLeft = bodyElem.scrollLeft;
679
- }
680
- });
681
- }
1100
+ const headerTableElem = (0, _util.getRefElem)(elemStore['main-header-table']);
1101
+ const footerTableElem = (0, _util.getRefElem)(elemStore['main-footer-table']);
1102
+ const headerHeight = headerTableElem ? headerTableElem.clientHeight : 0;
1103
+ const overflowX = tableWidth > bodyWidth;
1104
+ const footerHeight = footerTableElem ? footerTableElem.clientHeight : 0;
1105
+ reactData.scrollbarHeight = overflowX ? Math.max(scrollbarOpts.height || 0, xHandleEl.offsetHeight - xHandleEl.clientHeight) : 0;
682
1106
  internalData.headerHeight = headerHeight;
683
- let overflowX = false;
684
- let footerHeight = 0;
685
- let scrollbarHeight = 0;
686
- if (footerElem) {
687
- footerHeight = footerElem.offsetHeight;
688
- overflowX = tableWidth > footerElem.clientWidth;
689
- scrollbarHeight = Math.max(footerHeight - footerElem.clientHeight, 0);
690
- } else {
691
- overflowX = tableWidth > bodyWidth;
692
- scrollbarHeight = Math.max(tableHeight - bodyElem.clientHeight, 0);
693
- }
694
1107
  internalData.footerHeight = footerHeight;
695
1108
  reactData.overflowX = overflowX;
696
- reactData.scrollbarHeight = scrollbarHeight;
697
1109
  updateHeight($xeTable);
698
1110
  reactData.parentHeight = Math.max(internalData.headerHeight + footerHeight + 20, $xeTable.getParentHeight());
699
1111
  if (overflowX) {
@@ -931,9 +1343,9 @@ function showDropTip($xeTable, evnt, trEl, thEl, showLine, dragPos) {
931
1343
  const cdLineEl = $xeTable.$refs.refDragColLineElem;
932
1344
  if (cdLineEl) {
933
1345
  if (showLine) {
934
- const leftContainerElem = $xeTable.$refs.leftContainer;
1346
+ const leftContainerElem = $xeTable.$refs.refLeftContainer;
935
1347
  const leftContainerWidth = leftContainerElem ? leftContainerElem.clientWidth : 0;
936
- const rightContainerElem = $xeTable.$refs.rightContainer;
1348
+ const rightContainerElem = $xeTable.$refs.refRightContainer;
937
1349
  const rightContainerWidth = rightContainerElem ? rightContainerElem.clientWidth : 0;
938
1350
  const thRect = thEl.getBoundingClientRect();
939
1351
  let thWidth = thEl.clientWidth;
@@ -1015,12 +1427,16 @@ function computeScrollLoad($xeTable) {
1015
1427
  // 计算 X 逻辑
1016
1428
  if (scrollXLoad) {
1017
1429
  const {
1430
+ toVisibleIndex: toXVisibleIndex,
1018
1431
  visibleSize: visibleXSize
1019
1432
  } = handleVirtualXVisible($xeTable);
1020
- const offsetXSize = Math.max(0, sXOpts.oSize ? _xeUtils.default.toNumber(sXOpts.oSize) : _dom.browse.edge ? 5 : 0);
1433
+ const offsetXSize = Math.max(0, sXOpts.oSize ? _xeUtils.default.toNumber(sXOpts.oSize) : 0);
1434
+ scrollXStore.preloadSize = 4;
1021
1435
  scrollXStore.offsetSize = offsetXSize;
1022
1436
  scrollXStore.visibleSize = visibleXSize;
1023
1437
  scrollXStore.endIndex = Math.max(scrollXStore.startIndex + scrollXStore.visibleSize + offsetXSize, scrollXStore.endIndex);
1438
+ scrollXStore.visibleStartIndex = Math.max(scrollXStore.startIndex, toXVisibleIndex);
1439
+ scrollXStore.visibleEndIndex = Math.min(scrollXStore.endIndex, toXVisibleIndex + visibleXSize);
1024
1440
  $xeTable.updateScrollXData().then(() => {
1025
1441
  loadScrollXData($xeTable);
1026
1442
  });
@@ -1033,13 +1449,17 @@ function computeScrollLoad($xeTable) {
1033
1449
  scrollYStore.rowHeight = rowHeight;
1034
1450
  reactData.rowHeight = rowHeight;
1035
1451
  const {
1452
+ toVisibleIndex: toYVisibleIndex,
1036
1453
  visibleSize: visibleYSize
1037
1454
  } = handleVirtualYVisible($xeTable);
1038
1455
  if (scrollYLoad) {
1039
- const offsetYSize = Math.max(0, sYOpts.oSize ? _xeUtils.default.toNumber(sYOpts.oSize) : _dom.browse.edge ? 10 : 0);
1456
+ const offsetYSize = Math.max(0, sYOpts.oSize ? _xeUtils.default.toNumber(sYOpts.oSize) : 0);
1457
+ scrollYStore.preloadSize = 2;
1040
1458
  scrollYStore.offsetSize = offsetYSize;
1041
1459
  scrollYStore.visibleSize = visibleYSize;
1042
1460
  scrollYStore.endIndex = Math.max(scrollYStore.startIndex + visibleYSize + offsetYSize, scrollYStore.endIndex);
1461
+ scrollYStore.visibleStartIndex = Math.max(scrollYStore.startIndex, toYVisibleIndex);
1462
+ scrollYStore.visibleEndIndex = Math.min(scrollYStore.endIndex, toYVisibleIndex + visibleYSize);
1043
1463
  $xeTable.updateScrollYData().then(() => {
1044
1464
  loadScrollYData($xeTable);
1045
1465
  });
@@ -1047,7 +1467,7 @@ function computeScrollLoad($xeTable) {
1047
1467
  $xeTable.updateScrollYSpace();
1048
1468
  }
1049
1469
  $xeTable.$nextTick(() => {
1050
- $xeTable.updateStyle();
1470
+ updateStyle($xeTable);
1051
1471
  });
1052
1472
  });
1053
1473
  }
@@ -1070,6 +1490,35 @@ function handleRecalculateLayout($xeTable, reFull) {
1070
1490
  }
1071
1491
  });
1072
1492
  }
1493
+ function handleTableColumn($xeTable) {
1494
+ const reactData = $xeTable;
1495
+ const internalData = $xeTable;
1496
+ const {
1497
+ scrollXLoad
1498
+ } = reactData;
1499
+ const {
1500
+ visibleColumn,
1501
+ scrollXStore,
1502
+ fullColumnIdData
1503
+ } = internalData;
1504
+ const tableColumn = scrollXLoad ? visibleColumn.slice(scrollXStore.startIndex, scrollXStore.endIndex) : visibleColumn.slice(0);
1505
+ tableColumn.forEach((column, $index) => {
1506
+ const colid = column.id;
1507
+ const colRest = fullColumnIdData[colid];
1508
+ if (colRest) {
1509
+ colRest.$index = $index;
1510
+ }
1511
+ });
1512
+ reactData.tableColumn = tableColumn;
1513
+ }
1514
+ function handleUpdateColumn($xeTable) {
1515
+ const internalData = $xeTable;
1516
+ const columnList = _xeUtils.default.orderBy(internalData.collectColumn, 'renderSortNumber');
1517
+ internalData.collectColumn = columnList;
1518
+ const tableFullColumn = getColumnList(columnList);
1519
+ internalData.tableFullColumn = tableFullColumn;
1520
+ cacheColumnMap($xeTable);
1521
+ }
1073
1522
  function loadScrollXData($xeTable) {
1074
1523
  const reactData = $xeTable;
1075
1524
  const internalData = $xeTable;
@@ -1081,6 +1530,7 @@ function loadScrollXData($xeTable) {
1081
1530
  scrollXStore
1082
1531
  } = internalData;
1083
1532
  const {
1533
+ preloadSize,
1084
1534
  startIndex,
1085
1535
  endIndex,
1086
1536
  offsetSize
@@ -1090,9 +1540,11 @@ function loadScrollXData($xeTable) {
1090
1540
  visibleSize
1091
1541
  } = handleVirtualXVisible($xeTable);
1092
1542
  const offsetItem = {
1093
- startIndex: Math.max(0, toVisibleIndex - 1 - offsetSize),
1094
- endIndex: toVisibleIndex + visibleSize + offsetSize
1543
+ startIndex: Math.max(0, toVisibleIndex - 1 - offsetSize - preloadSize),
1544
+ endIndex: toVisibleIndex + visibleSize + offsetSize + preloadSize
1095
1545
  };
1546
+ scrollXStore.visibleStartIndex = toVisibleIndex;
1547
+ scrollXStore.visibleEndIndex = toVisibleIndex + visibleSize;
1096
1548
  calculateMergerOffsetIndex(mergeList.concat(mergeFooterList), offsetItem, 'col');
1097
1549
  const {
1098
1550
  startIndex: offsetStartIndex,
@@ -1104,8 +1556,210 @@ function loadScrollXData($xeTable) {
1104
1556
  scrollXStore.endIndex = offsetEndIndex;
1105
1557
  $xeTable.updateScrollXData();
1106
1558
  }
1107
- }
1108
- $xeTable.closeTooltip();
1559
+ }
1560
+ $xeTable.closeTooltip();
1561
+ }
1562
+ // 获取所有的列,排除分组
1563
+ function getColumnList(columns) {
1564
+ const result = [];
1565
+ columns.forEach(column => {
1566
+ result.push(...(column.children && column.children.length ? getColumnList(column.children) : [column]));
1567
+ });
1568
+ return result;
1569
+ }
1570
+ function parseColumns($xeTable, isReset) {
1571
+ const props = $xeTable;
1572
+ const reactData = $xeTable;
1573
+ const internalData = $xeTable;
1574
+ const {
1575
+ showOverflow
1576
+ } = props;
1577
+ const rowOpts = $xeTable.computeRowOpts;
1578
+ const leftList = [];
1579
+ const centerList = [];
1580
+ const rightList = [];
1581
+ const {
1582
+ isGroup,
1583
+ columnStore
1584
+ } = reactData;
1585
+ const sXOpts = $xeTable.computeSXOpts;
1586
+ const {
1587
+ collectColumn,
1588
+ tableFullColumn,
1589
+ scrollXStore,
1590
+ fullColumnIdData
1591
+ } = internalData;
1592
+ // 如果是分组表头,如果子列全部被隐藏,则根列也隐藏
1593
+ if (isGroup) {
1594
+ const leftGroupList = [];
1595
+ const centerGroupList = [];
1596
+ const rightGroupList = [];
1597
+ _xeUtils.default.eachTree(collectColumn, (column, index, items, path, parentColumn) => {
1598
+ const isColGroup = (0, _utils.hasChildrenList)(column);
1599
+ // 如果是分组,必须按组设置固定列,不允许给子列设置固定
1600
+ if (parentColumn && parentColumn.fixed) {
1601
+ column.fixed = parentColumn.fixed;
1602
+ }
1603
+ if (parentColumn && column.fixed !== parentColumn.fixed) {
1604
+ (0, _log.errLog)('vxe.error.groupFixed');
1605
+ }
1606
+ if (isColGroup) {
1607
+ column.visible = !!_xeUtils.default.findTree(column.children, subColumn => (0, _utils.hasChildrenList)(subColumn) ? false : subColumn.visible);
1608
+ } else if (column.visible) {
1609
+ if (column.fixed === 'left') {
1610
+ leftList.push(column);
1611
+ } else if (column.fixed === 'right') {
1612
+ rightList.push(column);
1613
+ } else {
1614
+ centerList.push(column);
1615
+ }
1616
+ }
1617
+ });
1618
+ collectColumn.forEach(column => {
1619
+ if (column.visible) {
1620
+ if (column.fixed === 'left') {
1621
+ leftGroupList.push(column);
1622
+ } else if (column.fixed === 'right') {
1623
+ rightGroupList.push(column);
1624
+ } else {
1625
+ centerGroupList.push(column);
1626
+ }
1627
+ }
1628
+ });
1629
+ reactData.tableGroupColumn = leftGroupList.concat(centerGroupList).concat(rightGroupList);
1630
+ } else {
1631
+ // 重新分配列
1632
+ tableFullColumn.forEach(column => {
1633
+ if (column.visible) {
1634
+ if (column.fixed === 'left') {
1635
+ leftList.push(column);
1636
+ } else if (column.fixed === 'right') {
1637
+ rightList.push(column);
1638
+ } else {
1639
+ centerList.push(column);
1640
+ }
1641
+ }
1642
+ });
1643
+ }
1644
+ const visibleColumn = leftList.concat(centerList).concat(rightList);
1645
+ // 如果gt为0,则总是启用
1646
+ const scrollXLoad = !!sXOpts.enabled && sXOpts.gt > -1 && (sXOpts.gt === 0 || sXOpts.gt < tableFullColumn.length);
1647
+ reactData.hasFixedColumn = leftList.length > 0 || rightList.length > 0;
1648
+ Object.assign(columnStore, {
1649
+ leftList,
1650
+ centerList,
1651
+ rightList
1652
+ });
1653
+ if (scrollXLoad) {
1654
+ if (showOverflow) {
1655
+ if (!rowOpts.height) {
1656
+ const errColumn = internalData.tableFullColumn.find(column => column.showOverflow === false);
1657
+ if (errColumn) {
1658
+ (0, _log.errLog)('vxe.error.errProp', [`column[field="${errColumn.field}"].show-overflow=false`, 'show-overflow=true']);
1659
+ }
1660
+ }
1661
+ }
1662
+ if (process.env.NODE_ENV === 'development') {
1663
+ // if (props.showHeader && !props.showHeaderOverflow) {
1664
+ // warnLog('vxe.error.reqProp', ['show-header-overflow'])
1665
+ // }
1666
+ // if (props.showFooter && !props.showFooterOverflow) {
1667
+ // warnLog('vxe.error.reqProp', ['show-footer-overflow'])
1668
+ // }
1669
+ if (props.spanMethod) {
1670
+ (0, _log.warnLog)('vxe.error.scrollErrProp', ['span-method']);
1671
+ }
1672
+ if (props.footerSpanMethod) {
1673
+ (0, _log.warnLog)('vxe.error.scrollErrProp', ['footer-span-method']);
1674
+ }
1675
+ }
1676
+ if (isReset) {
1677
+ const {
1678
+ visibleSize
1679
+ } = handleVirtualXVisible($xeTable);
1680
+ scrollXStore.startIndex = 0;
1681
+ scrollXStore.endIndex = visibleSize;
1682
+ scrollXStore.visibleSize = visibleSize;
1683
+ scrollXStore.visibleStartIndex = 0;
1684
+ scrollXStore.visibleEndIndex = visibleSize;
1685
+ }
1686
+ }
1687
+ // 如果列被显示/隐藏,则清除合并状态
1688
+ // 如果列被设置为固定,则清除合并状态
1689
+ if (visibleColumn.length !== internalData.visibleColumn.length || !internalData.visibleColumn.every((column, index) => column === visibleColumn[index])) {
1690
+ $xeTable.clearMergeCells();
1691
+ $xeTable.clearMergeFooterItems();
1692
+ }
1693
+ reactData.scrollXLoad = scrollXLoad;
1694
+ visibleColumn.forEach((column, index) => {
1695
+ const colid = column.id;
1696
+ const colRest = fullColumnIdData[colid];
1697
+ if (colRest) {
1698
+ colRest._index = index;
1699
+ }
1700
+ });
1701
+ internalData.visibleColumn = visibleColumn;
1702
+ handleTableColumn($xeTable);
1703
+ if (isReset) {
1704
+ return $xeTable.updateFooter().then(() => {
1705
+ return $xeTable.recalculate();
1706
+ }).then(() => {
1707
+ $xeTable.updateCellAreas();
1708
+ return $xeTable.recalculate();
1709
+ });
1710
+ }
1711
+ return $xeTable.updateFooter();
1712
+ }
1713
+ function initColumnSort($xeTable) {
1714
+ const internalData = $xeTable;
1715
+ const {
1716
+ collectColumn
1717
+ } = internalData;
1718
+ collectColumn.forEach((column, index) => {
1719
+ const sortIndex = index + 1;
1720
+ column.sortNumber = sortIndex;
1721
+ column.renderSortNumber = sortIndex;
1722
+ });
1723
+ }
1724
+ function handleColumn($xeTable, collectColumn) {
1725
+ const $xeToolbar = $xeTable.$refs.$xeToolbar;
1726
+ const reactData = $xeTable;
1727
+ const internalData = $xeTable;
1728
+ internalData.collectColumn = collectColumn;
1729
+ const tableFullColumn = getColumnList(collectColumn);
1730
+ internalData.tableFullColumn = tableFullColumn;
1731
+ reactData.isLoading = true;
1732
+ reactData.isDragColMove = false;
1733
+ initColumnSort($xeTable);
1734
+ return Promise.resolve(restoreCustomStorage($xeTable)).then(() => {
1735
+ reactData.isLoading = false;
1736
+ cacheColumnMap($xeTable);
1737
+ parseColumns($xeTable, true).then(() => {
1738
+ if (reactData.scrollXLoad) {
1739
+ loadScrollXData($xeTable);
1740
+ }
1741
+ });
1742
+ $xeTable.clearMergeCells();
1743
+ $xeTable.clearMergeFooterItems();
1744
+ $xeTable.handleTableData(true);
1745
+ if (process.env.NODE_ENV === 'development') {
1746
+ if ((reactData.scrollXLoad || reactData.scrollYLoad) && reactData.expandColumn) {
1747
+ (0, _log.warnLog)('vxe.error.scrollErrProp', ['column.type=expand']);
1748
+ }
1749
+ }
1750
+ return $xeTable.$nextTick().then(() => {
1751
+ if ($xeToolbar) {
1752
+ $xeToolbar.syncUpdate({
1753
+ collectColumn: internalData.collectColumn,
1754
+ $table: $xeTable
1755
+ });
1756
+ }
1757
+ if ($xeTable.handleUpdateCustomColumn) {
1758
+ $xeTable.handleUpdateCustomColumn();
1759
+ }
1760
+ return $xeTable.recalculate();
1761
+ });
1762
+ });
1109
1763
  }
1110
1764
  /**
1111
1765
  * 纵向 Y 可视渲染处理
@@ -1121,23 +1775,25 @@ function loadScrollYData($xeTable) {
1121
1775
  mergeList
1122
1776
  } = reactData;
1123
1777
  const {
1124
- tableHeight,
1125
1778
  scrollYStore
1126
1779
  } = internalData;
1127
1780
  const {
1781
+ preloadSize,
1128
1782
  startIndex,
1129
1783
  endIndex,
1130
1784
  offsetSize
1131
1785
  } = scrollYStore;
1132
- const autoOffsetYSize = showOverflow ? offsetSize : offsetSize + Math.min(8, Math.ceil(tableHeight / 200));
1786
+ const autoOffsetYSize = showOverflow ? offsetSize : offsetSize + 1;
1133
1787
  const {
1134
1788
  toVisibleIndex,
1135
1789
  visibleSize
1136
1790
  } = handleVirtualYVisible($xeTable);
1137
1791
  const offsetItem = {
1138
- startIndex: Math.max(0, toVisibleIndex - 1 - offsetSize),
1139
- endIndex: toVisibleIndex + visibleSize + autoOffsetYSize
1792
+ startIndex: Math.max(0, toVisibleIndex - 1 - offsetSize - preloadSize),
1793
+ endIndex: toVisibleIndex + visibleSize + autoOffsetYSize + preloadSize
1140
1794
  };
1795
+ scrollYStore.visibleStartIndex = toVisibleIndex;
1796
+ scrollYStore.visibleEndIndex = toVisibleIndex + visibleSize;
1141
1797
  calculateMergerOffsetIndex(mergeList, offsetItem, 'row');
1142
1798
  const {
1143
1799
  startIndex: offsetStartIndex,
@@ -1168,16 +1824,20 @@ function checkLastSyncScroll($xeTable, isRollX, isRollY) {
1168
1824
  internalData.lcsRunTime = Date.now();
1169
1825
  internalData.lcsTimeout = undefined;
1170
1826
  internalData.inVirtualScroll = false;
1827
+ internalData.inWheelScroll = false;
1828
+ internalData.inHeaderScroll = false;
1171
1829
  internalData.inBodyScroll = false;
1172
1830
  internalData.inFooterScroll = false;
1173
- internalData.bodyScrollType = '';
1831
+ internalData.scrollRenderType = '';
1174
1832
  if (isRollX && scrollXLoad) {
1175
1833
  $xeTable.updateScrollXData().then(() => {
1834
+ calcCellHeight($xeTable);
1176
1835
  loadScrollXData($xeTable);
1177
1836
  });
1178
1837
  }
1179
1838
  if (isRollY && scrollYLoad) {
1180
1839
  $xeTable.updateScrollYData().then(() => {
1840
+ calcCellHeight($xeTable);
1181
1841
  loadScrollYData($xeTable);
1182
1842
  });
1183
1843
  }
@@ -1477,7 +2137,7 @@ const Methods = {
1477
2137
  this.updateFooter();
1478
2138
  return this.$nextTick().then(() => {
1479
2139
  updateHeight($xeTable);
1480
- this.updateStyle();
2140
+ updateStyle($xeTable);
1481
2141
  }).then(() => {
1482
2142
  computeScrollLoad($xeTable);
1483
2143
  }).then(() => {
@@ -1500,9 +2160,15 @@ const Methods = {
1500
2160
  }
1501
2161
  // 是否变更虚拟滚动
1502
2162
  if (oldScrollYLoad === sYLoad) {
1503
- (0, _util.restoreScrollLocation)(this, targetScrollLeft, targetScrollTop).then(resolve);
2163
+ (0, _util.restoreScrollLocation)(this, targetScrollLeft, targetScrollTop).then(() => {
2164
+ resolve();
2165
+ });
1504
2166
  } else {
1505
- setTimeout(() => (0, _util.restoreScrollLocation)(this, targetScrollLeft, targetScrollTop).then(resolve));
2167
+ setTimeout(() => {
2168
+ (0, _util.restoreScrollLocation)(this, targetScrollLeft, targetScrollTop).then(() => {
2169
+ resolve();
2170
+ });
2171
+ });
1506
2172
  }
1507
2173
  });
1508
2174
  });
@@ -1592,10 +2258,11 @@ const Methods = {
1592
2258
  * @param {ColumnInfo} columns 列配置
1593
2259
  */
1594
2260
  loadColumn(columns) {
2261
+ const $xeTable = this;
1595
2262
  const collectColumn = _xeUtils.default.mapTree(columns, column => _cell.default.createColumn(this, column), {
1596
2263
  children: 'children'
1597
2264
  });
1598
- return this.handleColumn(collectColumn);
2265
+ return handleColumn($xeTable, collectColumn);
1599
2266
  },
1600
2267
  /**
1601
2268
  * 加载列配置并恢复到初始状态
@@ -1607,53 +2274,9 @@ const Methods = {
1607
2274
  return this.loadColumn(columns);
1608
2275
  });
1609
2276
  },
1610
- initColumnSort() {
1611
- const {
1612
- collectColumn
1613
- } = this;
1614
- collectColumn.forEach((column, index) => {
1615
- const sortIndex = index + 1;
1616
- column.sortNumber = sortIndex;
1617
- column.renderSortNumber = sortIndex;
1618
- });
1619
- },
1620
2277
  handleColumn(collectColumn) {
1621
2278
  const $xeTable = this;
1622
- this.collectColumn = collectColumn;
1623
- const tableFullColumn = getColumnList(collectColumn);
1624
- this.tableFullColumn = tableFullColumn;
1625
- this._isLoading = true;
1626
- this.isDragColMove = false;
1627
- this.initColumnSort();
1628
- return Promise.resolve(this.restoreCustomStorage()).then(() => {
1629
- this._isLoading = false;
1630
- cacheColumnMap($xeTable);
1631
- this.parseColumns(true).then(() => {
1632
- if (this.scrollXLoad) {
1633
- loadScrollXData($xeTable);
1634
- }
1635
- });
1636
- this.clearMergeCells();
1637
- this.clearMergeFooterItems();
1638
- this.handleTableData(true);
1639
- if (process.env.NODE_ENV === 'development') {
1640
- if ((this.scrollXLoad || this.scrollYLoad) && this.expandColumn) {
1641
- (0, _log.warnLog)('vxe.error.scrollErrProp', ['column.type=expand']);
1642
- }
1643
- }
1644
- return this.$nextTick().then(() => {
1645
- if (this.$toolbar) {
1646
- this.$toolbar.syncUpdate({
1647
- collectColumn: this.collectColumn,
1648
- $table: this
1649
- });
1650
- }
1651
- if ($xeTable.handleUpdateCustomColumn) {
1652
- $xeTable.handleUpdateCustomColumn();
1653
- }
1654
- return this.recalculate();
1655
- });
1656
- });
2279
+ return handleColumn($xeTable, collectColumn);
1657
2280
  },
1658
2281
  /**
1659
2282
  * 更新数据行的 Map
@@ -2203,7 +2826,7 @@ const Methods = {
2203
2826
  const rowid = (0, _util.getRowid)(this, row);
2204
2827
  let bodyElem = null;
2205
2828
  if (column) {
2206
- bodyElem = $refs[`${column.fixed || 'table'}Body`] || $refs.tableBody;
2829
+ bodyElem = $refs[`${column.fixed || 'table'}Body`] || $refs.refTableBody;
2207
2830
  }
2208
2831
  if (bodyElem && bodyElem.$el) {
2209
2832
  return bodyElem.$el.querySelector(`.vxe-body--row[rowid="${rowid}"] .${column.id}`);
@@ -2770,16 +3393,21 @@ const Methods = {
2770
3393
  * 只对 tree-config 有效,获取行的父级
2771
3394
  */
2772
3395
  getTreeParentRow(rowOrRowid) {
3396
+ const $xeTable = this;
3397
+ const props = $xeTable;
3398
+ const internalData = $xeTable;
3399
+ const {
3400
+ treeConfig
3401
+ } = props;
2773
3402
  const {
2774
- treeConfig,
2775
3403
  fullDataRowIdData
2776
- } = this;
3404
+ } = internalData;
2777
3405
  if (rowOrRowid && treeConfig) {
2778
3406
  let rowid;
2779
3407
  if (_xeUtils.default.isString(rowOrRowid)) {
2780
3408
  rowid = rowOrRowid;
2781
3409
  } else {
2782
- rowid = (0, _util.getRowid)(this, rowOrRowid);
3410
+ rowid = (0, _util.getRowid)($xeTable, rowOrRowid);
2783
3411
  }
2784
3412
  if (rowid) {
2785
3413
  const rest = fullDataRowIdData[rowid];
@@ -2806,10 +3434,14 @@ const Methods = {
2806
3434
  * 根据行获取行的唯一主键
2807
3435
  * @param {Row} row 行对象
2808
3436
  */
2809
- getRowid(row) {
3437
+ getRowid(cellValue) {
2810
3438
  const $xeTable = this;
2811
- const rowid = _xeUtils.default.get(row, (0, _util.getRowkey)($xeTable));
2812
- return _xeUtils.default.eqNull(rowid) ? '' : encodeURIComponent(rowid);
3439
+ const internalData = $xeTable;
3440
+ const {
3441
+ fullDataRowIdData
3442
+ } = internalData;
3443
+ const rowid = _xeUtils.default.eqNull(cellValue) ? '' : encodeURIComponent(cellValue || '');
3444
+ return fullDataRowIdData[rowid] ? fullDataRowIdData[rowid].row : null;
2813
3445
  },
2814
3446
  /**
2815
3447
  * 获取处理后的表格数据
@@ -2850,14 +3482,19 @@ const Methods = {
2850
3482
  const treeOpts = $xeTable.computeTreeOpts;
2851
3483
  const {
2852
3484
  transform,
2853
- mapChildrenField
3485
+ mapChildrenField,
3486
+ rowField,
3487
+ parentField
2854
3488
  } = treeOpts;
2855
3489
  const childrenField = treeOpts.children || treeOpts.childrenField;
2856
3490
  if (transform) {
2857
3491
  return _xeUtils.default.toArrayTree(_xeUtils.default.toTreeArray(tableFullTreeData, {
2858
3492
  children: mapChildrenField
2859
3493
  }), {
2860
- children: childrenField
3494
+ key: rowField,
3495
+ parentKey: parentField,
3496
+ children: childrenField,
3497
+ mapChildren: mapChildrenField
2861
3498
  });
2862
3499
  }
2863
3500
  return tableFullTreeData.slice(0);
@@ -3016,8 +3653,8 @@ const Methods = {
3016
3653
  const colWidth = _xeUtils.default.toInteger(width);
3017
3654
  let rdWidth = colWidth;
3018
3655
  if ((0, _dom.isScale)(width)) {
3019
- const tableBody = $xeTable.$refs.tableBody;
3020
- const bodyElem = tableBody ? tableBody.$el : null;
3656
+ const refTableBody = $xeTable.$refs.refTableBody;
3657
+ const bodyElem = refTableBody ? refTableBody.$el : null;
3021
3658
  const bodyWidth = bodyElem ? bodyElem.clientWidth - 1 : 0;
3022
3659
  rdWidth = Math.floor(colWidth * bodyWidth);
3023
3660
  }
@@ -3290,158 +3927,16 @@ const Methods = {
3290
3927
  * 刷新列配置
3291
3928
  */
3292
3929
  refreshColumn(initSort) {
3930
+ const $xeTable = this;
3293
3931
  if (initSort) {
3294
- this.handleUpdateColumn();
3932
+ handleUpdateColumn($xeTable);
3295
3933
  }
3296
- return this.parseColumns(true).then(() => {
3934
+ return parseColumns($xeTable, true).then(() => {
3297
3935
  return this.refreshScroll();
3298
3936
  }).then(() => {
3299
3937
  return this.recalculate();
3300
3938
  });
3301
3939
  },
3302
- /**
3303
- * 刷新列信息
3304
- * 将固定的列左边、右边分别靠边
3305
- */
3306
- parseColumns(isReset) {
3307
- const $xeTable = this;
3308
- const props = $xeTable;
3309
- const internalData = $xeTable;
3310
- const {
3311
- showOverflow
3312
- } = props;
3313
- const rowOpts = $xeTable.computeRowOpts;
3314
- const leftList = [];
3315
- const centerList = [];
3316
- const rightList = [];
3317
- const {
3318
- collectColumn,
3319
- tableFullColumn,
3320
- isGroup,
3321
- columnStore,
3322
- sXOpts,
3323
- scrollXStore,
3324
- fullColumnIdData
3325
- } = this;
3326
- // 如果是分组表头,如果子列全部被隐藏,则根列也隐藏
3327
- if (isGroup) {
3328
- const leftGroupList = [];
3329
- const centerGroupList = [];
3330
- const rightGroupList = [];
3331
- _xeUtils.default.eachTree(collectColumn, (column, index, items, path, parentColumn) => {
3332
- const isColGroup = (0, _utils.hasChildrenList)(column);
3333
- // 如果是分组,必须按组设置固定列,不允许给子列设置固定
3334
- if (parentColumn && parentColumn.fixed) {
3335
- column.fixed = parentColumn.fixed;
3336
- }
3337
- if (parentColumn && column.fixed !== parentColumn.fixed) {
3338
- (0, _log.errLog)('vxe.error.groupFixed');
3339
- }
3340
- if (isColGroup) {
3341
- column.visible = !!_xeUtils.default.findTree(column.children, subColumn => (0, _utils.hasChildrenList)(subColumn) ? null : subColumn.visible);
3342
- } else if (column.visible) {
3343
- if (column.fixed === 'left') {
3344
- leftList.push(column);
3345
- } else if (column.fixed === 'right') {
3346
- rightList.push(column);
3347
- } else {
3348
- centerList.push(column);
3349
- }
3350
- }
3351
- });
3352
- collectColumn.forEach(column => {
3353
- if (column.visible) {
3354
- if (column.fixed === 'left') {
3355
- leftGroupList.push(column);
3356
- } else if (column.fixed === 'right') {
3357
- rightGroupList.push(column);
3358
- } else {
3359
- centerGroupList.push(column);
3360
- }
3361
- }
3362
- });
3363
- this.tableGroupColumn = leftGroupList.concat(centerGroupList).concat(rightGroupList);
3364
- } else {
3365
- // 重新分配列
3366
- tableFullColumn.forEach(column => {
3367
- if (column.visible) {
3368
- if (column.fixed === 'left') {
3369
- leftList.push(column);
3370
- } else if (column.fixed === 'right') {
3371
- rightList.push(column);
3372
- } else {
3373
- centerList.push(column);
3374
- }
3375
- }
3376
- });
3377
- }
3378
- const visibleColumn = leftList.concat(centerList).concat(rightList);
3379
- // 如果gt为0,则总是启用
3380
- const scrollXLoad = sXOpts.enabled && sXOpts.gt > -1 && (sXOpts.gt === 0 || sXOpts.gt <= tableFullColumn.length);
3381
- this.hasFixedColumn = leftList.length > 0 || rightList.length > 0;
3382
- Object.assign(columnStore, {
3383
- leftList,
3384
- centerList,
3385
- rightList
3386
- });
3387
- if (scrollXLoad) {
3388
- if (showOverflow) {
3389
- if (!rowOpts.height) {
3390
- const errColumn = internalData.tableFullColumn.find(column => column.showOverflow === false);
3391
- if (errColumn) {
3392
- (0, _log.errLog)('vxe.error.errProp', [`column[field="${errColumn.field}"].show-overflow=false`, 'show-overflow=true']);
3393
- }
3394
- }
3395
- }
3396
- if (process.env.NODE_ENV === 'development') {
3397
- // if (this.showHeader && !this.showHeaderOverflow) {
3398
- // warnLog('vxe.error.reqProp', ['show-header-overflow'])
3399
- // }
3400
- // if (this.showFooter && !this.showFooterOverflow) {
3401
- // warnLog('vxe.error.reqProp', ['show-footer-overflow'])
3402
- // }
3403
- if (this.spanMethod) {
3404
- (0, _log.warnLog)('vxe.error.scrollErrProp', ['span-method']);
3405
- }
3406
- if (this.footerSpanMethod) {
3407
- (0, _log.warnLog)('vxe.error.scrollErrProp', ['footer-span-method']);
3408
- }
3409
- }
3410
- if (isReset) {
3411
- const {
3412
- visibleSize
3413
- } = handleVirtualXVisible(this);
3414
- scrollXStore.startIndex = 0;
3415
- scrollXStore.endIndex = visibleSize;
3416
- scrollXStore.visibleSize = visibleSize;
3417
- }
3418
- }
3419
- // 如果列被显示/隐藏,则清除合并状态
3420
- // 如果列被设置为固定,则清除合并状态
3421
- if (visibleColumn.length !== this.visibleColumn.length || !this.visibleColumn.every((column, index) => column === visibleColumn[index])) {
3422
- this.clearMergeCells();
3423
- this.clearMergeFooterItems();
3424
- }
3425
- this.scrollXLoad = scrollXLoad;
3426
- visibleColumn.forEach((column, index) => {
3427
- const colid = column.id;
3428
- const colRest = fullColumnIdData[colid];
3429
- if (colRest) {
3430
- colRest._index = index;
3431
- }
3432
- });
3433
- this.visibleColumn = visibleColumn;
3434
- this.handleTableColumn();
3435
- if (isReset) {
3436
- return this.updateFooter().then(() => {
3437
- return this.recalculate();
3438
- }).then(() => {
3439
- this.updateCellAreas();
3440
- return this.recalculate();
3441
- });
3442
- }
3443
- return this.updateFooter();
3444
- },
3445
3940
  /**
3446
3941
  * 指定列宽的列进行拆分
3447
3942
  */
@@ -3545,38 +4040,43 @@ const Methods = {
3545
4040
  * 刷新滚动操作,手动同步滚动相关位置(对于某些特殊的操作,比如滚动条错位、固定列不同步)
3546
4041
  */
3547
4042
  refreshScroll() {
4043
+ const $xeTable = this;
4044
+ const internalData = $xeTable;
3548
4045
  const {
4046
+ elemStore,
3549
4047
  lastScrollLeft,
3550
4048
  lastScrollTop
3551
- } = this;
3552
- const {
3553
- $refs
3554
- } = this;
3555
- const {
3556
- tableBody,
3557
- leftBody,
3558
- rightBody,
3559
- tableFooter
3560
- } = $refs;
3561
- const tableBodyElem = tableBody ? tableBody.$el : null;
3562
- const leftBodyElem = leftBody ? leftBody.$el : null;
3563
- const rightBodyElem = rightBody ? rightBody.$el : null;
3564
- const tableFooterElem = tableFooter ? tableFooter.$el : null;
4049
+ } = internalData;
4050
+ const headerScrollElem = (0, _util.getRefElem)(elemStore['main-header-scroll']);
4051
+ const bodyScrollElem = (0, _util.getRefElem)(elemStore['main-body-scroll']);
4052
+ const footerScrollElem = (0, _util.getRefElem)(elemStore['main-footer-scroll']);
4053
+ const leftScrollElem = (0, _util.getRefElem)(elemStore['left-body-scroll']);
4054
+ const rightScrollElem = (0, _util.getRefElem)(elemStore['right-body-scroll']);
4055
+ const xHandleEl = $xeTable.$refs.refScrollXHandleElem;
4056
+ const yHandleEl = $xeTable.$refs.refScrollYHandleElem;
3565
4057
  return new Promise(resolve => {
3566
4058
  // 还原滚动条位置
3567
4059
  if (lastScrollLeft || lastScrollTop) {
3568
- return (0, _util.restoreScrollLocation)(this, lastScrollLeft, lastScrollTop).then(() => {
4060
+ return (0, _util.restoreScrollLocation)($xeTable, lastScrollLeft, lastScrollTop).then().then(() => {
3569
4061
  // 存在滚动行为未结束情况
3570
- setTimeout(resolve, 30);
4062
+ setTimeout(resolve, 10);
3571
4063
  });
3572
4064
  }
4065
+ internalData.intoRunScroll = true;
3573
4066
  // 重置
3574
- (0, _dom.setScrollTop)(tableBodyElem, lastScrollTop);
3575
- (0, _dom.setScrollTop)(leftBodyElem, lastScrollTop);
3576
- (0, _dom.setScrollTop)(rightBodyElem, lastScrollTop);
3577
- (0, _dom.setScrollLeft)(tableFooterElem, lastScrollLeft);
4067
+ (0, _dom.setScrollTop)(yHandleEl, lastScrollTop);
4068
+ (0, _dom.setScrollTop)(bodyScrollElem, lastScrollTop);
4069
+ (0, _dom.setScrollTop)(leftScrollElem, lastScrollTop);
4070
+ (0, _dom.setScrollTop)(rightScrollElem, lastScrollTop);
4071
+ (0, _dom.setScrollLeft)(xHandleEl, lastScrollLeft);
4072
+ (0, _dom.setScrollLeft)(bodyScrollElem, lastScrollLeft);
4073
+ (0, _dom.setScrollLeft)(headerScrollElem, lastScrollLeft);
4074
+ (0, _dom.setScrollLeft)(footerScrollElem, lastScrollLeft);
3578
4075
  // 存在滚动行为未结束情况
3579
- setTimeout(resolve, 30);
4076
+ setTimeout(() => {
4077
+ internalData.intoRunScroll = false;
4078
+ resolve();
4079
+ }, 10);
3580
4080
  });
3581
4081
  },
3582
4082
  /**
@@ -3585,368 +4085,67 @@ const Methods = {
3585
4085
  */
3586
4086
  recalculate(reFull) {
3587
4087
  const $xeTable = this;
3588
- const internalData = $xeTable;
3589
- return new Promise(resolve => {
3590
- const {
3591
- rceTimeout,
3592
- rceRunTime
3593
- } = internalData;
3594
- const resizeOpts = $xeTable.computeResizeOpts;
3595
- const refreshDelay = resizeOpts.refreshDelay || 20;
3596
- const el = $xeTable.$refs.refElem;
3597
- if (el && el.clientWidth) {
3598
- autoCellWidth($xeTable);
3599
- }
3600
- if (rceTimeout) {
3601
- clearTimeout(rceTimeout);
3602
- if (rceRunTime && rceRunTime + (refreshDelay - 5) < Date.now()) {
3603
- resolve(handleRecalculateLayout($xeTable, !!reFull));
3604
- } else {
3605
- $xeTable.$nextTick(() => {
3606
- resolve();
3607
- });
3608
- }
3609
- } else {
3610
- resolve(handleRecalculateLayout($xeTable, !!reFull));
3611
- }
3612
- internalData.rceTimeout = setTimeout(() => {
3613
- internalData.rceTimeout = undefined;
3614
- handleRecalculateLayout($xeTable, !!reFull);
3615
- }, refreshDelay);
3616
- });
3617
- },
3618
- updateStyle() {
3619
- const $xeTable = this;
3620
- let {
3621
- $refs,
3622
- isGroup,
3623
- fullColumnIdData,
3624
- tableColumn,
3625
- customHeight,
3626
- customMinHeight,
3627
- customMaxHeight,
3628
- border,
3629
- headerHeight,
3630
- showFooter,
3631
- showOverflow: allColumnOverflow,
3632
- showHeaderOverflow: allColumnHeaderOverflow,
3633
- showFooterOverflow: allColumnFooterOverflow,
3634
- footerHeight,
3635
- tableHeight,
3636
- tableWidth,
3637
- scrollbarHeight,
3638
- scrollbarWidth,
3639
- scrollXLoad,
3640
- scrollYLoad,
3641
- overflowX,
3642
- cellOffsetWidth,
3643
- columnStore,
3644
- elemStore,
3645
- editStore,
3646
- currentRow,
3647
- mouseConfig,
3648
- spanMethod,
3649
- expandColumn,
3650
- footerSpanMethod,
3651
- isAllOverflow,
3652
- visibleColumn
3653
- } = $xeTable;
3654
- const containerList = ['main', 'left', 'right'];
3655
- const emptyPlaceholderElem = $refs.emptyPlaceholder;
3656
- const bodyWrapperElem = elemStore['main-body-wrapper'];
3657
- if (emptyPlaceholderElem) {
3658
- emptyPlaceholderElem.style.top = `${headerHeight}px`;
3659
- emptyPlaceholderElem.style.height = bodyWrapperElem ? `${bodyWrapperElem.offsetHeight - scrollbarHeight}px` : '';
3660
- }
3661
- if (customHeight > 0) {
3662
- if (showFooter) {
3663
- customHeight += scrollbarHeight;
3664
- }
3665
- }
3666
- const scrollXVirtualEl = $xeTable.$refs.refScrollXVirtualElem;
3667
- if (scrollXVirtualEl) {
3668
- scrollXVirtualEl.style.height = `${scrollbarHeight}px`;
3669
- }
3670
- const scrollYVirtualEl = $xeTable.$refs.refScrollYVirtualElem;
3671
- if (scrollYVirtualEl) {
3672
- let bodyHeight = 0;
3673
- let bodyMaxHeight = 0;
3674
- const bodyMinHeight = customMinHeight - headerHeight - footerHeight;
3675
- if (customMaxHeight) {
3676
- bodyMaxHeight = customMaxHeight - headerHeight - footerHeight;
3677
- bodyMaxHeight = Math.max(bodyMinHeight, bodyMaxHeight);
3678
- }
3679
- if (customHeight) {
3680
- bodyHeight = customHeight - headerHeight - footerHeight;
3681
- if (bodyMaxHeight) {
3682
- bodyHeight = Math.min(bodyMaxHeight, bodyHeight);
3683
- }
3684
- bodyHeight = Math.max(bodyMinHeight, bodyHeight);
3685
- }
3686
- scrollYVirtualEl.style.top = `${headerHeight}px`;
3687
- scrollYVirtualEl.style.width = `${scrollbarWidth}px`;
3688
- scrollYVirtualEl.style.height = `${bodyHeight + (overflowX ? -Math.max(1, scrollbarHeight) : 0)}px`;
3689
- }
3690
- containerList.forEach((name, index) => {
3691
- const fixedType = index > 0 ? name : '';
3692
- const layoutList = ['header', 'body', 'footer'];
3693
- const fixedColumn = columnStore[`${fixedType}List`];
3694
- const fixedWrapperElem = $refs[`${fixedType}Container`];
3695
- layoutList.forEach(layout => {
3696
- const wrapperElem = elemStore[`${name}-${layout}-wrapper`];
3697
- const tableElem = elemStore[`${name}-${layout}-table`];
3698
- if (layout === 'header') {
3699
- // 表头体样式处理
3700
- // 横向滚动渲染
3701
- let tWidth = tableWidth;
3702
- let renderColumnList = tableColumn;
3703
- if (isGroup) {
3704
- renderColumnList = visibleColumn;
3705
- } else {
3706
- if (fixedType) {
3707
- // 如果是使用优化模式
3708
- if (scrollXLoad || scrollYLoad || allColumnHeaderOverflow) {
3709
- // 如果不支持优化模式
3710
- if (spanMethod || footerSpanMethod) {
3711
- renderColumnList = visibleColumn;
3712
- } else {
3713
- renderColumnList = fixedColumn || [];
3714
- }
3715
- } else {
3716
- renderColumnList = visibleColumn;
3717
- }
3718
- }
3719
- }
3720
- tWidth = renderColumnList.reduce((previous, column) => previous + column.renderWidth, 0);
3721
- if (tableElem) {
3722
- tableElem.style.width = tWidth ? `${tWidth + scrollbarWidth}px` : '';
3723
- // 修复 IE 中高度无法自适应问题
3724
- if (_dom.browse.msie) {
3725
- _xeUtils.default.arrayEach(tableElem.querySelectorAll('.vxe-resizable'), resizeElem => {
3726
- resizeElem.style.height = `${resizeElem.parentNode.offsetHeight}px`;
3727
- });
3728
- }
3729
- }
3730
- const repairElem = elemStore[`${name}-${layout}-repair`];
3731
- if (repairElem) {
3732
- repairElem.style.width = `${tableWidth}px`;
3733
- }
3734
- const listElem = elemStore[`${name}-${layout}-list`];
3735
- if (isGroup && listElem) {
3736
- _xeUtils.default.arrayEach(listElem.querySelectorAll('.col--group'), thElem => {
3737
- const colNode = this.getColumnNode(thElem);
3738
- if (colNode) {
3739
- const column = colNode.item;
3740
- const {
3741
- showHeaderOverflow
3742
- } = column;
3743
- const cellOverflow = _xeUtils.default.isBoolean(showHeaderOverflow) ? showHeaderOverflow : allColumnHeaderOverflow;
3744
- const showEllipsis = cellOverflow === 'ellipsis';
3745
- const showTitle = cellOverflow === 'title';
3746
- const showTooltip = cellOverflow === true || cellOverflow === 'tooltip';
3747
- const hasEllipsis = showTitle || showTooltip || showEllipsis;
3748
- let childWidth = 0;
3749
- let countChild = 0;
3750
- if (hasEllipsis) {
3751
- _xeUtils.default.eachTree(column.children, item => {
3752
- if (!item.children || !column.children.length) {
3753
- countChild++;
3754
- }
3755
- childWidth += item.renderWidth;
3756
- });
3757
- }
3758
- thElem.style.width = hasEllipsis ? `${childWidth - countChild - (border ? 2 : 0)}px` : '';
3759
- }
3760
- });
3761
- }
3762
- } else if (layout === 'body') {
3763
- const emptyBlockElem = elemStore[`${name}-${layout}-emptyBlock`];
3764
- if ((0, _dom.isNodeElement)(wrapperElem)) {
3765
- let bodyMaxHeight = 0;
3766
- const bodyMinHeight = customMinHeight - headerHeight - footerHeight;
3767
- if (customMaxHeight) {
3768
- bodyMaxHeight = customMaxHeight - headerHeight - footerHeight;
3769
- // 如果是固定列
3770
- if (fixedType) {
3771
- bodyMaxHeight -= showFooter ? 0 : scrollbarHeight;
3772
- }
3773
- bodyMaxHeight = Math.max(bodyMinHeight, bodyMaxHeight);
3774
- wrapperElem.style.maxHeight = `${bodyMaxHeight}px`;
3775
- }
3776
- if (customHeight) {
3777
- let bodyHeight = customHeight - headerHeight - footerHeight;
3778
- // 如果是固定列
3779
- if (fixedType) {
3780
- bodyHeight -= showFooter ? 0 : scrollbarHeight;
3781
- }
3782
- if (bodyMaxHeight) {
3783
- bodyHeight = Math.min(bodyMaxHeight, bodyHeight);
3784
- }
3785
- wrapperElem.style.height = `${Math.max(bodyMinHeight, bodyHeight)}px`;
3786
- } else {
3787
- wrapperElem.style.height = '';
3788
- }
3789
- wrapperElem.style.minHeight = `${bodyMinHeight}px`;
3790
- }
3791
- // 如果是固定列
3792
- if (fixedWrapperElem) {
3793
- const isRightFixed = fixedType === 'right';
3794
- const fixedColumn = columnStore[`${fixedType}List`];
3795
- if ((0, _dom.isNodeElement)(wrapperElem)) {
3796
- wrapperElem.style.top = `${headerHeight}px`;
3797
- }
3798
- fixedWrapperElem.style.height = `${(customHeight > 0 ? customHeight - headerHeight - footerHeight : tableHeight) + headerHeight + footerHeight - scrollbarHeight * (showFooter ? 2 : 1)}px`;
3799
- fixedWrapperElem.style.width = `${fixedColumn.reduce((previous, column) => previous + column.renderWidth, isRightFixed ? scrollbarWidth : 0)}px`;
3800
- }
3801
- let tWidth = tableWidth;
3802
- let renderColumnList = tableColumn;
3803
- if (fixedType) {
3804
- // 如果是使用优化模式
3805
- if (scrollXLoad || scrollYLoad || allColumnOverflow && isAllOverflow) {
3806
- // 如果不支持优化模式
3807
- if (expandColumn || spanMethod || footerSpanMethod) {
3808
- renderColumnList = visibleColumn;
3809
- } else {
3810
- renderColumnList = fixedColumn || [];
3811
- }
3812
- } else {
3813
- renderColumnList = visibleColumn;
3814
- }
3815
- }
3816
- tWidth = renderColumnList.reduce((previous, column) => previous + column.renderWidth, 0);
3817
- if (tableElem) {
3818
- tableElem.style.width = tWidth ? `${tWidth}px` : '';
3819
- // 兼容性处理
3820
- tableElem.style.paddingRight = scrollbarWidth && fixedType && (_dom.browse['-moz'] || _dom.browse.safari) ? `${scrollbarWidth}px` : '';
3821
- }
3822
- if (emptyBlockElem) {
3823
- emptyBlockElem.style.width = tWidth ? `${tWidth}px` : '';
3824
- }
3825
- } else if (layout === 'footer') {
3826
- let tWidth = tableWidth;
3827
- let renderColumnList = tableColumn;
3828
- if (fixedType) {
3829
- // 如果是使用优化模式
3830
- if (scrollXLoad || scrollYLoad || allColumnFooterOverflow) {
3831
- // 如果不支持优化模式
3832
- if (spanMethod || footerSpanMethod) {
3833
- renderColumnList = visibleColumn;
3834
- } else {
3835
- renderColumnList = fixedColumn || [];
3836
- }
3837
- } else {
3838
- renderColumnList = visibleColumn;
3839
- }
3840
- }
3841
- tWidth = renderColumnList.reduce((previous, column) => previous + column.renderWidth, 0);
3842
- if ((0, _dom.isNodeElement)(wrapperElem)) {
3843
- // 如果是固定列
3844
- if (fixedWrapperElem) {
3845
- wrapperElem.style.top = `${customHeight > 0 ? customHeight - footerHeight : tableHeight + headerHeight}px`;
3846
- }
3847
- wrapperElem.style.marginTop = `${-scrollbarHeight}px`;
3848
- }
3849
- if (tableElem) {
3850
- tableElem.style.width = tWidth ? `${tWidth + scrollbarWidth}px` : '';
3851
- }
3852
- }
3853
- const colgroupElem = elemStore[`${name}-${layout}-colgroup`];
3854
- if (colgroupElem) {
3855
- _xeUtils.default.arrayEach(colgroupElem.children, colElem => {
3856
- const colid = colElem.getAttribute('name');
3857
- if (colid === 'col_gutter') {
3858
- colElem.style.width = `${scrollbarWidth}px`;
3859
- }
3860
- if (fullColumnIdData[colid]) {
3861
- const colRest = fullColumnIdData[colid];
3862
- const column = colRest.column;
3863
- const {
3864
- showHeaderOverflow,
3865
- showFooterOverflow,
3866
- showOverflow
3867
- } = column;
3868
- let cellOverflow;
3869
- colElem.style.width = `${column.renderWidth}px`;
3870
- if (layout === 'header') {
3871
- cellOverflow = _xeUtils.default.isUndefined(showHeaderOverflow) || _xeUtils.default.isNull(showHeaderOverflow) ? allColumnHeaderOverflow : showHeaderOverflow;
3872
- } else if (layout === 'footer') {
3873
- cellOverflow = _xeUtils.default.isUndefined(showFooterOverflow) || _xeUtils.default.isNull(showFooterOverflow) ? allColumnFooterOverflow : showFooterOverflow;
3874
- } else {
3875
- cellOverflow = _xeUtils.default.isUndefined(showOverflow) || _xeUtils.default.isNull(showOverflow) ? allColumnOverflow : showOverflow;
3876
- }
3877
- const showEllipsis = cellOverflow === 'ellipsis';
3878
- const showTitle = cellOverflow === 'title';
3879
- const showTooltip = cellOverflow === true || cellOverflow === 'tooltip';
3880
- let hasEllipsis = showTitle || showTooltip || showEllipsis;
3881
- const listElem = elemStore[`${name}-${layout}-list`];
3882
- // 滚动的渲染不支持动态行高
3883
- if (layout === 'header' || layout === 'footer') {
3884
- if (scrollXLoad && !hasEllipsis) {
3885
- hasEllipsis = true;
3886
- }
3887
- } else {
3888
- if ((scrollXLoad || scrollYLoad) && !hasEllipsis) {
3889
- hasEllipsis = true;
3890
- }
3891
- }
3892
- if (listElem) {
3893
- _xeUtils.default.arrayEach(listElem.querySelectorAll(`.${column.id}`), elem => {
3894
- const colspan = parseInt(elem.getAttribute('colspan') || 1);
3895
- const cellElem = elem.querySelector('.vxe-cell');
3896
- let colWidth = column.renderWidth;
3897
- if (cellElem) {
3898
- if (colspan > 1) {
3899
- const columnIndex = this.getColumnIndex(column);
3900
- for (let index = 1; index < colspan; index++) {
3901
- const nextColumn = this.getColumns(columnIndex + index);
3902
- if (nextColumn) {
3903
- colWidth += nextColumn.renderWidth;
3904
- }
3905
- }
3906
- }
3907
- cellElem.style.width = hasEllipsis ? `${colWidth - cellOffsetWidth * colspan}px` : '';
3908
- }
3909
- });
3910
- }
3911
- }
4088
+ const internalData = $xeTable;
4089
+ return new Promise(resolve => {
4090
+ const {
4091
+ rceTimeout,
4092
+ rceRunTime
4093
+ } = internalData;
4094
+ const resizeOpts = $xeTable.computeResizeOpts;
4095
+ const refreshDelay = resizeOpts.refreshDelay || 20;
4096
+ const el = $xeTable.$refs.refElem;
4097
+ if (el && el.clientWidth) {
4098
+ autoCellWidth($xeTable);
4099
+ }
4100
+ if (rceTimeout) {
4101
+ clearTimeout(rceTimeout);
4102
+ if (rceRunTime && rceRunTime + (refreshDelay - 5) < Date.now()) {
4103
+ resolve(handleRecalculateLayout($xeTable, !!reFull));
4104
+ } else {
4105
+ $xeTable.$nextTick(() => {
4106
+ resolve();
3912
4107
  });
3913
4108
  }
3914
- });
4109
+ } else {
4110
+ resolve(handleRecalculateLayout($xeTable, !!reFull));
4111
+ }
4112
+ internalData.rceTimeout = setTimeout(() => {
4113
+ internalData.rceTimeout = undefined;
4114
+ handleRecalculateLayout($xeTable, !!reFull);
4115
+ }, refreshDelay);
3915
4116
  });
3916
- if (currentRow) {
3917
- this.setCurrentRow(currentRow);
3918
- }
3919
- if (mouseConfig && mouseConfig.selected && editStore.selected.row && editStore.selected.column) {
3920
- this.addColSdCls();
3921
- }
3922
- return this.$nextTick();
4117
+ },
4118
+ updateStyle() {
4119
+ const $xeTable = this;
4120
+ return updateStyle($xeTable);
3923
4121
  },
3924
4122
  /**
3925
4123
  * 处理固定列的显示状态
3926
4124
  */
3927
4125
  checkScrolling() {
3928
4126
  const $xeTable = this;
4127
+ const internalData = $xeTable;
3929
4128
  const {
3930
- tableBody,
3931
- leftContainer,
3932
- rightContainer
3933
- } = $xeTable.$refs;
3934
- const bodyElem = tableBody ? tableBody.$el : null;
4129
+ elemStore
4130
+ } = internalData;
4131
+ const bodyScrollElem = (0, _util.getRefElem)(elemStore['main-body-scroll']);
4132
+ const leftContainerElem = $xeTable.$refs.refLeftContainer;
4133
+ const rightContainerElem = $xeTable.$refs.refRightContainer;
3935
4134
  const xHandleEl = $xeTable.$refs.refScrollXHandleElem;
3936
- const bodtTargetEl = xHandleEl || bodyElem;
4135
+ const bodtTargetEl = xHandleEl || bodyScrollElem;
3937
4136
  if (bodtTargetEl) {
3938
- if (leftContainer) {
4137
+ if (leftContainerElem) {
3939
4138
  if (bodtTargetEl.scrollLeft > 0) {
3940
- (0, _dom.addClass)(leftContainer, 'scrolling--middle');
4139
+ (0, _dom.addClass)(leftContainerElem, 'scrolling--middle');
3941
4140
  } else {
3942
- (0, _dom.removeClass)(leftContainer, 'scrolling--middle');
4141
+ (0, _dom.removeClass)(leftContainerElem, 'scrolling--middle');
3943
4142
  }
3944
4143
  }
3945
- if (rightContainer) {
4144
+ if (rightContainerElem) {
3946
4145
  if (bodtTargetEl.clientWidth < bodtTargetEl.scrollWidth - Math.ceil(bodtTargetEl.scrollLeft)) {
3947
- (0, _dom.addClass)(rightContainer, 'scrolling--middle');
4146
+ (0, _dom.addClass)(rightContainerElem, 'scrolling--middle');
3948
4147
  } else {
3949
- (0, _dom.removeClass)(rightContainer, 'scrolling--middle');
4148
+ (0, _dom.removeClass)(rightContainerElem, 'scrolling--middle');
3950
4149
  }
3951
4150
  }
3952
4151
  }
@@ -4002,10 +4201,10 @@ const Methods = {
4002
4201
  actived
4003
4202
  } = editStore;
4004
4203
  const {
4005
- ctxWrapper,
4204
+ refTableMenu,
4006
4205
  filterWrapper,
4007
4206
  customWrapper,
4008
- validTip
4207
+ refValidTooltip
4009
4208
  } = $refs;
4010
4209
  // 筛选
4011
4210
  if (filterWrapper) {
@@ -4037,7 +4236,7 @@ const Methods = {
4037
4236
  // 如果是激活状态,点击了单元格之外
4038
4237
  const cell = actived.args.cell;
4039
4238
  if (!cell || !(0, _dom.getEventTargetNode)(evnt, cell).flag) {
4040
- if (validTip && (0, _dom.getEventTargetNode)(evnt, validTip.$el).flag) {
4239
+ if (refValidTooltip && (0, _dom.getEventTargetNode)(evnt, refValidTooltip.$el).flag) {
4041
4240
  // 如果是激活状态,且点击了校验提示框
4042
4241
  } else if (!this.lastCallTime || this.lastCallTime + 50 < Date.now()) {
4043
4242
  if (!(0, _dom.getEventTargetNode)(evnt, document.body, 'vxe-table--ignore-clear').flag) {
@@ -4085,7 +4284,7 @@ const Methods = {
4085
4284
  }
4086
4285
  }
4087
4286
  } else if (mouseConfig) {
4088
- if (!(0, _dom.getEventTargetNode)(evnt, $el).flag && !($xegrid && (0, _dom.getEventTargetNode)(evnt, $xegrid.$el).flag) && !(ctxWrapper && (0, _dom.getEventTargetNode)(evnt, ctxWrapper.$el).flag) && !($toolbar && (0, _dom.getEventTargetNode)(evnt, $toolbar.$el).flag)) {
4287
+ if (!(0, _dom.getEventTargetNode)(evnt, $el).flag && !($xegrid && (0, _dom.getEventTargetNode)(evnt, $xegrid.$el).flag) && !(refTableMenu && (0, _dom.getEventTargetNode)(evnt, refTableMenu.$el).flag) && !($toolbar && (0, _dom.getEventTargetNode)(evnt, $toolbar.$el).flag)) {
4089
4288
  if (this.clearSelected) {
4090
4289
  this.clearSelected();
4091
4290
  }
@@ -4106,7 +4305,7 @@ const Methods = {
4106
4305
  }
4107
4306
  }
4108
4307
  // 如果配置了快捷菜单且,点击了其他地方则关闭
4109
- if (ctxMenuStore.visible && ctxWrapper && !(0, _dom.getEventTargetNode)(evnt, ctxWrapper.$el).flag) {
4308
+ if (ctxMenuStore.visible && refTableMenu && !(0, _dom.getEventTargetNode)(evnt, refTableMenu.$el).flag) {
4110
4309
  this.closeMenu();
4111
4310
  }
4112
4311
  const isActivated = (0, _dom.getEventTargetNode)(evnt, ($xegrid || this).$el).flag;
@@ -4272,8 +4471,8 @@ const Methods = {
4272
4471
  } else if (isContextMenu) {
4273
4472
  // 如果按下上下文键
4274
4473
  this._keyCtx = selected.row && selected.column && bodyCtxMenu.length;
4275
- clearTimeout(this.keyCtxTimeout);
4276
- this.keyCtxTimeout = setTimeout(() => {
4474
+ clearTimeout(internalData.keyCtxTimeout);
4475
+ internalData.keyCtxTimeout = setTimeout(() => {
4277
4476
  this._keyCtx = false;
4278
4477
  }, 1000);
4279
4478
  } else if (isEnter && !hasAltKey && keyboardConfig && keyboardOpts.isEnter && (selected.row || actived.row || treeConfig && (rowOpts.isCurrent || highlightCurrentRow) && currentRow)) {
@@ -4689,6 +4888,10 @@ const Methods = {
4689
4888
  * @param {Row} row 行对象
4690
4889
  */
4691
4890
  handleTooltip(evnt, cell, overflowElem, tipElem, params) {
4891
+ const $xeTable = this;
4892
+ if (!overflowElem) {
4893
+ return $xeTable.$nextTick();
4894
+ }
4692
4895
  params.cell = cell;
4693
4896
  const {
4694
4897
  $refs,
@@ -4728,7 +4931,7 @@ const Methods = {
4728
4931
  const {
4729
4932
  $refs
4730
4933
  } = this;
4731
- const commTip = $refs.commTip;
4934
+ const commTip = $refs.refCommTooltip;
4732
4935
  if (commTip) {
4733
4936
  return commTip.open(target, content);
4734
4937
  }
@@ -4743,7 +4946,7 @@ const Methods = {
4743
4946
  tooltipStore
4744
4947
  } = this;
4745
4948
  const tooltip = $refs.tooltip;
4746
- const commTip = $refs.commTip;
4949
+ const commTip = $refs.refCommTooltip;
4747
4950
  if (tooltipStore.visible) {
4748
4951
  Object.assign(tooltipStore, {
4749
4952
  row: null,
@@ -6175,6 +6378,7 @@ const Methods = {
6175
6378
  this.emitEvent('cell-dblclick', params, evnt);
6176
6379
  },
6177
6380
  handleDefaultSort() {
6381
+ const $xeTable = this;
6178
6382
  const {
6179
6383
  sortConfig,
6180
6384
  sortOpts
@@ -6201,7 +6405,7 @@ const Methods = {
6201
6405
  }
6202
6406
  });
6203
6407
  if (!sortOpts.remote) {
6204
- this.handleTableData(true).then(this.updateStyle);
6408
+ this.handleTableData(true).then(() => updateStyle($xeTable));
6205
6409
  }
6206
6410
  }
6207
6411
  }
@@ -6714,8 +6918,8 @@ const Methods = {
6714
6918
  },
6715
6919
  handleColDragSwapColumn() {
6716
6920
  const $xeTable = this;
6717
- $xeTable.handleUpdateColumn();
6718
- $xeTable.parseColumns(false).then(() => {
6921
+ handleUpdateColumn($xeTable);
6922
+ parseColumns($xeTable, false).then(() => {
6719
6923
  $xeTable.updateCellAreas();
6720
6924
  $xeTable.saveCustomStore('update:sort');
6721
6925
  });
@@ -6965,15 +7169,15 @@ const Methods = {
6965
7169
  return;
6966
7170
  }
6967
7171
  const xHandleEl = $xeTable.$refs.refScrollXHandleElem;
6968
- const tableBody = $xeTable.$refs.tableBody;
6969
- const tableBodyElem = tableBody ? tableBody.$el : null;
7172
+ const refTableBody = $xeTable.$refs.refTableBody;
7173
+ const tableBodyElem = refTableBody ? refTableBody.$el : null;
6970
7174
  const scrollTargetEl = xHandleEl || tableBodyElem;
6971
7175
  if (scrollTargetEl) {
6972
7176
  const wrapperRect = el.getBoundingClientRect();
6973
7177
  const tableWidth = el.clientWidth;
6974
- const leftContainerElem = $xeTable.$refs.leftContainer;
7178
+ const leftContainerElem = $xeTable.$refs.refLeftContainer;
6975
7179
  const leftContainerWidth = leftContainerElem ? leftContainerElem.clientWidth : 0;
6976
- const rightContainerElem = $xeTable.$refs.rightContainer;
7180
+ const rightContainerElem = $xeTable.$refs.refRightContainer;
6977
7181
  const rightContainerWidth = rightContainerElem ? rightContainerElem.clientWidth : 0;
6978
7182
  const srartX = wrapperRect.x + leftContainerWidth;
6979
7183
  const endX = wrapperRect.x + tableWidth - rightContainerWidth;
@@ -7105,6 +7309,7 @@ const Methods = {
7105
7309
  return this.$nextTick();
7106
7310
  },
7107
7311
  sort(sortConfs, sortOrder) {
7312
+ const $xeTable = this;
7108
7313
  const {
7109
7314
  sortOpts
7110
7315
  } = this;
@@ -7157,7 +7362,7 @@ const Methods = {
7157
7362
  }
7158
7363
  return this.$nextTick().then(() => {
7159
7364
  this.updateCellAreas();
7160
- return this.updateStyle();
7365
+ return updateStyle($xeTable);
7161
7366
  });
7162
7367
  }
7163
7368
  return this.$nextTick();
@@ -7209,7 +7414,7 @@ const Methods = {
7209
7414
  }
7210
7415
  return $xeTable.$nextTick().then(() => {
7211
7416
  $xeTable.updateCellAreas();
7212
- return $xeTable.updateStyle();
7417
+ return updateStyle($xeTable);
7213
7418
  });
7214
7419
  }
7215
7420
  return $xeTable.$nextTick();
@@ -7220,6 +7425,7 @@ const Methods = {
7220
7425
  * @param {String} column 列或字段名
7221
7426
  */
7222
7427
  clearSort(fieldOrColumn) {
7428
+ const $xeTable = this;
7223
7429
  const {
7224
7430
  sortOpts
7225
7431
  } = this;
@@ -7234,7 +7440,7 @@ const Methods = {
7234
7440
  if (!sortOpts.remote) {
7235
7441
  this.handleTableData(true);
7236
7442
  }
7237
- return this.$nextTick().then(this.updateStyle);
7443
+ return this.$nextTick().then(() => updateStyle($xeTable));
7238
7444
  },
7239
7445
  // 在 v3 中废弃
7240
7446
  getSortColumn() {
@@ -8132,7 +8338,7 @@ const Methods = {
8132
8338
  scrollXLoad,
8133
8339
  scrollYLoad
8134
8340
  } = this;
8135
- const bodyElem = $refs.tableBody.$el;
8341
+ const bodyElem = $refs.refTableBody.$el;
8136
8342
  return {
8137
8343
  virtualX: scrollXLoad,
8138
8344
  virtualY: scrollYLoad,
@@ -8152,15 +8358,18 @@ const Methods = {
8152
8358
  lastScrollLeft,
8153
8359
  lastScrollTop
8154
8360
  } = internalData;
8155
- const tableBody = $xeTable.$refs.tableBody;
8156
- const bodyElem = tableBody ? tableBody.$el : null;
8361
+ const xHandleEl = $xeTable.$refs.refScrollXHandleElem;
8362
+ const yHandleEl = $xeTable.$refs.refScrollYHandleElem;
8363
+ if (!xHandleEl || !yHandleEl) {
8364
+ return;
8365
+ }
8157
8366
  const rowOpts = $xeTable.computeRowOpts;
8158
- const validTip = $xeTable.$refs.validTip;
8159
- const tooltip = $xeTable.$refs.tooltip;
8160
- const bodyHeight = bodyElem ? bodyElem.clientHeight : 0;
8161
- const bodyWidth = bodyElem ? bodyElem.clientWidth : 0;
8162
- const scrollHeight = bodyElem ? bodyElem.scrollHeight : 0;
8163
- const scrollWidth = bodyElem ? bodyElem.scrollWidth : 0;
8367
+ const validTip = $xeTable.$refs.refValidTooltip;
8368
+ const tooltip = $xeTable.$refs.refTooltip;
8369
+ const bodyHeight = yHandleEl.clientHeight;
8370
+ const bodyWidth = xHandleEl.clientWidth;
8371
+ const scrollHeight = yHandleEl.scrollHeight;
8372
+ const scrollWidth = xHandleEl.scrollWidth;
8164
8373
  let isTop = false;
8165
8374
  let isBottom = false;
8166
8375
  let isLeft = false;
@@ -8231,10 +8440,10 @@ const Methods = {
8231
8440
  if (rowOpts.isHover || highlightHoverRow) {
8232
8441
  $xeTable.clearHoverRow();
8233
8442
  }
8234
- if (validTip && validTip.visible) {
8443
+ if (validTip && validTip.reactData.visible) {
8235
8444
  validTip.close();
8236
8445
  }
8237
- if (tooltip && tooltip.visible) {
8446
+ if (tooltip && tooltip.reactData.visible) {
8238
8447
  tooltip.close();
8239
8448
  }
8240
8449
  if (isBottomBoundary || isTopBoundary || isRightBoundary || isLeftBoundary) {
@@ -8253,7 +8462,7 @@ const Methods = {
8253
8462
  const {
8254
8463
  visibleSize
8255
8464
  } = scrollXStore;
8256
- const fpsTime = Math.min(80, Math.floor(visibleSize * 3));
8465
+ const fpsTime = Math.max(5, Math.min(80, Math.floor(visibleSize * 3)));
8257
8466
  if (lxTimeout) {
8258
8467
  clearTimeout(lxTimeout);
8259
8468
  }
@@ -8269,7 +8478,11 @@ const Methods = {
8269
8478
  },
8270
8479
  lazyScrollYData() {
8271
8480
  const $xeTable = this;
8481
+ const props = $xeTable;
8272
8482
  const internalData = $xeTable;
8483
+ const {
8484
+ showOverflow
8485
+ } = props;
8273
8486
  const {
8274
8487
  lyTimeout,
8275
8488
  lyRunTime,
@@ -8278,7 +8491,7 @@ const Methods = {
8278
8491
  const {
8279
8492
  visibleSize
8280
8493
  } = scrollYStore;
8281
- const fpsTime = Math.min(80, Math.floor(visibleSize));
8494
+ const fpsTime = showOverflow ? 5 : Math.max(5, Math.min(80, Math.floor(visibleSize / 2)));
8282
8495
  if (lyTimeout) {
8283
8496
  clearTimeout(lyTimeout);
8284
8497
  }
@@ -8316,35 +8529,285 @@ const Methods = {
8316
8529
  $xeTable.lazyScrollYData();
8317
8530
  }
8318
8531
  },
8319
- scrollXEvent(evnt) {
8532
+ triggerBodyScrollEvent(evnt, fixedType) {
8320
8533
  const $xeTable = this;
8321
8534
  const internalData = $xeTable;
8322
8535
  const {
8323
- intoRunScroll,
8324
- inFooterScroll,
8536
+ elemStore,
8537
+ lastScrollTop,
8538
+ lastScrollLeft,
8539
+ inWheelScroll,
8540
+ inVirtualScroll,
8541
+ inHeaderScroll,
8325
8542
  inBodyScroll,
8326
- lastScrollTop
8543
+ scrollRenderType,
8544
+ inFooterScroll
8327
8545
  } = internalData;
8328
- if (!intoRunScroll) {
8329
- if (inFooterScroll) {
8546
+ const xHandleEl = $xeTable.$refs.refScrollXHandleElem;
8547
+ const yHandleEl = $xeTable.$refs.refScrollYHandleElem;
8548
+ const leftScrollElem = (0, _util.getRefElem)(elemStore['left-body-scroll']);
8549
+ const bodyScrollElem = (0, _util.getRefElem)(elemStore['main-body-scroll']);
8550
+ const rightScrollElem = (0, _util.getRefElem)(elemStore['right-body-scroll']);
8551
+ const headerScrollElem = (0, _util.getRefElem)(elemStore['main-header-scroll']);
8552
+ const footerScrollElem = (0, _util.getRefElem)(elemStore['main-footer-scroll']);
8553
+ if (inWheelScroll || inVirtualScroll || inHeaderScroll || inFooterScroll) {
8554
+ return;
8555
+ }
8556
+ if (!bodyScrollElem) {
8557
+ return;
8558
+ }
8559
+ if (!xHandleEl) {
8560
+ return;
8561
+ }
8562
+ if (!yHandleEl) {
8563
+ return;
8564
+ }
8565
+ if (inBodyScroll) {
8566
+ if (scrollRenderType !== fixedType) {
8330
8567
  return;
8331
8568
  }
8332
- if (inBodyScroll) {
8333
- return;
8569
+ }
8570
+ let scrollTop = yHandleEl.scrollTop;
8571
+ let scrollLeft = xHandleEl.scrollLeft;
8572
+ if (leftScrollElem && fixedType === 'left') {
8573
+ scrollTop = leftScrollElem.scrollTop;
8574
+ } else if (rightScrollElem && fixedType === 'right') {
8575
+ scrollTop = rightScrollElem.scrollTop;
8576
+ } else {
8577
+ scrollTop = bodyScrollElem.scrollTop;
8578
+ scrollLeft = bodyScrollElem.scrollLeft;
8579
+ }
8580
+ const isRollX = scrollLeft !== lastScrollLeft;
8581
+ const isRollY = scrollTop !== lastScrollTop;
8582
+ internalData.inBodyScroll = true;
8583
+ internalData.scrollRenderType = fixedType;
8584
+ if (isRollY) {
8585
+ if (fixedType === 'left') {
8586
+ (0, _dom.setScrollTop)(bodyScrollElem, scrollTop);
8587
+ (0, _dom.setScrollTop)(rightScrollElem, scrollTop);
8588
+ } else if (fixedType === 'right') {
8589
+ (0, _dom.setScrollTop)(bodyScrollElem, scrollTop);
8590
+ (0, _dom.setScrollTop)(leftScrollElem, scrollTop);
8591
+ } else {
8592
+ (0, _dom.setScrollTop)(leftScrollElem, scrollTop);
8593
+ (0, _dom.setScrollTop)(rightScrollElem, scrollTop);
8334
8594
  }
8595
+ (0, _dom.setScrollTop)(yHandleEl, scrollTop);
8596
+ $xeTable.triggerScrollYEvent(evnt);
8597
+ }
8598
+ if (isRollX) {
8599
+ (0, _dom.setScrollLeft)(xHandleEl, scrollLeft);
8600
+ (0, _dom.setScrollLeft)(headerScrollElem, scrollLeft);
8601
+ (0, _dom.setScrollLeft)(footerScrollElem, scrollLeft);
8602
+ $xeTable.triggerScrollXEvent(evnt);
8603
+ }
8604
+ $xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
8605
+ type: 'body',
8606
+ fixed: fixedType
8607
+ });
8608
+ },
8609
+ triggerHeaderScrollEvent(evnt, fixedType) {
8610
+ const $xeTable = this;
8611
+ const internalData = $xeTable;
8612
+ const {
8613
+ elemStore,
8614
+ inWheelScroll,
8615
+ inVirtualScroll,
8616
+ inBodyScroll,
8617
+ inFooterScroll
8618
+ } = internalData;
8619
+ const xHandleEl = $xeTable.$refs.refScrollXHandleElem;
8620
+ const yHandleEl = $xeTable.$refs.refScrollYHandleElem;
8621
+ const bodyScrollElem = (0, _util.getRefElem)(elemStore['main-body-scroll']);
8622
+ const headerScrollElem = (0, _util.getRefElem)(elemStore['main-header-scroll']);
8623
+ const footerScrollElem = (0, _util.getRefElem)(elemStore['main-footer-scroll']);
8624
+ if (inWheelScroll) {
8625
+ return;
8626
+ }
8627
+ if (inVirtualScroll) {
8628
+ return;
8629
+ }
8630
+ if (inBodyScroll) {
8631
+ return;
8632
+ }
8633
+ if (inFooterScroll) {
8634
+ return;
8635
+ }
8636
+ if (!headerScrollElem) {
8637
+ return;
8638
+ }
8639
+ if (!xHandleEl) {
8640
+ return;
8641
+ }
8642
+ if (!yHandleEl) {
8643
+ return;
8644
+ }
8645
+ const scrollTop = yHandleEl.scrollTop;
8646
+ const scrollLeft = headerScrollElem.scrollLeft;
8647
+ const isRollX = true;
8648
+ const isRollY = false;
8649
+ internalData.inHeaderScroll = true;
8650
+ (0, _dom.setScrollLeft)(xHandleEl, scrollLeft);
8651
+ (0, _dom.setScrollLeft)(footerScrollElem, scrollLeft);
8652
+ (0, _dom.setScrollLeft)(bodyScrollElem, scrollLeft);
8653
+ $xeTable.triggerScrollXEvent(evnt);
8654
+ $xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
8655
+ type: 'header',
8656
+ fixed: fixedType
8657
+ });
8658
+ },
8659
+ triggerFooterScrollEvent(evnt, fixedType) {
8660
+ const $xeTable = this;
8661
+ const internalData = $xeTable;
8662
+ const {
8663
+ elemStore,
8664
+ inWheelScroll,
8665
+ inVirtualScroll,
8666
+ inHeaderScroll,
8667
+ inBodyScroll
8668
+ } = internalData;
8669
+ const xHandleEl = $xeTable.$refs.refScrollXHandleElem;
8670
+ const yHandleEl = $xeTable.$refs.refScrollYHandleElem;
8671
+ const bodyScrollElem = (0, _util.getRefElem)(elemStore['main-body-scroll']);
8672
+ const headerScrollElem = (0, _util.getRefElem)(elemStore['main-header-scroll']);
8673
+ const footerScrollElem = (0, _util.getRefElem)(elemStore['main-footer-scroll']);
8674
+ if (inWheelScroll) {
8675
+ return;
8676
+ }
8677
+ if (inVirtualScroll) {
8678
+ return;
8679
+ }
8680
+ if (inHeaderScroll) {
8681
+ return;
8682
+ }
8683
+ if (inBodyScroll) {
8684
+ return;
8685
+ }
8686
+ if (!footerScrollElem) {
8687
+ return;
8688
+ }
8689
+ if (!xHandleEl) {
8690
+ return;
8691
+ }
8692
+ if (!yHandleEl) {
8693
+ return;
8694
+ }
8695
+ const scrollTop = yHandleEl.scrollTop;
8696
+ const scrollLeft = footerScrollElem.scrollLeft;
8697
+ const isRollX = true;
8698
+ const isRollY = false;
8699
+ internalData.inFooterScroll = true;
8700
+ (0, _dom.setScrollLeft)(xHandleEl, scrollLeft);
8701
+ (0, _dom.setScrollLeft)(headerScrollElem, scrollLeft);
8702
+ (0, _dom.setScrollLeft)(bodyScrollElem, scrollLeft);
8703
+ $xeTable.triggerScrollXEvent(evnt);
8704
+ $xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
8705
+ type: 'footer',
8706
+ fixed: fixedType
8707
+ });
8708
+ },
8709
+ triggerBodyWheelEvent(evnt) {
8710
+ const $xeTable = this;
8711
+ const tableProps = $xeTable;
8712
+ const reactData = $xeTable;
8713
+ const internalData = $xeTable;
8714
+ const {
8715
+ deltaY,
8716
+ deltaX
8717
+ } = evnt;
8718
+ const {
8719
+ highlightHoverRow
8720
+ } = tableProps;
8721
+ const {
8722
+ elemStore,
8723
+ lastScrollTop,
8724
+ lastScrollLeft
8725
+ } = internalData;
8726
+ const rowOpts = $xeTable.computeRowOpts;
8727
+ const xHandleEl = $xeTable.$refs.refScrollXHandleElem;
8728
+ const yHandleEl = $xeTable.$refs.refScrollYHandleElem;
8729
+ const leftScrollElem = (0, _util.getRefElem)(elemStore['left-body-scroll']);
8730
+ const bodyScrollElem = (0, _util.getRefElem)(elemStore['main-body-scroll']);
8731
+ const rightScrollElem = (0, _util.getRefElem)(elemStore['right-body-scroll']);
8732
+ if (!xHandleEl) {
8733
+ return;
8734
+ }
8735
+ if (!yHandleEl) {
8736
+ return;
8737
+ }
8738
+ if (!bodyScrollElem) {
8739
+ return;
8740
+ }
8741
+ let multiple = 1;
8742
+ if (reactData.lastScrollTime + 25 > Date.now()) {
8743
+ multiple = 1.18;
8744
+ } else if (reactData.lastScrollTime + 30 > Date.now()) {
8745
+ multiple = 1.15;
8746
+ } else if (reactData.lastScrollTime + 40 > Date.now()) {
8747
+ multiple = 1.12;
8748
+ } else if (reactData.lastScrollTime + 55 > Date.now()) {
8749
+ multiple = 1.09;
8750
+ } else if (reactData.lastScrollTime + 75 > Date.now()) {
8751
+ multiple = 1.06;
8752
+ } else if (reactData.lastScrollTime + 100 > Date.now()) {
8753
+ multiple = 1.03;
8754
+ }
8755
+ const deltaTop = deltaY * multiple;
8756
+ const deltaLeft = deltaX * multiple;
8757
+ const isTopWheel = deltaTop < 0;
8758
+ const currScrollTop = yHandleEl.scrollTop;
8759
+ // 如果滚动位置已经是顶部或底部,则不需要触发
8760
+ if (isTopWheel ? currScrollTop <= 0 : currScrollTop >= yHandleEl.scrollHeight - yHandleEl.clientHeight) {
8761
+ return;
8762
+ }
8763
+ const scrollTop = bodyScrollElem.scrollTop + deltaTop;
8764
+ const scrollLeft = bodyScrollElem.scrollLeft + deltaLeft;
8765
+ const isRollX = scrollLeft !== lastScrollLeft;
8766
+ const isRollY = scrollTop !== lastScrollTop;
8767
+ // 用于鼠标纵向滚轮处理
8768
+ if (isRollY) {
8769
+ evnt.preventDefault();
8770
+ if (rowOpts.isHover || highlightHoverRow) {
8771
+ $xeTable.clearHoverRow();
8772
+ }
8773
+ internalData.inWheelScroll = true;
8774
+ (0, _dom.setScrollTop)(yHandleEl, scrollTop);
8775
+ (0, _dom.setScrollTop)(bodyScrollElem, scrollTop);
8776
+ (0, _dom.setScrollTop)(leftScrollElem, scrollTop);
8777
+ (0, _dom.setScrollTop)(rightScrollElem, scrollTop);
8778
+ $xeTable.triggerScrollYEvent(evnt);
8779
+ $xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
8780
+ type: 'footer',
8781
+ fixed: ''
8782
+ });
8783
+ }
8784
+ },
8785
+ scrollXEvent(evnt) {
8786
+ const $xeTable = this;
8787
+ const internalData = $xeTable;
8788
+ const {
8789
+ elemStore,
8790
+ inWheelScroll,
8791
+ lastScrollTop,
8792
+ inHeaderScroll,
8793
+ inBodyScroll,
8794
+ inFooterScroll
8795
+ } = internalData;
8796
+ if (inHeaderScroll || inBodyScroll || inFooterScroll) {
8797
+ return;
8798
+ }
8799
+ if (inWheelScroll) {
8800
+ return;
8335
8801
  }
8336
- const tableHeader = $xeTable.$refs.tableHeader;
8337
- const tableBody = $xeTable.$refs.tableBody;
8338
- const tableFooter = $xeTable.$refs.tableFooter;
8339
- const bodyElem = tableBody.$el;
8340
- const headerElem = tableHeader ? tableHeader.$el : null;
8341
- const footerElem = tableFooter ? tableFooter.$el : null;
8802
+ const headerScrollElem = (0, _util.getRefElem)(elemStore['main-header-scroll']);
8803
+ const bodyScrollElem = (0, _util.getRefElem)(elemStore['main-body-scroll']);
8804
+ const footerScrollElem = (0, _util.getRefElem)(elemStore['main-footer-scroll']);
8342
8805
  const yHandleEl = $xeTable.$refs.refScrollYHandleElem;
8343
8806
  const wrapperEl = evnt.currentTarget;
8344
8807
  const {
8345
8808
  scrollLeft
8346
8809
  } = wrapperEl;
8347
- const yBodyEl = yHandleEl || bodyElem;
8810
+ const yBodyEl = yHandleEl || bodyScrollElem;
8348
8811
  let scrollTop = 0;
8349
8812
  if (yBodyEl) {
8350
8813
  scrollTop = yBodyEl.scrollTop;
@@ -8352,9 +8815,9 @@ const Methods = {
8352
8815
  const isRollX = true;
8353
8816
  const isRollY = scrollTop !== lastScrollTop;
8354
8817
  internalData.inVirtualScroll = true;
8355
- (0, _dom.setScrollLeft)(bodyElem, scrollLeft);
8356
- (0, _dom.setScrollLeft)(headerElem, scrollLeft);
8357
- (0, _dom.setScrollLeft)(footerElem, scrollLeft);
8818
+ (0, _dom.setScrollLeft)(bodyScrollElem, scrollLeft);
8819
+ (0, _dom.setScrollLeft)(headerScrollElem, scrollLeft);
8820
+ (0, _dom.setScrollLeft)(footerScrollElem, scrollLeft);
8358
8821
  $xeTable.triggerScrollXEvent(evnt);
8359
8822
  $xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
8360
8823
  type: 'table',
@@ -8365,31 +8828,28 @@ const Methods = {
8365
8828
  const $xeTable = this;
8366
8829
  const internalData = $xeTable;
8367
8830
  const {
8368
- intoRunScroll,
8369
- inFooterScroll,
8831
+ elemStore,
8832
+ inWheelScroll,
8833
+ lastScrollLeft,
8834
+ inHeaderScroll,
8370
8835
  inBodyScroll,
8371
- lastScrollLeft
8836
+ inFooterScroll
8372
8837
  } = internalData;
8373
- if (!intoRunScroll) {
8374
- if (inFooterScroll) {
8375
- return;
8376
- }
8377
- if (inBodyScroll) {
8378
- return;
8379
- }
8838
+ if (inHeaderScroll || inBodyScroll || inFooterScroll) {
8839
+ return;
8840
+ }
8841
+ if (inWheelScroll) {
8842
+ return;
8380
8843
  }
8381
- const tableBody = $xeTable.$refs.tableBody;
8382
- const leftBody = $xeTable.$refs.leftBody;
8383
- const rightBody = $xeTable.$refs.rightBody;
8384
- const bodyElem = tableBody.$el;
8385
- const leftElem = leftBody ? leftBody.$el : null;
8386
- const rightElem = rightBody ? rightBody.$el : null;
8844
+ const leftScrollElem = (0, _util.getRefElem)(elemStore['left-body-scroll']);
8845
+ const bodyScrollElem = (0, _util.getRefElem)(elemStore['main-body-scroll']);
8846
+ const rightScrollElem = (0, _util.getRefElem)(elemStore['right-body-scroll']);
8387
8847
  const xHandleEl = $xeTable.$refs.refScrollXHandleElem;
8388
8848
  const wrapperEl = evnt.currentTarget;
8389
8849
  const {
8390
8850
  scrollTop
8391
8851
  } = wrapperEl;
8392
- const xBodyEl = xHandleEl || bodyElem;
8852
+ const xBodyEl = xHandleEl || bodyScrollElem;
8393
8853
  let scrollLeft = 0;
8394
8854
  if (xBodyEl) {
8395
8855
  scrollLeft = xBodyEl.scrollLeft;
@@ -8397,52 +8857,26 @@ const Methods = {
8397
8857
  const isRollX = scrollLeft !== lastScrollLeft;
8398
8858
  const isRollY = true;
8399
8859
  internalData.inVirtualScroll = true;
8400
- (0, _dom.setScrollTop)(bodyElem, scrollTop);
8401
- (0, _dom.setScrollTop)(leftElem, scrollTop);
8402
- (0, _dom.setScrollTop)(rightElem, scrollTop);
8860
+ (0, _dom.setScrollTop)(bodyScrollElem, scrollTop);
8861
+ (0, _dom.setScrollTop)(leftScrollElem, scrollTop);
8862
+ (0, _dom.setScrollTop)(rightScrollElem, scrollTop);
8403
8863
  $xeTable.triggerScrollYEvent(evnt);
8404
8864
  $xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
8405
8865
  type: 'table',
8406
8866
  fixed: ''
8407
8867
  });
8408
8868
  },
8409
- handleTableColumn() {
8410
- const {
8411
- scrollXLoad,
8412
- visibleColumn,
8413
- scrollXStore,
8414
- fullColumnIdData
8415
- } = this;
8416
- const tableColumn = scrollXLoad ? visibleColumn.slice(scrollXStore.startIndex, scrollXStore.endIndex) : visibleColumn.slice(0);
8417
- tableColumn.forEach((column, $index) => {
8418
- const colid = column.id;
8419
- const colRest = fullColumnIdData[colid];
8420
- if (colRest) {
8421
- colRest.$index = $index;
8422
- }
8423
- });
8424
- this.tableColumn = tableColumn;
8425
- },
8426
- handleUpdateColumn() {
8427
- const $xeTable = this;
8428
- const internalData = $xeTable;
8429
- const columnList = _xeUtils.default.orderBy(internalData.collectColumn, 'renderSortNumber');
8430
- internalData.collectColumn = columnList;
8431
- const tableFullColumn = getColumnList(columnList);
8432
- internalData.tableFullColumn = tableFullColumn;
8433
- cacheColumnMap($xeTable);
8434
- },
8435
8869
  updateScrollXData() {
8436
8870
  const $xeTable = this;
8437
8871
  const props = $xeTable;
8438
8872
  const {
8439
8873
  showOverflow
8440
8874
  } = props;
8441
- $xeTable.handleTableColumn();
8442
- calcCellHeight($xeTable);
8875
+ handleTableColumn($xeTable);
8876
+ // calcCellHeight()
8443
8877
  return $xeTable.$nextTick().then(() => {
8444
- calcCellHeight($xeTable);
8445
- $xeTable.handleTableColumn();
8878
+ // calcCellHeight()
8879
+ handleTableColumn($xeTable);
8446
8880
  $xeTable.updateScrollXSpace();
8447
8881
  if (!showOverflow) {
8448
8882
  $xeTable.updateScrollYSpace();
@@ -8452,21 +8886,21 @@ const Methods = {
8452
8886
  // 更新横向 X 可视渲染上下剩余空间大小
8453
8887
  updateScrollXSpace() {
8454
8888
  const $xeTable = this;
8889
+ const reactData = $xeTable;
8890
+ const internalData = $xeTable;
8455
8891
  const {
8456
- $refs,
8457
8892
  isGroup,
8458
- elemStore,
8893
+ scrollXLoad
8894
+ } = reactData;
8895
+ const {
8459
8896
  visibleColumn,
8460
8897
  scrollXStore,
8461
- scrollXLoad,
8462
- tableWidth,
8463
- scrollbarWidth
8464
- } = $xeTable;
8465
- const {
8466
- tableHeader,
8467
- tableBody,
8468
- tableFooter
8469
- } = $refs;
8898
+ elemStore,
8899
+ tableWidth
8900
+ } = internalData;
8901
+ const tableHeader = $xeTable.$refs.refTableHeader;
8902
+ const tableBody = $xeTable.$refs.refTableBody;
8903
+ const tableFooter = $xeTable.$refs.refTableFooter;
8470
8904
  const tableBodyElem = tableBody ? tableBody.$el : null;
8471
8905
  if (tableBodyElem) {
8472
8906
  const tableHeaderElem = tableHeader ? tableHeader.$el : null;
@@ -8490,25 +8924,27 @@ const Methods = {
8490
8924
  containerList.forEach(name => {
8491
8925
  const layoutList = ['header', 'body', 'footer'];
8492
8926
  layoutList.forEach(layout => {
8493
- const xSpaceElem = elemStore[`${name}-${layout}-xSpace`];
8927
+ const xSpaceElem = (0, _util.getRefElem)(elemStore[`${name}-${layout}-xSpace`]);
8494
8928
  if (xSpaceElem) {
8495
- xSpaceElem.style.width = scrollXLoad ? `${tableWidth + (layout === 'header' ? scrollbarWidth : 0)}px` : '';
8929
+ xSpaceElem.style.width = scrollXLoad ? `${tableWidth}px` : '';
8496
8930
  }
8497
8931
  });
8498
8932
  });
8499
8933
  const scrollXSpaceEl = $xeTable.$refs.refScrollXSpaceElem;
8500
8934
  if (scrollXSpaceEl) {
8501
- scrollXSpaceEl.style.width = `${tableWidth + scrollbarWidth}px`;
8935
+ scrollXSpaceEl.style.width = `${tableWidth}px`;
8502
8936
  }
8503
- this.$nextTick(this.updateStyle);
8937
+ $xeTable.$nextTick(() => {
8938
+ updateStyle($xeTable);
8939
+ });
8504
8940
  }
8505
8941
  },
8506
8942
  updateScrollYData() {
8507
8943
  const $xeTable = this;
8508
8944
  $xeTable.handleTableData();
8509
- calcCellHeight($xeTable);
8945
+ // calcCellHeight()
8510
8946
  return $xeTable.$nextTick().then(() => {
8511
- calcCellHeight($xeTable);
8947
+ // calcCellHeight()
8512
8948
  $xeTable.handleTableData();
8513
8949
  $xeTable.updateScrollYSpace();
8514
8950
  });
@@ -8516,26 +8952,32 @@ const Methods = {
8516
8952
  // 更新纵向 Y 可视渲染上下剩余空间大小
8517
8953
  updateScrollYSpace() {
8518
8954
  const $xeTable = this;
8955
+ const props = $xeTable;
8956
+ const reactData = $xeTable;
8957
+ const internalData = $xeTable;
8958
+ const {
8959
+ showOverflow
8960
+ } = props;
8519
8961
  const {
8520
- showOverflow,
8521
- elemStore,
8522
- scrollYStore,
8523
8962
  scrollYLoad,
8963
+ rowHeight
8964
+ } = reactData;
8965
+ const {
8966
+ scrollYStore,
8967
+ elemStore,
8524
8968
  afterFullData,
8525
8969
  fullAllDataRowIdData
8526
- } = this;
8970
+ } = internalData;
8527
8971
  const {
8528
- startIndex,
8529
- rowHeight
8972
+ startIndex
8530
8973
  } = scrollYStore;
8531
- let bodyHeight = 0;
8532
- let topSpaceHeight = 0;
8974
+ const bodyTableElem = (0, _util.getRefElem)(elemStore['main-body-table']);
8533
8975
  const containerList = ['main', 'left', 'right'];
8534
- let marginTop = '';
8535
- let ySpaceHeight = '';
8976
+ let topSpaceHeight = 0;
8977
+ let ySpaceHeight = 0;
8536
8978
  if (scrollYLoad) {
8537
8979
  if (showOverflow) {
8538
- bodyHeight = afterFullData.length * rowHeight;
8980
+ ySpaceHeight = afterFullData.length * rowHeight;
8539
8981
  topSpaceHeight = Math.max(0, startIndex * rowHeight);
8540
8982
  } else {
8541
8983
  for (let i = 0; i < afterFullData.length; i++) {
@@ -8543,7 +8985,7 @@ const Methods = {
8543
8985
  const rowid = (0, _util.getRowid)($xeTable, row);
8544
8986
  const rowRest = fullAllDataRowIdData[rowid];
8545
8987
  if (rowRest) {
8546
- bodyHeight += rowRest.height || rowHeight;
8988
+ ySpaceHeight += rowRest.height || rowHeight;
8547
8989
  }
8548
8990
  }
8549
8991
  for (let i = 0; i < startIndex; i++) {
@@ -8555,27 +8997,31 @@ const Methods = {
8555
8997
  }
8556
8998
  }
8557
8999
  }
8558
- marginTop = `${topSpaceHeight}px`;
8559
- ySpaceHeight = `${bodyHeight}px`;
9000
+ } else {
9001
+ if (bodyTableElem) {
9002
+ ySpaceHeight = bodyTableElem.clientHeight;
9003
+ }
8560
9004
  }
8561
9005
  containerList.forEach(name => {
8562
9006
  const layoutList = ['header', 'body', 'footer'];
8563
- const tableElem = elemStore[`${name}-body-table`];
9007
+ const tableElem = (0, _util.getRefElem)(elemStore[`${name}-body-table`]);
8564
9008
  if (tableElem) {
8565
- tableElem.style.marginTop = marginTop;
9009
+ tableElem.style.marginTop = topSpaceHeight ? `${topSpaceHeight}px` : '';
8566
9010
  }
8567
9011
  layoutList.forEach(layout => {
8568
- const ySpaceElem = elemStore[`${name}-${layout}-ySpace`];
9012
+ const ySpaceElem = (0, _util.getRefElem)(elemStore[`${name}-${layout}-ySpace`]);
8569
9013
  if (ySpaceElem) {
8570
- ySpaceElem.style.height = ySpaceHeight;
9014
+ ySpaceElem.style.height = ySpaceHeight ? `${ySpaceHeight}px` : '';
8571
9015
  }
8572
9016
  });
8573
9017
  });
8574
9018
  const scrollYSpaceEl = $xeTable.$refs.refScrollYSpaceElem;
8575
9019
  if (scrollYSpaceEl) {
8576
- scrollYSpaceEl.style.height = ySpaceHeight;
9020
+ scrollYSpaceEl.style.height = ySpaceHeight ? `${ySpaceHeight}px` : '';
8577
9021
  }
8578
- this.$nextTick(this.updateStyle);
9022
+ $xeTable.$nextTick(() => {
9023
+ updateStyle($xeTable);
9024
+ });
8579
9025
  },
8580
9026
  updateScrollYStatus() {
8581
9027
  const $xeTable = this;
@@ -8593,17 +9039,17 @@ const Methods = {
8593
9039
  $refs
8594
9040
  } = this;
8595
9041
  const {
8596
- tableBody,
8597
- tableHeader,
9042
+ refTableBody,
9043
+ refTableHeader,
8598
9044
  leftBody,
8599
9045
  rightBody,
8600
- tableFooter
9046
+ refTableFooter
8601
9047
  } = $refs;
8602
- const tableBodyElem = tableBody ? tableBody.$el : null;
9048
+ const tableBodyElem = refTableBody ? refTableBody.$el : null;
8603
9049
  const leftBodyElem = leftBody ? leftBody.$el : null;
8604
9050
  const rightBodyElem = rightBody ? rightBody.$el : null;
8605
- const tableHeaderElem = tableHeader ? tableHeader.$el : null;
8606
- const tableFooterElem = tableFooter ? tableFooter.$el : null;
9051
+ const tableHeaderElem = refTableHeader ? refTableHeader.$el : null;
9052
+ const tableFooterElem = refTableFooter ? refTableFooter.$el : null;
8607
9053
  internalData.intoRunScroll = true;
8608
9054
  if (_xeUtils.default.isNumber(scrollLeft)) {
8609
9055
  const xHandleEl = $xeTable.$refs.refScrollXHandleElem;
@@ -8717,46 +9163,36 @@ const Methods = {
8717
9163
  const $xeTable = this;
8718
9164
  const internalData = $xeTable;
8719
9165
  const {
9166
+ elemStore,
8720
9167
  scrollXStore,
8721
9168
  scrollYStore
8722
9169
  } = internalData;
8723
- const tableBody = $xeTable.$refs.tableBody;
8724
- const tableHeader = $xeTable.$refs.tableHeader;
8725
- const tableFooter = $xeTable.$refs.tableFooter;
8726
- const leftBody = $xeTable.$refs.leftBody;
8727
- const rightBody = $xeTable.$refs.rightBody;
8728
- const leftBodyElem = leftBody ? leftBody.$el : null;
8729
- const tableBodyElem = tableBody ? tableBody.$el : null;
8730
- const rightBodyElem = rightBody ? rightBody.$el : null;
8731
- const tableHeaderElem = tableHeader ? tableHeader.$el : null;
8732
- const tableFooterElem = tableFooter ? tableFooter.$el : null;
9170
+ const headerScrollElem = (0, _util.getRefElem)(elemStore['main-header-scroll']);
9171
+ const bodyScrollElem = (0, _util.getRefElem)(elemStore['main-body-scroll']);
9172
+ const footerScrollElem = (0, _util.getRefElem)(elemStore['main-footer-scroll']);
9173
+ const leftScrollElem = (0, _util.getRefElem)(elemStore['left-body-scroll']);
9174
+ const rightScrollElem = (0, _util.getRefElem)(elemStore['right-body-scroll']);
8733
9175
  const xHandleEl = $xeTable.$refs.refScrollXHandleElem;
8734
- if (xHandleEl) {
8735
- (0, _dom.setScrollLeft)(xHandleEl, 0);
8736
- } else {
8737
- (0, _dom.setScrollLeft)(tableBodyElem, 0);
8738
- (0, _dom.setScrollLeft)(tableHeaderElem, 0);
8739
- (0, _dom.setScrollLeft)(tableFooterElem, 0);
8740
- }
8741
9176
  const yHandleEl = $xeTable.$refs.refScrollYHandleElem;
8742
- if (yHandleEl) {
8743
- (0, _dom.setScrollTop)(yHandleEl, 0);
8744
- } else {
8745
- (0, _dom.setScrollTop)(tableBodyElem, 0);
8746
- (0, _dom.setScrollTop)(leftBodyElem, 0);
8747
- (0, _dom.setScrollTop)(rightBodyElem, 0);
8748
- }
9177
+ internalData.intoRunScroll = true;
9178
+ (0, _dom.setScrollLeft)(xHandleEl, 0);
9179
+ (0, _dom.setScrollLeft)(bodyScrollElem, 0);
9180
+ (0, _dom.setScrollLeft)(headerScrollElem, 0);
9181
+ (0, _dom.setScrollLeft)(footerScrollElem, 0);
9182
+ (0, _dom.setScrollTop)(yHandleEl, 0);
9183
+ (0, _dom.setScrollTop)(bodyScrollElem, 0);
9184
+ (0, _dom.setScrollTop)(leftScrollElem, 0);
9185
+ (0, _dom.setScrollTop)(rightScrollElem, 0);
8749
9186
  scrollXStore.startIndex = 0;
9187
+ scrollXStore.visibleStartIndex = 0;
8750
9188
  scrollXStore.endIndex = scrollXStore.visibleSize;
9189
+ scrollXStore.visibleEndIndex = scrollXStore.visibleSize;
8751
9190
  scrollYStore.startIndex = 0;
9191
+ scrollYStore.visibleStartIndex = 0;
8752
9192
  scrollYStore.endIndex = scrollYStore.visibleSize;
9193
+ scrollYStore.visibleEndIndex = scrollYStore.visibleSize;
8753
9194
  return $xeTable.$nextTick().then(() => {
8754
- (0, _dom.setScrollLeft)(tableBodyElem, 0);
8755
- (0, _dom.setScrollLeft)(tableHeaderElem, 0);
8756
- (0, _dom.setScrollLeft)(tableFooterElem, 0);
8757
- (0, _dom.setScrollTop)(tableBodyElem, 0);
8758
- (0, _dom.setScrollTop)(leftBodyElem, 0);
8759
- (0, _dom.setScrollTop)(rightBodyElem, 0);
9195
+ internalData.intoRunScroll = false;
8760
9196
  });
8761
9197
  },
8762
9198
  /**
@@ -8796,8 +9232,8 @@ const Methods = {
8796
9232
  editRules,
8797
9233
  validStore
8798
9234
  } = this;
8799
- const tableBody = $refs.tableBody;
8800
- if (slotParams && tableBody && editRules) {
9235
+ const refTableBody = $refs.refTableBody;
9236
+ if (slotParams && refTableBody && editRules) {
8801
9237
  const {
8802
9238
  row,
8803
9239
  column
@@ -8839,13 +9275,14 @@ const Methods = {
8839
9275
  * @param {TableMergeConfig[]} merges { row: Row|number, column: ColumnInfo|number, rowspan: number, colspan: number }
8840
9276
  */
8841
9277
  setMergeCells(merges) {
9278
+ const $xeTable = this;
8842
9279
  if (this.spanMethod) {
8843
9280
  (0, _log.errLog)('vxe.error.errConflicts', ['merge-cells', 'span-method']);
8844
9281
  }
8845
9282
  setMerges(this, merges, this.mergeList, this.afterFullData);
8846
9283
  return this.$nextTick().then(() => {
8847
9284
  this.updateCellAreas();
8848
- return this.updateStyle();
9285
+ return updateStyle($xeTable);
8849
9286
  });
8850
9287
  },
8851
9288
  /**
@@ -8853,13 +9290,14 @@ const Methods = {
8853
9290
  * @param {TableMergeConfig[]} merges 多个或数组 [{row:Row|number, col:ColumnInfo|number}]
8854
9291
  */
8855
9292
  removeMergeCells(merges) {
9293
+ const $xeTable = this;
8856
9294
  if (this.spanMethod) {
8857
9295
  (0, _log.errLog)('vxe.error.errConflicts', ['merge-cells', 'span-method']);
8858
9296
  }
8859
9297
  const rest = removeMerges(this, merges, this.mergeList, this.afterFullData);
8860
9298
  return this.$nextTick().then(() => {
8861
9299
  this.updateCellAreas();
8862
- this.updateStyle();
9300
+ updateStyle($xeTable);
8863
9301
  return rest;
8864
9302
  });
8865
9303
  },
@@ -8873,32 +9311,35 @@ const Methods = {
8873
9311
  * 清除所有单元格合并
8874
9312
  */
8875
9313
  clearMergeCells() {
9314
+ const $xeTable = this;
8876
9315
  this.mergeList = [];
8877
9316
  return this.$nextTick().then(() => {
8878
- return this.updateStyle();
9317
+ return updateStyle($xeTable);
8879
9318
  });
8880
9319
  },
8881
9320
  handleDefaultMergeFooterItems() {
8882
9321
  this.setMergeFooterItems(this.mergeFooterItems);
8883
9322
  },
8884
9323
  setMergeFooterItems(merges) {
9324
+ const $xeTable = this;
8885
9325
  if (this.footerSpanMethod) {
8886
9326
  (0, _log.errLog)('vxe.error.errConflicts', ['merge-footer-items', 'footer-span-method']);
8887
9327
  }
8888
9328
  setMerges(this, merges, this.mergeFooterList, null);
8889
9329
  return this.$nextTick().then(() => {
8890
9330
  this.updateCellAreas();
8891
- return this.updateStyle();
9331
+ return updateStyle($xeTable);
8892
9332
  });
8893
9333
  },
8894
9334
  removeMergeFooterItems(merges) {
9335
+ const $xeTable = this;
8895
9336
  if (this.footerSpanMethod) {
8896
9337
  (0, _log.errLog)('vxe.error.errConflicts', ['merge-footer-items', 'footer-span-method']);
8897
9338
  }
8898
9339
  const rest = removeMerges(this, merges, this.mergeFooterList, null);
8899
9340
  return this.$nextTick().then(() => {
8900
9341
  this.updateCellAreas();
8901
- this.updateStyle();
9342
+ updateStyle($xeTable);
8902
9343
  return rest;
8903
9344
  });
8904
9345
  },
@@ -8912,9 +9353,10 @@ const Methods = {
8912
9353
  * 清除所有表尾合并
8913
9354
  */
8914
9355
  clearMergeFooterItems() {
9356
+ const $xeTable = this;
8915
9357
  this.mergeFooterList = [];
8916
9358
  return this.$nextTick().then(() => {
8917
- return this.updateStyle();
9359
+ return updateStyle($xeTable);
8918
9360
  });
8919
9361
  },
8920
9362
  updateZindex() {