vxe-table 3.7.0-beta.8 → 3.7.0

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.
Files changed (113) hide show
  1. package/README.md +1 -1
  2. package/helper/vetur/attributes.json +26 -2
  3. package/helper/vetur/tags.json +6 -0
  4. package/lib/button/style/style.css +2 -3
  5. package/lib/button/style/style.min.css +1 -1
  6. package/lib/edit/src/mixin.js +267 -215
  7. package/lib/edit/src/mixin.min.js +1 -1
  8. package/lib/export/src/mixin.js +11 -7
  9. package/lib/export/src/mixin.min.js +1 -1
  10. package/lib/form/src/form-config-item.js +5 -1
  11. package/lib/form/src/form-config-item.min.js +1 -1
  12. package/lib/form/src/form-item.js +9 -1
  13. package/lib/form/src/form-item.min.js +1 -1
  14. package/lib/form/src/form.js +4 -0
  15. package/lib/form/src/form.min.js +1 -1
  16. package/lib/form/style/style.css +12 -0
  17. package/lib/form/style/style.min.css +1 -1
  18. package/lib/icon/style/style.css +1 -1
  19. package/lib/icon/style/style.min.css +1 -1
  20. package/lib/index.css +1 -1
  21. package/lib/index.umd.js +1155 -723
  22. package/lib/index.umd.min.js +1 -1
  23. package/lib/input/src/input.js +24 -1
  24. package/lib/input/src/input.min.js +1 -1
  25. package/lib/input/style/style.css +21 -0
  26. package/lib/input/style/style.min.css +1 -1
  27. package/lib/keyboard/src/mixin.js +4 -1
  28. package/lib/keyboard/src/mixin.min.js +1 -1
  29. package/lib/style.css +1 -1
  30. package/lib/style.min.css +1 -1
  31. package/lib/table/src/body.js +18 -15
  32. package/lib/table/src/body.min.js +1 -1
  33. package/lib/table/src/cell.js +38 -32
  34. package/lib/table/src/cell.min.js +1 -1
  35. package/lib/table/src/columnInfo.js +3 -3
  36. package/lib/table/src/columnInfo.min.js +1 -1
  37. package/lib/table/src/methods.js +652 -426
  38. package/lib/table/src/methods.min.js +1 -1
  39. package/lib/table/src/table.js +38 -24
  40. package/lib/table/src/table.min.js +1 -1
  41. package/lib/table/src/util.js +4 -2
  42. package/lib/table/src/util.min.js +1 -1
  43. package/lib/table/style/style.css +7 -2
  44. package/lib/table/style/style.min.css +1 -1
  45. package/lib/toolbar/src/toolbar.js +5 -1
  46. package/lib/toolbar/src/toolbar.min.js +1 -1
  47. package/lib/tools/log.js +1 -1
  48. package/lib/tools/log.min.js +1 -1
  49. package/lib/tools/utils.js +3 -5
  50. package/lib/tools/utils.min.js +1 -1
  51. package/lib/tooltip/style/style.css +0 -6
  52. package/lib/tooltip/style/style.min.css +1 -1
  53. package/lib/v-x-e-table/index.js +15 -12
  54. package/lib/v-x-e-table/index.min.js +1 -1
  55. package/lib/v-x-e-table/src/commands.js +3 -1
  56. package/lib/v-x-e-table/src/conf.js +5 -5
  57. package/lib/v-x-e-table/src/conf.min.js +1 -1
  58. package/lib/v-x-e-table/src/{setup.js → config.js} +3 -3
  59. package/lib/v-x-e-table/src/config.min.js +1 -0
  60. package/lib/v-x-e-table/src/formats.js +4 -2
  61. package/lib/v-x-e-table/src/formats.min.js +1 -1
  62. package/lib/v-x-e-table/src/menus.js +3 -1
  63. package/lib/v-x-e-table/src/renderer.js +4 -4
  64. package/lib/v-x-e-table/src/renderer.min.js +1 -1
  65. package/lib/validator/src/mixin.js +14 -1
  66. package/lib/validator/src/mixin.min.js +1 -1
  67. package/package.json +7 -8
  68. package/packages/edit/src/mixin.js +186 -143
  69. package/packages/export/src/mixin.js +9 -7
  70. package/packages/form/src/form-config-item.js +4 -2
  71. package/packages/form/src/form-item.js +8 -2
  72. package/packages/form/src/form.js +4 -0
  73. package/packages/input/src/input.js +24 -1
  74. package/packages/keyboard/src/mixin.js +2 -1
  75. package/packages/table/src/body.js +18 -15
  76. package/packages/table/src/cell.js +32 -23
  77. package/packages/table/src/columnInfo.js +3 -3
  78. package/packages/table/src/methods.js +485 -239
  79. package/packages/table/src/table.js +36 -22
  80. package/packages/table/src/util.js +4 -2
  81. package/packages/toolbar/src/toolbar.js +4 -1
  82. package/packages/tools/utils.js +3 -6
  83. package/packages/v-x-e-table/index.js +7 -4
  84. package/packages/v-x-e-table/src/commands.js +3 -1
  85. package/packages/v-x-e-table/src/conf.js +5 -5
  86. package/packages/v-x-e-table/src/{setup.js → config.js} +2 -2
  87. package/packages/v-x-e-table/src/formats.js +4 -2
  88. package/packages/v-x-e-table/src/menus.js +3 -1
  89. package/packages/v-x-e-table/src/renderer.js +4 -4
  90. package/packages/validator/src/mixin.js +12 -1
  91. package/styles/button.scss +5 -3
  92. package/styles/css-variable.scss +3 -3
  93. package/styles/form.scss +14 -0
  94. package/styles/input.scss +25 -0
  95. package/styles/table.scss +13 -2
  96. package/styles/textarea.scss +3 -3
  97. package/styles/tooltip.scss +0 -8
  98. package/styles/variable.scss +3 -3
  99. package/types/all.d.ts +2 -2
  100. package/types/form-item.d.ts +1 -0
  101. package/types/form.d.ts +1 -0
  102. package/types/table.d.ts +36 -5
  103. package/types/v-x-e-table/config.d.ts +51 -0
  104. package/types/v-x-e-table/formats.d.ts +1 -1
  105. package/types/v-x-e-table/index.d.ts +22 -10
  106. package/lib/v-x-e-table/src/setup.min.js +0 -1
  107. package/types/v-x-e-table/setup.d.ts +0 -74
  108. /package/lib/icon/style/{iconfont.1690504677290.ttf → iconfont.1694737793729.ttf} +0 -0
  109. /package/lib/icon/style/{iconfont.1690504677290.woff → iconfont.1694737793729.woff} +0 -0
  110. /package/lib/icon/style/{iconfont.1690504677290.woff2 → iconfont.1694737793729.woff2} +0 -0
  111. /package/lib/{iconfont.1690504677290.ttf → iconfont.1694737793729.ttf} +0 -0
  112. /package/lib/{iconfont.1690504677290.woff → iconfont.1694737793729.woff} +0 -0
  113. /package/lib/{iconfont.1690504677290.woff2 → iconfont.1694737793729.woff2} +0 -0
@@ -77,12 +77,16 @@ function getCustomStorageMap(key) {
77
77
  _v: version
78
78
  };
79
79
  }
80
- function getRecoverRow(_vm, list) {
81
- var fullAllDataRowMap = _vm.fullAllDataRowMap;
82
- return list.filter(function (row) {
83
- return fullAllDataRowMap.has(row);
80
+ var getRecoverRowMaps = function getRecoverRowMaps(_vm, keyMaps) {
81
+ var fullAllDataRowIdData = _vm.fullAllDataRowIdData;
82
+ var restKeys = {};
83
+ _xeUtils["default"].each(keyMaps, function (row, rowid) {
84
+ if (fullAllDataRowIdData[rowid]) {
85
+ restKeys[rowid] = row;
86
+ }
84
87
  });
85
- }
88
+ return restKeys;
89
+ };
86
90
  function handleReserveRow(_vm, reserveRowMap) {
87
91
  var fullDataRowIdData = _vm.fullDataRowIdData;
88
92
  var reserveList = [];
@@ -434,6 +438,7 @@ var Methods = {
434
438
  oldScrollYLoad = this.scrollYLoad,
435
439
  sXOpts = this.sXOpts,
436
440
  sYOpts = this.sYOpts;
441
+ var childrenField = treeOpts.children || treeOpts.childrenField;
437
442
  var treeData = [];
438
443
  var fullData = datas ? datas.slice(0) : [];
439
444
  if (treeConfig) {
@@ -446,26 +451,26 @@ var Methods = {
446
451
  if (!treeOpts.parentField) {
447
452
  (0, _log.errLog)('vxe.error.reqProp', ['table.tree-config.parentField']);
448
453
  }
449
- if (!treeOpts.children) {
450
- (0, _log.errLog)('vxe.error.reqProp', ['tree-config.children']);
454
+ if (!childrenField) {
455
+ (0, _log.errLog)('vxe.error.reqProp', ['tree-config.childrenField']);
451
456
  }
452
- if (!treeOpts.mapChildren) {
453
- (0, _log.errLog)('vxe.error.reqProp', ['tree-config.mapChildren']);
457
+ if (!treeOpts.mapChildrenField) {
458
+ (0, _log.errLog)('vxe.error.reqProp', ['tree-config.mapChildrenField']);
454
459
  }
455
- if (treeOpts.children === treeOpts.mapChildren) {
456
- (0, _log.errLog)('vxe.error.errConflicts', ['tree-config.children', 'tree-config.mapChildren']);
460
+ if (childrenField === treeOpts.mapChildrenField) {
461
+ (0, _log.errLog)('vxe.error.errConflicts', ['tree-config.childrenField', 'tree-config.mapChildrenField']);
457
462
  }
458
463
  fullData.forEach(function (row) {
459
- if (row[treeOpts.children] && row[treeOpts.children].length) {
460
- (0, _log.warnLog)('vxe.error.errConflicts', ['tree-config.transform', "row.".concat(treeOpts.children)]);
464
+ if (row[childrenField] && row[childrenField].length) {
465
+ (0, _log.warnLog)('vxe.error.errConflicts', ['tree-config.transform', "row.".concat(childrenField)]);
461
466
  }
462
467
  });
463
468
  }
464
469
  treeData = _xeUtils["default"].toArrayTree(fullData, {
465
470
  key: treeOpts.rowField,
466
471
  parentKey: treeOpts.parentField,
467
- children: treeOpts.children,
468
- mapChildren: treeOpts.mapChildren
472
+ children: childrenField,
473
+ mapChildren: treeOpts.mapChildrenField
469
474
  });
470
475
  fullData = treeData.slice(0);
471
476
  } else {
@@ -691,6 +696,8 @@ var Methods = {
691
696
  tableFullTreeData = this.tableFullTreeData;
692
697
  var fullDataRowIdData = this.fullDataRowIdData,
693
698
  fullAllDataRowIdData = this.fullAllDataRowIdData;
699
+ var childrenField = treeOpts.children || treeOpts.childrenField;
700
+ var hasChildField = treeOpts.hasChild || treeOpts.hasChildField;
694
701
  var rowkey = (0, _util.getRowkey)(this);
695
702
  var isLazy = treeConfig && treeOpts.lazy;
696
703
  var handleCache = function handleCache(row, index, items, path, parent, nodes) {
@@ -701,8 +708,8 @@ var Methods = {
701
708
  rowid = getRowUniqueId();
702
709
  _xeUtils["default"].set(row, rowkey, rowid);
703
710
  }
704
- if (isLazy && row[treeOpts.hasChild] && _xeUtils["default"].isUndefined(row[treeOpts.children])) {
705
- row[treeOpts.children] = null;
711
+ if (isLazy && row[hasChildField] && _xeUtils["default"].isUndefined(row[childrenField])) {
712
+ row[childrenField] = null;
706
713
  }
707
714
  var rest = {
708
715
  row: row,
@@ -729,7 +736,9 @@ var Methods = {
729
736
  fullAllDataRowIdData = this.fullAllDataRowIdData = {};
730
737
  fullAllDataRowMap.clear();
731
738
  if (treeConfig) {
732
- _xeUtils["default"].eachTree(tableFullTreeData, handleCache, treeOpts);
739
+ _xeUtils["default"].eachTree(tableFullTreeData, handleCache, {
740
+ children: childrenField
741
+ });
733
742
  } else {
734
743
  tableFullData.forEach(handleCache);
735
744
  }
@@ -755,7 +764,10 @@ var Methods = {
755
764
  };
756
765
  // 源数据缓存
757
766
  if (treeConfig && !treeOpts.transform) {
758
- _xeUtils["default"].eachTree(sourceData, handleSourceRow, treeOpts);
767
+ var childrenField = treeOpts.children || treeOpts.childrenField;
768
+ _xeUtils["default"].eachTree(sourceData, handleSourceRow, {
769
+ children: treeOpts.transform ? treeOpts.mapChildrenField : childrenField
770
+ });
759
771
  } else {
760
772
  sourceData.forEach(handleSourceRow);
761
773
  }
@@ -769,10 +781,11 @@ var Methods = {
769
781
  fullDataRowIdData = this.fullDataRowIdData,
770
782
  fullDataRowMap = this.fullDataRowMap,
771
783
  fullAllDataRowMap = this.fullAllDataRowMap,
772
- fullAllDataRowIdData = this.fullAllDataRowIdData;
784
+ fullAllDataRowIdData = this.fullAllDataRowIdData,
785
+ sourceDataRowIdData = this.sourceDataRowIdData;
773
786
  var transform = treeOpts.transform,
774
- children = treeOpts.children,
775
- mapChildren = treeOpts.mapChildren;
787
+ mapChildrenField = treeOpts.mapChildrenField;
788
+ var childrenField = treeOpts.children || treeOpts.childrenField;
776
789
  var rest = fullAllDataRowIdData[(0, _util.getRowid)(this, row)];
777
790
  var parentLevel = rest ? rest.level : 0;
778
791
  return this.createData(childRecords).then(function (rows) {
@@ -780,10 +793,16 @@ var Methods = {
780
793
  var rowid = (0, _util.getRowid)(_this12, row);
781
794
  var matchObj = _xeUtils["default"].findTree(tableSourceData, function (item) {
782
795
  return rowid === (0, _util.getRowid)(_this12, item);
783
- }, treeOpts);
796
+ }, {
797
+ children: childrenField
798
+ });
784
799
  if (matchObj) {
785
- matchObj.item[children] = _xeUtils["default"].clone(rows, true);
800
+ matchObj.item[childrenField] = _xeUtils["default"].clone(rows, true);
786
801
  }
802
+ rows.forEach(function (childRow) {
803
+ var rowid = (0, _util.getRowid)(_this12, childRow);
804
+ sourceDataRowIdData[rowid] = _xeUtils["default"].clone(childRow, true);
805
+ });
787
806
  }
788
807
  _xeUtils["default"].eachTree(rows, function (childRow, index, items, path, parent, nodes) {
789
808
  var rowid = (0, _util.getRowid)(_this12, childRow);
@@ -802,10 +821,12 @@ var Methods = {
802
821
  fullDataRowMap.set(childRow, rest);
803
822
  fullAllDataRowIdData[rowid] = rest;
804
823
  fullAllDataRowMap.set(childRow, rest);
805
- }, treeOpts);
806
- row[children] = rows;
824
+ }, {
825
+ children: childrenField
826
+ });
827
+ row[childrenField] = rows;
807
828
  if (transform) {
808
- row[mapChildren] = rows;
829
+ row[mapChildrenField] = rows;
809
830
  }
810
831
  _this12.updateAfterDataIndex();
811
832
  return rows;
@@ -1090,6 +1111,7 @@ var Methods = {
1090
1111
  treeConfig = this.treeConfig,
1091
1112
  treeOpts = this.treeOpts,
1092
1113
  expandOpts = this.expandOpts;
1114
+ var childrenField = treeOpts.children || treeOpts.childrenField;
1093
1115
  var rowkey = (0, _util.getRowkey)(this);
1094
1116
  if (!_xeUtils["default"].isArray(records)) {
1095
1117
  records = [records || {}];
@@ -1119,8 +1141,8 @@ var Methods = {
1119
1141
  _xeUtils["default"].set(record, key, null);
1120
1142
  }
1121
1143
  });
1122
- if (treeConfig && treeOpts.lazy && _xeUtils["default"].isUndefined(record[treeOpts.children])) {
1123
- record[treeOpts.children] = null;
1144
+ if (treeConfig && treeOpts.lazy && _xeUtils["default"].isUndefined(record[childrenField])) {
1145
+ record[childrenField] = null;
1124
1146
  }
1125
1147
  // 必须有行数据的唯一主键,可以自行设置;也可以默认生成一个随机数
1126
1148
  if ((0, _utils.eqEmptyValue)(_xeUtils["default"].get(record, rowkey))) {
@@ -1330,18 +1352,18 @@ var Methods = {
1330
1352
  * 用于多选行,获取已选中的数据
1331
1353
  */
1332
1354
  getCheckboxRecords: function getCheckboxRecords(isFull) {
1333
- var _this17 = this;
1334
1355
  var tableFullData = this.tableFullData,
1335
1356
  afterFullData = this.afterFullData,
1336
1357
  treeConfig = this.treeConfig,
1337
1358
  treeOpts = this.treeOpts,
1338
1359
  checkboxOpts = this.checkboxOpts,
1339
1360
  tableFullTreeData = this.tableFullTreeData,
1340
- afterTreeFullData = this.afterTreeFullData;
1361
+ afterTreeFullData = this.afterTreeFullData,
1362
+ afterFullRowMaps = this.afterFullRowMaps;
1341
1363
  var transform = treeOpts.transform,
1342
- children = treeOpts.children,
1343
- mapChildren = treeOpts.mapChildren;
1364
+ mapChildrenField = treeOpts.mapChildrenField;
1344
1365
  var checkField = checkboxOpts.checkField;
1366
+ var childrenField = treeOpts.children || treeOpts.childrenField;
1345
1367
  var currTableData = isFull ? transform ? tableFullTreeData : tableFullData : transform ? afterTreeFullData : afterFullData;
1346
1368
  var rowList = [];
1347
1369
  if (checkField) {
@@ -1349,7 +1371,7 @@ var Methods = {
1349
1371
  rowList = _xeUtils["default"].filterTree(currTableData, function (row) {
1350
1372
  return _xeUtils["default"].get(row, checkField);
1351
1373
  }, {
1352
- children: transform ? mapChildren : children
1374
+ children: transform ? mapChildrenField : childrenField
1353
1375
  });
1354
1376
  } else {
1355
1377
  rowList = currTableData.filter(function (row) {
@@ -1357,18 +1379,13 @@ var Methods = {
1357
1379
  });
1358
1380
  }
1359
1381
  } else {
1360
- var selectCheckboxRows = this.selectCheckboxRows;
1361
- if (treeConfig) {
1362
- rowList = _xeUtils["default"].filterTree(currTableData, function (row) {
1363
- return _this17.findRowIndexOf(selectCheckboxRows, row) > -1;
1364
- }, {
1365
- children: transform ? mapChildren : children
1366
- });
1367
- } else {
1368
- rowList = currTableData.filter(function (row) {
1369
- return _this17.findRowIndexOf(selectCheckboxRows, row) > -1;
1370
- });
1371
- }
1382
+ var selectCheckboxMaps = this.selectCheckboxMaps,
1383
+ fullDataRowIdData = this.fullDataRowIdData;
1384
+ _xeUtils["default"].each(selectCheckboxMaps, function (row, rowid) {
1385
+ if (isFull ? fullDataRowIdData[rowid] : afterFullRowMaps[rowid]) {
1386
+ rowList.push(row);
1387
+ }
1388
+ });
1372
1389
  }
1373
1390
  return rowList;
1374
1391
  },
@@ -1377,21 +1394,24 @@ var Methods = {
1377
1394
  * @returns
1378
1395
  */
1379
1396
  handleVirtualTreeToList: function handleVirtualTreeToList() {
1397
+ var _this17 = this;
1380
1398
  var treeOpts = this.treeOpts,
1381
1399
  treeConfig = this.treeConfig,
1382
- treeExpandeds = this.treeExpandeds,
1400
+ treeExpandedMaps = this.treeExpandedMaps,
1383
1401
  afterTreeFullData = this.afterTreeFullData,
1384
1402
  afterFullData = this.afterFullData;
1385
1403
  if (treeConfig && treeOpts.transform) {
1386
1404
  var fullData = [];
1387
- var expandMaps = new Map();
1405
+ var expandMaps = {};
1388
1406
  _xeUtils["default"].eachTree(afterTreeFullData, function (row, index, items, path, parent) {
1389
- if (!parent || expandMaps.has(parent) && treeExpandeds.indexOf(parent) > -1) {
1390
- expandMaps.set(row, 1);
1407
+ var rowid = (0, _util.getRowid)(_this17, row);
1408
+ var parentRowid = (0, _util.getRowid)(_this17, parent);
1409
+ if (!parent || expandMaps[parentRowid] && treeExpandedMaps[parentRowid]) {
1410
+ expandMaps[rowid] = 1;
1391
1411
  fullData.push(row);
1392
1412
  }
1393
1413
  }, {
1394
- children: treeOpts.mapChildren
1414
+ children: treeOpts.mapChildrenField
1395
1415
  });
1396
1416
  this.afterFullData = fullData;
1397
1417
  this.updateScrollYStatus(fullData);
@@ -1616,6 +1636,8 @@ var Methods = {
1616
1636
  fullAllDataRowIdData = this.fullAllDataRowIdData,
1617
1637
  afterTreeFullData = this.afterTreeFullData,
1618
1638
  treeOpts = this.treeOpts;
1639
+ var childrenField = treeOpts.children || treeOpts.childrenField;
1640
+ var fullMaps = {};
1619
1641
  if (treeConfig) {
1620
1642
  _xeUtils["default"].eachTree(afterTreeFullData, function (row, index, items, path) {
1621
1643
  var rowid = (0, _util.getRowid)(_this19, row);
@@ -1641,8 +1663,9 @@ var Methods = {
1641
1663
  fullAllDataRowIdData[rowid] = rest;
1642
1664
  fullDataRowIdData[rowid] = rest;
1643
1665
  }
1666
+ fullMaps[rowid] = row;
1644
1667
  }, {
1645
- children: treeOpts.transform ? treeOpts.mapChildren : treeOpts.children
1668
+ children: treeOpts.transform ? treeOpts.mapChildrenField : childrenField
1646
1669
  });
1647
1670
  } else {
1648
1671
  afterFullData.forEach(function (row, index) {
@@ -1667,8 +1690,10 @@ var Methods = {
1667
1690
  fullAllDataRowIdData[rowid] = rest;
1668
1691
  fullDataRowIdData[rowid] = rest;
1669
1692
  }
1693
+ fullMaps[rowid] = row;
1670
1694
  });
1671
1695
  }
1696
+ this.afterFullRowMaps = fullMaps;
1672
1697
  },
1673
1698
  /**
1674
1699
  * 只对 tree-config 有效,获取行的父级
@@ -1807,7 +1832,7 @@ var Methods = {
1807
1832
  */
1808
1833
  showColumn: function showColumn(fieldOrColumn) {
1809
1834
  var column = (0, _util.handleFieldOrColumn)(this, fieldOrColumn);
1810
- if (column && column.visible) {
1835
+ if (column && !column.visible) {
1811
1836
  column.visible = true;
1812
1837
  return this.handleCustom();
1813
1838
  }
@@ -2970,6 +2995,7 @@ var Methods = {
2970
2995
  var operArrow = isLeftArrow || isUpArrow || isRightArrow || isDwArrow;
2971
2996
  var operCtxMenu = isCtxMenu && ctxMenuStore.visible && (isEnter || isSpacebar || operArrow);
2972
2997
  var isEditStatus = (0, _utils.isEnableConf)(editConfig) && actived.column && actived.row;
2998
+ var childrenField = treeOpts.children || treeOpts.childrenField;
2973
2999
  var params;
2974
3000
  if (filterStore.visible) {
2975
3001
  if (isEsc) {
@@ -3044,7 +3070,7 @@ var Methods = {
3044
3070
  }
3045
3071
  } else if (treeConfig && (rowOpts.isCurrent || highlightCurrentRow) && currentRow) {
3046
3072
  // 如果是树形表格当前行回车移动到子节点
3047
- var childrens = currentRow[treeOpts.children];
3073
+ var childrens = currentRow[childrenField];
3048
3074
  if (childrens && childrens.length) {
3049
3075
  evnt.preventDefault();
3050
3076
  var targetRow = childrens[0];
@@ -3114,7 +3140,9 @@ var Methods = {
3114
3140
  // 如果树形表格回退键关闭当前行返回父节点
3115
3141
  var _XEUtils$findTree = _xeUtils["default"].findTree(_this29.afterFullData, function (item) {
3116
3142
  return item === currentRow;
3117
- }, treeOpts),
3143
+ }, {
3144
+ children: childrenField
3145
+ }),
3118
3146
  parentRow = _XEUtils$findTree.parent;
3119
3147
  if (parentRow) {
3120
3148
  evnt.preventDefault();
@@ -3420,15 +3448,24 @@ var Methods = {
3420
3448
  * 获取复选框半选状态的行数据
3421
3449
  */
3422
3450
  getCheckboxIndeterminateRecords: function getCheckboxIndeterminateRecords(isFull) {
3423
- var _this31 = this;
3424
3451
  var treeConfig = this.treeConfig,
3425
- treeIndeterminates = this.treeIndeterminates,
3452
+ treeIndeterminateMaps = this.treeIndeterminateMaps,
3426
3453
  fullDataRowIdData = this.fullDataRowIdData;
3427
3454
  if (treeConfig) {
3428
- return isFull ? treeIndeterminates.slice(0) : treeIndeterminates.filter(function (row) {
3429
- var rowid = (0, _util.getRowid)(_this31, row);
3430
- return fullDataRowIdData[rowid];
3455
+ var fullRest = [];
3456
+ var defRest = [];
3457
+ _xeUtils["default"].each(treeIndeterminateMaps, function (item, rowid) {
3458
+ if (item) {
3459
+ fullRest.push(item);
3460
+ if (fullDataRowIdData[rowid]) {
3461
+ defRest.push(item);
3462
+ }
3463
+ }
3431
3464
  });
3465
+ if (isFull) {
3466
+ return fullRest;
3467
+ }
3468
+ return defRest;
3432
3469
  }
3433
3470
  return [];
3434
3471
  },
@@ -3453,12 +3490,12 @@ var Methods = {
3453
3490
  }
3454
3491
  },
3455
3492
  handleCheckedCheckboxRow: function handleCheckedCheckboxRow(rows, value, isForce) {
3456
- var _this32 = this;
3493
+ var _this31 = this;
3457
3494
  if (rows && !_xeUtils["default"].isArray(rows)) {
3458
3495
  rows = [rows];
3459
3496
  }
3460
3497
  rows.forEach(function (row) {
3461
- return _this32.handleSelectRow({
3498
+ return _this31.handleSelectRow({
3462
3499
  row: row
3463
3500
  }, !!value, isForce);
3464
3501
  });
@@ -3473,78 +3510,108 @@ var Methods = {
3473
3510
  return this.handleCheckedCheckboxRow(rows, value, true);
3474
3511
  },
3475
3512
  isCheckedByCheckboxRow: function isCheckedByCheckboxRow(row) {
3476
- var selectCheckboxRows = this.selectCheckboxRows;
3513
+ var selectCheckboxMaps = this.selectCheckboxMaps;
3477
3514
  var checkField = this.checkboxOpts.checkField;
3478
3515
  if (checkField) {
3479
3516
  return _xeUtils["default"].get(row, checkField);
3480
3517
  }
3481
- return this.findRowIndexOf(selectCheckboxRows, row) > -1;
3518
+ return !!selectCheckboxMaps[(0, _util.getRowid)(this, row)];
3482
3519
  },
3483
3520
  isIndeterminateByCheckboxRow: function isIndeterminateByCheckboxRow(row) {
3484
- var treeIndeterminates = this.treeIndeterminates;
3485
- return this.findRowIndexOf(treeIndeterminates, row) > -1 && !this.isCheckedByCheckboxRow(row);
3521
+ var treeIndeterminateMaps = this.treeIndeterminateMaps;
3522
+ return !!treeIndeterminateMaps[(0, _util.getRowid)(this, row)] && !this.isCheckedByCheckboxRow(row);
3486
3523
  },
3487
3524
  /**
3488
3525
  * 多选,行选中事件
3489
3526
  * value 选中true 不选false 半选-1
3490
3527
  */
3491
3528
  handleSelectRow: function handleSelectRow(_ref6, value, isForce) {
3492
- var _this33 = this;
3529
+ var _this32 = this;
3493
3530
  var row = _ref6.row;
3494
- var selectCheckboxRows = this.selectCheckboxRows,
3531
+ var selectCheckboxMaps = this.selectCheckboxMaps,
3495
3532
  afterFullData = this.afterFullData,
3496
3533
  treeConfig = this.treeConfig,
3497
3534
  treeOpts = this.treeOpts,
3498
- treeIndeterminates = this.treeIndeterminates,
3535
+ treeIndeterminateMaps = this.treeIndeterminateMaps,
3499
3536
  checkboxOpts = this.checkboxOpts;
3500
3537
  var checkField = checkboxOpts.checkField,
3501
3538
  checkStrictly = checkboxOpts.checkStrictly,
3502
3539
  checkMethod = checkboxOpts.checkMethod;
3540
+ var selectRowMaps = _objectSpread({}, selectCheckboxMaps);
3541
+ var childrenField = treeOpts.children || treeOpts.childrenField;
3542
+ var indeterminateField = checkboxOpts.indeterminateField || checkboxOpts.halfField;
3543
+ var rowid = (0, _util.getRowid)(this, row);
3503
3544
  if (checkField) {
3504
3545
  if (treeConfig && !checkStrictly) {
3505
3546
  if (value === -1) {
3506
- if (this.findRowIndexOf(treeIndeterminates, row) === -1) {
3507
- treeIndeterminates.push(row);
3547
+ if (!treeIndeterminateMaps[rowid]) {
3548
+ if (indeterminateField) {
3549
+ _xeUtils["default"].set(row, indeterminateField, true);
3550
+ }
3551
+ treeIndeterminateMaps[rowid] = row;
3508
3552
  }
3509
3553
  _xeUtils["default"].set(row, checkField, false);
3510
3554
  } else {
3511
3555
  // 更新子节点状态
3512
3556
  _xeUtils["default"].eachTree([row], function (item) {
3513
- if (_this33.eqRow(item, row) || isForce || !checkMethod || checkMethod({
3557
+ if (_this32.eqRow(item, row) || isForce || !checkMethod || checkMethod({
3514
3558
  row: item
3515
3559
  })) {
3516
3560
  _xeUtils["default"].set(item, checkField, value);
3517
- _xeUtils["default"].remove(treeIndeterminates, function (half) {
3518
- return _this33.eqRow(half, item);
3519
- });
3520
- _this33.handleCheckboxReserveRow(row, value);
3561
+ if (indeterminateField) {
3562
+ _xeUtils["default"].set(row, indeterminateField, false);
3563
+ }
3564
+ delete treeIndeterminateMaps[(0, _util.getRowid)(_this32, item)];
3565
+ _this32.handleCheckboxReserveRow(row, value);
3521
3566
  }
3522
- }, treeOpts);
3567
+ }, {
3568
+ children: childrenField
3569
+ });
3523
3570
  }
3524
3571
  // 如果存在父节点,更新父节点状态
3525
3572
  var matchObj = _xeUtils["default"].findTree(afterFullData, function (item) {
3526
- return _this33.eqRow(item, row);
3527
- }, treeOpts);
3573
+ return _this32.eqRow(item, row);
3574
+ }, {
3575
+ children: childrenField
3576
+ });
3528
3577
  if (matchObj && matchObj.parent) {
3529
3578
  var parentStatus;
3530
- var vItems = !isForce && checkMethod ? matchObj.items.filter(function (item) {
3531
- return checkMethod({
3532
- row: item
3579
+ var vItems = [];
3580
+ var vItemMaps = {};
3581
+ if (!isForce && checkMethod) {
3582
+ matchObj.items.forEach(function (item) {
3583
+ if (checkMethod({
3584
+ row: item
3585
+ })) {
3586
+ var itemRid = (0, _util.getRowid)(_this32, item);
3587
+ vItemMaps[itemRid] = item;
3588
+ vItems.push(item);
3589
+ }
3533
3590
  });
3534
- }) : matchObj.items;
3591
+ } else {
3592
+ matchObj.items.forEach(function (item) {
3593
+ var itemRid = (0, _util.getRowid)(_this32, item);
3594
+ vItemMaps[itemRid] = item;
3595
+ vItems.push(item);
3596
+ });
3597
+ }
3535
3598
  var indeterminatesItem = _xeUtils["default"].find(matchObj.items, function (item) {
3536
- return _this33.findRowIndexOf(treeIndeterminates, item) > -1;
3599
+ return !!treeIndeterminateMaps[(0, _util.getRowid)(_this32, item)];
3537
3600
  });
3538
3601
  if (indeterminatesItem) {
3539
3602
  parentStatus = -1;
3540
3603
  } else {
3541
- var selectItems = matchObj.items.filter(function (item) {
3542
- return _xeUtils["default"].get(item, checkField);
3604
+ var selectItems = [];
3605
+ matchObj.items.forEach(function (item) {
3606
+ if (_xeUtils["default"].get(item, checkField)) {
3607
+ selectItems.push(item);
3608
+ }
3543
3609
  });
3544
3610
  parentStatus = selectItems.filter(function (item) {
3545
- return _this33.findRowIndexOf(vItems, item) > -1;
3611
+ return vItemMaps[(0, _util.getRowid)(_this32, item)];
3546
3612
  }).length === vItems.length ? true : selectItems.length || value === -1 ? -1 : false;
3547
3613
  }
3614
+ this.selectCheckboxMaps = selectRowMaps;
3548
3615
  return this.handleSelectRow({
3549
3616
  row: matchObj.parent
3550
3617
  }, parentStatus, isForce);
@@ -3560,56 +3627,84 @@ var Methods = {
3560
3627
  } else {
3561
3628
  if (treeConfig && !checkStrictly) {
3562
3629
  if (value === -1) {
3563
- if (this.findRowIndexOf(treeIndeterminates, row) === -1) {
3564
- treeIndeterminates.push(row);
3630
+ if (!treeIndeterminateMaps[rowid]) {
3631
+ if (indeterminateField) {
3632
+ _xeUtils["default"].set(row, indeterminateField, true);
3633
+ }
3634
+ treeIndeterminateMaps[rowid] = row;
3635
+ }
3636
+ if (selectRowMaps[rowid]) {
3637
+ delete selectRowMaps[rowid];
3565
3638
  }
3566
- _xeUtils["default"].remove(selectCheckboxRows, function (item) {
3567
- return _this33.eqRow(item, row);
3568
- });
3569
3639
  } else {
3570
3640
  // 更新子节点状态
3571
3641
  _xeUtils["default"].eachTree([row], function (item) {
3572
- if (_this33.eqRow(item, row) || isForce || !checkMethod || checkMethod({
3642
+ var itemRid = (0, _util.getRowid)(_this32, item);
3643
+ if (_this32.eqRow(item, row) || isForce || !checkMethod || checkMethod({
3573
3644
  row: item
3574
3645
  })) {
3575
3646
  if (value) {
3576
- selectCheckboxRows.push(item);
3647
+ selectRowMaps[itemRid] = item;
3577
3648
  } else {
3578
- _xeUtils["default"].remove(selectCheckboxRows, function (select) {
3579
- return _this33.eqRow(select, item);
3580
- });
3649
+ if (selectRowMaps[itemRid]) {
3650
+ delete selectRowMaps[itemRid];
3651
+ }
3581
3652
  }
3582
- _xeUtils["default"].remove(treeIndeterminates, function (half) {
3583
- return _this33.eqRow(half, item);
3584
- });
3585
- _this33.handleCheckboxReserveRow(row, value);
3653
+ if (indeterminateField) {
3654
+ _xeUtils["default"].set(row, indeterminateField, false);
3655
+ }
3656
+ delete treeIndeterminateMaps[(0, _util.getRowid)(_this32, item)];
3657
+ _this32.handleCheckboxReserveRow(row, value);
3586
3658
  }
3587
- }, treeOpts);
3659
+ }, {
3660
+ children: childrenField
3661
+ });
3588
3662
  }
3589
3663
  // 如果存在父节点,更新父节点状态
3590
3664
  var _matchObj = _xeUtils["default"].findTree(afterFullData, function (item) {
3591
- return _this33.eqRow(item, row);
3592
- }, treeOpts);
3665
+ return _this32.eqRow(item, row);
3666
+ }, {
3667
+ children: childrenField
3668
+ });
3593
3669
  if (_matchObj && _matchObj.parent) {
3594
3670
  var _parentStatus;
3595
- var _vItems = !isForce && checkMethod ? _matchObj.items.filter(function (item) {
3596
- return checkMethod({
3597
- row: item
3671
+ var _vItems = [];
3672
+ var _vItemMaps = {};
3673
+ if (!isForce && checkMethod) {
3674
+ _matchObj.items.forEach(function (item) {
3675
+ if (checkMethod({
3676
+ row: item
3677
+ })) {
3678
+ var itemRid = (0, _util.getRowid)(_this32, item);
3679
+ _vItemMaps[itemRid] = item;
3680
+ _vItems.push(item);
3681
+ }
3682
+ });
3683
+ } else {
3684
+ _matchObj.items.forEach(function (item) {
3685
+ var itemRid = (0, _util.getRowid)(_this32, item);
3686
+ _vItemMaps[itemRid] = item;
3687
+ _vItems.push(item);
3598
3688
  });
3599
- }) : _matchObj.items;
3689
+ }
3600
3690
  var _indeterminatesItem = _xeUtils["default"].find(_matchObj.items, function (item) {
3601
- return _this33.findRowIndexOf(treeIndeterminates, item) > -1;
3691
+ return !!treeIndeterminateMaps[(0, _util.getRowid)(_this32, item)];
3602
3692
  });
3603
3693
  if (_indeterminatesItem) {
3604
3694
  _parentStatus = -1;
3605
3695
  } else {
3606
- var _selectItems = _matchObj.items.filter(function (item) {
3607
- return _this33.findRowIndexOf(selectCheckboxRows, item) > -1;
3696
+ var _selectItems = [];
3697
+ _matchObj.items.forEach(function (item) {
3698
+ var itemRid = (0, _util.getRowid)(_this32, item);
3699
+ if (selectRowMaps[itemRid]) {
3700
+ _selectItems.push(item);
3701
+ }
3608
3702
  });
3609
3703
  _parentStatus = _selectItems.filter(function (item) {
3610
- return _this33.findRowIndexOf(_vItems, item) > -1;
3704
+ return _vItemMaps[(0, _util.getRowid)(_this32, item)];
3611
3705
  }).length === _vItems.length ? true : _selectItems.length || value === -1 ? -1 : false;
3612
3706
  }
3707
+ this.selectCheckboxMaps = selectRowMaps;
3613
3708
  return this.handleSelectRow({
3614
3709
  row: _matchObj.parent
3615
3710
  }, _parentStatus, isForce);
@@ -3619,26 +3714,32 @@ var Methods = {
3619
3714
  row: row
3620
3715
  })) {
3621
3716
  if (value) {
3622
- if (this.findRowIndexOf(selectCheckboxRows, row) === -1) {
3623
- selectCheckboxRows.push(row);
3717
+ if (!selectRowMaps[rowid]) {
3718
+ selectRowMaps[rowid] = row;
3624
3719
  }
3625
3720
  } else {
3626
- _xeUtils["default"].remove(selectCheckboxRows, function (item) {
3627
- return _this33.eqRow(item, row);
3628
- });
3721
+ if (selectRowMaps[rowid]) {
3722
+ delete selectRowMaps[rowid];
3723
+ }
3629
3724
  }
3630
3725
  this.handleCheckboxReserveRow(row, value);
3631
3726
  }
3632
3727
  }
3633
3728
  }
3729
+ this.selectCheckboxMaps = selectRowMaps;
3634
3730
  this.checkSelectionStatus();
3635
3731
  },
3636
3732
  handleToggleCheckRowEvent: function handleToggleCheckRowEvent(evnt, params) {
3637
- var selectCheckboxRows = this.selectCheckboxRows,
3733
+ var selectCheckboxMaps = this.selectCheckboxMaps,
3638
3734
  checkboxOpts = this.checkboxOpts;
3639
3735
  var checkField = checkboxOpts.checkField;
3640
3736
  var row = params.row;
3641
- var value = checkField ? !_xeUtils["default"].get(row, checkField) : this.findRowIndexOf(selectCheckboxRows, row) === -1;
3737
+ var value = false;
3738
+ if (checkField) {
3739
+ value = !_xeUtils["default"].get(row, checkField);
3740
+ } else {
3741
+ value = !selectCheckboxMaps[(0, _util.getRowid)(this, row)];
3742
+ }
3642
3743
  if (evnt) {
3643
3744
  this.triggerCheckRowEvent(evnt, params, value);
3644
3745
  } else {
@@ -3646,9 +3747,29 @@ var Methods = {
3646
3747
  }
3647
3748
  },
3648
3749
  triggerCheckRowEvent: function triggerCheckRowEvent(evnt, params, value) {
3649
- var checkMethod = this.checkboxOpts.checkMethod;
3750
+ var checkboxOpts = this.checkboxOpts,
3751
+ afterFullData = this.afterFullData;
3752
+ var checkMethod = checkboxOpts.checkMethod;
3753
+ var row = params.row;
3754
+ if (checkboxOpts.isShiftKey && evnt.shiftKey && !this.treeConfig) {
3755
+ var checkboxRecords = this.getCheckboxRecords();
3756
+ if (checkboxRecords.length) {
3757
+ var firstRow = checkboxRecords[0];
3758
+ var _rowIndex = this.getVTRowIndex(row);
3759
+ var _firstRowIndex = this.getVTRowIndex(firstRow);
3760
+ if (_rowIndex !== _firstRowIndex) {
3761
+ this.setAllCheckboxRow(false);
3762
+ var rangeRows = _rowIndex < _firstRowIndex ? afterFullData.slice(_rowIndex, _firstRowIndex + 1) : afterFullData.slice(_firstRowIndex, _rowIndex + 1);
3763
+ this.handleCheckedCheckboxRow(rangeRows, true, false);
3764
+ this.emitEvent('checkbox-range-select', Object.assign({
3765
+ rangeRecords: rangeRows
3766
+ }, params), evnt);
3767
+ return;
3768
+ }
3769
+ }
3770
+ }
3650
3771
  if (!checkMethod || checkMethod({
3651
- row: params.row
3772
+ row: row
3652
3773
  })) {
3653
3774
  this.handleSelectRow(params, value);
3654
3775
  this.emitEvent('checkbox-change', Object.assign({
@@ -3663,31 +3784,42 @@ var Methods = {
3663
3784
  * 多选,切换某一行的选中状态
3664
3785
  */
3665
3786
  toggleCheckboxRow: function toggleCheckboxRow(row) {
3666
- var selectCheckboxRows = this.selectCheckboxRows,
3787
+ var selectCheckboxMaps = this.selectCheckboxMaps,
3667
3788
  checkboxOpts = this.checkboxOpts;
3668
3789
  var checkField = checkboxOpts.checkField;
3669
- var value = checkField ? !_xeUtils["default"].get(row, checkField) : this.findRowIndexOf(selectCheckboxRows, row) === -1;
3790
+ var value = checkField ? !_xeUtils["default"].get(row, checkField) : !selectCheckboxMaps[(0, _util.getRowid)(this, row)];
3670
3791
  this.handleSelectRow({
3671
3792
  row: row
3672
3793
  }, value, true);
3673
3794
  return this.$nextTick();
3674
3795
  },
3675
3796
  handleCheckedAllCheckboxRow: function handleCheckedAllCheckboxRow(value, isForce) {
3676
- var _this34 = this;
3797
+ var _this33 = this;
3677
3798
  var afterFullData = this.afterFullData,
3678
3799
  treeConfig = this.treeConfig,
3679
3800
  treeOpts = this.treeOpts,
3680
- selectCheckboxRows = this.selectCheckboxRows,
3801
+ selectCheckboxMaps = this.selectCheckboxMaps,
3681
3802
  checkboxReserveRowMap = this.checkboxReserveRowMap,
3682
- checkboxOpts = this.checkboxOpts;
3803
+ checkboxOpts = this.checkboxOpts,
3804
+ afterFullRowMaps = this.afterFullRowMaps;
3683
3805
  var checkField = checkboxOpts.checkField,
3684
3806
  reserve = checkboxOpts.reserve,
3685
3807
  checkStrictly = checkboxOpts.checkStrictly,
3686
3808
  checkMethod = checkboxOpts.checkMethod;
3687
- var selectRows = [];
3688
- var beforeSelection = treeConfig ? [] : selectCheckboxRows.filter(function (row) {
3689
- return _this34.findRowIndexOf(afterFullData, row) === -1;
3690
- });
3809
+ var indeterminateField = checkboxOpts.indeterminateField || checkboxOpts.halfField;
3810
+ var childrenField = treeOpts.children || treeOpts.childrenField;
3811
+ var selectRowMaps = {};
3812
+
3813
+ // 疑惑!
3814
+ if (!treeConfig) {
3815
+ _xeUtils["default"].each(selectCheckboxMaps, function (row, rowid) {
3816
+ if (!afterFullRowMaps[rowid]) {
3817
+ selectRowMaps[rowid] = row;
3818
+ }
3819
+ });
3820
+ }
3821
+ // 疑惑!
3822
+
3691
3823
  if (checkStrictly) {
3692
3824
  this.isAllSelected = value;
3693
3825
  } else {
@@ -3701,15 +3833,20 @@ var Methods = {
3701
3833
  row: row
3702
3834
  })) {
3703
3835
  if (value) {
3704
- selectRows.push(row);
3836
+ selectRowMaps[(0, _util.getRowid)(_this33, row)] = row;
3705
3837
  }
3706
3838
  _xeUtils["default"].set(row, checkField, value);
3707
3839
  }
3840
+ if (treeConfig && indeterminateField) {
3841
+ _xeUtils["default"].set(row, indeterminateField, false);
3842
+ }
3708
3843
  };
3709
3844
  // 如果存在选中方法
3710
3845
  // 如果方法成立,则更新值,否则忽略该数据
3711
3846
  if (treeConfig) {
3712
- _xeUtils["default"].eachTree(afterFullData, checkValFn, treeOpts);
3847
+ _xeUtils["default"].eachTree(afterFullData, checkValFn, {
3848
+ children: childrenField
3849
+ });
3713
3850
  } else {
3714
3851
  afterFullData.forEach(checkValFn);
3715
3852
  }
@@ -3728,9 +3865,11 @@ var Methods = {
3728
3865
  if (isForce || !checkMethod || checkMethod({
3729
3866
  row: row
3730
3867
  })) {
3731
- selectRows.push(row);
3868
+ selectRowMaps[(0, _util.getRowid)(_this33, row)] = row;
3732
3869
  }
3733
- }, treeOpts);
3870
+ }, {
3871
+ children: childrenField
3872
+ });
3734
3873
  } else {
3735
3874
  /**
3736
3875
  * 如果是树取消
@@ -3738,12 +3877,15 @@ var Methods = {
3738
3877
  */
3739
3878
  if (!isForce && checkMethod) {
3740
3879
  _xeUtils["default"].eachTree(afterFullData, function (row) {
3880
+ var rowid = (0, _util.getRowid)(_this33, row);
3741
3881
  if (checkMethod({
3742
3882
  row: row
3743
- }) ? 0 : _this34.findRowIndexOf(selectCheckboxRows, row) > -1) {
3744
- selectRows.push(row);
3883
+ }) ? 0 : selectCheckboxMaps[rowid]) {
3884
+ selectRowMaps[rowid] = row;
3745
3885
  }
3746
- }, treeOpts);
3886
+ }, {
3887
+ children: childrenField
3888
+ });
3747
3889
  }
3748
3890
  }
3749
3891
  } else {
@@ -3754,13 +3896,18 @@ var Methods = {
3754
3896
  * 如果不存在选中方法,则添加所有数据到临时集合中
3755
3897
  */
3756
3898
  if (!isForce && checkMethod) {
3757
- selectRows = afterFullData.filter(function (row) {
3758
- return _this34.findRowIndexOf(selectCheckboxRows, row) > -1 || checkMethod({
3899
+ afterFullData.forEach(function (row) {
3900
+ var rowid = (0, _util.getRowid)(_this33, row);
3901
+ if (selectCheckboxMaps[rowid] || checkMethod({
3759
3902
  row: row
3760
- });
3903
+ })) {
3904
+ selectRowMaps[rowid] = row;
3905
+ }
3761
3906
  });
3762
3907
  } else {
3763
- selectRows = afterFullData.slice(0);
3908
+ afterFullData.forEach(function (row) {
3909
+ selectRowMaps[(0, _util.getRowid)(_this33, row)] = row;
3910
+ });
3764
3911
  }
3765
3912
  } else {
3766
3913
  /**
@@ -3769,10 +3916,13 @@ var Methods = {
3769
3916
  * 如果不存在选中方法,无需处理,临时集合默认为空
3770
3917
  */
3771
3918
  if (!isForce && checkMethod) {
3772
- selectRows = afterFullData.filter(function (row) {
3773
- return checkMethod({
3919
+ afterFullData.forEach(function (row) {
3920
+ var rowid = (0, _util.getRowid)(_this33, row);
3921
+ if (checkMethod({
3774
3922
  row: row
3775
- }) ? 0 : _this34.findRowIndexOf(selectCheckboxRows, row) > -1;
3923
+ }) ? 0 : selectCheckboxMaps[rowid]) {
3924
+ selectRowMaps[rowid] = row;
3925
+ }
3776
3926
  });
3777
3927
  }
3778
3928
  }
@@ -3780,18 +3930,19 @@ var Methods = {
3780
3930
  }
3781
3931
  if (reserve) {
3782
3932
  if (value) {
3783
- selectRows.forEach(function (row) {
3784
- checkboxReserveRowMap[(0, _util.getRowid)(_this34, row)] = row;
3933
+ _xeUtils["default"].each(selectRowMaps, function (row, rowid) {
3934
+ checkboxReserveRowMap[rowid] = row;
3785
3935
  });
3786
3936
  } else {
3787
3937
  afterFullData.forEach(function (row) {
3788
- return _this34.handleCheckboxReserveRow(row, false);
3938
+ return _this33.handleCheckboxReserveRow(row, false);
3789
3939
  });
3790
3940
  }
3791
3941
  }
3792
- this.selectCheckboxRows = checkField ? [] : beforeSelection.concat(selectRows);
3942
+ this.selectCheckboxMaps = checkField ? {} : selectRowMaps;
3793
3943
  }
3794
- this.treeIndeterminates = [];
3944
+ this.treeIndeterminateMaps = {};
3945
+ this.treeIndeterminateRowMaps = {};
3795
3946
  this.checkSelectionStatus();
3796
3947
  return this.$nextTick();
3797
3948
  },
@@ -3803,16 +3954,16 @@ var Methods = {
3803
3954
  return this.handleCheckedAllCheckboxRow(value, true);
3804
3955
  },
3805
3956
  checkSelectionStatus: function checkSelectionStatus() {
3806
- var _this35 = this;
3957
+ var _this34 = this;
3807
3958
  var afterFullData = this.afterFullData,
3808
- selectCheckboxRows = this.selectCheckboxRows,
3809
- treeIndeterminates = this.treeIndeterminates,
3959
+ selectCheckboxMaps = this.selectCheckboxMaps,
3960
+ treeIndeterminateMaps = this.treeIndeterminateMaps,
3810
3961
  checkboxOpts = this.checkboxOpts,
3811
3962
  treeConfig = this.treeConfig;
3812
3963
  var checkField = checkboxOpts.checkField,
3813
- halfField = checkboxOpts.halfField,
3814
3964
  checkStrictly = checkboxOpts.checkStrictly,
3815
3965
  checkMethod = checkboxOpts.checkMethod;
3966
+ var indeterminateField = checkboxOpts.indeterminateField || checkboxOpts.halfField;
3816
3967
  if (!checkStrictly) {
3817
3968
  var disableRows = [];
3818
3969
  var checkRows = [];
@@ -3837,19 +3988,19 @@ var Methods = {
3837
3988
  });
3838
3989
  isAllSelected = isAllResolve && afterFullData.length !== disableRows.length;
3839
3990
  if (treeConfig) {
3840
- if (halfField) {
3991
+ if (indeterminateField) {
3841
3992
  isIndeterminate = !isAllSelected && afterFullData.some(function (row) {
3842
- return _xeUtils["default"].get(row, checkField) || _xeUtils["default"].get(row, halfField) || _this35.findRowIndexOf(treeIndeterminates, row) > -1;
3993
+ return _xeUtils["default"].get(row, checkField) || _xeUtils["default"].get(row, indeterminateField) || !!treeIndeterminateMaps[(0, _util.getRowid)(_this34, row)];
3843
3994
  });
3844
3995
  } else {
3845
3996
  isIndeterminate = !isAllSelected && afterFullData.some(function (row) {
3846
- return _xeUtils["default"].get(row, checkField) || _this35.findRowIndexOf(treeIndeterminates, row) > -1;
3997
+ return _xeUtils["default"].get(row, checkField) || !!treeIndeterminateMaps[(0, _util.getRowid)(_this34, row)];
3847
3998
  });
3848
3999
  }
3849
4000
  } else {
3850
- if (halfField) {
4001
+ if (indeterminateField) {
3851
4002
  isIndeterminate = !isAllSelected && afterFullData.some(function (row) {
3852
- return _xeUtils["default"].get(row, checkField) || _xeUtils["default"].get(row, halfField);
4003
+ return _xeUtils["default"].get(row, checkField) || _xeUtils["default"].get(row, indeterminateField);
3853
4004
  });
3854
4005
  } else {
3855
4006
  isIndeterminate = !isAllSelected && afterFullData.some(function (row) {
@@ -3865,22 +4016,23 @@ var Methods = {
3865
4016
  disableRows.push(row);
3866
4017
  return true;
3867
4018
  }
3868
- if (_this35.findRowIndexOf(selectCheckboxRows, row) > -1) {
4019
+ if (selectCheckboxMaps[(0, _util.getRowid)(_this34, row)]) {
3869
4020
  checkRows.push(row);
3870
4021
  return true;
3871
4022
  }
3872
4023
  return false;
3873
4024
  } : function (row) {
3874
- return _this35.findRowIndexOf(selectCheckboxRows, row) > -1;
4025
+ return selectCheckboxMaps[(0, _util.getRowid)(_this34, row)];
3875
4026
  });
3876
4027
  isAllSelected = isAllResolve && afterFullData.length !== disableRows.length;
3877
4028
  if (treeConfig) {
3878
4029
  isIndeterminate = !isAllSelected && afterFullData.some(function (row) {
3879
- return _this35.findRowIndexOf(treeIndeterminates, row) > -1 || _this35.findRowIndexOf(selectCheckboxRows, row) > -1;
4030
+ var itemRid = (0, _util.getRowid)(_this34, row);
4031
+ return treeIndeterminateMaps[itemRid] || selectCheckboxMaps[itemRid];
3880
4032
  });
3881
4033
  } else {
3882
4034
  isIndeterminate = !isAllSelected && afterFullData.some(function (row) {
3883
- return _this35.findRowIndexOf(selectCheckboxRows, row) > -1;
4035
+ return selectCheckboxMaps[(0, _util.getRowid)(_this34, row)];
3884
4036
  });
3885
4037
  }
3886
4038
  }
@@ -3896,17 +4048,17 @@ var Methods = {
3896
4048
  fullDataRowIdData = this.fullDataRowIdData,
3897
4049
  fullAllDataRowMap = this.fullAllDataRowMap,
3898
4050
  currentRow = this.currentRow,
3899
- selectRow = this.selectRow,
4051
+ selectRadioRow = this.selectRadioRow,
3900
4052
  radioReserveRow = this.radioReserveRow,
3901
4053
  radioOpts = this.radioOpts,
3902
4054
  checkboxOpts = this.checkboxOpts,
3903
- selectCheckboxRows = this.selectCheckboxRows,
3904
- rowExpandeds = this.rowExpandeds,
3905
- treeExpandeds = this.treeExpandeds,
4055
+ selectCheckboxMaps = this.selectCheckboxMaps,
4056
+ rowExpandedMaps = this.rowExpandedMaps,
4057
+ treeExpandedMaps = this.treeExpandedMaps,
3906
4058
  expandOpts = this.expandOpts;
3907
4059
  // 单选框
3908
- if (selectRow && !fullAllDataRowMap.has(selectRow)) {
3909
- this.selectRow = null; // 刷新单选行状态
4060
+ if (selectRadioRow && !fullAllDataRowMap.has(selectRadioRow)) {
4061
+ this.selectRadioRow = null; // 刷新单选行状态
3910
4062
  }
3911
4063
  // 还原保留选中状态
3912
4064
  if (radioOpts.reserve && radioReserveRow) {
@@ -3916,7 +4068,7 @@ var Methods = {
3916
4068
  }
3917
4069
  }
3918
4070
  // 复选框
3919
- this.selectCheckboxRows = getRecoverRow(this, selectCheckboxRows); // 刷新多选行状态
4071
+ this.selectCheckboxMaps = getRecoverRowMaps(this, selectCheckboxMaps); // 刷新多选行状态
3920
4072
  // 还原保留选中状态
3921
4073
  if (checkboxOpts.reserve) {
3922
4074
  this.handleCheckedCheckboxRow(handleReserveRow(this, this.checkboxReserveRowMap), true, true);
@@ -3925,13 +4077,13 @@ var Methods = {
3925
4077
  this.currentRow = null; // 刷新当前行状态
3926
4078
  }
3927
4079
  // 行展开
3928
- this.rowExpandeds = expandColumn ? getRecoverRow(this, rowExpandeds) : []; // 刷新行展开状态
4080
+ this.rowExpandedMaps = expandColumn ? getRecoverRowMaps(this, rowExpandedMaps) : []; // 刷新行展开状态
3929
4081
  // 还原保留状态
3930
4082
  if (expandColumn && expandOpts.reserve) {
3931
4083
  this.setRowExpand(handleReserveRow(this, this.rowExpandedReserveRowMap), true);
3932
4084
  }
3933
4085
  // 树展开
3934
- this.treeExpandeds = treeConfig ? getRecoverRow(this, treeExpandeds) : []; // 刷新树展开状态
4086
+ this.treeExpandedMaps = treeConfig ? getRecoverRowMaps(this, treeExpandedMaps) : []; // 刷新树展开状态
3935
4087
  if (treeConfig && treeOpts.reserve) {
3936
4088
  this.setTreeExpand(handleReserveRow(this, this.treeExpandedReserveRowMap), true);
3937
4089
  }
@@ -3946,6 +4098,7 @@ var Methods = {
3946
4098
  afterFullData = this.afterFullData,
3947
4099
  treeConfig = this.treeConfig,
3948
4100
  treeOpts = this.treeOpts;
4101
+ var childrenField = treeOpts.children || treeOpts.childrenField;
3949
4102
  if (radioOpts.reserve && radioReserveRow) {
3950
4103
  var rowid = (0, _util.getRowid)(this, radioReserveRow);
3951
4104
  if (isFull) {
@@ -3957,7 +4110,9 @@ var Methods = {
3957
4110
  if (treeConfig) {
3958
4111
  var matchObj = _xeUtils["default"].findTree(afterFullData, function (row) {
3959
4112
  return rowid === _xeUtils["default"].get(row, rowkey);
3960
- }, treeOpts);
4113
+ }, {
4114
+ children: childrenField
4115
+ });
3961
4116
  if (matchObj) {
3962
4117
  return radioReserveRow;
3963
4118
  }
@@ -3986,23 +4141,26 @@ var Methods = {
3986
4141
  * 获取复选框保留选中的行
3987
4142
  */
3988
4143
  getCheckboxReserveRecords: function getCheckboxReserveRecords(isFull) {
3989
- var _this36 = this;
4144
+ var _this35 = this;
3990
4145
  var fullDataRowIdData = this.fullDataRowIdData,
3991
4146
  afterFullData = this.afterFullData,
3992
4147
  checkboxReserveRowMap = this.checkboxReserveRowMap,
3993
4148
  checkboxOpts = this.checkboxOpts,
3994
4149
  treeConfig = this.treeConfig,
3995
4150
  treeOpts = this.treeOpts;
4151
+ var childrenField = treeOpts.children || treeOpts.childrenField;
3996
4152
  var reserveSelection = [];
3997
4153
  if (checkboxOpts.reserve) {
3998
4154
  var afterFullIdMaps = {};
3999
4155
  if (treeConfig) {
4000
4156
  _xeUtils["default"].eachTree(afterFullData, function (row) {
4001
- afterFullIdMaps[(0, _util.getRowid)(_this36, row)] = 1;
4002
- }, treeOpts);
4157
+ afterFullIdMaps[(0, _util.getRowid)(_this35, row)] = 1;
4158
+ }, {
4159
+ children: childrenField
4160
+ });
4003
4161
  } else {
4004
4162
  afterFullData.forEach(function (row) {
4005
- afterFullIdMaps[(0, _util.getRowid)(_this36, row)] = 1;
4163
+ afterFullIdMaps[(0, _util.getRowid)(_this35, row)] = 1;
4006
4164
  });
4007
4165
  }
4008
4166
  _xeUtils["default"].each(checkboxReserveRowMap, function (oldRow, oldRowid) {
@@ -4061,33 +4219,39 @@ var Methods = {
4061
4219
  * 清空行为不管是否被禁用还是保留记录,都将彻底清空选中状态
4062
4220
  */
4063
4221
  clearCheckboxRow: function clearCheckboxRow() {
4064
- var _this37 = this;
4222
+ var _this36 = this;
4065
4223
  var tableFullData = this.tableFullData,
4066
4224
  treeConfig = this.treeConfig,
4067
4225
  treeOpts = this.treeOpts,
4068
4226
  checkboxOpts = this.checkboxOpts;
4069
4227
  var checkField = checkboxOpts.checkField,
4070
4228
  reserve = checkboxOpts.reserve;
4229
+ var childrenField = treeOpts.children || treeOpts.childrenField;
4230
+ var indeterminateField = checkboxOpts.indeterminateField || checkboxOpts.halfField;
4071
4231
  if (checkField) {
4232
+ var handleClearChecked = function handleClearChecked(item) {
4233
+ if (treeConfig && indeterminateField) {
4234
+ _xeUtils["default"].set(item, indeterminateField, false);
4235
+ }
4236
+ _xeUtils["default"].set(item, checkField, false);
4237
+ };
4072
4238
  if (treeConfig) {
4073
- _xeUtils["default"].eachTree(tableFullData, function (item) {
4074
- return _xeUtils["default"].set(item, checkField, false);
4075
- }, treeOpts);
4076
- } else {
4077
- tableFullData.forEach(function (item) {
4078
- return _xeUtils["default"].set(item, checkField, false);
4239
+ _xeUtils["default"].eachTree(tableFullData, handleClearChecked, {
4240
+ children: childrenField
4079
4241
  });
4242
+ } else {
4243
+ tableFullData.forEach(handleClearChecked);
4080
4244
  }
4081
4245
  }
4082
4246
  if (reserve) {
4083
4247
  tableFullData.forEach(function (row) {
4084
- return _this37.handleCheckboxReserveRow(row, false);
4248
+ return _this36.handleCheckboxReserveRow(row, false);
4085
4249
  });
4086
4250
  }
4087
4251
  this.isAllSelected = false;
4088
4252
  this.isIndeterminate = false;
4089
- this.selectCheckboxRows = [];
4090
- this.treeIndeterminates = [];
4253
+ this.selectCheckboxMaps = {};
4254
+ this.treeIndeterminateMaps = {};
4091
4255
  return this.$nextTick();
4092
4256
  },
4093
4257
  /**
@@ -4112,7 +4276,7 @@ var Methods = {
4112
4276
  * 单选,行选中事件
4113
4277
  */
4114
4278
  triggerRadioRowEvent: function triggerRadioRowEvent(evnt, params) {
4115
- var oldValue = this.selectRow,
4279
+ var oldValue = this.selectRadioRow,
4116
4280
  radioOpts = this.radioOpts;
4117
4281
  var row = params.row;
4118
4282
  var newValue = row;
@@ -4165,7 +4329,7 @@ var Methods = {
4165
4329
  return this.$nextTick();
4166
4330
  },
4167
4331
  isCheckedByRadioRow: function isCheckedByRadioRow(row) {
4168
- return this.selectRow === row;
4332
+ return this.selectRadioRow === row;
4169
4333
  },
4170
4334
  handleCheckedRadioRow: function handleCheckedRadioRow(row, isForce) {
4171
4335
  var radioOpts = this.radioOpts;
@@ -4173,7 +4337,7 @@ var Methods = {
4173
4337
  if (row && (isForce || !checkMethod || checkMethod({
4174
4338
  row: row
4175
4339
  }))) {
4176
- this.selectRow = row;
4340
+ this.selectRadioRow = row;
4177
4341
  this.handleRadioReserveRow(row);
4178
4342
  }
4179
4343
  return this.$nextTick();
@@ -4203,7 +4367,7 @@ var Methods = {
4203
4367
  * 用于单选行,手动清空用户的选择
4204
4368
  */
4205
4369
  clearRadioRow: function clearRadioRow() {
4206
- this.selectRow = null;
4370
+ this.selectRadioRow = null;
4207
4371
  return this.$nextTick();
4208
4372
  },
4209
4373
  /**
@@ -4216,30 +4380,18 @@ var Methods = {
4216
4380
  * 用于单选行,获取当已选中的数据
4217
4381
  */
4218
4382
  getRadioRecord: function getRadioRecord(isFull) {
4219
- var treeConfig = this.treeConfig,
4220
- treeOpts = this.treeOpts,
4221
- selectRow = this.selectRow,
4383
+ var selectRadioRow = this.selectRadioRow,
4222
4384
  fullDataRowIdData = this.fullDataRowIdData,
4223
- afterFullData = this.afterFullData;
4224
- if (selectRow) {
4225
- var rowid = (0, _util.getRowid)(this, selectRow);
4385
+ afterFullRowMaps = this.afterFullRowMaps;
4386
+ if (selectRadioRow) {
4387
+ var rowid = (0, _util.getRowid)(this, selectRadioRow);
4226
4388
  if (isFull) {
4227
4389
  if (!fullDataRowIdData[rowid]) {
4228
- return selectRow;
4390
+ return selectRadioRow;
4229
4391
  }
4230
4392
  } else {
4231
- if (treeConfig) {
4232
- var rowkey = (0, _util.getRowkey)(this);
4233
- var matchObj = _xeUtils["default"].findTree(afterFullData, function (row) {
4234
- return rowid === _xeUtils["default"].get(row, rowkey);
4235
- }, treeOpts);
4236
- if (matchObj) {
4237
- return selectRow;
4238
- }
4239
- } else {
4240
- if (afterFullData.indexOf(selectRow) > -1) {
4241
- return selectRow;
4242
- }
4393
+ if (afterFullRowMaps[rowid]) {
4394
+ return selectRadioRow;
4243
4395
  }
4244
4396
  }
4245
4397
  }
@@ -4333,12 +4485,12 @@ var Methods = {
4333
4485
  * 如果存在规则,则校验
4334
4486
  */
4335
4487
  handleChangeCell: function handleChangeCell(evnt, params) {
4336
- var _this38 = this;
4488
+ var _this37 = this;
4337
4489
  this.checkValidate('blur')["catch"](function (e) {
4338
4490
  return e;
4339
4491
  }).then(function () {
4340
- _this38.handleActived(params, evnt).then(function () {
4341
- return _this38.checkValidate('change');
4492
+ _this37.handleActived(params, evnt).then(function () {
4493
+ return _this37.checkValidate('change');
4342
4494
  })["catch"](function (e) {
4343
4495
  return e;
4344
4496
  });
@@ -4432,7 +4584,7 @@ var Methods = {
4432
4584
  * 如果是双击模式,则激活为编辑状态
4433
4585
  */
4434
4586
  triggerCellDblclickEvent: function triggerCellDblclickEvent(evnt, params) {
4435
- var _this39 = this;
4587
+ var _this38 = this;
4436
4588
  var editStore = this.editStore,
4437
4589
  editConfig = this.editConfig,
4438
4590
  editOpts = this.editOpts;
@@ -4445,15 +4597,15 @@ var Methods = {
4445
4597
  this.checkValidate('blur')["catch"](function (e) {
4446
4598
  return e;
4447
4599
  }).then(function () {
4448
- _this39.handleActived(params, evnt).then(function () {
4449
- return _this39.checkValidate('change');
4600
+ _this38.handleActived(params, evnt).then(function () {
4601
+ return _this38.checkValidate('change');
4450
4602
  })["catch"](function (e) {
4451
4603
  return e;
4452
4604
  });
4453
4605
  });
4454
4606
  } else if (editOpts.mode === 'cell') {
4455
4607
  this.handleActived(params, evnt).then(function () {
4456
- return _this39.checkValidate('change');
4608
+ return _this38.checkValidate('change');
4457
4609
  })["catch"](function (e) {
4458
4610
  return e;
4459
4611
  });
@@ -4463,7 +4615,7 @@ var Methods = {
4463
4615
  this.emitEvent('cell-dblclick', params, evnt);
4464
4616
  },
4465
4617
  handleDefaultSort: function handleDefaultSort() {
4466
- var _this40 = this;
4618
+ var _this39 = this;
4467
4619
  var sortConfig = this.sortConfig,
4468
4620
  sortOpts = this.sortOpts;
4469
4621
  var defaultSort = sortOpts.defaultSort;
@@ -4476,7 +4628,7 @@ var Methods = {
4476
4628
  var field = item.field,
4477
4629
  order = item.order;
4478
4630
  if (field && order) {
4479
- var column = _this40.getColumnByField(field);
4631
+ var column = _this39.getColumnByField(field);
4480
4632
  if (column && column.sortable) {
4481
4633
  column.order = order;
4482
4634
  column.sortTime = Date.now() + index;
@@ -4523,7 +4675,7 @@ var Methods = {
4523
4675
  }
4524
4676
  },
4525
4677
  sort: function sort(sortConfs, sortOrder) {
4526
- var _this41 = this;
4678
+ var _this40 = this;
4527
4679
  var sortOpts = this.sortOpts;
4528
4680
  var multiple = sortOpts.multiple,
4529
4681
  remote = sortOpts.remote,
@@ -4549,14 +4701,14 @@ var Methods = {
4549
4701
  order = confs.order;
4550
4702
  var column = field;
4551
4703
  if (_xeUtils["default"].isString(field)) {
4552
- column = _this41.getColumnByField(field);
4704
+ column = _this40.getColumnByField(field);
4553
4705
  }
4554
4706
  if (column && (column.sortable || column.remoteSort)) {
4555
4707
  if (!firstSortColumn) {
4556
4708
  firstSortColumn = column;
4557
4709
  }
4558
4710
  if (orders.indexOf(order) === -1) {
4559
- order = getNextSortOrder(_this41, column);
4711
+ order = getNextSortOrder(_this40, column);
4560
4712
  }
4561
4713
  if (column.order !== order) {
4562
4714
  column.order = order;
@@ -4569,8 +4721,8 @@ var Methods = {
4569
4721
  this.handleTableData(true);
4570
4722
  }
4571
4723
  return this.$nextTick().then(function () {
4572
- _this41.updateCellAreas();
4573
- return _this41.updateStyle();
4724
+ _this40.updateCellAreas();
4725
+ return _this40.updateStyle();
4574
4726
  });
4575
4727
  }
4576
4728
  return this.$nextTick();
@@ -4685,17 +4837,19 @@ var Methods = {
4685
4837
  return rest && rest.expandLoaded;
4686
4838
  },
4687
4839
  clearRowExpandLoaded: function clearRowExpandLoaded(row) {
4688
- var _this42 = this;
4689
4840
  var expandOpts = this.expandOpts,
4690
- expandLazyLoadeds = this.expandLazyLoadeds,
4841
+ rowExpandLazyLoadedMaps = this.rowExpandLazyLoadedMaps,
4691
4842
  fullAllDataRowMap = this.fullAllDataRowMap;
4692
4843
  var lazy = expandOpts.lazy;
4844
+ var rowid = (0, _util.getRowid)(this, row);
4693
4845
  var rest = fullAllDataRowMap.get(row);
4694
4846
  if (lazy && rest) {
4695
4847
  rest.expandLoaded = false;
4696
- _xeUtils["default"].remove(expandLazyLoadeds, function (item) {
4697
- return _this42.eqRow(item, row);
4698
- });
4848
+ var rowTempExpandLazyLoadedMaps = _objectSpread({}, rowExpandLazyLoadedMaps);
4849
+ if (rowTempExpandLazyLoadedMaps[rowid]) {
4850
+ delete rowTempExpandLazyLoadedMaps[rowid];
4851
+ }
4852
+ this.rowExpandLazyLoadedMaps = rowTempExpandLazyLoadedMaps;
4699
4853
  }
4700
4854
  return this.$nextTick();
4701
4855
  },
@@ -4704,13 +4858,14 @@ var Methods = {
4704
4858
  * @param {Row} row 行对象
4705
4859
  */
4706
4860
  reloadRowExpand: function reloadRowExpand(row) {
4707
- var _this43 = this;
4861
+ var _this41 = this;
4708
4862
  var expandOpts = this.expandOpts,
4709
- expandLazyLoadeds = this.expandLazyLoadeds;
4863
+ rowExpandLazyLoadedMaps = this.rowExpandLazyLoadedMaps;
4710
4864
  var lazy = expandOpts.lazy;
4711
- if (lazy && this.findRowIndexOf(expandLazyLoadeds, row) === -1) {
4865
+ var rowid = (0, _util.getRowid)(this, row);
4866
+ if (lazy && !rowExpandLazyLoadedMaps[rowid]) {
4712
4867
  this.clearRowExpandLoaded(row).then(function () {
4713
- return _this43.handleAsyncRowExpand(row);
4868
+ return _this41.handleAsyncRowExpand(row);
4714
4869
  });
4715
4870
  }
4716
4871
  return this.$nextTick();
@@ -4727,11 +4882,12 @@ var Methods = {
4727
4882
  */
4728
4883
  triggerRowExpandEvent: function triggerRowExpandEvent(evnt, params) {
4729
4884
  var expandOpts = this.expandOpts,
4730
- expandLazyLoadeds = this.expandLazyLoadeds,
4885
+ rowExpandLazyLoadedMaps = this.rowExpandLazyLoadedMaps,
4731
4886
  column = this.expandColumn;
4732
4887
  var row = params.row;
4733
4888
  var lazy = expandOpts.lazy;
4734
- if (!lazy || this.findRowIndexOf(expandLazyLoadeds, row) === -1) {
4889
+ var rowid = (0, _util.getRowid)(this, row);
4890
+ if (!lazy || !rowExpandLazyLoadedMaps[rowid]) {
4735
4891
  var expanded = !this.isExpandByRow(row);
4736
4892
  var columnIndex = this.getColumnIndex(column);
4737
4893
  var $columnIndex = this.getVMColumnIndex(column);
@@ -4782,37 +4938,57 @@ var Methods = {
4782
4938
  treeOpts = this.treeOpts,
4783
4939
  tableFullData = this.tableFullData,
4784
4940
  tableFullTreeData = this.tableFullTreeData;
4941
+ var childrenField = treeOpts.children || treeOpts.childrenField;
4785
4942
  var expandedRows = [];
4786
4943
  if (treeConfig) {
4787
4944
  _xeUtils["default"].eachTree(tableFullTreeData, function (row) {
4788
4945
  expandedRows.push(row);
4789
- }, treeOpts);
4946
+ }, {
4947
+ children: childrenField
4948
+ });
4790
4949
  } else {
4791
4950
  expandedRows = tableFullData;
4792
4951
  }
4793
4952
  return this.setRowExpand(expandedRows, expanded);
4794
4953
  },
4795
4954
  handleAsyncRowExpand: function handleAsyncRowExpand(row) {
4796
- var _this44 = this;
4797
- var rest = this.fullAllDataRowMap.get(row);
4955
+ var _this42 = this;
4956
+ var fullAllDataRowMap = this.fullAllDataRowMap,
4957
+ expandOpts = this.expandOpts;
4958
+ var rest = fullAllDataRowMap.get(row);
4798
4959
  return new Promise(function (resolve) {
4799
- _this44.expandLazyLoadeds.push(row);
4800
- _this44.expandOpts.loadMethod({
4801
- $table: _this44,
4802
- row: row,
4803
- rowIndex: _this44.getRowIndex(row),
4804
- $rowIndex: _this44.getVMRowIndex(row)
4805
- }).then(function () {
4806
- rest.expandLoaded = true;
4807
- _this44.rowExpandeds.push(row);
4808
- })["catch"](function () {
4809
- rest.expandLoaded = false;
4810
- })["finally"](function () {
4811
- _xeUtils["default"].remove(_this44.expandLazyLoadeds, function (item) {
4812
- return _this44.eqRow(item, row);
4960
+ var loadMethod = expandOpts.loadMethod;
4961
+ if (loadMethod) {
4962
+ var rowExpandLazyLoadedMaps = _this42.rowExpandLazyLoadedMaps;
4963
+ var rowTempExpandLazyLoadedMaps = _objectSpread({}, rowExpandLazyLoadedMaps);
4964
+ var rowid = (0, _util.getRowid)(_this42, row);
4965
+ rowTempExpandLazyLoadedMaps[rowid] = row;
4966
+ _this42.rowExpandLazyLoadedMaps = rowTempExpandLazyLoadedMaps;
4967
+ loadMethod({
4968
+ $table: _this42,
4969
+ row: row,
4970
+ rowIndex: _this42.getRowIndex(row),
4971
+ $rowIndex: _this42.getVMRowIndex(row)
4972
+ }).then(function () {
4973
+ rest.expandLoaded = true;
4974
+ var rowExpandedMaps = _this42.rowExpandedMaps;
4975
+ var rowTempExpandedMaps = _objectSpread({}, rowExpandedMaps);
4976
+ rowTempExpandedMaps[rowid] = row;
4977
+ _this42.rowExpandedMaps = rowTempExpandedMaps;
4978
+ })["catch"](function () {
4979
+ rest.expandLoaded = false;
4980
+ })["finally"](function () {
4981
+ var rowExpandLazyLoadedMaps = _this42.rowExpandLazyLoadedMaps;
4982
+ var rowTempExpandLazyLoadedMaps = _objectSpread({}, rowExpandLazyLoadedMaps);
4983
+ if (rowTempExpandLazyLoadedMaps[rowid]) {
4984
+ delete rowTempExpandLazyLoadedMaps[rowid];
4985
+ }
4986
+ _this42.rowExpandLazyLoadedMaps = rowTempExpandLazyLoadedMaps;
4987
+ resolve(_this42.$nextTick().then(_this42.recalculate));
4813
4988
  });
4814
- resolve(_this44.$nextTick().then(_this44.recalculate));
4815
- });
4989
+ } else {
4990
+ resolve();
4991
+ }
4816
4992
  });
4817
4993
  },
4818
4994
  /**
@@ -4823,12 +4999,13 @@ var Methods = {
4823
4999
  * @param {Boolean} expanded 是否展开
4824
5000
  */
4825
5001
  setRowExpand: function setRowExpand(rows, expanded) {
4826
- var _this45 = this;
4827
- var fullAllDataRowMap = this.fullAllDataRowMap,
4828
- expandLazyLoadeds = this.expandLazyLoadeds,
5002
+ var _this43 = this;
5003
+ var rowExpandedMaps = this.rowExpandedMaps,
5004
+ fullAllDataRowIdData = this.fullAllDataRowIdData,
5005
+ rowExpandLazyLoadedMaps = this.rowExpandLazyLoadedMaps,
4829
5006
  expandOpts = this.expandOpts,
4830
5007
  column = this.expandColumn;
4831
- var rowExpandeds = this.rowExpandeds;
5008
+ var rExpandedMaps = _objectSpread({}, rowExpandedMaps);
4832
5009
  var reserve = expandOpts.reserve,
4833
5010
  lazy = expandOpts.lazy,
4834
5011
  accordion = expandOpts.accordion,
@@ -4842,7 +5019,7 @@ var Methods = {
4842
5019
  }
4843
5020
  if (accordion) {
4844
5021
  // 只能同时展开一个
4845
- rowExpandeds = [];
5022
+ rExpandedMaps = {};
4846
5023
  rows = rows.slice(rows.length - 1, rows.length);
4847
5024
  }
4848
5025
  var validRows = toggleMethod ? rows.filter(function (row) {
@@ -4852,34 +5029,38 @@ var Methods = {
4852
5029
  columnIndex: columnIndex,
4853
5030
  $columnIndex: $columnIndex,
4854
5031
  row: row,
4855
- rowIndex: _this45.getRowIndex(row),
4856
- $rowIndex: _this45.getVMRowIndex(row)
5032
+ rowIndex: _this43.getRowIndex(row),
5033
+ $rowIndex: _this43.getVMRowIndex(row)
4857
5034
  });
4858
5035
  }) : rows;
4859
5036
  if (expanded) {
4860
5037
  validRows.forEach(function (row) {
4861
- if (_this45.findRowIndexOf(rowExpandeds, row) === -1) {
4862
- var rest = fullAllDataRowMap.get(row);
4863
- var isLoad = lazy && !rest.expandLoaded && _this45.findRowIndexOf(expandLazyLoadeds, row) === -1;
5038
+ var rowid = (0, _util.getRowid)(_this43, row);
5039
+ if (!rExpandedMaps[rowid]) {
5040
+ var rest = fullAllDataRowIdData[rowid];
5041
+ var isLoad = lazy && !rest.expandLoaded && !rowExpandLazyLoadedMaps[rowid];
4864
5042
  if (isLoad) {
4865
- lazyRests.push(_this45.handleAsyncRowExpand(row));
5043
+ lazyRests.push(_this43.handleAsyncRowExpand(row));
4866
5044
  } else {
4867
- rowExpandeds.push(row);
5045
+ rExpandedMaps[rowid] = row;
4868
5046
  }
4869
5047
  }
4870
5048
  });
4871
5049
  } else {
4872
- _xeUtils["default"].remove(rowExpandeds, function (row) {
4873
- return _this45.findRowIndexOf(validRows, row) > -1;
5050
+ validRows.forEach(function (item) {
5051
+ var rowid = (0, _util.getRowid)(_this43, item);
5052
+ if (rExpandedMaps[rowid]) {
5053
+ delete rExpandedMaps[rowid];
5054
+ }
4874
5055
  });
4875
5056
  }
4876
5057
  if (reserve) {
4877
5058
  validRows.forEach(function (row) {
4878
- return _this45.handleRowExpandReserve(row, expanded);
5059
+ return _this43.handleRowExpandReserve(row, expanded);
4879
5060
  });
4880
5061
  }
4881
5062
  }
4882
- this.rowExpandeds = rowExpandeds;
5063
+ this.rowExpandedMaps = rExpandedMaps;
4883
5064
  return Promise.all(lazyRests).then(this.recalculate);
4884
5065
  },
4885
5066
  /**
@@ -4887,28 +5068,28 @@ var Methods = {
4887
5068
  * @param {Row} row 行对象
4888
5069
  */
4889
5070
  isExpandByRow: function isExpandByRow(row) {
4890
- var rowExpandeds = this.rowExpandeds;
4891
- return this.findRowIndexOf(rowExpandeds, row) > -1;
5071
+ var rowExpandedMaps = this.rowExpandedMaps;
5072
+ var rowid = (0, _util.getRowid)(this, row);
5073
+ return !!rowExpandedMaps[rowid];
4892
5074
  },
4893
5075
  /**
4894
5076
  * 手动清空展开行状态,数据会恢复成未展开的状态
4895
5077
  */
4896
5078
  clearRowExpand: function clearRowExpand() {
4897
- var _this46 = this;
5079
+ var _this44 = this;
4898
5080
  var expandOpts = this.expandOpts,
4899
- rowExpandeds = this.rowExpandeds,
4900
5081
  tableFullData = this.tableFullData;
4901
5082
  var reserve = expandOpts.reserve;
4902
- var isExists = rowExpandeds.length;
4903
- this.rowExpandeds = [];
5083
+ var expList = this.getRowExpandRecords();
5084
+ this.rowExpandedMaps = {};
4904
5085
  if (reserve) {
4905
5086
  tableFullData.forEach(function (row) {
4906
- return _this46.handleRowExpandReserve(row, false);
5087
+ return _this44.handleRowExpandReserve(row, false);
4907
5088
  });
4908
5089
  }
4909
5090
  return this.$nextTick().then(function () {
4910
- if (isExists) {
4911
- _this46.recalculate();
5091
+ if (expList.length) {
5092
+ _this44.recalculate();
4912
5093
  }
4913
5094
  });
4914
5095
  },
@@ -4929,13 +5110,25 @@ var Methods = {
4929
5110
  }
4930
5111
  },
4931
5112
  getRowExpandRecords: function getRowExpandRecords() {
4932
- return this.rowExpandeds.slice(0);
5113
+ var rest = [];
5114
+ _xeUtils["default"].each(this.rowExpandedMaps, function (item) {
5115
+ if (item) {
5116
+ rest.push(item);
5117
+ }
5118
+ });
5119
+ return rest;
4933
5120
  },
4934
5121
  getTreeExpandRecords: function getTreeExpandRecords() {
4935
- return this.treeExpandeds.slice(0);
5122
+ var rest = [];
5123
+ _xeUtils["default"].each(this.treeExpandedMaps, function (item) {
5124
+ if (item) {
5125
+ rest.push(item);
5126
+ }
5127
+ });
5128
+ return rest;
4936
5129
  },
4937
5130
  /**
4938
- * 获取数表格状态
5131
+ * 获取树表格状态
4939
5132
  */
4940
5133
  getTreeStatus: function getTreeStatus() {
4941
5134
  if (this.treeConfig) {
@@ -4956,16 +5149,17 @@ var Methods = {
4956
5149
  },
4957
5150
  clearTreeExpandLoaded: function clearTreeExpandLoaded(row) {
4958
5151
  var treeOpts = this.treeOpts,
4959
- treeExpandeds = this.treeExpandeds,
5152
+ treeExpandedMaps = this.treeExpandedMaps,
4960
5153
  fullAllDataRowMap = this.fullAllDataRowMap;
4961
5154
  var transform = treeOpts.transform,
4962
5155
  lazy = treeOpts.lazy;
5156
+ var rowid = (0, _util.getRowid)(this, row);
4963
5157
  var rest = fullAllDataRowMap.get(row);
4964
5158
  if (lazy && rest) {
4965
5159
  rest.treeLoaded = false;
4966
- _xeUtils["default"].remove(treeExpandeds, function (item) {
4967
- return row === item;
4968
- });
5160
+ if (treeExpandedMaps[rowid]) {
5161
+ delete treeExpandedMaps[rowid];
5162
+ }
4969
5163
  }
4970
5164
  if (transform) {
4971
5165
  this.handleVirtualTreeToList();
@@ -4978,22 +5172,23 @@ var Methods = {
4978
5172
  * @param {Row} row 行对象
4979
5173
  */
4980
5174
  reloadTreeExpand: function reloadTreeExpand(row) {
4981
- var _this47 = this;
5175
+ var _this45 = this;
4982
5176
  var treeOpts = this.treeOpts,
4983
- treeLazyLoadeds = this.treeLazyLoadeds;
5177
+ treeExpandLazyLoadedMaps = this.treeExpandLazyLoadedMaps;
4984
5178
  var transform = treeOpts.transform,
4985
- lazy = treeOpts.lazy,
4986
- hasChild = treeOpts.hasChild;
4987
- if (lazy && row[hasChild] && treeLazyLoadeds.indexOf(row) === -1) {
5179
+ lazy = treeOpts.lazy;
5180
+ var hasChildField = treeOpts.hasChild || treeOpts.hasChildField;
5181
+ var rowid = (0, _util.getRowid)(this, row);
5182
+ if (lazy && row[hasChildField] && !treeExpandLazyLoadedMaps[rowid]) {
4988
5183
  this.clearTreeExpandLoaded(row).then(function () {
4989
- return _this47.handleAsyncTreeExpandChilds(row);
5184
+ return _this45.handleAsyncTreeExpandChilds(row);
4990
5185
  }).then(function () {
4991
5186
  if (transform) {
4992
- _this47.handleVirtualTreeToList();
4993
- return _this47.handleTableData();
5187
+ _this45.handleVirtualTreeToList();
5188
+ return _this45.handleTableData();
4994
5189
  }
4995
5190
  }).then(function () {
4996
- return _this47.recalculate();
5191
+ return _this45.recalculate();
4997
5192
  });
4998
5193
  }
4999
5194
  return this.$nextTick();
@@ -5010,11 +5205,12 @@ var Methods = {
5010
5205
  */
5011
5206
  triggerTreeExpandEvent: function triggerTreeExpandEvent(evnt, params) {
5012
5207
  var treeOpts = this.treeOpts,
5013
- treeLazyLoadeds = this.treeLazyLoadeds;
5208
+ treeExpandLazyLoadedMaps = this.treeExpandLazyLoadedMaps;
5014
5209
  var row = params.row,
5015
5210
  column = params.column;
5016
5211
  var lazy = treeOpts.lazy;
5017
- if (!lazy || treeLazyLoadeds.indexOf(row) === -1) {
5212
+ var rowid = (0, _util.getRowid)(this, row);
5213
+ if (!lazy || !treeExpandLazyLoadedMaps[rowid]) {
5018
5214
  var expanded = !this.isTreeExpandByRow(row);
5019
5215
  var columnIndex = this.getColumnIndex(column);
5020
5216
  var $columnIndex = this.getVMColumnIndex(column);
@@ -5044,6 +5240,7 @@ var Methods = {
5044
5240
  if (treeConfig) {
5045
5241
  var expandAll = treeOpts.expandAll,
5046
5242
  expandRowKeys = treeOpts.expandRowKeys;
5243
+ var childrenField = treeOpts.children || treeOpts.childrenField;
5047
5244
  if (expandAll) {
5048
5245
  this.setAllTreeExpand(true);
5049
5246
  } else if (expandRowKeys) {
@@ -5052,7 +5249,9 @@ var Methods = {
5052
5249
  expandRowKeys.forEach(function (rowid) {
5053
5250
  var matchObj = _xeUtils["default"].findTree(tableFullData, function (item) {
5054
5251
  return rowid === _xeUtils["default"].get(item, rowkey);
5055
- }, treeOpts);
5252
+ }, {
5253
+ children: childrenField
5254
+ });
5056
5255
  if (matchObj) {
5057
5256
  defExpandeds.push(matchObj.item);
5058
5257
  }
@@ -5062,59 +5261,67 @@ var Methods = {
5062
5261
  }
5063
5262
  },
5064
5263
  handleAsyncTreeExpandChilds: function handleAsyncTreeExpandChilds(row) {
5065
- var _this48 = this;
5066
- var fullAllDataRowMap = this.fullAllDataRowMap,
5067
- treeExpandeds = this.treeExpandeds,
5068
- treeOpts = this.treeOpts,
5069
- treeLazyLoadeds = this.treeLazyLoadeds,
5264
+ var _this46 = this;
5265
+ var treeOpts = this.treeOpts,
5070
5266
  checkboxOpts = this.checkboxOpts;
5071
5267
  var transform = treeOpts.transform,
5072
5268
  loadMethod = treeOpts.loadMethod;
5073
5269
  var checkStrictly = checkboxOpts.checkStrictly;
5074
- var rest = fullAllDataRowMap.get(row);
5075
5270
  return new Promise(function (resolve) {
5076
- treeLazyLoadeds.push(row);
5077
- loadMethod({
5078
- $table: _this48,
5079
- row: row
5080
- }).then(function (childRecords) {
5081
- // 响应成功后则展开行,并将子节点挂载到该节点下
5082
- rest.treeLoaded = true;
5083
- _xeUtils["default"].remove(treeLazyLoadeds, function (item) {
5084
- return item === row;
5085
- });
5086
- if (!_xeUtils["default"].isArray(childRecords)) {
5087
- childRecords = [];
5088
- }
5089
- if (childRecords) {
5090
- return _this48.loadTreeChildren(row, childRecords).then(function (childRows) {
5091
- if (childRows.length && treeExpandeds.indexOf(row) === -1) {
5092
- treeExpandeds.push(row);
5093
- }
5094
- // 如果当前节点已选中,则展开后子节点也被选中
5095
- if (!checkStrictly && _this48.isCheckedByCheckboxRow(row)) {
5096
- _this48.handleCheckedCheckboxRow(childRows, true, true);
5097
- }
5098
- return _this48.$nextTick().then(function () {
5099
- if (transform) {
5100
- return _this48.handleTableData();
5271
+ if (loadMethod) {
5272
+ var fullAllDataRowMap = _this46.fullAllDataRowMap,
5273
+ treeExpandLazyLoadedMaps = _this46.treeExpandLazyLoadedMaps;
5274
+ var rowid = (0, _util.getRowid)(_this46, row);
5275
+ var rest = fullAllDataRowMap.get(row);
5276
+ treeExpandLazyLoadedMaps[rowid] = row;
5277
+ loadMethod({
5278
+ $table: _this46,
5279
+ row: row
5280
+ }).then(function (childRecords) {
5281
+ // 响应成功后则展开行,并将子节点挂载到该节点下
5282
+ rest.treeLoaded = true;
5283
+ if (treeExpandLazyLoadedMaps[rowid]) {
5284
+ treeExpandLazyLoadedMaps[rowid] = null;
5285
+ }
5286
+ if (!_xeUtils["default"].isArray(childRecords)) {
5287
+ childRecords = [];
5288
+ }
5289
+ if (childRecords) {
5290
+ return _this46.loadTreeChildren(row, childRecords).then(function (childRows) {
5291
+ var treeExpandedMaps = _this46.treeExpandedMaps;
5292
+ var treeTempExpandedMaps = _objectSpread({}, treeExpandedMaps);
5293
+ if (childRows.length && !treeTempExpandedMaps[rowid]) {
5294
+ treeTempExpandedMaps[rowid] = row;
5295
+ _this46.treeExpandedMaps = treeTempExpandedMaps;
5101
5296
  }
5297
+ // 如果当前节点已选中,则展开后子节点也被选中
5298
+ if (!checkStrictly && _this46.isCheckedByCheckboxRow(row)) {
5299
+ _this46.handleCheckedCheckboxRow(childRows, true, true);
5300
+ }
5301
+ return _this46.$nextTick().then(function () {
5302
+ if (transform) {
5303
+ return _this46.handleTableData();
5304
+ }
5305
+ });
5102
5306
  });
5307
+ }
5308
+ })["catch"](function () {
5309
+ // 如果响应异常,则不展开,再次点击后将重新触发懒加载
5310
+ rest.treeLoaded = false;
5311
+ var treeExpandLazyLoadedMaps = _this46.treeExpandLazyLoadedMaps;
5312
+ if (treeExpandLazyLoadedMaps[rowid]) {
5313
+ treeExpandLazyLoadedMaps[rowid] = null;
5314
+ }
5315
+ })["finally"](function () {
5316
+ _this46.$nextTick().then(function () {
5317
+ return _this46.recalculate();
5318
+ }).then(function () {
5319
+ return resolve();
5103
5320
  });
5104
- }
5105
- })["catch"](function () {
5106
- // 如果响应异常,则不展开,再次点击后将重新触发懒加载
5107
- rest.treeLoaded = false;
5108
- _xeUtils["default"].remove(treeLazyLoadeds, function (item) {
5109
- return item === row;
5110
5321
  });
5111
- })["finally"](function () {
5112
- _this48.$nextTick().then(function () {
5113
- return _this48.recalculate();
5114
- }).then(function () {
5115
- return resolve();
5116
- });
5117
- });
5322
+ } else {
5323
+ resolve();
5324
+ }
5118
5325
  });
5119
5326
  },
5120
5327
  /**
@@ -5124,15 +5331,17 @@ var Methods = {
5124
5331
  setAllTreeExpand: function setAllTreeExpand(expanded) {
5125
5332
  var tableFullData = this.tableFullData,
5126
5333
  treeOpts = this.treeOpts;
5127
- var lazy = treeOpts.lazy,
5128
- children = treeOpts.children;
5334
+ var lazy = treeOpts.lazy;
5335
+ var childrenField = treeOpts.children || treeOpts.childrenField;
5129
5336
  var expandeds = [];
5130
5337
  _xeUtils["default"].eachTree(tableFullData, function (row) {
5131
- var rowChildren = row[children];
5338
+ var rowChildren = row[childrenField];
5132
5339
  if (lazy || rowChildren && rowChildren.length) {
5133
5340
  expandeds.push(row);
5134
5341
  }
5135
- }, treeOpts);
5342
+ }, {
5343
+ children: childrenField
5344
+ });
5136
5345
  return this.setTreeExpand(expandeds, expanded);
5137
5346
  },
5138
5347
  /**
@@ -5142,19 +5351,20 @@ var Methods = {
5142
5351
  * @returns
5143
5352
  */
5144
5353
  handleBaseTreeExpand: function handleBaseTreeExpand(rows, expanded) {
5145
- var _this49 = this;
5354
+ var _this47 = this;
5146
5355
  var fullAllDataRowMap = this.fullAllDataRowMap,
5147
5356
  tableFullData = this.tableFullData,
5148
- treeExpandeds = this.treeExpandeds,
5357
+ treeExpandedMaps = this.treeExpandedMaps,
5149
5358
  treeOpts = this.treeOpts,
5150
- treeLazyLoadeds = this.treeLazyLoadeds,
5359
+ treeExpandLazyLoadedMaps = this.treeExpandLazyLoadedMaps,
5151
5360
  treeNodeColumn = this.treeNodeColumn;
5152
5361
  var reserve = treeOpts.reserve,
5153
5362
  lazy = treeOpts.lazy,
5154
- hasChild = treeOpts.hasChild,
5155
- children = treeOpts.children,
5156
5363
  accordion = treeOpts.accordion,
5157
5364
  toggleMethod = treeOpts.toggleMethod;
5365
+ var treeTempExpandedMaps = _objectSpread({}, treeExpandedMaps);
5366
+ var childrenField = treeOpts.children || treeOpts.childrenField;
5367
+ var hasChildField = treeOpts.hasChild || treeOpts.hasChildField;
5158
5368
  var result = [];
5159
5369
  var columnIndex = this.getColumnIndex(treeNodeColumn);
5160
5370
  var $columnIndex = this.getVMColumnIndex(treeNodeColumn);
@@ -5172,38 +5382,48 @@ var Methods = {
5172
5382
  // 同一级只能展开一个
5173
5383
  var matchObj = _xeUtils["default"].findTree(tableFullData, function (item) {
5174
5384
  return item === validRows[0];
5175
- }, treeOpts);
5385
+ }, {
5386
+ children: childrenField
5387
+ });
5176
5388
  if (matchObj) {
5177
- _xeUtils["default"].remove(treeExpandeds, function (item) {
5178
- return matchObj.items.indexOf(item) > -1;
5389
+ matchObj.items.forEach(function (item) {
5390
+ var rowid = (0, _util.getRowid)(_this47, item);
5391
+ if (treeTempExpandedMaps[rowid]) {
5392
+ delete treeTempExpandedMaps[rowid];
5393
+ }
5179
5394
  });
5180
5395
  }
5181
5396
  }
5182
5397
  if (expanded) {
5183
5398
  validRows.forEach(function (row) {
5184
- if (treeExpandeds.indexOf(row) === -1) {
5399
+ var rowid = (0, _util.getRowid)(_this47, row);
5400
+ if (!treeTempExpandedMaps[rowid]) {
5185
5401
  var rest = fullAllDataRowMap.get(row);
5186
- var isLoad = lazy && row[hasChild] && !rest.treeLoaded && treeLazyLoadeds.indexOf(row) === -1;
5402
+ var isLoad = lazy && row[hasChildField] && !rest.treeLoaded && !treeExpandLazyLoadedMaps[rowid];
5187
5403
  // 是否使用懒加载
5188
5404
  if (isLoad) {
5189
- result.push(_this49.handleAsyncTreeExpandChilds(row));
5405
+ result.push(_this47.handleAsyncTreeExpandChilds(row));
5190
5406
  } else {
5191
- if (row[children] && row[children].length) {
5192
- treeExpandeds.push(row);
5407
+ if (row[childrenField] && row[childrenField].length) {
5408
+ treeTempExpandedMaps[rowid] = row;
5193
5409
  }
5194
5410
  }
5195
5411
  }
5196
5412
  });
5197
5413
  } else {
5198
- _xeUtils["default"].remove(treeExpandeds, function (row) {
5199
- return validRows.indexOf(row) > -1;
5414
+ validRows.forEach(function (item) {
5415
+ var rowid = (0, _util.getRowid)(_this47, item);
5416
+ if (treeTempExpandedMaps[rowid]) {
5417
+ delete treeTempExpandedMaps[rowid];
5418
+ }
5200
5419
  });
5201
5420
  }
5202
5421
  if (reserve) {
5203
5422
  validRows.forEach(function (row) {
5204
- return _this49.handleTreeExpandReserve(row, expanded);
5423
+ return _this47.handleTreeExpandReserve(row, expanded);
5205
5424
  });
5206
5425
  }
5426
+ this.treeExpandedMaps = treeTempExpandedMaps;
5207
5427
  return Promise.all(result).then(this.recalculate);
5208
5428
  },
5209
5429
  /**
@@ -5213,12 +5433,12 @@ var Methods = {
5213
5433
  * @returns
5214
5434
  */
5215
5435
  handleVirtualTreeExpand: function handleVirtualTreeExpand(rows, expanded) {
5216
- var _this50 = this;
5436
+ var _this48 = this;
5217
5437
  return this.handleBaseTreeExpand(rows, expanded).then(function () {
5218
- _this50.handleVirtualTreeToList();
5219
- return _this50.handleTableData();
5438
+ _this48.handleVirtualTreeToList();
5439
+ return _this48.handleTableData();
5220
5440
  }).then(function () {
5221
- return _this50.recalculate();
5441
+ return _this48.recalculate();
5222
5442
  });
5223
5443
  },
5224
5444
  /**
@@ -5251,33 +5471,36 @@ var Methods = {
5251
5471
  * @param {Row} row 行对象
5252
5472
  */
5253
5473
  isTreeExpandByRow: function isTreeExpandByRow(row) {
5254
- return this.treeExpandeds.indexOf(row) > -1;
5474
+ var treeExpandedMaps = this.treeExpandedMaps;
5475
+ return !!treeExpandedMaps[(0, _util.getRowid)(this, row)];
5255
5476
  },
5256
5477
  /**
5257
5478
  * 手动清空树形节点的展开状态,数据会恢复成未展开的状态
5258
5479
  */
5259
5480
  clearTreeExpand: function clearTreeExpand() {
5260
- var _this51 = this;
5481
+ var _this49 = this;
5261
5482
  var treeOpts = this.treeOpts,
5262
- treeExpandeds = this.treeExpandeds,
5263
5483
  tableFullData = this.tableFullData;
5264
5484
  var transform = treeOpts.transform,
5265
5485
  reserve = treeOpts.reserve;
5266
- var isExists = treeExpandeds.length;
5267
- this.treeExpandeds = [];
5486
+ var childrenField = treeOpts.children || treeOpts.childrenField;
5487
+ var expList = this.getTreeExpandRecords();
5488
+ this.treeExpandedMaps = {};
5268
5489
  if (reserve) {
5269
5490
  _xeUtils["default"].eachTree(tableFullData, function (row) {
5270
- return _this51.handleTreeExpandReserve(row, false);
5271
- }, treeOpts);
5491
+ return _this49.handleTreeExpandReserve(row, false);
5492
+ }, {
5493
+ children: childrenField
5494
+ });
5272
5495
  }
5273
5496
  return this.handleTableData().then(function () {
5274
5497
  if (transform) {
5275
- _this51.handleVirtualTreeToList();
5276
- return _this51.handleTableData();
5498
+ _this49.handleVirtualTreeToList();
5499
+ return _this49.handleTableData();
5277
5500
  }
5278
5501
  }).then(function () {
5279
- if (isExists) {
5280
- _this51.recalculate();
5502
+ if (expList.length) {
5503
+ _this49.recalculate();
5281
5504
  }
5282
5505
  });
5283
5506
  },
@@ -5396,28 +5619,28 @@ var Methods = {
5396
5619
  },
5397
5620
  // 计算可视渲染相关数据
5398
5621
  computeScrollLoad: function computeScrollLoad() {
5399
- var _this52 = this;
5622
+ var _this50 = this;
5400
5623
  return this.$nextTick().then(function () {
5401
- var sYOpts = _this52.sYOpts,
5402
- sXOpts = _this52.sXOpts,
5403
- scrollXLoad = _this52.scrollXLoad,
5404
- scrollYLoad = _this52.scrollYLoad,
5405
- scrollXStore = _this52.scrollXStore,
5406
- scrollYStore = _this52.scrollYStore;
5624
+ var sYOpts = _this50.sYOpts,
5625
+ sXOpts = _this50.sXOpts,
5626
+ scrollXLoad = _this50.scrollXLoad,
5627
+ scrollYLoad = _this50.scrollYLoad,
5628
+ scrollXStore = _this50.scrollXStore,
5629
+ scrollYStore = _this50.scrollYStore;
5407
5630
  // 计算 X 逻辑
5408
5631
  if (scrollXLoad) {
5409
- var _computeVirtualX3 = computeVirtualX(_this52),
5632
+ var _computeVirtualX3 = computeVirtualX(_this50),
5410
5633
  visibleXSize = _computeVirtualX3.visibleSize;
5411
5634
  var offsetXSize = sXOpts.oSize ? _xeUtils["default"].toNumber(sXOpts.oSize) : _dom.browse.msie ? 10 : _dom.browse.edge ? 5 : 0;
5412
5635
  scrollXStore.offsetSize = offsetXSize;
5413
5636
  scrollXStore.visibleSize = visibleXSize;
5414
5637
  scrollXStore.endIndex = Math.max(scrollXStore.startIndex + scrollXStore.visibleSize + offsetXSize, scrollXStore.endIndex);
5415
- _this52.updateScrollXData();
5638
+ _this50.updateScrollXData();
5416
5639
  } else {
5417
- _this52.updateScrollXSpace();
5640
+ _this50.updateScrollXSpace();
5418
5641
  }
5419
5642
  // 计算 Y 逻辑
5420
- var _computeVirtualY = computeVirtualY(_this52),
5643
+ var _computeVirtualY = computeVirtualY(_this50),
5421
5644
  rowHeight = _computeVirtualY.rowHeight,
5422
5645
  visibleYSize = _computeVirtualY.visibleSize;
5423
5646
  scrollYStore.rowHeight = rowHeight;
@@ -5426,12 +5649,12 @@ var Methods = {
5426
5649
  scrollYStore.offsetSize = offsetYSize;
5427
5650
  scrollYStore.visibleSize = visibleYSize;
5428
5651
  scrollYStore.endIndex = Math.max(scrollYStore.startIndex + visibleYSize + offsetYSize, scrollYStore.endIndex);
5429
- _this52.updateScrollYData();
5652
+ _this50.updateScrollYData();
5430
5653
  } else {
5431
- _this52.updateScrollYSpace();
5654
+ _this50.updateScrollYSpace();
5432
5655
  }
5433
- _this52.rowHeight = rowHeight;
5434
- _this52.$nextTick(_this52.updateStyle);
5656
+ _this50.rowHeight = rowHeight;
5657
+ _this50.$nextTick(_this50.updateStyle);
5435
5658
  });
5436
5659
  },
5437
5660
  handleTableColumn: function handleTableColumn() {
@@ -5441,11 +5664,11 @@ var Methods = {
5441
5664
  this.tableColumn = scrollXLoad ? visibleColumn.slice(scrollXStore.startIndex, scrollXStore.endIndex) : visibleColumn.slice(0);
5442
5665
  },
5443
5666
  updateScrollXData: function updateScrollXData() {
5444
- var _this53 = this;
5667
+ var _this51 = this;
5445
5668
  // this.tableColumn = []
5446
5669
  this.$nextTick(function () {
5447
- _this53.handleTableColumn();
5448
- _this53.updateScrollXSpace();
5670
+ _this51.handleTableColumn();
5671
+ _this51.updateScrollXSpace();
5449
5672
  });
5450
5673
  },
5451
5674
  // 更新横向 X 可视渲染上下剩余空间大小
@@ -5496,11 +5719,11 @@ var Methods = {
5496
5719
  }
5497
5720
  },
5498
5721
  updateScrollYData: function updateScrollYData() {
5499
- var _this54 = this;
5722
+ var _this52 = this;
5500
5723
  // this.tableData = []
5501
5724
  this.$nextTick(function () {
5502
- _this54.handleTableData();
5503
- _this54.updateScrollYSpace();
5725
+ _this52.handleTableData();
5726
+ _this52.updateScrollYSpace();
5504
5727
  });
5505
5728
  },
5506
5729
  // 更新纵向 Y 可视渲染上下剩余空间大小
@@ -5541,7 +5764,7 @@ var Methods = {
5541
5764
  * @param {Number} scrollTop 上距离
5542
5765
  */
5543
5766
  scrollTo: function scrollTo(scrollLeft, scrollTop) {
5544
- var _this55 = this;
5767
+ var _this53 = this;
5545
5768
  var $refs = this.$refs;
5546
5769
  var tableBody = $refs.tableBody,
5547
5770
  rightBody = $refs.rightBody,
@@ -5558,7 +5781,7 @@ var Methods = {
5558
5781
  if (this.scrollXLoad || this.scrollYLoad) {
5559
5782
  return new Promise(function (resolve) {
5560
5783
  return setTimeout(function () {
5561
- return resolve(_this55.$nextTick());
5784
+ return resolve(_this53.$nextTick());
5562
5785
  }, 50);
5563
5786
  });
5564
5787
  }
@@ -5600,26 +5823,29 @@ var Methods = {
5600
5823
  * @param {Row} row 行对象
5601
5824
  */
5602
5825
  scrollToTreeRow: function scrollToTreeRow(row) {
5603
- var _this56 = this;
5826
+ var _this54 = this;
5604
5827
  var tableFullData = this.tableFullData,
5605
5828
  treeConfig = this.treeConfig,
5606
5829
  treeOpts = this.treeOpts;
5830
+ var childrenField = treeOpts.children || treeOpts.childrenField;
5607
5831
  var rests = [];
5608
5832
  if (treeConfig) {
5609
5833
  var matchObj = _xeUtils["default"].findTree(tableFullData, function (item) {
5610
5834
  return item === row;
5611
- }, treeOpts);
5835
+ }, {
5836
+ children: childrenField
5837
+ });
5612
5838
  if (matchObj) {
5613
5839
  var nodes = matchObj.nodes;
5614
5840
  nodes.forEach(function (row, index) {
5615
- if (index < nodes.length - 1 && !_this56.isTreeExpandByRow(row)) {
5616
- rests.push(_this56.setTreeExpand(row, true));
5841
+ if (index < nodes.length - 1 && !_this54.isTreeExpandByRow(row)) {
5842
+ rests.push(_this54.setTreeExpand(row, true));
5617
5843
  }
5618
5844
  });
5619
5845
  }
5620
5846
  }
5621
5847
  return Promise.all(rests).then(function () {
5622
- return (0, _util.rowToVisible)(_this56, row);
5848
+ return (0, _util.rowToVisible)(_this54, row);
5623
5849
  });
5624
5850
  },
5625
5851
  /**
@@ -5674,30 +5900,30 @@ var Methods = {
5674
5900
  * 如果单元格配置了校验规则,则会进行校验
5675
5901
  */
5676
5902
  updateStatus: function updateStatus(slotParams, cellValue) {
5677
- var _this57 = this;
5903
+ var _this55 = this;
5678
5904
  var customVal = !_xeUtils["default"].isUndefined(cellValue);
5679
5905
  return this.$nextTick().then(function () {
5680
- var $refs = _this57.$refs,
5681
- editRules = _this57.editRules,
5682
- validStore = _this57.validStore;
5906
+ var $refs = _this55.$refs,
5907
+ editRules = _this55.editRules,
5908
+ validStore = _this55.validStore;
5683
5909
  if (slotParams && $refs.tableBody && editRules) {
5684
5910
  var row = slotParams.row,
5685
5911
  column = slotParams.column;
5686
5912
  var type = 'change';
5687
- if (_this57.hasCellRules(type, row, column)) {
5688
- var cell = _this57.getCell(row, column);
5913
+ if (_this55.hasCellRules(type, row, column)) {
5914
+ var cell = _this55.getCell(row, column);
5689
5915
  if (cell) {
5690
- return _this57.validCellRules(type, row, column, cellValue).then(function () {
5916
+ return _this55.validCellRules(type, row, column, cellValue).then(function () {
5691
5917
  if (customVal && validStore.visible) {
5692
5918
  setCellValue(row, column, cellValue);
5693
5919
  }
5694
- _this57.clearValidate();
5920
+ _this55.clearValidate();
5695
5921
  })["catch"](function (_ref8) {
5696
5922
  var rule = _ref8.rule;
5697
5923
  if (customVal) {
5698
5924
  setCellValue(row, column, cellValue);
5699
5925
  }
5700
- _this57.showValidTooltip({
5926
+ _this55.showValidTooltip({
5701
5927
  rule: rule,
5702
5928
  row: row,
5703
5929
  column: column,
@@ -5717,13 +5943,13 @@ var Methods = {
5717
5943
  * @param {TableMergeConfig[]} merges { row: Row|number, column: ColumnInfo|number, rowspan: number, colspan: number }
5718
5944
  */
5719
5945
  setMergeCells: function setMergeCells(merges) {
5720
- var _this58 = this;
5946
+ var _this56 = this;
5721
5947
  if (this.spanMethod) {
5722
5948
  (0, _log.errLog)('vxe.error.errConflicts', ['merge-cells', 'span-method']);
5723
5949
  }
5724
5950
  setMerges(this, merges, this.mergeList, this.afterFullData);
5725
5951
  return this.$nextTick().then(function () {
5726
- return _this58.updateCellAreas();
5952
+ return _this56.updateCellAreas();
5727
5953
  });
5728
5954
  },
5729
5955
  /**
@@ -5731,13 +5957,13 @@ var Methods = {
5731
5957
  * @param {TableMergeConfig[]} merges 多个或数组 [{row:Row|number, col:ColumnInfo|number}]
5732
5958
  */
5733
5959
  removeMergeCells: function removeMergeCells(merges) {
5734
- var _this59 = this;
5960
+ var _this57 = this;
5735
5961
  if (this.spanMethod) {
5736
5962
  (0, _log.errLog)('vxe.error.errConflicts', ['merge-cells', 'span-method']);
5737
5963
  }
5738
5964
  var rest = removeMerges(this, merges, this.mergeList, this.afterFullData);
5739
5965
  return this.$nextTick().then(function () {
5740
- _this59.updateCellAreas();
5966
+ _this57.updateCellAreas();
5741
5967
  return rest;
5742
5968
  });
5743
5969
  },
@@ -5758,23 +5984,23 @@ var Methods = {
5758
5984
  this.setMergeFooterItems(this.mergeFooterItems);
5759
5985
  },
5760
5986
  setMergeFooterItems: function setMergeFooterItems(merges) {
5761
- var _this60 = this;
5987
+ var _this58 = this;
5762
5988
  if (this.footerSpanMethod) {
5763
5989
  (0, _log.errLog)('vxe.error.errConflicts', ['merge-footer-items', 'footer-span-method']);
5764
5990
  }
5765
5991
  setMerges(this, merges, this.mergeFooterList, null);
5766
5992
  return this.$nextTick().then(function () {
5767
- return _this60.updateCellAreas();
5993
+ return _this58.updateCellAreas();
5768
5994
  });
5769
5995
  },
5770
5996
  removeMergeFooterItems: function removeMergeFooterItems(merges) {
5771
- var _this61 = this;
5997
+ var _this59 = this;
5772
5998
  if (this.footerSpanMethod) {
5773
5999
  (0, _log.errLog)('vxe.error.errConflicts', ['merge-footer-items', 'footer-span-method']);
5774
6000
  }
5775
6001
  var rest = removeMerges(this, merges, this.mergeFooterList, null);
5776
6002
  return this.$nextTick().then(function () {
5777
- _this61.updateCellAreas();
6003
+ _this59.updateCellAreas();
5778
6004
  return rest;
5779
6005
  });
5780
6006
  },
@@ -5874,10 +6100,10 @@ var Methods = {
5874
6100
  };
5875
6101
  if (_xeUtils["default"].isString(formatter)) {
5876
6102
  var gFormatOpts = _formats.formats.get(formatter);
5877
- cellLabel = gFormatOpts && gFormatOpts.formatMethod ? gFormatOpts.formatMethod(formatParams) : '';
6103
+ cellLabel = gFormatOpts && gFormatOpts.cellFormatMethod ? gFormatOpts.cellFormatMethod(formatParams) : '';
5878
6104
  } else if (_xeUtils["default"].isArray(formatter)) {
5879
6105
  var _gFormatOpts = _formats.formats.get(formatter[0]);
5880
- cellLabel = _gFormatOpts && _gFormatOpts.formatMethod ? _gFormatOpts.formatMethod.apply(_gFormatOpts, [formatParams].concat(_toConsumableArray(formatter.slice(1)))) : '';
6106
+ cellLabel = _gFormatOpts && _gFormatOpts.cellFormatMethod ? _gFormatOpts.cellFormatMethod.apply(_gFormatOpts, [formatParams].concat(_toConsumableArray(formatter.slice(1)))) : '';
5881
6107
  } else {
5882
6108
  cellLabel = formatter(formatParams);
5883
6109
  }
@@ -5891,9 +6117,9 @@ var Methods = {
5891
6117
  return cellLabel;
5892
6118
  },
5893
6119
  findRowIndexOf: function findRowIndexOf(list, row) {
5894
- var _this62 = this;
6120
+ var _this60 = this;
5895
6121
  return row ? _xeUtils["default"].findIndexOf(list, function (item) {
5896
- return _this62.eqRow(item, row);
6122
+ return _this60.eqRow(item, row);
5897
6123
  }) : -1;
5898
6124
  },
5899
6125
  eqRow: function eqRow(row1, row2) {
@@ -5914,7 +6140,7 @@ var Methods = {
5914
6140
  };
5915
6141
 
5916
6142
  // Module methods
5917
- var funcs = 'setFilter,openFilter,clearFilter,getCheckedFilters,closeMenu,setActiveCellArea,getActiveCellArea,getCellAreas,clearCellAreas,copyCellArea,cutCellArea,pasteCellArea,getCopyCellArea,getCopyCellAreas,clearCopyCellArea,setCellAreas,openFind,openReplace,closeFNR,getSelectedCell,clearSelected,insert,insertAt,remove,removeCheckboxRow,removeRadioRow,removeCurrentRow,getRecordset,getInsertRecords,getRemoveRecords,getUpdateRecords,clearEdit,clearActived,getEditRecord,getActiveRecord,isEditByRow,isActiveByRow,setEditRow,setActiveRow,setEditCell,setActiveCell,setSelectCell,clearValidate,fullValidate,validate,openExport,openPrint,exportData,openImport,importData,saveFile,readFile,importByFile,print'.split(',');
6143
+ var funcs = 'setFilter,openFilter,clearFilter,getCheckedFilters,closeMenu,setActiveCellArea,getActiveCellArea,getCellAreas,clearCellAreas,copyCellArea,cutCellArea,pasteCellArea,getCopyCellArea,getCopyCellAreas,clearCopyCellArea,setCellAreas,openFind,openReplace,closeFNR,getSelectedCell,clearSelected,insert,insertAt,insertNextAt,remove,removeCheckboxRow,removeRadioRow,removeCurrentRow,getRecordset,getInsertRecords,getRemoveRecords,getUpdateRecords,clearEdit,clearActived,getEditRecord,getActiveRecord,isEditByRow,isActiveByRow,setEditRow,setActiveRow,setEditCell,setActiveCell,setSelectCell,clearValidate,fullValidate,validate,openExport,openPrint,exportData,openImport,importData,saveFile,readFile,importByFile,print'.split(',');
5918
6144
  funcs.forEach(function (name) {
5919
6145
  Methods[name] = function () {
5920
6146
  if (process.env.NODE_ENV === 'development') {