super-page-runtime 2.2.26 → 2.2.29-tmp2

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.
Files changed (165) hide show
  1. package/dist/es/_virtual/_plugin-vue_export-helper.js +7 -5
  2. package/dist/es/assets/chart-themes/theme1.js +6 -2
  3. package/dist/es/assets/chart-themes/theme2.js +6 -2
  4. package/dist/es/assets/chart-themes/theme3.js +6 -2
  5. package/dist/es/components/runtime/utils/api/api-util.js +7 -4
  6. package/dist/es/components/runtime/utils/api/page-expose-util.js +443 -135
  7. package/dist/es/components/runtime/utils/assemblys-config.js +369 -13
  8. package/dist/es/components/runtime/utils/barcode-util.js +33 -9
  9. package/dist/es/components/runtime/utils/charts/chart-columnline-util.js +306 -122
  10. package/dist/es/components/runtime/utils/charts/chart-gauge-util.js +68 -29
  11. package/dist/es/components/runtime/utils/charts/chart-pie-util.js +152 -68
  12. package/dist/es/components/runtime/utils/charts/chart-radar-util.js +124 -46
  13. package/dist/es/components/runtime/utils/charts/chart-scatter-util.js +99 -36
  14. package/dist/es/components/runtime/utils/charts/chart-util.js +522 -224
  15. package/dist/es/components/runtime/utils/common-util.js +156 -76
  16. package/dist/es/components/runtime/utils/eventBus.js +8 -3
  17. package/dist/es/components/runtime/utils/events/event-util.js +775 -362
  18. package/dist/es/components/runtime/utils/events/print-label.js +140 -72
  19. package/dist/es/components/runtime/utils/events/standard-event.js +2320 -808
  20. package/dist/es/components/runtime/utils/events/validator-util.js +560 -224
  21. package/dist/es/components/runtime/utils/form/date-shortcuts.js +88 -28
  22. package/dist/es/components/runtime/utils/form/scan-util.js +162 -61
  23. package/dist/es/components/runtime/utils/global-refs.js +84 -53
  24. package/dist/es/components/runtime/utils/i18n-util.js +20 -11
  25. package/dist/es/components/runtime/utils/interfaces/page-design-types.js +7 -2
  26. package/dist/es/components/runtime/utils/page-helper-util.js +660 -279
  27. package/dist/es/components/runtime/utils/page-init-util.js +406 -141
  28. package/dist/es/components/runtime/utils/page-permission-util.js +531 -22
  29. package/dist/es/components/runtime/utils/page-store.js +68 -23
  30. package/dist/es/components/runtime/utils/store-util.js +13 -9
  31. package/dist/es/components/runtime/utils/store.js +2 -2
  32. package/dist/es/components/runtime/utils/table-utils.js +81 -40
  33. package/dist/es/components/runtime/utils/tree-utils.js +37 -17
  34. package/dist/es/components/runtime/views/assemblys/button/button/button-runtime.vue.js +2 -2
  35. package/dist/es/components/runtime/views/assemblys/button/button/button-runtime.vue2.js +83 -21
  36. package/dist/es/components/runtime/views/assemblys/button/button-group/buttongroup-runtime.vue.js +2 -2
  37. package/dist/es/components/runtime/views/assemblys/button/button-group/buttongroup-runtime.vue2.js +46 -14
  38. package/dist/es/components/runtime/views/assemblys/button/dropdown/dropdown-runtime.vue.js +2 -2
  39. package/dist/es/components/runtime/views/assemblys/button/dropdown/dropdown-runtime.vue2.js +132 -36
  40. package/dist/es/components/runtime/views/assemblys/button/export-pdf/exportpdf-runtime.vue.js +2 -2
  41. package/dist/es/components/runtime/views/assemblys/button/export-pdf/exportpdf-runtime.vue2.js +18 -4
  42. package/dist/es/components/runtime/views/assemblys/button/print-label/printlabel-runtime.vue.js +2 -2
  43. package/dist/es/components/runtime/views/assemblys/button/print-label/printlabel-runtime.vue2.js +107 -17
  44. package/dist/es/components/runtime/views/assemblys/chart/column-line/column-line-runtime.vue.js +2 -2
  45. package/dist/es/components/runtime/views/assemblys/chart/column-line/column-line-runtime.vue2.js +198 -50
  46. package/dist/es/components/runtime/views/assemblys/chart/common/common-chart-header-breadcrumb.vue.js +42 -12
  47. package/dist/es/components/runtime/views/assemblys/chart/common/common-chart-header-breadcrumb.vue2.js +2 -2
  48. package/dist/es/components/runtime/views/assemblys/chart/common/common-chart-header-group.vue.js +60 -7
  49. package/dist/es/components/runtime/views/assemblys/chart/common/common-chart-header-group.vue2.js +2 -2
  50. package/dist/es/components/runtime/views/assemblys/chart/common/common-chart-header.vue.js +203 -52
  51. package/dist/es/components/runtime/views/assemblys/chart/common/common-chart-header.vue2.js +2 -2
  52. package/dist/es/components/runtime/views/assemblys/chart/common/common-homepage-search.vue.js +4 -4
  53. package/dist/es/components/runtime/views/assemblys/chart/common/common-homepage-search.vue2.js +162 -46
  54. package/dist/es/components/runtime/views/assemblys/chart/gauge/gauge-runtime.vue.js +2 -2
  55. package/dist/es/components/runtime/views/assemblys/chart/gauge/gauge-runtime.vue2.js +109 -32
  56. package/dist/es/components/runtime/views/assemblys/chart/pie/pie-runtime.vue.js +2 -2
  57. package/dist/es/components/runtime/views/assemblys/chart/pie/pie-runtime.vue2.js +166 -43
  58. package/dist/es/components/runtime/views/assemblys/chart/radar/radar-runtime.vue.js +2 -2
  59. package/dist/es/components/runtime/views/assemblys/chart/radar/radar-runtime.vue2.js +117 -32
  60. package/dist/es/components/runtime/views/assemblys/chart/scatter/scatter-runtime.vue.js +2 -2
  61. package/dist/es/components/runtime/views/assemblys/chart/scatter/scatter-runtime.vue2.js +118 -32
  62. package/dist/es/components/runtime/views/assemblys/chart/table/chart-table-util.js +597 -246
  63. package/dist/es/components/runtime/views/assemblys/chart/table/group-column-item.vue.js +42 -4
  64. package/dist/es/components/runtime/views/assemblys/chart/table/group-column-item.vue2.js +2 -2
  65. package/dist/es/components/runtime/views/assemblys/chart/table/group-column.vue.js +62 -8
  66. package/dist/es/components/runtime/views/assemblys/chart/table/group-column.vue2.js +2 -2
  67. package/dist/es/components/runtime/views/assemblys/chart/table/normal-column.vue.js +160 -29
  68. package/dist/es/components/runtime/views/assemblys/chart/table/normal-column.vue2.js +2 -2
  69. package/dist/es/components/runtime/views/assemblys/chart/table/table-pageination.vue.js +62 -13
  70. package/dist/es/components/runtime/views/assemblys/chart/table/table-pageination.vue2.js +2 -2
  71. package/dist/es/components/runtime/views/assemblys/chart/table/table-runtime.vue.js +2 -2
  72. package/dist/es/components/runtime/views/assemblys/chart/table/table-runtime.vue2.js +594 -212
  73. package/dist/es/components/runtime/views/assemblys/common/export-form-report-dialog.vue.js +139 -29
  74. package/dist/es/components/runtime/views/assemblys/common/export-form-report-dialog.vue2.js +2 -2
  75. package/dist/es/components/runtime/views/assemblys/common/remove-signer-dialog.vue.js +125 -21
  76. package/dist/es/components/runtime/views/assemblys/common/remove-signer-dialog.vue2.js +2 -2
  77. package/dist/es/components/runtime/views/assemblys/common/task-informition-dialog.vue.js +102 -16
  78. package/dist/es/components/runtime/views/assemblys/common/task-informition-dialog.vue2.js +2 -2
  79. package/dist/es/components/runtime/views/assemblys/container/card/card-runtime.vue.js +2 -2
  80. package/dist/es/components/runtime/views/assemblys/container/card/card-runtime.vue2.js +81 -18
  81. package/dist/es/components/runtime/views/assemblys/container/collapse/collapse-runtime.vue.js +2 -2
  82. package/dist/es/components/runtime/views/assemblys/container/collapse/collapse-runtime.vue2.js +82 -17
  83. package/dist/es/components/runtime/views/assemblys/container/container/container-runtime.vue.js +2 -2
  84. package/dist/es/components/runtime/views/assemblys/container/container/container-runtime.vue2.js +86 -14
  85. package/dist/es/components/runtime/views/assemblys/container/flex/flex-runtime.vue.js +2 -2
  86. package/dist/es/components/runtime/views/assemblys/container/flex/flex-runtime.vue2.js +79 -21
  87. package/dist/es/components/runtime/views/assemblys/container/form/form-runtime.vue.js +2 -2
  88. package/dist/es/components/runtime/views/assemblys/container/form/form-runtime.vue2.js +61 -16
  89. package/dist/es/components/runtime/views/assemblys/container/iframe/iframe-runtime.vue.js +2 -2
  90. package/dist/es/components/runtime/views/assemblys/container/iframe/iframe-runtime.vue2.js +37 -10
  91. package/dist/es/components/runtime/views/assemblys/container/tabs/tabs-runtime.vue.js +2 -2
  92. package/dist/es/components/runtime/views/assemblys/container/tabs/tabs-runtime.vue2.js +127 -38
  93. package/dist/es/components/runtime/views/assemblys/container/tools/tools-runtime.vue.js +2 -2
  94. package/dist/es/components/runtime/views/assemblys/container/tools/tools-runtime.vue2.js +76 -28
  95. package/dist/es/components/runtime/views/assemblys/data/bar-code/barcode-runtime.vue.js +2 -2
  96. package/dist/es/components/runtime/views/assemblys/data/bar-code/barcode-runtime.vue2.js +178 -61
  97. package/dist/es/components/runtime/views/assemblys/data/table/main-table-runtime.vue.js +810 -302
  98. package/dist/es/components/runtime/views/assemblys/data/table/main-table-runtime.vue2.js +2 -2
  99. package/dist/es/components/runtime/views/assemblys/data/table/sub-table-runtime.vue.js +635 -262
  100. package/dist/es/components/runtime/views/assemblys/data/table/sub-table-runtime.vue2.js +2 -2
  101. package/dist/es/components/runtime/views/assemblys/data/table/table-runtime.vue.js +2 -2
  102. package/dist/es/components/runtime/views/assemblys/data/table/table-runtime.vue2.js +115 -40
  103. package/dist/es/components/runtime/views/assemblys/data/tree/tree-runtime.vue.js +2 -2
  104. package/dist/es/components/runtime/views/assemblys/data/tree/tree-runtime.vue2.js +215 -56
  105. package/dist/es/components/runtime/views/assemblys/error-render.vue.js +21 -3
  106. package/dist/es/components/runtime/views/assemblys/error-render.vue2.js +2 -2
  107. package/dist/es/components/runtime/views/assemblys/form/checkbox/checkbox-runtime.vue.js +2 -2
  108. package/dist/es/components/runtime/views/assemblys/form/checkbox/checkbox-runtime.vue2.js +154 -42
  109. package/dist/es/components/runtime/views/assemblys/form/common/title-suffix-element.vue.js +98 -34
  110. package/dist/es/components/runtime/views/assemblys/form/common/title-suffix-element.vue2.js +2 -2
  111. package/dist/es/components/runtime/views/assemblys/form/custom/custom-runtime.vue.js +2 -2
  112. package/dist/es/components/runtime/views/assemblys/form/custom/custom-runtime.vue2.js +200 -52
  113. package/dist/es/components/runtime/views/assemblys/form/date-picker/datepicker-runtime.vue.js +2 -2
  114. package/dist/es/components/runtime/views/assemblys/form/date-picker/datepicker-runtime.vue2.js +239 -68
  115. package/dist/es/components/runtime/views/assemblys/form/dept-tree/depttree-runtime.vue.js +2 -2
  116. package/dist/es/components/runtime/views/assemblys/form/dept-tree/depttree-runtime.vue2.js +109 -31
  117. package/dist/es/components/runtime/views/assemblys/form/divider/divider-runtime.vue.js +2 -2
  118. package/dist/es/components/runtime/views/assemblys/form/divider/divider-runtime.vue2.js +59 -21
  119. package/dist/es/components/runtime/views/assemblys/form/file-upload/fileupload-runtime.vue.js +2 -2
  120. package/dist/es/components/runtime/views/assemblys/form/file-upload/fileupload-runtime.vue2.js +188 -56
  121. package/dist/es/components/runtime/views/assemblys/form/input-number/input-number-runtime.vue.js +2 -2
  122. package/dist/es/components/runtime/views/assemblys/form/input-number/input-number-runtime.vue2.js +103 -22
  123. package/dist/es/components/runtime/views/assemblys/form/input-text/inputtext-runtime.vue.js +2 -2
  124. package/dist/es/components/runtime/views/assemblys/form/input-text/inputtext-runtime.vue2.js +245 -57
  125. package/dist/es/components/runtime/views/assemblys/form/label/label-runtime.vue.js +2 -2
  126. package/dist/es/components/runtime/views/assemblys/form/label/label-runtime.vue2.js +174 -32
  127. package/dist/es/components/runtime/views/assemblys/form/link/link-runtime.vue.js +2 -2
  128. package/dist/es/components/runtime/views/assemblys/form/link/link-runtime.vue2.js +107 -28
  129. package/dist/es/components/runtime/views/assemblys/form/placeholder/placeholder-runtime.vue.js +4 -4
  130. package/dist/es/components/runtime/views/assemblys/form/placeholder/placeholder-runtime.vue2.js +50 -13
  131. package/dist/es/components/runtime/views/assemblys/form/radio/radio-runtime.vue.js +2 -2
  132. package/dist/es/components/runtime/views/assemblys/form/radio/radio-runtime.vue2.js +194 -64
  133. package/dist/es/components/runtime/views/assemblys/form/rich-text/richtext-runtime.vue.js +2 -2
  134. package/dist/es/components/runtime/views/assemblys/form/rich-text/richtext-runtime.vue2.js +249 -88
  135. package/dist/es/components/runtime/views/assemblys/form/select/select-runtime.vue.js +2 -2
  136. package/dist/es/components/runtime/views/assemblys/form/select/select-runtime.vue2.js +263 -80
  137. package/dist/es/components/runtime/views/assemblys/form/separatelabel/separatelabel-runtime.vue.js +2 -2
  138. package/dist/es/components/runtime/views/assemblys/form/separatelabel/separatelabel-runtime.vue2.js +57 -13
  139. package/dist/es/components/runtime/views/assemblys/form/switch/switch-runtime.vue.js +2 -2
  140. package/dist/es/components/runtime/views/assemblys/form/switch/switch-runtime.vue2.js +155 -30
  141. package/dist/es/components/runtime/views/assemblys/form/tag/tag-runtime.vue.js +2 -2
  142. package/dist/es/components/runtime/views/assemblys/form/tag/tag-runtime.vue2.js +129 -40
  143. package/dist/es/components/runtime/views/assemblys/form/textarea/textarea-runtime.vue.js +2 -2
  144. package/dist/es/components/runtime/views/assemblys/form/textarea/textarea-runtime.vue2.js +107 -22
  145. package/dist/es/components/runtime/views/assemblys/home-chart-render.vue.js +188 -89
  146. package/dist/es/components/runtime/views/assemblys/home-chart-render.vue2.js +2 -2
  147. package/dist/es/components/runtime/views/assemblys/object-render.vue.js +272 -133
  148. package/dist/es/components/runtime/views/assemblys/object-render.vue2.js +2 -2
  149. package/dist/es/components/runtime/views/assemblys/workflow/picture-flow/pictureflow-runtime.vue.js +2 -2
  150. package/dist/es/components/runtime/views/assemblys/workflow/picture-flow/pictureflow-runtime.vue2.js +46 -18
  151. package/dist/es/components/runtime/views/assemblys/workflow/text-history/textflow-runtime.vue.js +2 -2
  152. package/dist/es/components/runtime/views/assemblys/workflow/text-history/textflow-runtime.vue2.js +49 -21
  153. package/dist/es/components/runtime/views/assemblys/workflow/workflow-button/workflowbutton-runtime.vue.js +2 -2
  154. package/dist/es/components/runtime/views/assemblys/workflow/workflow-button/workflowbutton-runtime.vue2.js +58 -20
  155. package/dist/es/components/runtime/views/assemblys/workflow/workflow-node/workflownode-runtime.vue.js +2 -2
  156. package/dist/es/components/runtime/views/assemblys/workflow/workflow-node/workflownode-runtime.vue2.js +53 -16
  157. package/dist/es/components/runtime/views/home-chart.vue.js +160 -40
  158. package/dist/es/components/runtime/views/home-chart.vue2.js +2 -2
  159. package/dist/es/components/runtime/views/super-page-dialog.vue.js +139 -20
  160. package/dist/es/components/runtime/views/super-page-dialog.vue2.js +2 -2
  161. package/dist/es/components/runtime/views/super-page.vue.js +754 -226
  162. package/dist/es/components/runtime/views/super-page.vue2.js +2 -2
  163. package/dist/es/i18n/langs/cn.js +55 -2
  164. package/dist/es/i18n/langs/en.js +55 -2
  165. package/package.json +2 -2
@@ -2,343 +2,694 @@ import { getParamNames, getValueFromVariable } from "../../../../utils/page-help
2
2
  import { getCustomFunc } from "../../../../utils/events/event-util.js";
3
3
  import { getMinValue, getMaxValue, getSumValue, getAvgValue } from "../../../../utils/charts/chart-util.js";
4
4
  class ExpressionEvaluator {
5
- static evaluate(e, t, o) {
6
- const r = t.map((t2) => this.createExpression(e, t2, o)).join(" ");
7
- return this.evaluateExpression(r);
8
- }
9
- static createExpression(e, t, o) {
10
- const { propName: r, operator: a, propValue: n, leftBracket: s, rightBracket: l, joinSign: i, dataType: c } = t;
11
- if (!r || "" === r) return "";
12
- const u = getValueFromVariable(e.entity, r, o);
13
- let p = `${s} ${this.getComparisonExpression(u, a, getValueFromVariable(e.entity, n, o), c)} ${l}`;
14
- return i && ("and" === i || "AND" === i ? p += "&&" : "or" !== i && "OR" !== i || (p += "||")), p.trim();
15
- }
16
- static getComparisonExpression(e, t, o, r) {
17
- t || (t = "EQ");
18
- const a = this.parseValue(e, r), n = this.parseValue(o, r);
19
- switch (t) {
5
+ static evaluate(pageContext, conditions, data2) {
6
+ const expressions = conditions.map(
7
+ (condition) => this.createExpression(pageContext, condition, data2)
8
+ );
9
+ const joinedExpression = expressions.join(" ");
10
+ return this.evaluateExpression(joinedExpression);
11
+ }
12
+ static createExpression(pageContext, condition, data2) {
13
+ const { propName, operator, propValue, leftBracket, rightBracket, joinSign, dataType } = condition;
14
+ if (!propName || propName === "") {
15
+ return "";
16
+ }
17
+ const value = getValueFromVariable(pageContext.entity, propName, data2);
18
+ let expression2 = `${leftBracket} ${this.getComparisonExpression(value, operator, getValueFromVariable(pageContext.entity, propValue, data2), dataType)} ${rightBracket}`;
19
+ if (joinSign) {
20
+ if (joinSign === "and" || joinSign === "AND") {
21
+ expression2 += "&&";
22
+ } else if (joinSign === "or" || joinSign === "OR") {
23
+ expression2 += "||";
24
+ }
25
+ }
26
+ return expression2.trim();
27
+ }
28
+ static getComparisonExpression(value, operator, propValue, dataType) {
29
+ if (!operator) {
30
+ operator = "EQ";
31
+ }
32
+ const parsedValue = this.parseValue(value, dataType);
33
+ const parsedPropValue = this.parseValue(propValue, dataType);
34
+ switch (operator) {
20
35
  case "EQ":
21
- return `${a} === ${n}`;
36
+ return `${parsedValue} === ${parsedPropValue}`;
22
37
  case "GT":
23
- return `${a} > ${n}`;
38
+ return `${parsedValue} > ${parsedPropValue}`;
24
39
  case "LT":
25
- return `${a} < ${n}`;
40
+ return `${parsedValue} < ${parsedPropValue}`;
26
41
  case "GET":
27
- return `${a} >= ${n}`;
42
+ return `${parsedValue} >= ${parsedPropValue}`;
28
43
  case "LET":
29
- return `${a} <= ${n}`;
44
+ return `${parsedValue} <= ${parsedPropValue}`;
30
45
  case "NET":
31
- return `${a} !== ${n}`;
46
+ return `${parsedValue} !== ${parsedPropValue}`;
32
47
  case "CONTAIN":
33
- return `${a}.includes(${n})`;
48
+ return `${parsedValue}.includes(${parsedPropValue})`;
34
49
  case "NOT_CONTAIN":
35
- return `!${a}.includes(${n})`;
50
+ return `!${parsedValue}.includes(${parsedPropValue})`;
36
51
  case "IS_NULL":
37
- return `${a} === null`;
52
+ return `${parsedValue} === null`;
38
53
  case "IS_NOT_NULL":
39
- return `${a} !== null`;
54
+ return `${parsedValue} !== null`;
40
55
  default:
41
- throw new Error(`比较符号不匹配: ${t}`);
56
+ throw new Error(`比较符号不匹配: ${operator}`);
42
57
  }
43
58
  }
44
- static changeDataType(e) {
45
- let t = e;
46
- return e && ("TEXT" === e ? t = "string" : "DATE" === e || "TIME" === e ? t = "date" : "DOUBLE" !== e && "FLOAT" !== e && "INTEGER" !== e && "LONG" !== e && "BOOLEAN" !== e || (t = "number")), t;
59
+ static changeDataType(dataType) {
60
+ let resultDataType = dataType;
61
+ if (dataType) {
62
+ if (dataType === "TEXT") {
63
+ resultDataType = "string";
64
+ } else if (dataType === "DATE" || dataType === "TIME") {
65
+ resultDataType = "date";
66
+ } else if (dataType === "DOUBLE" || dataType === "FLOAT" || dataType === "INTEGER" || dataType === "LONG" || dataType === "BOOLEAN") {
67
+ resultDataType = "number";
68
+ }
69
+ }
70
+ return resultDataType;
47
71
  }
48
- static parseValue(e, t) {
49
- switch (t = this.changeDataType(t)) {
72
+ static parseValue(value, dataType) {
73
+ dataType = this.changeDataType(dataType);
74
+ switch (dataType) {
50
75
  case "number":
51
- return Number(e);
76
+ return Number(value);
52
77
  case "date":
53
- return new Date(e).getTime();
78
+ return new Date(value).getTime();
54
79
  case "string":
55
- return `"${e}"`;
80
+ return `"${value}"`;
56
81
  default:
57
- throw new Error(`数据类型解析错误: ${t}`);
82
+ throw new Error(`数据类型解析错误: ${dataType}`);
58
83
  }
59
84
  }
60
85
  static evaluateExpression(expression) {
61
86
  try {
62
87
  return eval(expression);
63
- } catch (e) {
88
+ } catch (error) {
89
+ console.error("表达式错误:", expression, error);
64
90
  return false;
65
91
  }
66
92
  }
67
93
  }
68
- function getSummaryTitleColumn(e) {
94
+ function getSummaryTitleColumn(configure) {
69
95
  var _a;
70
- const t = {};
71
- return ((_a = e.props.summaries) == null ? void 0 : _a.titleColumn) && e.props.summaries.titleColumn.length > 0 && e.props.summaries.titleColumn.forEach((e2) => {
72
- t[e2.prop] = e2;
73
- }), t;
96
+ const result = {};
97
+ if (((_a = configure.props.summaries) == null ? void 0 : _a.titleColumn) && configure.props.summaries.titleColumn.length > 0) {
98
+ configure.props.summaries.titleColumn.forEach((item) => {
99
+ result[item.prop] = item;
100
+ });
101
+ }
102
+ return result;
74
103
  }
75
- function getSummaryDataColumn(e, t) {
104
+ function getSummaryDataColumn(configure, type) {
76
105
  var _a;
77
- const o = {};
78
- return ((_a = e.props.summaries) == null ? void 0 : _a.dataColumn) && e.props.summaries.dataColumn.length > 0 && e.props.summaries.dataColumn.forEach((r) => {
79
- var _a2;
80
- const a = (_a2 = e.items) == null ? void 0 : _a2.find((e2) => r.prop === e2.props.base.prop);
81
- a && ("table" === t && a.props.base.tableSummary || "group" === t && a.props.base.groupSummary) && (o[r.prop] = r);
82
- }), o;
106
+ const result = {};
107
+ if (((_a = configure.props.summaries) == null ? void 0 : _a.dataColumn) && configure.props.summaries.dataColumn.length > 0) {
108
+ configure.props.summaries.dataColumn.forEach((item) => {
109
+ var _a2;
110
+ const columnConfigs = (_a2 = configure.items) == null ? void 0 : _a2.find(
111
+ (columnItem) => item.prop === columnItem.props.base.prop
112
+ );
113
+ if (columnConfigs) {
114
+ if (type === "table" && columnConfigs.props.base.tableSummary) {
115
+ result[item.prop] = item;
116
+ } else if (type === "group" && columnConfigs.props.base.groupSummary) {
117
+ result[item.prop] = item;
118
+ }
119
+ }
120
+ });
121
+ }
122
+ return result;
83
123
  }
84
- function summaryStatistics(e, t, o, r) {
85
- let a = "";
86
- const n = e.summaryMode, s = t.map((e2) => Number(e2[o])).filter((e2) => !Number.isNaN(e2));
87
- if (s.length > 0) if ("custom" === n) {
88
- const n2 = getCustomFunc(r, e.customFunc);
89
- if (n2) try {
90
- const e2 = n2.apply(n2, [{ data: t, prop: o }]);
91
- a = e2 ? ` ${e2}` : " N/A";
92
- } catch (e2) {
124
+ function summaryStatistics(summaryColumn, data2, prop, pageContext) {
125
+ let sumsIndex = "";
126
+ const summaryMode = summaryColumn.summaryMode;
127
+ const values = data2.map((item) => Number(item[prop])).filter((value) => !Number.isNaN(value));
128
+ if (values.length > 0) {
129
+ if (summaryMode === "custom") {
130
+ const func = getCustomFunc(pageContext, summaryColumn.customFunc);
131
+ if (func) {
132
+ try {
133
+ const resultValue = func.apply(func, [{ data: data2, prop }]);
134
+ if (resultValue) {
135
+ sumsIndex = ` ${resultValue}`;
136
+ } else {
137
+ sumsIndex = " N/A";
138
+ }
139
+ } catch (error) {
140
+ console.error("自定义函数脚本错误:", data2, error);
141
+ }
142
+ } else {
143
+ sumsIndex = " N/A";
144
+ }
145
+ } else {
146
+ switch (summaryMode) {
147
+ case "sum":
148
+ sumsIndex = ` ${values.reduce((prev, curr) => prev + curr, 0)}`;
149
+ break;
150
+ case "avg":
151
+ sumsIndex = ` ${values.reduce((prev, curr) => prev + curr, 0) / values.length}`;
152
+ break;
153
+ case "min":
154
+ sumsIndex = ` ${Math.min(...values)}`;
155
+ break;
156
+ case "max":
157
+ sumsIndex = ` ${Math.max(...values)}`;
158
+ break;
159
+ default:
160
+ sumsIndex = " N/A";
161
+ }
93
162
  }
94
- else a = " N/A";
95
- } else switch (n) {
96
- case "sum":
97
- a = ` ${s.reduce((e2, t2) => e2 + t2, 0)}`;
98
- break;
99
- case "avg":
100
- a = " " + s.reduce((e2, t2) => e2 + t2, 0) / s.length;
101
- break;
102
- case "min":
103
- a = ` ${Math.min(...s)}`;
104
- break;
105
- case "max":
106
- a = ` ${Math.max(...s)}`;
107
- break;
108
- default:
109
- a = " N/A";
163
+ } else {
164
+ sumsIndex = " N/A";
110
165
  }
111
- else a = " N/A";
112
- return a;
166
+ return sumsIndex;
113
167
  }
114
- function replacePlaceholders(e, t) {
115
- if (e) return e.replace(/\$\{row\.(\w+)\}/g, (e2, o) => Object.prototype.hasOwnProperty.call(t, o) ? t[o] : "");
168
+ function replacePlaceholders(template, data2) {
169
+ if (template) {
170
+ return template.replace(/\$\{row\.(\w+)\}/g, (match, p1) => {
171
+ return Object.prototype.hasOwnProperty.call(data2, p1) ? data2[p1] : "";
172
+ });
173
+ }
116
174
  }
117
- function getHeaderCellStyleUtil(e, t, o) {
175
+ function getHeaderCellStyleUtil(data2, runtimeStyle, props) {
118
176
  var _a;
119
- const r = {};
120
- e.column.property && ((_a = t.titleStyle) == null ? void 0 : _a.forEach((t2) => {
121
- if (t2.field && t2.field.includes(e.column.property)) if (t2.scopeFunc) {
122
- const a2 = getCustomFunc(o.pageContext, t2.scopeFunc);
123
- if (a2) try {
124
- false !== a2.apply(a2, [{ item: t2, data: e }]) && copyStyle(r, t2);
125
- } catch (e2) {
177
+ const headerStyle = {};
178
+ if (data2.column.property) {
179
+ (_a = runtimeStyle.titleStyle) == null ? void 0 : _a.forEach((item) => {
180
+ if (item.field && item.field.includes(data2.column.property)) {
181
+ if (item.scopeFunc) {
182
+ const func = getCustomFunc(props.pageContext, item.scopeFunc);
183
+ if (func) {
184
+ try {
185
+ const funcResult = func.apply(func, [{ item, data: data2 }]);
186
+ if (funcResult !== false) {
187
+ copyStyle(headerStyle, item);
188
+ }
189
+ } catch (error) {
190
+ console.error("自定义函数脚本错误:", item, data2, error);
191
+ }
192
+ }
193
+ } else {
194
+ copyStyle(headerStyle, item);
195
+ }
126
196
  }
127
- } else copyStyle(r, t2);
128
- }));
129
- const a = getCellStyleUtil(e, t.cellTitleStyle, o);
130
- return a && Object.assign(r, a), r;
197
+ });
198
+ }
199
+ const cellTitleStytle = getCellStyleUtil(data2, runtimeStyle.cellTitleStyle, props);
200
+ if (cellTitleStytle) {
201
+ Object.assign(headerStyle, cellTitleStytle);
202
+ }
203
+ return headerStyle;
131
204
  }
132
- function getRowStyleUtil(e, t, o) {
133
- const r = {};
134
- if (o.configure.style.rowStyle) for (let t2 = 0; t2 < o.configure.style.rowStyle.length; t2++) {
135
- const a = o.configure.style.rowStyle[t2];
136
- if (a.scopeFunc) {
137
- const t3 = getCustomFunc(o.pageContext, a.scopeFunc);
138
- if (t3) try {
139
- const o2 = t3.apply(t3, [{ data: e }]);
140
- null != o2 && false !== o2 && copyStyle(r, a);
141
- } catch (e2) {
205
+ function getRowStyleUtil(data2, groupSummaryDataRowIndex, props) {
206
+ const returnStyle = {};
207
+ if (props.configure.style.rowStyle) {
208
+ for (let i = 0; i < props.configure.style.rowStyle.length; i++) {
209
+ const rowStyle = props.configure.style.rowStyle[i];
210
+ if (rowStyle.scopeFunc) {
211
+ const func = getCustomFunc(props.pageContext, rowStyle.scopeFunc);
212
+ if (func) {
213
+ try {
214
+ const funcResult = func.apply(func, [{ data: data2 }]);
215
+ if (funcResult !== void 0 && funcResult !== null && funcResult !== false) {
216
+ copyStyle(returnStyle, rowStyle);
217
+ }
218
+ } catch (error) {
219
+ console.error("自定义函数脚本错误:", data2, error);
220
+ }
221
+ }
222
+ } else if (rowStyle.matchingCondition) {
223
+ const result = ExpressionEvaluator.evaluate(
224
+ props.pageContext,
225
+ rowStyle.matchingCondition,
226
+ data2.row
227
+ );
228
+ if (result || result === void 0) {
229
+ copyStyle(returnStyle, rowStyle);
230
+ }
231
+ } else {
232
+ copyStyle(returnStyle, rowStyle);
233
+ }
234
+ }
235
+ }
236
+ if (groupSummaryDataRowIndex && groupSummaryDataRowIndex.length > 0 && groupSummaryDataRowIndex.indexOf(data2.rowIndex) !== -1) {
237
+ const result = {};
238
+ if (props.configure.style.collectStyle && props.configure.style.collectStyle.length > 0) {
239
+ for (let i = 0; i < props.configure.style.collectStyle.length; i++) {
240
+ const collectStyle = props.configure.style.collectStyle[i];
241
+ copyStyle(result, collectStyle);
142
242
  }
143
- } else if (a.matchingCondition) {
144
- const t3 = ExpressionEvaluator.evaluate(o.pageContext, a.matchingCondition, e.row);
145
- (t3 || void 0 === t3) && copyStyle(r, a);
146
- } else copyStyle(r, a);
147
- }
148
- if (t && t.length > 0 && -1 !== t.indexOf(e.rowIndex)) {
149
- const e2 = {};
150
- if (o.configure.style.collectStyle && o.configure.style.collectStyle.length > 0) for (let t2 = 0; t2 < o.configure.style.collectStyle.length; t2++) {
151
- copyStyle(e2, o.configure.style.collectStyle[t2]);
152
243
  }
153
- return 0 === Object.keys(e2).length && (e2["background-color"] = "var(--el-table-row-hover-bg-color)"), e2;
244
+ if (Object.keys(result).length === 0) {
245
+ result["background-color"] = "var(--el-table-row-hover-bg-color)";
246
+ }
247
+ return result;
154
248
  }
155
- return r;
249
+ return returnStyle;
156
250
  }
157
- function getCellStyleUtil(e, t, o) {
158
- const r = {};
159
- if (t) for (let a = 0; a < t.length; a++) {
160
- const n = t[a];
161
- if (isSetStyle(n)) if (n.scopeFunc) {
162
- const t2 = getCustomFunc(o.pageContext, n.scopeFunc);
163
- if (t2) try {
164
- false !== t2.apply(t2, [{ data: e }]) && copyStyle(r, n);
165
- } catch (e2) {
251
+ function getCellStyleUtil(data2, cellStyles, props) {
252
+ const cellStyle = {};
253
+ if (cellStyles) {
254
+ for (let i = 0; i < cellStyles.length; i++) {
255
+ const columnsStyleSetting = cellStyles[i];
256
+ if (isSetStyle(columnsStyleSetting)) {
257
+ if (columnsStyleSetting.scopeFunc) {
258
+ const func = getCustomFunc(props.pageContext, columnsStyleSetting.scopeFunc);
259
+ if (func) {
260
+ try {
261
+ const funcResult = func.apply(func, [{ data: data2 }]);
262
+ if (funcResult !== false) {
263
+ copyStyle(cellStyle, columnsStyleSetting);
264
+ }
265
+ } catch (error) {
266
+ console.error("自定义函数脚本错误:", data2, error);
267
+ }
268
+ }
269
+ } else if (columnsStyleSetting.matchingCondition) {
270
+ const result = ExpressionEvaluator.evaluate(
271
+ props.pageContext,
272
+ columnsStyleSetting.matchingCondition,
273
+ data2.row
274
+ );
275
+ if (result || result === void 0) {
276
+ copyStyle(cellStyle, columnsStyleSetting);
277
+ }
278
+ } else {
279
+ copyStyle(cellStyle, columnsStyleSetting);
280
+ }
166
281
  }
167
- } else if (n.matchingCondition) {
168
- const t2 = ExpressionEvaluator.evaluate(o.pageContext, n.matchingCondition, e.row);
169
- (t2 || void 0 === t2) && copyStyle(r, n);
170
- } else copyStyle(r, n);
282
+ }
171
283
  }
172
- return r;
284
+ return cellStyle;
173
285
  }
174
- function isSetStyle(e) {
175
- let t;
176
- return e.customStyle && (t = JSON.parse(e.customStyle)), !!(e.style && Object.keys(e.style).length > 0 || t && Object.keys(t).length > 0);
286
+ function isSetStyle(columnsStyleSetting) {
287
+ let customStyle;
288
+ if (columnsStyleSetting.customStyle) {
289
+ customStyle = JSON.parse(columnsStyleSetting.customStyle);
290
+ }
291
+ if (columnsStyleSetting.style && Object.keys(columnsStyleSetting.style).length > 0 || customStyle && Object.keys(customStyle).length > 0) {
292
+ return true;
293
+ }
294
+ return false;
177
295
  }
178
- function copyStyle(e, t) {
179
- Object.assign(e, t.style), t.customStyle && Object.assign(e, JSON.parse(t.customStyle));
296
+ function copyStyle(target, source) {
297
+ Object.assign(target, source.style);
298
+ if (source.customStyle) {
299
+ Object.assign(target, JSON.parse(source.customStyle));
300
+ }
180
301
  }
181
- function rowDataToColumn(e, t, o) {
182
- const r = t.props.dataOrigin.groupField, a = t.props.dataOrigin.rowToColumn.titleColumns, n = t.props.dataOrigin.rowToColumn.dataColumns, s = [], l = {};
183
- if (r && r.length > 0) e.forEach((e2) => {
184
- const t2 = r.map((t3) => e2[t3]).join("|");
185
- if (!l[t2]) {
186
- const o2 = {};
187
- r.forEach((t3) => o2[t3] = e2[t3]), l[t2] = o2, s.push(o2);
188
- }
189
- n.forEach((o2) => {
190
- const r2 = `${a.map((t3) => e2[t3]).join("")}${o2}`;
191
- l[t2][r2] = e2[o2];
192
- });
193
- });
194
- else {
195
- const t2 = [];
196
- e.forEach((e2) => {
197
- a.forEach((o2) => {
198
- e2[o2] && t2.push(e2[o2]);
302
+ function rowDataToColumn(data2, configure, sourceTableColumnsConfig) {
303
+ const groupByFields = configure.props.dataOrigin.groupField;
304
+ const titleColumns = configure.props.dataOrigin.rowToColumn.titleColumns;
305
+ const dataColumns = configure.props.dataOrigin.rowToColumn.dataColumns;
306
+ const result = [];
307
+ const groupedData = {};
308
+ if (groupByFields && groupByFields.length > 0) {
309
+ data2.forEach((item) => {
310
+ const key2 = groupByFields.map((field) => item[field]).join("|");
311
+ if (!groupedData[key2]) {
312
+ const group = {};
313
+ groupByFields.forEach((field) => group[field] = item[field]);
314
+ groupedData[key2] = group;
315
+ result.push(group);
316
+ }
317
+ dataColumns.forEach((valueField) => {
318
+ const columnNameParts = titleColumns.map((field) => item[field]);
319
+ const columnName = `${columnNameParts.join("")}${valueField}`;
320
+ groupedData[key2][columnName] = item[valueField];
199
321
  });
200
- }), n.forEach((t3) => {
201
- const r2 = {}, n2 = o.find((e2) => {
202
- var _a, _b;
203
- return ((_b = (_a = e2.props) == null ? void 0 : _a.base) == null ? void 0 : _b.prop) === t3;
322
+ });
323
+ } else {
324
+ const titleColProp = [];
325
+ data2.forEach((item) => {
326
+ titleColumns.forEach((titleColumn) => {
327
+ if (item[titleColumn]) {
328
+ titleColProp.push(item[titleColumn]);
329
+ }
204
330
  });
205
- n2 && (r2.$GroupColumn = n2.props.base.name), e.forEach((e2) => {
206
- a.forEach((o2) => {
207
- const a2 = e2[o2], n3 = e2[t3];
208
- r2[a2] = n3;
331
+ });
332
+ dataColumns.forEach((dataColumn) => {
333
+ const rowData = {};
334
+ const sourceDataColumns = sourceTableColumnsConfig.find(
335
+ (column) => {
336
+ var _a, _b;
337
+ return ((_b = (_a = column.props) == null ? void 0 : _a.base) == null ? void 0 : _b.prop) === dataColumn;
338
+ }
339
+ );
340
+ if (sourceDataColumns) {
341
+ rowData.$GroupColumn = sourceDataColumns.props.base.name;
342
+ }
343
+ data2.forEach((item) => {
344
+ titleColumns.forEach((titleProp) => {
345
+ const prop = item[titleProp];
346
+ const value = item[dataColumn];
347
+ rowData[prop] = value;
209
348
  });
210
- }), s.push(r2);
349
+ });
350
+ result.push(rowData);
211
351
  });
212
352
  }
213
- return s;
353
+ return result;
214
354
  }
215
- function colDataToRow(e, t) {
216
- const o = t.props.dataOrigin.groupField, r = t.props.dataOrigin.columnToRow.titleColumns, a = t.props.dataOrigin.columnToRow.dataColumns, n = t.props.dataOrigin.columnToRow.transColumns, s = t.props.dataOrigin.columnToRow.dataColumnsMapping;
217
- if (0 === e.length) return e;
218
- const l = [], i = groupBy(e, o), c = a.reduce((e2, t2) => t2.columns.length > e2.columns.length ? t2 : e2, a[0]), u = a.reduce((e2, t2) => (t2.columns.forEach((o2) => {
219
- e2[o2] = t2.prop;
220
- }), e2), {});
221
- return i.forEach((e2) => {
222
- c.columns.forEach((t2) => {
223
- const i2 = c.prop, p = {};
224
- if (o.forEach((t3) => {
225
- p[t3] = e2[t3];
226
- }), p[i2] = e2[t2], a.length > 1) {
227
- const o2 = s.find((e3) => e3.props.includes(t2));
228
- o2 && o2.props.length > 1 && o2.props.forEach((o3) => {
229
- o3 !== t2 && u[o3] && (p[u[o3]] = e2[o3]);
230
- });
355
+ function colDataToRow(data2, configure) {
356
+ const groupByFields = configure.props.dataOrigin.groupField;
357
+ const titleColumns = configure.props.dataOrigin.columnToRow.titleColumns;
358
+ const dataColumns = configure.props.dataOrigin.columnToRow.dataColumns;
359
+ const transColumns = configure.props.dataOrigin.columnToRow.transColumns;
360
+ const dataColumnsMapping = configure.props.dataOrigin.columnToRow.dataColumnsMapping;
361
+ if (data2.length === 0) {
362
+ return data2;
363
+ }
364
+ const result = [];
365
+ const newData = groupBy(data2, groupByFields);
366
+ const dataColumnsConfig = dataColumns.reduce((max, current) => {
367
+ return current.columns.length > max.columns.length ? current : max;
368
+ }, dataColumns[0]);
369
+ const dataColumnsAndNewColumnMapping = dataColumns.reduce((acc, item) => {
370
+ item.columns.forEach((column) => {
371
+ acc[column] = item.prop;
372
+ });
373
+ return acc;
374
+ }, {});
375
+ newData.forEach((item) => {
376
+ dataColumnsConfig.columns.forEach((col) => {
377
+ const newColumnsProp = dataColumnsConfig.prop;
378
+ const dataRow = {};
379
+ groupByFields.forEach((field) => {
380
+ dataRow[field] = item[field];
381
+ });
382
+ dataRow[newColumnsProp] = item[col];
383
+ if (dataColumns.length > 1) {
384
+ const columnMapping = dataColumnsMapping.find((item2) => item2.props.includes(col));
385
+ if (columnMapping && columnMapping.props.length > 1) {
386
+ columnMapping.props.forEach((prop) => {
387
+ if (prop !== col && dataColumnsAndNewColumnMapping[prop]) {
388
+ dataRow[dataColumnsAndNewColumnMapping[prop]] = item[prop];
389
+ }
390
+ });
391
+ }
231
392
  }
232
- r.forEach((e3) => {
233
- const o2 = n.filter((t3) => t3.relatedTitle === e3.prop);
234
- let r2 = false;
235
- o2 && o2.length > 0 && o2.forEach((o3) => {
236
- if (o3.columns.includes(t2)) return p[e3.prop] = o3.label, void (r2 = true);
237
- }), r2 || (p[e3.prop] = t2);
238
- }), l.push(p);
393
+ titleColumns.forEach((titleCol) => {
394
+ const sourceTitleRenameConfigs = transColumns.filter(
395
+ (transCol) => transCol.relatedTitle === titleCol.prop
396
+ );
397
+ let rename = false;
398
+ if (sourceTitleRenameConfigs && sourceTitleRenameConfigs.length > 0) {
399
+ sourceTitleRenameConfigs.forEach((item2) => {
400
+ if (item2.columns.includes(col)) {
401
+ dataRow[titleCol.prop] = item2.label;
402
+ rename = true;
403
+ return;
404
+ }
405
+ });
406
+ }
407
+ if (!rename) {
408
+ dataRow[titleCol.prop] = col;
409
+ }
410
+ });
411
+ result.push(dataRow);
239
412
  });
240
- }), l;
413
+ });
414
+ return result;
241
415
  }
242
- function getColumnToRowTableConfig(e) {
243
- const t = e.items, o = e.props.dataOrigin.groupField, r = e.props.dataOrigin.columnToRow.titleColumns, a = e.props.dataOrigin.columnToRow.dataColumns, n = [];
244
- o && o.length > 0 && o.forEach((e2) => {
245
- if (t) {
246
- const o2 = t.find((t2) => t2.props.base.prop === e2);
247
- o2 && n.push(o2);
416
+ function getColumnToRowTableConfig(configure) {
417
+ const sourceConfig = configure.items;
418
+ const groupField = configure.props.dataOrigin.groupField;
419
+ const titleColumns = configure.props.dataOrigin.columnToRow.titleColumns;
420
+ const dataColumns = configure.props.dataOrigin.columnToRow.dataColumns;
421
+ const newTableColumns = [];
422
+ if (groupField && groupField.length > 0) {
423
+ groupField.forEach((field) => {
424
+ if (sourceConfig) {
425
+ const column = sourceConfig.find((item) => item.props.base.prop === field);
426
+ if (column) {
427
+ newTableColumns.push(column);
428
+ }
429
+ }
430
+ });
431
+ }
432
+ const newCols = [...titleColumns, ...dataColumns];
433
+ newCols.forEach((field) => {
434
+ if (sourceConfig) {
435
+ const column = sourceConfig.find((item) => item.props.base.prop === field);
436
+ if (column) {
437
+ newTableColumns.push(column);
438
+ } else {
439
+ newTableColumns.push({
440
+ uuid: (/* @__PURE__ */ new Date()).getTime(),
441
+ // 生成新的UUID
442
+ name: "",
443
+ props: {
444
+ base: {
445
+ prop: field.prop,
446
+ name: field.title,
447
+ sortable: true,
448
+ headerAlign: "center",
449
+ align: "center",
450
+ fixed: false,
451
+ visible: true,
452
+ dataType: "string"
453
+ },
454
+ format: {},
455
+ size: {
456
+ pc: {}
457
+ }
458
+ },
459
+ style: {},
460
+ componentIndex: 0,
461
+ // 根据实际情况设置
462
+ runtime: {
463
+ common: {
464
+ class: "",
465
+ style: {
466
+ pc_style: {},
467
+ pc_class: ""
468
+ }
469
+ }
470
+ }
471
+ });
472
+ }
248
473
  }
249
474
  });
250
- return [...r, ...a].forEach((e2) => {
251
- if (t) {
252
- const o2 = t.find((t2) => t2.props.base.prop === e2);
253
- o2 ? n.push(o2) : n.push({ uuid: (/* @__PURE__ */ new Date()).getTime(), name: "", props: { base: { prop: e2.prop, name: e2.title, sortable: true, headerAlign: "center", align: "center", fixed: false, visible: true, dataType: "string" }, format: {}, size: { pc: {} } }, style: {}, componentIndex: 0, runtime: { common: { class: "", style: { pc_style: {}, pc_class: "" } } } });
254
- }
255
- }), n;
475
+ return newTableColumns;
256
476
  }
257
- function groupBy(e, t) {
258
- const o = {};
259
- return e.forEach((e2) => {
260
- const r = t.map((t2) => e2[t2]).join("|");
261
- o[r] || (o[r] = { ...e2, records: [] }, t.forEach((t2, a) => {
262
- o[r][t2] = e2[t2];
263
- })), o[r].records.push(e2);
264
- }), Object.values(o).map((e2) => ({ ...e2, records: void 0 }));
477
+ function groupBy(data2, groupFields) {
478
+ const grouped = {};
479
+ data2.forEach((item) => {
480
+ const key2 = groupFields.map((field) => item[field]).join("|");
481
+ if (!grouped[key2]) {
482
+ grouped[key2] = {
483
+ ...item,
484
+ // 复制所有字段
485
+ records: []
486
+ // 初始化记录数组
487
+ };
488
+ groupFields.forEach((field, index2) => {
489
+ grouped[key2][field] = item[field];
490
+ });
491
+ }
492
+ grouped[key2].records.push(item);
493
+ });
494
+ return Object.values(grouped).map((group) => ({
495
+ ...group,
496
+ // 复制所有分组信息
497
+ records: void 0
498
+ // 移除records字段,因为不需要展示
499
+ }));
265
500
  }
266
501
  function getIndexColumn() {
267
- return { props: { base: { name: "序号", prop: "$index", columnWidth: 80, sortable: true, visible: true, displayOrder: 1, alignTitle: "center", alignContent: "center" } }, events: [], style: { titleFont: {}, contentFont: {}, width: {}, background: {}, tableCell: [{ type: "", model: "" }], conentPadding: {}, tittlePadding: {}, border: {}, shadow: {}, tittleClass: "" } };
502
+ return {
503
+ props: {
504
+ base: {
505
+ name: "序号",
506
+ prop: "$index",
507
+ columnWidth: 80,
508
+ sortable: true,
509
+ visible: true,
510
+ displayOrder: 1,
511
+ alignTitle: "center",
512
+ alignContent: "center"
513
+ }
514
+ },
515
+ events: [],
516
+ style: {
517
+ titleFont: {},
518
+ contentFont: {},
519
+ width: {},
520
+ background: {},
521
+ tableCell: [{ type: "", model: "" }],
522
+ conentPadding: {},
523
+ tittlePadding: {},
524
+ border: {},
525
+ shadow: {},
526
+ tittleClass: ""
527
+ }
528
+ };
268
529
  }
269
- function getNewColumnConfig(e, t, o, r) {
270
- return { uuid: (/* @__PURE__ */ new Date()).getTime(), name: "", props: { base: { prop: e, name: t, displayOrder: o, sortable: true, headerAlign: "center", align: "center", fixed: false, visible: true, dataType: r }, format: {}, size: { pc: {} } }, style: {}, componentIndex: 0, runtime: { common: { class: "", style: { pc_style: {}, pc_class: "" } } } };
530
+ function getNewColumnConfig(prop, name, displayOrder, dataType) {
531
+ return {
532
+ uuid: (/* @__PURE__ */ new Date()).getTime(),
533
+ // 生成新的UUID
534
+ name: "",
535
+ props: {
536
+ base: {
537
+ prop,
538
+ name,
539
+ displayOrder,
540
+ // 更新显示顺序
541
+ sortable: true,
542
+ headerAlign: "center",
543
+ align: "center",
544
+ fixed: false,
545
+ visible: true,
546
+ dataType
547
+ },
548
+ format: {},
549
+ size: {
550
+ pc: {}
551
+ }
552
+ },
553
+ style: {},
554
+ componentIndex: 0,
555
+ // 根据实际情况设置
556
+ runtime: {
557
+ common: {
558
+ class: "",
559
+ style: {
560
+ pc_style: {},
561
+ pc_class: ""
562
+ }
563
+ }
564
+ }
565
+ };
271
566
  }
272
567
  function computeFormula(itemConfs, datas, entity) {
273
568
  Object.keys(itemConfs).forEach((key) => {
274
569
  const paramNames = getParamNames(itemConfs[key]);
275
570
  datas.forEach((data, index) => {
276
571
  const totalValueMap = {};
277
- for (const e of paramNames) if (e.startsWith("${min.")) totalValueMap[e] = getMinValue(datas, getFieldName(e));
278
- else if (e.startsWith("${max.")) totalValueMap[e] = getMaxValue(datas, getFieldName(e));
279
- else if (e.startsWith("${sum.")) totalValueMap[e] = getSumValue(datas, getFieldName(e));
280
- else if (e.startsWith("${avg.")) totalValueMap[e] = getAvgValue(datas, getFieldName(e));
281
- else if (e.startsWith("${add.")) {
282
- const t = getFieldName(e);
283
- let o = 0;
284
- try {
285
- o = Number(data[t]), datas.slice(0, index).forEach((e2) => {
286
- o += Number(e2[t]);
287
- });
288
- } catch (e2) {
289
- o = 0;
572
+ for (const paramName of paramNames) {
573
+ if (paramName.startsWith("${min.")) {
574
+ totalValueMap[paramName] = getMinValue(datas, getFieldName(paramName));
575
+ } else if (paramName.startsWith("${max.")) {
576
+ totalValueMap[paramName] = getMaxValue(datas, getFieldName(paramName));
577
+ } else if (paramName.startsWith("${sum.")) {
578
+ totalValueMap[paramName] = getSumValue(datas, getFieldName(paramName));
579
+ } else if (paramName.startsWith("${avg.")) {
580
+ totalValueMap[paramName] = getAvgValue(datas, getFieldName(paramName));
581
+ } else if (paramName.startsWith("${add.")) {
582
+ const fieldName = getFieldName(paramName);
583
+ let currentRowValue = 0;
584
+ try {
585
+ currentRowValue = Number(data[fieldName]);
586
+ datas.slice(0, index).forEach((item) => {
587
+ currentRowValue += Number(item[fieldName]);
588
+ });
589
+ } catch (e) {
590
+ console.error("计算错误:", e);
591
+ currentRowValue = 0;
592
+ }
593
+ totalValueMap[paramName] = currentRowValue;
594
+ } else if (paramName.startsWith("${page.") || paramName.startsWith("${data.") || paramName.startsWith("${row.") || paramName.startsWith("${request.") || paramName.startsWith("${context.") || paramName.startsWith("${system.") || paramName.startsWith("${fixed.")) {
595
+ totalValueMap[paramName] = getValueFromVariable(entity, paramName, data);
290
596
  }
291
- totalValueMap[e] = o;
292
- } else (e.startsWith("${page.") || e.startsWith("${data.") || e.startsWith("${row.") || e.startsWith("${request.") || e.startsWith("${context.") || e.startsWith("${system.") || e.startsWith("${fixed.")) && (totalValueMap[e] = getValueFromVariable(entity, e, data));
597
+ }
293
598
  let expr = itemConfs[key];
294
- Object.keys(totalValueMap).forEach((e) => {
295
- expr.indexOf(e) > -1 && (expr = expr.replaceAll(e, totalValueMap[e]));
599
+ Object.keys(totalValueMap).forEach((exprParam) => {
600
+ if (expr.indexOf(exprParam) > -1) {
601
+ expr = expr.replaceAll(exprParam, totalValueMap[exprParam]);
602
+ }
296
603
  });
297
- for (const e of paramNames) expr.indexOf(e) > -1 && (expr = expr.replaceAll(e, 0));
604
+ for (const paramName of paramNames) {
605
+ if (expr.indexOf(paramName) > -1) {
606
+ expr = expr.replaceAll(paramName, 0);
607
+ }
608
+ }
298
609
  try {
299
610
  data[key] = eval(expr);
300
611
  } catch (e) {
612
+ console.error(itemConfs[key] + " 计算错误, 替换后表达式为:" + expr, e);
301
613
  data[key] = 0;
302
614
  }
303
615
  });
304
616
  });
305
617
  }
306
- function getFieldName(e) {
307
- return e.substring(6, e.length - 1);
618
+ function getFieldName(paramName) {
619
+ return paramName.substring(6, paramName.length - 1);
308
620
  }
309
- function formatColContent(e, t, o, r, a) {
310
- const n = e[o.props.base.prop];
311
- switch (t.type) {
621
+ function formatColContent(row, format, column, pageContext, configure) {
622
+ const value = row[column.props.base.prop];
623
+ switch (format.type) {
312
624
  case "number":
313
- return formatNumber(n, t);
625
+ return formatNumber(value, format);
314
626
  case "currency":
315
- return formatCurrency(n, t);
627
+ return formatCurrency(value, format);
316
628
  case "percent":
317
- return formatPercent(n, t);
629
+ return formatPercent(value, format);
318
630
  case "custom":
319
- return formatCustomFunc(e, t, o, r, a);
631
+ return formatCustomFunc(row, format, column, pageContext, configure);
320
632
  default:
321
- return n;
633
+ return value;
322
634
  }
323
635
  }
324
- function formatNumber(e, t) {
325
- let o = e;
326
- return o || (o = 0), t.scientific && (o = Number(e).toExponential(t.scientificNum)), t.decimalDigit && (o = Number(e).toFixed(t.decimalDigit)), t.thousandsSeparator && (o = o.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")), t.symbol && (o = `${t.symbol} ${o}`), o;
636
+ function formatNumber(value, format) {
637
+ let formattedValue = value;
638
+ if (!formattedValue) {
639
+ formattedValue = 0;
640
+ }
641
+ if (format.scientific) {
642
+ formattedValue = Number(value).toExponential(format.scientificNum);
643
+ }
644
+ if (format.decimalDigit) {
645
+ formattedValue = Number(value).toFixed(format.decimalDigit);
646
+ }
647
+ if (format.thousandsSeparator) {
648
+ formattedValue = formattedValue.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
649
+ }
650
+ if (format.symbol) {
651
+ formattedValue = `${format.symbol} ${formattedValue}`;
652
+ }
653
+ return formattedValue;
327
654
  }
328
- function formatCurrency(e, t) {
329
- let o = e;
330
- return o || (o = 0), t.decimalDigit && (o = Number(e).toFixed(t.decimalDigit)), t.symbol && (o = `${t.symbol} ${o}`), o;
655
+ function formatCurrency(value, format) {
656
+ let formattedValue = value;
657
+ if (!formattedValue) {
658
+ formattedValue = 0;
659
+ }
660
+ if (format.decimalDigit) {
661
+ formattedValue = Number(value).toFixed(format.decimalDigit);
662
+ }
663
+ if (format.symbol) {
664
+ formattedValue = `${format.symbol} ${formattedValue}`;
665
+ }
666
+ return formattedValue;
331
667
  }
332
- function formatPercent(e, t) {
333
- let o = e;
334
- return o || (o = 0), t.decimalDigit && (o = Number(e).toFixed(t.decimalDigit)), o + " %";
668
+ function formatPercent(value, format) {
669
+ let formattedValue = value;
670
+ if (!formattedValue) {
671
+ formattedValue = 0;
672
+ }
673
+ if (format.decimalDigit) {
674
+ formattedValue = Number(value).toFixed(format.decimalDigit);
675
+ }
676
+ return formattedValue + " %";
335
677
  }
336
- function formatCustomFunc(e, t, o, r, a) {
337
- const n = getCustomFunc(r, t.customFunc);
338
- if (n) {
678
+ function formatCustomFunc(row, format, column, pageContext, configure) {
679
+ const func = getCustomFunc(pageContext, format.customFunc);
680
+ if (func) {
339
681
  try {
340
- return n.apply(n, [{ pageContext: r, configureObj: a, row: e, prop: o.props.base.prop }]);
341
- } catch (e2) {
682
+ const resultValue = func.apply(func, [
683
+ {
684
+ pageContext,
685
+ configureObj: configure,
686
+ row,
687
+ prop: column.props.base.prop
688
+ }
689
+ ]);
690
+ return resultValue;
691
+ } catch (error) {
692
+ console.error("自定义函数脚本错误:", row, error);
342
693
  }
343
694
  return "";
344
695
  }