vxe-table 3.12.8 → 3.12.10-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) 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/style.css +1 -1
  5. package/es/style.min.css +1 -1
  6. package/es/table/module/export/mixin.js +3 -3
  7. package/es/table/module/filter/mixin.js +3 -3
  8. package/es/table/module/keyboard/mixin.js +4 -4
  9. package/es/table/module/menu/mixin.js +2 -2
  10. package/es/table/module/validator/mixin.js +2 -2
  11. package/es/table/src/body.js +262 -363
  12. package/es/table/src/footer.js +135 -154
  13. package/es/table/src/header.js +120 -100
  14. package/es/table/src/methods.js +1175 -816
  15. package/es/table/src/props.js +9 -3
  16. package/es/table/src/table.js +187 -103
  17. package/es/table/src/util.js +35 -21
  18. package/es/table/style.css +146 -63
  19. package/es/table/style.min.css +1 -1
  20. package/es/ui/index.js +14 -4
  21. package/es/ui/src/log.js +1 -1
  22. package/es/vxe-table/style.css +146 -63
  23. package/es/vxe-table/style.min.css +1 -1
  24. package/lib/grid/src/grid.js +4 -1
  25. package/lib/grid/src/grid.min.js +1 -1
  26. package/lib/index.css +1 -1
  27. package/lib/index.min.css +1 -1
  28. package/lib/index.umd.js +1920 -1599
  29. package/lib/index.umd.min.js +1 -1
  30. package/lib/style.css +1 -1
  31. package/lib/style.min.css +1 -1
  32. package/lib/table/module/export/mixin.js +3 -3
  33. package/lib/table/module/export/mixin.min.js +1 -1
  34. package/lib/table/module/filter/mixin.js +4 -4
  35. package/lib/table/module/filter/mixin.min.js +1 -1
  36. package/lib/table/module/keyboard/mixin.js +5 -5
  37. package/lib/table/module/keyboard/mixin.min.js +1 -1
  38. package/lib/table/module/menu/mixin.js +2 -2
  39. package/lib/table/module/menu/mixin.min.js +1 -1
  40. package/lib/table/module/validator/mixin.js +2 -2
  41. package/lib/table/module/validator/mixin.min.js +1 -1
  42. package/lib/table/src/body.js +205 -381
  43. package/lib/table/src/body.min.js +1 -1
  44. package/lib/table/src/footer.js +124 -151
  45. package/lib/table/src/footer.min.js +1 -1
  46. package/lib/table/src/header.js +97 -74
  47. package/lib/table/src/header.min.js +1 -1
  48. package/lib/table/src/methods.js +1261 -875
  49. package/lib/table/src/methods.min.js +1 -1
  50. package/lib/table/src/props.js +9 -3
  51. package/lib/table/src/props.min.js +1 -1
  52. package/lib/table/src/table.js +171 -90
  53. package/lib/table/src/table.min.js +1 -1
  54. package/lib/table/src/util.js +38 -22
  55. package/lib/table/src/util.min.js +1 -1
  56. package/lib/table/style/style.css +146 -63
  57. package/lib/table/style/style.min.css +1 -1
  58. package/lib/ui/index.js +14 -4
  59. package/lib/ui/index.min.js +1 -1
  60. package/lib/ui/src/log.js +1 -1
  61. package/lib/ui/src/log.min.js +1 -1
  62. package/lib/vxe-table/style/style.css +146 -63
  63. package/lib/vxe-table/style/style.min.css +1 -1
  64. package/package.json +2 -2
  65. package/packages/grid/src/grid.ts +6 -1
  66. package/packages/table/module/export/mixin.ts +3 -3
  67. package/packages/table/module/filter/mixin.ts +3 -3
  68. package/packages/table/module/keyboard/mixin.ts +4 -4
  69. package/packages/table/module/menu/mixin.ts +2 -2
  70. package/packages/table/module/validator/mixin.ts +2 -2
  71. package/packages/table/src/body.ts +296 -436
  72. package/packages/table/src/footer.ts +148 -164
  73. package/packages/table/src/header.ts +135 -111
  74. package/packages/table/src/methods.ts +1249 -873
  75. package/packages/table/src/props.ts +9 -3
  76. package/packages/table/src/table.ts +195 -146
  77. package/packages/table/src/util.ts +40 -23
  78. package/packages/ui/index.ts +13 -3
  79. package/styles/components/table.scss +164 -74
  80. /package/es/{iconfont.1736406699090.ttf → iconfont.1736688976404.ttf} +0 -0
  81. /package/es/{iconfont.1736406699090.woff → iconfont.1736688976404.woff} +0 -0
  82. /package/es/{iconfont.1736406699090.woff2 → iconfont.1736688976404.woff2} +0 -0
  83. /package/lib/{iconfont.1736406699090.ttf → iconfont.1736688976404.ttf} +0 -0
  84. /package/lib/{iconfont.1736406699090.woff → iconfont.1736688976404.woff} +0 -0
  85. /package/lib/{iconfont.1736406699090.woff2 → iconfont.1736688976404.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}`);
@@ -2651,47 +3274,6 @@ const Methods = {
2651
3274
  this.afterTreeFullData = tableTree;
2652
3275
  this.updateAfterDataIndex();
2653
3276
  },
2654
- updateTreeDataIndex() {
2655
- const $xeTable = this;
2656
- const props = $xeTable;
2657
- const internalData = $xeTable;
2658
- const {
2659
- treeConfig
2660
- } = props;
2661
- const {
2662
- afterFullData,
2663
- fullDataRowIdData,
2664
- fullAllDataRowIdData
2665
- } = internalData;
2666
- const treeOpts = $xeTable.computeTreeOpts;
2667
- if (treeConfig) {
2668
- if (treeOpts.transform) {
2669
- afterFullData.forEach((row, index) => {
2670
- const rowid = (0, _util.getRowid)($xeTable, row);
2671
- const rowRest = fullAllDataRowIdData[rowid];
2672
- if (rowRest) {
2673
- rowRest._index = index;
2674
- } else {
2675
- const rest = {
2676
- row,
2677
- rowid,
2678
- seq: '-1',
2679
- index: -1,
2680
- $index: -1,
2681
- _index: index,
2682
- items: [],
2683
- parent: null,
2684
- level: 0,
2685
- height: 0,
2686
- oTop: 0
2687
- };
2688
- fullAllDataRowIdData[rowid] = rest;
2689
- fullDataRowIdData[rowid] = rest;
2690
- }
2691
- });
2692
- }
2693
- }
2694
- },
2695
3277
  /**
2696
3278
  * 预编译
2697
3279
  * 对渲染中的数据提前解析序号及索引。牺牲提前编译耗时换取渲染中额外损耗,使运行时更加流畅
@@ -2741,7 +3323,6 @@ const Methods = {
2741
3323
  }, {
2742
3324
  children: treeOpts.transform ? treeOpts.mapChildrenField : childrenField
2743
3325
  });
2744
- $xeTable.updateTreeDataIndex();
2745
3326
  } else {
2746
3327
  afterFullData.forEach((row, index) => {
2747
3328
  const rowid = (0, _util.getRowid)($xeTable, row);
@@ -3058,8 +3639,8 @@ const Methods = {
3058
3639
  const colWidth = _xeUtils.default.toInteger(width);
3059
3640
  let rdWidth = colWidth;
3060
3641
  if ((0, _dom.isScale)(width)) {
3061
- const tableBody = $xeTable.$refs.tableBody;
3062
- const bodyElem = tableBody ? tableBody.$el : null;
3642
+ const refTableBody = $xeTable.$refs.refTableBody;
3643
+ const bodyElem = refTableBody ? refTableBody.$el : null;
3063
3644
  const bodyWidth = bodyElem ? bodyElem.clientWidth - 1 : 0;
3064
3645
  rdWidth = Math.floor(colWidth * bodyWidth);
3065
3646
  }
@@ -3332,158 +3913,16 @@ const Methods = {
3332
3913
  * 刷新列配置
3333
3914
  */
3334
3915
  refreshColumn(initSort) {
3916
+ const $xeTable = this;
3335
3917
  if (initSort) {
3336
- this.handleUpdateColumn();
3918
+ handleUpdateColumn($xeTable);
3337
3919
  }
3338
- return this.parseColumns(true).then(() => {
3920
+ return parseColumns($xeTable, true).then(() => {
3339
3921
  return this.refreshScroll();
3340
3922
  }).then(() => {
3341
3923
  return this.recalculate();
3342
3924
  });
3343
3925
  },
3344
- /**
3345
- * 刷新列信息
3346
- * 将固定的列左边、右边分别靠边
3347
- */
3348
- parseColumns(isReset) {
3349
- const $xeTable = this;
3350
- const props = $xeTable;
3351
- const internalData = $xeTable;
3352
- const {
3353
- showOverflow
3354
- } = props;
3355
- const rowOpts = $xeTable.computeRowOpts;
3356
- const leftList = [];
3357
- const centerList = [];
3358
- const rightList = [];
3359
- const {
3360
- collectColumn,
3361
- tableFullColumn,
3362
- isGroup,
3363
- columnStore,
3364
- sXOpts,
3365
- scrollXStore,
3366
- fullColumnIdData
3367
- } = this;
3368
- // 如果是分组表头,如果子列全部被隐藏,则根列也隐藏
3369
- if (isGroup) {
3370
- const leftGroupList = [];
3371
- const centerGroupList = [];
3372
- const rightGroupList = [];
3373
- _xeUtils.default.eachTree(collectColumn, (column, index, items, path, parentColumn) => {
3374
- const isColGroup = (0, _utils.hasChildrenList)(column);
3375
- // 如果是分组,必须按组设置固定列,不允许给子列设置固定
3376
- if (parentColumn && parentColumn.fixed) {
3377
- column.fixed = parentColumn.fixed;
3378
- }
3379
- if (parentColumn && column.fixed !== parentColumn.fixed) {
3380
- (0, _log.errLog)('vxe.error.groupFixed');
3381
- }
3382
- if (isColGroup) {
3383
- column.visible = !!_xeUtils.default.findTree(column.children, subColumn => (0, _utils.hasChildrenList)(subColumn) ? null : subColumn.visible);
3384
- } else if (column.visible) {
3385
- if (column.fixed === 'left') {
3386
- leftList.push(column);
3387
- } else if (column.fixed === 'right') {
3388
- rightList.push(column);
3389
- } else {
3390
- centerList.push(column);
3391
- }
3392
- }
3393
- });
3394
- collectColumn.forEach(column => {
3395
- if (column.visible) {
3396
- if (column.fixed === 'left') {
3397
- leftGroupList.push(column);
3398
- } else if (column.fixed === 'right') {
3399
- rightGroupList.push(column);
3400
- } else {
3401
- centerGroupList.push(column);
3402
- }
3403
- }
3404
- });
3405
- this.tableGroupColumn = leftGroupList.concat(centerGroupList).concat(rightGroupList);
3406
- } else {
3407
- // 重新分配列
3408
- tableFullColumn.forEach(column => {
3409
- if (column.visible) {
3410
- if (column.fixed === 'left') {
3411
- leftList.push(column);
3412
- } else if (column.fixed === 'right') {
3413
- rightList.push(column);
3414
- } else {
3415
- centerList.push(column);
3416
- }
3417
- }
3418
- });
3419
- }
3420
- const visibleColumn = leftList.concat(centerList).concat(rightList);
3421
- // 如果gt为0,则总是启用
3422
- const scrollXLoad = sXOpts.enabled && sXOpts.gt > -1 && (sXOpts.gt === 0 || sXOpts.gt <= tableFullColumn.length);
3423
- this.hasFixedColumn = leftList.length > 0 || rightList.length > 0;
3424
- Object.assign(columnStore, {
3425
- leftList,
3426
- centerList,
3427
- rightList
3428
- });
3429
- if (scrollXLoad) {
3430
- if (showOverflow) {
3431
- if (!rowOpts.height) {
3432
- const errColumn = internalData.tableFullColumn.find(column => column.showOverflow === false);
3433
- if (errColumn) {
3434
- (0, _log.errLog)('vxe.error.errProp', [`column[field="${errColumn.field}"].show-overflow=false`, 'show-overflow=true']);
3435
- }
3436
- }
3437
- }
3438
- if (process.env.NODE_ENV === 'development') {
3439
- // if (this.showHeader && !this.showHeaderOverflow) {
3440
- // warnLog('vxe.error.reqProp', ['show-header-overflow'])
3441
- // }
3442
- // if (this.showFooter && !this.showFooterOverflow) {
3443
- // warnLog('vxe.error.reqProp', ['show-footer-overflow'])
3444
- // }
3445
- if (this.spanMethod) {
3446
- (0, _log.warnLog)('vxe.error.scrollErrProp', ['span-method']);
3447
- }
3448
- if (this.footerSpanMethod) {
3449
- (0, _log.warnLog)('vxe.error.scrollErrProp', ['footer-span-method']);
3450
- }
3451
- }
3452
- if (isReset) {
3453
- const {
3454
- visibleSize
3455
- } = handleVirtualXVisible(this);
3456
- scrollXStore.startIndex = 0;
3457
- scrollXStore.endIndex = visibleSize;
3458
- scrollXStore.visibleSize = visibleSize;
3459
- }
3460
- }
3461
- // 如果列被显示/隐藏,则清除合并状态
3462
- // 如果列被设置为固定,则清除合并状态
3463
- if (visibleColumn.length !== this.visibleColumn.length || !this.visibleColumn.every((column, index) => column === visibleColumn[index])) {
3464
- this.clearMergeCells();
3465
- this.clearMergeFooterItems();
3466
- }
3467
- this.scrollXLoad = scrollXLoad;
3468
- visibleColumn.forEach((column, index) => {
3469
- const colid = column.id;
3470
- const colRest = fullColumnIdData[colid];
3471
- if (colRest) {
3472
- colRest._index = index;
3473
- }
3474
- });
3475
- this.visibleColumn = visibleColumn;
3476
- this.handleTableColumn();
3477
- if (isReset) {
3478
- return this.updateFooter().then(() => {
3479
- return this.recalculate();
3480
- }).then(() => {
3481
- this.updateCellAreas();
3482
- return this.recalculate();
3483
- });
3484
- }
3485
- return this.updateFooter();
3486
- },
3487
3926
  /**
3488
3927
  * 指定列宽的列进行拆分
3489
3928
  */
@@ -3587,38 +4026,43 @@ const Methods = {
3587
4026
  * 刷新滚动操作,手动同步滚动相关位置(对于某些特殊的操作,比如滚动条错位、固定列不同步)
3588
4027
  */
3589
4028
  refreshScroll() {
4029
+ const $xeTable = this;
4030
+ const internalData = $xeTable;
3590
4031
  const {
4032
+ elemStore,
3591
4033
  lastScrollLeft,
3592
4034
  lastScrollTop
3593
- } = this;
3594
- const {
3595
- $refs
3596
- } = this;
3597
- const {
3598
- tableBody,
3599
- leftBody,
3600
- rightBody,
3601
- tableFooter
3602
- } = $refs;
3603
- const tableBodyElem = tableBody ? tableBody.$el : null;
3604
- const leftBodyElem = leftBody ? leftBody.$el : null;
3605
- const rightBodyElem = rightBody ? rightBody.$el : null;
3606
- const tableFooterElem = tableFooter ? tableFooter.$el : null;
4035
+ } = internalData;
4036
+ const headerScrollElem = (0, _util.getRefElem)(elemStore['main-header-scroll']);
4037
+ const bodyScrollElem = (0, _util.getRefElem)(elemStore['main-body-scroll']);
4038
+ const footerScrollElem = (0, _util.getRefElem)(elemStore['main-footer-scroll']);
4039
+ const leftScrollElem = (0, _util.getRefElem)(elemStore['left-body-scroll']);
4040
+ const rightScrollElem = (0, _util.getRefElem)(elemStore['right-body-scroll']);
4041
+ const xHandleEl = $xeTable.$refs.refScrollXHandleElem;
4042
+ const yHandleEl = $xeTable.$refs.refScrollYHandleElem;
3607
4043
  return new Promise(resolve => {
3608
4044
  // 还原滚动条位置
3609
4045
  if (lastScrollLeft || lastScrollTop) {
3610
- return (0, _util.restoreScrollLocation)(this, lastScrollLeft, lastScrollTop).then(() => {
4046
+ return (0, _util.restoreScrollLocation)($xeTable, lastScrollLeft, lastScrollTop).then().then(() => {
3611
4047
  // 存在滚动行为未结束情况
3612
- setTimeout(resolve, 30);
4048
+ setTimeout(resolve, 10);
3613
4049
  });
3614
4050
  }
4051
+ internalData.intoRunScroll = true;
3615
4052
  // 重置
3616
- (0, _dom.setScrollTop)(tableBodyElem, lastScrollTop);
3617
- (0, _dom.setScrollTop)(leftBodyElem, lastScrollTop);
3618
- (0, _dom.setScrollTop)(rightBodyElem, lastScrollTop);
3619
- (0, _dom.setScrollLeft)(tableFooterElem, lastScrollLeft);
4053
+ (0, _dom.setScrollTop)(yHandleEl, lastScrollTop);
4054
+ (0, _dom.setScrollTop)(bodyScrollElem, lastScrollTop);
4055
+ (0, _dom.setScrollTop)(leftScrollElem, lastScrollTop);
4056
+ (0, _dom.setScrollTop)(rightScrollElem, lastScrollTop);
4057
+ (0, _dom.setScrollLeft)(xHandleEl, lastScrollLeft);
4058
+ (0, _dom.setScrollLeft)(bodyScrollElem, lastScrollLeft);
4059
+ (0, _dom.setScrollLeft)(headerScrollElem, lastScrollLeft);
4060
+ (0, _dom.setScrollLeft)(footerScrollElem, lastScrollLeft);
3620
4061
  // 存在滚动行为未结束情况
3621
- setTimeout(resolve, 30);
4062
+ setTimeout(() => {
4063
+ internalData.intoRunScroll = false;
4064
+ resolve();
4065
+ }, 10);
3622
4066
  });
3623
4067
  },
3624
4068
  /**
@@ -3628,367 +4072,66 @@ const Methods = {
3628
4072
  recalculate(reFull) {
3629
4073
  const $xeTable = this;
3630
4074
  const internalData = $xeTable;
3631
- return new Promise(resolve => {
3632
- const {
3633
- rceTimeout,
3634
- rceRunTime
3635
- } = internalData;
3636
- const resizeOpts = $xeTable.computeResizeOpts;
3637
- const refreshDelay = resizeOpts.refreshDelay || 20;
3638
- const el = $xeTable.$refs.refElem;
3639
- if (el && el.clientWidth) {
3640
- autoCellWidth($xeTable);
3641
- }
3642
- if (rceTimeout) {
3643
- clearTimeout(rceTimeout);
3644
- if (rceRunTime && rceRunTime + (refreshDelay - 5) < Date.now()) {
3645
- resolve(handleRecalculateLayout($xeTable, !!reFull));
3646
- } else {
3647
- $xeTable.$nextTick(() => {
3648
- resolve();
3649
- });
3650
- }
3651
- } else {
3652
- resolve(handleRecalculateLayout($xeTable, !!reFull));
3653
- }
3654
- internalData.rceTimeout = setTimeout(() => {
3655
- internalData.rceTimeout = undefined;
3656
- handleRecalculateLayout($xeTable, !!reFull);
3657
- }, refreshDelay);
3658
- });
3659
- },
3660
- updateStyle() {
3661
- const $xeTable = this;
3662
- let {
3663
- $refs,
3664
- isGroup,
3665
- fullColumnIdData,
3666
- tableColumn,
3667
- customHeight,
3668
- customMinHeight,
3669
- customMaxHeight,
3670
- border,
3671
- headerHeight,
3672
- showFooter,
3673
- showOverflow: allColumnOverflow,
3674
- showHeaderOverflow: allColumnHeaderOverflow,
3675
- showFooterOverflow: allColumnFooterOverflow,
3676
- footerHeight,
3677
- tableHeight,
3678
- tableWidth,
3679
- scrollbarHeight,
3680
- scrollbarWidth,
3681
- scrollXLoad,
3682
- scrollYLoad,
3683
- overflowX,
3684
- cellOffsetWidth,
3685
- columnStore,
3686
- elemStore,
3687
- editStore,
3688
- currentRow,
3689
- mouseConfig,
3690
- spanMethod,
3691
- expandColumn,
3692
- footerSpanMethod,
3693
- isAllOverflow,
3694
- visibleColumn
3695
- } = $xeTable;
3696
- const containerList = ['main', 'left', 'right'];
3697
- const emptyPlaceholderElem = $refs.emptyPlaceholder;
3698
- const bodyWrapperElem = elemStore['main-body-wrapper'];
3699
- if (emptyPlaceholderElem) {
3700
- emptyPlaceholderElem.style.top = `${headerHeight}px`;
3701
- emptyPlaceholderElem.style.height = bodyWrapperElem ? `${bodyWrapperElem.offsetHeight - scrollbarHeight}px` : '';
3702
- }
3703
- if (customHeight > 0) {
3704
- if (showFooter) {
3705
- customHeight += scrollbarHeight;
3706
- }
3707
- }
3708
- const scrollXVirtualEl = $xeTable.$refs.refScrollXVirtualElem;
3709
- if (scrollXVirtualEl) {
3710
- scrollXVirtualEl.style.height = `${scrollbarHeight}px`;
3711
- }
3712
- const scrollYVirtualEl = $xeTable.$refs.refScrollYVirtualElem;
3713
- if (scrollYVirtualEl) {
3714
- let bodyHeight = 0;
3715
- let bodyMaxHeight = 0;
3716
- const bodyMinHeight = customMinHeight - headerHeight - footerHeight;
3717
- if (customMaxHeight) {
3718
- bodyMaxHeight = customMaxHeight - headerHeight - footerHeight;
3719
- bodyMaxHeight = Math.max(bodyMinHeight, bodyMaxHeight);
3720
- }
3721
- if (customHeight) {
3722
- bodyHeight = customHeight - headerHeight - footerHeight;
3723
- if (bodyMaxHeight) {
3724
- bodyHeight = Math.min(bodyMaxHeight, bodyHeight);
3725
- }
3726
- bodyHeight = Math.max(bodyMinHeight, bodyHeight);
3727
- }
3728
- scrollYVirtualEl.style.top = `${headerHeight}px`;
3729
- scrollYVirtualEl.style.width = `${scrollbarWidth}px`;
3730
- scrollYVirtualEl.style.height = `${bodyHeight + (overflowX ? -Math.max(1, scrollbarHeight) : 0)}px`;
3731
- }
3732
- containerList.forEach((name, index) => {
3733
- const fixedType = index > 0 ? name : '';
3734
- const layoutList = ['header', 'body', 'footer'];
3735
- const fixedColumn = columnStore[`${fixedType}List`];
3736
- const fixedWrapperElem = $refs[`${fixedType}Container`];
3737
- layoutList.forEach(layout => {
3738
- const wrapperElem = elemStore[`${name}-${layout}-wrapper`];
3739
- const tableElem = elemStore[`${name}-${layout}-table`];
3740
- if (layout === 'header') {
3741
- // 表头体样式处理
3742
- // 横向滚动渲染
3743
- let tWidth = tableWidth;
3744
- let renderColumnList = tableColumn;
3745
- if (isGroup) {
3746
- renderColumnList = visibleColumn;
3747
- } else {
3748
- if (fixedType) {
3749
- // 如果是使用优化模式
3750
- if (scrollXLoad || scrollYLoad || allColumnHeaderOverflow) {
3751
- // 如果不支持优化模式
3752
- if (spanMethod || footerSpanMethod) {
3753
- renderColumnList = visibleColumn;
3754
- } else {
3755
- renderColumnList = fixedColumn || [];
3756
- }
3757
- } else {
3758
- renderColumnList = visibleColumn;
3759
- }
3760
- }
3761
- }
3762
- tWidth = renderColumnList.reduce((previous, column) => previous + column.renderWidth, 0);
3763
- if (tableElem) {
3764
- tableElem.style.width = tWidth ? `${tWidth + scrollbarWidth}px` : '';
3765
- // 修复 IE 中高度无法自适应问题
3766
- if (_dom.browse.msie) {
3767
- _xeUtils.default.arrayEach(tableElem.querySelectorAll('.vxe-resizable'), resizeElem => {
3768
- resizeElem.style.height = `${resizeElem.parentNode.offsetHeight}px`;
3769
- });
3770
- }
3771
- }
3772
- const repairElem = elemStore[`${name}-${layout}-repair`];
3773
- if (repairElem) {
3774
- repairElem.style.width = `${tableWidth}px`;
3775
- }
3776
- const listElem = elemStore[`${name}-${layout}-list`];
3777
- if (isGroup && listElem) {
3778
- _xeUtils.default.arrayEach(listElem.querySelectorAll('.col--group'), thElem => {
3779
- const colNode = this.getColumnNode(thElem);
3780
- if (colNode) {
3781
- const column = colNode.item;
3782
- const {
3783
- showHeaderOverflow
3784
- } = column;
3785
- const cellOverflow = _xeUtils.default.isBoolean(showHeaderOverflow) ? showHeaderOverflow : allColumnHeaderOverflow;
3786
- const showEllipsis = cellOverflow === 'ellipsis';
3787
- const showTitle = cellOverflow === 'title';
3788
- const showTooltip = cellOverflow === true || cellOverflow === 'tooltip';
3789
- const hasEllipsis = showTitle || showTooltip || showEllipsis;
3790
- let childWidth = 0;
3791
- let countChild = 0;
3792
- if (hasEllipsis) {
3793
- _xeUtils.default.eachTree(column.children, item => {
3794
- if (!item.children || !column.children.length) {
3795
- countChild++;
3796
- }
3797
- childWidth += item.renderWidth;
3798
- });
3799
- }
3800
- thElem.style.width = hasEllipsis ? `${childWidth - countChild - (border ? 2 : 0)}px` : '';
3801
- }
3802
- });
3803
- }
3804
- } else if (layout === 'body') {
3805
- const emptyBlockElem = elemStore[`${name}-${layout}-emptyBlock`];
3806
- if ((0, _dom.isNodeElement)(wrapperElem)) {
3807
- let bodyMaxHeight = 0;
3808
- const bodyMinHeight = customMinHeight - headerHeight - footerHeight;
3809
- if (customMaxHeight) {
3810
- bodyMaxHeight = customMaxHeight - headerHeight - footerHeight;
3811
- // 如果是固定列
3812
- if (fixedType) {
3813
- bodyMaxHeight -= showFooter ? 0 : scrollbarHeight;
3814
- }
3815
- bodyMaxHeight = Math.max(bodyMinHeight, bodyMaxHeight);
3816
- wrapperElem.style.maxHeight = `${bodyMaxHeight}px`;
3817
- }
3818
- if (customHeight) {
3819
- let bodyHeight = customHeight - headerHeight - footerHeight;
3820
- // 如果是固定列
3821
- if (fixedType) {
3822
- bodyHeight -= showFooter ? 0 : scrollbarHeight;
3823
- }
3824
- if (bodyMaxHeight) {
3825
- bodyHeight = Math.min(bodyMaxHeight, bodyHeight);
3826
- }
3827
- wrapperElem.style.height = `${Math.max(bodyMinHeight, bodyHeight)}px`;
3828
- } else {
3829
- wrapperElem.style.height = '';
3830
- }
3831
- wrapperElem.style.minHeight = `${bodyMinHeight}px`;
3832
- }
3833
- // 如果是固定列
3834
- if (fixedWrapperElem) {
3835
- const isRightFixed = fixedType === 'right';
3836
- const fixedColumn = columnStore[`${fixedType}List`];
3837
- if ((0, _dom.isNodeElement)(wrapperElem)) {
3838
- wrapperElem.style.top = `${headerHeight}px`;
3839
- }
3840
- fixedWrapperElem.style.height = `${(customHeight > 0 ? customHeight - headerHeight - footerHeight : tableHeight) + headerHeight + footerHeight - scrollbarHeight * (showFooter ? 2 : 1)}px`;
3841
- fixedWrapperElem.style.width = `${fixedColumn.reduce((previous, column) => previous + column.renderWidth, isRightFixed ? scrollbarWidth : 0)}px`;
3842
- }
3843
- let tWidth = tableWidth;
3844
- let renderColumnList = tableColumn;
3845
- if (fixedType) {
3846
- // 如果是使用优化模式
3847
- if (scrollXLoad || scrollYLoad || allColumnOverflow && isAllOverflow) {
3848
- // 如果不支持优化模式
3849
- if (expandColumn || spanMethod || footerSpanMethod) {
3850
- renderColumnList = visibleColumn;
3851
- } else {
3852
- renderColumnList = fixedColumn || [];
3853
- }
3854
- } else {
3855
- renderColumnList = visibleColumn;
3856
- }
3857
- }
3858
- tWidth = renderColumnList.reduce((previous, column) => previous + column.renderWidth, 0);
3859
- if (tableElem) {
3860
- tableElem.style.width = tWidth ? `${tWidth}px` : '';
3861
- // 兼容性处理
3862
- tableElem.style.paddingRight = scrollbarWidth && fixedType && (_dom.browse['-moz'] || _dom.browse.safari) ? `${scrollbarWidth}px` : '';
3863
- }
3864
- if (emptyBlockElem) {
3865
- emptyBlockElem.style.width = tWidth ? `${tWidth}px` : '';
3866
- }
3867
- } else if (layout === 'footer') {
3868
- let tWidth = tableWidth;
3869
- let renderColumnList = tableColumn;
3870
- if (fixedType) {
3871
- // 如果是使用优化模式
3872
- if (scrollXLoad || scrollYLoad || allColumnFooterOverflow) {
3873
- // 如果不支持优化模式
3874
- if (spanMethod || footerSpanMethod) {
3875
- renderColumnList = visibleColumn;
3876
- } else {
3877
- renderColumnList = fixedColumn || [];
3878
- }
3879
- } else {
3880
- renderColumnList = visibleColumn;
3881
- }
3882
- }
3883
- tWidth = renderColumnList.reduce((previous, column) => previous + column.renderWidth, 0);
3884
- if ((0, _dom.isNodeElement)(wrapperElem)) {
3885
- // 如果是固定列
3886
- if (fixedWrapperElem) {
3887
- wrapperElem.style.top = `${customHeight > 0 ? customHeight - footerHeight : tableHeight + headerHeight}px`;
3888
- }
3889
- wrapperElem.style.marginTop = `${-scrollbarHeight}px`;
3890
- }
3891
- if (tableElem) {
3892
- tableElem.style.width = tWidth ? `${tWidth + scrollbarWidth}px` : '';
3893
- }
3894
- }
3895
- const colgroupElem = elemStore[`${name}-${layout}-colgroup`];
3896
- if (colgroupElem) {
3897
- _xeUtils.default.arrayEach(colgroupElem.children, colElem => {
3898
- const colid = colElem.getAttribute('name');
3899
- if (colid === 'col_gutter') {
3900
- colElem.style.width = `${scrollbarWidth}px`;
3901
- }
3902
- if (fullColumnIdData[colid]) {
3903
- const colRest = fullColumnIdData[colid];
3904
- const column = colRest.column;
3905
- const {
3906
- showHeaderOverflow,
3907
- showFooterOverflow,
3908
- showOverflow
3909
- } = column;
3910
- let cellOverflow;
3911
- colElem.style.width = `${column.renderWidth}px`;
3912
- if (layout === 'header') {
3913
- cellOverflow = _xeUtils.default.isUndefined(showHeaderOverflow) || _xeUtils.default.isNull(showHeaderOverflow) ? allColumnHeaderOverflow : showHeaderOverflow;
3914
- } else if (layout === 'footer') {
3915
- cellOverflow = _xeUtils.default.isUndefined(showFooterOverflow) || _xeUtils.default.isNull(showFooterOverflow) ? allColumnFooterOverflow : showFooterOverflow;
3916
- } else {
3917
- cellOverflow = _xeUtils.default.isUndefined(showOverflow) || _xeUtils.default.isNull(showOverflow) ? allColumnOverflow : showOverflow;
3918
- }
3919
- const showEllipsis = cellOverflow === 'ellipsis';
3920
- const showTitle = cellOverflow === 'title';
3921
- const showTooltip = cellOverflow === true || cellOverflow === 'tooltip';
3922
- let hasEllipsis = showTitle || showTooltip || showEllipsis;
3923
- const listElem = elemStore[`${name}-${layout}-list`];
3924
- // 滚动的渲染不支持动态行高
3925
- if (layout === 'header' || layout === 'footer') {
3926
- if (scrollXLoad && !hasEllipsis) {
3927
- hasEllipsis = true;
3928
- }
3929
- } else {
3930
- if ((scrollXLoad || scrollYLoad) && !hasEllipsis) {
3931
- hasEllipsis = true;
3932
- }
3933
- }
3934
- if (listElem) {
3935
- _xeUtils.default.arrayEach(listElem.querySelectorAll(`.${column.id}`), elem => {
3936
- const colspan = parseInt(elem.getAttribute('colspan') || 1);
3937
- const cellElem = elem.querySelector('.vxe-cell');
3938
- let colWidth = column.renderWidth;
3939
- if (cellElem) {
3940
- if (colspan > 1) {
3941
- const columnIndex = this.getColumnIndex(column);
3942
- for (let index = 1; index < colspan; index++) {
3943
- const nextColumn = this.getColumns(columnIndex + index);
3944
- if (nextColumn) {
3945
- colWidth += nextColumn.renderWidth;
3946
- }
3947
- }
3948
- }
3949
- cellElem.style.width = hasEllipsis ? `${colWidth - cellOffsetWidth * colspan}px` : '';
3950
- }
3951
- });
3952
- }
3953
- }
4075
+ return new Promise(resolve => {
4076
+ const {
4077
+ rceTimeout,
4078
+ rceRunTime
4079
+ } = internalData;
4080
+ const resizeOpts = $xeTable.computeResizeOpts;
4081
+ const refreshDelay = resizeOpts.refreshDelay || 20;
4082
+ const el = $xeTable.$refs.refElem;
4083
+ if (el && el.clientWidth) {
4084
+ autoCellWidth($xeTable);
4085
+ }
4086
+ if (rceTimeout) {
4087
+ clearTimeout(rceTimeout);
4088
+ if (rceRunTime && rceRunTime + (refreshDelay - 5) < Date.now()) {
4089
+ resolve(handleRecalculateLayout($xeTable, !!reFull));
4090
+ } else {
4091
+ $xeTable.$nextTick(() => {
4092
+ resolve();
3954
4093
  });
3955
4094
  }
3956
- });
4095
+ } else {
4096
+ resolve(handleRecalculateLayout($xeTable, !!reFull));
4097
+ }
4098
+ internalData.rceTimeout = setTimeout(() => {
4099
+ internalData.rceTimeout = undefined;
4100
+ handleRecalculateLayout($xeTable, !!reFull);
4101
+ }, refreshDelay);
3957
4102
  });
3958
- if (currentRow) {
3959
- this.setCurrentRow(currentRow);
3960
- }
3961
- if (mouseConfig && mouseConfig.selected && editStore.selected.row && editStore.selected.column) {
3962
- this.addColSdCls();
3963
- }
3964
- return this.$nextTick();
4103
+ },
4104
+ updateStyle() {
4105
+ const $xeTable = this;
4106
+ return updateStyle($xeTable);
3965
4107
  },
3966
4108
  /**
3967
4109
  * 处理固定列的显示状态
3968
4110
  */
3969
4111
  checkScrolling() {
3970
4112
  const $xeTable = this;
4113
+ const internalData = $xeTable;
3971
4114
  const {
3972
- tableBody,
3973
- leftContainer,
3974
- rightContainer
3975
- } = $xeTable.$refs;
3976
- const bodyElem = tableBody ? tableBody.$el : null;
4115
+ elemStore
4116
+ } = internalData;
4117
+ const bodyScrollElem = (0, _util.getRefElem)(elemStore['main-body-scroll']);
4118
+ const leftContainerElem = $xeTable.$refs.refLeftContainer;
4119
+ const rightContainerElem = $xeTable.$refs.refRightContainer;
3977
4120
  const xHandleEl = $xeTable.$refs.refScrollXHandleElem;
3978
- const bodtTargetEl = xHandleEl || bodyElem;
4121
+ const bodtTargetEl = xHandleEl || bodyScrollElem;
3979
4122
  if (bodtTargetEl) {
3980
- if (leftContainer) {
4123
+ if (leftContainerElem) {
3981
4124
  if (bodtTargetEl.scrollLeft > 0) {
3982
- (0, _dom.addClass)(leftContainer, 'scrolling--middle');
4125
+ (0, _dom.addClass)(leftContainerElem, 'scrolling--middle');
3983
4126
  } else {
3984
- (0, _dom.removeClass)(leftContainer, 'scrolling--middle');
4127
+ (0, _dom.removeClass)(leftContainerElem, 'scrolling--middle');
3985
4128
  }
3986
4129
  }
3987
- if (rightContainer) {
4130
+ if (rightContainerElem) {
3988
4131
  if (bodtTargetEl.clientWidth < bodtTargetEl.scrollWidth - Math.ceil(bodtTargetEl.scrollLeft)) {
3989
- (0, _dom.addClass)(rightContainer, 'scrolling--middle');
4132
+ (0, _dom.addClass)(rightContainerElem, 'scrolling--middle');
3990
4133
  } else {
3991
- (0, _dom.removeClass)(rightContainer, 'scrolling--middle');
4134
+ (0, _dom.removeClass)(rightContainerElem, 'scrolling--middle');
3992
4135
  }
3993
4136
  }
3994
4137
  }
@@ -4044,10 +4187,10 @@ const Methods = {
4044
4187
  actived
4045
4188
  } = editStore;
4046
4189
  const {
4047
- ctxWrapper,
4190
+ refTableMenu,
4048
4191
  filterWrapper,
4049
4192
  customWrapper,
4050
- validTip
4193
+ refValidTooltip
4051
4194
  } = $refs;
4052
4195
  // 筛选
4053
4196
  if (filterWrapper) {
@@ -4079,7 +4222,7 @@ const Methods = {
4079
4222
  // 如果是激活状态,点击了单元格之外
4080
4223
  const cell = actived.args.cell;
4081
4224
  if (!cell || !(0, _dom.getEventTargetNode)(evnt, cell).flag) {
4082
- if (validTip && (0, _dom.getEventTargetNode)(evnt, validTip.$el).flag) {
4225
+ if (refValidTooltip && (0, _dom.getEventTargetNode)(evnt, refValidTooltip.$el).flag) {
4083
4226
  // 如果是激活状态,且点击了校验提示框
4084
4227
  } else if (!this.lastCallTime || this.lastCallTime + 50 < Date.now()) {
4085
4228
  if (!(0, _dom.getEventTargetNode)(evnt, document.body, 'vxe-table--ignore-clear').flag) {
@@ -4127,7 +4270,7 @@ const Methods = {
4127
4270
  }
4128
4271
  }
4129
4272
  } else if (mouseConfig) {
4130
- 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)) {
4273
+ 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)) {
4131
4274
  if (this.clearSelected) {
4132
4275
  this.clearSelected();
4133
4276
  }
@@ -4148,7 +4291,7 @@ const Methods = {
4148
4291
  }
4149
4292
  }
4150
4293
  // 如果配置了快捷菜单且,点击了其他地方则关闭
4151
- if (ctxMenuStore.visible && ctxWrapper && !(0, _dom.getEventTargetNode)(evnt, ctxWrapper.$el).flag) {
4294
+ if (ctxMenuStore.visible && refTableMenu && !(0, _dom.getEventTargetNode)(evnt, refTableMenu.$el).flag) {
4152
4295
  this.closeMenu();
4153
4296
  }
4154
4297
  const isActivated = (0, _dom.getEventTargetNode)(evnt, ($xegrid || this).$el).flag;
@@ -4314,8 +4457,8 @@ const Methods = {
4314
4457
  } else if (isContextMenu) {
4315
4458
  // 如果按下上下文键
4316
4459
  this._keyCtx = selected.row && selected.column && bodyCtxMenu.length;
4317
- clearTimeout(this.keyCtxTimeout);
4318
- this.keyCtxTimeout = setTimeout(() => {
4460
+ clearTimeout(internalData.keyCtxTimeout);
4461
+ internalData.keyCtxTimeout = setTimeout(() => {
4319
4462
  this._keyCtx = false;
4320
4463
  }, 1000);
4321
4464
  } else if (isEnter && !hasAltKey && keyboardConfig && keyboardOpts.isEnter && (selected.row || actived.row || treeConfig && (rowOpts.isCurrent || highlightCurrentRow) && currentRow)) {
@@ -4731,6 +4874,10 @@ const Methods = {
4731
4874
  * @param {Row} row 行对象
4732
4875
  */
4733
4876
  handleTooltip(evnt, cell, overflowElem, tipElem, params) {
4877
+ const $xeTable = this;
4878
+ if (!overflowElem) {
4879
+ return $xeTable.$nextTick();
4880
+ }
4734
4881
  params.cell = cell;
4735
4882
  const {
4736
4883
  $refs,
@@ -4770,7 +4917,7 @@ const Methods = {
4770
4917
  const {
4771
4918
  $refs
4772
4919
  } = this;
4773
- const commTip = $refs.commTip;
4920
+ const commTip = $refs.refCommTooltip;
4774
4921
  if (commTip) {
4775
4922
  return commTip.open(target, content);
4776
4923
  }
@@ -4785,7 +4932,7 @@ const Methods = {
4785
4932
  tooltipStore
4786
4933
  } = this;
4787
4934
  const tooltip = $refs.tooltip;
4788
- const commTip = $refs.commTip;
4935
+ const commTip = $refs.refCommTooltip;
4789
4936
  if (tooltipStore.visible) {
4790
4937
  Object.assign(tooltipStore, {
4791
4938
  row: null,
@@ -6217,6 +6364,7 @@ const Methods = {
6217
6364
  this.emitEvent('cell-dblclick', params, evnt);
6218
6365
  },
6219
6366
  handleDefaultSort() {
6367
+ const $xeTable = this;
6220
6368
  const {
6221
6369
  sortConfig,
6222
6370
  sortOpts
@@ -6243,7 +6391,7 @@ const Methods = {
6243
6391
  }
6244
6392
  });
6245
6393
  if (!sortOpts.remote) {
6246
- this.handleTableData(true).then(this.updateStyle);
6394
+ this.handleTableData(true).then(() => updateStyle($xeTable));
6247
6395
  }
6248
6396
  }
6249
6397
  }
@@ -6756,8 +6904,8 @@ const Methods = {
6756
6904
  },
6757
6905
  handleColDragSwapColumn() {
6758
6906
  const $xeTable = this;
6759
- $xeTable.handleUpdateColumn();
6760
- $xeTable.parseColumns(false).then(() => {
6907
+ handleUpdateColumn($xeTable);
6908
+ parseColumns($xeTable, false).then(() => {
6761
6909
  $xeTable.updateCellAreas();
6762
6910
  $xeTable.saveCustomStore('update:sort');
6763
6911
  });
@@ -7007,15 +7155,15 @@ const Methods = {
7007
7155
  return;
7008
7156
  }
7009
7157
  const xHandleEl = $xeTable.$refs.refScrollXHandleElem;
7010
- const tableBody = $xeTable.$refs.tableBody;
7011
- const tableBodyElem = tableBody ? tableBody.$el : null;
7158
+ const refTableBody = $xeTable.$refs.refTableBody;
7159
+ const tableBodyElem = refTableBody ? refTableBody.$el : null;
7012
7160
  const scrollTargetEl = xHandleEl || tableBodyElem;
7013
7161
  if (scrollTargetEl) {
7014
7162
  const wrapperRect = el.getBoundingClientRect();
7015
7163
  const tableWidth = el.clientWidth;
7016
- const leftContainerElem = $xeTable.$refs.leftContainer;
7164
+ const leftContainerElem = $xeTable.$refs.refLeftContainer;
7017
7165
  const leftContainerWidth = leftContainerElem ? leftContainerElem.clientWidth : 0;
7018
- const rightContainerElem = $xeTable.$refs.rightContainer;
7166
+ const rightContainerElem = $xeTable.$refs.refRightContainer;
7019
7167
  const rightContainerWidth = rightContainerElem ? rightContainerElem.clientWidth : 0;
7020
7168
  const srartX = wrapperRect.x + leftContainerWidth;
7021
7169
  const endX = wrapperRect.x + tableWidth - rightContainerWidth;
@@ -7147,6 +7295,7 @@ const Methods = {
7147
7295
  return this.$nextTick();
7148
7296
  },
7149
7297
  sort(sortConfs, sortOrder) {
7298
+ const $xeTable = this;
7150
7299
  const {
7151
7300
  sortOpts
7152
7301
  } = this;
@@ -7199,7 +7348,7 @@ const Methods = {
7199
7348
  }
7200
7349
  return this.$nextTick().then(() => {
7201
7350
  this.updateCellAreas();
7202
- return this.updateStyle();
7351
+ return updateStyle($xeTable);
7203
7352
  });
7204
7353
  }
7205
7354
  return this.$nextTick();
@@ -7251,7 +7400,7 @@ const Methods = {
7251
7400
  }
7252
7401
  return $xeTable.$nextTick().then(() => {
7253
7402
  $xeTable.updateCellAreas();
7254
- return $xeTable.updateStyle();
7403
+ return updateStyle($xeTable);
7255
7404
  });
7256
7405
  }
7257
7406
  return $xeTable.$nextTick();
@@ -7262,6 +7411,7 @@ const Methods = {
7262
7411
  * @param {String} column 列或字段名
7263
7412
  */
7264
7413
  clearSort(fieldOrColumn) {
7414
+ const $xeTable = this;
7265
7415
  const {
7266
7416
  sortOpts
7267
7417
  } = this;
@@ -7276,7 +7426,7 @@ const Methods = {
7276
7426
  if (!sortOpts.remote) {
7277
7427
  this.handleTableData(true);
7278
7428
  }
7279
- return this.$nextTick().then(this.updateStyle);
7429
+ return this.$nextTick().then(() => updateStyle($xeTable));
7280
7430
  },
7281
7431
  // 在 v3 中废弃
7282
7432
  getSortColumn() {
@@ -7925,7 +8075,7 @@ const Methods = {
7925
8075
  return this.$nextTick().then(() => {
7926
8076
  if (transform) {
7927
8077
  this.handleTableData();
7928
- this.updateTreeDataIndex();
8078
+ this.updateAfterDataIndex();
7929
8079
  return this.$nextTick();
7930
8080
  }
7931
8081
  });
@@ -8067,7 +8217,7 @@ const Methods = {
8067
8217
  return this.handleBaseTreeExpand(rows, expanded).then(() => {
8068
8218
  handleVirtualTreeToList($xeTable);
8069
8219
  this.handleTableData();
8070
- this.updateTreeDataIndex();
8220
+ this.updateAfterDataIndex();
8071
8221
  }).then(() => {
8072
8222
  return this.recalculate();
8073
8223
  }).then(() => {
@@ -8174,7 +8324,7 @@ const Methods = {
8174
8324
  scrollXLoad,
8175
8325
  scrollYLoad
8176
8326
  } = this;
8177
- const bodyElem = $refs.tableBody.$el;
8327
+ const bodyElem = $refs.refTableBody.$el;
8178
8328
  return {
8179
8329
  virtualX: scrollXLoad,
8180
8330
  virtualY: scrollYLoad,
@@ -8194,15 +8344,18 @@ const Methods = {
8194
8344
  lastScrollLeft,
8195
8345
  lastScrollTop
8196
8346
  } = internalData;
8197
- const tableBody = $xeTable.$refs.tableBody;
8198
- const bodyElem = tableBody ? tableBody.$el : null;
8347
+ const xHandleEl = $xeTable.$refs.refScrollXHandleElem;
8348
+ const yHandleEl = $xeTable.$refs.refScrollYHandleElem;
8349
+ if (!xHandleEl || !yHandleEl) {
8350
+ return;
8351
+ }
8199
8352
  const rowOpts = $xeTable.computeRowOpts;
8200
- const validTip = $xeTable.$refs.validTip;
8201
- const tooltip = $xeTable.$refs.tooltip;
8202
- const bodyHeight = bodyElem ? bodyElem.clientHeight : 0;
8203
- const bodyWidth = bodyElem ? bodyElem.clientWidth : 0;
8204
- const scrollHeight = bodyElem ? bodyElem.scrollHeight : 0;
8205
- const scrollWidth = bodyElem ? bodyElem.scrollWidth : 0;
8353
+ const validTip = $xeTable.$refs.refValidTooltip;
8354
+ const tooltip = $xeTable.$refs.refTooltip;
8355
+ const bodyHeight = yHandleEl.clientHeight;
8356
+ const bodyWidth = xHandleEl.clientWidth;
8357
+ const scrollHeight = yHandleEl.scrollHeight;
8358
+ const scrollWidth = xHandleEl.scrollWidth;
8206
8359
  let isTop = false;
8207
8360
  let isBottom = false;
8208
8361
  let isLeft = false;
@@ -8273,10 +8426,10 @@ const Methods = {
8273
8426
  if (rowOpts.isHover || highlightHoverRow) {
8274
8427
  $xeTable.clearHoverRow();
8275
8428
  }
8276
- if (validTip && validTip.visible) {
8429
+ if (validTip && validTip.reactData.visible) {
8277
8430
  validTip.close();
8278
8431
  }
8279
- if (tooltip && tooltip.visible) {
8432
+ if (tooltip && tooltip.reactData.visible) {
8280
8433
  tooltip.close();
8281
8434
  }
8282
8435
  if (isBottomBoundary || isTopBoundary || isRightBoundary || isLeftBoundary) {
@@ -8295,7 +8448,7 @@ const Methods = {
8295
8448
  const {
8296
8449
  visibleSize
8297
8450
  } = scrollXStore;
8298
- const fpsTime = Math.min(80, Math.floor(visibleSize * 3));
8451
+ const fpsTime = Math.max(5, Math.min(80, Math.floor(visibleSize * 3)));
8299
8452
  if (lxTimeout) {
8300
8453
  clearTimeout(lxTimeout);
8301
8454
  }
@@ -8311,7 +8464,11 @@ const Methods = {
8311
8464
  },
8312
8465
  lazyScrollYData() {
8313
8466
  const $xeTable = this;
8467
+ const props = $xeTable;
8314
8468
  const internalData = $xeTable;
8469
+ const {
8470
+ showOverflow
8471
+ } = props;
8315
8472
  const {
8316
8473
  lyTimeout,
8317
8474
  lyRunTime,
@@ -8320,7 +8477,7 @@ const Methods = {
8320
8477
  const {
8321
8478
  visibleSize
8322
8479
  } = scrollYStore;
8323
- const fpsTime = Math.min(80, Math.floor(visibleSize));
8480
+ const fpsTime = showOverflow ? 5 : Math.max(5, Math.min(80, Math.floor(visibleSize / 2)));
8324
8481
  if (lyTimeout) {
8325
8482
  clearTimeout(lyTimeout);
8326
8483
  }
@@ -8358,35 +8515,285 @@ const Methods = {
8358
8515
  $xeTable.lazyScrollYData();
8359
8516
  }
8360
8517
  },
8361
- scrollXEvent(evnt) {
8518
+ triggerBodyScrollEvent(evnt, fixedType) {
8362
8519
  const $xeTable = this;
8363
8520
  const internalData = $xeTable;
8364
8521
  const {
8365
- intoRunScroll,
8366
- inFooterScroll,
8522
+ elemStore,
8523
+ lastScrollTop,
8524
+ lastScrollLeft,
8525
+ inWheelScroll,
8526
+ inVirtualScroll,
8527
+ inHeaderScroll,
8367
8528
  inBodyScroll,
8368
- lastScrollTop
8529
+ scrollRenderType,
8530
+ inFooterScroll
8369
8531
  } = internalData;
8370
- if (!intoRunScroll) {
8371
- if (inFooterScroll) {
8532
+ const xHandleEl = $xeTable.$refs.refScrollXHandleElem;
8533
+ const yHandleEl = $xeTable.$refs.refScrollYHandleElem;
8534
+ const leftScrollElem = (0, _util.getRefElem)(elemStore['left-body-scroll']);
8535
+ const bodyScrollElem = (0, _util.getRefElem)(elemStore['main-body-scroll']);
8536
+ const rightScrollElem = (0, _util.getRefElem)(elemStore['right-body-scroll']);
8537
+ const headerScrollElem = (0, _util.getRefElem)(elemStore['main-header-scroll']);
8538
+ const footerScrollElem = (0, _util.getRefElem)(elemStore['main-footer-scroll']);
8539
+ if (inWheelScroll || inVirtualScroll || inHeaderScroll || inFooterScroll) {
8540
+ return;
8541
+ }
8542
+ if (!bodyScrollElem) {
8543
+ return;
8544
+ }
8545
+ if (!xHandleEl) {
8546
+ return;
8547
+ }
8548
+ if (!yHandleEl) {
8549
+ return;
8550
+ }
8551
+ if (inBodyScroll) {
8552
+ if (scrollRenderType !== fixedType) {
8372
8553
  return;
8373
8554
  }
8374
- if (inBodyScroll) {
8375
- return;
8555
+ }
8556
+ let scrollTop = yHandleEl.scrollTop;
8557
+ let scrollLeft = xHandleEl.scrollLeft;
8558
+ if (leftScrollElem && fixedType === 'left') {
8559
+ scrollTop = leftScrollElem.scrollTop;
8560
+ } else if (rightScrollElem && fixedType === 'right') {
8561
+ scrollTop = rightScrollElem.scrollTop;
8562
+ } else {
8563
+ scrollTop = bodyScrollElem.scrollTop;
8564
+ scrollLeft = bodyScrollElem.scrollLeft;
8565
+ }
8566
+ const isRollX = scrollLeft !== lastScrollLeft;
8567
+ const isRollY = scrollTop !== lastScrollTop;
8568
+ internalData.inBodyScroll = true;
8569
+ internalData.scrollRenderType = fixedType;
8570
+ if (isRollY) {
8571
+ if (fixedType === 'left') {
8572
+ (0, _dom.setScrollTop)(bodyScrollElem, scrollTop);
8573
+ (0, _dom.setScrollTop)(rightScrollElem, scrollTop);
8574
+ } else if (fixedType === 'right') {
8575
+ (0, _dom.setScrollTop)(bodyScrollElem, scrollTop);
8576
+ (0, _dom.setScrollTop)(leftScrollElem, scrollTop);
8577
+ } else {
8578
+ (0, _dom.setScrollTop)(leftScrollElem, scrollTop);
8579
+ (0, _dom.setScrollTop)(rightScrollElem, scrollTop);
8376
8580
  }
8581
+ (0, _dom.setScrollTop)(yHandleEl, scrollTop);
8582
+ $xeTable.triggerScrollYEvent(evnt);
8583
+ }
8584
+ if (isRollX) {
8585
+ (0, _dom.setScrollLeft)(xHandleEl, scrollLeft);
8586
+ (0, _dom.setScrollLeft)(headerScrollElem, scrollLeft);
8587
+ (0, _dom.setScrollLeft)(footerScrollElem, scrollLeft);
8588
+ $xeTable.triggerScrollXEvent(evnt);
8589
+ }
8590
+ $xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
8591
+ type: 'body',
8592
+ fixed: fixedType
8593
+ });
8594
+ },
8595
+ triggerHeaderScrollEvent(evnt, fixedType) {
8596
+ const $xeTable = this;
8597
+ const internalData = $xeTable;
8598
+ const {
8599
+ elemStore,
8600
+ inWheelScroll,
8601
+ inVirtualScroll,
8602
+ inBodyScroll,
8603
+ inFooterScroll
8604
+ } = internalData;
8605
+ const xHandleEl = $xeTable.$refs.refScrollXHandleElem;
8606
+ const yHandleEl = $xeTable.$refs.refScrollYHandleElem;
8607
+ const bodyScrollElem = (0, _util.getRefElem)(elemStore['main-body-scroll']);
8608
+ const headerScrollElem = (0, _util.getRefElem)(elemStore['main-header-scroll']);
8609
+ const footerScrollElem = (0, _util.getRefElem)(elemStore['main-footer-scroll']);
8610
+ if (inWheelScroll) {
8611
+ return;
8612
+ }
8613
+ if (inVirtualScroll) {
8614
+ return;
8615
+ }
8616
+ if (inBodyScroll) {
8617
+ return;
8618
+ }
8619
+ if (inFooterScroll) {
8620
+ return;
8621
+ }
8622
+ if (!headerScrollElem) {
8623
+ return;
8624
+ }
8625
+ if (!xHandleEl) {
8626
+ return;
8627
+ }
8628
+ if (!yHandleEl) {
8629
+ return;
8630
+ }
8631
+ const scrollTop = yHandleEl.scrollTop;
8632
+ const scrollLeft = headerScrollElem.scrollLeft;
8633
+ const isRollX = true;
8634
+ const isRollY = false;
8635
+ internalData.inHeaderScroll = true;
8636
+ (0, _dom.setScrollLeft)(xHandleEl, scrollLeft);
8637
+ (0, _dom.setScrollLeft)(footerScrollElem, scrollLeft);
8638
+ (0, _dom.setScrollLeft)(bodyScrollElem, scrollLeft);
8639
+ $xeTable.triggerScrollXEvent(evnt);
8640
+ $xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
8641
+ type: 'header',
8642
+ fixed: fixedType
8643
+ });
8644
+ },
8645
+ triggerFooterScrollEvent(evnt, fixedType) {
8646
+ const $xeTable = this;
8647
+ const internalData = $xeTable;
8648
+ const {
8649
+ elemStore,
8650
+ inWheelScroll,
8651
+ inVirtualScroll,
8652
+ inHeaderScroll,
8653
+ inBodyScroll
8654
+ } = internalData;
8655
+ const xHandleEl = $xeTable.$refs.refScrollXHandleElem;
8656
+ const yHandleEl = $xeTable.$refs.refScrollYHandleElem;
8657
+ const bodyScrollElem = (0, _util.getRefElem)(elemStore['main-body-scroll']);
8658
+ const headerScrollElem = (0, _util.getRefElem)(elemStore['main-header-scroll']);
8659
+ const footerScrollElem = (0, _util.getRefElem)(elemStore['main-footer-scroll']);
8660
+ if (inWheelScroll) {
8661
+ return;
8662
+ }
8663
+ if (inVirtualScroll) {
8664
+ return;
8665
+ }
8666
+ if (inHeaderScroll) {
8667
+ return;
8668
+ }
8669
+ if (inBodyScroll) {
8670
+ return;
8671
+ }
8672
+ if (!footerScrollElem) {
8673
+ return;
8674
+ }
8675
+ if (!xHandleEl) {
8676
+ return;
8677
+ }
8678
+ if (!yHandleEl) {
8679
+ return;
8680
+ }
8681
+ const scrollTop = yHandleEl.scrollTop;
8682
+ const scrollLeft = footerScrollElem.scrollLeft;
8683
+ const isRollX = true;
8684
+ const isRollY = false;
8685
+ internalData.inFooterScroll = true;
8686
+ (0, _dom.setScrollLeft)(xHandleEl, scrollLeft);
8687
+ (0, _dom.setScrollLeft)(headerScrollElem, scrollLeft);
8688
+ (0, _dom.setScrollLeft)(bodyScrollElem, scrollLeft);
8689
+ $xeTable.triggerScrollXEvent(evnt);
8690
+ $xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
8691
+ type: 'footer',
8692
+ fixed: fixedType
8693
+ });
8694
+ },
8695
+ triggerBodyWheelEvent(evnt) {
8696
+ const $xeTable = this;
8697
+ const tableProps = $xeTable;
8698
+ const reactData = $xeTable;
8699
+ const internalData = $xeTable;
8700
+ const {
8701
+ deltaY,
8702
+ deltaX
8703
+ } = evnt;
8704
+ const {
8705
+ highlightHoverRow
8706
+ } = tableProps;
8707
+ const {
8708
+ elemStore,
8709
+ lastScrollTop,
8710
+ lastScrollLeft
8711
+ } = internalData;
8712
+ const rowOpts = $xeTable.computeRowOpts;
8713
+ const xHandleEl = $xeTable.$refs.refScrollXHandleElem;
8714
+ const yHandleEl = $xeTable.$refs.refScrollYHandleElem;
8715
+ const leftScrollElem = (0, _util.getRefElem)(elemStore['left-body-scroll']);
8716
+ const bodyScrollElem = (0, _util.getRefElem)(elemStore['main-body-scroll']);
8717
+ const rightScrollElem = (0, _util.getRefElem)(elemStore['right-body-scroll']);
8718
+ if (!xHandleEl) {
8719
+ return;
8720
+ }
8721
+ if (!yHandleEl) {
8722
+ return;
8723
+ }
8724
+ if (!bodyScrollElem) {
8725
+ return;
8726
+ }
8727
+ let multiple = 1;
8728
+ if (reactData.lastScrollTime + 25 > Date.now()) {
8729
+ multiple = 1.18;
8730
+ } else if (reactData.lastScrollTime + 30 > Date.now()) {
8731
+ multiple = 1.15;
8732
+ } else if (reactData.lastScrollTime + 40 > Date.now()) {
8733
+ multiple = 1.12;
8734
+ } else if (reactData.lastScrollTime + 55 > Date.now()) {
8735
+ multiple = 1.09;
8736
+ } else if (reactData.lastScrollTime + 75 > Date.now()) {
8737
+ multiple = 1.06;
8738
+ } else if (reactData.lastScrollTime + 100 > Date.now()) {
8739
+ multiple = 1.03;
8740
+ }
8741
+ const deltaTop = deltaY * multiple;
8742
+ const deltaLeft = deltaX * multiple;
8743
+ const isTopWheel = deltaTop < 0;
8744
+ const currScrollTop = yHandleEl.scrollTop;
8745
+ // 如果滚动位置已经是顶部或底部,则不需要触发
8746
+ if (isTopWheel ? currScrollTop <= 0 : currScrollTop >= yHandleEl.scrollHeight - yHandleEl.clientHeight) {
8747
+ return;
8748
+ }
8749
+ const scrollTop = bodyScrollElem.scrollTop + deltaTop;
8750
+ const scrollLeft = bodyScrollElem.scrollLeft + deltaLeft;
8751
+ const isRollX = scrollLeft !== lastScrollLeft;
8752
+ const isRollY = scrollTop !== lastScrollTop;
8753
+ // 用于鼠标纵向滚轮处理
8754
+ if (isRollY) {
8755
+ evnt.preventDefault();
8756
+ if (rowOpts.isHover || highlightHoverRow) {
8757
+ $xeTable.clearHoverRow();
8758
+ }
8759
+ internalData.inWheelScroll = true;
8760
+ (0, _dom.setScrollTop)(yHandleEl, scrollTop);
8761
+ (0, _dom.setScrollTop)(bodyScrollElem, scrollTop);
8762
+ (0, _dom.setScrollTop)(leftScrollElem, scrollTop);
8763
+ (0, _dom.setScrollTop)(rightScrollElem, scrollTop);
8764
+ $xeTable.triggerScrollYEvent(evnt);
8765
+ $xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
8766
+ type: 'footer',
8767
+ fixed: ''
8768
+ });
8769
+ }
8770
+ },
8771
+ scrollXEvent(evnt) {
8772
+ const $xeTable = this;
8773
+ const internalData = $xeTable;
8774
+ const {
8775
+ elemStore,
8776
+ inWheelScroll,
8777
+ lastScrollTop,
8778
+ inHeaderScroll,
8779
+ inBodyScroll,
8780
+ inFooterScroll
8781
+ } = internalData;
8782
+ if (inHeaderScroll || inBodyScroll || inFooterScroll) {
8783
+ return;
8784
+ }
8785
+ if (inWheelScroll) {
8786
+ return;
8377
8787
  }
8378
- const tableHeader = $xeTable.$refs.tableHeader;
8379
- const tableBody = $xeTable.$refs.tableBody;
8380
- const tableFooter = $xeTable.$refs.tableFooter;
8381
- const bodyElem = tableBody.$el;
8382
- const headerElem = tableHeader ? tableHeader.$el : null;
8383
- const footerElem = tableFooter ? tableFooter.$el : null;
8788
+ const headerScrollElem = (0, _util.getRefElem)(elemStore['main-header-scroll']);
8789
+ const bodyScrollElem = (0, _util.getRefElem)(elemStore['main-body-scroll']);
8790
+ const footerScrollElem = (0, _util.getRefElem)(elemStore['main-footer-scroll']);
8384
8791
  const yHandleEl = $xeTable.$refs.refScrollYHandleElem;
8385
8792
  const wrapperEl = evnt.currentTarget;
8386
8793
  const {
8387
8794
  scrollLeft
8388
8795
  } = wrapperEl;
8389
- const yBodyEl = yHandleEl || bodyElem;
8796
+ const yBodyEl = yHandleEl || bodyScrollElem;
8390
8797
  let scrollTop = 0;
8391
8798
  if (yBodyEl) {
8392
8799
  scrollTop = yBodyEl.scrollTop;
@@ -8394,9 +8801,9 @@ const Methods = {
8394
8801
  const isRollX = true;
8395
8802
  const isRollY = scrollTop !== lastScrollTop;
8396
8803
  internalData.inVirtualScroll = true;
8397
- (0, _dom.setScrollLeft)(bodyElem, scrollLeft);
8398
- (0, _dom.setScrollLeft)(headerElem, scrollLeft);
8399
- (0, _dom.setScrollLeft)(footerElem, scrollLeft);
8804
+ (0, _dom.setScrollLeft)(bodyScrollElem, scrollLeft);
8805
+ (0, _dom.setScrollLeft)(headerScrollElem, scrollLeft);
8806
+ (0, _dom.setScrollLeft)(footerScrollElem, scrollLeft);
8400
8807
  $xeTable.triggerScrollXEvent(evnt);
8401
8808
  $xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
8402
8809
  type: 'table',
@@ -8407,31 +8814,28 @@ const Methods = {
8407
8814
  const $xeTable = this;
8408
8815
  const internalData = $xeTable;
8409
8816
  const {
8410
- intoRunScroll,
8411
- inFooterScroll,
8817
+ elemStore,
8818
+ inWheelScroll,
8819
+ lastScrollLeft,
8820
+ inHeaderScroll,
8412
8821
  inBodyScroll,
8413
- lastScrollLeft
8822
+ inFooterScroll
8414
8823
  } = internalData;
8415
- if (!intoRunScroll) {
8416
- if (inFooterScroll) {
8417
- return;
8418
- }
8419
- if (inBodyScroll) {
8420
- return;
8421
- }
8824
+ if (inHeaderScroll || inBodyScroll || inFooterScroll) {
8825
+ return;
8826
+ }
8827
+ if (inWheelScroll) {
8828
+ return;
8422
8829
  }
8423
- const tableBody = $xeTable.$refs.tableBody;
8424
- const leftBody = $xeTable.$refs.leftBody;
8425
- const rightBody = $xeTable.$refs.rightBody;
8426
- const bodyElem = tableBody.$el;
8427
- const leftElem = leftBody ? leftBody.$el : null;
8428
- const rightElem = rightBody ? rightBody.$el : null;
8830
+ const leftScrollElem = (0, _util.getRefElem)(elemStore['left-body-scroll']);
8831
+ const bodyScrollElem = (0, _util.getRefElem)(elemStore['main-body-scroll']);
8832
+ const rightScrollElem = (0, _util.getRefElem)(elemStore['right-body-scroll']);
8429
8833
  const xHandleEl = $xeTable.$refs.refScrollXHandleElem;
8430
8834
  const wrapperEl = evnt.currentTarget;
8431
8835
  const {
8432
8836
  scrollTop
8433
8837
  } = wrapperEl;
8434
- const xBodyEl = xHandleEl || bodyElem;
8838
+ const xBodyEl = xHandleEl || bodyScrollElem;
8435
8839
  let scrollLeft = 0;
8436
8840
  if (xBodyEl) {
8437
8841
  scrollLeft = xBodyEl.scrollLeft;
@@ -8439,52 +8843,26 @@ const Methods = {
8439
8843
  const isRollX = scrollLeft !== lastScrollLeft;
8440
8844
  const isRollY = true;
8441
8845
  internalData.inVirtualScroll = true;
8442
- (0, _dom.setScrollTop)(bodyElem, scrollTop);
8443
- (0, _dom.setScrollTop)(leftElem, scrollTop);
8444
- (0, _dom.setScrollTop)(rightElem, scrollTop);
8846
+ (0, _dom.setScrollTop)(bodyScrollElem, scrollTop);
8847
+ (0, _dom.setScrollTop)(leftScrollElem, scrollTop);
8848
+ (0, _dom.setScrollTop)(rightScrollElem, scrollTop);
8445
8849
  $xeTable.triggerScrollYEvent(evnt);
8446
8850
  $xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
8447
8851
  type: 'table',
8448
8852
  fixed: ''
8449
8853
  });
8450
8854
  },
8451
- handleTableColumn() {
8452
- const {
8453
- scrollXLoad,
8454
- visibleColumn,
8455
- scrollXStore,
8456
- fullColumnIdData
8457
- } = this;
8458
- const tableColumn = scrollXLoad ? visibleColumn.slice(scrollXStore.startIndex, scrollXStore.endIndex) : visibleColumn.slice(0);
8459
- tableColumn.forEach((column, $index) => {
8460
- const colid = column.id;
8461
- const colRest = fullColumnIdData[colid];
8462
- if (colRest) {
8463
- colRest.$index = $index;
8464
- }
8465
- });
8466
- this.tableColumn = tableColumn;
8467
- },
8468
- handleUpdateColumn() {
8469
- const $xeTable = this;
8470
- const internalData = $xeTable;
8471
- const columnList = _xeUtils.default.orderBy(internalData.collectColumn, 'renderSortNumber');
8472
- internalData.collectColumn = columnList;
8473
- const tableFullColumn = getColumnList(columnList);
8474
- internalData.tableFullColumn = tableFullColumn;
8475
- cacheColumnMap($xeTable);
8476
- },
8477
8855
  updateScrollXData() {
8478
8856
  const $xeTable = this;
8479
8857
  const props = $xeTable;
8480
8858
  const {
8481
8859
  showOverflow
8482
8860
  } = props;
8483
- $xeTable.handleTableColumn();
8484
- calcCellHeight($xeTable);
8861
+ handleTableColumn($xeTable);
8862
+ // calcCellHeight()
8485
8863
  return $xeTable.$nextTick().then(() => {
8486
- calcCellHeight($xeTable);
8487
- $xeTable.handleTableColumn();
8864
+ // calcCellHeight()
8865
+ handleTableColumn($xeTable);
8488
8866
  $xeTable.updateScrollXSpace();
8489
8867
  if (!showOverflow) {
8490
8868
  $xeTable.updateScrollYSpace();
@@ -8494,21 +8872,21 @@ const Methods = {
8494
8872
  // 更新横向 X 可视渲染上下剩余空间大小
8495
8873
  updateScrollXSpace() {
8496
8874
  const $xeTable = this;
8875
+ const reactData = $xeTable;
8876
+ const internalData = $xeTable;
8497
8877
  const {
8498
- $refs,
8499
8878
  isGroup,
8500
- elemStore,
8879
+ scrollXLoad
8880
+ } = reactData;
8881
+ const {
8501
8882
  visibleColumn,
8502
8883
  scrollXStore,
8503
- scrollXLoad,
8504
- tableWidth,
8505
- scrollbarWidth
8506
- } = $xeTable;
8507
- const {
8508
- tableHeader,
8509
- tableBody,
8510
- tableFooter
8511
- } = $refs;
8884
+ elemStore,
8885
+ tableWidth
8886
+ } = internalData;
8887
+ const tableHeader = $xeTable.$refs.refTableHeader;
8888
+ const tableBody = $xeTable.$refs.refTableBody;
8889
+ const tableFooter = $xeTable.$refs.refTableFooter;
8512
8890
  const tableBodyElem = tableBody ? tableBody.$el : null;
8513
8891
  if (tableBodyElem) {
8514
8892
  const tableHeaderElem = tableHeader ? tableHeader.$el : null;
@@ -8532,25 +8910,27 @@ const Methods = {
8532
8910
  containerList.forEach(name => {
8533
8911
  const layoutList = ['header', 'body', 'footer'];
8534
8912
  layoutList.forEach(layout => {
8535
- const xSpaceElem = elemStore[`${name}-${layout}-xSpace`];
8913
+ const xSpaceElem = (0, _util.getRefElem)(elemStore[`${name}-${layout}-xSpace`]);
8536
8914
  if (xSpaceElem) {
8537
- xSpaceElem.style.width = scrollXLoad ? `${tableWidth + (layout === 'header' ? scrollbarWidth : 0)}px` : '';
8915
+ xSpaceElem.style.width = scrollXLoad ? `${tableWidth}px` : '';
8538
8916
  }
8539
8917
  });
8540
8918
  });
8541
8919
  const scrollXSpaceEl = $xeTable.$refs.refScrollXSpaceElem;
8542
8920
  if (scrollXSpaceEl) {
8543
- scrollXSpaceEl.style.width = `${tableWidth + scrollbarWidth}px`;
8921
+ scrollXSpaceEl.style.width = `${tableWidth}px`;
8544
8922
  }
8545
- this.$nextTick(this.updateStyle);
8923
+ $xeTable.$nextTick(() => {
8924
+ updateStyle($xeTable);
8925
+ });
8546
8926
  }
8547
8927
  },
8548
8928
  updateScrollYData() {
8549
8929
  const $xeTable = this;
8550
8930
  $xeTable.handleTableData();
8551
- calcCellHeight($xeTable);
8931
+ // calcCellHeight()
8552
8932
  return $xeTable.$nextTick().then(() => {
8553
- calcCellHeight($xeTable);
8933
+ // calcCellHeight()
8554
8934
  $xeTable.handleTableData();
8555
8935
  $xeTable.updateScrollYSpace();
8556
8936
  });
@@ -8558,26 +8938,32 @@ const Methods = {
8558
8938
  // 更新纵向 Y 可视渲染上下剩余空间大小
8559
8939
  updateScrollYSpace() {
8560
8940
  const $xeTable = this;
8941
+ const props = $xeTable;
8942
+ const reactData = $xeTable;
8943
+ const internalData = $xeTable;
8944
+ const {
8945
+ showOverflow
8946
+ } = props;
8561
8947
  const {
8562
- showOverflow,
8563
- elemStore,
8564
- scrollYStore,
8565
8948
  scrollYLoad,
8949
+ rowHeight
8950
+ } = reactData;
8951
+ const {
8952
+ scrollYStore,
8953
+ elemStore,
8566
8954
  afterFullData,
8567
8955
  fullAllDataRowIdData
8568
- } = this;
8956
+ } = internalData;
8569
8957
  const {
8570
- startIndex,
8571
- rowHeight
8958
+ startIndex
8572
8959
  } = scrollYStore;
8573
- let bodyHeight = 0;
8574
- let topSpaceHeight = 0;
8960
+ const bodyTableElem = (0, _util.getRefElem)(elemStore['main-body-table']);
8575
8961
  const containerList = ['main', 'left', 'right'];
8576
- let marginTop = '';
8577
- let ySpaceHeight = '';
8962
+ let topSpaceHeight = 0;
8963
+ let ySpaceHeight = 0;
8578
8964
  if (scrollYLoad) {
8579
8965
  if (showOverflow) {
8580
- bodyHeight = afterFullData.length * rowHeight;
8966
+ ySpaceHeight = afterFullData.length * rowHeight;
8581
8967
  topSpaceHeight = Math.max(0, startIndex * rowHeight);
8582
8968
  } else {
8583
8969
  for (let i = 0; i < afterFullData.length; i++) {
@@ -8585,7 +8971,7 @@ const Methods = {
8585
8971
  const rowid = (0, _util.getRowid)($xeTable, row);
8586
8972
  const rowRest = fullAllDataRowIdData[rowid];
8587
8973
  if (rowRest) {
8588
- bodyHeight += rowRest.height || rowHeight;
8974
+ ySpaceHeight += rowRest.height || rowHeight;
8589
8975
  }
8590
8976
  }
8591
8977
  for (let i = 0; i < startIndex; i++) {
@@ -8597,27 +8983,31 @@ const Methods = {
8597
8983
  }
8598
8984
  }
8599
8985
  }
8600
- marginTop = `${topSpaceHeight}px`;
8601
- ySpaceHeight = `${bodyHeight}px`;
8986
+ } else {
8987
+ if (bodyTableElem) {
8988
+ ySpaceHeight = bodyTableElem.clientHeight;
8989
+ }
8602
8990
  }
8603
8991
  containerList.forEach(name => {
8604
8992
  const layoutList = ['header', 'body', 'footer'];
8605
- const tableElem = elemStore[`${name}-body-table`];
8993
+ const tableElem = (0, _util.getRefElem)(elemStore[`${name}-body-table`]);
8606
8994
  if (tableElem) {
8607
- tableElem.style.marginTop = marginTop;
8995
+ tableElem.style.marginTop = topSpaceHeight ? `${topSpaceHeight}px` : '';
8608
8996
  }
8609
8997
  layoutList.forEach(layout => {
8610
- const ySpaceElem = elemStore[`${name}-${layout}-ySpace`];
8998
+ const ySpaceElem = (0, _util.getRefElem)(elemStore[`${name}-${layout}-ySpace`]);
8611
8999
  if (ySpaceElem) {
8612
- ySpaceElem.style.height = ySpaceHeight;
9000
+ ySpaceElem.style.height = ySpaceHeight ? `${ySpaceHeight}px` : '';
8613
9001
  }
8614
9002
  });
8615
9003
  });
8616
9004
  const scrollYSpaceEl = $xeTable.$refs.refScrollYSpaceElem;
8617
9005
  if (scrollYSpaceEl) {
8618
- scrollYSpaceEl.style.height = ySpaceHeight;
9006
+ scrollYSpaceEl.style.height = ySpaceHeight ? `${ySpaceHeight}px` : '';
8619
9007
  }
8620
- this.$nextTick(this.updateStyle);
9008
+ $xeTable.$nextTick(() => {
9009
+ updateStyle($xeTable);
9010
+ });
8621
9011
  },
8622
9012
  updateScrollYStatus() {
8623
9013
  const $xeTable = this;
@@ -8635,17 +9025,17 @@ const Methods = {
8635
9025
  $refs
8636
9026
  } = this;
8637
9027
  const {
8638
- tableBody,
8639
- tableHeader,
9028
+ refTableBody,
9029
+ refTableHeader,
8640
9030
  leftBody,
8641
9031
  rightBody,
8642
- tableFooter
9032
+ refTableFooter
8643
9033
  } = $refs;
8644
- const tableBodyElem = tableBody ? tableBody.$el : null;
9034
+ const tableBodyElem = refTableBody ? refTableBody.$el : null;
8645
9035
  const leftBodyElem = leftBody ? leftBody.$el : null;
8646
9036
  const rightBodyElem = rightBody ? rightBody.$el : null;
8647
- const tableHeaderElem = tableHeader ? tableHeader.$el : null;
8648
- const tableFooterElem = tableFooter ? tableFooter.$el : null;
9037
+ const tableHeaderElem = refTableHeader ? refTableHeader.$el : null;
9038
+ const tableFooterElem = refTableFooter ? refTableFooter.$el : null;
8649
9039
  internalData.intoRunScroll = true;
8650
9040
  if (_xeUtils.default.isNumber(scrollLeft)) {
8651
9041
  const xHandleEl = $xeTable.$refs.refScrollXHandleElem;
@@ -8759,46 +9149,36 @@ const Methods = {
8759
9149
  const $xeTable = this;
8760
9150
  const internalData = $xeTable;
8761
9151
  const {
9152
+ elemStore,
8762
9153
  scrollXStore,
8763
9154
  scrollYStore
8764
9155
  } = internalData;
8765
- const tableBody = $xeTable.$refs.tableBody;
8766
- const tableHeader = $xeTable.$refs.tableHeader;
8767
- const tableFooter = $xeTable.$refs.tableFooter;
8768
- const leftBody = $xeTable.$refs.leftBody;
8769
- const rightBody = $xeTable.$refs.rightBody;
8770
- const leftBodyElem = leftBody ? leftBody.$el : null;
8771
- const tableBodyElem = tableBody ? tableBody.$el : null;
8772
- const rightBodyElem = rightBody ? rightBody.$el : null;
8773
- const tableHeaderElem = tableHeader ? tableHeader.$el : null;
8774
- const tableFooterElem = tableFooter ? tableFooter.$el : null;
9156
+ const headerScrollElem = (0, _util.getRefElem)(elemStore['main-header-scroll']);
9157
+ const bodyScrollElem = (0, _util.getRefElem)(elemStore['main-body-scroll']);
9158
+ const footerScrollElem = (0, _util.getRefElem)(elemStore['main-footer-scroll']);
9159
+ const leftScrollElem = (0, _util.getRefElem)(elemStore['left-body-scroll']);
9160
+ const rightScrollElem = (0, _util.getRefElem)(elemStore['right-body-scroll']);
8775
9161
  const xHandleEl = $xeTable.$refs.refScrollXHandleElem;
8776
- if (xHandleEl) {
8777
- (0, _dom.setScrollLeft)(xHandleEl, 0);
8778
- } else {
8779
- (0, _dom.setScrollLeft)(tableBodyElem, 0);
8780
- (0, _dom.setScrollLeft)(tableHeaderElem, 0);
8781
- (0, _dom.setScrollLeft)(tableFooterElem, 0);
8782
- }
8783
9162
  const yHandleEl = $xeTable.$refs.refScrollYHandleElem;
8784
- if (yHandleEl) {
8785
- (0, _dom.setScrollTop)(yHandleEl, 0);
8786
- } else {
8787
- (0, _dom.setScrollTop)(tableBodyElem, 0);
8788
- (0, _dom.setScrollTop)(leftBodyElem, 0);
8789
- (0, _dom.setScrollTop)(rightBodyElem, 0);
8790
- }
9163
+ internalData.intoRunScroll = true;
9164
+ (0, _dom.setScrollLeft)(xHandleEl, 0);
9165
+ (0, _dom.setScrollLeft)(bodyScrollElem, 0);
9166
+ (0, _dom.setScrollLeft)(headerScrollElem, 0);
9167
+ (0, _dom.setScrollLeft)(footerScrollElem, 0);
9168
+ (0, _dom.setScrollTop)(yHandleEl, 0);
9169
+ (0, _dom.setScrollTop)(bodyScrollElem, 0);
9170
+ (0, _dom.setScrollTop)(leftScrollElem, 0);
9171
+ (0, _dom.setScrollTop)(rightScrollElem, 0);
8791
9172
  scrollXStore.startIndex = 0;
9173
+ scrollXStore.visibleStartIndex = 0;
8792
9174
  scrollXStore.endIndex = scrollXStore.visibleSize;
9175
+ scrollXStore.visibleEndIndex = scrollXStore.visibleSize;
8793
9176
  scrollYStore.startIndex = 0;
9177
+ scrollYStore.visibleStartIndex = 0;
8794
9178
  scrollYStore.endIndex = scrollYStore.visibleSize;
9179
+ scrollYStore.visibleEndIndex = scrollYStore.visibleSize;
8795
9180
  return $xeTable.$nextTick().then(() => {
8796
- (0, _dom.setScrollLeft)(tableBodyElem, 0);
8797
- (0, _dom.setScrollLeft)(tableHeaderElem, 0);
8798
- (0, _dom.setScrollLeft)(tableFooterElem, 0);
8799
- (0, _dom.setScrollTop)(tableBodyElem, 0);
8800
- (0, _dom.setScrollTop)(leftBodyElem, 0);
8801
- (0, _dom.setScrollTop)(rightBodyElem, 0);
9181
+ internalData.intoRunScroll = false;
8802
9182
  });
8803
9183
  },
8804
9184
  /**
@@ -8838,8 +9218,8 @@ const Methods = {
8838
9218
  editRules,
8839
9219
  validStore
8840
9220
  } = this;
8841
- const tableBody = $refs.tableBody;
8842
- if (slotParams && tableBody && editRules) {
9221
+ const refTableBody = $refs.refTableBody;
9222
+ if (slotParams && refTableBody && editRules) {
8843
9223
  const {
8844
9224
  row,
8845
9225
  column
@@ -8881,13 +9261,14 @@ const Methods = {
8881
9261
  * @param {TableMergeConfig[]} merges { row: Row|number, column: ColumnInfo|number, rowspan: number, colspan: number }
8882
9262
  */
8883
9263
  setMergeCells(merges) {
9264
+ const $xeTable = this;
8884
9265
  if (this.spanMethod) {
8885
9266
  (0, _log.errLog)('vxe.error.errConflicts', ['merge-cells', 'span-method']);
8886
9267
  }
8887
9268
  setMerges(this, merges, this.mergeList, this.afterFullData);
8888
9269
  return this.$nextTick().then(() => {
8889
9270
  this.updateCellAreas();
8890
- return this.updateStyle();
9271
+ return updateStyle($xeTable);
8891
9272
  });
8892
9273
  },
8893
9274
  /**
@@ -8895,13 +9276,14 @@ const Methods = {
8895
9276
  * @param {TableMergeConfig[]} merges 多个或数组 [{row:Row|number, col:ColumnInfo|number}]
8896
9277
  */
8897
9278
  removeMergeCells(merges) {
9279
+ const $xeTable = this;
8898
9280
  if (this.spanMethod) {
8899
9281
  (0, _log.errLog)('vxe.error.errConflicts', ['merge-cells', 'span-method']);
8900
9282
  }
8901
9283
  const rest = removeMerges(this, merges, this.mergeList, this.afterFullData);
8902
9284
  return this.$nextTick().then(() => {
8903
9285
  this.updateCellAreas();
8904
- this.updateStyle();
9286
+ updateStyle($xeTable);
8905
9287
  return rest;
8906
9288
  });
8907
9289
  },
@@ -8915,32 +9297,35 @@ const Methods = {
8915
9297
  * 清除所有单元格合并
8916
9298
  */
8917
9299
  clearMergeCells() {
9300
+ const $xeTable = this;
8918
9301
  this.mergeList = [];
8919
9302
  return this.$nextTick().then(() => {
8920
- return this.updateStyle();
9303
+ return updateStyle($xeTable);
8921
9304
  });
8922
9305
  },
8923
9306
  handleDefaultMergeFooterItems() {
8924
9307
  this.setMergeFooterItems(this.mergeFooterItems);
8925
9308
  },
8926
9309
  setMergeFooterItems(merges) {
9310
+ const $xeTable = this;
8927
9311
  if (this.footerSpanMethod) {
8928
9312
  (0, _log.errLog)('vxe.error.errConflicts', ['merge-footer-items', 'footer-span-method']);
8929
9313
  }
8930
9314
  setMerges(this, merges, this.mergeFooterList, null);
8931
9315
  return this.$nextTick().then(() => {
8932
9316
  this.updateCellAreas();
8933
- return this.updateStyle();
9317
+ return updateStyle($xeTable);
8934
9318
  });
8935
9319
  },
8936
9320
  removeMergeFooterItems(merges) {
9321
+ const $xeTable = this;
8937
9322
  if (this.footerSpanMethod) {
8938
9323
  (0, _log.errLog)('vxe.error.errConflicts', ['merge-footer-items', 'footer-span-method']);
8939
9324
  }
8940
9325
  const rest = removeMerges(this, merges, this.mergeFooterList, null);
8941
9326
  return this.$nextTick().then(() => {
8942
9327
  this.updateCellAreas();
8943
- this.updateStyle();
9328
+ updateStyle($xeTable);
8944
9329
  return rest;
8945
9330
  });
8946
9331
  },
@@ -8954,9 +9339,10 @@ const Methods = {
8954
9339
  * 清除所有表尾合并
8955
9340
  */
8956
9341
  clearMergeFooterItems() {
9342
+ const $xeTable = this;
8957
9343
  this.mergeFooterList = [];
8958
9344
  return this.$nextTick().then(() => {
8959
- return this.updateStyle();
9345
+ return updateStyle($xeTable);
8960
9346
  });
8961
9347
  },
8962
9348
  updateZindex() {