vxe-table 4.10.6-beta.7 → 4.10.6-beta.9

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 (49) hide show
  1. package/es/index.css +1 -1
  2. package/es/index.min.css +1 -1
  3. package/es/style.css +1 -1
  4. package/es/style.min.css +1 -1
  5. package/es/table/src/body.js +40 -27
  6. package/es/table/src/footer.js +4 -4
  7. package/es/table/src/header.js +11 -6
  8. package/es/table/src/table.js +298 -226
  9. package/es/table/style.css +128 -38
  10. package/es/table/style.min.css +1 -1
  11. package/es/ui/index.js +7 -5
  12. package/es/ui/src/log.js +1 -1
  13. package/es/vxe-table/style.css +128 -38
  14. package/es/vxe-table/style.min.css +1 -1
  15. package/lib/index.css +1 -1
  16. package/lib/index.min.css +1 -1
  17. package/lib/index.umd.js +347 -270
  18. package/lib/index.umd.min.js +1 -1
  19. package/lib/style.css +1 -1
  20. package/lib/style.min.css +1 -1
  21. package/lib/table/src/body.js +33 -25
  22. package/lib/table/src/body.min.js +1 -1
  23. package/lib/table/src/footer.js +4 -4
  24. package/lib/table/src/footer.min.js +1 -1
  25. package/lib/table/src/header.js +14 -6
  26. package/lib/table/src/header.min.js +1 -1
  27. package/lib/table/src/table.js +288 -229
  28. package/lib/table/src/table.min.js +1 -1
  29. package/lib/table/style/style.css +128 -38
  30. package/lib/table/style/style.min.css +1 -1
  31. package/lib/ui/index.js +7 -5
  32. package/lib/ui/index.min.js +1 -1
  33. package/lib/ui/src/log.js +1 -1
  34. package/lib/ui/src/log.min.js +1 -1
  35. package/lib/vxe-table/style/style.css +128 -38
  36. package/lib/vxe-table/style/style.min.css +1 -1
  37. package/package.json +1 -1
  38. package/packages/table/src/body.ts +40 -25
  39. package/packages/table/src/footer.ts +4 -4
  40. package/packages/table/src/header.ts +11 -6
  41. package/packages/table/src/table.ts +309 -236
  42. package/packages/ui/index.ts +6 -4
  43. package/styles/components/table.scss +158 -60
  44. /package/es/{iconfont.1736820154664.ttf → iconfont.1736854674495.ttf} +0 -0
  45. /package/es/{iconfont.1736820154664.woff → iconfont.1736854674495.woff} +0 -0
  46. /package/es/{iconfont.1736820154664.woff2 → iconfont.1736854674495.woff2} +0 -0
  47. /package/lib/{iconfont.1736820154664.ttf → iconfont.1736854674495.ttf} +0 -0
  48. /package/lib/{iconfont.1736820154664.woff → iconfont.1736854674495.woff} +0 -0
  49. /package/lib/{iconfont.1736820154664.woff2 → iconfont.1736854674495.woff2} +0 -0
@@ -367,9 +367,12 @@ export default defineComponent({
367
367
  const refScrollXVirtualElem = ref();
368
368
  const refScrollYVirtualElem = ref();
369
369
  const refScrollXHandleElem = ref();
370
+ const refScrollXLeftCornerElem = ref();
370
371
  const refScrollXRightCornerElem = ref();
371
372
  const refScrollYHandleElem = ref();
372
373
  const refScrollYTopCornerElem = ref();
374
+ const refScrollXWrapperElem = ref();
375
+ const refScrollYWrapperElem = ref();
373
376
  const refScrollYBottomCornerElem = ref();
374
377
  const refScrollXSpaceElem = ref();
375
378
  const refScrollYSpaceElem = ref();
@@ -419,6 +422,14 @@ export default defineComponent({
419
422
  const computeScrollbarOpts = computed(() => {
420
423
  return Object.assign({}, getConfig().table.scrollbarConfig, props.scrollbarConfig);
421
424
  });
425
+ const computeScrollbarXToTop = computed(() => {
426
+ const scrollbarOpts = computeScrollbarOpts.value;
427
+ return !!(scrollbarOpts.x && scrollbarOpts.x.position === 'top');
428
+ });
429
+ const computeScrollbarYToLeft = computed(() => {
430
+ const scrollbarOpts = computeScrollbarOpts.value;
431
+ return !!(scrollbarOpts.y && scrollbarOpts.y.position === 'left');
432
+ });
422
433
  const computeScrollYThreshold = computed(() => {
423
434
  const sYOpts = computeSYOpts.value;
424
435
  const { threshold } = sYOpts;
@@ -679,6 +690,8 @@ export default defineComponent({
679
690
  computeVirtualXOpts,
680
691
  computeVirtualYOpts,
681
692
  computeScrollbarOpts,
693
+ computeScrollbarXToTop,
694
+ computeScrollbarYToLeft,
682
695
  computeColumnOpts,
683
696
  computeScrollXThreshold,
684
697
  computeScrollYThreshold,
@@ -814,35 +827,42 @@ export default defineComponent({
814
827
  return { toVisibleIndex: 0, visibleSize: 6 };
815
828
  };
816
829
  const computeRowHeight = () => {
830
+ const { showOverflow } = props;
817
831
  const tableHeader = refTableHeader.value;
818
832
  const tableBody = refTableBody.value;
819
833
  const tableBodyElem = tableBody ? tableBody.$el : null;
820
834
  const defaultRowHeight = computeDefaultRowHeight.value;
821
835
  let rowHeight = 0;
822
- if (tableBodyElem) {
823
- const tableHeaderElem = tableHeader ? tableHeader.$el : null;
824
- let firstTrElem;
825
- firstTrElem = tableBodyElem.querySelector('tr');
826
- if (!firstTrElem && tableHeaderElem) {
827
- firstTrElem = tableHeaderElem.querySelector('tr');
836
+ if (showOverflow) {
837
+ if (tableBodyElem) {
838
+ const tableHeaderElem = tableHeader ? tableHeader.$el : null;
839
+ let firstTrElem;
840
+ firstTrElem = tableBodyElem.querySelector('tr');
841
+ if (!firstTrElem && tableHeaderElem) {
842
+ firstTrElem = tableHeaderElem.querySelector('tr');
843
+ }
844
+ if (firstTrElem) {
845
+ rowHeight = firstTrElem.clientHeight;
846
+ }
828
847
  }
829
- if (firstTrElem) {
830
- rowHeight = firstTrElem.clientHeight;
848
+ if (!rowHeight) {
849
+ rowHeight = defaultRowHeight;
831
850
  }
832
851
  }
833
- if (!rowHeight) {
852
+ else {
834
853
  rowHeight = defaultRowHeight;
835
854
  }
836
855
  // 最低支持 18px 行高
837
856
  return Math.max(18, rowHeight);
838
857
  };
839
- const handleVirtualYVisible = () => {
858
+ const handleVirtualYVisible = (currScrollTop) => {
840
859
  const { showOverflow } = props;
841
860
  const { rowHeight } = reactData;
842
861
  const { elemStore, afterFullData, fullAllDataRowIdData } = internalData;
843
862
  const bodyScrollElem = getRefElem(elemStore['main-body-scroll']);
844
863
  if (bodyScrollElem) {
845
- const { scrollTop, clientHeight } = bodyScrollElem;
864
+ const clientHeight = bodyScrollElem.clientHeight;
865
+ const scrollTop = XEUtils.isNumber(currScrollTop) ? currScrollTop : bodyScrollElem.scrollTop;
846
866
  const endHeight = scrollTop + clientHeight;
847
867
  let toVisibleIndex = -1;
848
868
  let offsetTop = 0;
@@ -1394,7 +1414,7 @@ export default defineComponent({
1394
1414
  tableData.forEach(row => {
1395
1415
  const rowid = getRowid($xeTable, row);
1396
1416
  const rowRest = fullAllDataRowIdData[rowid];
1397
- const cellList = el.querySelectorAll(`.vxe-body--row[rowid="${rowid}"]>.vxe-body--column>.vxe-cell`);
1417
+ const cellList = el.querySelectorAll(`.vxe-body--row[rowid="${rowid}"]>.vxe-body--column>.vxe-cell>.vxe-cell--auto-wrapper`);
1398
1418
  if (rowRest && cellList.length) {
1399
1419
  let height = 0;
1400
1420
  for (let i = 0; i < cellList.length; i++) {
@@ -1710,19 +1730,26 @@ export default defineComponent({
1710
1730
  }
1711
1731
  bodyHeight = Math.max(bodyMinHeight, bodyHeight);
1712
1732
  }
1733
+ const xLeftCornerEl = refScrollXLeftCornerElem.value;
1734
+ const xRightCornerEl = refScrollXRightCornerElem.value;
1735
+ const scrollbarXToTop = computeScrollbarXToTop.value;
1713
1736
  const scrollXVirtualEl = refScrollXVirtualElem.value;
1714
1737
  if (scrollXVirtualEl) {
1715
1738
  scrollXVirtualEl.style.height = `${scrollbarHeight}px`;
1716
1739
  scrollXVirtualEl.style.visibility = scrollbarHeight ? 'visible' : 'hidden';
1717
1740
  }
1718
- const xHandleEl = refScrollXHandleElem.value;
1719
- if (xHandleEl) {
1720
- xHandleEl.style.width = `${el.clientWidth - scrollbarWidth}px`;
1741
+ const xWrapperEl = refScrollXWrapperElem.value;
1742
+ if (xWrapperEl) {
1743
+ xWrapperEl.style.left = scrollbarXToTop ? `${scrollbarWidth}px` : '';
1744
+ xWrapperEl.style.width = `${el.clientWidth - scrollbarWidth}px`;
1745
+ }
1746
+ if (xLeftCornerEl) {
1747
+ xLeftCornerEl.style.width = scrollbarXToTop ? `${scrollbarWidth}px` : '';
1748
+ xLeftCornerEl.style.display = scrollbarXToTop ? (scrollbarWidth && scrollbarHeight ? 'block' : '') : '';
1721
1749
  }
1722
- const xRightCornerEl = refScrollXRightCornerElem.value;
1723
1750
  if (xRightCornerEl) {
1724
- xRightCornerEl.style.width = `${scrollbarWidth}px`;
1725
- xRightCornerEl.style.display = scrollbarWidth && scrollbarHeight ? 'block' : '';
1751
+ xRightCornerEl.style.width = scrollbarXToTop ? '' : `${scrollbarWidth}px`;
1752
+ xRightCornerEl.style.display = scrollbarXToTop ? '' : (scrollbarWidth && scrollbarHeight ? 'block' : '');
1726
1753
  }
1727
1754
  const scrollYVirtualEl = refScrollYVirtualElem.value;
1728
1755
  if (scrollYVirtualEl) {
@@ -1735,10 +1762,10 @@ export default defineComponent({
1735
1762
  yTopCornerEl.style.height = `${headerHeight}px`;
1736
1763
  yTopCornerEl.style.display = headerHeight ? 'block' : '';
1737
1764
  }
1738
- const yHandleEl = refScrollYHandleElem.value;
1739
- if (yHandleEl) {
1740
- yHandleEl.style.height = `${bodyHeight}px`;
1741
- yHandleEl.style.top = `${headerHeight}px`;
1765
+ const yWrapperEl = refScrollYWrapperElem.value;
1766
+ if (yWrapperEl) {
1767
+ yWrapperEl.style.height = `${bodyHeight}px`;
1768
+ yWrapperEl.style.top = `${headerHeight}px`;
1742
1769
  }
1743
1770
  const yBottomCornerEl = refScrollYBottomCornerElem.value;
1744
1771
  if (yBottomCornerEl) {
@@ -2456,13 +2483,13 @@ export default defineComponent({
2456
2483
  return nextTick().then(() => {
2457
2484
  const { scrollXLoad, scrollYLoad } = reactData;
2458
2485
  const { scrollXStore, scrollYStore } = internalData;
2459
- const sYOpts = computeSYOpts.value;
2460
- const sXOpts = computeSXOpts.value;
2486
+ const virtualYOpts = computeVirtualYOpts.value;
2487
+ const virtualXOpts = computeVirtualXOpts.value;
2461
2488
  // 计算 X 逻辑
2462
2489
  if (scrollXLoad) {
2463
2490
  const { toVisibleIndex: toXVisibleIndex, visibleSize: visibleXSize } = handleVirtualXVisible();
2464
- const offsetXSize = Math.max(0, sXOpts.oSize ? XEUtils.toNumber(sXOpts.oSize) : 0);
2465
- scrollXStore.preloadSize = 4;
2491
+ const offsetXSize = Math.max(0, virtualXOpts.oSize ? XEUtils.toNumber(virtualXOpts.oSize) : 0);
2492
+ scrollXStore.preloadSize = XEUtils.toNumber(virtualXOpts.preSize);
2466
2493
  scrollXStore.offsetSize = offsetXSize;
2467
2494
  scrollXStore.visibleSize = visibleXSize;
2468
2495
  scrollXStore.endIndex = Math.max(scrollXStore.startIndex + scrollXStore.visibleSize + offsetXSize, scrollXStore.endIndex);
@@ -2475,15 +2502,14 @@ export default defineComponent({
2475
2502
  else {
2476
2503
  $xeTable.updateScrollXSpace();
2477
2504
  }
2478
- calcCellHeight();
2479
2505
  // 计算 Y 逻辑
2480
2506
  const rowHeight = computeRowHeight();
2481
2507
  scrollYStore.rowHeight = rowHeight;
2482
2508
  reactData.rowHeight = rowHeight;
2483
2509
  const { toVisibleIndex: toYVisibleIndex, visibleSize: visibleYSize } = handleVirtualYVisible();
2484
2510
  if (scrollYLoad) {
2485
- const offsetYSize = Math.max(0, sYOpts.oSize ? XEUtils.toNumber(sYOpts.oSize) : 0);
2486
- scrollYStore.preloadSize = 2;
2511
+ const offsetYSize = Math.max(0, virtualYOpts.oSize ? XEUtils.toNumber(virtualYOpts.oSize) : 0);
2512
+ scrollYStore.preloadSize = XEUtils.toNumber(virtualYOpts.preSize);
2487
2513
  scrollYStore.offsetSize = offsetYSize;
2488
2514
  scrollYStore.visibleSize = visibleYSize;
2489
2515
  scrollYStore.endIndex = Math.max(scrollYStore.startIndex + visibleYSize + offsetYSize, scrollYStore.endIndex);
@@ -2513,7 +2539,6 @@ export default defineComponent({
2513
2539
  return computeScrollLoad().then(() => {
2514
2540
  if (reFull === true) {
2515
2541
  // 初始化时需要在列计算之后再执行优化运算,达到最优显示效果
2516
- calcCellHeight();
2517
2542
  calcCellWidth();
2518
2543
  autoCellWidth();
2519
2544
  updateStyle();
@@ -2648,6 +2673,7 @@ export default defineComponent({
2648
2673
  if (sYOpts.scrollToTopOnChange) {
2649
2674
  targetScrollTop = 0;
2650
2675
  }
2676
+ calcCellHeight();
2651
2677
  // 是否变更虚拟滚动
2652
2678
  if (oldScrollYLoad === sYLoad) {
2653
2679
  restoreScrollLocation($xeTable, targetScrollLeft, targetScrollTop)
@@ -3026,13 +3052,13 @@ export default defineComponent({
3026
3052
  /**
3027
3053
  * 纵向 Y 可视渲染处理
3028
3054
  */
3029
- const loadScrollYData = () => {
3055
+ const loadScrollYData = (scrollTop) => {
3030
3056
  const { showOverflow } = props;
3031
3057
  const { mergeList } = reactData;
3032
3058
  const { scrollYStore } = internalData;
3033
3059
  const { preloadSize, startIndex, endIndex, offsetSize } = scrollYStore;
3034
3060
  const autoOffsetYSize = showOverflow ? offsetSize : offsetSize + 1;
3035
- const { toVisibleIndex, visibleSize } = handleVirtualYVisible();
3061
+ const { toVisibleIndex, visibleSize } = handleVirtualYVisible(scrollTop);
3036
3062
  const offsetItem = {
3037
3063
  startIndex: Math.max(0, toVisibleIndex - 1 - offsetSize - preloadSize),
3038
3064
  endIndex: toVisibleIndex + visibleSize + autoOffsetYSize + preloadSize
@@ -3092,10 +3118,8 @@ export default defineComponent({
3092
3118
  }, fpsTime);
3093
3119
  };
3094
3120
  const lazyScrollYData = () => {
3095
- const { showOverflow } = props;
3096
- const { lyTimeout, lyRunTime, scrollYStore } = internalData;
3097
- const { visibleSize } = scrollYStore;
3098
- const fpsTime = showOverflow ? 5 : Math.max(5, Math.min(80, Math.floor(visibleSize / 2)));
3121
+ const { lyTimeout, lyRunTime } = internalData;
3122
+ const fpsTime = Math.floor(Math.max(4, Math.min(10, 20 / 3)));
3099
3123
  if (lyTimeout) {
3100
3124
  clearTimeout(lyTimeout);
3101
3125
  }
@@ -3109,68 +3133,6 @@ export default defineComponent({
3109
3133
  loadScrollYData();
3110
3134
  }, fpsTime);
3111
3135
  };
3112
- const scrollXEvent = (evnt) => {
3113
- const { elemStore, inWheelScroll, lastScrollTop, inHeaderScroll, inBodyScroll, inFooterScroll } = internalData;
3114
- if (inHeaderScroll || inBodyScroll || inFooterScroll) {
3115
- return;
3116
- }
3117
- if (inWheelScroll) {
3118
- return;
3119
- }
3120
- const headerScrollElem = getRefElem(elemStore['main-header-scroll']);
3121
- const bodyScrollElem = getRefElem(elemStore['main-body-scroll']);
3122
- const footerScrollElem = getRefElem(elemStore['main-footer-scroll']);
3123
- const yHandleEl = refScrollYHandleElem.value;
3124
- const wrapperEl = evnt.currentTarget;
3125
- const { scrollLeft } = wrapperEl;
3126
- const yBodyEl = yHandleEl || bodyScrollElem;
3127
- let scrollTop = 0;
3128
- if (yBodyEl) {
3129
- scrollTop = yBodyEl.scrollTop;
3130
- }
3131
- const isRollX = true;
3132
- const isRollY = scrollTop !== lastScrollTop;
3133
- internalData.inVirtualScroll = true;
3134
- setScrollLeft(bodyScrollElem, scrollLeft);
3135
- setScrollLeft(headerScrollElem, scrollLeft);
3136
- setScrollLeft(footerScrollElem, scrollLeft);
3137
- $xeTable.triggerScrollXEvent(evnt);
3138
- $xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
3139
- type: 'table',
3140
- fixed: ''
3141
- });
3142
- };
3143
- const scrollYEvent = (evnt) => {
3144
- const { elemStore, inWheelScroll, lastScrollLeft, inHeaderScroll, inBodyScroll, inFooterScroll } = internalData;
3145
- if (inHeaderScroll || inBodyScroll || inFooterScroll) {
3146
- return;
3147
- }
3148
- if (inWheelScroll) {
3149
- return;
3150
- }
3151
- const leftScrollElem = getRefElem(elemStore['left-body-scroll']);
3152
- const bodyScrollElem = getRefElem(elemStore['main-body-scroll']);
3153
- const rightScrollElem = getRefElem(elemStore['right-body-scroll']);
3154
- const xHandleEl = refScrollXHandleElem.value;
3155
- const wrapperEl = evnt.currentTarget;
3156
- const { scrollTop } = wrapperEl;
3157
- const xBodyEl = xHandleEl || bodyScrollElem;
3158
- let scrollLeft = 0;
3159
- if (xBodyEl) {
3160
- scrollLeft = xBodyEl.scrollLeft;
3161
- }
3162
- const isRollX = scrollLeft !== lastScrollLeft;
3163
- const isRollY = true;
3164
- internalData.inVirtualScroll = true;
3165
- setScrollTop(bodyScrollElem, scrollTop);
3166
- setScrollTop(leftScrollElem, scrollTop);
3167
- setScrollTop(rightScrollElem, scrollTop);
3168
- $xeTable.triggerScrollYEvent(evnt);
3169
- $xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
3170
- type: 'table',
3171
- fixed: ''
3172
- });
3173
- };
3174
3136
  const checkLastSyncScroll = (isRollX, isRollY) => {
3175
3137
  const { scrollXLoad, scrollYLoad } = reactData;
3176
3138
  const { lcsTimeout } = internalData;
@@ -3186,16 +3148,14 @@ export default defineComponent({
3186
3148
  internalData.inBodyScroll = false;
3187
3149
  internalData.inFooterScroll = false;
3188
3150
  internalData.scrollRenderType = '';
3151
+ calcCellHeight();
3189
3152
  if (isRollX && scrollXLoad) {
3190
- $xeTable.updateScrollXData().then(() => {
3191
- calcCellHeight();
3192
- loadScrollXData();
3193
- });
3153
+ $xeTable.updateScrollXData();
3194
3154
  }
3195
3155
  if (isRollY && scrollYLoad) {
3196
3156
  $xeTable.updateScrollYData().then(() => {
3197
3157
  calcCellHeight();
3198
- loadScrollYData();
3158
+ $xeTable.updateScrollYSpace();
3199
3159
  });
3200
3160
  }
3201
3161
  $xeTable.updateCellAreas();
@@ -3212,6 +3172,12 @@ export default defineComponent({
3212
3172
  }
3213
3173
  return nextTick();
3214
3174
  };
3175
+ function handleUupdateResize() {
3176
+ const el = refElem.value;
3177
+ if (el && el.clientWidth && el.clientHeight) {
3178
+ tableMethods.recalculate();
3179
+ }
3180
+ }
3215
3181
  tableMethods = {
3216
3182
  dispatchEvent,
3217
3183
  /**
@@ -6163,6 +6129,7 @@ export default defineComponent({
6163
6129
  const rdLineEl = refDragRowLineElem.value;
6164
6130
  if (rdLineEl) {
6165
6131
  if (showLine) {
6132
+ const scrollbarYToLeft = computeScrollbarYToLeft.value;
6166
6133
  const trRect = trEl.getBoundingClientRect();
6167
6134
  let trHeight = trEl.clientHeight;
6168
6135
  const offsetTop = Math.max(1, trRect.y - wrapperRect.y);
@@ -6170,6 +6137,7 @@ export default defineComponent({
6170
6137
  trHeight = tableHeight - offsetTop - scrollbarHeight;
6171
6138
  }
6172
6139
  rdLineEl.style.display = 'block';
6140
+ rdLineEl.style.left = `${scrollbarYToLeft ? scrollbarWidth : 0}px`;
6173
6141
  rdLineEl.style.top = `${offsetTop}px`;
6174
6142
  rdLineEl.style.height = `${trHeight}px`;
6175
6143
  rdLineEl.style.width = `${tableWidth - scrollbarWidth}px`;
@@ -6185,6 +6153,7 @@ export default defineComponent({
6185
6153
  const cdLineEl = refDragColLineElem.value;
6186
6154
  if (cdLineEl) {
6187
6155
  if (showLine) {
6156
+ const scrollbarXToTop = computeScrollbarXToTop.value;
6188
6157
  const leftContainerElem = refLeftContainer.value;
6189
6158
  const leftContainerWidth = leftContainerElem ? leftContainerElem.clientWidth : 0;
6190
6159
  const rightContainerElem = refRightContainer.value;
@@ -6210,7 +6179,7 @@ export default defineComponent({
6210
6179
  cdLineEl.style.height = `${thRect.height}px`;
6211
6180
  }
6212
6181
  else {
6213
- cdLineEl.style.height = `${tableHeight - offsetTop - scrollbarHeight}px`;
6182
+ cdLineEl.style.height = `${tableHeight - offsetTop - (scrollbarXToTop ? 0 : scrollbarHeight)}px`;
6214
6183
  }
6215
6184
  cdLineEl.setAttribute('drag-pos', dragPos);
6216
6185
  cdLineEl.setAttribute('drag-to-child', prevDragToChild ? 'y' : 'n');
@@ -8295,13 +8264,75 @@ export default defineComponent({
8295
8264
  setScrollTop(bodyScrollElem, scrollTop);
8296
8265
  setScrollTop(leftScrollElem, scrollTop);
8297
8266
  setScrollTop(rightScrollElem, scrollTop);
8298
- $xeTable.triggerScrollYEvent(evnt);
8267
+ loadScrollYData(scrollTop);
8299
8268
  $xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
8300
- type: 'footer',
8269
+ type: 'table',
8301
8270
  fixed: ''
8302
8271
  });
8303
8272
  }
8304
8273
  },
8274
+ triggerVirtualScrollXEvent(evnt) {
8275
+ const { elemStore, inWheelScroll, lastScrollTop, inHeaderScroll, inBodyScroll, inFooterScroll } = internalData;
8276
+ if (inHeaderScroll || inBodyScroll || inFooterScroll) {
8277
+ return;
8278
+ }
8279
+ if (inWheelScroll) {
8280
+ return;
8281
+ }
8282
+ const headerScrollElem = getRefElem(elemStore['main-header-scroll']);
8283
+ const bodyScrollElem = getRefElem(elemStore['main-body-scroll']);
8284
+ const footerScrollElem = getRefElem(elemStore['main-footer-scroll']);
8285
+ const yHandleEl = refScrollYHandleElem.value;
8286
+ const wrapperEl = evnt.currentTarget;
8287
+ const { scrollLeft } = wrapperEl;
8288
+ const yBodyEl = yHandleEl || bodyScrollElem;
8289
+ let scrollTop = 0;
8290
+ if (yBodyEl) {
8291
+ scrollTop = yBodyEl.scrollTop;
8292
+ }
8293
+ const isRollX = true;
8294
+ const isRollY = scrollTop !== lastScrollTop;
8295
+ internalData.inVirtualScroll = true;
8296
+ setScrollLeft(bodyScrollElem, scrollLeft);
8297
+ setScrollLeft(headerScrollElem, scrollLeft);
8298
+ setScrollLeft(footerScrollElem, scrollLeft);
8299
+ $xeTable.triggerScrollXEvent(evnt);
8300
+ $xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
8301
+ type: 'table',
8302
+ fixed: ''
8303
+ });
8304
+ },
8305
+ triggerVirtualScrollYEvent(evnt) {
8306
+ const { elemStore, inWheelScroll, lastScrollLeft, inHeaderScroll, inBodyScroll, inFooterScroll } = internalData;
8307
+ if (inHeaderScroll || inBodyScroll || inFooterScroll) {
8308
+ return;
8309
+ }
8310
+ if (inWheelScroll) {
8311
+ return;
8312
+ }
8313
+ const leftScrollElem = getRefElem(elemStore['left-body-scroll']);
8314
+ const bodyScrollElem = getRefElem(elemStore['main-body-scroll']);
8315
+ const rightScrollElem = getRefElem(elemStore['right-body-scroll']);
8316
+ const xHandleEl = refScrollXHandleElem.value;
8317
+ const wrapperEl = evnt.currentTarget;
8318
+ const { scrollTop } = wrapperEl;
8319
+ const xBodyEl = xHandleEl || bodyScrollElem;
8320
+ let scrollLeft = 0;
8321
+ if (xBodyEl) {
8322
+ scrollLeft = xBodyEl.scrollLeft;
8323
+ }
8324
+ const isRollX = scrollLeft !== lastScrollLeft;
8325
+ const isRollY = true;
8326
+ internalData.inVirtualScroll = true;
8327
+ setScrollTop(bodyScrollElem, scrollTop);
8328
+ setScrollTop(leftScrollElem, scrollTop);
8329
+ setScrollTop(rightScrollElem, scrollTop);
8330
+ $xeTable.triggerScrollYEvent(evnt);
8331
+ $xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
8332
+ type: 'table',
8333
+ fixed: ''
8334
+ });
8335
+ },
8305
8336
  /**
8306
8337
  * 对于树形结构中,可以直接滚动到指定深层节点中
8307
8338
  * 对于某些特定的场景可能会用到,比如定位到某一节点
@@ -8435,9 +8466,7 @@ export default defineComponent({
8435
8466
  updateScrollXData() {
8436
8467
  const { showOverflow } = props;
8437
8468
  handleTableColumn();
8438
- // calcCellHeight()
8439
8469
  return nextTick().then(() => {
8440
- // calcCellHeight()
8441
8470
  handleTableColumn();
8442
8471
  $xeTable.updateScrollXSpace();
8443
8472
  if (!showOverflow) {
@@ -8447,9 +8476,7 @@ export default defineComponent({
8447
8476
  },
8448
8477
  updateScrollYData() {
8449
8478
  $xeTable.handleTableData();
8450
- // calcCellHeight()
8451
8479
  return nextTick().then(() => {
8452
- // calcCellHeight()
8453
8480
  $xeTable.handleTableData();
8454
8481
  $xeTable.updateScrollYSpace();
8455
8482
  });
@@ -8674,15 +8701,133 @@ export default defineComponent({
8674
8701
  }
8675
8702
  return renderEmptyElement($xeTable);
8676
8703
  };
8677
- function handleUupdateResize() {
8678
- const el = refElem.value;
8679
- if (el && el.clientWidth && el.clientHeight) {
8680
- tableMethods.recalculate();
8681
- }
8682
- }
8704
+ const renderScrollX = () => {
8705
+ return h('div', {
8706
+ key: 'vsx',
8707
+ ref: refScrollXVirtualElem,
8708
+ class: 'vxe-table--scroll-x-virtual'
8709
+ }, [
8710
+ h('div', {
8711
+ ref: refScrollXLeftCornerElem,
8712
+ class: 'vxe-table--scroll-x-left-corner'
8713
+ }),
8714
+ h('div', {
8715
+ ref: refScrollXWrapperElem,
8716
+ class: 'vxe-table--scroll-x-wrapper'
8717
+ }, [
8718
+ h('div', {
8719
+ ref: refScrollXHandleElem,
8720
+ class: 'vxe-table--scroll-x-handle',
8721
+ onScroll: $xeTable.triggerVirtualScrollXEvent
8722
+ }, [
8723
+ h('div', {
8724
+ ref: refScrollXSpaceElem,
8725
+ class: 'vxe-table--scroll-x-space'
8726
+ })
8727
+ ])
8728
+ ]),
8729
+ h('div', {
8730
+ ref: refScrollXRightCornerElem,
8731
+ class: 'vxe-table--scroll-x-right-corner'
8732
+ })
8733
+ ]);
8734
+ };
8735
+ const renderScrollY = () => {
8736
+ return h('div', {
8737
+ ref: refScrollYVirtualElem,
8738
+ class: 'vxe-table--scroll-y-virtual'
8739
+ }, [
8740
+ h('div', {
8741
+ ref: refScrollYTopCornerElem,
8742
+ class: 'vxe-table--scroll-y-top-corner'
8743
+ }),
8744
+ h('div', {
8745
+ ref: refScrollYWrapperElem,
8746
+ class: 'vxe-table--scroll-y-wrapper'
8747
+ }, [
8748
+ h('div', {
8749
+ ref: refScrollYHandleElem,
8750
+ class: 'vxe-table--scroll-y-handle',
8751
+ onScroll: $xeTable.triggerVirtualScrollYEvent
8752
+ }, [
8753
+ h('div', {
8754
+ ref: refScrollYSpaceElem,
8755
+ class: 'vxe-table--scroll-y-space'
8756
+ })
8757
+ ])
8758
+ ]),
8759
+ h('div', {
8760
+ ref: refScrollYBottomCornerElem,
8761
+ class: 'vxe-table--scroll-y-bottom-corner'
8762
+ })
8763
+ ]);
8764
+ };
8765
+ const renderViewport = () => {
8766
+ const { showHeader, showFooter } = props;
8767
+ const { overflowX, tableData, tableColumn, tableGroupColumn, footerTableData, columnStore } = reactData;
8768
+ const { leftList, rightList } = columnStore;
8769
+ return h('div', {
8770
+ ref: refTableViewportElem,
8771
+ class: 'vxe-table--viewport-wrapper'
8772
+ }, [
8773
+ h('div', {
8774
+ class: 'vxe-table--main-wrapper'
8775
+ }, [
8776
+ /**
8777
+ * 表头
8778
+ */
8779
+ showHeader
8780
+ ? h(TableHeaderComponent, {
8781
+ ref: refTableHeader,
8782
+ tableData,
8783
+ tableColumn,
8784
+ tableGroupColumn
8785
+ })
8786
+ : renderEmptyElement($xeTable),
8787
+ /**
8788
+ * 表体
8789
+ */
8790
+ h(TableBodyComponent, {
8791
+ ref: refTableBody,
8792
+ tableData,
8793
+ tableColumn
8794
+ }),
8795
+ /**
8796
+ * 表尾
8797
+ */
8798
+ showFooter
8799
+ ? h(TableFooterComponent, {
8800
+ ref: refTableFooter,
8801
+ footerTableData,
8802
+ tableColumn
8803
+ })
8804
+ : renderEmptyElement($xeTable)
8805
+ ]),
8806
+ h('div', {
8807
+ class: 'vxe-table--fixed-wrapper'
8808
+ }, [
8809
+ leftList && leftList.length && overflowX ? renderFixed('left') : renderEmptyElement($xeTable),
8810
+ rightList && rightList.length && overflowX ? renderFixed('right') : renderEmptyElement($xeTable)
8811
+ ])
8812
+ ]);
8813
+ };
8814
+ const renderBody = () => {
8815
+ const scrollbarYToLeft = computeScrollbarYToLeft.value;
8816
+ return h('div', {
8817
+ class: 'vxe-table--layout-wrapper'
8818
+ }, scrollbarYToLeft
8819
+ ? [
8820
+ renderScrollY(),
8821
+ renderViewport()
8822
+ ]
8823
+ : [
8824
+ renderViewport(),
8825
+ renderScrollY()
8826
+ ]);
8827
+ };
8683
8828
  const renderVN = () => {
8684
8829
  const { loading, stripe, showHeader, height, treeConfig, mouseConfig, showFooter, highlightCell, highlightHoverRow, highlightHoverColumn, editConfig, editRules } = props;
8685
- const { isCalcColumn, isGroup, overflowX, overflowY, scrollXLoad, scrollYLoad, scrollbarHeight, tableData, tableColumn, tableGroupColumn, footerTableData, initStore, columnStore, filterStore, customStore, tooltipStore } = reactData;
8830
+ const { isCalcColumn, isGroup, overflowX, overflowY, scrollXLoad, scrollYLoad, tableData, initStore, columnStore, filterStore, customStore, tooltipStore } = reactData;
8686
8831
  const { leftList, rightList } = columnStore;
8687
8832
  const loadingSlot = slots.loading;
8688
8833
  const tooltipOpts = computeTooltipOpts.value;
@@ -8701,9 +8846,11 @@ export default defineComponent({
8701
8846
  const resizableOpts = computeResizableOpts.value;
8702
8847
  const isArea = mouseConfig && mouseOpts.area;
8703
8848
  const columnDragOpts = computeColumnDragOpts.value;
8849
+ const scrollbarXToTop = computeScrollbarXToTop.value;
8850
+ const scrollbarYToLeft = computeScrollbarYToLeft.value;
8704
8851
  return h('div', {
8705
8852
  ref: refElem,
8706
- class: ['vxe-table', 'vxe-table--render-default', `tid_${xID}`, `border--${tableBorder}`, {
8853
+ class: ['vxe-table', 'vxe-table--render-default', `tid_${xID}`, `border--${tableBorder}`, `sx-pos--${scrollbarXToTop ? 'top' : 'bottom'}`, `sy-pos--${scrollbarYToLeft ? 'left' : 'right'}`, {
8707
8854
  [`size--${vSize}`]: vSize,
8708
8855
  [`valid-msg--${validOpts.msgMode}`]: !!editRules,
8709
8856
  'vxe-editable': !!editConfig,
@@ -8747,95 +8894,15 @@ export default defineComponent({
8747
8894
  h('div', {
8748
8895
  key: 'tw',
8749
8896
  class: 'vxe-table--render-wrapper'
8750
- }, [
8751
- h('div', {
8752
- ref: refTableViewportElem,
8753
- class: 'vxe-table--viewport-wrapper'
8754
- }, [
8755
- h('div', {
8756
- class: 'vxe-table--main-wrapper'
8757
- }, [
8758
- /**
8759
- * 表头
8760
- */
8761
- showHeader
8762
- ? h(TableHeaderComponent, {
8763
- ref: refTableHeader,
8764
- tableData,
8765
- tableColumn,
8766
- tableGroupColumn
8767
- })
8768
- : renderEmptyElement($xeTable),
8769
- /**
8770
- * 表体
8771
- */
8772
- h(TableBodyComponent, {
8773
- ref: refTableBody,
8774
- tableData,
8775
- tableColumn
8776
- }),
8777
- /**
8778
- * 表尾
8779
- */
8780
- showFooter
8781
- ? h(TableFooterComponent, {
8782
- ref: refTableFooter,
8783
- footerTableData,
8784
- tableColumn
8785
- })
8786
- : renderEmptyElement($xeTable)
8787
- ]),
8788
- h('div', {
8789
- class: 'vxe-table--fixed-wrapper'
8790
- }, [
8791
- leftList && leftList.length && overflowX ? renderFixed('left') : renderEmptyElement($xeTable),
8792
- rightList && rightList.length && overflowX ? renderFixed('right') : renderEmptyElement($xeTable)
8793
- ])
8794
- ]),
8795
- h('div', {
8796
- ref: refScrollYVirtualElem,
8797
- class: 'vxe-table--scroll-y-virtual'
8798
- }, [
8799
- h('div', {
8800
- ref: refScrollYTopCornerElem,
8801
- class: 'vxe-table--scroll-y-top-corner'
8802
- }),
8803
- h('div', {
8804
- ref: refScrollYHandleElem,
8805
- class: 'vxe-table--scroll-y-handle',
8806
- onScroll: scrollYEvent
8807
- }, [
8808
- h('div', {
8809
- ref: refScrollYSpaceElem,
8810
- class: 'vxe-table--scroll-y-space'
8811
- })
8812
- ]),
8813
- h('div', {
8814
- ref: refScrollYBottomCornerElem,
8815
- class: 'vxe-table--scroll-y-bottom-corner'
8816
- })
8817
- ])
8818
- ]),
8819
- h('div', {
8820
- key: 'vx',
8821
- ref: refScrollXVirtualElem,
8822
- class: 'vxe-table--scroll-x-virtual'
8823
- }, [
8824
- h('div', {
8825
- ref: refScrollXHandleElem,
8826
- class: 'vxe-table--scroll-x-handle',
8827
- onScroll: scrollXEvent
8828
- }, [
8829
- h('div', {
8830
- ref: refScrollXSpaceElem,
8831
- class: 'vxe-table--scroll-x-space'
8832
- })
8897
+ }, scrollbarXToTop
8898
+ ? [
8899
+ renderScrollX(),
8900
+ renderBody()
8901
+ ]
8902
+ : [
8903
+ renderBody(),
8904
+ renderScrollX()
8833
8905
  ]),
8834
- h('div', {
8835
- ref: refScrollXRightCornerElem,
8836
- class: 'vxe-table--scroll-x-right-corner'
8837
- })
8838
- ]),
8839
8906
  /**
8840
8907
  * 空数据
8841
8908
  */
@@ -8861,12 +8928,7 @@ export default defineComponent({
8861
8928
  h('div', {
8862
8929
  key: 'cl',
8863
8930
  ref: refCellResizeBar,
8864
- class: 'vxe-table--resizable-bar',
8865
- style: overflowX
8866
- ? {
8867
- 'padding-bottom': `${scrollbarHeight}px`
8868
- }
8869
- : null
8931
+ class: 'vxe-table--resizable-bar'
8870
8932
  }, resizableOpts.showDragTip
8871
8933
  ? [
8872
8934
  h('div', {
@@ -9044,16 +9106,37 @@ export default defineComponent({
9044
9106
  tableMethods.refreshColumn();
9045
9107
  });
9046
9108
  });
9109
+ const reScrollFlag = ref(0);
9110
+ watch(computeSize, () => {
9111
+ reScrollFlag.value++;
9112
+ });
9047
9113
  watch(() => props.showHeader, () => {
9048
- nextTick(() => {
9049
- tableMethods.recalculate(true).then(() => tableMethods.refreshScroll());
9050
- });
9114
+ reScrollFlag.value++;
9051
9115
  });
9052
9116
  watch(() => props.showFooter, () => {
9117
+ reScrollFlag.value++;
9118
+ });
9119
+ watch(reScrollFlag, () => {
9053
9120
  nextTick(() => {
9054
9121
  tableMethods.recalculate(true).then(() => tableMethods.refreshScroll());
9055
9122
  });
9056
9123
  });
9124
+ const reLayoutFlag = ref(0);
9125
+ watch(() => props.height, () => {
9126
+ reLayoutFlag.value++;
9127
+ });
9128
+ watch(() => props.maxHeight, () => {
9129
+ reLayoutFlag.value++;
9130
+ });
9131
+ watch(computeScrollbarXToTop, () => {
9132
+ reLayoutFlag.value++;
9133
+ });
9134
+ watch(computeScrollbarYToLeft, () => {
9135
+ reLayoutFlag.value++;
9136
+ });
9137
+ watch(reLayoutFlag, () => {
9138
+ nextTick(() => tableMethods.recalculate(true));
9139
+ });
9057
9140
  const footFlag = ref(0);
9058
9141
  watch(() => props.footerData ? props.footerData.length : -1, () => {
9059
9142
  footFlag.value++;
@@ -9064,17 +9147,6 @@ export default defineComponent({
9064
9147
  watch(footFlag, () => {
9065
9148
  tableMethods.updateFooter();
9066
9149
  });
9067
- watch(() => props.height, () => {
9068
- nextTick(() => tableMethods.recalculate(true));
9069
- });
9070
- watch(() => props.maxHeight, () => {
9071
- nextTick(() => tableMethods.recalculate(true));
9072
- });
9073
- watch(computeSize, () => {
9074
- nextTick(() => {
9075
- tableMethods.recalculate(true).then(() => tableMethods.refreshScroll());
9076
- });
9077
- });
9078
9150
  watch(() => props.syncResize, (value) => {
9079
9151
  if (value) {
9080
9152
  handleUupdateResize();