zmdms-webui 2.6.6 → 2.6.8

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.
@@ -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 { plus, exactRound, addThousedSeparator } from 'zmdms-utils';
8
+ import { exactRound, addThousedSeparator, plus } 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,40 +22,61 @@ var useSummaryRow = function (params) {
22
22
  if (!hasSummary)
23
23
  return null;
24
24
  var summaryRecord = {};
25
- // 原始值,为转为千分符的
26
- var summaryOriginalValues = {};
27
25
  // 找到第一个列(包括序号列、选择框列)
28
26
  var firstColIndex = leafColumns.length > 0 ? 0 : -1;
29
27
  leafColumns.forEach(function (column, colIndex) {
30
28
  var dataIndex = column.dataIndex || column.key;
31
29
  if (column.isSummary) {
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);
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
+ }
43
52
  }
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);
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
+ }
56
77
  }
78
+ summaryRecord[dataIndex] = formattedSum;
57
79
  }
58
- summaryRecord[dataIndex] = formattedSum;
59
80
  }
60
81
  else if (colIndex === firstColIndex) {
61
82
  // 第一列显示"合计"(可以是序号列、选择框列或数据列)
@@ -65,12 +86,6 @@ var useSummaryRow = function (params) {
65
86
  summaryRecord[dataIndex] = "";
66
87
  }
67
88
  });
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
- });
74
89
  summaryRecord[IS_SUMMARY] = true;
75
90
  return summaryRecord;
76
91
  }, [columns, dataSource]);
@@ -215,14 +215,15 @@ var DynamicDrawer = function (props, ref) {
215
215
  });
216
216
  newDynamicList[pIndex].children = changeCList;
217
217
  // 联动父元素
218
- var allChildrenChecked = changeCList.length > 0 && changeCList.every(function (child) { return child.checked; });
219
- changeCList.some(function (child) { return child.checked; });
220
- if (allChildrenChecked) {
221
- // 所有子元素都选中,父元素也选中
218
+ // const allChildrenChecked =
219
+ // changeCList.length > 0 && changeCList.every((child) => child.checked);
220
+ var someChildrenChecked = changeCList.some(function (child) { return child.checked; });
221
+ if (someChildrenChecked) {
222
+ // 只要有子元素选中,父元素就应该是 checked = true
222
223
  newDynamicList[pIndex].checked = true;
223
224
  }
224
225
  else {
225
- // 部分选中或全不选中,父元素取消选中(配合 indeterminate 显示半选状态)
226
+ // 所有子元素都不选中,父元素才取消选中
226
227
  newDynamicList[pIndex].checked = false;
227
228
  }
228
229
  setTempDynamicList(sortDynamicListByType(newDynamicList));
@@ -1,6 +1,7 @@
1
1
  import { __assign } from '../_virtual/_tslib.js';
2
2
  import { jsxs, jsx } from 'react/jsx-runtime';
3
- import React__default, { useState, useRef, useCallback } from 'react';
3
+ import React__default, { useState, useRef } from 'react';
4
+ import { useMemoizedFn } from 'ahooks';
4
5
 
5
6
  var useResizable = function (options) {
6
7
  var isResize = options.isResize, _a = options.minWidth, minWidth = _a === void 0 ? 100 : _a, _b = options.minHeight, minHeight = _b === void 0 ? 100 : _b, maxWidth = options.maxWidth, maxHeight = options.maxHeight, _c = options.defaultWidth, defaultWidth = _c === void 0 ? "70%" : _c, _d = options.defaultHeight, defaultHeight = _d === void 0 ? "auto" : _d;
@@ -17,7 +18,7 @@ var useResizable = function (options) {
17
18
  startHeight: 0,
18
19
  });
19
20
  // 开始调整大小
20
- var onResizeStart = useCallback(function (direction, e) {
21
+ var onResizeStart = useMemoizedFn(function (direction, e) {
21
22
  var _a;
22
23
  if (!isResize) {
23
24
  return;
@@ -42,9 +43,9 @@ var useResizable = function (options) {
42
43
  document.body.style.cursor = getCursor(direction);
43
44
  document.body.style.userSelect = "none";
44
45
  document.body.classList.add("ztxk-modal-resizing");
45
- }, [isResize]);
46
+ });
46
47
  // 调整大小中
47
- var onResizeMove = useCallback(function (e) {
48
+ var onResizeMove = useMemoizedFn(function (e) {
48
49
  var _a = resizingRef.current, direction = _a.direction, startX = _a.startX, startY = _a.startY, startWidth = _a.startWidth, startHeight = _a.startHeight;
49
50
  if (!direction) {
50
51
  return;
@@ -79,16 +80,16 @@ var useResizable = function (options) {
79
80
  width: newWidth,
80
81
  height: newHeight,
81
82
  });
82
- }, [minWidth, minHeight, maxWidth, maxHeight]);
83
+ });
83
84
  // 结束调整大小
84
- var onResizeEnd = useCallback(function () {
85
+ var onResizeEnd = useMemoizedFn(function () {
85
86
  resizingRef.current.direction = null;
86
87
  document.removeEventListener("mousemove", onResizeMove);
87
88
  document.removeEventListener("mouseup", onResizeEnd);
88
89
  document.body.style.cursor = "";
89
90
  document.body.style.userSelect = "";
90
91
  document.body.classList.remove("ztxk-modal-resizing");
91
- }, [onResizeMove]);
92
+ });
92
93
  // 获取鼠标样式
93
94
  var getCursor = function (direction) {
94
95
  var cursorMap = {
@@ -73,16 +73,34 @@ 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
- var total = 0;
77
- for (var i = 0; i < processedData.length; i++) {
78
- if (processedData[i][IS_SUMMARY])
79
- continue;
80
- var v = processedData[i][key];
81
- var n = typeof v === "number" ? v : Number(v);
82
- if (!isNaN(n))
83
- total += n;
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;
84
103
  }
85
- sumsByKey_1[key] = total;
86
104
  }
87
105
  });
88
106
  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.6.6",
3
+ "version": "2.6.8",
4
4
  "private": false,
5
5
  "main": "dist/index.es.js",
6
6
  "module": "dist/index.es.js",