vxe-table 3.10.8 → 3.10.10

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 (33) hide show
  1. package/es/style.css +1 -1
  2. package/es/table/src/body.js +4 -12
  3. package/es/table/src/footer.js +2 -6
  4. package/es/table/src/methods.js +199 -79
  5. package/es/table/src/table.js +18 -0
  6. package/es/ui/index.js +1 -1
  7. package/es/ui/src/log.js +1 -1
  8. package/lib/index.umd.js +231 -105
  9. package/lib/index.umd.min.js +1 -1
  10. package/lib/style.css +1 -1
  11. package/lib/table/src/body.js +4 -12
  12. package/lib/table/src/body.min.js +1 -1
  13. package/lib/table/src/footer.js +2 -6
  14. package/lib/table/src/footer.min.js +1 -1
  15. package/lib/table/src/methods.js +202 -86
  16. package/lib/table/src/methods.min.js +1 -1
  17. package/lib/table/src/table.js +22 -0
  18. package/lib/table/src/table.min.js +1 -1
  19. package/lib/ui/index.js +1 -1
  20. package/lib/ui/index.min.js +1 -1
  21. package/lib/ui/src/log.js +1 -1
  22. package/lib/ui/src/log.min.js +1 -1
  23. package/package.json +2 -2
  24. package/packages/table/src/body.ts +4 -12
  25. package/packages/table/src/footer.ts +2 -6
  26. package/packages/table/src/methods.ts +204 -81
  27. package/packages/table/src/table.ts +20 -0
  28. /package/es/{iconfont.1731060585164.ttf → iconfont.1731289527548.ttf} +0 -0
  29. /package/es/{iconfont.1731060585164.woff → iconfont.1731289527548.woff} +0 -0
  30. /package/es/{iconfont.1731060585164.woff2 → iconfont.1731289527548.woff2} +0 -0
  31. /package/lib/{iconfont.1731060585164.ttf → iconfont.1731289527548.ttf} +0 -0
  32. /package/lib/{iconfont.1731060585164.woff → iconfont.1731289527548.woff} +0 -0
  33. /package/lib/{iconfont.1731060585164.woff2 → iconfont.1731289527548.woff2} +0 -0
@@ -1808,80 +1808,137 @@ const Methods = {
1808
1808
  * 设置为固定列
1809
1809
  */
1810
1810
  setColumnFixed (fieldOrColumn: any, fixed: any) {
1811
- const { isMaxFixedColumn, columnOpts } = this
1812
- const column = handleFieldOrColumn(this, fieldOrColumn)
1813
- const targetColumn = getRootColumn(this, column)
1814
- if (targetColumn && targetColumn.fixed !== fixed) {
1815
- // 是否超过最大固定列数量
1816
- if (!targetColumn.fixed && isMaxFixedColumn) {
1817
- if (VxeUI.modal) {
1818
- VxeUI.modal.message({
1819
- status: 'error',
1820
- content: getI18n('vxe.table.maxFixedCol', [columnOpts.maxFixedSize])
1821
- })
1811
+ const $xeTable = this
1812
+
1813
+ let status = false
1814
+ const cols = XEUtils.isArray(fieldOrColumn) ? fieldOrColumn : [fieldOrColumn]
1815
+ const columnOpts = $xeTable.computeColumnOpts
1816
+ const isMaxFixedColumn = $xeTable.computeIsMaxFixedColumn
1817
+ for (let i = 0; i < cols.length; i++) {
1818
+ const item = cols[i]
1819
+ const column = handleFieldOrColumn($xeTable, item)
1820
+ const targetColumn = getRootColumn($xeTable, column as any)
1821
+ if (targetColumn && targetColumn.fixed !== fixed) {
1822
+ // 是否超过最大固定列数量
1823
+ if (!targetColumn.fixed && isMaxFixedColumn) {
1824
+ if (VxeUI.modal) {
1825
+ VxeUI.modal.message({
1826
+ status: 'error',
1827
+ content: getI18n('vxe.table.maxFixedCol', [columnOpts.maxFixedSize])
1828
+ })
1829
+ }
1830
+ return $xeTable.$nextTick()
1831
+ }
1832
+ XEUtils.eachTree([targetColumn], (column) => {
1833
+ column.fixed = fixed
1834
+ })
1835
+ $xeTable.saveCustomStore('update:fixed')
1836
+ if (!status) {
1837
+ status = true
1822
1838
  }
1823
- return this.$nextTick()
1824
1839
  }
1825
- XEUtils.eachTree([targetColumn], (column) => {
1826
- column.fixed = fixed
1827
- })
1828
- this.saveCustomStore('update:fixed')
1829
- return this.refreshColumn()
1830
1840
  }
1831
- return this.$nextTick()
1841
+ if (status) {
1842
+ return $xeTable.refreshColumn()
1843
+ }
1844
+ return $xeTable.$nextTick()
1832
1845
  },
1833
1846
  /**
1834
1847
  * 取消指定固定列
1835
1848
  */
1836
1849
  clearColumnFixed (fieldOrColumn: any) {
1837
- const column = handleFieldOrColumn(this, fieldOrColumn)
1838
- const targetColumn = getRootColumn(this, column)
1839
- if (targetColumn && targetColumn.fixed) {
1840
- XEUtils.eachTree([targetColumn], (column) => {
1841
- column.fixed = null
1842
- })
1843
- this.saveCustomStore('update:fixed')
1844
- return this.refreshColumn()
1850
+ const $xeTable = this
1851
+
1852
+ let status = false
1853
+ const cols = XEUtils.isArray(fieldOrColumn) ? fieldOrColumn : [fieldOrColumn]
1854
+ cols.forEach(item => {
1855
+ const column = handleFieldOrColumn($xeTable, item)
1856
+ const targetColumn = getRootColumn($xeTable, column as any)
1857
+ if (targetColumn && targetColumn.fixed) {
1858
+ XEUtils.eachTree([targetColumn], (column) => {
1859
+ column.fixed = null
1860
+ })
1861
+ $xeTable.saveCustomStore('update:fixed')
1862
+ if (!status) {
1863
+ status = true
1864
+ }
1865
+ }
1866
+ })
1867
+ if (status) {
1868
+ return $xeTable.refreshColumn()
1845
1869
  }
1846
- return this.$nextTick()
1870
+ return $xeTable.$nextTick()
1847
1871
  },
1848
1872
  /**
1849
1873
  * 隐藏指定列
1850
1874
  */
1851
1875
  hideColumn (fieldOrColumn: any) {
1852
- const column = handleFieldOrColumn(this, fieldOrColumn)
1853
- if (column && column.visible) {
1854
- column.visible = false
1855
- return this.handleCustom()
1876
+ const $xeTable = this
1877
+
1878
+ let status = false
1879
+ const cols = XEUtils.isArray(fieldOrColumn) ? fieldOrColumn : [fieldOrColumn]
1880
+ cols.forEach(item => {
1881
+ const column = handleFieldOrColumn($xeTable, item)
1882
+ if (column && column.visible) {
1883
+ column.visible = false
1884
+ if (!status) {
1885
+ status = true
1886
+ }
1887
+ }
1888
+ })
1889
+ if (status) {
1890
+ return $xeTable.handleCustom()
1856
1891
  }
1857
- return this.$nextTick()
1892
+ return $xeTable.$nextTick()
1858
1893
  },
1859
1894
  /**
1860
1895
  * 显示指定列
1861
1896
  */
1862
1897
  showColumn (fieldOrColumn: any) {
1863
- const column = handleFieldOrColumn(this, fieldOrColumn)
1864
- if (column && !column.visible) {
1865
- column.visible = true
1866
- return this.handleCustom()
1898
+ const $xeTable = this
1899
+
1900
+ let status = false
1901
+ const cols = XEUtils.isArray(fieldOrColumn) ? fieldOrColumn : [fieldOrColumn]
1902
+ cols.forEach(item => {
1903
+ const column = handleFieldOrColumn($xeTable, item)
1904
+ if (column && !column.visible) {
1905
+ column.visible = true
1906
+ if (!status) {
1907
+ status = true
1908
+ }
1909
+ }
1910
+ })
1911
+ if (status) {
1912
+ return $xeTable.handleCustom()
1867
1913
  }
1868
- return this.$nextTick()
1914
+ return $xeTable.$nextTick()
1869
1915
  },
1870
1916
  setColumnWidth (fieldOrColumn: any, width: any) {
1871
- const column = handleFieldOrColumn(this, fieldOrColumn)
1872
- if (column) {
1873
- const colWidth = XEUtils.toInteger(width)
1874
- let rdWidth = colWidth
1875
- if (isScale(width)) {
1876
- const { tableBody } = this.$refs
1877
- const tableBodyElem = tableBody ? tableBody.$el : null
1878
- const bodyWidth = tableBodyElem ? tableBodyElem.clientWidth - 1 : 0
1879
- rdWidth = Math.floor(colWidth * bodyWidth)
1917
+ const $xeTable = this
1918
+
1919
+ let status = false
1920
+ const cols = XEUtils.isArray(fieldOrColumn) ? fieldOrColumn : [fieldOrColumn]
1921
+ cols.forEach(item => {
1922
+ const column = handleFieldOrColumn($xeTable, item)
1923
+ if (column) {
1924
+ const colWidth = XEUtils.toInteger(width)
1925
+ let rdWidth = colWidth
1926
+ if (isScale(width)) {
1927
+ const tableBody = $xeTable.$refs.tableBody
1928
+ const bodyElem = tableBody ? tableBody.$el as HTMLDivElement : null
1929
+ const bodyWidth = bodyElem ? bodyElem.clientWidth - 1 : 0
1930
+ rdWidth = Math.floor(colWidth * bodyWidth)
1931
+ }
1932
+ column.resizeWidth = rdWidth
1933
+ if (!status) {
1934
+ status = true
1935
+ }
1880
1936
  }
1881
- column.resizeWidth = rdWidth
1882
- return this.refreshColumn()
1937
+ })
1938
+ if (status) {
1939
+ return $xeTable.refreshColumn()
1883
1940
  }
1884
- return this.$nextTick()
1941
+ return $xeTable.$nextTick()
1885
1942
  },
1886
1943
  getColumnWidth (fieldOrColumn: any) {
1887
1944
  const column = handleFieldOrColumn(this, fieldOrColumn)
@@ -5594,41 +5651,101 @@ const Methods = {
5594
5651
  }
5595
5652
  this.closeTooltip()
5596
5653
  },
5597
- handleScrollEvent (evnt: Event, isRollY: boolean, isRollX: boolean, params: any) {
5654
+ handleScrollEvent (evnt: Event, isRollY: boolean, isRollX: boolean, scrollTop: number, scrollLeft: number, params: any) {
5598
5655
  const $xeTable = this
5599
5656
  const props = $xeTable
5657
+ const reactData = $xeTable
5658
+ const internalData = $xeTable
5600
5659
 
5601
5660
  const { highlightHoverRow } = props
5661
+ const { lastScrollLeft, lastScrollTop } = internalData
5602
5662
  const tableBody = $xeTable.$refs.tableBody
5603
5663
  const bodyElem = tableBody ? tableBody.$el as HTMLDivElement : null
5604
5664
  const rowOpts = $xeTable.computeRowOpts
5605
5665
  const validTip = $xeTable.$refs.validTip
5606
5666
  const tooltip = $xeTable.$refs.tooltip
5607
- if (rowOpts.isHover || highlightHoverRow) {
5608
- $xeTable.clearHoverRow()
5609
- }
5610
- if (validTip && validTip.visible) {
5611
- validTip.close()
5612
- }
5613
- if (tooltip && tooltip.visible) {
5614
- tooltip.close()
5615
- }
5616
- if (isRollX) {
5617
- $xeTable.checkScrolling()
5618
- }
5619
5667
  const bodyHeight = bodyElem ? bodyElem.clientHeight : 0
5620
5668
  const bodyWidth = bodyElem ? bodyElem.clientWidth : 0
5621
5669
  const scrollHeight = bodyElem ? bodyElem.scrollHeight : 0
5622
5670
  const scrollWidth = bodyElem ? bodyElem.scrollWidth : 0
5671
+ let isTop = false
5672
+ let isBottom = false
5673
+ let isLeft = false
5674
+ let isRight = false
5675
+ let direction = ''
5676
+ let isTopBoundary = false
5677
+ let isBottomBoundary = false
5678
+ let isLeftBoundary = false
5679
+ let isRightBoundary = false
5680
+ if (isRollX) {
5681
+ const xThreshold = $xeTable.computeScrollXThreshold
5682
+ isLeft = scrollLeft <= 0
5683
+ if (!isLeft) {
5684
+ isRight = scrollLeft + bodyWidth >= scrollWidth
5685
+ }
5686
+ if (scrollLeft > lastScrollLeft) {
5687
+ direction = 'right'
5688
+ if (scrollLeft + bodyWidth >= scrollWidth - xThreshold) {
5689
+ isRightBoundary = true
5690
+ }
5691
+ } else {
5692
+ direction = 'left'
5693
+ if (scrollLeft <= xThreshold) {
5694
+ isLeftBoundary = true
5695
+ }
5696
+ }
5697
+ $xeTable.checkScrolling()
5698
+ internalData.lastScrollLeft = scrollLeft
5699
+ reactData.lastScrollTime = Date.now()
5700
+ } else {
5701
+ const yThreshold = $xeTable.computeScrollYThreshold
5702
+ isTop = scrollTop <= 0
5703
+ if (!isTop) {
5704
+ isBottom = scrollTop + bodyHeight >= scrollHeight
5705
+ }
5706
+ if (scrollTop > lastScrollTop) {
5707
+ direction = 'bottom'
5708
+ if (scrollTop + bodyHeight >= scrollHeight - yThreshold) {
5709
+ isBottomBoundary = true
5710
+ }
5711
+ } else {
5712
+ direction = 'top'
5713
+ if (scrollTop <= yThreshold) {
5714
+ isTopBoundary = true
5715
+ }
5716
+ }
5717
+ internalData.lastScrollTop = scrollTop
5718
+ reactData.lastScrollTime = Date.now()
5719
+ }
5623
5720
  const evntParams = {
5721
+ scrollTop,
5722
+ scrollLeft,
5624
5723
  bodyHeight,
5625
5724
  bodyWidth,
5626
5725
  scrollHeight,
5627
5726
  scrollWidth,
5628
5727
  isX: isRollX,
5629
5728
  isY: isRollY,
5729
+ isTop,
5730
+ isBottom,
5731
+ isLeft,
5732
+ isRight,
5733
+ direction,
5630
5734
  ...params
5631
5735
  }
5736
+ if (rowOpts.isHover || highlightHoverRow) {
5737
+ $xeTable.clearHoverRow()
5738
+ }
5739
+ if (validTip && validTip.visible) {
5740
+ validTip.close()
5741
+ }
5742
+ if (tooltip && tooltip.visible) {
5743
+ tooltip.close()
5744
+ }
5745
+
5746
+ if (isBottomBoundary || isTopBoundary || isRightBoundary || isLeftBoundary) {
5747
+ $xeTable.dispatchEvent('scroll-boundary', evntParams, evnt)
5748
+ }
5632
5749
  $xeTable.dispatchEvent('scroll', evntParams, evnt)
5633
5750
  },
5634
5751
  /**
@@ -5657,8 +5774,6 @@ const Methods = {
5657
5774
  const bodyElem = tableBody.$el as HTMLDivElement
5658
5775
  const headerElem = tableHeader ? tableHeader.$el as HTMLDivElement : null
5659
5776
  const footerElem = tableFooter ? tableFooter.$el as HTMLDivElement : null
5660
- $xeTable.lastScrollLeft = scrollLeft
5661
- $xeTable.lastScrollTime = Date.now()
5662
5777
  setScrollLeft(bodyElem, scrollLeft)
5663
5778
  setScrollLeft(headerElem, scrollLeft)
5664
5779
  setScrollLeft(footerElem, scrollLeft)
@@ -5670,15 +5785,11 @@ const Methods = {
5670
5785
  const { scrollTop, scrollLeft } = wrapperEl
5671
5786
  const isRollX = true
5672
5787
  const isRollY = false
5673
- $xeTable.lastScrollLeft = scrollLeft
5674
- $xeTable.lastScrollTime = Date.now()
5675
5788
  $xeTable.handleSyncScrollX(scrollLeft)
5676
5789
  $xeTable.triggerScrollXEvent(evnt)
5677
- $xeTable.handleScrollEvent(evnt, isRollY, isRollX, {
5790
+ $xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
5678
5791
  type: 'table',
5679
- fixed: '',
5680
- scrollTop,
5681
- scrollLeft
5792
+ fixed: ''
5682
5793
  })
5683
5794
  },
5684
5795
  debounceScrollYCalculate: XEUtils.debounce(function () {
@@ -5693,8 +5804,6 @@ const Methods = {
5693
5804
  const bodyElem = tableBody.$el as HTMLDivElement
5694
5805
  const leftElem = leftBody ? leftBody.$el as HTMLDivElement : null
5695
5806
  const rightElem = rightBody ? rightBody.$el as HTMLDivElement : null
5696
- $xeTable.lastScrollTop = scrollTop
5697
- $xeTable.lastScrollTime = Date.now()
5698
5807
  setScrollTop(bodyElem, scrollTop)
5699
5808
  setScrollTop(leftElem, scrollTop)
5700
5809
  setScrollTop(rightElem, scrollTop)
@@ -5706,15 +5815,11 @@ const Methods = {
5706
5815
  const { scrollTop, scrollLeft } = wrapperEl
5707
5816
  const isRollX = false
5708
5817
  const isRollY = true
5709
- $xeTable.lastScrollTop = scrollTop
5710
- $xeTable.lastScrollTime = Date.now()
5711
5818
  $xeTable.handleSyncScrollY(scrollTop)
5712
5819
  $xeTable.triggerScrollYEvent(evnt)
5713
- $xeTable.handleScrollEvent(evnt, isRollY, isRollX, {
5820
+ $xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
5714
5821
  type: 'table',
5715
- fixed: '',
5716
- scrollTop,
5717
- scrollLeft
5822
+ fixed: ''
5718
5823
  })
5719
5824
  },
5720
5825
  /**
@@ -5911,16 +6016,34 @@ const Methods = {
5911
6016
  * @param {Number} scrollTop 上距离
5912
6017
  */
5913
6018
  scrollTo (scrollLeft: any, scrollTop: any) {
6019
+ const $xeTable = this
6020
+
5914
6021
  const { $refs } = this
5915
- const { tableBody, rightBody, tableFooter } = $refs
6022
+ const { tableBody, tableHeader, leftBody, rightBody, tableFooter } = $refs
5916
6023
  const tableBodyElem = tableBody ? tableBody.$el : null
6024
+ const leftBodyElem = leftBody ? leftBody.$el : null
5917
6025
  const rightBodyElem = rightBody ? rightBody.$el : null
6026
+ const tableHeaderElem = tableHeader ? tableHeader.$el : null
5918
6027
  const tableFooterElem = tableFooter ? tableFooter.$el : null
5919
6028
  if (XEUtils.isNumber(scrollLeft)) {
5920
- setScrollLeft(tableFooterElem || tableBodyElem, scrollLeft)
6029
+ const xHandleEl = $xeTable.$refs.refScrollXHandleElem
6030
+ if (xHandleEl) {
6031
+ setScrollLeft(xHandleEl, scrollLeft)
6032
+ } else {
6033
+ setScrollLeft(tableBodyElem, scrollLeft)
6034
+ setScrollLeft(tableHeaderElem, scrollLeft)
6035
+ setScrollLeft(tableFooterElem, scrollLeft)
6036
+ }
5921
6037
  }
5922
6038
  if (XEUtils.isNumber(scrollTop)) {
5923
- setScrollTop(rightBodyElem || tableBodyElem, scrollTop)
6039
+ const yHandleEl = $xeTable.$refs.refScrollYHandleElem
6040
+ if (yHandleEl) {
6041
+ setScrollTop(yHandleEl, scrollTop)
6042
+ } else {
6043
+ setScrollTop(tableBodyElem, scrollTop)
6044
+ setScrollTop(leftBodyElem, scrollTop)
6045
+ setScrollTop(rightBodyElem, scrollTop)
6046
+ }
5924
6047
  }
5925
6048
  if (this.scrollXLoad || this.scrollYLoad) {
5926
6049
  return new Promise(resolve => setTimeout(() => resolve(this.$nextTick()), 50))
@@ -384,12 +384,32 @@ export default {
384
384
  computeSXOpts () {
385
385
  return Object.assign({}, getConfig().table.scrollX, this.scrollX)
386
386
  },
387
+ computeScrollXThreshold () {
388
+ const $xeTable = this
389
+
390
+ const sXOpts = $xeTable.computeSXOpts
391
+ const { threshold } = sXOpts
392
+ if (threshold) {
393
+ return XEUtils.toNumber(threshold)
394
+ }
395
+ return 0
396
+ },
387
397
  sYOpts () {
388
398
  return this.computeSYOpts
389
399
  },
390
400
  computeSYOpts () {
391
401
  return Object.assign({}, getConfig().table.scrollY, this.scrollY)
392
402
  },
403
+ computeScrollYThreshold () {
404
+ const $xeTable = this
405
+
406
+ const sYOpts = $xeTable.computeSYOpts
407
+ const { threshold } = sYOpts
408
+ if (threshold) {
409
+ return XEUtils.toNumber(threshold)
410
+ }
411
+ return 0
412
+ },
393
413
  rowHeightMaps () {
394
414
  return {
395
415
  default: 48,