vxe-table 3.10.8 → 3.10.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.
@@ -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,7 +6782,7 @@ 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;
6741
6788
  const {
@@ -6762,13 +6809,35 @@ const Methods = {
6762
6809
  const bodyWidth = bodyElem ? bodyElem.clientWidth : 0;
6763
6810
  const scrollHeight = bodyElem ? bodyElem.scrollHeight : 0;
6764
6811
  const scrollWidth = bodyElem ? bodyElem.scrollWidth : 0;
6812
+ let isTop = false;
6813
+ let isBottom = false;
6814
+ let isLeft = false;
6815
+ let isRight = false;
6816
+ if (isRollX) {
6817
+ isLeft = scrollLeft <= 0;
6818
+ if (!isTop) {
6819
+ isRight = scrollLeft + bodyWidth >= scrollWidth;
6820
+ }
6821
+ $xeTable.checkScrolling();
6822
+ } else {
6823
+ isTop = scrollTop <= 0;
6824
+ if (!isTop) {
6825
+ isBottom = scrollTop + bodyHeight >= scrollHeight;
6826
+ }
6827
+ }
6765
6828
  const evntParams = Object.assign({
6829
+ scrollTop,
6830
+ scrollLeft,
6766
6831
  bodyHeight,
6767
6832
  bodyWidth,
6768
6833
  scrollHeight,
6769
6834
  scrollWidth,
6770
6835
  isX: isRollX,
6771
- isY: isRollY
6836
+ isY: isRollY,
6837
+ isTop,
6838
+ isBottom,
6839
+ isLeft,
6840
+ isRight
6772
6841
  }, params);
6773
6842
  $xeTable.dispatchEvent('scroll', evntParams, evnt);
6774
6843
  },
@@ -6825,11 +6894,9 @@ const Methods = {
6825
6894
  $xeTable.lastScrollTime = Date.now();
6826
6895
  $xeTable.handleSyncScrollX(scrollLeft);
6827
6896
  $xeTable.triggerScrollXEvent(evnt);
6828
- $xeTable.handleScrollEvent(evnt, isRollY, isRollX, {
6897
+ $xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
6829
6898
  type: 'table',
6830
- fixed: '',
6831
- scrollTop,
6832
- scrollLeft
6899
+ fixed: ''
6833
6900
  });
6834
6901
  },
6835
6902
  debounceScrollYCalculate: _xeUtils.default.debounce(function () {
@@ -6865,11 +6932,9 @@ const Methods = {
6865
6932
  $xeTable.lastScrollTime = Date.now();
6866
6933
  $xeTable.handleSyncScrollY(scrollTop);
6867
6934
  $xeTable.triggerScrollYEvent(evnt);
6868
- $xeTable.handleScrollEvent(evnt, isRollY, isRollX, {
6935
+ $xeTable.handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, {
6869
6936
  type: 'table',
6870
- fixed: '',
6871
- scrollTop,
6872
- scrollLeft
6937
+ fixed: ''
6873
6938
  });
6874
6939
  },
6875
6940
  /**
@@ -7116,22 +7181,41 @@ const Methods = {
7116
7181
  * @param {Number} scrollTop 上距离
7117
7182
  */
7118
7183
  scrollTo(scrollLeft, scrollTop) {
7184
+ const $xeTable = this;
7119
7185
  const {
7120
7186
  $refs
7121
7187
  } = this;
7122
7188
  const {
7123
7189
  tableBody,
7190
+ tableHeader,
7191
+ leftBody,
7124
7192
  rightBody,
7125
7193
  tableFooter
7126
7194
  } = $refs;
7127
7195
  const tableBodyElem = tableBody ? tableBody.$el : null;
7196
+ const leftBodyElem = leftBody ? leftBody.$el : null;
7128
7197
  const rightBodyElem = rightBody ? rightBody.$el : null;
7198
+ const tableHeaderElem = tableHeader ? tableHeader.$el : null;
7129
7199
  const tableFooterElem = tableFooter ? tableFooter.$el : null;
7130
7200
  if (_xeUtils.default.isNumber(scrollLeft)) {
7131
- (0, _dom.setScrollLeft)(tableFooterElem || tableBodyElem, scrollLeft);
7201
+ const xHandleEl = $xeTable.$refs.refScrollXHandleElem;
7202
+ if (xHandleEl) {
7203
+ (0, _dom.setScrollLeft)(xHandleEl, scrollLeft);
7204
+ } else {
7205
+ (0, _dom.setScrollLeft)(tableBodyElem, scrollLeft);
7206
+ (0, _dom.setScrollLeft)(tableHeaderElem, scrollLeft);
7207
+ (0, _dom.setScrollLeft)(tableFooterElem, scrollLeft);
7208
+ }
7132
7209
  }
7133
7210
  if (_xeUtils.default.isNumber(scrollTop)) {
7134
- (0, _dom.setScrollTop)(rightBodyElem || tableBodyElem, scrollTop);
7211
+ const yHandleEl = $xeTable.$refs.refScrollYHandleElem;
7212
+ if (yHandleEl) {
7213
+ (0, _dom.setScrollTop)(yHandleEl, scrollTop);
7214
+ } else {
7215
+ (0, _dom.setScrollTop)(tableBodyElem, scrollTop);
7216
+ (0, _dom.setScrollTop)(leftBodyElem, scrollTop);
7217
+ (0, _dom.setScrollTop)(rightBodyElem, scrollTop);
7218
+ }
7135
7219
  }
7136
7220
  if (this.scrollXLoad || this.scrollYLoad) {
7137
7221
  return new Promise(resolve => setTimeout(() => resolve(this.$nextTick()), 50));