zmdms-webui 2.6.5 → 2.6.7

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.
@@ -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));
@@ -486,7 +486,8 @@ function flattenRecordsOptimized(records, mergeKeys, dimensionSummaryKeys, summa
486
486
  summaryKeys &&
487
487
  summaryKeys.length > 0) {
488
488
  result = insertDimensionSummaryRows(result, mergeKeys, // 传入完整的维度字段列表
489
- dimensionSummaryKeys, summaryKeys);
489
+ dimensionSummaryKeys, summaryKeys, order, dimensionCustomSumKeys // 传入自定义合计配置
490
+ );
490
491
  }
491
492
  // 3. 为每行初始化合并信息
492
493
  for (var i = 0; i < result.length; i++) {
@@ -733,7 +734,8 @@ function sortByDimensions(records, dimensionKeys, order, columns) {
733
734
  */
734
735
  function insertDimensionSummaryRows(records, allDimensionKeys, // 完整的维度字段列表
735
736
  dimensionSummaryKeys, // 需要合计的维度字段
736
- summaryKeys, order // 排序配置
737
+ summaryKeys, order, // 排序配置
738
+ dimensionCustomSumKeys // 自定义合计配置
737
739
  ) {
738
740
  var result = __spreadArray([], records, true);
739
741
  // 按维度层级从深到浅处理
@@ -756,7 +758,8 @@ summaryKeys, order // 排序配置
756
758
  newResult.push.apply(newResult, group.items);
757
759
  // 创建合计行
758
760
  var summaryRow = createSummaryRow(group.items, group.key, groupingKeys, allDimensionKeys, // 传入完整的维度字段列表
759
- summaryKeys, currentDimensionIndex);
761
+ summaryKeys, currentDimensionIndex, dimensionCustomSumKeys // 传入自定义合计配置
762
+ );
760
763
  newResult.push(summaryRow);
761
764
  }
762
765
  result = newResult;
@@ -793,7 +796,8 @@ function groupByDimensions(records, dimensionKeys) {
793
796
  */
794
797
  function createSummaryRow(items, groupKey, groupingKeys, // 当前分组使用的维度字段
795
798
  allDimensionKeys, // 完整的维度字段列表
796
- summaryKeys, summaryLevelIndex // 在完整维度列表中的索引
799
+ summaryKeys, summaryLevelIndex, // 在完整维度列表中的索引
800
+ dimensionCustomSumKeys // 自定义合计配置
797
801
  ) {
798
802
  var summaryRow = {};
799
803
  // 设置所有维度字段
@@ -825,6 +829,89 @@ summaryKeys, summaryLevelIndex // 在完整维度列表中的索引
825
829
  var summaryKey = summaryKeys_1[_i];
826
830
  _loop_5(summaryKey);
827
831
  }
832
+ // 处理dimensionCustomSumKeys的额外合并计算逻辑
833
+ if (dimensionCustomSumKeys && Array.isArray(dimensionCustomSumKeys)) {
834
+ var _loop_6 = function (customSumKey) {
835
+ if (typeof customSumKey === "string") {
836
+ // 如果是字符串,对指定字段进行合计
837
+ summaryRow[customSumKey] = items
838
+ .filter(function (item) { return !isSummaryRow(item); }) // 排除已有的合计行
839
+ .reduce(function (sum, item) {
840
+ var value = parseFloat(item[customSumKey]) || 0;
841
+ return plus(sum, value);
842
+ }, 0);
843
+ }
844
+ else if (typeof customSumKey === "object" && customSumKey.key) {
845
+ // 如果是对象,使用自定义的key和value函数
846
+ var key = customSumKey.key, valueFn_1 = customSumKey.value, _b = customSumKey.summaryType, summaryType = _b === void 0 ? "sum" : _b, computedSummary = customSumKey.computedSummary;
847
+ var filteredItems = items.filter(function (item) { return !isSummaryRow(item); }); // 排除已有的合计行
848
+ switch (summaryType) {
849
+ case "sum":
850
+ if (valueFn_1) {
851
+ // 默认累加方式
852
+ var customValues = filteredItems.map(function (item) {
853
+ var result = valueFn_1(item);
854
+ return typeof result === "number"
855
+ ? result
856
+ : parseFloat(result) || 0;
857
+ });
858
+ var customSum = customValues.reduce(function (sum, value) {
859
+ return plus(sum, value);
860
+ }, 0);
861
+ summaryRow[key] = customSum;
862
+ }
863
+ break;
864
+ case "first":
865
+ if (valueFn_1) {
866
+ // 使用第一条记录的值
867
+ if (filteredItems.length > 0) {
868
+ var result = valueFn_1(filteredItems[0]);
869
+ summaryRow[key] =
870
+ typeof result === "number" ? result : parseFloat(result) || 0;
871
+ }
872
+ else {
873
+ summaryRow[key] = 0;
874
+ }
875
+ }
876
+ break;
877
+ case "computed":
878
+ // 使用自定义计算函数
879
+ if (typeof computedSummary === "function") {
880
+ var result = computedSummary(filteredItems, summaryRow);
881
+ summaryRow[key] =
882
+ typeof result === "number"
883
+ ? result
884
+ : parseFloat(result) || result;
885
+ }
886
+ else {
887
+ console.warn("\u5B57\u6BB5 ".concat(key, " \u8BBE\u7F6E\u4E86 summaryType: 'computed' \u4F46\u6CA1\u6709\u63D0\u4F9B computedSummary \u51FD\u6570"));
888
+ summaryRow[key] = 0;
889
+ }
890
+ break;
891
+ default:
892
+ console.warn("\u672A\u77E5\u7684 summaryType: ".concat(summaryType, "\uFF0C\u4F7F\u7528\u9ED8\u8BA4\u7684 sum \u65B9\u5F0F"));
893
+ if (valueFn_1) {
894
+ // 回退到默认的 sum 方式
895
+ var defaultValues = filteredItems.map(function (item) {
896
+ var result = valueFn_1(item);
897
+ return typeof result === "number"
898
+ ? result
899
+ : parseFloat(result) || 0;
900
+ });
901
+ var defaultSum = defaultValues.reduce(function (sum, value) {
902
+ return plus(sum, value);
903
+ }, 0);
904
+ summaryRow[key] = defaultSum;
905
+ break;
906
+ }
907
+ }
908
+ }
909
+ };
910
+ for (var _a = 0, dimensionCustomSumKeys_1 = dimensionCustomSumKeys; _a < dimensionCustomSumKeys_1.length; _a++) {
911
+ var customSumKey = dimensionCustomSumKeys_1[_a];
912
+ _loop_6(customSumKey);
913
+ }
914
+ }
828
915
  // 标记为合计行
829
916
  summaryRow[IS_SUMMARY] = true;
830
917
  return summaryRow;
@@ -858,7 +945,7 @@ function hasParentGroupChanged(records, currentIndex, mergeKeys, currentKeyIndex
858
945
  function groupByLastMergeKey(records, mergeKeys, // 改为传入所有合并键
859
946
  summaryKeys, dimensionCustomSumKeys) {
860
947
  var groups = new Map();
861
- var _loop_6 = function (record) {
948
+ var _loop_7 = function (record) {
862
949
  var key = mergeKeys.map(function (k) { return record[k]; });
863
950
  var keyStr = JSON.stringify(key);
864
951
  if (!groups.has(keyStr)) {
@@ -869,7 +956,7 @@ summaryKeys, dimensionCustomSumKeys) {
869
956
  // 按所有合并键的组合进行分组
870
957
  for (var _i = 0, records_2 = records; _i < records_2.length; _i++) {
871
958
  var record = records_2[_i];
872
- _loop_6(record);
959
+ _loop_7(record);
873
960
  }
874
961
  // 为每个分组创建合计行
875
962
  var result = [];
@@ -885,7 +972,7 @@ summaryKeys, dimensionCustomSumKeys) {
885
972
  for (var i = 0; i < mergeKeys.length; i++) {
886
973
  summaryRow[mergeKeys[i]] = keyValues[i];
887
974
  }
888
- var _loop_7 = function (summaryKey) {
975
+ var _loop_8 = function (summaryKey) {
889
976
  summaryRow[summaryKey] = items
890
977
  .filter(function (item) { return !isSummaryRow(item); }) // 排除已有的合计行
891
978
  .reduce(function (sum, item) {
@@ -896,11 +983,11 @@ summaryKeys, dimensionCustomSumKeys) {
896
983
  // 计算合计值
897
984
  for (var _d = 0, summaryKeys_2 = summaryKeys; _d < summaryKeys_2.length; _d++) {
898
985
  var summaryKey = summaryKeys_2[_d];
899
- _loop_7(summaryKey);
986
+ _loop_8(summaryKey);
900
987
  }
901
988
  // 处理dimensionCustomSumKeys的额外合并计算逻辑
902
989
  if (dimensionCustomSumKeys && Array.isArray(dimensionCustomSumKeys)) {
903
- var _loop_8 = function (customSumKey) {
990
+ var _loop_9 = function (customSumKey) {
904
991
  if (typeof customSumKey === "string") {
905
992
  // 如果是字符串,对指定字段进行合计
906
993
  summaryRow[customSumKey] = items
@@ -912,14 +999,14 @@ summaryKeys, dimensionCustomSumKeys) {
912
999
  }
913
1000
  else if (typeof customSumKey === "object" && customSumKey.key) {
914
1001
  // 如果是对象,使用自定义的key和value函数
915
- var key = customSumKey.key, valueFn_1 = customSumKey.value, _f = customSumKey.summaryType, summaryType = _f === void 0 ? "sum" : _f, computedSummary = customSumKey.computedSummary;
1002
+ var key = customSumKey.key, valueFn_2 = customSumKey.value, _f = customSumKey.summaryType, summaryType = _f === void 0 ? "sum" : _f, computedSummary = customSumKey.computedSummary;
916
1003
  var filteredItems = items.filter(function (item) { return !isSummaryRow(item); }); // 排除已有的合计行
917
1004
  switch (summaryType) {
918
1005
  case "sum":
919
- if (valueFn_1) {
1006
+ if (valueFn_2) {
920
1007
  // 默认累加方式
921
1008
  var customValues = filteredItems.map(function (item) {
922
- var result = valueFn_1(item);
1009
+ var result = valueFn_2(item);
923
1010
  return typeof result === "number"
924
1011
  ? result
925
1012
  : parseFloat(result) || 0;
@@ -931,10 +1018,10 @@ summaryKeys, dimensionCustomSumKeys) {
931
1018
  }
932
1019
  break;
933
1020
  case "first":
934
- if (valueFn_1) {
1021
+ if (valueFn_2) {
935
1022
  // 使用第一条记录的值
936
1023
  if (filteredItems.length > 0) {
937
- var result_1 = valueFn_1(filteredItems[0]);
1024
+ var result_1 = valueFn_2(filteredItems[0]);
938
1025
  summaryRow[key] =
939
1026
  typeof result_1 === "number"
940
1027
  ? result_1
@@ -961,10 +1048,10 @@ summaryKeys, dimensionCustomSumKeys) {
961
1048
  break;
962
1049
  default:
963
1050
  console.warn("\u672A\u77E5\u7684 summaryType: ".concat(summaryType, "\uFF0C\u4F7F\u7528\u9ED8\u8BA4\u7684 sum \u65B9\u5F0F"));
964
- if (valueFn_1) {
1051
+ if (valueFn_2) {
965
1052
  // 回退到默认的 sum 方式
966
1053
  var defaultValues = filteredItems.map(function (item) {
967
- var result = valueFn_1(item);
1054
+ var result = valueFn_2(item);
968
1055
  return typeof result === "number"
969
1056
  ? result
970
1057
  : parseFloat(result) || 0;
@@ -978,9 +1065,9 @@ summaryKeys, dimensionCustomSumKeys) {
978
1065
  }
979
1066
  }
980
1067
  };
981
- for (var _e = 0, dimensionCustomSumKeys_1 = dimensionCustomSumKeys; _e < dimensionCustomSumKeys_1.length; _e++) {
982
- var customSumKey = dimensionCustomSumKeys_1[_e];
983
- _loop_8(customSumKey);
1068
+ for (var _e = 0, dimensionCustomSumKeys_2 = dimensionCustomSumKeys; _e < dimensionCustomSumKeys_2.length; _e++) {
1069
+ var customSumKey = dimensionCustomSumKeys_2[_e];
1070
+ _loop_9(customSumKey);
984
1071
  }
985
1072
  }
986
1073
  result.push(summaryRow);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zmdms-webui",
3
- "version": "2.6.5",
3
+ "version": "2.6.7",
4
4
  "private": false,
5
5
  "main": "dist/index.es.js",
6
6
  "module": "dist/index.es.js",