vxe-table 3.9.9 → 3.9.11

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.
@@ -323,7 +323,6 @@ const Methods = {
323
323
  const { scrollXLoad, scrollYLoad } = this;
324
324
  return this.handleTableData(true).then(() => {
325
325
  this.updateFooter();
326
- this.checkSelectionStatus();
327
326
  if (scrollXLoad || scrollYLoad) {
328
327
  if (scrollXLoad) {
329
328
  this.updateScrollXSpace();
@@ -640,7 +639,7 @@ const Methods = {
640
639
  * 牺牲数据组装的耗时,用来换取使用过程中的流畅
641
640
  */
642
641
  cacheRowMap(isSource) {
643
- const { treeConfig, treeOpts, tableFullData, fullAllDataRowIdData, fullAllDataRowMap, tableFullTreeData } = this;
642
+ const { treeConfig, treeOpts, tableFullData, fullAllDataRowIdData, tableFullTreeData } = this;
644
643
  const childrenField = treeOpts.children || treeOpts.childrenField;
645
644
  const hasChildField = treeOpts.hasChild || treeOpts.hasChildField;
646
645
  const rowkey = getRowkey(this);
@@ -672,7 +671,6 @@ const Methods = {
672
671
  this.fullDataRowIdData = fullDataRowIdMaps;
673
672
  }
674
673
  this.fullAllDataRowIdData = fullAllDataRowIdMaps;
675
- fullAllDataRowMap.clear();
676
674
  if (treeConfig) {
677
675
  XEUtils.eachTree(tableFullTreeData, handleCache, { children: childrenField });
678
676
  }
@@ -710,11 +708,12 @@ const Methods = {
710
708
  return this.params;
711
709
  },
712
710
  loadTreeChildren(row, childRecords) {
713
- const { keepSource, tableSourceData, treeOpts, fullDataRowIdData, fullDataRowMap, fullAllDataRowMap, fullAllDataRowIdData, sourceDataRowIdData } = this;
711
+ const $xeTable = this;
712
+ const { keepSource, tableSourceData, treeOpts, fullDataRowIdData, fullAllDataRowIdData, sourceDataRowIdData } = this;
714
713
  const { transform, mapChildrenField } = treeOpts;
715
714
  const childrenField = treeOpts.children || treeOpts.childrenField;
716
- const rest = fullAllDataRowIdData[getRowid(this, row)];
717
- const parentLevel = rest ? rest.level : 0;
715
+ const parentRest = fullAllDataRowIdData[getRowid($xeTable, row)];
716
+ const parentLevel = parentRest ? parentRest.level : 0;
718
717
  return this.createData(childRecords).then((rows) => {
719
718
  if (keepSource) {
720
719
  const rowid = getRowid(this, row);
@@ -728,13 +727,11 @@ const Methods = {
728
727
  });
729
728
  }
730
729
  XEUtils.eachTree(rows, (childRow, index, items, path, parent, nodes) => {
731
- const rowid = getRowid(this, childRow);
732
- const parentRow = parent || row;
730
+ const rowid = getRowid($xeTable, childRow);
731
+ const parentRow = parent || parentRest.row;
733
732
  const rest = { row: childRow, rowid, seq: -1, index, _index: -1, $index: -1, items, parent: parentRow, level: parentLevel + nodes.length };
734
733
  fullDataRowIdData[rowid] = rest;
735
- fullDataRowMap.set(childRow, rest);
736
734
  fullAllDataRowIdData[rowid] = rest;
737
- fullAllDataRowMap.set(childRow, rest);
738
735
  }, { children: childrenField });
739
736
  row[childrenField] = rows;
740
737
  if (transform) {
@@ -1194,6 +1191,7 @@ const Methods = {
1194
1191
  return null;
1195
1192
  },
1196
1193
  getCellLabel(row, fieldOrColumn) {
1194
+ const $xeTable = this;
1197
1195
  const column = handleFieldOrColumn(this, fieldOrColumn);
1198
1196
  if (!column) {
1199
1197
  return null;
@@ -1202,15 +1200,15 @@ const Methods = {
1202
1200
  const cellValue = getCellValue(row, column);
1203
1201
  let cellLabel = cellValue;
1204
1202
  if (formatter) {
1205
- let rest, formatData;
1206
- const { fullAllDataRowMap } = this;
1203
+ let formatData;
1204
+ const { fullAllDataRowIdData } = $xeTable;
1205
+ const rowid = getRowid($xeTable, row);
1207
1206
  const colid = column.id;
1208
- const cacheFormat = fullAllDataRowMap.has(row);
1209
- if (cacheFormat) {
1210
- rest = fullAllDataRowMap.get(row);
1207
+ const rest = fullAllDataRowIdData[rowid];
1208
+ if (rest) {
1211
1209
  formatData = rest.formatData;
1212
1210
  if (!formatData) {
1213
- formatData = fullAllDataRowMap.get(row).formatData = {};
1211
+ formatData = fullAllDataRowIdData[rowid].formatData = {};
1214
1212
  }
1215
1213
  if (rest && formatData[colid]) {
1216
1214
  if (formatData[colid].value === cellValue) {
@@ -1607,8 +1605,9 @@ const Methods = {
1607
1605
  * @param {Row} row 行对象
1608
1606
  */
1609
1607
  getRowid(row) {
1610
- const fullAllDataRowMap = this.fullAllDataRowMap;
1611
- return fullAllDataRowMap.has(row) ? fullAllDataRowMap.get(row).rowid : null;
1608
+ const $xeTable = this;
1609
+ const rowid = XEUtils.get(row, getRowkey($xeTable));
1610
+ return XEUtils.eqNull(rowid) ? '' : encodeURIComponent(rowid);
1612
1611
  },
1613
1612
  /**
1614
1613
  * 获取处理后的表格数据
@@ -3379,7 +3378,8 @@ const Methods = {
3379
3378
  if (rows && !XEUtils.isArray(rows)) {
3380
3379
  rows = [rows];
3381
3380
  }
3382
- rows.forEach((row) => this.handleSelectRow({ row }, !!value, isForce));
3381
+ this.handleBatchSelectRows(rows, !!value, isForce);
3382
+ this.checkSelectionStatus();
3383
3383
  return this.$nextTick();
3384
3384
  },
3385
3385
  /**
@@ -3388,6 +3388,9 @@ const Methods = {
3388
3388
  * @param {Boolean} value 是否选中
3389
3389
  */
3390
3390
  setCheckboxRow(rows, value) {
3391
+ if (rows && !XEUtils.isArray(rows)) {
3392
+ rows = [rows];
3393
+ }
3391
3394
  return this.handleCheckedCheckboxRow(rows, value, true);
3392
3395
  },
3393
3396
  isCheckedByCheckboxRow(row) {
@@ -3402,6 +3405,59 @@ const Methods = {
3402
3405
  const { treeIndeterminateMaps } = this;
3403
3406
  return !!treeIndeterminateMaps[getRowid(this, row)] && !this.isCheckedByCheckboxRow(row);
3404
3407
  },
3408
+ /**
3409
+ * 多行
3410
+ * 多选,行选中事件
3411
+ * value 选中true 不选false 半选-1
3412
+ */
3413
+ handleBatchSelectRows(rows, value, isForce) {
3414
+ const $xeTable = this;
3415
+ const { treeConfig } = $xeTable;
3416
+ const { selectCheckboxMaps, checkboxOpts } = this;
3417
+ const { checkField, checkStrictly, checkMethod } = checkboxOpts;
3418
+ if (checkField) {
3419
+ if (treeConfig && !checkStrictly) {
3420
+ rows.forEach(row => {
3421
+ this.handleSelectRow({ row }, value, isForce);
3422
+ });
3423
+ }
3424
+ else {
3425
+ rows.forEach(row => {
3426
+ if (isForce || (!checkMethod || checkMethod({ row }))) {
3427
+ XEUtils.set(row, checkField, value);
3428
+ this.handleCheckboxReserveRow(row, value);
3429
+ }
3430
+ });
3431
+ }
3432
+ }
3433
+ else {
3434
+ if (treeConfig && !checkStrictly) {
3435
+ rows.forEach(row => {
3436
+ this.handleSelectRow({ row }, value, isForce);
3437
+ });
3438
+ }
3439
+ else {
3440
+ const selectRowMaps = Object.assign({}, selectCheckboxMaps);
3441
+ rows.forEach(row => {
3442
+ const rowid = getRowid($xeTable, row);
3443
+ if (isForce || (!checkMethod || checkMethod({ row }))) {
3444
+ if (value) {
3445
+ if (!selectRowMaps[rowid]) {
3446
+ selectRowMaps[rowid] = row;
3447
+ }
3448
+ }
3449
+ else {
3450
+ if (selectRowMaps[rowid]) {
3451
+ delete selectRowMaps[rowid];
3452
+ }
3453
+ }
3454
+ this.handleCheckboxReserveRow(row, value);
3455
+ }
3456
+ });
3457
+ this.selectCheckboxMaps = selectRowMaps;
3458
+ }
3459
+ }
3460
+ },
3405
3461
  /**
3406
3462
  * 多选,行选中事件
3407
3463
  * value 选中true 不选false 半选-1
@@ -3574,7 +3630,6 @@ const Methods = {
3574
3630
  }
3575
3631
  }
3576
3632
  this.selectCheckboxMaps = selectRowMaps;
3577
- this.checkSelectionStatus();
3578
3633
  },
3579
3634
  handleToggleCheckRowEvent(evnt, params) {
3580
3635
  const { selectCheckboxMaps, checkboxOpts } = this;
@@ -3595,6 +3650,7 @@ const Methods = {
3595
3650
  }
3596
3651
  else {
3597
3652
  this.handleSelectRow(params, value);
3653
+ this.checkSelectionStatus();
3598
3654
  }
3599
3655
  },
3600
3656
  triggerCheckRowEvent(evnt, params, value) {
@@ -3622,6 +3678,7 @@ const Methods = {
3622
3678
  }
3623
3679
  if (!checkMethod || checkMethod({ row })) {
3624
3680
  this.handleSelectRow(params, value);
3681
+ this.checkSelectionStatus();
3625
3682
  this.emitEvent('checkbox-change', Object.assign({
3626
3683
  records: this.getCheckboxRecords(),
3627
3684
  reserves: this.getCheckboxReserveRecords(),
@@ -3638,6 +3695,7 @@ const Methods = {
3638
3695
  const { checkField } = checkboxOpts;
3639
3696
  const value = checkField ? !XEUtils.get(row, checkField) : !selectCheckboxMaps[getRowid(this, row)];
3640
3697
  this.handleSelectRow({ row }, value, true);
3698
+ this.checkSelectionStatus();
3641
3699
  return this.$nextTick();
3642
3700
  },
3643
3701
  handleCheckedAllCheckboxRow(value, isForce) {
@@ -3851,9 +3909,10 @@ const Methods = {
3851
3909
  },
3852
3910
  // 还原展开、选中等相关状态
3853
3911
  handleReserveStatus() {
3854
- const { expandColumn, treeOpts, treeConfig, fullDataRowIdData, fullAllDataRowMap, currentRow, selectRadioRow, radioReserveRow, radioOpts, checkboxOpts, selectCheckboxMaps, rowExpandedMaps, treeExpandedMaps, expandOpts } = this;
3912
+ const $xeTable = this;
3913
+ const { expandColumn, treeOpts, treeConfig, fullDataRowIdData, fullAllDataRowIdData, currentRow, selectRadioRow, radioReserveRow, radioOpts, checkboxOpts, selectCheckboxMaps, rowExpandedMaps, treeExpandedMaps, expandOpts } = this;
3855
3914
  // 单选框
3856
- if (selectRadioRow && !fullAllDataRowMap.has(selectRadioRow)) {
3915
+ if (selectRadioRow && !fullAllDataRowIdData[getRowid($xeTable, selectRadioRow)]) {
3857
3916
  this.selectRadioRow = null; // 刷新单选行状态
3858
3917
  }
3859
3918
  // 还原保留选中状态
@@ -3869,7 +3928,7 @@ const Methods = {
3869
3928
  if (checkboxOpts.reserve) {
3870
3929
  this.handleCheckedCheckboxRow(handleReserveRow(this, this.checkboxReserveRowMap), true, true);
3871
3930
  }
3872
- if (currentRow && !fullAllDataRowMap.has(currentRow)) {
3931
+ if (currentRow && !this.fullAllDataRowIdData[getRowid($xeTable, currentRow)]) {
3873
3932
  this.currentRow = null; // 刷新当前行状态
3874
3933
  }
3875
3934
  // 行展开
@@ -4601,14 +4660,17 @@ const Methods = {
4601
4660
  * @param {Row} row 行对象
4602
4661
  */
4603
4662
  isRowExpandLoaded(row) {
4604
- const rest = this.fullAllDataRowMap.get(row);
4605
- return rest && rest.expandLoaded;
4663
+ const $xeTable = this;
4664
+ const { fullAllDataRowIdData } = this;
4665
+ const rest = fullAllDataRowIdData[getRowid($xeTable, row)];
4666
+ return rest && !!rest.expandLoaded;
4606
4667
  },
4607
4668
  clearRowExpandLoaded(row) {
4608
- const { expandOpts, rowExpandLazyLoadedMaps, fullAllDataRowMap } = this;
4669
+ const $xeTable = this;
4670
+ const { expandOpts, rowExpandLazyLoadedMaps, fullAllDataRowIdData } = this;
4609
4671
  const { lazy } = expandOpts;
4610
- const rowid = getRowid(this, row);
4611
- const rest = fullAllDataRowMap.get(row);
4672
+ const rowid = getRowid($xeTable, row);
4673
+ const rest = fullAllDataRowIdData[rowid];
4612
4674
  if (lazy && rest) {
4613
4675
  rest.expandLoaded = false;
4614
4676
  const rowTempExpandLazyLoadedMaps = Object.assign({}, rowExpandLazyLoadedMaps);
@@ -4704,32 +4766,27 @@ const Methods = {
4704
4766
  return this.setRowExpand(expandedRows, expanded);
4705
4767
  },
4706
4768
  handleAsyncRowExpand(row) {
4707
- const { fullAllDataRowMap, expandOpts } = this;
4708
- const rest = fullAllDataRowMap.get(row);
4769
+ const $xeTable = this;
4709
4770
  return new Promise(resolve => {
4771
+ const { expandOpts } = this;
4710
4772
  const { loadMethod } = expandOpts;
4711
4773
  if (loadMethod) {
4712
- const { rowExpandLazyLoadedMaps } = this;
4713
- const rowTempExpandLazyLoadedMaps = Object.assign({}, rowExpandLazyLoadedMaps);
4714
- const rowid = getRowid(this, row);
4715
- rowTempExpandLazyLoadedMaps[rowid] = row;
4716
- this.rowExpandLazyLoadedMaps = rowTempExpandLazyLoadedMaps;
4717
- loadMethod({ $table: this, row, rowIndex: this.getRowIndex(row), $rowIndex: this.getVMRowIndex(row) }).then(() => {
4718
- rest.expandLoaded = true;
4774
+ const { rowExpandLazyLoadedMaps, fullAllDataRowIdData } = this;
4775
+ const rowid = getRowid($xeTable, row);
4776
+ const rest = fullAllDataRowIdData[rowid];
4777
+ rowExpandLazyLoadedMaps[rowid] = row;
4778
+ loadMethod({ $table: $xeTable, row, rowIndex: this.getRowIndex(row), $rowIndex: this.getVMRowIndex(row) }).then(() => {
4719
4779
  const { rowExpandedMaps } = this;
4720
- const rowTempExpandedMaps = Object.assign({}, rowExpandedMaps);
4721
- rowTempExpandedMaps[rowid] = row;
4722
- this.rowExpandedMaps = rowTempExpandedMaps;
4780
+ rest.expandLoaded = true;
4781
+ rowExpandedMaps[rowid] = row;
4723
4782
  }).catch(() => {
4724
4783
  rest.expandLoaded = false;
4725
4784
  }).finally(() => {
4726
4785
  const { rowExpandLazyLoadedMaps } = this;
4727
- const rowTempExpandLazyLoadedMaps = Object.assign({}, rowExpandLazyLoadedMaps);
4728
- if (rowTempExpandLazyLoadedMaps[rowid]) {
4729
- delete rowTempExpandLazyLoadedMaps[rowid];
4786
+ if (rowExpandLazyLoadedMaps[rowid]) {
4787
+ delete rowExpandLazyLoadedMaps[rowid];
4730
4788
  }
4731
- this.rowExpandLazyLoadedMaps = rowTempExpandLazyLoadedMaps;
4732
- resolve(this.$nextTick().then(this.recalculate));
4789
+ this.$nextTick().then(() => this.recalculate()).then(() => resolve());
4733
4790
  });
4734
4791
  }
4735
4792
  else {
@@ -4875,14 +4932,17 @@ const Methods = {
4875
4932
  * @param {Row} row 行对象
4876
4933
  */
4877
4934
  isTreeExpandLoaded(row) {
4878
- const rest = this.fullAllDataRowMap.get(row);
4879
- return rest && rest.treeLoaded;
4935
+ const $xeTable = this;
4936
+ const { fullAllDataRowIdData } = this;
4937
+ const rest = fullAllDataRowIdData[getRowid($xeTable, row)];
4938
+ return rest && !!rest.treeLoaded;
4880
4939
  },
4881
4940
  clearTreeExpandLoaded(row) {
4882
- const { treeOpts, treeExpandedMaps, fullAllDataRowMap } = this;
4941
+ const $xeTable = this;
4942
+ const { treeOpts, treeExpandedMaps, fullAllDataRowIdData } = this;
4883
4943
  const { transform, lazy } = treeOpts;
4884
- const rowid = getRowid(this, row);
4885
- const rest = fullAllDataRowMap.get(row);
4944
+ const rowid = getRowid($xeTable, row);
4945
+ const rest = fullAllDataRowIdData[rowid];
4886
4946
  if (lazy && rest) {
4887
4947
  rest.treeLoaded = false;
4888
4948
  if (treeExpandedMaps[rowid]) {
@@ -4976,20 +5036,20 @@ const Methods = {
4976
5036
  }
4977
5037
  },
4978
5038
  handleAsyncTreeExpandChilds(row) {
5039
+ const $xeTable = this;
4979
5040
  const { treeOpts, checkboxOpts } = this;
4980
5041
  const { transform, loadMethod } = treeOpts;
4981
5042
  const { checkStrictly } = checkboxOpts;
4982
5043
  return new Promise(resolve => {
4983
5044
  if (loadMethod) {
4984
- const { fullAllDataRowMap, treeExpandLazyLoadedMaps } = this;
4985
- const rowid = getRowid(this, row);
4986
- const rest = fullAllDataRowMap.get(row);
5045
+ const { treeExpandLazyLoadedMaps, fullAllDataRowIdData } = this;
5046
+ const rowid = getRowid($xeTable, row);
5047
+ const rest = fullAllDataRowIdData[rowid];
4987
5048
  treeExpandLazyLoadedMaps[rowid] = row;
4988
- loadMethod({ $table: this, row }).then((childRecords) => {
4989
- // 响应成功后则展开行,并将子节点挂载到该节点下
5049
+ Promise.resolve(loadMethod({ $table: $xeTable, row })).then((childRecords) => {
4990
5050
  rest.treeLoaded = true;
4991
5051
  if (treeExpandLazyLoadedMaps[rowid]) {
4992
- treeExpandLazyLoadedMaps[rowid] = null;
5052
+ delete treeExpandLazyLoadedMaps[rowid];
4993
5053
  }
4994
5054
  if (!XEUtils.isArray(childRecords)) {
4995
5055
  childRecords = [];
@@ -4997,14 +5057,12 @@ const Methods = {
4997
5057
  if (childRecords) {
4998
5058
  return this.loadTreeChildren(row, childRecords).then((childRows) => {
4999
5059
  const { treeExpandedMaps } = this;
5000
- const treeTempExpandedMaps = Object.assign({}, treeExpandedMaps);
5001
- if (childRows.length && !treeTempExpandedMaps[rowid]) {
5002
- treeTempExpandedMaps[rowid] = row;
5003
- this.treeExpandedMaps = treeTempExpandedMaps;
5060
+ if (childRows.length && !treeExpandedMaps[rowid]) {
5061
+ treeExpandedMaps[rowid] = row;
5004
5062
  }
5005
5063
  // 如果当前节点已选中,则展开后子节点也被选中
5006
5064
  if (!checkStrictly && this.isCheckedByCheckboxRow(row)) {
5007
- this.handleCheckedCheckboxRow(childRows, true, true);
5065
+ this.handleCheckedCheckboxRow(childRows, true);
5008
5066
  }
5009
5067
  return this.$nextTick().then(() => {
5010
5068
  if (transform) {
@@ -5014,11 +5072,10 @@ const Methods = {
5014
5072
  });
5015
5073
  }
5016
5074
  }).catch(() => {
5017
- // 如果响应异常,则不展开,再次点击后将重新触发懒加载
5018
- rest.treeLoaded = false;
5019
5075
  const { treeExpandLazyLoadedMaps } = this;
5076
+ rest.treeLoaded = false;
5020
5077
  if (treeExpandLazyLoadedMaps[rowid]) {
5021
- treeExpandLazyLoadedMaps[rowid] = null;
5078
+ delete treeExpandLazyLoadedMaps[rowid];
5022
5079
  }
5023
5080
  }).finally(() => {
5024
5081
  this.$nextTick().then(() => this.recalculate()).then(() => resolve());
@@ -5053,7 +5110,7 @@ const Methods = {
5053
5110
  * @returns
5054
5111
  */
5055
5112
  handleBaseTreeExpand(rows, expanded) {
5056
- const { fullAllDataRowMap, tableFullData, treeExpandedMaps, treeOpts, treeExpandLazyLoadedMaps, treeNodeColumn } = this;
5113
+ const { fullAllDataRowIdData, tableFullData, treeExpandedMaps, treeOpts, treeExpandLazyLoadedMaps, treeNodeColumn } = this;
5057
5114
  const { reserve, lazy, accordion, toggleMethod } = treeOpts;
5058
5115
  const treeTempExpandedMaps = Object.assign({}, treeExpandedMaps);
5059
5116
  const childrenField = treeOpts.children || treeOpts.childrenField;
@@ -5079,7 +5136,7 @@ const Methods = {
5079
5136
  validRows.forEach((row) => {
5080
5137
  const rowid = getRowid(this, row);
5081
5138
  if (!treeTempExpandedMaps[rowid]) {
5082
- const rest = fullAllDataRowMap.get(row);
5139
+ const rest = fullAllDataRowIdData[rowid];
5083
5140
  const isLoad = lazy && row[hasChildField] && !rest.treeLoaded && !treeExpandLazyLoadedMaps[rowid];
5084
5141
  // 是否使用懒加载
5085
5142
  if (isLoad) {
@@ -736,7 +736,6 @@ export default {
736
736
  // 渲染所有列
737
737
  visibleColumn: [],
738
738
  // 缓存数据集
739
- fullAllDataRowMap: new Map(),
740
739
  fullAllDataRowIdData: {},
741
740
  fullDataRowMap: new Map(),
742
741
  fullDataRowIdData: {},
package/es/ui/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { VxeUI } from '@vxe-ui/core';
2
2
  import { getFuncText } from './src/utils';
3
- export const version = "3.9.9";
3
+ export const version = "3.9.11";
4
4
  VxeUI.version = version;
5
- VxeUI.tableVersion = "3.9.9";
5
+ VxeUI.tableVersion = "3.9.11";
6
6
  VxeUI.setConfig({
7
7
  emptyCell: ' ',
8
8
  table: {
package/es/ui/src/log.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { VxeUI } from '@vxe-ui/core';
2
2
  const { log } = VxeUI;
3
- const version = `table v${"3.9.9"}`;
3
+ const version = `table v${"3.9.11"}`;
4
4
  export const warnLog = log.create('warn', version);
5
5
  export const errLog = log.create('error', version);