vxe-table 3.19.21 → 3.19.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.
@@ -364,8 +364,9 @@ export const Cell = {
364
364
  const aggRow = row;
365
365
  const { fullColumnFieldData } = tableInternalData;
366
366
  const aggregateOpts = $table.computeAggregateOpts;
367
- const { mode, showTotal, totalMethod, countFields, contentMethod, mapChildrenField } = aggregateOpts;
368
- const aggCalcMethod = aggregateOpts.calcValuesMethod || aggregateOpts.countMethod || aggregateOpts.aggregateMethod;
367
+ const { mode, showTotal, totalMethod, countFields, contentMethod, formatValuesMethod, mapChildrenField } = aggregateOpts;
368
+ const aggData = aggRow.aggData;
369
+ const currAggData = aggData ? aggData[field] : null;
369
370
  const groupField = aggRow.groupField;
370
371
  const groupContent = aggRow.groupContent;
371
372
  const childList = mapChildrenField ? (aggRow[mapChildrenField] || []) : [];
@@ -407,9 +408,10 @@ export const Cell = {
407
408
  cellValue = $table.getPivotTableAggregateCellAggValue(params);
408
409
  }
409
410
  else if (aggFunc === true || (countFields && countFields.includes(field))) {
410
- if (aggCalcMethod) {
411
- ctParams.aggValue = childCount;
412
- cellValue = `${aggCalcMethod(ctParams)}`;
411
+ cellValue = currAggData ? currAggData.value : childCount;
412
+ ctParams.aggValue = cellValue;
413
+ if (formatValuesMethod) {
414
+ cellValue = formatValuesMethod(ctParams);
413
415
  }
414
416
  }
415
417
  }
@@ -2462,26 +2462,53 @@ const calcCellHeight = ($xeTable) => {
2462
2462
  }
2463
2463
  };
2464
2464
  function getOrderField($xeTable, column) {
2465
- const { sortBy, sortType } = column;
2466
- return (row) => {
2467
- let cellValue;
2468
- if (sortBy) {
2469
- cellValue = XEUtils.isFunction(sortBy) ? sortBy({ row, column }) : XEUtils.get(row, sortBy);
2470
- }
2471
- else {
2472
- cellValue = $xeTable.getCellLabel(row, column);
2473
- }
2474
- if (!sortType || sortType === 'auto') {
2475
- return isNaN(cellValue) ? cellValue : XEUtils.toNumber(cellValue);
2476
- }
2477
- else if (sortType === 'number') {
2478
- return XEUtils.toNumber(cellValue);
2479
- }
2480
- else if (sortType === 'string') {
2481
- return XEUtils.toValueString(cellValue);
2465
+ const reactData = $xeTable;
2466
+ const { isRowGroupStatus } = reactData;
2467
+ const { sortBy, sortType, aggFunc } = column;
2468
+ return isRowGroupStatus && aggFunc
2469
+ ? (row) => {
2470
+ if (row.isAggregate) {
2471
+ const aggData = row.aggData;
2472
+ const currAggData = aggData ? aggData[column.field] : null;
2473
+ return currAggData ? currAggData.value : null;
2474
+ }
2475
+ let cellValue;
2476
+ if (sortBy) {
2477
+ cellValue = XEUtils.isFunction(sortBy) ? sortBy({ row, column }) : XEUtils.get(row, sortBy);
2478
+ }
2479
+ else {
2480
+ cellValue = $xeTable.getCellLabel(row, column);
2481
+ }
2482
+ if (!sortType || sortType === 'auto') {
2483
+ return isNaN(cellValue) ? cellValue : XEUtils.toNumber(cellValue);
2484
+ }
2485
+ else if (sortType === 'number') {
2486
+ return XEUtils.toNumber(cellValue);
2487
+ }
2488
+ else if (sortType === 'string') {
2489
+ return XEUtils.toValueString(cellValue);
2490
+ }
2491
+ return cellValue;
2482
2492
  }
2483
- return cellValue;
2484
- };
2493
+ : (row) => {
2494
+ let cellValue;
2495
+ if (sortBy) {
2496
+ cellValue = XEUtils.isFunction(sortBy) ? sortBy({ row, column }) : XEUtils.get(row, sortBy);
2497
+ }
2498
+ else {
2499
+ cellValue = $xeTable.getCellLabel(row, column);
2500
+ }
2501
+ if (!sortType || sortType === 'auto') {
2502
+ return isNaN(cellValue) ? cellValue : XEUtils.toNumber(cellValue);
2503
+ }
2504
+ else if (sortType === 'number') {
2505
+ return XEUtils.toNumber(cellValue);
2506
+ }
2507
+ else if (sortType === 'string') {
2508
+ return XEUtils.toValueString(cellValue);
2509
+ }
2510
+ return cellValue;
2511
+ };
2485
2512
  }
2486
2513
  function handleTargetEnterEvent($xeTable, isClear) {
2487
2514
  const internalData = $xeTable;
@@ -3019,8 +3046,12 @@ function handleUpdateRowGroup($xeTable, groupFields) {
3019
3046
  handleUpdateAggValues($xeTable);
3020
3047
  }
3021
3048
  function handleeGroupSummary($xeTable, aggList) {
3049
+ const internalData = $xeTable;
3050
+ const { fullColumnFieldData } = internalData;
3022
3051
  const aggregateOpts = $xeTable.computeAggregateOpts;
3052
+ const aggFuncColumns = $xeTable.computeAggFuncColumns;
3023
3053
  const { mapChildrenField } = aggregateOpts;
3054
+ const aggCalcMethod = aggregateOpts.calcValuesMethod || aggregateOpts.countMethod || aggregateOpts.aggregateMethod;
3024
3055
  if (mapChildrenField) {
3025
3056
  XEUtils.lastEach(aggList, aggRow => {
3026
3057
  let count = 0;
@@ -3037,6 +3068,62 @@ function handleeGroupSummary($xeTable, aggList) {
3037
3068
  if ($xeTable.handlePivotTableAggregateData) {
3038
3069
  $xeTable.handlePivotTableAggregateData(aggList);
3039
3070
  }
3071
+ else {
3072
+ XEUtils.lastEach(aggList, aggRow => {
3073
+ const aggDtObj = {};
3074
+ const aggData = aggRow.aggData;
3075
+ const groupField = aggRow.groupField;
3076
+ const groupContent = aggRow.groupContent;
3077
+ const childList = mapChildrenField ? (aggRow[mapChildrenField] || []) : [];
3078
+ const childCount = aggRow.childCount;
3079
+ const colRest = fullColumnFieldData[groupField] || {};
3080
+ aggFuncColumns.forEach(column => {
3081
+ const { field } = column;
3082
+ const currAggData = aggData ? aggData[field] : null;
3083
+ const ctParams = {
3084
+ $table: $xeTable,
3085
+ groupField,
3086
+ groupColumn: (colRest ? colRest.column : null),
3087
+ column,
3088
+ groupValue: groupContent,
3089
+ childList,
3090
+ childCount,
3091
+ aggValue: currAggData ? currAggData.value : 0,
3092
+ /**
3093
+ * 已废弃
3094
+ * @deprecated
3095
+ */
3096
+ children: childList,
3097
+ /**
3098
+ * 已废弃
3099
+ * @deprecated
3100
+ */
3101
+ totalValue: childCount
3102
+ };
3103
+ let aggVal = 0;
3104
+ // 如果下层同时也是分组
3105
+ if (childList.length && childList[0].isAggregate) {
3106
+ XEUtils.each(childList, (row) => {
3107
+ if (row.isAggregate) {
3108
+ const currAggData = row.aggData[field];
3109
+ if (currAggData) {
3110
+ aggVal += currAggData.value;
3111
+ }
3112
+ }
3113
+ });
3114
+ }
3115
+ else {
3116
+ aggVal = aggCalcMethod ? aggCalcMethod(ctParams) : aggRow.childCount;
3117
+ }
3118
+ aggDtObj[field] = {
3119
+ type: 'count',
3120
+ value: aggVal,
3121
+ label: aggVal
3122
+ };
3123
+ });
3124
+ aggRow.aggData = aggDtObj;
3125
+ });
3126
+ }
3040
3127
  }
3041
3128
  }
3042
3129
  function updateGroupData($xeTable) {
@@ -4098,7 +4185,36 @@ function handleRowExpandScroll($xeTable) {
4098
4185
  rowExpandEl.scrollTop = bodyScrollElem.scrollTop;
4099
4186
  }
4100
4187
  }
4101
- const Methods = {
4188
+ function handleColumnVisible(visible) {
4189
+ return function (fieldOrColumn) {
4190
+ const $xeTable = this;
4191
+ let status = false;
4192
+ const cols = XEUtils.isArray(fieldOrColumn) ? fieldOrColumn : [fieldOrColumn];
4193
+ cols.forEach(item => {
4194
+ const column = handleFieldOrColumn($xeTable, item);
4195
+ if (column) {
4196
+ if (column.children && column.children.length) {
4197
+ XEUtils.eachTree([column], (item) => {
4198
+ item.visible = visible;
4199
+ item.renderVisible = visible;
4200
+ });
4201
+ }
4202
+ else {
4203
+ column.visible = visible;
4204
+ column.renderVisible = visible;
4205
+ }
4206
+ if (!status) {
4207
+ status = true;
4208
+ }
4209
+ }
4210
+ });
4211
+ if (status) {
4212
+ return $xeTable.handleCustom();
4213
+ }
4214
+ return $xeTable.$nextTick();
4215
+ };
4216
+ }
4217
+ const tableMethods = {
4102
4218
  callSlot(slotFunc, params, h, vNodes) {
4103
4219
  const $xeTable = this;
4104
4220
  // const slots = $xeTable.$scopedSlots
@@ -5538,45 +5654,11 @@ const Methods = {
5538
5654
  /**
5539
5655
  * 隐藏指定列
5540
5656
  */
5541
- hideColumn(fieldOrColumn) {
5542
- const $xeTable = this;
5543
- let status = false;
5544
- const cols = XEUtils.isArray(fieldOrColumn) ? fieldOrColumn : [fieldOrColumn];
5545
- cols.forEach(item => {
5546
- const column = handleFieldOrColumn($xeTable, item);
5547
- if (column && column.visible) {
5548
- column.visible = false;
5549
- if (!status) {
5550
- status = true;
5551
- }
5552
- }
5553
- });
5554
- if (status) {
5555
- return $xeTable.handleCustom();
5556
- }
5557
- return $xeTable.$nextTick();
5558
- },
5657
+ hideColumn: handleColumnVisible(false),
5559
5658
  /**
5560
5659
  * 显示指定列
5561
5660
  */
5562
- showColumn(fieldOrColumn) {
5563
- const $xeTable = this;
5564
- let status = false;
5565
- const cols = XEUtils.isArray(fieldOrColumn) ? fieldOrColumn : [fieldOrColumn];
5566
- cols.forEach(item => {
5567
- const column = handleFieldOrColumn($xeTable, item);
5568
- if (column && !column.visible) {
5569
- column.visible = true;
5570
- if (!status) {
5571
- status = true;
5572
- }
5573
- }
5574
- });
5575
- if (status) {
5576
- return $xeTable.handleCustom();
5577
- }
5578
- return $xeTable.$nextTick();
5579
- },
5661
+ showColumn: handleColumnVisible(true),
5580
5662
  setColumnWidth(fieldOrColumn, width) {
5581
5663
  const $xeTable = this;
5582
5664
  const internalData = $xeTable;
@@ -7135,7 +7217,7 @@ const Methods = {
7135
7217
  },
7136
7218
  handleAggregateSummaryData() {
7137
7219
  const $xeTable = this;
7138
- return updateGroupData($xeTable);
7220
+ return $xeTable.refreshAggregateCalcValues();
7139
7221
  },
7140
7222
  handleTargetLeaveEvent() {
7141
7223
  const $xeTable = this;
@@ -10408,6 +10490,11 @@ const Methods = {
10408
10490
  const { isRowGroupStatus } = reactData;
10409
10491
  return isRowGroupStatus && row && row.isAggregate && childrenField && mapChildrenField ? (row[mapChildrenField] || []) : [];
10410
10492
  },
10493
+ refreshAggregateCalcValues() {
10494
+ const $xeTable = this;
10495
+ updateGroupData($xeTable);
10496
+ return $xeTable.$nextTick();
10497
+ },
10411
10498
  isAggregateExpandByRow(row) {
10412
10499
  const $xeTable = this;
10413
10500
  const reactData = $xeTable;
@@ -12052,10 +12139,12 @@ const Methods = {
12052
12139
  return getConfig();
12053
12140
  }
12054
12141
  };
12142
+ const tablePrivateMethods = {};
12143
+ const exportMethods = Object.assign({}, tableMethods, tablePrivateMethods);
12055
12144
  // Module methods
12056
12145
  const funcs = 'setFilter,openFilter,clearFilter,saveFilter,saveFilterByEvent,resetFilter,resetFilterByEvent,saveFilterPanel,saveFilterPanelByEvent,resetFilterPanel,resetFilterPanelByEvent,getCheckedFilters,updateFilterOptionStatus,closeMenu,setActiveCellArea,getActiveCellArea,getCellAreas,clearCellAreas,copyCellArea,cutCellArea,pasteCellArea,getCopyCellArea,getCopyCellAreas,clearCopyCellArea,setCellAreas,openFNR,openFind,openReplace,closeFNR,getSelectedCell,clearSelected,insert,insertAt,insertNextAt,insertChild,insertChildAt,insertChildNextAt,remove,removeCheckboxRow,removeRadioRow,removeCurrentRow,getRecordset,getInsertRecords,getRemoveRecords,getUpdateRecords,clearEdit,clearActived,getEditRecord,getEditCell,getActiveRecord,isEditByRow,isActiveByRow,setEditRow,setActiveRow,setEditCell,setActiveCell,setSelectCell,clearValidate,fullValidate,validate,fullValidateField,validateField,openExport,closeExport,openPrint,closePrint,getPrintHtml,exportData,openImport,closeImport,importData,saveFile,readFile,importByFile,print,getCustomVisible,openCustom,closeCustom,toggleCustom,saveCustom,cancelCustom,resetCustom,toggleCustomAllCheckbox,setCustomAllCheckbox'.split(',');
12057
12146
  funcs.forEach(name => {
12058
- Methods[name] = function (...args) {
12147
+ exportMethods[name] = function (...args) {
12059
12148
  // if (!this[`_${name}`]) {
12060
12149
  // if ('openExport,openPrint,exportData,openImport,importData,saveFile,readFile,importByFile,print'.split(',').includes(name)) {
12061
12150
  // errLog('vxe.error.reqModule', ['Export'])
@@ -12072,4 +12161,4 @@ funcs.forEach(name => {
12072
12161
  return this[`_${name}`] ? this[`_${name}`](...args) : null;
12073
12162
  };
12074
12163
  });
12075
- export default Methods;
12164
+ export default exportMethods;
@@ -1444,6 +1444,15 @@ export default {
1444
1444
  });
1445
1445
  return rgColumns;
1446
1446
  },
1447
+ computeAggFuncColumns() {
1448
+ const $xeTable = this;
1449
+ const reactData = $xeTable;
1450
+ const { rowGroupList, tableColumn } = reactData;
1451
+ if (rowGroupList.length) {
1452
+ return tableColumn.filter(column => column.field && column.aggFunc);
1453
+ }
1454
+ return [];
1455
+ },
1447
1456
  tabsResizeFlag() {
1448
1457
  const $xeTable = this;
1449
1458
  const $xeTabs = $xeTable.$xeTabs;
@@ -1994,8 +2003,9 @@ export default {
1994
2003
  if (this.$resize) {
1995
2004
  this.$resize.disconnect();
1996
2005
  }
1997
- this.closeFilter();
1998
- this.closeMenu();
2006
+ $xeTable.closeTooltip();
2007
+ $xeTable.closeFilter();
2008
+ $xeTable.closeMenu();
1999
2009
  globalEvents.off($xeTable, 'paste');
2000
2010
  globalEvents.off($xeTable, 'copy');
2001
2011
  globalEvents.off($xeTable, 'cut');
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 = "3.19.21";
3
+ export const version = "3.19.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${"3.19.21"}`;
3
+ const version = `table v${"3.19.24"}`;
4
4
  export const warnLog = log.create('warn', version);
5
5
  export const errLog = log.create('error', version);