vxe-table 3.7.0-beta.3 → 3.7.0-beta.4

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.
@@ -491,7 +491,7 @@ var Methods = {
491
491
  this.tableSynchData = datas;
492
492
  // 克隆原数据,用于显示编辑状态,与编辑值做对比
493
493
  if (keepSource) {
494
- this.tableSourceData = _xeUtils["default"].clone(fullData, true);
494
+ this.cacheSourceMap(fullData);
495
495
  }
496
496
  if (process.env.NODE_ENV === 'development') {
497
497
  if (sYLoad) {
@@ -688,11 +688,9 @@ var Methods = {
688
688
  tableFullData = this.tableFullData,
689
689
  fullDataRowMap = this.fullDataRowMap,
690
690
  fullAllDataRowMap = this.fullAllDataRowMap,
691
- tableFullTreeData = this.tableFullTreeData,
692
- tableSourceData = this.tableSourceData;
691
+ tableFullTreeData = this.tableFullTreeData;
693
692
  var fullDataRowIdData = this.fullDataRowIdData,
694
- fullAllDataRowIdData = this.fullAllDataRowIdData,
695
- sourceDataRowIdData = this.sourceDataRowIdData;
693
+ fullAllDataRowIdData = this.fullAllDataRowIdData;
696
694
  var rowkey = (0, _util.getRowkey)(this);
697
695
  var isLazy = treeConfig && treeOpts.lazy;
698
696
  var handleCache = function handleCache(row, index, items, path, parent, nodes) {
@@ -729,15 +727,23 @@ var Methods = {
729
727
  fullDataRowMap.clear();
730
728
  }
731
729
  fullAllDataRowIdData = this.fullAllDataRowIdData = {};
732
- sourceDataRowIdData = this.sourceDataRowIdData = {};
733
730
  fullAllDataRowMap.clear();
734
731
  if (treeConfig) {
735
732
  _xeUtils["default"].eachTree(tableFullTreeData, handleCache, treeOpts);
736
733
  } else {
737
734
  tableFullData.forEach(handleCache);
738
735
  }
736
+ },
737
+ cacheSourceMap: function cacheSourceMap(fullData) {
738
+ var _this11 = this;
739
+ var treeConfig = this.treeConfig,
740
+ treeOpts = this.treeOpts,
741
+ sourceDataRowIdData = this.sourceDataRowIdData;
742
+ var sourceData = _xeUtils["default"].clone(fullData, true);
743
+ var rowkey = (0, _util.getRowkey)(this);
744
+ sourceDataRowIdData = this.sourceDataRowIdData = {};
739
745
  var handleSourceRow = function handleSourceRow(row) {
740
- var rowid = (0, _util.getRowid)(_this10, row);
746
+ var rowid = (0, _util.getRowid)(_this11, row);
741
747
  if ((0, _utils.eqEmptyValue)(rowid)) {
742
748
  rowid = getRowUniqueId();
743
749
  _xeUtils["default"].set(row, rowkey, rowid);
@@ -749,13 +755,14 @@ var Methods = {
749
755
  };
750
756
  // 源数据缓存
751
757
  if (treeConfig && !treeOpts.transform) {
752
- _xeUtils["default"].eachTree(tableSourceData, handleSourceRow, treeOpts);
758
+ _xeUtils["default"].eachTree(sourceData, handleSourceRow, treeOpts);
753
759
  } else {
754
- tableSourceData.forEach(handleSourceRow);
760
+ sourceData.forEach(handleSourceRow);
755
761
  }
762
+ this.tableSourceData = sourceData;
756
763
  },
757
764
  loadTreeChildren: function loadTreeChildren(row, childRecords) {
758
- var _this11 = this;
765
+ var _this12 = this;
759
766
  var keepSource = this.keepSource,
760
767
  tableSourceData = this.tableSourceData,
761
768
  treeOpts = this.treeOpts,
@@ -770,16 +777,16 @@ var Methods = {
770
777
  var parentLevel = rest ? rest.level : 0;
771
778
  return this.createData(childRecords).then(function (rows) {
772
779
  if (keepSource) {
773
- var rowid = (0, _util.getRowid)(_this11, row);
780
+ var rowid = (0, _util.getRowid)(_this12, row);
774
781
  var matchObj = _xeUtils["default"].findTree(tableSourceData, function (item) {
775
- return rowid === (0, _util.getRowid)(_this11, item);
782
+ return rowid === (0, _util.getRowid)(_this12, item);
776
783
  }, treeOpts);
777
784
  if (matchObj) {
778
785
  matchObj.item[children] = _xeUtils["default"].clone(rows, true);
779
786
  }
780
787
  }
781
788
  _xeUtils["default"].eachTree(rows, function (childRow, index, items, path, parent, nodes) {
782
- var rowid = (0, _util.getRowid)(_this11, childRow);
789
+ var rowid = (0, _util.getRowid)(_this12, childRow);
783
790
  var rest = {
784
791
  row: childRow,
785
792
  rowid: rowid,
@@ -800,7 +807,7 @@ var Methods = {
800
807
  if (transform) {
801
808
  row[mapChildren] = rows;
802
809
  }
803
- _this11.updateAfterDataIndex();
810
+ _this12.updateAfterDataIndex();
804
811
  return rows;
805
812
  });
806
813
  },
@@ -809,7 +816,7 @@ var Methods = {
809
816
  * 牺牲数据组装的耗时,用来换取使用过程中的流畅
810
817
  */
811
818
  cacheColumnMap: function cacheColumnMap() {
812
- var _this12 = this;
819
+ var _this13 = this;
813
820
  var tableFullColumn = this.tableFullColumn,
814
821
  collectColumn = this.collectColumn,
815
822
  fullColumnMap = this.fullColumnMap,
@@ -890,14 +897,14 @@ var Methods = {
890
897
  }
891
898
  }
892
899
  if (process.env.NODE_ENV === 'development') {
893
- if (_this12.showOverflow && column.showOverflow === false) {
894
- (0, _log.warnLog)('vxe.error.errConflicts', ["table.show-overflow=".concat(_this12.showOverflow), "column.show-overflow=".concat(column.showOverflow)]);
900
+ if (_this13.showOverflow && column.showOverflow === false) {
901
+ (0, _log.warnLog)('vxe.error.errConflicts', ["table.show-overflow=".concat(_this13.showOverflow), "column.show-overflow=".concat(column.showOverflow)]);
895
902
  }
896
- if (_this12.showHeaderOverflow && column.showHeaderOverflow === false) {
897
- (0, _log.warnLog)('vxe.error.errConflicts', ["table.show-header-overflow=".concat(_this12.showHeaderOverflow), "column.show-header-overflow=".concat(column.showHeaderOverflow)]);
903
+ if (_this13.showHeaderOverflow && column.showHeaderOverflow === false) {
904
+ (0, _log.warnLog)('vxe.error.errConflicts', ["table.show-header-overflow=".concat(_this13.showHeaderOverflow), "column.show-header-overflow=".concat(column.showHeaderOverflow)]);
898
905
  }
899
- if (_this12.showFooterOverflow && column.showFooterOverflow === false) {
900
- (0, _log.warnLog)('vxe.error.errConflicts', ["table.show-footer-overflow=".concat(_this12.showFooterOverflow), "column.show-footer-overflow=".concat(column.showFooterOverflow)]);
906
+ if (_this13.showFooterOverflow && column.showFooterOverflow === false) {
907
+ (0, _log.warnLog)('vxe.error.errConflicts', ["table.show-footer-overflow=".concat(_this13.showFooterOverflow), "column.show-footer-overflow=".concat(column.showFooterOverflow)]);
901
908
  }
902
909
  }
903
910
  if (process.env.NODE_ENV === 'development') {
@@ -1077,7 +1084,7 @@ var Methods = {
1077
1084
  * @param {Row} records 行数据
1078
1085
  */
1079
1086
  defineField: function defineField(records) {
1080
- var _this13 = this;
1087
+ var _this14 = this;
1081
1088
  var radioOpts = this.radioOpts,
1082
1089
  checkboxOpts = this.checkboxOpts,
1083
1090
  treeConfig = this.treeConfig,
@@ -1088,7 +1095,7 @@ var Methods = {
1088
1095
  records = [records || {}];
1089
1096
  }
1090
1097
  return records.map(function (record) {
1091
- _this13.tableFullColumn.forEach(function (column) {
1098
+ _this14.tableFullColumn.forEach(function (column) {
1092
1099
  var field = column.field,
1093
1100
  editRender = column.editRender;
1094
1101
  if (field && !_xeUtils["default"].has(record, field)) {
@@ -1128,9 +1135,9 @@ var Methods = {
1128
1135
  * @param {Array} records 新数据
1129
1136
  */
1130
1137
  createData: function createData(records) {
1131
- var _this14 = this;
1138
+ var _this15 = this;
1132
1139
  return this.$nextTick().then(function () {
1133
- return _this14.defineField(records);
1140
+ return _this15.defineField(records);
1134
1141
  });
1135
1142
  },
1136
1143
  /**
@@ -1155,7 +1162,7 @@ var Methods = {
1155
1162
  * 如果还额外传了 field 则还原指定的单元格数据
1156
1163
  */
1157
1164
  revertData: function revertData(rows, field) {
1158
- var _this15 = this;
1165
+ var _this16 = this;
1159
1166
  var keepSource = this.keepSource,
1160
1167
  tableSourceData = this.tableSourceData,
1161
1168
  treeConfig = this.treeConfig;
@@ -1175,8 +1182,8 @@ var Methods = {
1175
1182
  }
1176
1183
  if (targetRows.length) {
1177
1184
  targetRows.forEach(function (row) {
1178
- if (!_this15.isInsertByRow(row)) {
1179
- var rowIndex = _this15.getRowIndex(row);
1185
+ if (!_this16.isInsertByRow(row)) {
1186
+ var rowIndex = _this16.getRowIndex(row);
1180
1187
  if (treeConfig && rowIndex === -1) {
1181
1188
  (0, _log.errLog)('vxe.error.noTree', ['revertData']);
1182
1189
  }
@@ -1250,39 +1257,24 @@ var Methods = {
1250
1257
  * @param {String} field 字段名
1251
1258
  */
1252
1259
  isUpdateByRow: function isUpdateByRow(row, field) {
1253
- var _this16 = this;
1254
1260
  var tableFullColumn = this.tableFullColumn,
1255
1261
  keepSource = this.keepSource,
1256
- treeConfig = this.treeConfig,
1257
- treeOpts = this.treeOpts,
1258
- tableSourceData = this.tableSourceData,
1262
+ sourceDataRowIdData = this.sourceDataRowIdData,
1259
1263
  fullDataRowIdData = this.fullDataRowIdData;
1260
1264
  if (keepSource) {
1261
- var oRow, property;
1262
1265
  var rowid = (0, _util.getRowid)(this, row);
1263
1266
  // 新增的数据不需要检测
1264
1267
  if (!fullDataRowIdData[rowid]) {
1265
1268
  return false;
1266
1269
  }
1267
- if (treeConfig) {
1268
- var children = treeOpts.children;
1269
- var matchObj = _xeUtils["default"].findTree(tableSourceData, function (item) {
1270
- return rowid === (0, _util.getRowid)(_this16, item);
1271
- }, treeOpts);
1272
- row = Object.assign({}, row, _defineProperty({}, children, null));
1273
- if (matchObj) {
1274
- oRow = Object.assign({}, matchObj.item, _defineProperty({}, children, null));
1275
- }
1276
- } else {
1277
- var oRowIndex = fullDataRowIdData[rowid].index;
1278
- oRow = tableSourceData[oRowIndex];
1279
- }
1280
- if (oRow) {
1270
+ var oldRest = sourceDataRowIdData[rowid];
1271
+ if (oldRest) {
1272
+ var oRow = oldRest.row;
1281
1273
  if (arguments.length > 1) {
1282
1274
  return !eqCellValue(oRow, row, field);
1283
1275
  }
1284
1276
  for (var index = 0, len = tableFullColumn.length; index < len; index++) {
1285
- property = tableFullColumn[index].field;
1277
+ var property = tableFullColumn[index].field;
1286
1278
  if (property && !eqCellValue(oRow, row, property)) {
1287
1279
  return true;
1288
1280
  }
@@ -4561,7 +4553,10 @@ var Methods = {
4561
4553
  if (!remote || firstSortColumn && firstSortColumn.remoteSort) {
4562
4554
  this.handleTableData(true);
4563
4555
  }
4564
- return this.$nextTick().then(this.updateStyle);
4556
+ return this.$nextTick().then(function () {
4557
+ _this41.updateCellAreas();
4558
+ return _this41.updateStyle();
4559
+ });
4565
4560
  }
4566
4561
  return this.$nextTick();
4567
4562
  },