vxe-table 3.4.0 → 3.4.3

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.
@@ -478,12 +478,12 @@ var Methods = {
478
478
  // 树结构自动转换
479
479
  if (treeOpts.transform) {
480
480
  if (process.env.NODE_ENV === 'development') {
481
- if (!treeOpts.rowtKey) {
482
- _tools.UtilTools.error('vxe.error.reqProp', ['table.tree-config.rowtKey']);
481
+ if (!treeOpts.rowField) {
482
+ _tools.UtilTools.error('vxe.error.reqProp', ['table.tree-config.rowField']);
483
483
  }
484
484
 
485
- if (!treeOpts.parentKey) {
486
- _tools.UtilTools.error('vxe.error.reqProp', ['table.tree-config.parentKey']);
485
+ if (!treeOpts.parentField) {
486
+ _tools.UtilTools.error('vxe.error.reqProp', ['table.tree-config.parentField']);
487
487
  }
488
488
 
489
489
  if (!treeOpts.children) {
@@ -498,8 +498,8 @@ var Methods = {
498
498
  }
499
499
 
500
500
  treeData = _xeUtils.default.toArrayTree(fullData, {
501
- key: treeOpts.rowtKey,
502
- parentKey: treeOpts.parentKey,
501
+ key: treeOpts.rowField,
502
+ parentKey: treeOpts.parentField,
503
503
  children: treeOpts.children
504
504
  });
505
505
  fullData = treeData.slice(0);
@@ -652,18 +652,15 @@ var Methods = {
652
652
 
653
653
  if (oRow && row) {
654
654
  if (field) {
655
- _xeUtils.default.set(oRow, field, _xeUtils.default.get(record || row, field));
656
- } else {
657
- if (record) {
658
- tableSourceData[rowIndex] = record;
655
+ var newValue = _xeUtils.default.get(record || row, field);
659
656
 
660
- _xeUtils.default.clear(row, undefined);
657
+ _xeUtils.default.set(row, field, newValue);
661
658
 
662
- Object.assign(row, this.defineField(Object.assign({}, record)));
663
- this.cacheRowMap(true);
664
- } else {
665
- _xeUtils.default.destructuring(oRow, _xeUtils.default.clone(row, true));
666
- }
659
+ _xeUtils.default.set(oRow, field, newValue);
660
+ } else {
661
+ var newRecord = _xeUtils.default.clone(_objectSpread({}, record), true);
662
+
663
+ _xeUtils.default.destructuring(oRow, Object.assign(row, newRecord));
667
664
  }
668
665
  }
669
666
 
@@ -2918,7 +2915,8 @@ var Methods = {
2918
2915
  treeOpts = _this24.treeOpts,
2919
2916
  highlightCurrentRow = _this24.highlightCurrentRow,
2920
2917
  currentRow = _this24.currentRow,
2921
- bodyCtxMenu = _this24.bodyCtxMenu;
2918
+ bodyCtxMenu = _this24.bodyCtxMenu,
2919
+ rowOpts = _this24.rowOpts;
2922
2920
  var selected = editStore.selected,
2923
2921
  actived = editStore.actived;
2924
2922
  var keyCode = evnt.keyCode;
@@ -2988,7 +2986,7 @@ var Methods = {
2988
2986
  _this24.keyCtxTimeout = setTimeout(function () {
2989
2987
  _this24._keyCtx = false;
2990
2988
  }, 1000);
2991
- } else if (isEnter && !hasAltKey && keyboardConfig && keyboardOpts.isEnter && (selected.row || actived.row || treeConfig && highlightCurrentRow && currentRow)) {
2989
+ } else if (isEnter && !hasAltKey && keyboardConfig && keyboardOpts.isEnter && (selected.row || actived.row || treeConfig && (rowOpts.isCurrent || highlightCurrentRow) && currentRow)) {
2992
2990
  // 退出选中
2993
2991
  if (hasCtrlKey) {
2994
2992
  // 如果是激活编辑状态,则取消编辑
@@ -3022,7 +3020,7 @@ var Methods = {
3022
3020
  _this24.moveSelected(targetArgs, isLeftArrow, false, isRightArrow, true, evnt);
3023
3021
  }
3024
3022
  }
3025
- } else if (treeConfig && highlightCurrentRow && currentRow) {
3023
+ } else if (treeConfig && (rowOpts.isCurrent || highlightCurrentRow) && currentRow) {
3026
3024
  // 如果是树形表格当前行回车移动到子节点
3027
3025
  var childrens = currentRow[treeOpts.children];
3028
3026
 
@@ -3047,7 +3045,7 @@ var Methods = {
3047
3045
  // 如果按下了方向键
3048
3046
  if (selected.row && selected.column) {
3049
3047
  _this24.moveSelected(selected.args, isLeftArrow, isUpArrow, isRightArrow, isDwArrow, evnt);
3050
- } else if ((isUpArrow || isDwArrow) && highlightCurrentRow) {
3048
+ } else if ((isUpArrow || isDwArrow) && (rowOpts.isCurrent || highlightCurrentRow)) {
3051
3049
  // 当前行按键上下移动
3052
3050
  _this24.moveCurrentRow(isUpArrow, isDwArrow, evnt);
3053
3051
  }
@@ -3059,7 +3057,7 @@ var Methods = {
3059
3057
  } else if (actived.row || actived.column) {
3060
3058
  _this24.moveTabSelected(actived.args, hasShiftKey, evnt);
3061
3059
  }
3062
- } else if (keyboardConfig && (isDel || (treeConfig && highlightCurrentRow && currentRow ? isBack && keyboardOpts.isArrow : isBack))) {
3060
+ } else if (keyboardConfig && (isDel || (treeConfig && (rowOpts.isCurrent || highlightCurrentRow) && currentRow ? isBack && keyboardOpts.isArrow : isBack))) {
3063
3061
  if (!isEditStatus) {
3064
3062
  var delMethod = keyboardOpts.delMethod,
3065
3063
  backMethod = keyboardOpts.backMethod; // 如果是删除键
@@ -3093,7 +3091,7 @@ var Methods = {
3093
3091
  // 如果按下 del 键,更新表尾数据
3094
3092
  _this24.updateFooter();
3095
3093
  }
3096
- } else if (isBack && keyboardOpts.isArrow && treeConfig && highlightCurrentRow && currentRow) {
3094
+ } else if (isBack && keyboardOpts.isArrow && treeConfig && (rowOpts.isCurrent || highlightCurrentRow) && currentRow) {
3097
3095
  // 如果树形表格回退键关闭当前行返回父节点
3098
3096
  var _XEUtils$findTree = _xeUtils.default.findTree(_this24.afterFullData, function (item) {
3099
3097
  return item === currentRow;
@@ -4209,12 +4207,13 @@ var Methods = {
4209
4207
  * @param {Row} row 行对象
4210
4208
  */
4211
4209
  setCurrentRow: function setCurrentRow(row) {
4212
- var $el = this.$el;
4210
+ var $el = this.$el,
4211
+ rowOpts = this.rowOpts;
4213
4212
  this.clearCurrentRow();
4214
4213
  this.clearCurrentColumn();
4215
4214
  this.currentRow = row;
4216
4215
 
4217
- if (this.highlightCurrentRow) {
4216
+ if (rowOpts.isCurrent || this.highlightCurrentRow) {
4218
4217
  if ($el) {
4219
4218
  _xeUtils.default.arrayEach($el.querySelectorAll("[rowid=\"".concat(getRowid(this, row), "\"]")), function (elem) {
4220
4219
  return addClass(elem, 'row--current');
@@ -4275,7 +4274,7 @@ var Methods = {
4275
4274
  * 用于当前行,获取当前行的数据
4276
4275
  */
4277
4276
  getCurrentRecord: function getCurrentRecord() {
4278
- return this.highlightCurrentRow ? this.currentRow : null;
4277
+ return this.rowOpts.isCurrent || this.highlightCurrentRow ? this.currentRow : null;
4279
4278
  },
4280
4279
 
4281
4280
  /**
@@ -4370,7 +4369,7 @@ var Methods = {
4370
4369
  cell: cell
4371
4370
  }, params), evnt);
4372
4371
 
4373
- if (this.highlightCurrentColumn) {
4372
+ if (this.columnOpts.isCurrent || this.highlightCurrentColumn) {
4374
4373
  return this.setCurrentColumn(column);
4375
4374
  }
4376
4375
 
@@ -4382,7 +4381,7 @@ var Methods = {
4382
4381
  }, params), evnt);
4383
4382
  },
4384
4383
  getCurrentColumn: function getCurrentColumn() {
4385
- return this.highlightCurrentColumn ? this.currentColumn : null;
4384
+ return this.columnOpts.isCurrent || this.highlightCurrentColumn ? this.currentColumn : null;
4386
4385
  },
4387
4386
 
4388
4387
  /**
@@ -4447,7 +4446,8 @@ var Methods = {
4447
4446
  treeOpts = this.treeOpts,
4448
4447
  editConfig = this.editConfig,
4449
4448
  editOpts = this.editOpts,
4450
- checkboxOpts = this.checkboxOpts;
4449
+ checkboxOpts = this.checkboxOpts,
4450
+ rowOpts = this.rowOpts;
4451
4451
  var actived = editStore.actived;
4452
4452
  var _params = params,
4453
4453
  row = _params.row,
@@ -4486,7 +4486,7 @@ var Methods = {
4486
4486
  if (!triggerTreeNode) {
4487
4487
  if (!triggerExpandNode) {
4488
4488
  // 如果是高亮行
4489
- if (highlightCurrentRow) {
4489
+ if (rowOpts.isCurrent || highlightCurrentRow) {
4490
4490
  if (!triggerCheckbox && !triggerRadio) {
4491
4491
  this.triggerCurrentRowEvent(evnt, params);
4492
4492
  }
@@ -4815,7 +4815,7 @@ var Methods = {
4815
4815
  * 重新懒加载展开行,并展开内容
4816
4816
  * @param {Row} row 行对象
4817
4817
  */
4818
- lazyExpandContent: function lazyExpandContent(row) {
4818
+ reloadRowExpand: function reloadRowExpand(row) {
4819
4819
  var _this36 = this;
4820
4820
 
4821
4821
  var expandOpts = this.expandOpts,
@@ -4832,11 +4832,11 @@ var Methods = {
4832
4832
  },
4833
4833
  reloadExpandContent: function reloadExpandContent(row) {
4834
4834
  if (process.env.NODE_ENV === 'development') {
4835
- _tools.UtilTools.warn('vxe.error.delFunc', ['reloadExpandContent', 'lazyExpandContent']);
4835
+ _tools.UtilTools.warn('vxe.error.delFunc', ['reloadExpandContent', 'reloadRowExpand']);
4836
4836
  } // 即将废弃
4837
4837
 
4838
4838
 
4839
- return this.lazyExpandContent(row);
4839
+ return this.reloadRowExpand(row);
4840
4840
  },
4841
4841
 
4842
4842
  /**
@@ -5108,7 +5108,7 @@ var Methods = {
5108
5108
  * 重新懒加载树节点,并展开该节点
5109
5109
  * @param {Row} row 行对象
5110
5110
  */
5111
- lazyTreeChildren: function lazyTreeChildren(row) {
5111
+ reloadTreeExpand: function reloadTreeExpand(row) {
5112
5112
  var _this40 = this;
5113
5113
 
5114
5114
  var treeOpts = this.treeOpts,
@@ -5133,11 +5133,11 @@ var Methods = {
5133
5133
  },
5134
5134
  reloadTreeChilds: function reloadTreeChilds(row) {
5135
5135
  if (process.env.NODE_ENV === 'development') {
5136
- _tools.UtilTools.warn('vxe.error.delFunc', ['reloadTreeChilds', 'lazyTreeChildren']);
5136
+ _tools.UtilTools.warn('vxe.error.delFunc', ['reloadTreeChilds', 'reloadTreeExpand']);
5137
5137
  } // 即将废弃
5138
5138
 
5139
5139
 
5140
- return this.lazyTreeChildren(row);
5140
+ return this.reloadTreeExpand(row);
5141
5141
  },
5142
5142
 
5143
5143
  /**
@@ -5356,9 +5356,11 @@ var Methods = {
5356
5356
  treeOpts = this.treeOpts,
5357
5357
  treeFullData = this.treeFullData;
5358
5358
  var fullData = [];
5359
+ var expandMaps = new Map();
5359
5360
 
5360
5361
  _xeUtils.default.eachTree(treeFullData, function (row, index, items, path, parent) {
5361
- if (!parent || treeExpandeds.indexOf(parent) > -1) {
5362
+ if (!parent || expandMaps.has(parent) && treeExpandeds.indexOf(parent) > -1) {
5363
+ expandMaps.set(row, 1);
5362
5364
  fullData.push(row);
5363
5365
  }
5364
5366
  }, treeOpts);