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
@@ -391,9 +391,12 @@ export default defineComponent({
391
391
  const refScrollXVirtualElem = ref<HTMLDivElement>()
392
392
  const refScrollYVirtualElem = ref<HTMLDivElement>()
393
393
  const refScrollXHandleElem = ref<HTMLDivElement>()
394
+ const refScrollXLeftCornerElem = ref<HTMLDivElement>()
394
395
  const refScrollXRightCornerElem = ref<HTMLDivElement>()
395
396
  const refScrollYHandleElem = ref<HTMLDivElement>()
396
397
  const refScrollYTopCornerElem = ref<HTMLDivElement>()
398
+ const refScrollXWrapperElem = ref<HTMLDivElement>()
399
+ const refScrollYWrapperElem = ref<HTMLDivElement>()
397
400
  const refScrollYBottomCornerElem = ref<HTMLDivElement>()
398
401
  const refScrollXSpaceElem = ref<HTMLDivElement>()
399
402
  const refScrollYSpaceElem = ref<HTMLDivElement>()
@@ -442,17 +445,27 @@ export default defineComponent({
442
445
  })
443
446
 
444
447
  const computeVirtualXOpts = computed(() => {
445
- return Object.assign({}, getConfig().table.scrollX, getConfig().table.virtualXConfig, props.scrollX, props.virtualXConfig)
448
+ return Object.assign({}, getConfig().table.scrollX, getConfig().table.virtualXConfig, props.scrollX, props.virtualXConfig) as VxeTablePropTypes.VirtualXConfig
446
449
  })
447
450
 
448
451
  const computeVirtualYOpts = computed(() => {
449
- return Object.assign({}, getConfig().table.scrollY, getConfig().table.virtualYConfig, props.scrollY, props.virtualYConfig)
452
+ return Object.assign({}, getConfig().table.scrollY, getConfig().table.virtualYConfig, props.scrollY, props.virtualYConfig) as VxeTablePropTypes.VirtualYConfig
450
453
  })
451
454
 
452
455
  const computeScrollbarOpts = computed(() => {
453
456
  return Object.assign({}, getConfig().table.scrollbarConfig, props.scrollbarConfig)
454
457
  })
455
458
 
459
+ const computeScrollbarXToTop = computed(() => {
460
+ const scrollbarOpts = computeScrollbarOpts.value
461
+ return !!(scrollbarOpts.x && scrollbarOpts.x.position === 'top')
462
+ })
463
+
464
+ const computeScrollbarYToLeft = computed(() => {
465
+ const scrollbarOpts = computeScrollbarOpts.value
466
+ return !!(scrollbarOpts.y && scrollbarOpts.y.position === 'left')
467
+ })
468
+
456
469
  const computeScrollYThreshold = computed(() => {
457
470
  const sYOpts = computeSYOpts.value
458
471
  const { threshold } = sYOpts
@@ -759,6 +772,8 @@ export default defineComponent({
759
772
  computeVirtualXOpts,
760
773
  computeVirtualYOpts,
761
774
  computeScrollbarOpts,
775
+ computeScrollbarXToTop,
776
+ computeScrollbarYToLeft,
762
777
  computeColumnOpts,
763
778
  computeScrollXThreshold,
764
779
  computeScrollYThreshold,
@@ -905,36 +920,42 @@ export default defineComponent({
905
920
  }
906
921
 
907
922
  const computeRowHeight = () => {
923
+ const { showOverflow } = props
908
924
  const tableHeader = refTableHeader.value
909
925
  const tableBody = refTableBody.value
910
926
  const tableBodyElem = tableBody ? tableBody.$el as HTMLDivElement : null
911
927
  const defaultRowHeight = computeDefaultRowHeight.value
912
928
  let rowHeight = 0
913
- if (tableBodyElem) {
914
- const tableHeaderElem = tableHeader ? tableHeader.$el as HTMLDivElement : null
915
- let firstTrElem
916
- firstTrElem = tableBodyElem.querySelector('tr')
917
- if (!firstTrElem && tableHeaderElem) {
918
- firstTrElem = tableHeaderElem.querySelector('tr')
929
+ if (showOverflow) {
930
+ if (tableBodyElem) {
931
+ const tableHeaderElem = tableHeader ? tableHeader.$el as HTMLDivElement : null
932
+ let firstTrElem
933
+ firstTrElem = tableBodyElem.querySelector('tr')
934
+ if (!firstTrElem && tableHeaderElem) {
935
+ firstTrElem = tableHeaderElem.querySelector('tr')
936
+ }
937
+ if (firstTrElem) {
938
+ rowHeight = firstTrElem.clientHeight
939
+ }
919
940
  }
920
- if (firstTrElem) {
921
- rowHeight = firstTrElem.clientHeight
941
+ if (!rowHeight) {
942
+ rowHeight = defaultRowHeight
922
943
  }
923
- }
924
- if (!rowHeight) {
944
+ } else {
925
945
  rowHeight = defaultRowHeight
926
946
  }
927
947
  // 最低支持 18px 行高
928
948
  return Math.max(18, rowHeight)
929
949
  }
930
950
 
931
- const handleVirtualYVisible = () => {
951
+ const handleVirtualYVisible = (currScrollTop?: number) => {
932
952
  const { showOverflow } = props
933
953
  const { rowHeight } = reactData
934
954
  const { elemStore, afterFullData, fullAllDataRowIdData } = internalData
935
955
  const bodyScrollElem = getRefElem(elemStore['main-body-scroll'])
936
956
  if (bodyScrollElem) {
937
- const { scrollTop, clientHeight } = bodyScrollElem
957
+ const clientHeight = bodyScrollElem.clientHeight
958
+ const scrollTop = XEUtils.isNumber(currScrollTop) ? currScrollTop : bodyScrollElem.scrollTop
938
959
  const endHeight = scrollTop + clientHeight
939
960
  let toVisibleIndex = -1
940
961
  let offsetTop = 0
@@ -1494,7 +1515,7 @@ export default defineComponent({
1494
1515
  tableData.forEach(row => {
1495
1516
  const rowid = getRowid($xeTable, row)
1496
1517
  const rowRest = fullAllDataRowIdData[rowid]
1497
- const cellList = el.querySelectorAll(`.vxe-body--row[rowid="${rowid}"]>.vxe-body--column>.vxe-cell`)
1518
+ const cellList = el.querySelectorAll(`.vxe-body--row[rowid="${rowid}"]>.vxe-body--column>.vxe-cell>.vxe-cell--auto-wrapper`)
1498
1519
  if (rowRest && cellList.length) {
1499
1520
  let height = 0
1500
1521
  for (let i = 0; i < cellList.length; i++) {
@@ -1810,19 +1831,26 @@ export default defineComponent({
1810
1831
  bodyHeight = Math.max(bodyMinHeight, bodyHeight)
1811
1832
  }
1812
1833
 
1834
+ const xLeftCornerEl = refScrollXLeftCornerElem.value
1835
+ const xRightCornerEl = refScrollXRightCornerElem.value
1836
+ const scrollbarXToTop = computeScrollbarXToTop.value
1813
1837
  const scrollXVirtualEl = refScrollXVirtualElem.value
1814
1838
  if (scrollXVirtualEl) {
1815
1839
  scrollXVirtualEl.style.height = `${scrollbarHeight}px`
1816
1840
  scrollXVirtualEl.style.visibility = scrollbarHeight ? 'visible' : 'hidden'
1817
1841
  }
1818
- const xHandleEl = refScrollXHandleElem.value
1819
- if (xHandleEl) {
1820
- xHandleEl.style.width = `${el.clientWidth - scrollbarWidth}px`
1842
+ const xWrapperEl = refScrollXWrapperElem.value
1843
+ if (xWrapperEl) {
1844
+ xWrapperEl.style.left = scrollbarXToTop ? `${scrollbarWidth}px` : ''
1845
+ xWrapperEl.style.width = `${el.clientWidth - scrollbarWidth}px`
1846
+ }
1847
+ if (xLeftCornerEl) {
1848
+ xLeftCornerEl.style.width = scrollbarXToTop ? `${scrollbarWidth}px` : ''
1849
+ xLeftCornerEl.style.display = scrollbarXToTop ? (scrollbarWidth && scrollbarHeight ? 'block' : '') : ''
1821
1850
  }
1822
- const xRightCornerEl = refScrollXRightCornerElem.value
1823
1851
  if (xRightCornerEl) {
1824
- xRightCornerEl.style.width = `${scrollbarWidth}px`
1825
- xRightCornerEl.style.display = scrollbarWidth && scrollbarHeight ? 'block' : ''
1852
+ xRightCornerEl.style.width = scrollbarXToTop ? '' : `${scrollbarWidth}px`
1853
+ xRightCornerEl.style.display = scrollbarXToTop ? '' : (scrollbarWidth && scrollbarHeight ? 'block' : '')
1826
1854
  }
1827
1855
 
1828
1856
  const scrollYVirtualEl = refScrollYVirtualElem.value
@@ -1836,10 +1864,10 @@ export default defineComponent({
1836
1864
  yTopCornerEl.style.height = `${headerHeight}px`
1837
1865
  yTopCornerEl.style.display = headerHeight ? 'block' : ''
1838
1866
  }
1839
- const yHandleEl = refScrollYHandleElem.value
1840
- if (yHandleEl) {
1841
- yHandleEl.style.height = `${bodyHeight}px`
1842
- yHandleEl.style.top = `${headerHeight}px`
1867
+ const yWrapperEl = refScrollYWrapperElem.value
1868
+ if (yWrapperEl) {
1869
+ yWrapperEl.style.height = `${bodyHeight}px`
1870
+ yWrapperEl.style.top = `${headerHeight}px`
1843
1871
  }
1844
1872
  const yBottomCornerEl = refScrollYBottomCornerElem.value
1845
1873
  if (yBottomCornerEl) {
@@ -2579,13 +2607,13 @@ export default defineComponent({
2579
2607
  return nextTick().then(() => {
2580
2608
  const { scrollXLoad, scrollYLoad } = reactData
2581
2609
  const { scrollXStore, scrollYStore } = internalData
2582
- const sYOpts = computeSYOpts.value
2583
- const sXOpts = computeSXOpts.value
2610
+ const virtualYOpts = computeVirtualYOpts.value
2611
+ const virtualXOpts = computeVirtualXOpts.value
2584
2612
  // 计算 X 逻辑
2585
2613
  if (scrollXLoad) {
2586
2614
  const { toVisibleIndex: toXVisibleIndex, visibleSize: visibleXSize } = handleVirtualXVisible()
2587
- const offsetXSize = Math.max(0, sXOpts.oSize ? XEUtils.toNumber(sXOpts.oSize) : 0)
2588
- scrollXStore.preloadSize = 4
2615
+ const offsetXSize = Math.max(0, virtualXOpts.oSize ? XEUtils.toNumber(virtualXOpts.oSize) : 0)
2616
+ scrollXStore.preloadSize = XEUtils.toNumber(virtualXOpts.preSize)
2589
2617
  scrollXStore.offsetSize = offsetXSize
2590
2618
  scrollXStore.visibleSize = visibleXSize
2591
2619
  scrollXStore.endIndex = Math.max(scrollXStore.startIndex + scrollXStore.visibleSize + offsetXSize, scrollXStore.endIndex)
@@ -2597,15 +2625,14 @@ export default defineComponent({
2597
2625
  } else {
2598
2626
  $xeTable.updateScrollXSpace()
2599
2627
  }
2600
- calcCellHeight()
2601
2628
  // 计算 Y 逻辑
2602
2629
  const rowHeight = computeRowHeight()
2603
2630
  ;(scrollYStore as any).rowHeight = rowHeight
2604
2631
  reactData.rowHeight = rowHeight
2605
2632
  const { toVisibleIndex: toYVisibleIndex, visibleSize: visibleYSize } = handleVirtualYVisible()
2606
2633
  if (scrollYLoad) {
2607
- const offsetYSize = Math.max(0, sYOpts.oSize ? XEUtils.toNumber(sYOpts.oSize) : 0)
2608
- scrollYStore.preloadSize = 2
2634
+ const offsetYSize = Math.max(0, virtualYOpts.oSize ? XEUtils.toNumber(virtualYOpts.oSize) : 0)
2635
+ scrollYStore.preloadSize = XEUtils.toNumber(virtualYOpts.preSize)
2609
2636
  scrollYStore.offsetSize = offsetYSize
2610
2637
  scrollYStore.visibleSize = visibleYSize
2611
2638
  scrollYStore.endIndex = Math.max(scrollYStore.startIndex + visibleYSize + offsetYSize, scrollYStore.endIndex)
@@ -2635,7 +2662,6 @@ export default defineComponent({
2635
2662
  return computeScrollLoad().then(() => {
2636
2663
  if (reFull === true) {
2637
2664
  // 初始化时需要在列计算之后再执行优化运算,达到最优显示效果
2638
- calcCellHeight()
2639
2665
  calcCellWidth()
2640
2666
  autoCellWidth()
2641
2667
  updateStyle()
@@ -2771,6 +2797,7 @@ export default defineComponent({
2771
2797
  if (sYOpts.scrollToTopOnChange) {
2772
2798
  targetScrollTop = 0
2773
2799
  }
2800
+ calcCellHeight()
2774
2801
  // 是否变更虚拟滚动
2775
2802
  if (oldScrollYLoad === sYLoad) {
2776
2803
  restoreScrollLocation($xeTable, targetScrollLeft, targetScrollTop)
@@ -3154,13 +3181,13 @@ export default defineComponent({
3154
3181
  /**
3155
3182
  * 纵向 Y 可视渲染处理
3156
3183
  */
3157
- const loadScrollYData = () => {
3184
+ const loadScrollYData = (scrollTop?: number) => {
3158
3185
  const { showOverflow } = props
3159
3186
  const { mergeList } = reactData
3160
3187
  const { scrollYStore } = internalData
3161
3188
  const { preloadSize, startIndex, endIndex, offsetSize } = scrollYStore
3162
3189
  const autoOffsetYSize = showOverflow ? offsetSize : offsetSize + 1
3163
- const { toVisibleIndex, visibleSize } = handleVirtualYVisible()
3190
+ const { toVisibleIndex, visibleSize } = handleVirtualYVisible(scrollTop)
3164
3191
  const offsetItem = {
3165
3192
  startIndex: Math.max(0, toVisibleIndex - 1 - offsetSize - preloadSize),
3166
3193
  endIndex: toVisibleIndex + visibleSize + autoOffsetYSize + preloadSize
@@ -3224,10 +3251,8 @@ export default defineComponent({
3224
3251
  }
3225
3252
 
3226
3253
  const lazyScrollYData = () => {
3227
- const { showOverflow } = props
3228
- const { lyTimeout, lyRunTime, scrollYStore } = internalData
3229
- const { visibleSize } = scrollYStore
3230
- const fpsTime = showOverflow ? 5 : Math.max(5, Math.min(80, Math.floor(visibleSize / 2)))
3254
+ const { lyTimeout, lyRunTime } = internalData
3255
+ const fpsTime = Math.floor(Math.max(4, Math.min(10, 20 / 3)))
3231
3256
  if (lyTimeout) {
3232
3257
  clearTimeout(lyTimeout)
3233
3258
  }
@@ -3242,72 +3267,6 @@ export default defineComponent({
3242
3267
  }, fpsTime)
3243
3268
  }
3244
3269
 
3245
- const scrollXEvent = (evnt: Event) => {
3246
- const { elemStore, inWheelScroll, lastScrollTop, inHeaderScroll, inBodyScroll, inFooterScroll } = internalData
3247
- if (inHeaderScroll || inBodyScroll || inFooterScroll) {
3248
- return
3249
- }
3250
- if (inWheelScroll) {
3251
- return
3252
- }
3253
- const headerScrollElem = getRefElem(elemStore['main-header-scroll'])
3254
- const bodyScrollElem = getRefElem(elemStore['main-body-scroll'])
3255
- const footerScrollElem = getRefElem(elemStore['main-footer-scroll'])
3256
- const yHandleEl = refScrollYHandleElem.value
3257
- const wrapperEl = evnt.currentTarget as HTMLDivElement
3258
- const { scrollLeft } = wrapperEl
3259
- const yBodyEl = yHandleEl || bodyScrollElem
3260
- let scrollTop = 0
3261
- if (yBodyEl) {
3262
- scrollTop = yBodyEl.scrollTop
3263
- }
3264
- const isRollX = true
3265
- const isRollY = scrollTop !== lastScrollTop
3266
-
3267
- internalData.inVirtualScroll = true
3268
- setScrollLeft(bodyScrollElem, scrollLeft)
3269
- setScrollLeft(headerScrollElem, scrollLeft)
3270
- setScrollLeft(footerScrollElem, scrollLeft)
3271
- $xeTable.triggerScrollXEvent(evnt)
3272
- $xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
3273
- type: 'table',
3274
- fixed: ''
3275
- })
3276
- }
3277
-
3278
- const scrollYEvent = (evnt: Event) => {
3279
- const { elemStore, inWheelScroll, lastScrollLeft, inHeaderScroll, inBodyScroll, inFooterScroll } = internalData
3280
- if (inHeaderScroll || inBodyScroll || inFooterScroll) {
3281
- return
3282
- }
3283
- if (inWheelScroll) {
3284
- return
3285
- }
3286
- const leftScrollElem = getRefElem(elemStore['left-body-scroll'])
3287
- const bodyScrollElem = getRefElem(elemStore['main-body-scroll'])
3288
- const rightScrollElem = getRefElem(elemStore['right-body-scroll'])
3289
- const xHandleEl = refScrollXHandleElem.value
3290
- const wrapperEl = evnt.currentTarget as HTMLDivElement
3291
- const { scrollTop } = wrapperEl
3292
- const xBodyEl = xHandleEl || bodyScrollElem
3293
- let scrollLeft = 0
3294
- if (xBodyEl) {
3295
- scrollLeft = xBodyEl.scrollLeft
3296
- }
3297
- const isRollX = scrollLeft !== lastScrollLeft
3298
- const isRollY = true
3299
-
3300
- internalData.inVirtualScroll = true
3301
- setScrollTop(bodyScrollElem, scrollTop)
3302
- setScrollTop(leftScrollElem, scrollTop)
3303
- setScrollTop(rightScrollElem, scrollTop)
3304
- $xeTable.triggerScrollYEvent(evnt)
3305
- $xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
3306
- type: 'table',
3307
- fixed: ''
3308
- })
3309
- }
3310
-
3311
3270
  const checkLastSyncScroll = (isRollX: boolean, isRollY: boolean) => {
3312
3271
  const { scrollXLoad, scrollYLoad } = reactData
3313
3272
  const { lcsTimeout } = internalData
@@ -3323,16 +3282,14 @@ export default defineComponent({
3323
3282
  internalData.inBodyScroll = false
3324
3283
  internalData.inFooterScroll = false
3325
3284
  internalData.scrollRenderType = ''
3285
+ calcCellHeight()
3326
3286
  if (isRollX && scrollXLoad) {
3327
- $xeTable.updateScrollXData().then(() => {
3328
- calcCellHeight()
3329
- loadScrollXData()
3330
- })
3287
+ $xeTable.updateScrollXData()
3331
3288
  }
3332
3289
  if (isRollY && scrollYLoad) {
3333
3290
  $xeTable.updateScrollYData().then(() => {
3334
3291
  calcCellHeight()
3335
- loadScrollYData()
3292
+ $xeTable.updateScrollYSpace()
3336
3293
  })
3337
3294
  }
3338
3295
  $xeTable.updateCellAreas()
@@ -3352,6 +3309,13 @@ export default defineComponent({
3352
3309
  return nextTick()
3353
3310
  }
3354
3311
 
3312
+ function handleUupdateResize () {
3313
+ const el = refElem.value
3314
+ if (el && el.clientWidth && el.clientHeight) {
3315
+ tableMethods.recalculate()
3316
+ }
3317
+ }
3318
+
3355
3319
  tableMethods = {
3356
3320
  dispatchEvent,
3357
3321
  /**
@@ -6270,6 +6234,7 @@ export default defineComponent({
6270
6234
  const rdLineEl = refDragRowLineElem.value
6271
6235
  if (rdLineEl) {
6272
6236
  if (showLine) {
6237
+ const scrollbarYToLeft = computeScrollbarYToLeft.value
6273
6238
  const trRect = trEl.getBoundingClientRect()
6274
6239
  let trHeight = trEl.clientHeight
6275
6240
  const offsetTop = Math.max(1, trRect.y - wrapperRect.y)
@@ -6277,6 +6242,7 @@ export default defineComponent({
6277
6242
  trHeight = tableHeight - offsetTop - scrollbarHeight
6278
6243
  }
6279
6244
  rdLineEl.style.display = 'block'
6245
+ rdLineEl.style.left = `${scrollbarYToLeft ? scrollbarWidth : 0}px`
6280
6246
  rdLineEl.style.top = `${offsetTop}px`
6281
6247
  rdLineEl.style.height = `${trHeight}px`
6282
6248
  rdLineEl.style.width = `${tableWidth - scrollbarWidth}px`
@@ -6290,6 +6256,7 @@ export default defineComponent({
6290
6256
  const cdLineEl = refDragColLineElem.value
6291
6257
  if (cdLineEl) {
6292
6258
  if (showLine) {
6259
+ const scrollbarXToTop = computeScrollbarXToTop.value
6293
6260
  const leftContainerElem = refLeftContainer.value
6294
6261
  const leftContainerWidth = leftContainerElem ? leftContainerElem.clientWidth : 0
6295
6262
  const rightContainerElem = refRightContainer.value
@@ -6314,7 +6281,7 @@ export default defineComponent({
6314
6281
  if (prevDragToChild) {
6315
6282
  cdLineEl.style.height = `${thRect.height}px`
6316
6283
  } else {
6317
- cdLineEl.style.height = `${tableHeight - offsetTop - scrollbarHeight}px`
6284
+ cdLineEl.style.height = `${tableHeight - offsetTop - (scrollbarXToTop ? 0 : scrollbarHeight)}px`
6318
6285
  }
6319
6286
  cdLineEl.setAttribute('drag-pos', dragPos)
6320
6287
  cdLineEl.setAttribute('drag-to-child', prevDragToChild ? 'y' : 'n')
@@ -8400,13 +8367,78 @@ export default defineComponent({
8400
8367
  setScrollTop(bodyScrollElem, scrollTop)
8401
8368
  setScrollTop(leftScrollElem, scrollTop)
8402
8369
  setScrollTop(rightScrollElem, scrollTop)
8403
- $xeTable.triggerScrollYEvent(evnt)
8370
+
8371
+ loadScrollYData(scrollTop)
8404
8372
  $xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
8405
- type: 'footer',
8373
+ type: 'table',
8406
8374
  fixed: ''
8407
8375
  })
8408
8376
  }
8409
8377
  },
8378
+ triggerVirtualScrollXEvent (evnt) {
8379
+ const { elemStore, inWheelScroll, lastScrollTop, inHeaderScroll, inBodyScroll, inFooterScroll } = internalData
8380
+ if (inHeaderScroll || inBodyScroll || inFooterScroll) {
8381
+ return
8382
+ }
8383
+ if (inWheelScroll) {
8384
+ return
8385
+ }
8386
+ const headerScrollElem = getRefElem(elemStore['main-header-scroll'])
8387
+ const bodyScrollElem = getRefElem(elemStore['main-body-scroll'])
8388
+ const footerScrollElem = getRefElem(elemStore['main-footer-scroll'])
8389
+ const yHandleEl = refScrollYHandleElem.value
8390
+ const wrapperEl = evnt.currentTarget as HTMLDivElement
8391
+ const { scrollLeft } = wrapperEl
8392
+ const yBodyEl = yHandleEl || bodyScrollElem
8393
+ let scrollTop = 0
8394
+ if (yBodyEl) {
8395
+ scrollTop = yBodyEl.scrollTop
8396
+ }
8397
+ const isRollX = true
8398
+ const isRollY = scrollTop !== lastScrollTop
8399
+
8400
+ internalData.inVirtualScroll = true
8401
+ setScrollLeft(bodyScrollElem, scrollLeft)
8402
+ setScrollLeft(headerScrollElem, scrollLeft)
8403
+ setScrollLeft(footerScrollElem, scrollLeft)
8404
+ $xeTable.triggerScrollXEvent(evnt)
8405
+ $xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
8406
+ type: 'table',
8407
+ fixed: ''
8408
+ })
8409
+ },
8410
+ triggerVirtualScrollYEvent (evnt) {
8411
+ const { elemStore, inWheelScroll, lastScrollLeft, inHeaderScroll, inBodyScroll, inFooterScroll } = internalData
8412
+ if (inHeaderScroll || inBodyScroll || inFooterScroll) {
8413
+ return
8414
+ }
8415
+ if (inWheelScroll) {
8416
+ return
8417
+ }
8418
+ const leftScrollElem = getRefElem(elemStore['left-body-scroll'])
8419
+ const bodyScrollElem = getRefElem(elemStore['main-body-scroll'])
8420
+ const rightScrollElem = getRefElem(elemStore['right-body-scroll'])
8421
+ const xHandleEl = refScrollXHandleElem.value
8422
+ const wrapperEl = evnt.currentTarget as HTMLDivElement
8423
+ const { scrollTop } = wrapperEl
8424
+ const xBodyEl = xHandleEl || bodyScrollElem
8425
+ let scrollLeft = 0
8426
+ if (xBodyEl) {
8427
+ scrollLeft = xBodyEl.scrollLeft
8428
+ }
8429
+ const isRollX = scrollLeft !== lastScrollLeft
8430
+ const isRollY = true
8431
+
8432
+ internalData.inVirtualScroll = true
8433
+ setScrollTop(bodyScrollElem, scrollTop)
8434
+ setScrollTop(leftScrollElem, scrollTop)
8435
+ setScrollTop(rightScrollElem, scrollTop)
8436
+ $xeTable.triggerScrollYEvent(evnt)
8437
+ $xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
8438
+ type: 'table',
8439
+ fixed: ''
8440
+ })
8441
+ },
8410
8442
  /**
8411
8443
  * 对于树形结构中,可以直接滚动到指定深层节点中
8412
8444
  * 对于某些特定的场景可能会用到,比如定位到某一节点
@@ -8538,9 +8570,7 @@ export default defineComponent({
8538
8570
  updateScrollXData () {
8539
8571
  const { showOverflow } = props
8540
8572
  handleTableColumn()
8541
- // calcCellHeight()
8542
8573
  return nextTick().then(() => {
8543
- // calcCellHeight()
8544
8574
  handleTableColumn()
8545
8575
  $xeTable.updateScrollXSpace()
8546
8576
  if (!showOverflow) {
@@ -8550,9 +8580,7 @@ export default defineComponent({
8550
8580
  },
8551
8581
  updateScrollYData () {
8552
8582
  $xeTable.handleTableData()
8553
- // calcCellHeight()
8554
8583
  return nextTick().then(() => {
8555
- // calcCellHeight()
8556
8584
  $xeTable.handleTableData()
8557
8585
  $xeTable.updateScrollYSpace()
8558
8586
  })
@@ -8782,16 +8810,137 @@ export default defineComponent({
8782
8810
  return renderEmptyElement($xeTable)
8783
8811
  }
8784
8812
 
8785
- function handleUupdateResize () {
8786
- const el = refElem.value
8787
- if (el && el.clientWidth && el.clientHeight) {
8788
- tableMethods.recalculate()
8789
- }
8813
+ const renderScrollX = () => {
8814
+ return h('div', {
8815
+ key: 'vsx',
8816
+ ref: refScrollXVirtualElem,
8817
+ class: 'vxe-table--scroll-x-virtual'
8818
+ }, [
8819
+ h('div', {
8820
+ ref: refScrollXLeftCornerElem,
8821
+ class: 'vxe-table--scroll-x-left-corner'
8822
+ }),
8823
+ h('div', {
8824
+ ref: refScrollXWrapperElem,
8825
+ class: 'vxe-table--scroll-x-wrapper'
8826
+ }, [
8827
+ h('div', {
8828
+ ref: refScrollXHandleElem,
8829
+ class: 'vxe-table--scroll-x-handle',
8830
+ onScroll: $xeTable.triggerVirtualScrollXEvent
8831
+ }, [
8832
+ h('div', {
8833
+ ref: refScrollXSpaceElem,
8834
+ class: 'vxe-table--scroll-x-space'
8835
+ })
8836
+ ])
8837
+ ]),
8838
+ h('div', {
8839
+ ref: refScrollXRightCornerElem,
8840
+ class: 'vxe-table--scroll-x-right-corner'
8841
+ })
8842
+ ])
8843
+ }
8844
+
8845
+ const renderScrollY = () => {
8846
+ return h('div', {
8847
+ ref: refScrollYVirtualElem,
8848
+ class: 'vxe-table--scroll-y-virtual'
8849
+ }, [
8850
+ h('div', {
8851
+ ref: refScrollYTopCornerElem,
8852
+ class: 'vxe-table--scroll-y-top-corner'
8853
+ }),
8854
+ h('div', {
8855
+ ref: refScrollYWrapperElem,
8856
+ class: 'vxe-table--scroll-y-wrapper'
8857
+ }, [
8858
+ h('div', {
8859
+ ref: refScrollYHandleElem,
8860
+ class: 'vxe-table--scroll-y-handle',
8861
+ onScroll: $xeTable.triggerVirtualScrollYEvent
8862
+ }, [
8863
+ h('div', {
8864
+ ref: refScrollYSpaceElem,
8865
+ class: 'vxe-table--scroll-y-space'
8866
+ })
8867
+ ])
8868
+ ]),
8869
+ h('div', {
8870
+ ref: refScrollYBottomCornerElem,
8871
+ class: 'vxe-table--scroll-y-bottom-corner'
8872
+ })
8873
+ ])
8874
+ }
8875
+
8876
+ const renderViewport = () => {
8877
+ const { showHeader, showFooter } = props
8878
+ const { overflowX, tableData, tableColumn, tableGroupColumn, footerTableData, columnStore } = reactData
8879
+ const { leftList, rightList } = columnStore
8880
+ return h('div', {
8881
+ ref: refTableViewportElem,
8882
+ class: 'vxe-table--viewport-wrapper'
8883
+ }, [
8884
+ h('div', {
8885
+ class: 'vxe-table--main-wrapper'
8886
+ }, [
8887
+ /**
8888
+ * 表头
8889
+ */
8890
+ showHeader
8891
+ ? h(TableHeaderComponent, {
8892
+ ref: refTableHeader,
8893
+ tableData,
8894
+ tableColumn,
8895
+ tableGroupColumn
8896
+ })
8897
+ : renderEmptyElement($xeTable),
8898
+ /**
8899
+ * 表体
8900
+ */
8901
+ h(TableBodyComponent, {
8902
+ ref: refTableBody,
8903
+ tableData,
8904
+ tableColumn
8905
+ }),
8906
+ /**
8907
+ * 表尾
8908
+ */
8909
+ showFooter
8910
+ ? h(TableFooterComponent, {
8911
+ ref: refTableFooter,
8912
+ footerTableData,
8913
+ tableColumn
8914
+ })
8915
+ : renderEmptyElement($xeTable)
8916
+ ]),
8917
+ h('div', {
8918
+ class: 'vxe-table--fixed-wrapper'
8919
+ }, [
8920
+ leftList && leftList.length && overflowX ? renderFixed('left') : renderEmptyElement($xeTable),
8921
+ rightList && rightList.length && overflowX ? renderFixed('right') : renderEmptyElement($xeTable)
8922
+ ])
8923
+ ])
8924
+ }
8925
+
8926
+ const renderBody = () => {
8927
+ const scrollbarYToLeft = computeScrollbarYToLeft.value
8928
+ return h('div', {
8929
+ class: 'vxe-table--layout-wrapper'
8930
+ }, scrollbarYToLeft
8931
+ ? [
8932
+ renderScrollY(),
8933
+ renderViewport()
8934
+ ]
8935
+ : [
8936
+ renderViewport(),
8937
+ renderScrollY()
8938
+ ])
8790
8939
  }
8791
8940
 
8792
8941
  const renderVN = () => {
8793
8942
  const { loading, stripe, showHeader, height, treeConfig, mouseConfig, showFooter, highlightCell, highlightHoverRow, highlightHoverColumn, editConfig, editRules } = props
8794
- const { isCalcColumn, isGroup, overflowX, overflowY, scrollXLoad, scrollYLoad, scrollbarHeight, tableData, tableColumn, tableGroupColumn, footerTableData, initStore, columnStore, filterStore, customStore, tooltipStore } = reactData
8943
+ const { isCalcColumn, isGroup, overflowX, overflowY, scrollXLoad, scrollYLoad, tableData, initStore, columnStore, filterStore, customStore, tooltipStore } = reactData
8795
8944
  const { leftList, rightList } = columnStore
8796
8945
  const loadingSlot = slots.loading
8797
8946
  const tooltipOpts = computeTooltipOpts.value
@@ -8810,9 +8959,11 @@ export default defineComponent({
8810
8959
  const resizableOpts = computeResizableOpts.value
8811
8960
  const isArea = mouseConfig && mouseOpts.area
8812
8961
  const columnDragOpts = computeColumnDragOpts.value
8962
+ const scrollbarXToTop = computeScrollbarXToTop.value
8963
+ const scrollbarYToLeft = computeScrollbarYToLeft.value
8813
8964
  return h('div', {
8814
8965
  ref: refElem,
8815
- class: ['vxe-table', 'vxe-table--render-default', `tid_${xID}`, `border--${tableBorder}`, {
8966
+ class: ['vxe-table', 'vxe-table--render-default', `tid_${xID}`, `border--${tableBorder}`, `sx-pos--${scrollbarXToTop ? 'top' : 'bottom'}`, `sy-pos--${scrollbarYToLeft ? 'left' : 'right'}`, {
8816
8967
  [`size--${vSize}`]: vSize,
8817
8968
  [`valid-msg--${validOpts.msgMode}`]: !!editRules,
8818
8969
  'vxe-editable': !!editConfig,
@@ -8856,95 +9007,15 @@ export default defineComponent({
8856
9007
  h('div', {
8857
9008
  key: 'tw',
8858
9009
  class: 'vxe-table--render-wrapper'
8859
- }, [
8860
- h('div', {
8861
- ref: refTableViewportElem,
8862
- class: 'vxe-table--viewport-wrapper'
8863
- }, [
8864
- h('div', {
8865
- class: 'vxe-table--main-wrapper'
8866
- }, [
8867
- /**
8868
- * 表头
8869
- */
8870
- showHeader
8871
- ? h(TableHeaderComponent, {
8872
- ref: refTableHeader,
8873
- tableData,
8874
- tableColumn,
8875
- tableGroupColumn
8876
- })
8877
- : renderEmptyElement($xeTable),
8878
- /**
8879
- * 表体
8880
- */
8881
- h(TableBodyComponent, {
8882
- ref: refTableBody,
8883
- tableData,
8884
- tableColumn
8885
- }),
8886
- /**
8887
- * 表尾
8888
- */
8889
- showFooter
8890
- ? h(TableFooterComponent, {
8891
- ref: refTableFooter,
8892
- footerTableData,
8893
- tableColumn
8894
- })
8895
- : renderEmptyElement($xeTable)
8896
- ]),
8897
- h('div', {
8898
- class: 'vxe-table--fixed-wrapper'
8899
- }, [
8900
- leftList && leftList.length && overflowX ? renderFixed('left') : renderEmptyElement($xeTable),
8901
- rightList && rightList.length && overflowX ? renderFixed('right') : renderEmptyElement($xeTable)
8902
- ])
8903
- ]),
8904
- h('div', {
8905
- ref: refScrollYVirtualElem,
8906
- class: 'vxe-table--scroll-y-virtual'
8907
- }, [
8908
- h('div', {
8909
- ref: refScrollYTopCornerElem,
8910
- class: 'vxe-table--scroll-y-top-corner'
8911
- }),
8912
- h('div', {
8913
- ref: refScrollYHandleElem,
8914
- class: 'vxe-table--scroll-y-handle',
8915
- onScroll: scrollYEvent
8916
- }, [
8917
- h('div', {
8918
- ref: refScrollYSpaceElem,
8919
- class: 'vxe-table--scroll-y-space'
8920
- })
9010
+ }, scrollbarXToTop
9011
+ ? [
9012
+ renderScrollX(),
9013
+ renderBody()
9014
+ ]
9015
+ : [
9016
+ renderBody(),
9017
+ renderScrollX()
8921
9018
  ]),
8922
- h('div', {
8923
- ref: refScrollYBottomCornerElem,
8924
- class: 'vxe-table--scroll-y-bottom-corner'
8925
- })
8926
- ])
8927
- ]),
8928
- h('div', {
8929
- key: 'vx',
8930
- ref: refScrollXVirtualElem,
8931
- class: 'vxe-table--scroll-x-virtual'
8932
- }, [
8933
- h('div', {
8934
- ref: refScrollXHandleElem,
8935
- class: 'vxe-table--scroll-x-handle',
8936
- onScroll: scrollXEvent
8937
- }, [
8938
- h('div', {
8939
- ref: refScrollXSpaceElem,
8940
- class: 'vxe-table--scroll-x-space'
8941
- })
8942
- ]),
8943
- h('div', {
8944
- ref: refScrollXRightCornerElem,
8945
- class: 'vxe-table--scroll-x-right-corner'
8946
- })
8947
- ]),
8948
9019
  /**
8949
9020
  * 空数据
8950
9021
  */
@@ -8970,12 +9041,7 @@ export default defineComponent({
8970
9041
  h('div', {
8971
9042
  key: 'cl',
8972
9043
  ref: refCellResizeBar,
8973
- class: 'vxe-table--resizable-bar',
8974
- style: overflowX
8975
- ? {
8976
- 'padding-bottom': `${scrollbarHeight}px`
8977
- }
8978
- : null
9044
+ class: 'vxe-table--resizable-bar'
8979
9045
  }, resizableOpts.showDragTip
8980
9046
  ? [
8981
9047
  h('div', {
@@ -9164,18 +9230,39 @@ export default defineComponent({
9164
9230
  })
9165
9231
  })
9166
9232
 
9233
+ const reScrollFlag = ref(0)
9234
+ watch(computeSize, () => {
9235
+ reScrollFlag.value++
9236
+ })
9167
9237
  watch(() => props.showHeader, () => {
9168
- nextTick(() => {
9169
- tableMethods.recalculate(true).then(() => tableMethods.refreshScroll())
9170
- })
9238
+ reScrollFlag.value++
9171
9239
  })
9172
-
9173
9240
  watch(() => props.showFooter, () => {
9241
+ reScrollFlag.value++
9242
+ })
9243
+ watch(reScrollFlag, () => {
9174
9244
  nextTick(() => {
9175
9245
  tableMethods.recalculate(true).then(() => tableMethods.refreshScroll())
9176
9246
  })
9177
9247
  })
9178
9248
 
9249
+ const reLayoutFlag = ref(0)
9250
+ watch(() => props.height, () => {
9251
+ reLayoutFlag.value++
9252
+ })
9253
+ watch(() => props.maxHeight, () => {
9254
+ reLayoutFlag.value++
9255
+ })
9256
+ watch(computeScrollbarXToTop, () => {
9257
+ reLayoutFlag.value++
9258
+ })
9259
+ watch(computeScrollbarYToLeft, () => {
9260
+ reLayoutFlag.value++
9261
+ })
9262
+ watch(reLayoutFlag, () => {
9263
+ nextTick(() => tableMethods.recalculate(true))
9264
+ })
9265
+
9179
9266
  const footFlag = ref(0)
9180
9267
  watch(() => props.footerData ? props.footerData.length : -1, () => {
9181
9268
  footFlag.value++
@@ -9187,20 +9274,6 @@ export default defineComponent({
9187
9274
  tableMethods.updateFooter()
9188
9275
  })
9189
9276
 
9190
- watch(() => props.height, () => {
9191
- nextTick(() => tableMethods.recalculate(true))
9192
- })
9193
-
9194
- watch(() => props.maxHeight, () => {
9195
- nextTick(() => tableMethods.recalculate(true))
9196
- })
9197
-
9198
- watch(computeSize, () => {
9199
- nextTick(() => {
9200
- tableMethods.recalculate(true).then(() => tableMethods.refreshScroll())
9201
- })
9202
- })
9203
-
9204
9277
  watch(() => props.syncResize, (value) => {
9205
9278
  if (value) {
9206
9279
  handleUupdateResize()