zmdms-webui 2.6.8 → 2.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.
@@ -128,7 +128,7 @@ var useCopyToClipboard = function (params) {
128
128
  return;
129
129
  var handleKeyDown = function (e) {
130
130
  // 检查是否为复制快捷键且有选中的单元格
131
- if ((e.ctrlKey || e.metaKey) && e.key === "c" && cellSelection) {
131
+ if ((e.ctrlKey || e.metaKey) && e.code === "KeyC" && cellSelection) {
132
132
  // 检查当前焦点是否在表格容器内,或者事件目标是否在表格容器内
133
133
  var isInContainer = container.contains(document.activeElement) ||
134
134
  container.contains(e.target);
@@ -5,7 +5,7 @@ import 'lodash/isEqual';
5
5
  import 'ahooks';
6
6
  import '../../node_modules/immutability-helper/index.js';
7
7
  import 'react/jsx-runtime';
8
- import { exactRound, addThousedSeparator, plus } from 'zmdms-utils';
8
+ import { plus, exactRound, addThousedSeparator } from 'zmdms-utils';
9
9
  import '../../node_modules/exceljs/dist/exceljs.min.js';
10
10
  import 'dayjs';
11
11
  import { getAllLeafColumns } from '../utils/columnHelpers.js';
@@ -22,61 +22,40 @@ var useSummaryRow = function (params) {
22
22
  if (!hasSummary)
23
23
  return null;
24
24
  var summaryRecord = {};
25
+ // 原始值,为转为千分符的
26
+ var summaryOriginalValues = {};
25
27
  // 找到第一个列(包括序号列、选择框列)
26
28
  var firstColIndex = leafColumns.length > 0 ? 0 : -1;
27
29
  leafColumns.forEach(function (column, colIndex) {
28
30
  var dataIndex = column.dataIndex || column.key;
29
31
  if (column.isSummary) {
30
- // 优先使用自定义合计计算回调
31
- if (column.totalCalcCallback) {
32
- // 提取该列的所有值(排除小计行)
33
- var columnValues_1 = [];
34
- dataSource.forEach(function (record) {
35
- if (!record[IS_SUMMARY]) {
36
- columnValues_1.push(record[dataIndex]);
37
- }
38
- });
39
- // 调用自定义计算回调
40
- // 第一个参数:该列所有值数组
41
- // 第二个参数:所有数据(可用于复杂计算)
42
- var calculatedValue = column.totalCalcCallback(columnValues_1, dataSource);
43
- var formattedValue = calculatedValue;
44
- // 应用格式化
45
- if (typeof calculatedValue === "number") {
46
- if (column.precision !== undefined) {
47
- formattedValue = exactRound(calculatedValue, column.precision);
48
- }
49
- if (column.thousand) {
50
- formattedValue = addThousedSeparator(formattedValue);
51
- }
32
+ var calculatedSum = void 0;
33
+ // 默认计算逻辑:数值求和
34
+ var sum_1 = 0;
35
+ dataSource.forEach(function (record) {
36
+ var value = record[dataIndex];
37
+ var num = typeof value === "string" ? parseFloat(value) : value;
38
+ if (!isNaN(num) &&
39
+ num !== null &&
40
+ num !== undefined &&
41
+ !record[IS_SUMMARY]) {
42
+ sum_1 = plus(sum_1, num);
52
43
  }
53
- summaryRecord[dataIndex] = formattedValue;
54
- }
55
- else {
56
- // 默认计算逻辑:数值求和
57
- var sum_1 = 0;
58
- dataSource.forEach(function (record) {
59
- var value = record[dataIndex];
60
- var num = typeof value === "string" ? parseFloat(value) : value;
61
- if (!isNaN(num) &&
62
- num !== null &&
63
- num !== undefined &&
64
- !record[IS_SUMMARY]) {
65
- sum_1 = plus(sum_1, num);
66
- }
67
- });
68
- // 应用格式化
69
- var formattedSum = sum_1;
70
- if (typeof sum_1 === "number") {
71
- if (column.precision !== undefined) {
72
- formattedSum = exactRound(sum_1, column.precision);
73
- }
74
- if (column.thousand) {
75
- formattedSum = addThousedSeparator(formattedSum);
76
- }
44
+ });
45
+ calculatedSum = sum_1;
46
+ // 应用格式化(仅在没有自定义回调或回调返回数值时)
47
+ var formattedSum = calculatedSum;
48
+ summaryOriginalValues[dataIndex] = calculatedSum;
49
+ if (typeof calculatedSum === "number") {
50
+ if (column.precision !== undefined) {
51
+ formattedSum = exactRound(calculatedSum, column.precision);
52
+ summaryOriginalValues[dataIndex] = calculatedSum;
53
+ }
54
+ if (column.thousand) {
55
+ formattedSum = addThousedSeparator(formattedSum);
77
56
  }
78
- summaryRecord[dataIndex] = formattedSum;
79
57
  }
58
+ summaryRecord[dataIndex] = formattedSum;
80
59
  }
81
60
  else if (colIndex === firstColIndex) {
82
61
  // 第一列显示"合计"(可以是序号列、选择框列或数据列)
@@ -86,6 +65,12 @@ var useSummaryRow = function (params) {
86
65
  summaryRecord[dataIndex] = "";
87
66
  }
88
67
  });
68
+ leafColumns.forEach(function (column) {
69
+ if (column.totalCalcCallback) {
70
+ var dataIndex = column.dataIndex || column.key;
71
+ summaryRecord[dataIndex] = column.totalCalcCallback(summaryOriginalValues[dataIndex], summaryOriginalValues);
72
+ }
73
+ });
89
74
  summaryRecord[IS_SUMMARY] = true;
90
75
  return summaryRecord;
91
76
  }, [columns, dataSource]);
@@ -3,7 +3,7 @@ import ExcelJS from '../node_modules/exceljs/dist/exceljs.min.js';
3
3
  import { useMergeKeys, useNumKeys, useDateKeys } from './hooks.js';
4
4
  import { useMemoizedFn } from 'ahooks';
5
5
  import { IS_SUMMARY, MERGE_ROW_SPANS } from './constant.js';
6
- import { exactRound } from 'zmdms-utils';
6
+ import { plus, exactRound } from 'zmdms-utils';
7
7
  import dayjs from 'dayjs';
8
8
 
9
9
  // 内部常量,用于标记父数据
@@ -73,34 +73,17 @@ function exportToExcelWithMergeAndComments(records, columns, mergeKeys, numKeys,
73
73
  excelData.leafColumns.forEach(function (col, colIndex) {
74
74
  var key = col.dataIndex;
75
75
  if (col.isSummary) {
76
- // 优先使用自定义合计计算回调
77
- if (col.totalCalcCallback) {
78
- // 提取该列的所有值(排除小计行)
79
- var columnValues = [];
80
- for (var i = 0; i < processedData.length; i++) {
81
- if (processedData[i][IS_SUMMARY])
82
- continue;
83
- columnValues.push(processedData[i][key]);
84
- }
85
- // 调用自定义计算回调
86
- // 第一个参数:该列所有值数组
87
- // 第二个参数:所有数据(可用于复杂计算)
88
- var calculatedValue = col.totalCalcCallback(columnValues, processedData);
89
- sumsByKey_1[key] = calculatedValue;
90
- }
91
- else {
92
- // 默认计算逻辑:数值求和
93
- var total = 0;
94
- for (var i = 0; i < processedData.length; i++) {
95
- if (processedData[i][IS_SUMMARY])
96
- continue;
97
- var v = processedData[i][key];
98
- var n = typeof v === "number" ? v : Number(v);
99
- if (!isNaN(n))
100
- total += n;
101
- }
102
- sumsByKey_1[key] = total;
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);
103
85
  }
86
+ sumsByKey_1[key] = total;
104
87
  }
105
88
  });
106
89
  summaryRow = excelData.leafColumns.map(function (col, index) {
@@ -108,6 +91,9 @@ function exportToExcelWithMergeAndComments(records, columns, mergeKeys, numKeys,
108
91
  return "合计";
109
92
  var key = col.dataIndex;
110
93
  if (col.isSummary && sumsByKey_1[key] !== undefined) {
94
+ if (col.totalCalcCallback) {
95
+ sumsByKey_1[key] = col.totalCalcCallback(sumsByKey_1, processedData);
96
+ }
111
97
  return sumsByKey_1[key];
112
98
  }
113
99
  return "";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zmdms-webui",
3
- "version": "2.6.8",
3
+ "version": "2.7.0",
4
4
  "private": false,
5
5
  "main": "dist/index.es.js",
6
6
  "module": "dist/index.es.js",