@agile-team/mach-report 2.15.0 → 2.16.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.
- package/README.md +14 -9
- package/dist/{ExcelBindingWizard-Bs43BGNp.cjs → ExcelBindingWizard-CP6h2x1f.cjs} +1 -1
- package/dist/{ExcelBindingWizard-BKH1nGNS.js → ExcelBindingWizard-HhB3hAJE.js} +3 -3
- package/dist/{ParamEditor-Da4akw6V.cjs → ParamEditor-CUQLgoxa.cjs} +1 -1
- package/dist/{ParamEditor-DoAhzJsm.js → ParamEditor-OKesP_nO.js} +1 -1
- package/dist/{ReportBatchPanel-wP9m9Pj1.cjs → ReportBatchPanel-cZCAMAwH.cjs} +1 -1
- package/dist/{ReportBatchPanel-BMf6boMA.js → ReportBatchPanel-ruxcbfY6.js} +3 -3
- package/dist/ReportPreview-BcDKCLiK.js +4834 -0
- package/dist/ReportPreview-Bk9nLfO9.cjs +6 -0
- package/dist/{ReportTemplateLibrary-Sxr3eD0J.cjs → ReportTemplateLibrary-BDlNT8JN.cjs} +1 -1
- package/dist/{ReportTemplateLibrary-C9wutIiT.js → ReportTemplateLibrary-DcwrH-63.js} +1 -1
- package/dist/{RuleEditor-XhGHK8DE.cjs → RuleEditor-BX5S8RSF.cjs} +1 -1
- package/dist/{RuleEditor-C_Clasvd.js → RuleEditor-CGl9XY2s.js} +2 -2
- package/dist/{TemplateOutlinePanel-JTSR53vJ.cjs → TemplateOutlinePanel-CGrT5DFN.cjs} +1 -1
- package/dist/{TemplateOutlinePanel-D6Bkny59.js → TemplateOutlinePanel-SXCjaPKR.js} +1 -1
- package/dist/{TemplateReusePanel-Kx35S0Ql.cjs → TemplateReusePanel-6Z3wRFz8.cjs} +1 -1
- package/dist/{TemplateReusePanel-rVuK1kTz.js → TemplateReusePanel-lHLOS9Wn.js} +2 -2
- package/dist/{TemplateReviewPanel-B0ar9_zf.js → TemplateReviewPanel-CJ9PLc48.js} +1 -1
- package/dist/{TemplateReviewPanel-Dn6X9UmY.cjs → TemplateReviewPanel-Dpk7sLcF.cjs} +1 -1
- package/dist/analytics.d.cts +2 -0
- package/dist/analytics.d.ts +2 -0
- package/dist/artifact-integrity.json +99 -91
- package/dist/{assets-DEaz4qsp.js → assets-CqIbfbTr.js} +24 -22
- package/dist/assets-e4YSke8n.cjs +1 -0
- package/dist/auto-YR7a4BtF.js +240 -0
- package/dist/auto-uVBjX1j5.cjs +1 -0
- package/dist/{batch-BfZHN1do.js → batch-WzDIXJAt.js} +1 -1
- package/dist/{batch-CLpELXBl.cjs → batch-z6Aw5GEY.cjs} +1 -1
- package/dist/capabilities-DDwXr_cA.js +103 -0
- package/dist/capabilities-DNLyZdNw.cjs +1 -0
- package/dist/codes.d.cts +2 -0
- package/dist/codes.d.ts +2 -0
- package/dist/component-tree-Ca6YYfHq.js +61 -0
- package/dist/component-tree-DkGLEfZC.cjs +1 -0
- package/dist/config-Dg_o8e7m.cjs +1 -0
- package/dist/{config-BVsJXSqS.js → config-XQ4qrQ7Q.js} +66 -64
- package/dist/designer-BfQSahxq.js +5163 -0
- package/dist/designer-CPPdeM5_.cjs +2 -0
- package/dist/designer.cjs +1 -1
- package/dist/designer.d.cts +53 -0
- package/dist/designer.d.ts +53 -0
- package/dist/designer.js +1 -1
- package/dist/diagnostic-notification-B9K9We3h.cjs +1 -0
- package/dist/diagnostic-notification-qGAYZdkB.js +7 -0
- package/dist/drill-CsdjgkRM.cjs +1 -0
- package/dist/{drill-ByJviLXS.js → drill-DIGsZfyB.js} +11 -11
- package/dist/encoding-BOGq4qYL.js +21 -0
- package/dist/encoding-BYF9ZTl9.cjs +1 -0
- package/dist/{font-loader-Q3bQjmrI.js → font-loader-CzI1GuBc.js} +1 -1
- package/dist/{font-loader-B_UkxpzC.cjs → font-loader-EKLzOJxf.cjs} +1 -1
- package/dist/index.cjs +7 -8
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +865 -834
- package/dist/json-snapshot-D6ioHth9.js +1702 -0
- package/dist/json-snapshot-DknkjvxP.cjs +2 -0
- package/dist/{pdf-CvvrjPQg.cjs → pdf-ByVCb1i6.cjs} +48 -50
- package/dist/{pdf-BwNyeGpt.js → pdf-DJ5S6ukC.js} +2737 -2749
- package/dist/pdf.cjs +1 -1
- package/dist/pdf.d.cts +2 -0
- package/dist/pdf.d.ts +2 -0
- package/dist/pdf.js +2 -2
- package/dist/{plugin-Ca_XZG3l.js → plugin-C2j5_mhx.js} +1 -1
- package/dist/{plugin-DHO7X8z2.cjs → plugin-Dr39GBRG.cjs} +1 -1
- package/dist/prepared-DdrjLC7L.cjs +1 -0
- package/dist/prepared-DqtpvRTn.js +87 -0
- package/dist/progress-BXzlVbIp.js +29 -0
- package/dist/progress-DJBd9Rb9.cjs +1 -0
- package/dist/{progress-D-OTpEav.js → progress-Hc2vxoCs.js} +2 -2
- package/dist/protocol-BzwMP4Vw.cjs +1 -0
- package/dist/protocol-kt4Iy6-3.js +90 -0
- package/dist/{record-bindings-Do_b3h4V.js → record-bindings-CZWBJ1fU.js} +9 -10
- package/dist/record-bindings-DUX1VMlR.cjs +1 -0
- package/dist/{region-binding-workflow-BMhK_TjP.js → region-binding-workflow-CWNvIjkV.js} +1 -1
- package/dist/{region-binding-workflow-DIYJdCUr.cjs → region-binding-workflow-CqSMxQ4p.cjs} +1 -1
- package/dist/report-encoding-worker.cjs +1 -0
- package/dist/report-encoding-worker.d.ts +1 -0
- package/dist/report-encoding-worker.js +2 -0
- package/dist/rich-text-layout-ALlMoYOG.cjs +3 -0
- package/dist/rich-text-layout-Ct5WrY1g.js +102 -0
- package/dist/runtime-BjKBI530.js +168 -0
- package/dist/runtime-CBFEPKEs.cjs +1 -0
- package/dist/sbom.cdx.json +2 -2
- package/dist/server/node.d.cts +86 -1
- package/dist/server/node.d.ts +86 -1
- package/dist/server-node.cjs +5 -1
- package/dist/server-node.js +4558 -473
- package/dist/server.cjs +1 -1
- package/dist/server.d.cts +8 -1
- package/dist/server.d.ts +8 -1
- package/dist/server.js +634 -792
- package/dist/sha256-BshdOkCC.cjs +1 -0
- package/dist/sha256-DTG-Gq8i.js +157 -0
- package/dist/style-67OqfNed.js +73 -0
- package/dist/style-C22Pbv3T.cjs +1 -0
- package/dist/style.css +1 -1
- package/dist/{template-catalog-j2B1MJlL.js → template-catalog-BtR2JmCL.js} +9 -9
- package/dist/{template-catalog-FJE_c9Qe.cjs → template-catalog-C2NLdrwB.cjs} +1 -1
- package/dist/{template-fragments-DcKeiylI.cjs → template-fragments-BVsbxs4a.cjs} +1 -1
- package/dist/{template-fragments-BGbQLGlV.js → template-fragments-By0aZC1D.js} +2 -2
- package/dist/template-registry-C62vpv4a.cjs +1 -0
- package/dist/{template-registry-BtaKPELV.js → template-registry-Cw3vRTX2.js} +389 -321
- package/dist/{textwrap-DE1kgcJB.js → textwrap-BEIg2w8y.js} +1 -1
- package/dist/textwrap-BI-yJ6Wt.cjs +4 -0
- package/dist/vue/async.d.cts +66 -0
- package/dist/vue/async.d.ts +66 -0
- package/dist/vue/index.d.cts +89 -1
- package/dist/vue/index.d.ts +89 -1
- package/dist/vue-async.cjs +1 -1
- package/dist/vue-async.js +3 -3
- package/dist/vue.cjs +1 -1
- package/dist/vue.js +7 -7
- package/dist/{workbook-session-BvToI-Fd.js → workbook-session-BeSO8PFB.js} +153 -140
- package/dist/{workbook-session-Bjv1YCRK.cjs → workbook-session-Cbts-22R.cjs} +12 -12
- package/dist/worker.cjs +1 -1
- package/dist/worker.d.cts +84 -1
- package/dist/worker.d.ts +84 -1
- package/dist/worker.js +12 -157
- package/dist/xlsx-node.cjs +33 -33
- package/dist/xlsx-node.js +1282 -1289
- package/dist/xlsx.cjs +4 -3
- package/dist/xlsx.d.cts +2 -0
- package/dist/xlsx.d.ts +2 -0
- package/dist/xlsx.js +297 -279
- package/package.json +6 -3
- package/dist/ReportPreview-ChV19HBp.js +0 -4619
- package/dist/ReportPreview-DbLvvOUT.cjs +0 -6
- package/dist/assets-B9ImAi6_.cjs +0 -1
- package/dist/batch-BaP6pWDE.cjs +0 -1
- package/dist/batch-CGyt-b2W.js +0 -273
- package/dist/capabilities-CAh2Nrue.cjs +0 -1
- package/dist/capabilities-DskCHs3V.js +0 -69
- package/dist/config-D10us76d.cjs +0 -1
- package/dist/data-explanation-B8MZRYVS.js +0 -16
- package/dist/data-explanation-DE55G30w.cjs +0 -1
- package/dist/defaults-DXhiM1ZD.js +0 -10
- package/dist/defaults-xhmcLLrf.cjs +0 -1
- package/dist/designer-2bDlcNXQ.js +0 -5136
- package/dist/designer-BT7XCdbW.cjs +0 -2
- package/dist/drill-DYTxuL3A.cjs +0 -1
- package/dist/grid-strokes-Cr7DwUux.cjs +0 -1
- package/dist/grid-strokes-DyyG1q_o.js +0 -53
- package/dist/json-snapshot-DFb2eWkf.js +0 -1416
- package/dist/json-snapshot-WWSGlaHG.cjs +0 -2
- package/dist/prepared-CFy9B75C.cjs +0 -1
- package/dist/prepared-ajM-H-9B.js +0 -69
- package/dist/record-bindings-By_UKZ2g.cjs +0 -1
- package/dist/render-plan-7xpGrCEl.cjs +0 -1
- package/dist/render-plan-Ck6koX9L.js +0 -13
- package/dist/sha256-ArEYjaTI.cjs +0 -1
- package/dist/sha256-DPEuJ3nh.js +0 -155
- package/dist/style-CQ1PK8ZB.js +0 -67
- package/dist/style-UgIJSA1F.cjs +0 -1
- package/dist/template-registry-Co1zPq5e.cjs +0 -1
- package/dist/textwrap-CWHyzkBH.cjs +0 -4
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
import { v as
|
|
2
|
-
import { v as
|
|
3
|
-
import { R as
|
|
4
|
-
import { c as
|
|
5
|
-
import { v as
|
|
6
|
-
import { v as
|
|
7
|
-
function
|
|
1
|
+
import { v as X } from "./matrix-CGRGkn5s.js";
|
|
2
|
+
import { v as Y, c as Q } from "./computed-C-4C2S5h.js";
|
|
3
|
+
import { c as j, r as Z, R as ee } from "./component-tree-Ca6YYfHq.js";
|
|
4
|
+
import { c as te } from "./code-options-BKXXY7NI.js";
|
|
5
|
+
import { v as ie, e as se } from "./param-validation-Do7Eg8Zv.js";
|
|
6
|
+
import { v as ne, a as oe } from "./tree-CjVZLRw7.js";
|
|
7
|
+
function ae(e, i, t) {
|
|
8
8
|
e !== void 0 && (typeof e != "string" || !e.trim() || e.length > 4096) && t.push({ path: i, message: "来源范围应为不超过 4096 字符的非空字符串" });
|
|
9
9
|
}
|
|
10
|
-
function
|
|
10
|
+
function D(e, i, t) {
|
|
11
11
|
e.editable !== void 0 && typeof e.editable != "boolean" && t.push({ path: `${i}.editable`, message: "编辑控制应为布尔值" }), e.valueType !== void 0 && !["text", "number", "boolean"].includes(e.valueType) && t.push({ path: `${i}.valueType`, message: "编辑类型应为 text、number 或 boolean" });
|
|
12
12
|
}
|
|
13
|
-
function
|
|
14
|
-
|
|
13
|
+
function fe(e, i, t) {
|
|
14
|
+
D(e, i, t), e.indentMm !== void 0 && (typeof e.indentMm != "number" || !Number.isFinite(e.indentMm) || e.indentMm < 0) && t.push({ path: `${i}.indentMm`, message: "单元格缩进应为有限非负数" }), e.derived !== void 0 && typeof e.derived != "boolean" && t.push({ path: `${i}.derived`, message: "派生结果标记应为布尔值" }), V(e.source, `${i}.source`, t, !0), e.formula !== void 0 && typeof e.formula != "string" && t.push({ path: `${i}.formula`, message: "单元格公式应为字符串" });
|
|
15
15
|
}
|
|
16
|
-
function
|
|
16
|
+
function V(e, i, t, s = !1) {
|
|
17
17
|
if (e === void 0) return;
|
|
18
18
|
if (!e || typeof e != "object" || Array.isArray(e)) {
|
|
19
19
|
t.push({ path: i, message: "业务来源应为对象" });
|
|
20
20
|
return;
|
|
21
21
|
}
|
|
22
22
|
const n = e;
|
|
23
|
-
|
|
24
|
-
for (const
|
|
25
|
-
(typeof n[
|
|
26
|
-
for (const
|
|
27
|
-
const
|
|
28
|
-
|
|
23
|
+
ae(n.sourceScope, `${i}.sourceScope`, t);
|
|
24
|
+
for (const o of ["datasetId", ...s ? ["field"] : []])
|
|
25
|
+
(typeof n[o] != "string" || !n[o].trim()) && t.push({ path: `${i}.${o}`, message: "业务标识应为非空字符串" });
|
|
26
|
+
for (const o of ["rowKey", "revision"]) {
|
|
27
|
+
const a = n[o];
|
|
28
|
+
a === void 0 && !(s && o === "rowKey") || typeof a != "string" && !(typeof a == "number" && Number.isFinite(a)) && t.push({ path: `${i}.${o}`, message: "业务键及修订号应为字符串或有限数字" });
|
|
29
29
|
}
|
|
30
30
|
n.sourceToken !== void 0 && typeof n.sourceToken != "string" && t.push({ path: `${i}.sourceToken`, message: "来源令牌应为字符串" });
|
|
31
31
|
}
|
|
32
|
-
const
|
|
32
|
+
const re = /* @__PURE__ */ new Set([
|
|
33
33
|
"text",
|
|
34
34
|
"image",
|
|
35
35
|
"barcode",
|
|
@@ -39,196 +39,261 @@ const ee = /* @__PURE__ */ new Set([
|
|
|
39
39
|
"rect",
|
|
40
40
|
"ellipse"
|
|
41
41
|
]);
|
|
42
|
-
function
|
|
42
|
+
function g(e) {
|
|
43
43
|
return typeof e == "object" && e !== null && !Array.isArray(e);
|
|
44
44
|
}
|
|
45
|
-
function
|
|
45
|
+
function E(e) {
|
|
46
|
+
return e === null ? "null" : typeof e == "string" ? JSON.stringify(e.slice(0, 120)) : ["number", "boolean", "undefined"].includes(typeof e) ? String(e) : `[${typeof e}]`;
|
|
47
|
+
}
|
|
48
|
+
function de(e, i, t, s) {
|
|
46
49
|
const n = e[i];
|
|
47
|
-
(typeof n != "number" || !Number.isFinite(n)) && s.push({ path: `${t}.${i}`, message: `应为有限数字,实际 ${
|
|
50
|
+
(typeof n != "number" || !Number.isFinite(n)) && s.push({ path: `${t}.${i}`, message: `应为有限数字,实际 ${E(n)}` });
|
|
48
51
|
}
|
|
49
|
-
function
|
|
52
|
+
function ue(e, i, t) {
|
|
50
53
|
if (e !== void 0) {
|
|
51
54
|
const s = `${i}.table`;
|
|
52
|
-
if (!
|
|
55
|
+
if (!g(e)) t.push({ path: s, message: "逻辑表来源应为对象" });
|
|
53
56
|
else {
|
|
54
|
-
|
|
57
|
+
V(e.source, `${s}.source`, t), (typeof e.id != "string" || !e.id.trim()) && t.push({ path: `${s}.id`, message: "逻辑表 ID 应为非空字符串" });
|
|
55
58
|
const n = e.role;
|
|
56
59
|
["header", "body", "group-header", "subtotal", "grand-total"].includes(n) || t.push({ path: `${s}.role`, message: "未知逻辑表行角色" });
|
|
57
|
-
const
|
|
58
|
-
(typeof
|
|
60
|
+
const o = e.rowIndex;
|
|
61
|
+
(typeof o != "number" || !Number.isInteger(o) || (n === "header" ? o !== -1 : o < 0)) && t.push({ path: `${s}.rowIndex`, message: "表头索引应为 -1,内容行索引应为非负整数" }), (!Array.isArray(e.columnKeys) || e.columnKeys.some((a) => typeof a != "string")) && t.push({ path: `${s}.columnKeys`, message: "逻辑列字段应为字符串数组" }), e.layout !== void 0 && e.layout !== "page" && e.layout !== "wide" && t.push({ path: `${s}.layout`, message: "布局应为 page 或 wide" }), e.title !== void 0 && typeof e.title != "string" && t.push({ path: `${s}.title`, message: "逻辑表名称应为字符串" });
|
|
59
62
|
}
|
|
60
63
|
}
|
|
61
64
|
}
|
|
62
|
-
function
|
|
65
|
+
function he(e, i, t, s) {
|
|
63
66
|
if (e !== void 0)
|
|
64
|
-
if (!
|
|
67
|
+
if (!g(e) || !Array.isArray(e.cells))
|
|
65
68
|
t.push({ path: `${i}.grid.cells`, message: "grid.cells 应为二维数组" });
|
|
66
69
|
else {
|
|
67
70
|
const n = e.paddingMm;
|
|
68
|
-
n !== void 0 && (typeof n != "number" || !Number.isFinite(n) || n < 0) && t.push({ path: `${i}.grid.paddingMm`, message: "单元格内距应为有限非负数" }), e.cells.forEach((
|
|
69
|
-
if (!Array.isArray(
|
|
70
|
-
t.push({ path: `${i}.grid.cells.${
|
|
71
|
+
n !== void 0 && (typeof n != "number" || !Number.isFinite(n) || n < 0) && t.push({ path: `${i}.grid.paddingMm`, message: "单元格内距应为有限非负数" }), e.cells.forEach((o, a) => {
|
|
72
|
+
if (!Array.isArray(o)) {
|
|
73
|
+
t.push({ path: `${i}.grid.cells.${a}`, message: "行应为数组" });
|
|
71
74
|
return;
|
|
72
75
|
}
|
|
73
|
-
|
|
76
|
+
o.forEach((f, r) => {
|
|
74
77
|
if (f == null) return;
|
|
75
|
-
const d = `${i}.grid.cells.${
|
|
76
|
-
if (!
|
|
78
|
+
const d = `${i}.grid.cells.${a}.${r}`;
|
|
79
|
+
if (!g(f)) {
|
|
77
80
|
t.push({ path: d, message: "网格单元格应为对象或 null" });
|
|
78
81
|
return;
|
|
79
82
|
}
|
|
80
|
-
|
|
81
|
-
|
|
83
|
+
fe(f, d, t), K(f.richParagraphs, d, t), Array.isArray(f.children) && f.children.forEach((u, p) => {
|
|
84
|
+
I(u, `${i}.grid.cells.${a}.${r}.children.${p}`, t, s);
|
|
82
85
|
});
|
|
83
86
|
});
|
|
84
87
|
});
|
|
85
88
|
}
|
|
86
89
|
}
|
|
87
|
-
function
|
|
88
|
-
e !== void 0 &&
|
|
89
|
-
|
|
90
|
-
|
|
90
|
+
function S(e, i, t, s) {
|
|
91
|
+
e !== void 0 && !i.includes(e) && s.push({ path: t, message: "未知富文本属性值" });
|
|
92
|
+
}
|
|
93
|
+
function F(e, i, t, s, n = 0) {
|
|
94
|
+
for (const o of i) {
|
|
95
|
+
const a = e[o];
|
|
96
|
+
a !== void 0 && (typeof a != "number" || !Number.isFinite(a) || a < n) && s.push({ path: `${t}.${o}`, message: "富文本数值应为范围内有限数字" });
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
function me(e, i, t) {
|
|
100
|
+
if (e !== void 0) {
|
|
101
|
+
if (!g(e)) {
|
|
102
|
+
t.push({ path: i, message: "富文本样式应为对象" });
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
for (const s of ["fontFamily", "color", "backgroundColor", "lineColor", "borderColor"])
|
|
106
|
+
e[s] !== void 0 && typeof e[s] != "string" && t.push({ path: `${i}.${s}`, message: "富文本样式应为字符串" });
|
|
107
|
+
for (const s of ["bold", "italic", "underline", "borderTop", "borderRight", "borderBottom", "borderLeft"])
|
|
108
|
+
e[s] !== void 0 && typeof e[s] != "boolean" && t.push({ path: `${i}.${s}`, message: "富文本样式应为布尔值" });
|
|
109
|
+
F(e, ["fontSize", "fontSizePx", "lineWidthPt", "lineHeight", "opacity"], i, t), F(e, ["letterSpacing", "rotateDeg"], i, t, -1 / 0), typeof e.opacity == "number" && e.opacity > 1 && t.push({ path: `${i}.opacity`, message: "透明度不能大于1" }), S(e.align, ["left", "center", "right", "justify"], `${i}.align`, t), S(e.verticalAlign, ["top", "middle", "bottom"], `${i}.verticalAlign`, t);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
function ce(e, i, t) {
|
|
113
|
+
if (!g(e)) {
|
|
114
|
+
t.push({ path: i, message: "富文本片段应为对象" });
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
S(e.kind, ["text", "field"], `${i}.kind`, t);
|
|
118
|
+
for (const s of ["text", "field"])
|
|
119
|
+
e[s] !== void 0 && typeof e[s] != "string" && t.push({ path: `${i}.${s}`, message: "富文本内容应为字符串" });
|
|
120
|
+
me(e.style, `${i}.style`, t);
|
|
121
|
+
}
|
|
122
|
+
function K(e, i, t) {
|
|
123
|
+
if (e !== void 0) {
|
|
124
|
+
if (!Array.isArray(e)) {
|
|
125
|
+
t.push({ path: `${i}.richParagraphs`, message: "richParagraphs 应为数组" });
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
e.forEach((s, n) => {
|
|
129
|
+
const o = `${i}.richParagraphs.${n}`;
|
|
130
|
+
if (!g(s) || !Array.isArray(s.segments)) {
|
|
131
|
+
t.push({ path: o, message: "段落缺少 segments 数组" });
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
S(s.align, ["left", "center", "right", "justify"], `${o}.align`, t), F(s, ["lineHeight", "spaceBeforeMm", "spaceAfterMm", "indentMm"], o, t), s.segments.forEach((a, f) => ce(a, `${o}.segments.${f}`, t));
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
function H(e, i, t, s = []) {
|
|
139
|
+
const n = j([e], i);
|
|
140
|
+
if (n) {
|
|
141
|
+
t.push(n);
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
I(e, i, t, s);
|
|
91
145
|
}
|
|
92
|
-
function
|
|
93
|
-
if (!
|
|
146
|
+
function I(e, i, t, s = []) {
|
|
147
|
+
if (!g(e)) {
|
|
94
148
|
t.push({ path: i, message: "组件应为对象" });
|
|
95
149
|
return;
|
|
96
150
|
}
|
|
97
151
|
const n = e.kind;
|
|
98
|
-
typeof n != "string" ? t.push({ path: `${i}.kind`, message: "组件缺少 kind 字符串" }) :
|
|
152
|
+
typeof n != "string" ? t.push({ path: `${i}.kind`, message: "组件缺少 kind 字符串" }) : re.has(n) || s.push({
|
|
99
153
|
path: `${i}.kind`,
|
|
100
|
-
message: `未知组件类型 ${
|
|
154
|
+
message: `未知组件类型 ${E(n)},将以兜底方式渲染`
|
|
101
155
|
});
|
|
102
|
-
for (const
|
|
103
|
-
|
|
156
|
+
for (const o of ["leftMm", "topMm", "widthMm", "heightMm"])
|
|
157
|
+
de(e, o, i, t);
|
|
104
158
|
typeof e.leftMm == "number" && e.leftMm < -100 && t.push({ path: `${i}.leftMm`, message: "几何数值异常(leftMm<-100)" });
|
|
105
|
-
for (const
|
|
106
|
-
typeof e[
|
|
107
|
-
|
|
159
|
+
for (const o of ["widthMm", "heightMm"])
|
|
160
|
+
typeof e[o] == "number" && e[o] < 0 && t.push({ path: `${i}.${o}`, message: "组件尺寸不能为负数" });
|
|
161
|
+
ue(e.table, i, t), ge(e.code, n, i, t), e.pageAnchor !== void 0 && !["header", "footer"].includes(e.pageAnchor) && t.push({ path: `${i}.pageAnchor`, message: "页面锚点应为 header 或 footer" }), e.lineDirection !== void 0 && !["down", "up"].includes(e.lineDirection) && t.push({ path: `${i}.lineDirection`, message: "线段方向应为 down 或 up" }), he(e.grid, i, t, s), K(e.richParagraphs, i, t);
|
|
108
162
|
}
|
|
109
|
-
function
|
|
163
|
+
function ge(e, i, t, s) {
|
|
110
164
|
if (e !== void 0)
|
|
111
|
-
for (const n of
|
|
165
|
+
for (const n of te(e, i)) s.push({ path: `${t}.code${n.path ? `.${n.path}` : ""}`, message: n.message });
|
|
112
166
|
}
|
|
113
|
-
function
|
|
114
|
-
if (!
|
|
167
|
+
function J(e, i, t) {
|
|
168
|
+
if (!g(e)) return;
|
|
115
169
|
e.binding !== void 0 && t.push({ path: `${i}.binding`, message: "渲染计划不允许未解析字段绑定" });
|
|
116
170
|
const s = e.grid;
|
|
117
|
-
!
|
|
118
|
-
Array.isArray(n) && n.forEach((
|
|
119
|
-
!
|
|
171
|
+
!g(s) || !Array.isArray(s.cells) || s.cells.forEach((n, o) => {
|
|
172
|
+
Array.isArray(n) && n.forEach((a, f) => {
|
|
173
|
+
!g(a) || !Array.isArray(a.children) || a.children.forEach((r, d) => J(r, `${i}.grid.cells.${o}.${f}.children.${d}`, t));
|
|
120
174
|
});
|
|
121
175
|
});
|
|
122
176
|
}
|
|
123
|
-
function
|
|
124
|
-
if (!
|
|
177
|
+
function pe(e, i, t, s = []) {
|
|
178
|
+
if (!g(e)) {
|
|
125
179
|
t.push({ path: i, message: "页应为对象" });
|
|
126
180
|
return;
|
|
127
181
|
}
|
|
128
|
-
const n = e.pageWidthMm,
|
|
129
|
-
(typeof n != "number" || !Number.isFinite(n) || n <= 0) && t.push({ path: `${i}.pageWidthMm`, message: `页宽非法: ${
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
182
|
+
const n = e.pageWidthMm, o = e.pageHeightMm;
|
|
183
|
+
(typeof n != "number" || !Number.isFinite(n) || n <= 0) && t.push({ path: `${i}.pageWidthMm`, message: `页宽非法: ${E(n)}` }), (typeof o != "number" || !(o > 0 && o < 5e3)) && t.push({ path: `${i}.pageHeightMm`, message: `页高非法: ${E(o)}` }), e.layout !== void 0 && e.layout !== "page" && e.layout !== "wide" && t.push({ path: `${i}.layout`, message: "布局应为 page 或 wide" });
|
|
184
|
+
const a = e.components;
|
|
185
|
+
if (!Array.isArray(a))
|
|
186
|
+
t.push({ path: `${i}.components`, message: "components 应为数组" });
|
|
187
|
+
else if (Array.isArray(a)) {
|
|
188
|
+
const f = j(a, `${i}.components`);
|
|
189
|
+
if (f) {
|
|
190
|
+
t.push(f);
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
a.forEach((r, d) => {
|
|
194
|
+
I(r, `${i}.components.${d}`, t, s), J(r, `${i}.components.${d}`, t);
|
|
195
|
+
});
|
|
196
|
+
}
|
|
134
197
|
}
|
|
135
|
-
function
|
|
136
|
-
const i = [], t = [], s =
|
|
137
|
-
if (
|
|
198
|
+
function ye(e) {
|
|
199
|
+
const i = [], t = [], s = g(e) ? e.pages : void 0;
|
|
200
|
+
if (g(e) && e.requiresRecalculation !== void 0 && typeof e.requiresRecalculation != "boolean" && i.push({ path: "$.requiresRecalculation", message: "重算能力要求应为布尔值" }), !Array.isArray(s))
|
|
138
201
|
i.push({
|
|
139
202
|
path: "$.pages",
|
|
140
203
|
message: e == null ? "渲染计划为空" : "渲染计划缺少 pages 数组"
|
|
141
204
|
});
|
|
142
205
|
else {
|
|
143
|
-
|
|
206
|
+
const n = Z(s);
|
|
207
|
+
if (n) return { ok: !1, errors: [...i, n], warnings: t };
|
|
208
|
+
s.forEach((a, f) => pe(a, `$.pages.${f}`, i, t)), s.length > 2e3 && t.push({
|
|
144
209
|
path: "$.pages",
|
|
145
210
|
message: `页数异常大(${s.length} 页),渲染与打印耗时可能显著增加`
|
|
146
211
|
});
|
|
147
|
-
const
|
|
148
|
-
(a,
|
|
212
|
+
const o = s.reduce(
|
|
213
|
+
(a, f) => a + (g(f) && Array.isArray(f.components) ? f.components.length : 0),
|
|
149
214
|
0
|
|
150
215
|
);
|
|
151
|
-
|
|
216
|
+
o > 5e4 && t.push({
|
|
152
217
|
path: "$.pages",
|
|
153
|
-
message: `组件总数异常大(${
|
|
218
|
+
message: `组件总数异常大(${o} 个),可能触发浏览器性能限制`
|
|
154
219
|
});
|
|
155
220
|
}
|
|
156
221
|
return { ok: i.length === 0, errors: i, warnings: t };
|
|
157
222
|
}
|
|
158
|
-
function
|
|
159
|
-
const i =
|
|
223
|
+
function Qe(e) {
|
|
224
|
+
const i = ye(e);
|
|
160
225
|
if (!i.ok) {
|
|
161
226
|
const t = i.errors.slice(0, 3).map((s) => `${s.path}: ${s.message}`).join("; ");
|
|
162
227
|
throw new Error(`渲染计划校验失败(${i.errors.length} 处): ${t}`);
|
|
163
228
|
}
|
|
164
229
|
return e.pages;
|
|
165
230
|
}
|
|
166
|
-
function
|
|
231
|
+
function O(e) {
|
|
167
232
|
return e.kind === "list" ? e.id : e.nid;
|
|
168
233
|
}
|
|
169
|
-
function
|
|
234
|
+
function le(e) {
|
|
170
235
|
return e.kind === "list" ? !1 : e.pageAnchor !== void 0 || e.kind === "text" && typeof e.text == "string" && /\{(?:page|totalPages)\}/.test(e.text);
|
|
171
236
|
}
|
|
172
|
-
function
|
|
173
|
-
const t = e.filter((n) => i.componentIds.includes(
|
|
237
|
+
function $e(e, i) {
|
|
238
|
+
const t = e.filter((n) => i.componentIds.includes(O(n) ?? ""));
|
|
174
239
|
if (t.filter((n) => n.kind === "list" && n.cardinality !== "record").length && t.length !== 1) throw new Error("纵向重复区域必须独占流式分段,不能与静态或单记录区域并排");
|
|
175
240
|
for (const n of t) {
|
|
176
|
-
const
|
|
177
|
-
if (n.topMm < i.topMm - 1e-3 ||
|
|
241
|
+
const o = n.kind === "list" ? n.topMm + (n.rowHeightMm ?? 0) : n.topMm + n.heightMm;
|
|
242
|
+
if (n.topMm < i.topMm - 1e-3 || o > i.topMm + i.heightMm + 1e-3) throw new Error("流式分段应完整包含其组件的原始纵向范围");
|
|
178
243
|
}
|
|
179
244
|
}
|
|
180
|
-
function
|
|
245
|
+
function Ze(e, i) {
|
|
181
246
|
if (!i) return e.map((s) => ({ components: [s] }));
|
|
182
|
-
const t = new Map(e.map((s) => [
|
|
247
|
+
const t = new Map(e.map((s) => [O(s), s]));
|
|
183
248
|
return i.bands.map((s) => ({ band: s, components: s.componentIds.map((n) => {
|
|
184
|
-
const
|
|
185
|
-
if (!
|
|
186
|
-
return
|
|
249
|
+
const o = t.get(n);
|
|
250
|
+
if (!o) throw new Error(`流式区域引用不存在的组件:${n}`);
|
|
251
|
+
return o;
|
|
187
252
|
}) }));
|
|
188
253
|
}
|
|
189
|
-
function
|
|
254
|
+
function be(e, i) {
|
|
190
255
|
if (!i || !Array.isArray(i.bands) || !i.bands.length || i.bands.length > 1e4) throw new Error("流式排版应包含 1–10000 个区域");
|
|
191
256
|
const t = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set();
|
|
192
257
|
for (const n of e) {
|
|
193
|
-
if (
|
|
194
|
-
const
|
|
195
|
-
if (!
|
|
196
|
-
t.add(
|
|
258
|
+
if (le(n)) continue;
|
|
259
|
+
const o = O(n);
|
|
260
|
+
if (!o || t.has(o)) throw new Error("流式排版组件应具有唯一标识");
|
|
261
|
+
t.add(o);
|
|
197
262
|
}
|
|
198
|
-
if (
|
|
263
|
+
if (Ae(e, i, t, s), s.size !== t.size) throw new Error("流式排版必须显式包含每个非锚点组件");
|
|
199
264
|
}
|
|
200
|
-
function
|
|
265
|
+
function Ae(e, i, t, s) {
|
|
201
266
|
let n = -1 / 0;
|
|
202
|
-
for (const
|
|
203
|
-
if (!Number.isFinite(
|
|
204
|
-
if (!Array.isArray(
|
|
205
|
-
for (const
|
|
206
|
-
if (!t.has(
|
|
207
|
-
s.add(
|
|
267
|
+
for (const o of i.bands) {
|
|
268
|
+
if (!Number.isFinite(o.topMm) || !Number.isFinite(o.heightMm) || o.topMm < 0 || o.heightMm <= 0 || o.topMm < n - 1e-3) throw new Error("流式区域应按原始位置排序,尺寸有效且不重叠");
|
|
269
|
+
if (!Array.isArray(o.componentIds) || !o.componentIds.length) throw new Error("流式区域不能没有组件");
|
|
270
|
+
for (const a of o.componentIds) {
|
|
271
|
+
if (!t.has(a) || s.has(a)) throw new Error(`流式区域组件缺失、重复或包含页锚点:${a}`);
|
|
272
|
+
s.add(a);
|
|
208
273
|
}
|
|
209
|
-
|
|
274
|
+
$e(e, o), n = o.topMm + o.heightMm;
|
|
210
275
|
}
|
|
211
276
|
}
|
|
212
|
-
const
|
|
277
|
+
const we = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]);
|
|
213
278
|
function l(e) {
|
|
214
279
|
return !!e && typeof e == "object" && !Array.isArray(e);
|
|
215
280
|
}
|
|
216
|
-
function
|
|
217
|
-
return typeof e == "string" && !!e.trim() && !
|
|
281
|
+
function N(e) {
|
|
282
|
+
return typeof e == "string" && !!e.trim() && !we.has(e);
|
|
218
283
|
}
|
|
219
|
-
function
|
|
284
|
+
function v(e, i, t, s) {
|
|
220
285
|
for (const n of Object.keys(e)) i.includes(n) || s.push({ path: `${t}.${n}`, message: "存在未知配置字段" });
|
|
221
286
|
}
|
|
222
|
-
function
|
|
287
|
+
function Me(e, i, t) {
|
|
223
288
|
if (e !== void 0) {
|
|
224
289
|
if (!l(e) || !["number", "percent", "date"].includes(String(e.kind))) {
|
|
225
290
|
t.push({ path: i, message: "绑定格式应为 number、percent 或 date" });
|
|
226
291
|
return;
|
|
227
292
|
}
|
|
228
|
-
|
|
293
|
+
v(e, e.kind === "date" ? ["kind", "pattern"] : e.kind === "number" ? ["kind", "digits", "thousands"] : ["kind", "digits"], i, t), e.digits !== void 0 && (!Number.isInteger(e.digits) || Number(e.digits) < 0 || Number(e.digits) > 100) && t.push({ path: `${i}.digits`, message: "精度应为 0..100 整数" }), e.thousands !== void 0 && typeof e.thousands != "boolean" && t.push({ path: `${i}.thousands`, message: "千分位开关应为布尔值" }), e.pattern !== void 0 && typeof e.pattern != "string" && t.push({ path: `${i}.pattern`, message: "日期格式应为字符串" });
|
|
229
294
|
}
|
|
230
295
|
}
|
|
231
|
-
function
|
|
296
|
+
function Ne(e, i, t) {
|
|
232
297
|
const s = e.binding;
|
|
233
298
|
if (s === void 0) return;
|
|
234
299
|
const n = `${i}.binding`;
|
|
@@ -236,48 +301,48 @@ function ge(e, i, t) {
|
|
|
236
301
|
t.push({ path: n, message: "字段绑定应为对象" });
|
|
237
302
|
return;
|
|
238
303
|
}
|
|
239
|
-
(!["text", "image", "barcode", "qrcode"].includes(String(e.kind)) || e.grid !== void 0) && t.push({ path: n, message: "绑定仅支持独立文本、图片、条码与二维码组件" }),
|
|
240
|
-
for (const
|
|
241
|
-
|
|
304
|
+
(!["text", "image", "barcode", "qrcode"].includes(String(e.kind)) || e.grid !== void 0) && t.push({ path: n, message: "绑定仅支持独立文本、图片、条码与二维码组件" }), v(s, ["field", "format", "prefix", "suffix", "emptyText"], n, t), N(s.field) || t.push({ path: `${n}.field`, message: "绑定字段应为安全的非空字段名(按字面读取自有字段)" });
|
|
305
|
+
for (const o of ["prefix", "suffix", "emptyText"]) s[o] !== void 0 && typeof s[o] != "string" && t.push({ path: `${n}.${o}`, message: "应为字符串" });
|
|
306
|
+
Me(s.format, `${n}.format`, t), e.kind === "image" && ["format", "prefix", "suffix"].some((o) => s[o] !== void 0) && t.push({ path: n, message: "图片绑定直接读取 PNG/JPEG data URL,不支持文本格式或前后缀" });
|
|
242
307
|
}
|
|
243
|
-
function
|
|
308
|
+
function ke(e, i) {
|
|
244
309
|
if (!l(e)) {
|
|
245
310
|
i.push({ path: "$.repeat", message: "逐记录配置应为对象" });
|
|
246
311
|
return;
|
|
247
312
|
}
|
|
248
|
-
|
|
313
|
+
v(e, ["dataset", "rowKey", "copies"], "$.repeat", i), N(e.dataset) || i.push({ path: "$.repeat.dataset", message: "数据集应为安全的非空名称" }), e.rowKey !== void 0 && !N(e.rowKey) && i.push({ path: "$.repeat.rowKey", message: "业务主键应为安全的非空字段名" });
|
|
249
314
|
const t = e.copies;
|
|
250
|
-
t !== void 0 && (l(t) ? (
|
|
315
|
+
t !== void 0 && (l(t) ? (v(t, ["field"], "$.repeat.copies", i), N(t.field) || i.push({ path: "$.repeat.copies.field", message: "复制数字段应为安全的非空字段名" })) : (!Number.isSafeInteger(t) || Number(t) < 1 || Number(t) > 1e3) && i.push({ path: "$.repeat.copies", message: "每条记录复制数应为 1..1000 整数" }));
|
|
251
316
|
}
|
|
252
|
-
function
|
|
317
|
+
function W(e, i, t, s) {
|
|
253
318
|
if (!l(e)) return;
|
|
254
|
-
|
|
319
|
+
Ne(e, i, s), e.binding !== void 0 && !t && s.push({ path: `${i}.binding`, message: "字段绑定需要模板 repeat 数据集;普通报表请使用列表字段" }), t && e.kind === "list" && s.push({ path: i, message: "逐记录标签使用固定组件;动态列表请使用普通报表模板" });
|
|
255
320
|
const n = e.grid;
|
|
256
|
-
l(n) && Array.isArray(n.cells) && n.cells.forEach((
|
|
257
|
-
Array.isArray(
|
|
258
|
-
l(f) && Array.isArray(f.children) && f.children.forEach((d,
|
|
321
|
+
l(n) && Array.isArray(n.cells) && n.cells.forEach((o, a) => {
|
|
322
|
+
Array.isArray(o) && o.forEach((f, r) => {
|
|
323
|
+
l(f) && Array.isArray(f.children) && f.children.forEach((d, u) => W(d, `${i}.grid.cells.${a}.${r}.children.${u}`, t, s));
|
|
259
324
|
});
|
|
260
325
|
});
|
|
261
326
|
}
|
|
262
|
-
function
|
|
327
|
+
function Ee(e, i) {
|
|
263
328
|
const t = e.repeat !== void 0;
|
|
264
|
-
t &&
|
|
329
|
+
t && ke(e.repeat, i), Array.isArray(e.pages) && e.pages.forEach((s, n) => {
|
|
265
330
|
if (!l(s)) return;
|
|
266
|
-
const
|
|
267
|
-
t && (s.layout === "wide" || s.flow !== void 0) && i.push({ path:
|
|
268
|
-
const r = `${
|
|
269
|
-
if (
|
|
270
|
-
const { leftMm: d, topMm:
|
|
271
|
-
[d,
|
|
331
|
+
const o = `$.pages.${n}`;
|
|
332
|
+
t && (s.layout === "wide" || s.flow !== void 0) && i.push({ path: o, message: "逐记录标签仅支持固定尺寸页面,不支持宽表或流式分区" }), Array.isArray(s.components) && s.components.forEach((a, f) => {
|
|
333
|
+
const r = `${o}.components.${f}`;
|
|
334
|
+
if (W(a, r, t, i), !t || !l(a)) return;
|
|
335
|
+
const { leftMm: d, topMm: u, widthMm: p, heightMm: y } = a;
|
|
336
|
+
[d, u, p, y, s.widthMm, s.heightMm].every((A) => typeof A == "number" && Number.isFinite(A)) && (Number(d) < 0 || Number(u) < 0 || Number(d) + Number(p) > Number(s.widthMm) + 1e-3 || Number(u) + Number(y) > Number(s.heightMm) + 1e-3) && i.push({ path: r, message: "标签组件超出纸张边界,请调整位置或尺寸" });
|
|
272
337
|
});
|
|
273
338
|
});
|
|
274
339
|
}
|
|
275
|
-
function
|
|
340
|
+
function G(e) {
|
|
276
341
|
return !!e && typeof e == "object" && !Array.isArray(e);
|
|
277
342
|
}
|
|
278
|
-
function
|
|
343
|
+
function T(e, i, t) {
|
|
279
344
|
if (e !== void 0) {
|
|
280
|
-
if (!
|
|
345
|
+
if (!G(e)) {
|
|
281
346
|
t.push({ path: i, message: "条件应为对象" });
|
|
282
347
|
return;
|
|
283
348
|
}
|
|
@@ -287,52 +352,52 @@ function O(e, i, t) {
|
|
|
287
352
|
});
|
|
288
353
|
}
|
|
289
354
|
}
|
|
290
|
-
function
|
|
355
|
+
function U(e, i, t) {
|
|
291
356
|
if (e === void 0) return;
|
|
292
357
|
if (!Array.isArray(e) || e.length > 2048) {
|
|
293
358
|
t.push({ path: i, message: "聚合应为数组且最多 2048 项" });
|
|
294
359
|
return;
|
|
295
360
|
}
|
|
296
361
|
const s = /* @__PURE__ */ new Set();
|
|
297
|
-
e.forEach((n,
|
|
298
|
-
const
|
|
299
|
-
if (!
|
|
300
|
-
t.push({ path:
|
|
362
|
+
e.forEach((n, o) => {
|
|
363
|
+
const a = `${i}.${o}`;
|
|
364
|
+
if (!G(n)) {
|
|
365
|
+
t.push({ path: a, message: "聚合应为对象" });
|
|
301
366
|
return;
|
|
302
367
|
}
|
|
303
368
|
const f = n.field;
|
|
304
369
|
typeof f != "string" || !f.trim() || s.has(f) ? t.push({
|
|
305
|
-
path: `${
|
|
370
|
+
path: `${a}.field`,
|
|
306
371
|
message: "聚合输出字段应非空且唯一"
|
|
307
372
|
}) : s.add(f), n.numeric !== void 0 && n.numeric !== "number" && n.numeric !== "decimal" && t.push({
|
|
308
|
-
path: `${
|
|
373
|
+
path: `${a}.numeric`,
|
|
309
374
|
message: "数值模式应为 number 或 decimal"
|
|
310
375
|
}), n.digits !== void 0 && (!Number.isInteger(n.digits) || Number(n.digits) < 0 || Number(n.digits) > 100) && t.push({
|
|
311
|
-
path: `${
|
|
376
|
+
path: `${a}.digits`,
|
|
312
377
|
message: "小数位应为 0–100 的整数"
|
|
313
378
|
});
|
|
314
379
|
try {
|
|
315
|
-
|
|
380
|
+
Q({
|
|
316
381
|
...n,
|
|
317
382
|
field: n.valueField ?? f
|
|
318
383
|
});
|
|
319
384
|
} catch (r) {
|
|
320
385
|
t.push({
|
|
321
|
-
path:
|
|
386
|
+
path: a,
|
|
322
387
|
message: r instanceof Error ? r.message : String(r)
|
|
323
388
|
});
|
|
324
389
|
}
|
|
325
390
|
});
|
|
326
391
|
}
|
|
327
|
-
function
|
|
392
|
+
function Se(e, i, t) {
|
|
328
393
|
if (e === void 0) return;
|
|
329
|
-
const s =
|
|
394
|
+
const s = Y(e);
|
|
330
395
|
for (const n of s.errors) t.push({ path: i, message: n });
|
|
331
396
|
}
|
|
332
|
-
function
|
|
397
|
+
function ve(e, i, t) {
|
|
333
398
|
if (e !== void 0)
|
|
334
399
|
try {
|
|
335
|
-
|
|
400
|
+
X(e);
|
|
336
401
|
} catch (s) {
|
|
337
402
|
t.push({
|
|
338
403
|
path: i,
|
|
@@ -340,65 +405,65 @@ function $e(e, i, t) {
|
|
|
340
405
|
});
|
|
341
406
|
}
|
|
342
407
|
}
|
|
343
|
-
function
|
|
408
|
+
function xe(e, i, t) {
|
|
344
409
|
if (e.tree === void 0) return;
|
|
345
410
|
const s = `${i}.tree`;
|
|
346
411
|
try {
|
|
347
|
-
|
|
412
|
+
ne(e.tree);
|
|
348
413
|
const n = e.tree;
|
|
349
414
|
if (e.matrix || e.detail || e.groupBy || Array.isArray(e.groups) && e.groups.length || e.rowVisibleWhen) throw new Error("树形布局不能同时配置普通分组、矩阵、主从或行可见条件");
|
|
350
415
|
if (e.rowKey !== void 0 && e.rowKey !== n.idField) throw new Error("树形 rowKey 应与 idField 一致");
|
|
351
|
-
if (!Array.isArray(e.columns) || !e.columns.some((
|
|
352
|
-
Array.isArray(e.computed) &&
|
|
416
|
+
if (!Array.isArray(e.columns) || !e.columns.some((o) => o && o.field === n.labelField && !o.hidden)) throw new Error("树形布局需要可见的标签列");
|
|
417
|
+
Array.isArray(e.computed) && oe(n, e.computed);
|
|
353
418
|
} catch (n) {
|
|
354
419
|
t.push({ path: s, message: n instanceof Error ? n.message : String(n) });
|
|
355
420
|
}
|
|
356
421
|
}
|
|
357
|
-
const
|
|
422
|
+
const B = "1.0";
|
|
358
423
|
class w extends Error {
|
|
359
424
|
constructor(i) {
|
|
360
425
|
super(`模板校验失败:${i.slice(0, 3).map((t) => `${t.path}: ${t.message}`).join("; ")}`), this.errors = i, this.name = "ReportTemplateError";
|
|
361
426
|
}
|
|
362
427
|
}
|
|
363
|
-
const
|
|
364
|
-
function
|
|
428
|
+
const Re = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]), Fe = /* @__PURE__ */ new Set(["schemaVersion", "id", "name", "revision", "description", "template"]), Te = /* @__PURE__ */ new Set(["left", "center", "right", "justify"]), k = 2e5, Ie = 64, P = 1e7;
|
|
429
|
+
function h(e) {
|
|
365
430
|
return !!e && typeof e == "object" && !Array.isArray(e);
|
|
366
431
|
}
|
|
367
|
-
function
|
|
432
|
+
function Oe(e, i, t) {
|
|
368
433
|
const s = Object.getPrototypeOf(e), n = Array.isArray(e);
|
|
369
434
|
if (n ? s !== Array.prototype : s !== Object.prototype && s !== null)
|
|
370
435
|
return t.push({ path: i, message: "模板对象必须使用普通 JSON 对象原型" }), !1;
|
|
371
436
|
if (n) {
|
|
372
|
-
const
|
|
373
|
-
if (
|
|
437
|
+
const o = Object.keys(e);
|
|
438
|
+
if (o.length !== e.length || o.some((a) => !/^(0|[1-9]\d*)$/.test(a) || Number(a) >= e.length))
|
|
374
439
|
return t.push({ path: i, message: "模板数组不能包含空位或额外属性" }), !1;
|
|
375
440
|
}
|
|
376
441
|
return Object.getOwnPropertySymbols(e).length > 0 ? (t.push({ path: i, message: "模板不能包含 Symbol 键" }), !1) : !0;
|
|
377
442
|
}
|
|
378
|
-
function
|
|
379
|
-
return
|
|
443
|
+
function Pe(e, i, t, s) {
|
|
444
|
+
return Re.has(e) ? (s.push({ path: t, message: "模板不能包含可能污染原型的键" }), !1) : i.get || i.set || !i.enumerable ? (s.push({ path: t, message: "模板不能包含访问器或不可枚举字段" }), !1) : !0;
|
|
380
445
|
}
|
|
381
|
-
function
|
|
446
|
+
function Le(e) {
|
|
382
447
|
return e === null || typeof e == "boolean" || typeof e == "number" && Number.isFinite(e);
|
|
383
448
|
}
|
|
384
|
-
function
|
|
449
|
+
function L(e, i) {
|
|
385
450
|
const t = /* @__PURE__ */ new Set();
|
|
386
|
-
let s = 0, n = 0,
|
|
387
|
-
const
|
|
388
|
-
if (!
|
|
389
|
-
if (++s >
|
|
390
|
-
s ===
|
|
451
|
+
let s = 0, n = 0, o = !1;
|
|
452
|
+
const a = (f, r, d) => {
|
|
453
|
+
if (!o) {
|
|
454
|
+
if (++s > k) {
|
|
455
|
+
s === k + 1 && i.push({ path: r, message: "模板超过 JSON 节点安全上限" });
|
|
391
456
|
return;
|
|
392
457
|
}
|
|
393
|
-
if (d >
|
|
458
|
+
if (d > Ie) {
|
|
394
459
|
i.push({ path: r, message: "模板嵌套层级过深" });
|
|
395
460
|
return;
|
|
396
461
|
}
|
|
397
462
|
if (typeof f == "string") {
|
|
398
|
-
n += f.length, n >
|
|
463
|
+
n += f.length, n > P && (o = !0, i.push({ path: r, message: "模板文本超过 1000 万字符的安全上限" }));
|
|
399
464
|
return;
|
|
400
465
|
}
|
|
401
|
-
if (!
|
|
466
|
+
if (!Le(f)) {
|
|
402
467
|
if (!f || typeof f != "object") {
|
|
403
468
|
i.push({ path: r, message: "模板只允许 JSON 值,不允许函数、undefined 或非有限数字" });
|
|
404
469
|
return;
|
|
@@ -407,37 +472,37 @@ function T(e, i) {
|
|
|
407
472
|
i.push({ path: r, message: "模板不能包含循环引用" });
|
|
408
473
|
return;
|
|
409
474
|
}
|
|
410
|
-
if (
|
|
475
|
+
if (Oe(f, r, i)) {
|
|
411
476
|
t.add(f);
|
|
412
|
-
for (const [
|
|
413
|
-
if (Array.isArray(f) &&
|
|
414
|
-
const y = `${r}.${
|
|
415
|
-
if (
|
|
477
|
+
for (const [u, p] of Object.entries(Object.getOwnPropertyDescriptors(f))) {
|
|
478
|
+
if (Array.isArray(f) && u === "length") continue;
|
|
479
|
+
const y = `${r}.${u}`;
|
|
480
|
+
if (Pe(u, p, y, i) && a(p.value, y, d + 1), s > k || o) break;
|
|
416
481
|
}
|
|
417
482
|
t.delete(f);
|
|
418
483
|
}
|
|
419
484
|
}
|
|
420
485
|
}
|
|
421
486
|
};
|
|
422
|
-
|
|
487
|
+
a(e, "$", 0);
|
|
423
488
|
}
|
|
424
489
|
function m(e, i, t, s, n = !1) {
|
|
425
|
-
const a = e[i];
|
|
426
|
-
a === void 0 && !n || (typeof a != "string" || n && !a.trim()) && s.push({ path: `${t}.${i}`, message: n ? "应为非空字符串" : "应为字符串" });
|
|
427
|
-
}
|
|
428
|
-
function c(e, i, t, s, n = 0, a = !1) {
|
|
429
490
|
const o = e[i];
|
|
430
|
-
o === void 0 && !
|
|
491
|
+
o === void 0 && !n || (typeof o != "string" || n && !o.trim()) && s.push({ path: `${t}.${i}`, message: n ? "应为非空字符串" : "应为字符串" });
|
|
492
|
+
}
|
|
493
|
+
function c(e, i, t, s, n = 0, o = !1) {
|
|
494
|
+
const a = e[i];
|
|
495
|
+
a === void 0 && !o || (typeof a != "number" || !Number.isFinite(a) || a < n) && s.push({ path: `${t}.${i}`, message: `应为大于等于 ${n} 的有限数字` });
|
|
431
496
|
}
|
|
432
497
|
function b(e, i, t, s) {
|
|
433
498
|
e[i] !== void 0 && typeof e[i] != "boolean" && s.push({ path: `${t}.${i}`, message: "应为布尔值" });
|
|
434
499
|
}
|
|
435
500
|
function M(e, i, t, s = !1) {
|
|
436
|
-
e !== void 0 && !
|
|
501
|
+
e !== void 0 && !Te.has(e) && !(s && e === "auto") && t.push({ path: i, message: `未知对齐方式${s ? "(支持 auto)" : ""}` });
|
|
437
502
|
}
|
|
438
503
|
function $(e, i, t) {
|
|
439
504
|
if (e !== void 0) {
|
|
440
|
-
if (!
|
|
505
|
+
if (!h(e)) {
|
|
441
506
|
t.push({ path: i, message: "样式应为对象" });
|
|
442
507
|
return;
|
|
443
508
|
}
|
|
@@ -449,237 +514,240 @@ function $(e, i, t) {
|
|
|
449
514
|
for (const s of ["fontFamily", "color", "backgroundColor", "lineColor", "borderColor"]) m(e, s, i, t);
|
|
450
515
|
}
|
|
451
516
|
}
|
|
452
|
-
function
|
|
517
|
+
function _e(e, i, t) {
|
|
453
518
|
if (e === void 0) return;
|
|
454
519
|
if (!Array.isArray(e)) {
|
|
455
520
|
t.push({ path: i, message: "参数定义应为数组" });
|
|
456
521
|
return;
|
|
457
522
|
}
|
|
458
523
|
const s = /* @__PURE__ */ new Set(), n = t.length;
|
|
459
|
-
e.forEach((
|
|
460
|
-
const f = `${i}.${
|
|
461
|
-
if (!
|
|
524
|
+
e.forEach((o, a) => {
|
|
525
|
+
const f = `${i}.${a}`;
|
|
526
|
+
if (!h(o)) {
|
|
462
527
|
t.push({ path: f, message: "参数定义应为对象" });
|
|
463
528
|
return;
|
|
464
529
|
}
|
|
465
|
-
m(
|
|
466
|
-
for (const r of ["label", "defaultValue", "placeholder"]) m(
|
|
467
|
-
b(
|
|
530
|
+
m(o, "field", f, t, !0), typeof o.field == "string" && (s.has(o.field) && t.push({ path: `${f}.field`, message: "参数名重复" }), s.add(o.field)), o.type !== void 0 && !["text", "number", "date", "month", "year", "dateRange", "select"].includes(o.type) && t.push({ path: `${f}.type`, message: "未知参数类型" });
|
|
531
|
+
for (const r of ["label", "defaultValue", "placeholder"]) m(o, r, f, t);
|
|
532
|
+
b(o, "required", f, t);
|
|
468
533
|
for (const r of ["minLength", "maxLength"]) {
|
|
469
|
-
const d =
|
|
534
|
+
const d = o[r];
|
|
470
535
|
d !== void 0 && (typeof d != "number" || !Number.isSafeInteger(d) || d < 0) && t.push({ path: `${f}.${r}`, message: "长度边界应为非负整数" });
|
|
471
536
|
}
|
|
472
|
-
|
|
473
|
-
const
|
|
474
|
-
if (!
|
|
537
|
+
Ce(o, f, t), o.options !== void 0 && (Array.isArray(o.options) ? o.options.forEach((r, d) => {
|
|
538
|
+
const u = `${f}.options.${d}`;
|
|
539
|
+
if (!h(r)) t.push({ path: u, message: "选项应为对象" });
|
|
475
540
|
else
|
|
476
|
-
for (const
|
|
541
|
+
for (const p of ["label", "value"]) typeof r[p] != "string" && t.push({ path: `${u}.${p}`, message: "选项标签与值应为字符串(允许空白选项)" });
|
|
477
542
|
}) : t.push({ path: `${f}.options`, message: "选项应为数组" }));
|
|
478
|
-
}), t.length === n && t.push(...
|
|
543
|
+
}), t.length === n && t.push(...ie(e).map((o) => ({ path: o.path.replace("$.paramDefs", i), message: o.message })));
|
|
479
544
|
}
|
|
480
|
-
function
|
|
481
|
-
for (const
|
|
482
|
-
const
|
|
483
|
-
if (
|
|
484
|
-
|
|
545
|
+
function Ce(e, i, t) {
|
|
546
|
+
for (const o of ["min", "max"]) {
|
|
547
|
+
const a = e[o];
|
|
548
|
+
if (a === void 0) continue;
|
|
549
|
+
se(e.type, a) || e.type === "number" && typeof a == "number" && Number.isFinite(a) || t.push({ path: `${i}.${o}`, message: "数字使用有限数字边界,日期/月/年使用对应规范字符串边界" });
|
|
485
550
|
}
|
|
486
551
|
const s = typeof e.min == "number" && typeof e.max == "number" && e.min > e.max, n = typeof e.min == "string" && typeof e.max == "string" && e.min > e.max;
|
|
487
552
|
(s || n) && t.push({ path: i, message: "最小边界不能大于最大边界" }), typeof e.minLength == "number" && typeof e.maxLength == "number" && e.minLength > e.maxLength && t.push({ path: i, message: "最小长度不能大于最大长度" });
|
|
488
553
|
}
|
|
489
|
-
function
|
|
554
|
+
function z(e, i, t) {
|
|
490
555
|
if (!Array.isArray(e) || e.length === 0) {
|
|
491
556
|
t.push({ path: i, message: "列表至少需要一列" });
|
|
492
557
|
return;
|
|
493
558
|
}
|
|
494
|
-
e.every((s) =>
|
|
495
|
-
const
|
|
496
|
-
if (!
|
|
497
|
-
t.push({ path:
|
|
559
|
+
e.every((s) => h(s) && s.hidden === !0) && t.push({ path: i, message: "列表至少需要一列可见列" }), e.forEach((s, n) => {
|
|
560
|
+
const o = `${i}.${n}`;
|
|
561
|
+
if (!h(s)) {
|
|
562
|
+
t.push({ path: o, message: "列应为对象" });
|
|
498
563
|
return;
|
|
499
564
|
}
|
|
500
|
-
if (
|
|
501
|
-
if (!
|
|
502
|
-
t.push({ path: `${
|
|
565
|
+
if (D(s, o, t), b(s, "hidden", o, t), T(s.visibleWhen, `${o}.visibleWhen`, t), typeof s.header != "string" && t.push({ path: `${o}.header`, message: "表头应为字符串(允许空白表头)" }), m(s, "field", o, t, !0), c(s, "widthMm", o, t, Number.MIN_VALUE, !0), $(s.style, `${o}.style`, t), $(s.headerStyle, `${o}.headerStyle`, t), M(s.align, `${o}.align`, t, !0), M(s.headerAlign, `${o}.headerAlign`, t), s.semanticRole !== void 0 && !["identifier", "dimension", "measure", "date", "text"].includes(s.semanticRole) && t.push({ path: `${o}.semanticRole`, message: "未知列语义" }), s.format !== void 0)
|
|
566
|
+
if (!h(s.format) || !["number", "percent", "date"].includes(s.format.kind))
|
|
567
|
+
t.push({ path: `${o}.format`, message: "未知列格式" });
|
|
503
568
|
else {
|
|
504
|
-
const
|
|
505
|
-
|
|
569
|
+
const a = s.format.digits;
|
|
570
|
+
a !== void 0 && (typeof a != "number" || !Number.isInteger(a) || a < 0 || a > 100) && t.push({ path: `${o}.format.digits`, message: "小数位应为 0–100 的整数" }), b(s.format, "thousands", `${o}.format`, t), m(s.format, "pattern", `${o}.format`, t);
|
|
506
571
|
}
|
|
507
|
-
s.rules !== void 0 && (Array.isArray(s.rules) ? s.rules.forEach((
|
|
508
|
-
const r = `${
|
|
509
|
-
if (!
|
|
572
|
+
s.rules !== void 0 && (Array.isArray(s.rules) ? s.rules.forEach((a, f) => {
|
|
573
|
+
const r = `${o}.rules.${f}`;
|
|
574
|
+
if (!h(a) || !h(a.when)) {
|
|
510
575
|
t.push({ path: r, message: "条件格式缺少 when 对象" });
|
|
511
576
|
return;
|
|
512
577
|
}
|
|
513
|
-
|
|
514
|
-
}) : t.push({ path: `${
|
|
578
|
+
T(a.when, `${r}.when`, t), m(a.when, "field", `${r}.when`, t, !0), [">", ">=", "<", "<=", "==", "!="].includes(a.when.op) || t.push({ path: `${r}.when.op`, message: "未知条件运算符" }), typeof a.when.value != "number" && typeof a.when.value != "string" && t.push({ path: `${r}.when.value`, message: "条件值应为数字或字符串" }), $(a.style, `${r}.style`, t);
|
|
579
|
+
}) : t.push({ path: `${o}.rules`, message: "条件格式应为数组" }));
|
|
515
580
|
});
|
|
516
581
|
}
|
|
517
|
-
function
|
|
582
|
+
function q(e, i, t) {
|
|
518
583
|
if (e !== void 0) {
|
|
519
|
-
if (!
|
|
584
|
+
if (!h(e)) {
|
|
520
585
|
t.push({ path: i, message: "分组应为对象" });
|
|
521
586
|
return;
|
|
522
587
|
}
|
|
523
588
|
m(e, "field", i, t, !0);
|
|
524
589
|
for (const s of ["headerTemplate", "subtotalLabel"]) m(e, s, i, t);
|
|
525
590
|
for (const s of ["headerStyle", "subtotalStyle"]) $(e[s], `${i}.${s}`, t);
|
|
526
|
-
b(e, "keepWithNext", i, t), b(e, "repeatHeader", i, t),
|
|
591
|
+
b(e, "keepWithNext", i, t), b(e, "repeatHeader", i, t), U(e.aggregates, `${i}.aggregates`, t), e.subtotal !== void 0 && (!Array.isArray(e.subtotal) || e.subtotal.some((s) => typeof s != "string")) && t.push({ path: `${i}.subtotal`, message: "小计字段应为字符串数组" });
|
|
527
592
|
}
|
|
528
593
|
}
|
|
529
|
-
function
|
|
594
|
+
function je(e, i, t) {
|
|
530
595
|
if (!(e === void 0 || typeof e == "boolean")) {
|
|
531
|
-
if (!
|
|
596
|
+
if (!h(e)) {
|
|
532
597
|
t.push({ path: i, message: "合计应为布尔值或对象" });
|
|
533
598
|
return;
|
|
534
599
|
}
|
|
535
|
-
m(e, "label", i, t),
|
|
600
|
+
m(e, "label", i, t), U(e.aggregates, `${i}.aggregates`, t), $(e.style, `${i}.style`, t), e.fields !== void 0 && (!Array.isArray(e.fields) || e.fields.some((s) => typeof s != "string")) && t.push({ path: `${i}.fields`, message: "合计字段应为字符串数组" });
|
|
536
601
|
}
|
|
537
602
|
}
|
|
538
|
-
function
|
|
603
|
+
function De(e, i, t, s) {
|
|
539
604
|
const n = { kind: "rect", leftMm: 0, topMm: 0, widthMm: 1, heightMm: 1, grid: e };
|
|
540
|
-
if (
|
|
541
|
-
const
|
|
542
|
-
if (
|
|
605
|
+
if (H(n, t, s, []), _(n, t, s), !h(e) || !Array.isArray(e.cells)) return;
|
|
606
|
+
const o = e.cells, a = Array.isArray(i) ? i.length : 0;
|
|
607
|
+
if (o.length * a > k) {
|
|
543
608
|
s.push({ path: t, message: "表头逻辑网格超过 20 万格安全上限" });
|
|
544
609
|
return;
|
|
545
610
|
}
|
|
546
|
-
e.cells.length || s.push({ path: `${t}.cells`, message: "表头至少需要一行" }), Array.isArray(e.colWidthsMm) && e.colWidthsMm.length !==
|
|
611
|
+
e.cells.length || s.push({ path: `${t}.cells`, message: "表头至少需要一行" }), Array.isArray(e.colWidthsMm) && e.colWidthsMm.length !== a && s.push({ path: `${t}.colWidthsMm`, message: "表头列宽数量应与列表列数一致" }), Array.isArray(e.rowHeightsMm) && e.rowHeightsMm.length !== e.cells.length && s.push({ path: `${t}.rowHeightsMm`, message: "表头行高数量应与行数一致" }), Ve(o, a, t, s);
|
|
547
612
|
}
|
|
548
|
-
function
|
|
613
|
+
function Ve(e, i, t, s) {
|
|
549
614
|
const n = /* @__PURE__ */ new Set();
|
|
550
|
-
e.forEach((
|
|
551
|
-
if (!Array.isArray(
|
|
615
|
+
e.forEach((o, a) => {
|
|
616
|
+
if (!Array.isArray(o)) return;
|
|
552
617
|
let f = 0;
|
|
553
|
-
|
|
554
|
-
for (; n.has(`${
|
|
555
|
-
const
|
|
556
|
-
(f +
|
|
557
|
-
for (let y =
|
|
558
|
-
for (let A = f; A < Math.min(i, f +
|
|
559
|
-
n.has(`${y}:${A}`) && s.push({ path: `${t}.cells.${
|
|
560
|
-
f +=
|
|
618
|
+
o.forEach((r, d) => {
|
|
619
|
+
for (; n.has(`${a}:${f}`); ) f++;
|
|
620
|
+
const u = h(r) && typeof r.colSpan == "number" ? r.colSpan : 1, p = h(r) && typeof r.rowSpan == "number" ? r.rowSpan : 1;
|
|
621
|
+
(f + u > i || a + p > e.length) && s.push({ path: `${t}.cells.${a}.${d}`, message: "表头合并区域超出表头边界" });
|
|
622
|
+
for (let y = a; y < Math.min(e.length, a + p); y++)
|
|
623
|
+
for (let A = f; A < Math.min(i, f + u); A++)
|
|
624
|
+
n.has(`${y}:${A}`) && s.push({ path: `${t}.cells.${a}.${d}`, message: "表头合并区域重叠" }), n.add(`${y}:${A}`);
|
|
625
|
+
f += u;
|
|
561
626
|
});
|
|
562
627
|
});
|
|
563
628
|
}
|
|
564
|
-
function
|
|
565
|
-
if (
|
|
629
|
+
function Ke(e, i, t) {
|
|
630
|
+
if (xe(e, i, t), Se(e.computed, `${i}.computed`, t), ve(e.matrix, `${i}.matrix`, t), e.matrix && (e.detail || e.groupBy || Array.isArray(e.groups) && e.groups.length || e.grandTotal) && t.push({ path: `${i}.matrix`, message: "矩阵请使用自身 totals 汇总,不能同时配置普通分组、总计或主从明细" }), T(e.rowVisibleWhen, `${i}.rowVisibleWhen`, t), e.groups !== void 0 && (!Array.isArray(e.groups) || e.groups.length > 16 ? t.push({ path: `${i}.groups`, message: "分组应为数组,最多 16 级" }) : e.groups.forEach((o, a) => q(o, `${i}.groups.${a}`, t))), e.detail === void 0) return;
|
|
566
631
|
const s = e.detail, n = `${i}.detail`;
|
|
567
|
-
if (!
|
|
632
|
+
if (!h(s)) {
|
|
568
633
|
t.push({ path: n, message: "主从关联应为对象" });
|
|
569
634
|
return;
|
|
570
635
|
}
|
|
571
|
-
for (const
|
|
572
|
-
for (const
|
|
573
|
-
m(s, "label", n, t), b(s, "header", n, t), c(s, "rowHeightMm", n, t, Number.MIN_VALUE),
|
|
636
|
+
for (const o of ["dataset", "parentKey", "foreignKey"]) m(s, o, n, t, !0);
|
|
637
|
+
for (const o of ["rowKey", "revisionField", "sourceTokenField"]) m(s, o, n, t, s[o] !== void 0);
|
|
638
|
+
m(s, "label", n, t), b(s, "header", n, t), c(s, "rowHeightMm", n, t, Number.MIN_VALUE), z(s.columns, `${n}.columns`, t), s.unmatched !== void 0 && s.unmatched !== "error" && s.unmatched !== "ignore" && t.push({ path: `${n}.unmatched`, message: "未关联明细策略应为 error 或 ignore" });
|
|
574
639
|
}
|
|
575
|
-
function
|
|
640
|
+
function He(e, i, t) {
|
|
576
641
|
for (const s of ["leftMm", "topMm"]) c(e, s, i, t, -1 / 0, !0);
|
|
577
642
|
c(e, "widthMm", i, t, Number.MIN_VALUE, !0), m(e, "dataset", i, t, !0), m(e, "title", i, t);
|
|
578
643
|
for (const s of ["rowKey", "revisionField", "sourceTokenField"]) m(e, s, i, t, e[s] !== void 0);
|
|
579
|
-
e.headerGrid !== void 0 &&
|
|
644
|
+
e.headerGrid !== void 0 && De(e.headerGrid, e.columns, `${i}.headerGrid`, t), e.layout !== void 0 && e.layout !== "page" && e.layout !== "wide" && t.push({ path: `${i}.layout`, message: "布局应为 page 或 wide" }), z(e.columns, `${i}.columns`, t);
|
|
580
645
|
for (const s of ["fontSizePt", "rowHeightMm"]) c(e, s, i, t, Number.MIN_VALUE);
|
|
581
646
|
c(e, "paddingMm", i, t);
|
|
582
647
|
for (const s of ["header", "headerBold", "headerEveryPage", "border"]) b(e, s, i, t);
|
|
583
|
-
e.cardinality !== void 0 && e.cardinality !== "record" && t.push({ path: `${i}.cardinality`, message: "单记录区域类型应为 record" }), m(e, "headerBackgroundColor", i, t), M(e.align, `${i}.align`, t, !0), M(e.headerAlign, `${i}.headerAlign`, t), $(e.headerStyle, `${i}.headerStyle`, t),
|
|
584
|
-
}
|
|
585
|
-
function
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
const
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
if (!u(f)) {
|
|
596
|
-
t.push({ path: d, message: "富文本片段应为对象" });
|
|
648
|
+
e.cardinality !== void 0 && e.cardinality !== "record" && t.push({ path: `${i}.cardinality`, message: "单记录区域类型应为 record" }), m(e, "headerBackgroundColor", i, t), M(e.align, `${i}.align`, t, !0), M(e.headerAlign, `${i}.headerAlign`, t), $(e.headerStyle, `${i}.headerStyle`, t), Ke(e, i, t), q(e.groupBy, `${i}.groupBy`, t), je(e.grandTotal, `${i}.grandTotal`, t);
|
|
649
|
+
}
|
|
650
|
+
function C(e, i, t) {
|
|
651
|
+
Array.isArray(e.richParagraphs) && e.richParagraphs.forEach((s, n) => {
|
|
652
|
+
if (!h(s)) return;
|
|
653
|
+
const o = `${i}.richParagraphs.${n}`;
|
|
654
|
+
M(s.align, `${o}.align`, t);
|
|
655
|
+
for (const a of ["lineHeight", "spaceBeforeMm", "spaceAfterMm", "indentMm"]) c(s, a, o, t);
|
|
656
|
+
Array.isArray(s.segments) && s.segments.forEach((a, f) => {
|
|
657
|
+
const r = `${o}.segments.${f}`;
|
|
658
|
+
if (!h(a)) {
|
|
659
|
+
t.push({ path: r, message: "富文本片段应为对象" });
|
|
597
660
|
return;
|
|
598
661
|
}
|
|
599
|
-
|
|
600
|
-
for (const
|
|
601
|
-
$(
|
|
662
|
+
a.kind !== void 0 && a.kind !== "text" && a.kind !== "field" && t.push({ path: `${r}.kind`, message: "未知富文本片段类型" });
|
|
663
|
+
for (const d of ["text", "field"]) m(a, d, r, t);
|
|
664
|
+
$(a.style, `${r}.style`, t);
|
|
602
665
|
});
|
|
603
|
-
})
|
|
666
|
+
});
|
|
667
|
+
}
|
|
668
|
+
function _(e, i, t) {
|
|
669
|
+
$(e.style, `${i}.style`, t);
|
|
670
|
+
for (const n of ["text", "rawText", "imageData", "fallbackText", "nid", "rkey"]) m(e, n, i, t);
|
|
671
|
+
if (e.lines !== void 0 && (!Array.isArray(e.lines) || e.lines.some((n) => typeof n != "string")) && t.push({ path: `${i}.lines`, message: "文本行应为字符串数组" }), C(e, i, t), !h(e.grid)) return;
|
|
604
672
|
const s = e.grid;
|
|
605
673
|
c(s, "gapMm", `${i}.grid`, t), c(s, "paddingMm", `${i}.grid`, t);
|
|
606
674
|
for (const n of ["colWidthsMm", "rowHeightsMm"]) {
|
|
607
|
-
const
|
|
608
|
-
|
|
609
|
-
}
|
|
610
|
-
Array.isArray(s.cells) && s.cells.forEach((n,
|
|
611
|
-
Array.isArray(n) && n.forEach((
|
|
612
|
-
const r = `${i}.grid.cells.${
|
|
613
|
-
if (
|
|
614
|
-
if (!
|
|
675
|
+
const o = s[n];
|
|
676
|
+
o !== void 0 && (!Array.isArray(o) || o.some((a) => typeof a != "number" || !Number.isFinite(a) || a < 0)) && t.push({ path: `${i}.grid.${n}`, message: "网格尺寸应为有限非负数字数组" });
|
|
677
|
+
}
|
|
678
|
+
Array.isArray(s.cells) && s.cells.forEach((n, o) => {
|
|
679
|
+
Array.isArray(n) && n.forEach((a, f) => {
|
|
680
|
+
const r = `${i}.grid.cells.${o}.${f}`;
|
|
681
|
+
if (a !== null) {
|
|
682
|
+
if (!h(a)) {
|
|
615
683
|
t.push({ path: r, message: "网格单元格应为对象或 null" });
|
|
616
684
|
return;
|
|
617
685
|
}
|
|
618
|
-
for (const d of ["text", "rawText", "numberFormat"]) m(
|
|
686
|
+
for (const d of ["text", "rawText", "numberFormat"]) m(a, d, r, t);
|
|
619
687
|
for (const d of ["colSpan", "rowSpan"]) {
|
|
620
|
-
const
|
|
621
|
-
|
|
688
|
+
const u = a[d];
|
|
689
|
+
u !== void 0 && (typeof u != "number" || !Number.isInteger(u) || u <= 0) && t.push({ path: `${r}.${d}`, message: "跨度应为正整数" });
|
|
622
690
|
}
|
|
623
|
-
|
|
624
|
-
|
|
691
|
+
a.value !== void 0 && a.value !== null && !["string", "number", "boolean"].includes(typeof a.value) && t.push({ path: `${r}.value`, message: "Excel 原始值应为字符串、数字、布尔值或 null" }), $(a.style, `${r}.style`, t), C(a, r, t), a.children !== void 0 && (Array.isArray(a.children) ? a.children.forEach((d, u) => {
|
|
692
|
+
h(d) && _(d, `${r}.children.${u}`, t);
|
|
625
693
|
}) : t.push({ path: `${r}.children`, message: "嵌套组件应为数组" }));
|
|
626
694
|
}
|
|
627
695
|
});
|
|
628
696
|
});
|
|
629
697
|
}
|
|
630
|
-
function
|
|
698
|
+
function Je(e, i, t) {
|
|
631
699
|
if (!(e.flow === void 0 || !Array.isArray(e.components)))
|
|
632
700
|
try {
|
|
633
|
-
|
|
701
|
+
be(e.components, e.flow);
|
|
634
702
|
} catch (s) {
|
|
635
703
|
t.push({ path: `${i}.flow`, message: s instanceof Error ? s.message : String(s) });
|
|
636
704
|
}
|
|
637
705
|
}
|
|
638
|
-
function
|
|
706
|
+
function We(e) {
|
|
639
707
|
const i = [], t = [];
|
|
640
|
-
return
|
|
641
|
-
const
|
|
642
|
-
if (!
|
|
643
|
-
i.push({ path:
|
|
708
|
+
return L(e, i), i.length ? { ok: !1, errors: i, warnings: t } : (h(e) ? (e.schemaVersion !== void 0 && e.schemaVersion !== ee && i.push({ path: "$.schemaVersion", message: "不支持的模板 schemaVersion" }), _e(e.params, "$.params", i), Ee(e, i), !Array.isArray(e.pages) || e.pages.length === 0 ? i.push({ path: "$.pages", message: "模板至少需要一页" }) : e.pages.forEach((s, n) => {
|
|
709
|
+
const o = `$.pages.${n}`;
|
|
710
|
+
if (!h(s)) {
|
|
711
|
+
i.push({ path: o, message: "页应为对象" });
|
|
644
712
|
return;
|
|
645
713
|
}
|
|
646
|
-
c(s, "widthMm",
|
|
647
|
-
for (const
|
|
648
|
-
typeof s.widthMm == "number" && Number(s.marginLeftMm ?? 0) + Number(s.marginRightMm ?? 0) >= s.widthMm && i.push({ path:
|
|
649
|
-
const r = `${
|
|
650
|
-
|
|
651
|
-
}) : i.push({ path: `${
|
|
714
|
+
c(s, "widthMm", o, i, Number.MIN_VALUE, !0), c(s, "heightMm", o, i, Number.MIN_VALUE, !0), s.layout !== void 0 && s.layout !== "page" && s.layout !== "wide" && i.push({ path: `${o}.layout`, message: "布局应为 page 或 wide" }), typeof s.heightMm == "number" && s.heightMm >= 5e3 && i.push({ path: `${o}.heightMm`, message: "页高应小于 5000mm" });
|
|
715
|
+
for (const a of ["marginTopMm", "marginBottomMm", "marginLeftMm", "marginRightMm"]) c(s, a, o, i);
|
|
716
|
+
typeof s.widthMm == "number" && Number(s.marginLeftMm ?? 0) + Number(s.marginRightMm ?? 0) >= s.widthMm && i.push({ path: o, message: "横向页边距占满页面" }), typeof s.heightMm == "number" && Number(s.marginTopMm ?? 0) + Number(s.marginBottomMm ?? 0) >= s.heightMm && i.push({ path: o, message: "纵向页边距占满页面" }), Array.isArray(s.components) ? s.components.forEach((a, f) => {
|
|
717
|
+
const r = `${o}.components.${f}`;
|
|
718
|
+
h(a) && a.kind === "list" ? He(a, r, i) : (H(a, r, i, t), h(a) && _(a, r, i));
|
|
719
|
+
}) : i.push({ path: `${o}.components`, message: "组件应为数组" }), Je(s, o, i);
|
|
652
720
|
})) : i.push({ path: "$", message: "模板应为对象" }), { ok: i.length === 0, errors: i, warnings: t });
|
|
653
721
|
}
|
|
654
|
-
function
|
|
722
|
+
function Ge(e) {
|
|
655
723
|
const i = [], t = [];
|
|
656
|
-
if (
|
|
657
|
-
if (!
|
|
724
|
+
if (L(e, i), i.length) return { ok: !1, errors: i, warnings: t };
|
|
725
|
+
if (!h(e)) i.push({ path: "$", message: "模板文档应为对象" });
|
|
658
726
|
else {
|
|
659
727
|
for (const n of Object.keys(e))
|
|
660
|
-
|
|
661
|
-
e.schemaVersion !==
|
|
728
|
+
Fe.has(n) || i.push({ path: `$.${n}`, message: "模板文档存在未知字段;只保存模板与描述,不保存取数或业务数据" });
|
|
729
|
+
e.schemaVersion !== B && i.push({ path: "$.schemaVersion", message: "不支持的模板文档版本" });
|
|
662
730
|
for (const n of ["id", "name"]) m(e, n, "$", i, !0);
|
|
663
731
|
for (const n of ["revision", "description"]) m(e, n, "$", i);
|
|
664
|
-
const s =
|
|
732
|
+
const s = We(e.template);
|
|
665
733
|
i.push(...s.errors.map((n) => ({ ...n, path: `$.template${n.path.slice(1)}` }))), t.push(...s.warnings.map((n) => ({ ...n, path: `$.template${n.path.slice(1)}` })));
|
|
666
734
|
}
|
|
667
735
|
return { ok: i.length === 0, errors: i, warnings: t };
|
|
668
736
|
}
|
|
669
|
-
function
|
|
670
|
-
const i =
|
|
737
|
+
function R(e) {
|
|
738
|
+
const i = Ge(e);
|
|
671
739
|
if (!i.ok) throw new w(i.errors);
|
|
672
740
|
}
|
|
673
|
-
function
|
|
741
|
+
function et(e) {
|
|
674
742
|
const i = [];
|
|
675
|
-
if (
|
|
676
|
-
const t = { ...e, schemaVersion: e.schemaVersion ??
|
|
677
|
-
return
|
|
743
|
+
if (L(e, i), i.length) throw new w(i);
|
|
744
|
+
const t = { ...e, schemaVersion: e.schemaVersion ?? B };
|
|
745
|
+
return R(t), x(t);
|
|
678
746
|
}
|
|
679
|
-
function
|
|
747
|
+
function tt(e) {
|
|
680
748
|
let i = e;
|
|
681
749
|
if (typeof e == "string") {
|
|
682
|
-
if (e.length >
|
|
750
|
+
if (e.length > P)
|
|
683
751
|
throw new w([{ path: "$", message: "模板 JSON 超过 1000 万字符的导出/导入上限" }]);
|
|
684
752
|
try {
|
|
685
753
|
i = JSON.parse(e);
|
|
@@ -687,27 +755,27 @@ function Ue(e) {
|
|
|
687
755
|
throw new w([{ path: "$", message: "模板 JSON 语法无效" }]);
|
|
688
756
|
}
|
|
689
757
|
}
|
|
690
|
-
return
|
|
758
|
+
return R(i), x(i);
|
|
691
759
|
}
|
|
692
|
-
function
|
|
693
|
-
|
|
760
|
+
function it(e) {
|
|
761
|
+
R(e);
|
|
694
762
|
const i = JSON.stringify(e, null, 2);
|
|
695
|
-
if (i.length >
|
|
763
|
+
if (i.length > P) throw new w([{ path: "$", message: "模板 JSON 超过 1000 万字符的导出/导入上限" }]);
|
|
696
764
|
return i;
|
|
697
765
|
}
|
|
698
|
-
function
|
|
766
|
+
function x(e) {
|
|
699
767
|
return JSON.parse(JSON.stringify(e));
|
|
700
768
|
}
|
|
701
|
-
function
|
|
769
|
+
function st(e = []) {
|
|
702
770
|
const i = /* @__PURE__ */ new Map(), t = {
|
|
703
771
|
get: (s) => {
|
|
704
772
|
const n = i.get(s);
|
|
705
|
-
return n ?
|
|
773
|
+
return n ? x(n) : void 0;
|
|
706
774
|
},
|
|
707
775
|
list: () => Array.from(i.values(), ({ template: s, ...n }) => ({ ...n })),
|
|
708
776
|
register: (s, n = {}) => {
|
|
709
|
-
if (
|
|
710
|
-
i.set(s.id,
|
|
777
|
+
if (R(s), i.has(s.id) && !n.replace) throw new w([{ path: "$.id", message: `模板 ID ${s.id} 已注册;更新需显式 replace:true` }]);
|
|
778
|
+
i.set(s.id, x(s));
|
|
711
779
|
},
|
|
712
780
|
remove: (s) => i.delete(s)
|
|
713
781
|
};
|
|
@@ -716,18 +784,18 @@ function ze(e = []) {
|
|
|
716
784
|
}
|
|
717
785
|
export {
|
|
718
786
|
w as R,
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
787
|
+
ye as a,
|
|
788
|
+
B as b,
|
|
789
|
+
Qe as c,
|
|
790
|
+
st as d,
|
|
791
|
+
et as e,
|
|
792
|
+
H as f,
|
|
793
|
+
pe as g,
|
|
794
|
+
Ge as h,
|
|
795
|
+
be as i,
|
|
796
|
+
Ee as j,
|
|
797
|
+
tt as p,
|
|
798
|
+
Ze as r,
|
|
799
|
+
it as s,
|
|
800
|
+
We as v
|
|
733
801
|
};
|