vxe-table 3.13.4 → 3.13.5

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.
@@ -2462,15 +2462,11 @@ const Methods = {
2462
2462
  internalData.tableFullData = fullData;
2463
2463
  internalData.tableFullTreeData = treeData;
2464
2464
  // 缓存数据
2465
- $xeTable.cacheRowMap(true, isReset);
2465
+ $xeTable.cacheRowMap(true);
2466
2466
  // 原始数据
2467
2467
  internalData.tableSynchData = datas;
2468
2468
  if (isReset) {
2469
2469
  internalData.isResizeCellHeight = false;
2470
- reactData.rowExpandedMaps = {};
2471
- reactData.rowExpandLazyLoadedMaps = {};
2472
- reactData.treeExpandedMaps = {};
2473
- reactData.treeExpandLazyLoadedMaps = {};
2474
2470
  }
2475
2471
  // 克隆原数据,用于显示编辑状态,与编辑值做对比
2476
2472
  if (keepSource) {
@@ -2653,22 +2649,27 @@ const Methods = {
2653
2649
  /**
2654
2650
  * 更新数据行的 Map
2655
2651
  */
2656
- cacheRowMap(isReset, isSource) {
2652
+ cacheRowMap() {
2653
+ const $xeTable = this;
2654
+ const props = $xeTable;
2655
+ const internalData = $xeTable;
2656
+ const {
2657
+ treeConfig
2658
+ } = props;
2659
+ const treeOpts = $xeTable.computeTreeOpts;
2657
2660
  const {
2658
- treeConfig,
2659
- treeOpts,
2660
- tableFullData,
2661
2661
  fullAllDataRowIdData,
2662
+ tableFullData,
2662
2663
  tableFullTreeData
2663
- } = this;
2664
+ } = internalData;
2664
2665
  const childrenField = treeOpts.children || treeOpts.childrenField;
2665
2666
  const hasChildField = treeOpts.hasChild || treeOpts.hasChildField;
2666
- const rowkey = (0, _util.getRowkey)(this);
2667
+ const rowkey = (0, _util.getRowkey)($xeTable);
2667
2668
  const isLazy = treeConfig && treeOpts.lazy;
2668
2669
  const fullAllDataRowIdMaps = {};
2669
2670
  const fullDataRowIdMaps = {};
2670
- const handleCache = (row, index, items, path, parentRow, nodes) => {
2671
- let rowid = (0, _util.getRowid)(this, row);
2671
+ const handleRow = (row, index, items, path, parentRow, nodes) => {
2672
+ let rowid = (0, _util.getRowid)($xeTable, row);
2672
2673
  const seq = treeConfig && path ? (0, _util.toTreePathSeq)(path) : index + 1;
2673
2674
  const level = nodes ? nodes.length - 1 : 0;
2674
2675
  if ((0, _utils.eqEmptyValue)(rowid)) {
@@ -2678,9 +2679,9 @@ const Methods = {
2678
2679
  if (isLazy && row[hasChildField] && _xeUtils.default.isUndefined(row[childrenField])) {
2679
2680
  row[childrenField] = null;
2680
2681
  }
2681
- let cacheItem = fullAllDataRowIdData[rowid];
2682
- if (isReset || !cacheItem) {
2683
- cacheItem = {
2682
+ let rowRest = fullAllDataRowIdData[rowid];
2683
+ if (!rowRest) {
2684
+ rowRest = {
2684
2685
  row,
2685
2686
  rowid,
2686
2687
  seq,
@@ -2697,26 +2698,22 @@ const Methods = {
2697
2698
  expandHeight: 0
2698
2699
  };
2699
2700
  }
2700
- cacheItem.row = row;
2701
- cacheItem.items = items;
2702
- cacheItem.parent = parentRow;
2703
- cacheItem.level = level;
2704
- cacheItem.index = treeConfig && parentRow ? -1 : index;
2705
- if (isSource) {
2706
- fullDataRowIdMaps[rowid] = cacheItem;
2707
- }
2708
- fullAllDataRowIdMaps[rowid] = cacheItem;
2701
+ rowRest.row = row;
2702
+ rowRest.items = items;
2703
+ rowRest.parent = parentRow;
2704
+ rowRest.level = level;
2705
+ rowRest.index = treeConfig && parentRow ? -1 : index;
2706
+ fullDataRowIdMaps[rowid] = rowRest;
2707
+ fullAllDataRowIdMaps[rowid] = rowRest;
2709
2708
  };
2710
- if (isSource) {
2711
- this.fullDataRowIdData = fullDataRowIdMaps;
2712
- }
2713
- this.fullAllDataRowIdData = fullAllDataRowIdMaps;
2709
+ internalData.fullDataRowIdData = fullDataRowIdMaps;
2710
+ internalData.fullAllDataRowIdData = fullAllDataRowIdMaps;
2714
2711
  if (treeConfig) {
2715
- _xeUtils.default.eachTree(tableFullTreeData, handleCache, {
2712
+ _xeUtils.default.eachTree(tableFullTreeData, handleRow, {
2716
2713
  children: childrenField
2717
2714
  });
2718
2715
  } else {
2719
- tableFullData.forEach(handleCache);
2716
+ tableFullData.forEach(handleRow);
2720
2717
  }
2721
2718
  },
2722
2719
  cacheSourceMap(fullData) {
@@ -3721,7 +3718,7 @@ const Methods = {
3721
3718
  treeConfig
3722
3719
  } = props;
3723
3720
  const {
3724
- fullDataRowIdData
3721
+ fullAllDataRowIdData
3725
3722
  } = internalData;
3726
3723
  const treeOpts = $xeTable.computeTreeOpts;
3727
3724
  const {
@@ -3737,7 +3734,7 @@ const Methods = {
3737
3734
  rowid = (0, _util.getRowid)($xeTable, rowOrRowid);
3738
3735
  }
3739
3736
  if (rowid) {
3740
- const rest = fullDataRowIdData[rowid];
3737
+ const rest = fullAllDataRowIdData[rowid];
3741
3738
  const row = rest ? rest.row : null;
3742
3739
  if (row) {
3743
3740
  return row[transform ? mapChildrenField : childrenField] || [];
@@ -3757,7 +3754,7 @@ const Methods = {
3757
3754
  treeConfig
3758
3755
  } = props;
3759
3756
  const {
3760
- fullDataRowIdData
3757
+ fullAllDataRowIdData
3761
3758
  } = internalData;
3762
3759
  if (rowOrRowid && treeConfig) {
3763
3760
  let rowid;
@@ -3767,7 +3764,7 @@ const Methods = {
3767
3764
  rowid = (0, _util.getRowid)($xeTable, rowOrRowid);
3768
3765
  }
3769
3766
  if (rowid) {
3770
- const rest = fullDataRowIdData[rowid];
3767
+ const rest = fullAllDataRowIdData[rowid];
3771
3768
  return rest ? rest.parent : null;
3772
3769
  }
3773
3770
  }
@@ -3786,10 +3783,10 @@ const Methods = {
3786
3783
  const $xeTable = this;
3787
3784
  const internalData = $xeTable;
3788
3785
  const {
3789
- fullDataRowIdData
3786
+ fullAllDataRowIdData
3790
3787
  } = internalData;
3791
3788
  const rowid = _xeUtils.default.eqNull(cellValue) ? '' : encodeURIComponent(cellValue);
3792
- return fullDataRowIdData[rowid] ? fullDataRowIdData[rowid].row : null;
3789
+ return fullAllDataRowIdData[rowid] ? fullAllDataRowIdData[rowid].row : null;
3793
3790
  },
3794
3791
  /**
3795
3792
  * 根据行获取行的唯一主键
@@ -8752,7 +8749,6 @@ const Methods = {
8752
8749
  const $xeTable = this;
8753
8750
  const reactData = $xeTable;
8754
8751
  const internalData = $xeTable;
8755
- const tExpandedMaps = Object.assign({}, reactData.treeExpandedMaps);
8756
8752
  const {
8757
8753
  fullAllDataRowIdData
8758
8754
  } = internalData;
@@ -8760,7 +8756,9 @@ const Methods = {
8760
8756
  const {
8761
8757
  transform
8762
8758
  } = treeOpts;
8759
+ let tExpandedMaps = {};
8763
8760
  if (rows) {
8761
+ tExpandedMaps = Object.assign({}, reactData.treeExpandedMaps);
8764
8762
  if (!_xeUtils.default.isArray(rows)) {
8765
8763
  rows = [rows];
8766
8764
  }
@@ -8774,8 +8772,12 @@ const Methods = {
8774
8772
  }
8775
8773
  }
8776
8774
  });
8775
+ } else {
8776
+ _xeUtils.default.each(fullAllDataRowIdData, rowRest => {
8777
+ rowRest.treeLoaded = false;
8778
+ });
8777
8779
  }
8778
- reactData.treeExpandedMaps = tExpandedMaps;
8780
+ reactData.treeExpandedMaps = {};
8779
8781
  if (transform) {
8780
8782
  handleVirtualTreeToList($xeTable);
8781
8783
  return $xeTable.handleTableData();