vxe-table 3.11.17 → 3.11.19

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.
@@ -755,6 +755,7 @@ const Methods = {
755
755
  * @param {Array} datas 数据
756
756
  */
757
757
  loadTableData(datas) {
758
+ const $xeTable = this;
758
759
  const {
759
760
  keepSource,
760
761
  showOverflow,
@@ -770,6 +771,7 @@ const Methods = {
770
771
  sYOpts
771
772
  } = this;
772
773
  const childrenField = treeOpts.children || treeOpts.childrenField;
774
+ const rowOpts = $xeTable.computeRowOpts;
773
775
  let treeData = [];
774
776
  let fullData = datas ? datas.slice(0) : [];
775
777
  if (treeConfig) {
@@ -831,9 +833,11 @@ const Methods = {
831
833
  }
832
834
  if (sYLoad) {
833
835
  if (showOverflow) {
834
- const errColumn = this.tableFullColumn.find(column => column.showOverflow === false);
835
- if (errColumn) {
836
- (0, _log.errLog)('vxe.error.errProp', [`column[field="${errColumn.field}"].show-overflow=false`, 'show-overflow=true']);
836
+ if (!rowOpts.height) {
837
+ const errColumn = this.tableFullColumn.find(column => column.showOverflow === false);
838
+ if (errColumn) {
839
+ (0, _log.errLog)('vxe.error.errProp', [`column[field="${errColumn.field}"].show-overflow=false`, 'show-overflow=true']);
840
+ }
837
841
  }
838
842
  }
839
843
  if (process.env.NODE_ENV === 'development') {
@@ -2679,7 +2683,7 @@ const Methods = {
2679
2683
  const isCustomVisible = isAllCustom || storageOpts.visible;
2680
2684
  const isCustomFixed = isAllCustom || storageOpts.fixed;
2681
2685
  const isCustomSort = isAllCustom || storageOpts.sort;
2682
- if (customConfig && (isCustomResizable || isCustomVisible || isCustomFixed || isCustomSort)) {
2686
+ if ((customConfig ? (0, _utils.isEnableConf)(customOpts) : customOpts.enabled) && (isCustomResizable || isCustomVisible || isCustomFixed || isCustomSort)) {
2683
2687
  if (!tableId) {
2684
2688
  (0, _log.errLog)('vxe.error.reqProp', ['id']);
2685
2689
  return;
@@ -2786,10 +2790,13 @@ const Methods = {
2786
2790
  return storeData;
2787
2791
  },
2788
2792
  saveCustomStore(type) {
2793
+ const $xeTable = this;
2794
+ const props = $xeTable;
2789
2795
  const {
2790
- tableId,
2791
- customOpts
2792
- } = this;
2796
+ customConfig
2797
+ } = props;
2798
+ const tableId = $xeTable.computeTableId;
2799
+ const customOpts = $xeTable.computeCustomOpts;
2793
2800
  const {
2794
2801
  updateStore,
2795
2802
  storage
@@ -2800,7 +2807,7 @@ const Methods = {
2800
2807
  const isCustomVisible = isAllCustom || storageOpts.visible;
2801
2808
  const isCustomFixed = isAllCustom || storageOpts.fixed;
2802
2809
  const isCustomSort = isAllCustom || storageOpts.sort;
2803
- if (isCustomResizable || isCustomVisible || isCustomFixed || isCustomSort) {
2810
+ if ((customConfig ? (0, _utils.isEnableConf)(customOpts) : customOpts.enabled) && (isCustomResizable || isCustomVisible || isCustomFixed || isCustomSort)) {
2804
2811
  if (!tableId) {
2805
2812
  (0, _log.errLog)('vxe.error.reqProp', ['id']);
2806
2813
  return this.$nextTick();
@@ -2851,6 +2858,13 @@ const Methods = {
2851
2858
  * 将固定的列左边、右边分别靠边
2852
2859
  */
2853
2860
  parseColumns() {
2861
+ const $xeTable = this;
2862
+ const props = $xeTable;
2863
+ const internalData = $xeTable;
2864
+ const {
2865
+ showOverflow
2866
+ } = props;
2867
+ const rowOpts = $xeTable.computeRowOpts;
2854
2868
  const leftList = [];
2855
2869
  const centerList = [];
2856
2870
  const rightList = [];
@@ -2925,6 +2939,14 @@ const Methods = {
2925
2939
  rightList
2926
2940
  });
2927
2941
  if (scrollXLoad) {
2942
+ if (showOverflow) {
2943
+ if (!rowOpts.height) {
2944
+ const errColumn = internalData.tableFullColumn.find(column => column.showOverflow === false);
2945
+ if (errColumn) {
2946
+ (0, _log.errLog)('vxe.error.errProp', [`column[field="${errColumn.field}"].show-overflow=false`, 'show-overflow=true']);
2947
+ }
2948
+ }
2949
+ }
2928
2950
  if (process.env.NODE_ENV === 'development') {
2929
2951
  // if (this.showHeader && !this.showHeaderOverflow) {
2930
2952
  // warnLog('vxe.error.reqProp', ['show-header-overflow'])
@@ -3092,13 +3114,8 @@ const Methods = {
3092
3114
  calcCellWidth() {
3093
3115
  const $xeTable = this;
3094
3116
  const {
3095
- autoWidthColumnList,
3096
- tableData
3117
+ autoWidthColumnList
3097
3118
  } = this;
3098
- if (!tableData.length || !autoWidthColumnList.length) {
3099
- this.isCalcColumn = false;
3100
- return this.$nextTick();
3101
- }
3102
3119
  this.isCalcColumn = true;
3103
3120
  return this.$nextTick().then(() => {
3104
3121
  const internalData = $xeTable;
@@ -3917,9 +3934,14 @@ const Methods = {
3917
3934
  * 全局键盘事件
3918
3935
  */
3919
3936
  handleGlobalKeydownEvent(evnt) {
3937
+ const $xeTable = this;
3938
+ const internalData = $xeTable;
3920
3939
  // 该行为只对当前激活的表格有效
3921
3940
  if (this.isActivated) {
3922
3941
  this.preventEvent(evnt, 'event.keydown', null, () => {
3942
+ const {
3943
+ afterFullData
3944
+ } = internalData;
3923
3945
  const {
3924
3946
  filterStore,
3925
3947
  isCtxMenu,
@@ -4007,6 +4029,11 @@ const Methods = {
4007
4029
  this._keyCtx = false;
4008
4030
  }, 1000);
4009
4031
  } else if (isEnter && !hasAltKey && keyboardConfig && keyboardOpts.isEnter && (selected.row || actived.row || treeConfig && (rowOpts.isCurrent || highlightCurrentRow) && currentRow)) {
4032
+ const {
4033
+ isLastEnterAppendRow,
4034
+ beforeEnterMethod,
4035
+ enterMethod
4036
+ } = keyboardOpts;
4010
4037
  // 退出选中
4011
4038
  if (hasCtrlKey) {
4012
4039
  // 如果是激活编辑状态,则取消编辑
@@ -4021,18 +4048,52 @@ const Methods = {
4021
4048
  } else {
4022
4049
  // 如果是激活状态,退则出到上一行/下一行
4023
4050
  if (selected.row || actived.row) {
4024
- const targetArgs = selected.row ? selected.args : actived.args;
4051
+ const activeParams = selected.row ? selected.args : actived.args;
4025
4052
  if (hasShiftKey) {
4026
4053
  if (keyboardOpts.enterToTab) {
4027
- this.moveTabSelected(targetArgs, hasShiftKey, evnt);
4054
+ this.moveTabSelected(activeParams, hasShiftKey, evnt);
4028
4055
  } else {
4029
- this.moveSelected(targetArgs, isLeftArrow, true, isRightArrow, false, evnt);
4056
+ this.moveSelected(activeParams, isLeftArrow, true, isRightArrow, false, evnt);
4030
4057
  }
4031
4058
  } else {
4032
4059
  if (keyboardOpts.enterToTab) {
4033
- this.moveTabSelected(targetArgs, hasShiftKey, evnt);
4060
+ this.moveTabSelected(activeParams, hasShiftKey, evnt);
4034
4061
  } else {
4035
- this.moveSelected(targetArgs, isLeftArrow, false, isRightArrow, true, evnt);
4062
+ const activeRow = selected.row || actived.row;
4063
+ const activeColumn = selected.column || actived.column;
4064
+ const _rowIndex = $xeTable.getVTRowIndex(activeRow);
4065
+ const etrParams = {
4066
+ row: activeRow,
4067
+ rowIndex: $xeTable.getRowIndex(activeRow),
4068
+ $rowIndex: $xeTable.getVMRowIndex(activeRow),
4069
+ _rowIndex,
4070
+ column: activeColumn,
4071
+ columnIndex: $xeTable.getColumnIndex(activeColumn),
4072
+ $columnIndex: $xeTable.getVMColumnIndex(activeColumn),
4073
+ _columnIndex: $xeTable.getVTColumnIndex(activeColumn),
4074
+ $table: $xeTable
4075
+ };
4076
+ if (!beforeEnterMethod || beforeEnterMethod(etrParams) !== false) {
4077
+ // 最后一行按下回车键,自动追加一行
4078
+ if (isLastEnterAppendRow) {
4079
+ if (_rowIndex >= afterFullData.length - 1) {
4080
+ $xeTable.insertAt({}, -1).then(({
4081
+ row: newRow
4082
+ }) => {
4083
+ $xeTable.scrollToRow(newRow, selected.column);
4084
+ $xeTable.handleSelected(Object.assign(Object.assign({}, activeParams), {
4085
+ row: newRow
4086
+ }), evnt);
4087
+ });
4088
+ $xeTable.dispatchEvent('enter-append-row', etrParams, evnt);
4089
+ return;
4090
+ }
4091
+ }
4092
+ this.moveSelected(activeParams, isLeftArrow, false, isRightArrow, true, evnt);
4093
+ if (enterMethod) {
4094
+ enterMethod(etrParams);
4095
+ }
4096
+ }
4036
4097
  }
4037
4098
  }
4038
4099
  } else if (treeConfig && (rowOpts.isCurrent || highlightCurrentRow) && currentRow) {
@@ -4095,6 +4156,7 @@ const Methods = {
4095
4156
  } else if (hasBackspaceKey && keyboardConfig && keyboardOpts.isBack && (0, _utils.isEnableConf)(editConfig) && (selected.row || selected.column)) {
4096
4157
  if (!isEditStatus) {
4097
4158
  const {
4159
+ editMode,
4098
4160
  backMethod
4099
4161
  } = keyboardOpts;
4100
4162
  // 如果是删除键
@@ -4112,7 +4174,10 @@ const Methods = {
4112
4174
  if (backMethod) {
4113
4175
  backMethod(params);
4114
4176
  } else {
4115
- (0, _util.setCellValue)(selected.row, selected.column, null);
4177
+ // 追加方式与覆盖式
4178
+ if (editMode !== 'insert') {
4179
+ (0, _util.setCellValue)(selected.row, selected.column, null);
4180
+ }
4116
4181
  this.handleEdit(selected.args, evnt);
4117
4182
  }
4118
4183
  this.emitEvent('cell-backspace-value', params, evnt);
@@ -7331,7 +7396,8 @@ const Methods = {
7331
7396
  }
7332
7397
  $xeTable.checkScrolling();
7333
7398
  internalData.lastScrollLeft = scrollLeft;
7334
- } else {
7399
+ }
7400
+ if (isRollY) {
7335
7401
  const yThreshold = $xeTable.computeScrollYThreshold;
7336
7402
  isTop = scrollTop <= 0;
7337
7403
  if (!isTop) {
@@ -7460,7 +7526,8 @@ const Methods = {
7460
7526
  const internalData = $xeTable;
7461
7527
  const {
7462
7528
  inFooterScroll,
7463
- inBodyScroll
7529
+ inBodyScroll,
7530
+ lastScrollTop
7464
7531
  } = internalData;
7465
7532
  if (inFooterScroll) {
7466
7533
  return;
@@ -7474,13 +7541,18 @@ const Methods = {
7474
7541
  const bodyElem = tableBody.$el;
7475
7542
  const headerElem = tableHeader ? tableHeader.$el : null;
7476
7543
  const footerElem = tableFooter ? tableFooter.$el : null;
7544
+ const yHandleEl = $xeTable.$refs.refScrollYHandleElem;
7477
7545
  const wrapperEl = evnt.currentTarget;
7478
7546
  const {
7479
- scrollTop,
7480
7547
  scrollLeft
7481
7548
  } = wrapperEl;
7549
+ const yBodyEl = yHandleEl || bodyElem;
7550
+ let scrollTop = 0;
7551
+ if (yBodyEl) {
7552
+ scrollTop = yBodyEl.scrollTop;
7553
+ }
7482
7554
  const isRollX = true;
7483
- const isRollY = false;
7555
+ const isRollY = scrollTop !== lastScrollTop;
7484
7556
  internalData.inVirtualScroll = true;
7485
7557
  (0, _dom.setScrollLeft)(bodyElem, scrollLeft);
7486
7558
  (0, _dom.setScrollLeft)(headerElem, scrollLeft);
@@ -7496,7 +7568,8 @@ const Methods = {
7496
7568
  const internalData = $xeTable;
7497
7569
  const {
7498
7570
  inFooterScroll,
7499
- inBodyScroll
7571
+ inBodyScroll,
7572
+ lastScrollLeft
7500
7573
  } = internalData;
7501
7574
  if (inFooterScroll) {
7502
7575
  return;
@@ -7510,12 +7583,17 @@ const Methods = {
7510
7583
  const bodyElem = tableBody.$el;
7511
7584
  const leftElem = leftBody ? leftBody.$el : null;
7512
7585
  const rightElem = rightBody ? rightBody.$el : null;
7586
+ const xHandleEl = $xeTable.$refs.refScrollXHandleElem;
7513
7587
  const wrapperEl = evnt.currentTarget;
7514
7588
  const {
7515
- scrollTop,
7516
- scrollLeft
7589
+ scrollTop
7517
7590
  } = wrapperEl;
7518
- const isRollX = false;
7591
+ const xBodyEl = xHandleEl || bodyElem;
7592
+ let scrollLeft = 0;
7593
+ if (xBodyEl) {
7594
+ scrollLeft = xBodyEl.scrollLeft;
7595
+ }
7596
+ const isRollX = scrollLeft !== lastScrollLeft;
7519
7597
  const isRollY = true;
7520
7598
  internalData.inVirtualScroll = true;
7521
7599
  (0, _dom.setScrollTop)(bodyElem, scrollTop);
@@ -7820,7 +7898,7 @@ const Methods = {
7820
7898
  }
7821
7899
  }
7822
7900
  if (this.scrollXLoad || this.scrollYLoad) {
7823
- return new Promise(resolve => setTimeout(() => resolve(this.$nextTick()), 50));
7901
+ return new Promise(resolve => setTimeout(() => resolve(this.$nextTick()), 30));
7824
7902
  }
7825
7903
  return this.$nextTick();
7826
7904
  },