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
@@ -1806,80 +1806,132 @@ const Methods = {
1806
1806
  * 设置为固定列
1807
1807
  */
1808
1808
  setColumnFixed(fieldOrColumn, fixed) {
1809
- const { isMaxFixedColumn, columnOpts } = this;
1810
- const column = handleFieldOrColumn(this, fieldOrColumn);
1811
- const targetColumn = getRootColumn(this, column);
1812
- if (targetColumn && targetColumn.fixed !== fixed) {
1813
- // 是否超过最大固定列数量
1814
- if (!targetColumn.fixed && isMaxFixedColumn) {
1815
- if (VxeUI.modal) {
1816
- VxeUI.modal.message({
1817
- status: 'error',
1818
- content: getI18n('vxe.table.maxFixedCol', [columnOpts.maxFixedSize])
1819
- });
1809
+ const $xeTable = this;
1810
+ let status = false;
1811
+ const cols = XEUtils.isArray(fieldOrColumn) ? fieldOrColumn : [fieldOrColumn];
1812
+ const columnOpts = $xeTable.computeColumnOpts;
1813
+ const isMaxFixedColumn = $xeTable.computeIsMaxFixedColumn;
1814
+ for (let i = 0; i < cols.length; i++) {
1815
+ const item = cols[i];
1816
+ const column = handleFieldOrColumn($xeTable, item);
1817
+ const targetColumn = getRootColumn($xeTable, column);
1818
+ if (targetColumn && targetColumn.fixed !== fixed) {
1819
+ // 是否超过最大固定列数量
1820
+ if (!targetColumn.fixed && isMaxFixedColumn) {
1821
+ if (VxeUI.modal) {
1822
+ VxeUI.modal.message({
1823
+ status: 'error',
1824
+ content: getI18n('vxe.table.maxFixedCol', [columnOpts.maxFixedSize])
1825
+ });
1826
+ }
1827
+ return $xeTable.$nextTick();
1828
+ }
1829
+ XEUtils.eachTree([targetColumn], (column) => {
1830
+ column.fixed = fixed;
1831
+ });
1832
+ $xeTable.saveCustomStore('update:fixed');
1833
+ if (!status) {
1834
+ status = true;
1820
1835
  }
1821
- return this.$nextTick();
1822
1836
  }
1823
- XEUtils.eachTree([targetColumn], (column) => {
1824
- column.fixed = fixed;
1825
- });
1826
- this.saveCustomStore('update:fixed');
1827
- return this.refreshColumn();
1828
1837
  }
1829
- return this.$nextTick();
1838
+ if (status) {
1839
+ return $xeTable.refreshColumn();
1840
+ }
1841
+ return $xeTable.$nextTick();
1830
1842
  },
1831
1843
  /**
1832
1844
  * 取消指定固定列
1833
1845
  */
1834
1846
  clearColumnFixed(fieldOrColumn) {
1835
- const column = handleFieldOrColumn(this, fieldOrColumn);
1836
- const targetColumn = getRootColumn(this, column);
1837
- if (targetColumn && targetColumn.fixed) {
1838
- XEUtils.eachTree([targetColumn], (column) => {
1839
- column.fixed = null;
1840
- });
1841
- this.saveCustomStore('update:fixed');
1842
- return this.refreshColumn();
1847
+ const $xeTable = this;
1848
+ let status = false;
1849
+ const cols = XEUtils.isArray(fieldOrColumn) ? fieldOrColumn : [fieldOrColumn];
1850
+ cols.forEach(item => {
1851
+ const column = handleFieldOrColumn($xeTable, item);
1852
+ const targetColumn = getRootColumn($xeTable, column);
1853
+ if (targetColumn && targetColumn.fixed) {
1854
+ XEUtils.eachTree([targetColumn], (column) => {
1855
+ column.fixed = null;
1856
+ });
1857
+ $xeTable.saveCustomStore('update:fixed');
1858
+ if (!status) {
1859
+ status = true;
1860
+ }
1861
+ }
1862
+ });
1863
+ if (status) {
1864
+ return $xeTable.refreshColumn();
1843
1865
  }
1844
- return this.$nextTick();
1866
+ return $xeTable.$nextTick();
1845
1867
  },
1846
1868
  /**
1847
1869
  * 隐藏指定列
1848
1870
  */
1849
1871
  hideColumn(fieldOrColumn) {
1850
- const column = handleFieldOrColumn(this, fieldOrColumn);
1851
- if (column && column.visible) {
1852
- column.visible = false;
1853
- return this.handleCustom();
1872
+ const $xeTable = this;
1873
+ let status = false;
1874
+ const cols = XEUtils.isArray(fieldOrColumn) ? fieldOrColumn : [fieldOrColumn];
1875
+ cols.forEach(item => {
1876
+ const column = handleFieldOrColumn($xeTable, item);
1877
+ if (column && column.visible) {
1878
+ column.visible = false;
1879
+ if (!status) {
1880
+ status = true;
1881
+ }
1882
+ }
1883
+ });
1884
+ if (status) {
1885
+ return $xeTable.handleCustom();
1854
1886
  }
1855
- return this.$nextTick();
1887
+ return $xeTable.$nextTick();
1856
1888
  },
1857
1889
  /**
1858
1890
  * 显示指定列
1859
1891
  */
1860
1892
  showColumn(fieldOrColumn) {
1861
- const column = handleFieldOrColumn(this, fieldOrColumn);
1862
- if (column && !column.visible) {
1863
- column.visible = true;
1864
- return this.handleCustom();
1893
+ const $xeTable = this;
1894
+ let status = false;
1895
+ const cols = XEUtils.isArray(fieldOrColumn) ? fieldOrColumn : [fieldOrColumn];
1896
+ cols.forEach(item => {
1897
+ const column = handleFieldOrColumn($xeTable, item);
1898
+ if (column && !column.visible) {
1899
+ column.visible = true;
1900
+ if (!status) {
1901
+ status = true;
1902
+ }
1903
+ }
1904
+ });
1905
+ if (status) {
1906
+ return $xeTable.handleCustom();
1865
1907
  }
1866
- return this.$nextTick();
1908
+ return $xeTable.$nextTick();
1867
1909
  },
1868
1910
  setColumnWidth(fieldOrColumn, width) {
1869
- const column = handleFieldOrColumn(this, fieldOrColumn);
1870
- if (column) {
1871
- const colWidth = XEUtils.toInteger(width);
1872
- let rdWidth = colWidth;
1873
- if (isScale(width)) {
1874
- const { tableBody } = this.$refs;
1875
- const tableBodyElem = tableBody ? tableBody.$el : null;
1876
- const bodyWidth = tableBodyElem ? tableBodyElem.clientWidth - 1 : 0;
1877
- rdWidth = Math.floor(colWidth * bodyWidth);
1911
+ const $xeTable = this;
1912
+ let status = false;
1913
+ const cols = XEUtils.isArray(fieldOrColumn) ? fieldOrColumn : [fieldOrColumn];
1914
+ cols.forEach(item => {
1915
+ const column = handleFieldOrColumn($xeTable, item);
1916
+ if (column) {
1917
+ const colWidth = XEUtils.toInteger(width);
1918
+ let rdWidth = colWidth;
1919
+ if (isScale(width)) {
1920
+ const tableBody = $xeTable.$refs.tableBody;
1921
+ const bodyElem = tableBody ? tableBody.$el : null;
1922
+ const bodyWidth = bodyElem ? bodyElem.clientWidth - 1 : 0;
1923
+ rdWidth = Math.floor(colWidth * bodyWidth);
1924
+ }
1925
+ column.resizeWidth = rdWidth;
1926
+ if (!status) {
1927
+ status = true;
1928
+ }
1878
1929
  }
1879
- column.resizeWidth = rdWidth;
1880
- return this.refreshColumn();
1930
+ });
1931
+ if (status) {
1932
+ return $xeTable.refreshColumn();
1881
1933
  }
1882
- return this.$nextTick();
1934
+ return $xeTable.$nextTick();
1883
1935
  },
1884
1936
  getColumnWidth(fieldOrColumn) {
1885
1937
  const column = handleFieldOrColumn(this, fieldOrColumn);
@@ -5632,15 +5684,84 @@ const Methods = {
5632
5684
  }
5633
5685
  this.closeTooltip();
5634
5686
  },
5635
- handleScrollEvent(evnt, isRollY, isRollX, params) {
5687
+ handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, params) {
5636
5688
  const $xeTable = this;
5637
5689
  const props = $xeTable;
5690
+ const reactData = $xeTable;
5691
+ const internalData = $xeTable;
5638
5692
  const { highlightHoverRow } = props;
5693
+ const { lastScrollLeft, lastScrollTop } = internalData;
5639
5694
  const tableBody = $xeTable.$refs.tableBody;
5640
5695
  const bodyElem = tableBody ? tableBody.$el : null;
5641
5696
  const rowOpts = $xeTable.computeRowOpts;
5642
5697
  const validTip = $xeTable.$refs.validTip;
5643
5698
  const tooltip = $xeTable.$refs.tooltip;
5699
+ const bodyHeight = bodyElem ? bodyElem.clientHeight : 0;
5700
+ const bodyWidth = bodyElem ? bodyElem.clientWidth : 0;
5701
+ const scrollHeight = bodyElem ? bodyElem.scrollHeight : 0;
5702
+ const scrollWidth = bodyElem ? bodyElem.scrollWidth : 0;
5703
+ let isTop = false;
5704
+ let isBottom = false;
5705
+ let isLeft = false;
5706
+ let isRight = false;
5707
+ let direction = '';
5708
+ let isTopBoundary = false;
5709
+ let isBottomBoundary = false;
5710
+ let isLeftBoundary = false;
5711
+ let isRightBoundary = false;
5712
+ if (isRollX) {
5713
+ const xThreshold = $xeTable.computeScrollXThreshold;
5714
+ isLeft = scrollLeft <= 0;
5715
+ if (!isLeft) {
5716
+ isRight = scrollLeft + bodyWidth >= scrollWidth;
5717
+ }
5718
+ if (scrollLeft > lastScrollLeft) {
5719
+ direction = 'right';
5720
+ if (scrollLeft + bodyWidth >= scrollWidth - xThreshold) {
5721
+ isRightBoundary = true;
5722
+ }
5723
+ }
5724
+ else {
5725
+ direction = 'left';
5726
+ if (scrollLeft <= xThreshold) {
5727
+ isLeftBoundary = true;
5728
+ }
5729
+ }
5730
+ $xeTable.checkScrolling();
5731
+ internalData.lastScrollLeft = scrollLeft;
5732
+ reactData.lastScrollTime = Date.now();
5733
+ }
5734
+ else {
5735
+ const yThreshold = $xeTable.computeScrollYThreshold;
5736
+ isTop = scrollTop <= 0;
5737
+ if (!isTop) {
5738
+ isBottom = scrollTop + bodyHeight >= scrollHeight;
5739
+ }
5740
+ if (scrollTop > lastScrollTop) {
5741
+ direction = 'bottom';
5742
+ if (scrollTop + bodyHeight >= scrollHeight - yThreshold) {
5743
+ isBottomBoundary = true;
5744
+ }
5745
+ }
5746
+ else {
5747
+ direction = 'top';
5748
+ if (scrollTop <= yThreshold) {
5749
+ isTopBoundary = true;
5750
+ }
5751
+ }
5752
+ internalData.lastScrollTop = scrollTop;
5753
+ reactData.lastScrollTime = Date.now();
5754
+ }
5755
+ const evntParams = Object.assign({ scrollTop,
5756
+ scrollLeft,
5757
+ bodyHeight,
5758
+ bodyWidth,
5759
+ scrollHeight,
5760
+ scrollWidth, isX: isRollX, isY: isRollY, isTop,
5761
+ isBottom,
5762
+ isLeft,
5763
+ isRight,
5764
+ direction }, params);
5644
5765
  if (rowOpts.isHover || highlightHoverRow) {
5645
5766
  $xeTable.clearHoverRow();
5646
5767
  }
@@ -5650,17 +5771,9 @@ const Methods = {
5650
5771
  if (tooltip && tooltip.visible) {
5651
5772
  tooltip.close();
5652
5773
  }
5653
- if (isRollX) {
5654
- $xeTable.checkScrolling();
5774
+ if (isBottomBoundary || isTopBoundary || isRightBoundary || isLeftBoundary) {
5775
+ $xeTable.dispatchEvent('scroll-boundary', evntParams, evnt);
5655
5776
  }
5656
- const bodyHeight = bodyElem ? bodyElem.clientHeight : 0;
5657
- const bodyWidth = bodyElem ? bodyElem.clientWidth : 0;
5658
- const scrollHeight = bodyElem ? bodyElem.scrollHeight : 0;
5659
- const scrollWidth = bodyElem ? bodyElem.scrollWidth : 0;
5660
- const evntParams = Object.assign({ bodyHeight,
5661
- bodyWidth,
5662
- scrollHeight,
5663
- scrollWidth, isX: isRollX, isY: isRollY }, params);
5664
5777
  $xeTable.dispatchEvent('scroll', evntParams, evnt);
5665
5778
  },
5666
5779
  /**
@@ -5689,8 +5802,6 @@ const Methods = {
5689
5802
  const bodyElem = tableBody.$el;
5690
5803
  const headerElem = tableHeader ? tableHeader.$el : null;
5691
5804
  const footerElem = tableFooter ? tableFooter.$el : null;
5692
- $xeTable.lastScrollLeft = scrollLeft;
5693
- $xeTable.lastScrollTime = Date.now();
5694
5805
  setScrollLeft(bodyElem, scrollLeft);
5695
5806
  setScrollLeft(headerElem, scrollLeft);
5696
5807
  setScrollLeft(footerElem, scrollLeft);
@@ -5701,15 +5812,11 @@ const Methods = {
5701
5812
  const { scrollTop, scrollLeft } = wrapperEl;
5702
5813
  const isRollX = true;
5703
5814
  const isRollY = false;
5704
- $xeTable.lastScrollLeft = scrollLeft;
5705
- $xeTable.lastScrollTime = Date.now();
5706
5815
  $xeTable.handleSyncScrollX(scrollLeft);
5707
5816
  $xeTable.triggerScrollXEvent(evnt);
5708
- $xeTable.handleScrollEvent(evnt, isRollY, isRollX, {
5817
+ $xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
5709
5818
  type: 'table',
5710
- fixed: '',
5711
- scrollTop,
5712
- scrollLeft
5819
+ fixed: ''
5713
5820
  });
5714
5821
  },
5715
5822
  debounceScrollYCalculate: XEUtils.debounce(function () {
@@ -5723,8 +5830,6 @@ const Methods = {
5723
5830
  const bodyElem = tableBody.$el;
5724
5831
  const leftElem = leftBody ? leftBody.$el : null;
5725
5832
  const rightElem = rightBody ? rightBody.$el : null;
5726
- $xeTable.lastScrollTop = scrollTop;
5727
- $xeTable.lastScrollTime = Date.now();
5728
5833
  setScrollTop(bodyElem, scrollTop);
5729
5834
  setScrollTop(leftElem, scrollTop);
5730
5835
  setScrollTop(rightElem, scrollTop);
@@ -5735,15 +5840,11 @@ const Methods = {
5735
5840
  const { scrollTop, scrollLeft } = wrapperEl;
5736
5841
  const isRollX = false;
5737
5842
  const isRollY = true;
5738
- $xeTable.lastScrollTop = scrollTop;
5739
- $xeTable.lastScrollTime = Date.now();
5740
5843
  $xeTable.handleSyncScrollY(scrollTop);
5741
5844
  $xeTable.triggerScrollYEvent(evnt);
5742
- $xeTable.handleScrollEvent(evnt, isRollY, isRollX, {
5845
+ $xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
5743
5846
  type: 'table',
5744
- fixed: '',
5745
- scrollTop,
5746
- scrollLeft
5847
+ fixed: ''
5747
5848
  });
5748
5849
  },
5749
5850
  /**
@@ -5939,16 +6040,35 @@ const Methods = {
5939
6040
  * @param {Number} scrollTop 上距离
5940
6041
  */
5941
6042
  scrollTo(scrollLeft, scrollTop) {
6043
+ const $xeTable = this;
5942
6044
  const { $refs } = this;
5943
- const { tableBody, rightBody, tableFooter } = $refs;
6045
+ const { tableBody, tableHeader, leftBody, rightBody, tableFooter } = $refs;
5944
6046
  const tableBodyElem = tableBody ? tableBody.$el : null;
6047
+ const leftBodyElem = leftBody ? leftBody.$el : null;
5945
6048
  const rightBodyElem = rightBody ? rightBody.$el : null;
6049
+ const tableHeaderElem = tableHeader ? tableHeader.$el : null;
5946
6050
  const tableFooterElem = tableFooter ? tableFooter.$el : null;
5947
6051
  if (XEUtils.isNumber(scrollLeft)) {
5948
- setScrollLeft(tableFooterElem || tableBodyElem, scrollLeft);
6052
+ const xHandleEl = $xeTable.$refs.refScrollXHandleElem;
6053
+ if (xHandleEl) {
6054
+ setScrollLeft(xHandleEl, scrollLeft);
6055
+ }
6056
+ else {
6057
+ setScrollLeft(tableBodyElem, scrollLeft);
6058
+ setScrollLeft(tableHeaderElem, scrollLeft);
6059
+ setScrollLeft(tableFooterElem, scrollLeft);
6060
+ }
5949
6061
  }
5950
6062
  if (XEUtils.isNumber(scrollTop)) {
5951
- setScrollTop(rightBodyElem || tableBodyElem, scrollTop);
6063
+ const yHandleEl = $xeTable.$refs.refScrollYHandleElem;
6064
+ if (yHandleEl) {
6065
+ setScrollTop(yHandleEl, scrollTop);
6066
+ }
6067
+ else {
6068
+ setScrollTop(tableBodyElem, scrollTop);
6069
+ setScrollTop(leftBodyElem, scrollTop);
6070
+ setScrollTop(rightBodyElem, scrollTop);
6071
+ }
5952
6072
  }
5953
6073
  if (this.scrollXLoad || this.scrollYLoad) {
5954
6074
  return new Promise(resolve => setTimeout(() => resolve(this.$nextTick()), 50));
@@ -373,12 +373,30 @@ export default {
373
373
  computeSXOpts() {
374
374
  return Object.assign({}, getConfig().table.scrollX, this.scrollX);
375
375
  },
376
+ computeScrollXThreshold() {
377
+ const $xeTable = this;
378
+ const sXOpts = $xeTable.computeSXOpts;
379
+ const { threshold } = sXOpts;
380
+ if (threshold) {
381
+ return XEUtils.toNumber(threshold);
382
+ }
383
+ return 0;
384
+ },
376
385
  sYOpts() {
377
386
  return this.computeSYOpts;
378
387
  },
379
388
  computeSYOpts() {
380
389
  return Object.assign({}, getConfig().table.scrollY, this.scrollY);
381
390
  },
391
+ computeScrollYThreshold() {
392
+ const $xeTable = this;
393
+ const sYOpts = $xeTable.computeSYOpts;
394
+ const { threshold } = sYOpts;
395
+ if (threshold) {
396
+ return XEUtils.toNumber(threshold);
397
+ }
398
+ return 0;
399
+ },
382
400
  rowHeightMaps() {
383
401
  return {
384
402
  default: 48,
package/es/ui/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { VxeUI } from '@vxe-ui/core';
2
2
  import { getFuncText } from './src/utils';
3
- export const version = "3.10.8";
3
+ export const version = "3.10.10";
4
4
  VxeUI.version = version;
5
5
  VxeUI.tableVersion = version;
6
6
  VxeUI.setConfig({
package/es/ui/src/log.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { VxeUI } from '@vxe-ui/core';
2
2
  const { log } = VxeUI;
3
- const version = `table v${"3.10.8"}`;
3
+ const version = `table v${"3.10.10"}`;
4
4
  export const warnLog = log.create('warn', version);
5
5
  export const errLog = log.create('error', version);