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
@@ -2188,85 +2188,132 @@ const Methods = {
2188
2188
  * 设置为固定列
2189
2189
  */
2190
2190
  setColumnFixed(fieldOrColumn, fixed) {
2191
- const {
2192
- isMaxFixedColumn,
2193
- columnOpts
2194
- } = this;
2195
- const column = (0, _util.handleFieldOrColumn)(this, fieldOrColumn);
2196
- const targetColumn = (0, _util.getRootColumn)(this, column);
2197
- if (targetColumn && targetColumn.fixed !== fixed) {
2198
- // 是否超过最大固定列数量
2199
- if (!targetColumn.fixed && isMaxFixedColumn) {
2200
- if (_ui.VxeUI.modal) {
2201
- _ui.VxeUI.modal.message({
2202
- status: 'error',
2203
- content: getI18n('vxe.table.maxFixedCol', [columnOpts.maxFixedSize])
2204
- });
2191
+ const $xeTable = this;
2192
+ let status = false;
2193
+ const cols = _xeUtils.default.isArray(fieldOrColumn) ? fieldOrColumn : [fieldOrColumn];
2194
+ const columnOpts = $xeTable.computeColumnOpts;
2195
+ const isMaxFixedColumn = $xeTable.computeIsMaxFixedColumn;
2196
+ for (let i = 0; i < cols.length; i++) {
2197
+ const item = cols[i];
2198
+ const column = (0, _util.handleFieldOrColumn)($xeTable, item);
2199
+ const targetColumn = (0, _util.getRootColumn)($xeTable, column);
2200
+ if (targetColumn && targetColumn.fixed !== fixed) {
2201
+ // 是否超过最大固定列数量
2202
+ if (!targetColumn.fixed && isMaxFixedColumn) {
2203
+ if (_ui.VxeUI.modal) {
2204
+ _ui.VxeUI.modal.message({
2205
+ status: 'error',
2206
+ content: getI18n('vxe.table.maxFixedCol', [columnOpts.maxFixedSize])
2207
+ });
2208
+ }
2209
+ return $xeTable.$nextTick();
2210
+ }
2211
+ _xeUtils.default.eachTree([targetColumn], column => {
2212
+ column.fixed = fixed;
2213
+ });
2214
+ $xeTable.saveCustomStore('update:fixed');
2215
+ if (!status) {
2216
+ status = true;
2205
2217
  }
2206
- return this.$nextTick();
2207
2218
  }
2208
- _xeUtils.default.eachTree([targetColumn], column => {
2209
- column.fixed = fixed;
2210
- });
2211
- this.saveCustomStore('update:fixed');
2212
- return this.refreshColumn();
2213
2219
  }
2214
- return this.$nextTick();
2220
+ if (status) {
2221
+ return $xeTable.refreshColumn();
2222
+ }
2223
+ return $xeTable.$nextTick();
2215
2224
  },
2216
2225
  /**
2217
2226
  * 取消指定固定列
2218
2227
  */
2219
2228
  clearColumnFixed(fieldOrColumn) {
2220
- const column = (0, _util.handleFieldOrColumn)(this, fieldOrColumn);
2221
- const targetColumn = (0, _util.getRootColumn)(this, column);
2222
- if (targetColumn && targetColumn.fixed) {
2223
- _xeUtils.default.eachTree([targetColumn], column => {
2224
- column.fixed = null;
2225
- });
2226
- this.saveCustomStore('update:fixed');
2227
- return this.refreshColumn();
2229
+ const $xeTable = this;
2230
+ let status = false;
2231
+ const cols = _xeUtils.default.isArray(fieldOrColumn) ? fieldOrColumn : [fieldOrColumn];
2232
+ cols.forEach(item => {
2233
+ const column = (0, _util.handleFieldOrColumn)($xeTable, item);
2234
+ const targetColumn = (0, _util.getRootColumn)($xeTable, column);
2235
+ if (targetColumn && targetColumn.fixed) {
2236
+ _xeUtils.default.eachTree([targetColumn], column => {
2237
+ column.fixed = null;
2238
+ });
2239
+ $xeTable.saveCustomStore('update:fixed');
2240
+ if (!status) {
2241
+ status = true;
2242
+ }
2243
+ }
2244
+ });
2245
+ if (status) {
2246
+ return $xeTable.refreshColumn();
2228
2247
  }
2229
- return this.$nextTick();
2248
+ return $xeTable.$nextTick();
2230
2249
  },
2231
2250
  /**
2232
2251
  * 隐藏指定列
2233
2252
  */
2234
2253
  hideColumn(fieldOrColumn) {
2235
- const column = (0, _util.handleFieldOrColumn)(this, fieldOrColumn);
2236
- if (column && column.visible) {
2237
- column.visible = false;
2238
- return this.handleCustom();
2254
+ const $xeTable = this;
2255
+ let status = false;
2256
+ const cols = _xeUtils.default.isArray(fieldOrColumn) ? fieldOrColumn : [fieldOrColumn];
2257
+ cols.forEach(item => {
2258
+ const column = (0, _util.handleFieldOrColumn)($xeTable, item);
2259
+ if (column && column.visible) {
2260
+ column.visible = false;
2261
+ if (!status) {
2262
+ status = true;
2263
+ }
2264
+ }
2265
+ });
2266
+ if (status) {
2267
+ return $xeTable.handleCustom();
2239
2268
  }
2240
- return this.$nextTick();
2269
+ return $xeTable.$nextTick();
2241
2270
  },
2242
2271
  /**
2243
2272
  * 显示指定列
2244
2273
  */
2245
2274
  showColumn(fieldOrColumn) {
2246
- const column = (0, _util.handleFieldOrColumn)(this, fieldOrColumn);
2247
- if (column && !column.visible) {
2248
- column.visible = true;
2249
- return this.handleCustom();
2275
+ const $xeTable = this;
2276
+ let status = false;
2277
+ const cols = _xeUtils.default.isArray(fieldOrColumn) ? fieldOrColumn : [fieldOrColumn];
2278
+ cols.forEach(item => {
2279
+ const column = (0, _util.handleFieldOrColumn)($xeTable, item);
2280
+ if (column && !column.visible) {
2281
+ column.visible = true;
2282
+ if (!status) {
2283
+ status = true;
2284
+ }
2285
+ }
2286
+ });
2287
+ if (status) {
2288
+ return $xeTable.handleCustom();
2250
2289
  }
2251
- return this.$nextTick();
2290
+ return $xeTable.$nextTick();
2252
2291
  },
2253
2292
  setColumnWidth(fieldOrColumn, width) {
2254
- const column = (0, _util.handleFieldOrColumn)(this, fieldOrColumn);
2255
- if (column) {
2256
- const colWidth = _xeUtils.default.toInteger(width);
2257
- let rdWidth = colWidth;
2258
- if ((0, _dom.isScale)(width)) {
2259
- const {
2260
- tableBody
2261
- } = this.$refs;
2262
- const tableBodyElem = tableBody ? tableBody.$el : null;
2263
- const bodyWidth = tableBodyElem ? tableBodyElem.clientWidth - 1 : 0;
2264
- rdWidth = Math.floor(colWidth * bodyWidth);
2293
+ const $xeTable = this;
2294
+ let status = false;
2295
+ const cols = _xeUtils.default.isArray(fieldOrColumn) ? fieldOrColumn : [fieldOrColumn];
2296
+ cols.forEach(item => {
2297
+ const column = (0, _util.handleFieldOrColumn)($xeTable, item);
2298
+ if (column) {
2299
+ const colWidth = _xeUtils.default.toInteger(width);
2300
+ let rdWidth = colWidth;
2301
+ if ((0, _dom.isScale)(width)) {
2302
+ const tableBody = $xeTable.$refs.tableBody;
2303
+ const bodyElem = tableBody ? tableBody.$el : null;
2304
+ const bodyWidth = bodyElem ? bodyElem.clientWidth - 1 : 0;
2305
+ rdWidth = Math.floor(colWidth * bodyWidth);
2306
+ }
2307
+ column.resizeWidth = rdWidth;
2308
+ if (!status) {
2309
+ status = true;
2310
+ }
2265
2311
  }
2266
- column.resizeWidth = rdWidth;
2267
- return this.refreshColumn();
2312
+ });
2313
+ if (status) {
2314
+ return $xeTable.refreshColumn();
2268
2315
  }
2269
- return this.$nextTick();
2316
+ return $xeTable.$nextTick();
2270
2317
  },
2271
2318
  getColumnWidth(fieldOrColumn) {
2272
2319
  const column = (0, _util.handleFieldOrColumn)(this, fieldOrColumn);
@@ -6735,41 +6782,103 @@ const Methods = {
6735
6782
  }
6736
6783
  this.closeTooltip();
6737
6784
  },
6738
- handleScrollEvent(evnt, isRollY, isRollX, params) {
6785
+ handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, params) {
6739
6786
  const $xeTable = this;
6740
6787
  const props = $xeTable;
6788
+ const reactData = $xeTable;
6789
+ const internalData = $xeTable;
6741
6790
  const {
6742
6791
  highlightHoverRow
6743
6792
  } = props;
6793
+ const {
6794
+ lastScrollLeft,
6795
+ lastScrollTop
6796
+ } = internalData;
6744
6797
  const tableBody = $xeTable.$refs.tableBody;
6745
6798
  const bodyElem = tableBody ? tableBody.$el : null;
6746
6799
  const rowOpts = $xeTable.computeRowOpts;
6747
6800
  const validTip = $xeTable.$refs.validTip;
6748
6801
  const tooltip = $xeTable.$refs.tooltip;
6749
- if (rowOpts.isHover || highlightHoverRow) {
6750
- $xeTable.clearHoverRow();
6751
- }
6752
- if (validTip && validTip.visible) {
6753
- validTip.close();
6754
- }
6755
- if (tooltip && tooltip.visible) {
6756
- tooltip.close();
6757
- }
6758
- if (isRollX) {
6759
- $xeTable.checkScrolling();
6760
- }
6761
6802
  const bodyHeight = bodyElem ? bodyElem.clientHeight : 0;
6762
6803
  const bodyWidth = bodyElem ? bodyElem.clientWidth : 0;
6763
6804
  const scrollHeight = bodyElem ? bodyElem.scrollHeight : 0;
6764
6805
  const scrollWidth = bodyElem ? bodyElem.scrollWidth : 0;
6806
+ let isTop = false;
6807
+ let isBottom = false;
6808
+ let isLeft = false;
6809
+ let isRight = false;
6810
+ let direction = '';
6811
+ let isTopBoundary = false;
6812
+ let isBottomBoundary = false;
6813
+ let isLeftBoundary = false;
6814
+ let isRightBoundary = false;
6815
+ if (isRollX) {
6816
+ const xThreshold = $xeTable.computeScrollXThreshold;
6817
+ isLeft = scrollLeft <= 0;
6818
+ if (!isLeft) {
6819
+ isRight = scrollLeft + bodyWidth >= scrollWidth;
6820
+ }
6821
+ if (scrollLeft > lastScrollLeft) {
6822
+ direction = 'right';
6823
+ if (scrollLeft + bodyWidth >= scrollWidth - xThreshold) {
6824
+ isRightBoundary = true;
6825
+ }
6826
+ } else {
6827
+ direction = 'left';
6828
+ if (scrollLeft <= xThreshold) {
6829
+ isLeftBoundary = true;
6830
+ }
6831
+ }
6832
+ $xeTable.checkScrolling();
6833
+ internalData.lastScrollLeft = scrollLeft;
6834
+ reactData.lastScrollTime = Date.now();
6835
+ } else {
6836
+ const yThreshold = $xeTable.computeScrollYThreshold;
6837
+ isTop = scrollTop <= 0;
6838
+ if (!isTop) {
6839
+ isBottom = scrollTop + bodyHeight >= scrollHeight;
6840
+ }
6841
+ if (scrollTop > lastScrollTop) {
6842
+ direction = 'bottom';
6843
+ if (scrollTop + bodyHeight >= scrollHeight - yThreshold) {
6844
+ isBottomBoundary = true;
6845
+ }
6846
+ } else {
6847
+ direction = 'top';
6848
+ if (scrollTop <= yThreshold) {
6849
+ isTopBoundary = true;
6850
+ }
6851
+ }
6852
+ internalData.lastScrollTop = scrollTop;
6853
+ reactData.lastScrollTime = Date.now();
6854
+ }
6765
6855
  const evntParams = Object.assign({
6856
+ scrollTop,
6857
+ scrollLeft,
6766
6858
  bodyHeight,
6767
6859
  bodyWidth,
6768
6860
  scrollHeight,
6769
6861
  scrollWidth,
6770
6862
  isX: isRollX,
6771
- isY: isRollY
6863
+ isY: isRollY,
6864
+ isTop,
6865
+ isBottom,
6866
+ isLeft,
6867
+ isRight,
6868
+ direction
6772
6869
  }, params);
6870
+ if (rowOpts.isHover || highlightHoverRow) {
6871
+ $xeTable.clearHoverRow();
6872
+ }
6873
+ if (validTip && validTip.visible) {
6874
+ validTip.close();
6875
+ }
6876
+ if (tooltip && tooltip.visible) {
6877
+ tooltip.close();
6878
+ }
6879
+ if (isBottomBoundary || isTopBoundary || isRightBoundary || isLeftBoundary) {
6880
+ $xeTable.dispatchEvent('scroll-boundary', evntParams, evnt);
6881
+ }
6773
6882
  $xeTable.dispatchEvent('scroll', evntParams, evnt);
6774
6883
  },
6775
6884
  /**
@@ -6806,8 +6915,6 @@ const Methods = {
6806
6915
  const bodyElem = tableBody.$el;
6807
6916
  const headerElem = tableHeader ? tableHeader.$el : null;
6808
6917
  const footerElem = tableFooter ? tableFooter.$el : null;
6809
- $xeTable.lastScrollLeft = scrollLeft;
6810
- $xeTable.lastScrollTime = Date.now();
6811
6918
  (0, _dom.setScrollLeft)(bodyElem, scrollLeft);
6812
6919
  (0, _dom.setScrollLeft)(headerElem, scrollLeft);
6813
6920
  (0, _dom.setScrollLeft)(footerElem, scrollLeft);
@@ -6821,15 +6928,11 @@ const Methods = {
6821
6928
  } = wrapperEl;
6822
6929
  const isRollX = true;
6823
6930
  const isRollY = false;
6824
- $xeTable.lastScrollLeft = scrollLeft;
6825
- $xeTable.lastScrollTime = Date.now();
6826
6931
  $xeTable.handleSyncScrollX(scrollLeft);
6827
6932
  $xeTable.triggerScrollXEvent(evnt);
6828
- $xeTable.handleScrollEvent(evnt, isRollY, isRollX, {
6933
+ $xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
6829
6934
  type: 'table',
6830
- fixed: '',
6831
- scrollTop,
6832
- scrollLeft
6935
+ fixed: ''
6833
6936
  });
6834
6937
  },
6835
6938
  debounceScrollYCalculate: _xeUtils.default.debounce(function () {
@@ -6846,8 +6949,6 @@ const Methods = {
6846
6949
  const bodyElem = tableBody.$el;
6847
6950
  const leftElem = leftBody ? leftBody.$el : null;
6848
6951
  const rightElem = rightBody ? rightBody.$el : null;
6849
- $xeTable.lastScrollTop = scrollTop;
6850
- $xeTable.lastScrollTime = Date.now();
6851
6952
  (0, _dom.setScrollTop)(bodyElem, scrollTop);
6852
6953
  (0, _dom.setScrollTop)(leftElem, scrollTop);
6853
6954
  (0, _dom.setScrollTop)(rightElem, scrollTop);
@@ -6861,15 +6962,11 @@ const Methods = {
6861
6962
  } = wrapperEl;
6862
6963
  const isRollX = false;
6863
6964
  const isRollY = true;
6864
- $xeTable.lastScrollTop = scrollTop;
6865
- $xeTable.lastScrollTime = Date.now();
6866
6965
  $xeTable.handleSyncScrollY(scrollTop);
6867
6966
  $xeTable.triggerScrollYEvent(evnt);
6868
- $xeTable.handleScrollEvent(evnt, isRollY, isRollX, {
6967
+ $xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
6869
6968
  type: 'table',
6870
- fixed: '',
6871
- scrollTop,
6872
- scrollLeft
6969
+ fixed: ''
6873
6970
  });
6874
6971
  },
6875
6972
  /**
@@ -7116,22 +7213,41 @@ const Methods = {
7116
7213
  * @param {Number} scrollTop 上距离
7117
7214
  */
7118
7215
  scrollTo(scrollLeft, scrollTop) {
7216
+ const $xeTable = this;
7119
7217
  const {
7120
7218
  $refs
7121
7219
  } = this;
7122
7220
  const {
7123
7221
  tableBody,
7222
+ tableHeader,
7223
+ leftBody,
7124
7224
  rightBody,
7125
7225
  tableFooter
7126
7226
  } = $refs;
7127
7227
  const tableBodyElem = tableBody ? tableBody.$el : null;
7228
+ const leftBodyElem = leftBody ? leftBody.$el : null;
7128
7229
  const rightBodyElem = rightBody ? rightBody.$el : null;
7230
+ const tableHeaderElem = tableHeader ? tableHeader.$el : null;
7129
7231
  const tableFooterElem = tableFooter ? tableFooter.$el : null;
7130
7232
  if (_xeUtils.default.isNumber(scrollLeft)) {
7131
- (0, _dom.setScrollLeft)(tableFooterElem || tableBodyElem, scrollLeft);
7233
+ const xHandleEl = $xeTable.$refs.refScrollXHandleElem;
7234
+ if (xHandleEl) {
7235
+ (0, _dom.setScrollLeft)(xHandleEl, scrollLeft);
7236
+ } else {
7237
+ (0, _dom.setScrollLeft)(tableBodyElem, scrollLeft);
7238
+ (0, _dom.setScrollLeft)(tableHeaderElem, scrollLeft);
7239
+ (0, _dom.setScrollLeft)(tableFooterElem, scrollLeft);
7240
+ }
7132
7241
  }
7133
7242
  if (_xeUtils.default.isNumber(scrollTop)) {
7134
- (0, _dom.setScrollTop)(rightBodyElem || tableBodyElem, scrollTop);
7243
+ const yHandleEl = $xeTable.$refs.refScrollYHandleElem;
7244
+ if (yHandleEl) {
7245
+ (0, _dom.setScrollTop)(yHandleEl, scrollTop);
7246
+ } else {
7247
+ (0, _dom.setScrollTop)(tableBodyElem, scrollTop);
7248
+ (0, _dom.setScrollTop)(leftBodyElem, scrollTop);
7249
+ (0, _dom.setScrollTop)(rightBodyElem, scrollTop);
7250
+ }
7135
7251
  }
7136
7252
  if (this.scrollXLoad || this.scrollYLoad) {
7137
7253
  return new Promise(resolve => setTimeout(() => resolve(this.$nextTick()), 50));