vxe-table 4.17.21 → 4.17.24

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.
@@ -366,8 +366,9 @@ export const Cell = {
366
366
  const { fullColumnFieldData } = tableInternalData;
367
367
  const { computeAggregateOpts } = $table.getComputeMaps();
368
368
  const aggregateOpts = computeAggregateOpts.value;
369
- const { mode, showTotal, totalMethod, countFields, contentMethod, mapChildrenField } = aggregateOpts;
370
- const aggCalcMethod = aggregateOpts.calcValuesMethod || aggregateOpts.countMethod || aggregateOpts.aggregateMethod;
369
+ const { mode, showTotal, totalMethod, countFields, contentMethod, formatValuesMethod, mapChildrenField } = aggregateOpts;
370
+ const aggData = aggRow.aggData;
371
+ const currAggData = aggData ? aggData[field] : null;
371
372
  const groupField = aggRow.groupField;
372
373
  const groupContent = aggRow.groupContent;
373
374
  const childList = mapChildrenField ? (aggRow[mapChildrenField] || []) : [];
@@ -409,9 +410,10 @@ export const Cell = {
409
410
  cellValue = $table.getPivotTableAggregateCellAggValue(params);
410
411
  }
411
412
  else if (aggFunc === true || (countFields && countFields.includes(field))) {
412
- if (aggCalcMethod) {
413
- ctParams.aggValue = childCount;
414
- cellValue = `${aggCalcMethod(ctParams)}`;
413
+ cellValue = currAggData ? currAggData.value : childCount;
414
+ ctParams.aggValue = cellValue;
415
+ if (formatValuesMethod) {
416
+ cellValue = formatValuesMethod(ctParams);
415
417
  }
416
418
  }
417
419
  }
@@ -818,6 +818,13 @@ export default defineVxeComponent({
818
818
  });
819
819
  return rgColumns;
820
820
  });
821
+ const computeAggFuncColumns = computed(() => {
822
+ const { rowGroupList, tableColumn } = reactData;
823
+ if (rowGroupList.length) {
824
+ return tableColumn.filter(column => column.aggFunc);
825
+ }
826
+ return [];
827
+ });
821
828
  const refMaps = {
822
829
  refElem,
823
830
  refTooltip,
@@ -917,6 +924,7 @@ export default defineVxeComponent({
917
924
  computeVirtualScrollBars,
918
925
  computeRowGroupFields,
919
926
  computeRowGroupColumns,
927
+ computeAggFuncColumns,
920
928
  computeFNROpts,
921
929
  computeSXOpts,
922
930
  computeSYOpts
@@ -2072,26 +2080,52 @@ export default defineVxeComponent({
2072
2080
  }
2073
2081
  };
2074
2082
  const getOrderField = (column) => {
2075
- const { sortBy, sortType } = column;
2076
- return (row) => {
2077
- let cellValue;
2078
- if (sortBy) {
2079
- cellValue = XEUtils.isFunction(sortBy) ? sortBy({ row, column }) : XEUtils.get(row, sortBy);
2080
- }
2081
- else {
2082
- cellValue = tableMethods.getCellLabel(row, column);
2083
- }
2084
- if (!sortType || sortType === 'auto') {
2085
- return isNaN(cellValue) ? cellValue : XEUtils.toNumber(cellValue);
2086
- }
2087
- else if (sortType === 'number') {
2088
- return XEUtils.toNumber(cellValue);
2089
- }
2090
- else if (sortType === 'string') {
2091
- return XEUtils.toValueString(cellValue);
2083
+ const { isRowGroupStatus } = reactData;
2084
+ const { sortBy, sortType, aggFunc } = column;
2085
+ return isRowGroupStatus && aggFunc
2086
+ ? (row) => {
2087
+ if (row.isAggregate) {
2088
+ const aggData = row.aggData;
2089
+ const currAggData = aggData ? aggData[column.field] : null;
2090
+ return currAggData ? currAggData.value : null;
2091
+ }
2092
+ let cellValue;
2093
+ if (sortBy) {
2094
+ cellValue = XEUtils.isFunction(sortBy) ? sortBy({ row, column }) : XEUtils.get(row, sortBy);
2095
+ }
2096
+ else {
2097
+ cellValue = tableMethods.getCellLabel(row, column);
2098
+ }
2099
+ if (!sortType || sortType === 'auto') {
2100
+ return isNaN(cellValue) ? cellValue : XEUtils.toNumber(cellValue);
2101
+ }
2102
+ else if (sortType === 'number') {
2103
+ return XEUtils.toNumber(cellValue);
2104
+ }
2105
+ else if (sortType === 'string') {
2106
+ return XEUtils.toValueString(cellValue);
2107
+ }
2108
+ return cellValue;
2092
2109
  }
2093
- return cellValue;
2094
- };
2110
+ : (row) => {
2111
+ let cellValue;
2112
+ if (sortBy) {
2113
+ cellValue = XEUtils.isFunction(sortBy) ? sortBy({ row, column }) : XEUtils.get(row, sortBy);
2114
+ }
2115
+ else {
2116
+ cellValue = tableMethods.getCellLabel(row, column);
2117
+ }
2118
+ if (!sortType || sortType === 'auto') {
2119
+ return isNaN(cellValue) ? cellValue : XEUtils.toNumber(cellValue);
2120
+ }
2121
+ else if (sortType === 'number') {
2122
+ return XEUtils.toNumber(cellValue);
2123
+ }
2124
+ else if (sortType === 'string') {
2125
+ return XEUtils.toValueString(cellValue);
2126
+ }
2127
+ return cellValue;
2128
+ };
2095
2129
  };
2096
2130
  const updateAfterListIndex = () => {
2097
2131
  const { treeConfig } = props;
@@ -3415,8 +3449,11 @@ export default defineVxeComponent({
3415
3449
  handleUpdateAggValues();
3416
3450
  };
3417
3451
  const handleeGroupSummary = (aggList) => {
3452
+ const { fullColumnFieldData } = internalData;
3418
3453
  const aggregateOpts = computeAggregateOpts.value;
3454
+ const aggFuncColumns = computeAggFuncColumns.value;
3419
3455
  const { mapChildrenField } = aggregateOpts;
3456
+ const aggCalcMethod = aggregateOpts.calcValuesMethod || aggregateOpts.countMethod || aggregateOpts.aggregateMethod;
3420
3457
  if (mapChildrenField) {
3421
3458
  XEUtils.lastEach(aggList, aggRow => {
3422
3459
  let count = 0;
@@ -3433,6 +3470,64 @@ export default defineVxeComponent({
3433
3470
  if ($xeTable.handlePivotTableAggregateData) {
3434
3471
  $xeTable.handlePivotTableAggregateData(aggList);
3435
3472
  }
3473
+ else {
3474
+ if (aggFuncColumns.length) {
3475
+ XEUtils.lastEach(aggList, aggRow => {
3476
+ const aggDtObj = {};
3477
+ const aggData = aggRow.aggData;
3478
+ const groupField = aggRow.groupField;
3479
+ const groupContent = aggRow.groupContent;
3480
+ const childList = mapChildrenField ? (aggRow[mapChildrenField] || []) : [];
3481
+ const childCount = aggRow.childCount;
3482
+ const colRest = fullColumnFieldData[groupField] || {};
3483
+ aggFuncColumns.forEach(column => {
3484
+ const { field } = column;
3485
+ const currAggData = aggData ? aggData[field] : null;
3486
+ const ctParams = {
3487
+ $table: $xeTable,
3488
+ groupField,
3489
+ groupColumn: (colRest ? colRest.column : null),
3490
+ column,
3491
+ groupValue: groupContent,
3492
+ childList,
3493
+ childCount,
3494
+ aggValue: currAggData ? currAggData.value : 0,
3495
+ /**
3496
+ * 已废弃
3497
+ * @deprecated
3498
+ */
3499
+ children: childList,
3500
+ /**
3501
+ * 已废弃
3502
+ * @deprecated
3503
+ */
3504
+ totalValue: childCount
3505
+ };
3506
+ let aggVal = 0;
3507
+ // 如果下层同时也是分组
3508
+ if (childList.length && childList[0].isAggregate) {
3509
+ XEUtils.each(childList, (row) => {
3510
+ if (row.isAggregate) {
3511
+ const currAggData = row.aggData[field];
3512
+ if (currAggData) {
3513
+ aggVal += currAggData.value;
3514
+ }
3515
+ }
3516
+ });
3517
+ }
3518
+ else {
3519
+ aggVal = aggCalcMethod ? aggCalcMethod(ctParams) : aggRow.childCount;
3520
+ }
3521
+ aggDtObj[field] = {
3522
+ type: 'count',
3523
+ value: aggVal,
3524
+ label: aggVal
3525
+ };
3526
+ });
3527
+ aggRow.aggData = aggDtObj;
3528
+ });
3529
+ }
3530
+ }
3436
3531
  }
3437
3532
  };
3438
3533
  const updateGroupData = () => {
@@ -4635,6 +4730,34 @@ export default defineVxeComponent({
4635
4730
  rowExpandEl.scrollTop = bodyScrollElem.scrollTop;
4636
4731
  }
4637
4732
  };
4733
+ const handleColumnVisible = (visible) => {
4734
+ return function (fieldOrColumn) {
4735
+ let status = false;
4736
+ const cols = XEUtils.isArray(fieldOrColumn) ? fieldOrColumn : [fieldOrColumn];
4737
+ cols.forEach(item => {
4738
+ const column = handleFieldOrColumn($xeTable, item);
4739
+ if (column) {
4740
+ if (column.children && column.children.length) {
4741
+ XEUtils.eachTree([column], (item) => {
4742
+ item.visible = visible;
4743
+ item.renderVisible = visible;
4744
+ });
4745
+ }
4746
+ else {
4747
+ column.visible = visible;
4748
+ column.renderVisible = visible;
4749
+ }
4750
+ if (!status) {
4751
+ status = true;
4752
+ }
4753
+ }
4754
+ });
4755
+ if (status) {
4756
+ return $xeTable.handleCustom();
4757
+ }
4758
+ return nextTick();
4759
+ };
4760
+ };
4638
4761
  tableMethods = {
4639
4762
  dispatchEvent,
4640
4763
  getEl() {
@@ -5649,43 +5772,11 @@ export default defineVxeComponent({
5649
5772
  /**
5650
5773
  * 隐藏指定列
5651
5774
  */
5652
- hideColumn(fieldOrColumn) {
5653
- let status = false;
5654
- const cols = XEUtils.isArray(fieldOrColumn) ? fieldOrColumn : [fieldOrColumn];
5655
- cols.forEach(item => {
5656
- const column = handleFieldOrColumn($xeTable, item);
5657
- if (column && column.visible) {
5658
- column.visible = false;
5659
- if (!status) {
5660
- status = true;
5661
- }
5662
- }
5663
- });
5664
- if (status) {
5665
- return tablePrivateMethods.handleCustom();
5666
- }
5667
- return nextTick();
5668
- },
5775
+ hideColumn: handleColumnVisible(false),
5669
5776
  /**
5670
5777
  * 显示指定列
5671
5778
  */
5672
- showColumn(fieldOrColumn) {
5673
- let status = false;
5674
- const cols = XEUtils.isArray(fieldOrColumn) ? fieldOrColumn : [fieldOrColumn];
5675
- cols.forEach(item => {
5676
- const column = handleFieldOrColumn($xeTable, item);
5677
- if (column && !column.visible) {
5678
- column.visible = true;
5679
- if (!status) {
5680
- status = true;
5681
- }
5682
- }
5683
- });
5684
- if (status) {
5685
- return tablePrivateMethods.handleCustom();
5686
- }
5687
- return nextTick();
5688
- },
5779
+ showColumn: handleColumnVisible(true),
5689
5780
  setColumnWidth(fieldOrColumn, width) {
5690
5781
  const { elemStore } = internalData;
5691
5782
  let status = false;
@@ -6899,6 +6990,10 @@ export default defineVxeComponent({
6899
6990
  const { isRowGroupStatus } = reactData;
6900
6991
  return isRowGroupStatus && row && row.isAggregate && childrenField && mapChildrenField ? (row[mapChildrenField] || []) : [];
6901
6992
  },
6993
+ refreshAggregateCalcValues() {
6994
+ updateGroupData();
6995
+ return nextTick();
6996
+ },
6902
6997
  isAggregateExpandByRow(row) {
6903
6998
  const { rowGroupExpandedFlag } = reactData;
6904
6999
  const { rowGroupExpandedMaps } = internalData;
@@ -9592,7 +9687,7 @@ export default defineVxeComponent({
9592
9687
  reactData.mergeFootFlag++;
9593
9688
  },
9594
9689
  handleAggregateSummaryData() {
9595
- return updateGroupData();
9690
+ return $xeTable.refreshAggregateCalcValues();
9596
9691
  },
9597
9692
  triggerHeaderTitleEvent(evnt, iconParams, params) {
9598
9693
  const tipContent = iconParams.content || iconParams.message;
@@ -13396,6 +13491,7 @@ export default defineVxeComponent({
13396
13491
  if (resizeObserver) {
13397
13492
  resizeObserver.disconnect();
13398
13493
  }
13494
+ $xeTable.closeTooltip();
13399
13495
  tableMethods.closeFilter();
13400
13496
  if ($xeTable.closeMenu) {
13401
13497
  $xeTable.closeMenu();
package/es/ui/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { VxeUI } from '@vxe-ui/core';
2
2
  import { getFuncText } from './src/utils';
3
- export const version = "4.17.21";
3
+ export const version = "4.17.24";
4
4
  VxeUI.version = version;
5
5
  VxeUI.tableVersion = version;
6
6
  VxeUI.setConfig({
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${"4.17.21"}`;
3
+ const version = `table v${"4.17.24"}`;
4
4
  export const warnLog = log.create('warn', version);
5
5
  export const errLog = log.create('error', version);