zmdms-webui 2.8.9 → 2.9.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.
@@ -70,20 +70,28 @@ function exportToExcelWithMergeAndComments(records, columns, mergeKeys, numKeys,
70
70
  var dataForStyles = processedData;
71
71
  if (summaryConfig !== undefined) {
72
72
  var sumsByKey_1 = {};
73
- excelData.leafColumns.forEach(function (col, colIndex) {
73
+ // 过滤掉合计行的数据
74
+ var dataWithoutSummary_1 = processedData.filter(function (record) { return !record[IS_SUMMARY]; });
75
+ excelData.leafColumns.forEach(function (col) {
74
76
  var key = col.dataIndex;
75
77
  if (col.isSummary) {
76
- // 默认计算逻辑:数值求和
77
- var total = 0;
78
- for (var i = 0; i < processedData.length; i++) {
79
- if (processedData[i][IS_SUMMARY])
80
- continue;
81
- var v = processedData[i][key];
82
- var n = typeof v === "number" ? v : Number(v);
83
- if (!isNaN(n))
84
- total = plus(total, n);
78
+ var calculatedSum = void 0;
79
+ // 如果有自定义计算函数,使用自定义逻辑
80
+ if (col.summaryCalc) {
81
+ calculatedSum = col.summaryCalc(dataWithoutSummary_1, key);
85
82
  }
86
- sumsByKey_1[key] = total;
83
+ else {
84
+ // 默认计算逻辑:数值求和
85
+ var total = 0;
86
+ for (var i = 0; i < dataWithoutSummary_1.length; i++) {
87
+ var v = dataWithoutSummary_1[i][key];
88
+ var n = typeof v === "number" ? v : Number(v);
89
+ if (!isNaN(n))
90
+ total = plus(total, n);
91
+ }
92
+ calculatedSum = total;
93
+ }
94
+ sumsByKey_1[key] = calculatedSum;
87
95
  }
88
96
  });
89
97
  summaryRow = excelData.leafColumns.map(function (col, index) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zmdms-webui",
3
- "version": "2.8.9",
3
+ "version": "2.9.0",
4
4
  "private": false,
5
5
  "main": "dist/index.es.js",
6
6
  "module": "dist/index.es.js",