@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,1416 +0,0 @@
|
|
|
1
|
-
import { R as z } from "./render-plan-Ck6koX9L.js";
|
|
2
|
-
import { c as mt, D as Pe, L as Te } from "./defaults-DXhiM1ZD.js";
|
|
3
|
-
import { w as q, h as ke } from "./textwrap-DE1kgcJB.js";
|
|
4
|
-
import { R as C, g as $e, b as gt, i as ht, e as L, l as ce, c as pt, t as Re, h as Ee, f as xe, j as wt, k as yt } from "./record-bindings-Do_b3h4V.js";
|
|
5
|
-
import { e as Ce, b as bt } from "./computed-C-4C2S5h.js";
|
|
6
|
-
import { e as Mt, c as vt } from "./matrix-CGRGkn5s.js";
|
|
7
|
-
import { f as Oe, a as St, c as Pt } from "./tree-CjVZLRw7.js";
|
|
8
|
-
import { i as Tt, r as kt, j as $t, a as Fe, v as Rt, R as Et } from "./template-registry-BtaKPELV.js";
|
|
9
|
-
import { r as de, b as xt, e as I } from "./style-CQ1PK8ZB.js";
|
|
10
|
-
import { g as Ct } from "./report-params-B1RzkhJj.js";
|
|
11
|
-
import { a as ye } from "./param-validation-Do7Eg8Zv.js";
|
|
12
|
-
import { R as P, r as j, e as le, h as Ae, f as Ot, i as Ft } from "./batch-CGyt-b2W.js";
|
|
13
|
-
import { h as At } from "./data-explanation-B8MZRYVS.js";
|
|
14
|
-
import { d as It, v as jt } from "./dataset-H5pFuQGU.js";
|
|
15
|
-
function Nt(e, t, r) {
|
|
16
|
-
const o = /* @__PURE__ */ new Set(), a = e.cells.map((n, s) => {
|
|
17
|
-
const i = [];
|
|
18
|
-
let c = 0;
|
|
19
|
-
for (const d of n) {
|
|
20
|
-
for (; o.has(`${s}:${c}`); ) c++;
|
|
21
|
-
const l = d?.colSpan ?? 1, f = d?.rowSpan ?? 1;
|
|
22
|
-
let u = 0;
|
|
23
|
-
for (let g = c; g < c + l; g++) {
|
|
24
|
-
t.has(g) && u++;
|
|
25
|
-
for (let h = s + 1; h < s + f; h++)
|
|
26
|
-
o.add(`${h}:${g}`);
|
|
27
|
-
}
|
|
28
|
-
u && i.push(d ? { ...d, colSpan: u } : null), c += l;
|
|
29
|
-
}
|
|
30
|
-
return i;
|
|
31
|
-
});
|
|
32
|
-
return { ...e, cells: a, colWidthsMm: r };
|
|
33
|
-
}
|
|
34
|
-
function Ht(e) {
|
|
35
|
-
if (!e.columns.some((o) => o.hidden)) return e;
|
|
36
|
-
const t = /* @__PURE__ */ new Set(), r = e.columns.filter((o, a) => o.hidden ? !1 : (t.add(a), !0));
|
|
37
|
-
if (!r.length) throw new Error("列表至少需要一列可见列");
|
|
38
|
-
return {
|
|
39
|
-
...e,
|
|
40
|
-
columns: r,
|
|
41
|
-
...e.headerGrid ? {
|
|
42
|
-
headerGrid: Nt(
|
|
43
|
-
e.headerGrid,
|
|
44
|
-
t,
|
|
45
|
-
r.map((o) => o.widthMm)
|
|
46
|
-
)
|
|
47
|
-
} : {}
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
function* Lt(e) {
|
|
51
|
-
const { page: t } = e;
|
|
52
|
-
Tt(t.components, t.flow);
|
|
53
|
-
let r = 0, o = 0;
|
|
54
|
-
for (const a of kt(t.components, t.flow)) {
|
|
55
|
-
e.active();
|
|
56
|
-
const n = a.band, s = a.components.some((l) => l.kind === "list" && l.cardinality !== "record"), i = s ? 0 : a.components.reduce((l, f) => Math.max(l, f.topMm - n.topMm + (f.kind === "list" ? e.height(f) : f.heightMm)), n.heightMm);
|
|
57
|
-
let c = Math.max(e.top(), o + n.topMm - r);
|
|
58
|
-
if (!s && i > e.bottom() - e.top() + 1e-3) throw new Error(`静态区域 ${n.componentIds.join(",")} 高度超出单页可用范围`);
|
|
59
|
-
!s && c + i > e.bottom() + 1e-3 && (e.nextPage(), yield* e.takePages(), e.active(), c = e.top());
|
|
60
|
-
let d = c + i;
|
|
61
|
-
for (const l of a.components) {
|
|
62
|
-
const f = c + l.topMm - n.topMm;
|
|
63
|
-
l.kind === "list" ? (yield* e.list(l, f, (u) => {
|
|
64
|
-
d = s ? u : Math.max(d, u);
|
|
65
|
-
}), e.active()) : e.append({ ...l, topMm: f });
|
|
66
|
-
}
|
|
67
|
-
o = d, r = n.topMm + n.heightMm;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
function Dt(e) {
|
|
71
|
-
return !!(e.computed?.length || e.groups?.length || e.groupBy || e.grandTotal || e.rowVisibleWhen || e.matrix || e.tree || e.detail || e.columns.some((t) => t.rules?.length || t.visibleWhen));
|
|
72
|
-
}
|
|
73
|
-
function U(e) {
|
|
74
|
-
return e.pages.some((t) => t.components.some((r) => r.kind === "list" && Dt(r)));
|
|
75
|
-
}
|
|
76
|
-
const Kt = 512, be = 256 * 1024;
|
|
77
|
-
function Bt() {
|
|
78
|
-
const e = /* @__PURE__ */ new Map();
|
|
79
|
-
let t = 0, r;
|
|
80
|
-
return (o, a, n, s) => {
|
|
81
|
-
s !== r && (e.clear(), t = 0, r = s);
|
|
82
|
-
const i = JSON.stringify([o, a, n.fontSizePt, n.fontFamily, n.bold, n.italic, n.letterSpacingPt]), c = e.get(i);
|
|
83
|
-
if (c)
|
|
84
|
-
return e.delete(i), e.set(i, c), c.lines.slice();
|
|
85
|
-
const d = q(o, a, n, s), l = i.length + d.reduce((f, u) => f + u.length, 0);
|
|
86
|
-
if (l <= be) {
|
|
87
|
-
for (; e.size >= Kt || t + l > be; ) {
|
|
88
|
-
const f = e.keys().next().value;
|
|
89
|
-
t -= e.get(f).units, e.delete(f);
|
|
90
|
-
}
|
|
91
|
-
e.set(i, { lines: d.slice(), units: l }), t += l;
|
|
92
|
-
}
|
|
93
|
-
return d;
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
class N extends Error {
|
|
97
|
-
constructor(t, r) {
|
|
98
|
-
super(`报表页数超出上限 ${t}(至少 ${r} 页)`), this.limit = t, this.actual = r, this.code = "page-limit", this.name = "PaginatePageLimitError";
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
class D extends Error {
|
|
102
|
-
constructor(t, r) {
|
|
103
|
-
super(`报表单元格数量超出上限 ${t}(至少 ${r} 格)`), this.limit = t, this.actual = r, this.code = "cell-limit", this.name = "PaginateCellLimitError";
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
const Wt = 1e4, Me = 25e4;
|
|
107
|
-
function ue(e) {
|
|
108
|
-
if (e?.aborted) throw e.reason ?? new DOMException("标签生成已取消", "AbortError");
|
|
109
|
-
}
|
|
110
|
-
function Ie(e, t, r) {
|
|
111
|
-
const o = typeof e.copies == "object" ? $e(t, e.copies.field, r) : e.copies ?? 1;
|
|
112
|
-
if (typeof o != "number" || !Number.isSafeInteger(o) || o < 1 || o > 1e3) throw new C(`$.datasets.${r.dataset}[${r.rowIndex}]`, "每条记录复制数必须是 1..1000 的数值型整数", r.rowIndex, typeof e.copies == "object" ? e.copies.field : void 0);
|
|
113
|
-
return o;
|
|
114
|
-
}
|
|
115
|
-
function je(e, t, r) {
|
|
116
|
-
if (e.rowKey === void 0) return;
|
|
117
|
-
const o = $e(t, e.rowKey, r);
|
|
118
|
-
if (typeof o == "string" && o.trim() || typeof o == "number" && Number.isFinite(o)) return o;
|
|
119
|
-
throw new C(`$.datasets.${r.dataset}[${r.rowIndex}].${e.rowKey}`, "业务主键必须是非空字符串或有限数字", r.rowIndex, e.rowKey);
|
|
120
|
-
}
|
|
121
|
-
function Gt(e) {
|
|
122
|
-
const t = (r) => 1 + (r.grid?.cells.reduce((o, a) => o + 1 + a.length + a.reduce((n, s) => n + (s?.children?.reduce((i, c) => i + t(c), 0) ?? 0), 0), 0) ?? 0);
|
|
123
|
-
return e.pages.reduce((r, o) => r + o.components.reduce((a, n) => a + t(n), 0), 0);
|
|
124
|
-
}
|
|
125
|
-
function Vt(e, t, r) {
|
|
126
|
-
const o = e.repeat, a = Object.prototype.hasOwnProperty.call(t, o.dataset) ? t[o.dataset] : void 0;
|
|
127
|
-
if (!Array.isArray(a)) throw new C(`$.datasets.${o.dataset}`, "逐记录标签数据集缺失,应提供对象数组(允许空数组)");
|
|
128
|
-
const n = /* @__PURE__ */ new Set(), s = r.maxPages ?? Wt, i = Gt(e);
|
|
129
|
-
let c = 0, d = 0;
|
|
130
|
-
for (const [l, f] of a.entries()) {
|
|
131
|
-
if (ue(r.signal), !f || typeof f != "object" || Array.isArray(f)) throw new C(`$.datasets.${o.dataset}[${l}]`, "标签记录应为对象", l);
|
|
132
|
-
const u = { rowIndex: l, dataset: o.dataset }, g = je(o, f, u);
|
|
133
|
-
if (g !== void 0) {
|
|
134
|
-
const m = JSON.stringify([typeof g, g]);
|
|
135
|
-
if (n.has(m)) throw new C(`$.datasets.${o.dataset}[${l}].${o.rowKey}`, "业务主键重复;请先确认记录来源,避免重复打印标签", l, o.rowKey);
|
|
136
|
-
n.add(m);
|
|
137
|
-
}
|
|
138
|
-
const h = Ie(o, f, u);
|
|
139
|
-
if (c += h * e.pages.length, d += h * i, c > s) throw new N(s, c);
|
|
140
|
-
if (d > Me) throw new C("$.repeat", `标签组件总量(含网格行、槽位及嵌套组件)超过安全预算 ${Me},请分批生成`, l);
|
|
141
|
-
}
|
|
142
|
-
return a;
|
|
143
|
-
}
|
|
144
|
-
function _t(e, t, r) {
|
|
145
|
-
if (!e.binding) return e;
|
|
146
|
-
const { binding: o, ...a } = e, n = gt(o, t.row, t);
|
|
147
|
-
if (e.kind === "image") {
|
|
148
|
-
if (!n) return;
|
|
149
|
-
if (!ht(n)) throw new C(`${r}.binding`, "图片字段只接受 PNG/JPEG base64 data URL;业务 URL 应由宿主安全加载后转换", t.rowIndex, o.field);
|
|
150
|
-
return { ...a, imageData: n };
|
|
151
|
-
}
|
|
152
|
-
return e.kind === "barcode" || e.kind === "qrcode" ? (delete a.imageData, { ...a, code: { ...a.code, value: n }, fallbackText: n }) : (delete a.lines, delete a.richParagraphs, { ...a, text: n });
|
|
153
|
-
}
|
|
154
|
-
function Jt(e, t, r) {
|
|
155
|
-
if (e.kind !== "text" || e.grid || e.richParagraphs?.length) return e;
|
|
156
|
-
const o = e.style ?? {}, a = de(o).fontSizePt, n = e.text ?? e.lines?.join(`
|
|
157
|
-
`) ?? "";
|
|
158
|
-
if (n.length > 16384) throw new C(r, "标签文本超过 16384 字符预算,请缩小字段内容", t.rowIndex);
|
|
159
|
-
const s = t.wrapText(n, e.widthMm, { fontSizePt: a, bold: o.bold, italic: o.italic, fontFamily: o.fontFamily, letterSpacingPt: o.letterSpacing }, t.options.measurer ?? ke), i = s.length * a * xt(o) * 25.4 / 72;
|
|
160
|
-
if (i > e.heightMm + 0.05) throw new C(r, `标签文字需要约 ${i.toFixed(2)}mm 高,超出 ${e.heightMm}mm;请增大文本区域、减少内容或调整字号`, t.rowIndex, e.binding?.field);
|
|
161
|
-
return { ...e, lines: s };
|
|
162
|
-
}
|
|
163
|
-
function Ne(e, t, r) {
|
|
164
|
-
ue(t.options.signal);
|
|
165
|
-
const o = _t(e, t, r);
|
|
166
|
-
if (!o) return;
|
|
167
|
-
let a = o.grid;
|
|
168
|
-
return a && (a = { ...a, cells: a.cells.map((n, s) => n.map((i, c) => i?.children?.length ? { ...i, children: i.children.flatMap((d, l) => {
|
|
169
|
-
const f = Ne(d, t, `${r}.grid.cells.${s}.${c}.children.${l}`);
|
|
170
|
-
return f ? [f] : [];
|
|
171
|
-
}) } : i)) }), Jt(a === o.grid ? o : { ...o, grid: a }, t, r);
|
|
172
|
-
}
|
|
173
|
-
function zt(e, t, r, o, a, n) {
|
|
174
|
-
return {
|
|
175
|
-
...e,
|
|
176
|
-
components: e.components.flatMap((s, i) => {
|
|
177
|
-
const c = Ne(s, r, `$.pages.${t}.components.${i}`);
|
|
178
|
-
return c ? [{ ...c, meta: { ...c.meta, labelSource: { pageIndex: t, componentIndex: i } } }] : [];
|
|
179
|
-
}),
|
|
180
|
-
meta: { ...e.meta, record: { dataset: r.dataset, rowIndex: r.rowIndex, ...n === void 0 ? {} : { rowKey: n }, copyIndex: o, copyCount: a, templatePageIndex: t } }
|
|
181
|
-
};
|
|
182
|
-
}
|
|
183
|
-
function* qt(e, t, r) {
|
|
184
|
-
const o = [];
|
|
185
|
-
if ($t(e, o), o.length) throw new C(o[0].path, o[0].message);
|
|
186
|
-
if (!e.repeat) {
|
|
187
|
-
for (const [i, c] of e.pages.entries()) yield { page: c, pageIndex: i };
|
|
188
|
-
return;
|
|
189
|
-
}
|
|
190
|
-
const a = e.repeat, n = Vt(e, t, r), s = Bt();
|
|
191
|
-
for (const [i, c] of n.entries()) {
|
|
192
|
-
const d = { row: c, rowIndex: i, dataset: a.dataset, options: r, wrapText: s }, l = Ie(a, c, d), f = je(a, c, d);
|
|
193
|
-
for (let u = 0; u < l; u++) for (const [g, h] of e.pages.entries())
|
|
194
|
-
ue(r.signal), yield { page: zt(h, g, d, u, l, f), pageIndex: g };
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
function Ut(e) {
|
|
198
|
-
return {
|
|
199
|
-
widthMm: e.widthMm,
|
|
200
|
-
heightMm: e.heightMm,
|
|
201
|
-
marginTopMm: e.marginTopMm ?? 0,
|
|
202
|
-
marginBottomMm: e.marginBottomMm ?? 0,
|
|
203
|
-
marginLeftMm: e.marginLeftMm ?? 0,
|
|
204
|
-
marginRightMm: e.marginRightMm ?? 0,
|
|
205
|
-
components: []
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
|
-
function _(e, t) {
|
|
209
|
-
const r = t.heightMm - (e.layout === "wide" ? t.marginBottomMm : e.marginBottomMm ?? t.marginBottomMm);
|
|
210
|
-
return e.components.reduce((o, a) => a.kind !== "list" && a.pageAnchor === "footer" ? Math.min(o, a.topMm) : o, r);
|
|
211
|
-
}
|
|
212
|
-
function B(e) {
|
|
213
|
-
return e.components.reduce((t, r) => r.kind !== "list" && r.pageAnchor === "header" ? Math.max(t, r.topMm + r.heightMm) : t, 0);
|
|
214
|
-
}
|
|
215
|
-
function He(e, t) {
|
|
216
|
-
let r = e.textMetrics.get(t);
|
|
217
|
-
if (!r) {
|
|
218
|
-
const o = de(t).fontSizePt;
|
|
219
|
-
r = {
|
|
220
|
-
measureOptions: {
|
|
221
|
-
fontSizePt: o,
|
|
222
|
-
fontFamily: t.fontFamily ?? Pe,
|
|
223
|
-
italic: t.italic,
|
|
224
|
-
bold: t.bold,
|
|
225
|
-
letterSpacingPt: t.letterSpacing
|
|
226
|
-
},
|
|
227
|
-
lineMm: o * (t.lineHeight ?? Te) * 25.4 / 72
|
|
228
|
-
}, e.textMetrics.set(t, r);
|
|
229
|
-
}
|
|
230
|
-
return r;
|
|
231
|
-
}
|
|
232
|
-
function Xt(e) {
|
|
233
|
-
if (e === null || typeof e == "string" || typeof e == "boolean" || typeof e == "number" && Number.isFinite(e)) return e;
|
|
234
|
-
}
|
|
235
|
-
function fe(e, t) {
|
|
236
|
-
const r = e.fontSizePt ?? mt, o = e.paddingMm ?? 1, a = e.columns.map((m) => m.align ?? m.style?.align ?? e.align ?? "left"), n = e.columns.map((m, w) => ({
|
|
237
|
-
...I({
|
|
238
|
-
fontSize: r,
|
|
239
|
-
verticalAlign: "middle"
|
|
240
|
-
}, m.style),
|
|
241
|
-
align: a[w] === "auto" ? "left" : a[w]
|
|
242
|
-
})), s = n.map((m, w) => a[w] === "auto" ? { left: m, center: { ...m, align: "center" }, right: { ...m, align: "right" } } : void 0), i = e.columns.map((m, w) => m.rules?.map((v) => {
|
|
243
|
-
const S = s[w];
|
|
244
|
-
if (S) return {
|
|
245
|
-
left: I(S.left, v.style),
|
|
246
|
-
center: I(S.center, v.style),
|
|
247
|
-
right: I(S.right, v.style)
|
|
248
|
-
};
|
|
249
|
-
const k = I(n[w], v.style);
|
|
250
|
-
return { left: k, center: k, right: k };
|
|
251
|
-
})), c = e.columns.map((m) => pt(e, m)), d = e.columns.map((m) => m.header);
|
|
252
|
-
let l = e.rowHeightMm ?? 0;
|
|
253
|
-
for (let m = 0; m < d.length; m++) {
|
|
254
|
-
const w = c[m], v = de(w).fontSizePt, S = q(
|
|
255
|
-
d[m],
|
|
256
|
-
e.columns[m].widthMm - o * 2,
|
|
257
|
-
{ fontSizePt: v, fontFamily: w.fontFamily ?? Pe, italic: w.italic, bold: w.bold, letterSpacingPt: w.letterSpacing },
|
|
258
|
-
t
|
|
259
|
-
), k = v * (w.lineHeight ?? Te) * 25.4 / 72;
|
|
260
|
-
l = Math.max(l, Math.max(S.length, 1) * k + o * 2);
|
|
261
|
-
}
|
|
262
|
-
const f = d.map((m, w) => ({
|
|
263
|
-
text: m,
|
|
264
|
-
style: c[w]
|
|
265
|
-
})), u = e.border === !1 ? { borderTop: !1, borderRight: !1, borderBottom: !1, borderLeft: !1 } : { borderBottom: !0, borderLeft: !0, borderRight: !0, borderTop: !0 }, g = e.columns.map((m) => m.widthMm), h = Yt(e.headerGrid, g, {
|
|
266
|
-
cells: [f],
|
|
267
|
-
colWidthsMm: g,
|
|
268
|
-
rowHeightsMm: [l],
|
|
269
|
-
paddingMm: o
|
|
270
|
-
});
|
|
271
|
-
return {
|
|
272
|
-
fontSizePt: r,
|
|
273
|
-
paddingMm: o,
|
|
274
|
-
cellStyles: n,
|
|
275
|
-
autoStyles: s,
|
|
276
|
-
ruleStyles: i,
|
|
277
|
-
textMetrics: /* @__PURE__ */ new WeakMap(),
|
|
278
|
-
numberFormats: e.columns.map((m) => Re(m.format)),
|
|
279
|
-
derivedFields: new Set(e.computed?.map((m) => m.field)),
|
|
280
|
-
borderStyle: u,
|
|
281
|
-
headerHeightMm: h.rowHeightsMm.reduce((m, w) => m + w, 0),
|
|
282
|
-
headerGrid: h,
|
|
283
|
-
colWidthsMm: g,
|
|
284
|
-
columns: e.columns
|
|
285
|
-
};
|
|
286
|
-
}
|
|
287
|
-
function Yt(e, t, r) {
|
|
288
|
-
if (!e) return r;
|
|
289
|
-
if (!e.cells.length) throw new Error("自定义列表表头至少需要一行");
|
|
290
|
-
const o = e.rowHeightsMm ?? e.cells.map(() => r.rowHeightsMm[0]);
|
|
291
|
-
if (o.length !== e.cells.length || o.some((a) => !Number.isFinite(a) || a <= 0)) throw new Error("自定义列表表头行高无效");
|
|
292
|
-
return { ...e, colWidthsMm: t, rowHeightsMm: o };
|
|
293
|
-
}
|
|
294
|
-
function Qt(e, t, r) {
|
|
295
|
-
const o = t.format?.kind === "number" || t.format?.kind === "percent";
|
|
296
|
-
t.valueType !== void 0 ? e.valueType = t.valueType : o && (e.valueType = "number"), t.editable !== void 0 && (e.editable = t.editable), (typeof e.value == "number" || e.value == null) && r !== void 0 && (e.numberFormat = r);
|
|
297
|
-
}
|
|
298
|
-
function W(e, t, r) {
|
|
299
|
-
const o = e.columns, a = e.tree?.rows.get(t);
|
|
300
|
-
let n = e.rowHeightFloorMm;
|
|
301
|
-
const s = new Array(o.length);
|
|
302
|
-
for (let i = 0; i < o.length; i++) {
|
|
303
|
-
const c = o[i], d = c.visibleWhen && !L(t, c.visibleWhen) ? null : t[c.field], l = e.autoStyles[i] ? Ee(d, c.format, c.semanticRole) : "left";
|
|
304
|
-
let f = e.autoStyles[i]?.[l] ?? e.cellStyles[i];
|
|
305
|
-
if (c.rules)
|
|
306
|
-
for (let S = 0; S < c.rules.length; S++) {
|
|
307
|
-
const k = c.rules[S];
|
|
308
|
-
if (L(t, k.when)) {
|
|
309
|
-
f = e.ruleStyles[i][S][l];
|
|
310
|
-
break;
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
const u = c.format ? xe(d, c.format) : ce(d), g = Zt(e, c, a);
|
|
314
|
-
f = er(e, c, f, a);
|
|
315
|
-
const h = He(e, f), m = q(u, Math.max(1, c.widthMm - e.paddingMm * 2 - g), h.measureOptions, r);
|
|
316
|
-
n = Math.max(n, m.length * h.lineMm + e.paddingMm * 2);
|
|
317
|
-
const w = Xt(d), v = { text: u, style: f };
|
|
318
|
-
w !== void 0 && (v.value = w), Qt(v, c, e.numberFormats[i]), tr(v, c, e, a, g), e.derivedFields.has(c.field) && (v.derived = !0, v.editable = !1), c.visibleWhen && d === null && !L(t, c.visibleWhen) && (v.editable = !1), s[i] = v;
|
|
319
|
-
}
|
|
320
|
-
return {
|
|
321
|
-
grid: { cells: [s], colWidthsMm: e.colWidthsMm, rowHeightsMm: [n], paddingMm: e.paddingMm },
|
|
322
|
-
heightMm: n
|
|
323
|
-
};
|
|
324
|
-
}
|
|
325
|
-
function Zt(e, t, r) {
|
|
326
|
-
return !r || t.field !== e.tree.list.tree.labelField ? 0 : wt(e.tree.list, t, r, e.paddingMm);
|
|
327
|
-
}
|
|
328
|
-
function er(e, t, r, o) {
|
|
329
|
-
return !o || t.field !== e.tree.list.tree.labelField || r.align === "left" ? r : { ...r, align: "left" };
|
|
330
|
-
}
|
|
331
|
-
function tr(e, t, r, o, a = 0) {
|
|
332
|
-
o && (a && (e.indentMm = a), yt(e, t, o, r.tree.list));
|
|
333
|
-
}
|
|
334
|
-
function Le(e) {
|
|
335
|
-
if (e != null && typeof e != "string" && typeof e != "boolean" && !(typeof e == "number" && Number.isFinite(e))) throw new Error("分组字段应为有限 JSON 标量");
|
|
336
|
-
return JSON.stringify([typeof e, e ?? null]);
|
|
337
|
-
}
|
|
338
|
-
function* De(e, t, r = 0) {
|
|
339
|
-
const o = t[r];
|
|
340
|
-
if (!o) {
|
|
341
|
-
for (const n of e) yield { kind: "row", row: n };
|
|
342
|
-
return;
|
|
343
|
-
}
|
|
344
|
-
const a = /* @__PURE__ */ new Map();
|
|
345
|
-
for (const n of e) {
|
|
346
|
-
const s = Le(n[o.field]), i = a.get(s);
|
|
347
|
-
i ? i.push(n) : a.set(s, [n]);
|
|
348
|
-
}
|
|
349
|
-
for (const n of a.values())
|
|
350
|
-
yield { kind: "groupHeader", label: (o.headerTemplate ?? "{value}").replace(/\{value\}/g, ce(n[0][o.field])), firstRow: n[0], group: o, depth: r, rows: n }, yield* De(n, t, r + 1), (o.subtotal?.length || o.aggregates?.length) && (yield { kind: "subtotal", label: o.subtotalLabel ?? "小计", rows: n, group: o, depth: r }), yield { kind: "groupEnd", depth: r };
|
|
351
|
-
}
|
|
352
|
-
function Ke(e, t, r, o = []) {
|
|
353
|
-
const a = [...r.filter((n) => !o.some((s) => s.field === n)).map((n) => ({ field: n, op: "sum" })), ...o];
|
|
354
|
-
return new Map(a.map((n) => {
|
|
355
|
-
const s = e.find((c) => c.field === n.field)?.format ?? { kind: "number", thousands: !0 }, i = bt(t, { ...n, field: n.valueField ?? n.field });
|
|
356
|
-
return [n.field, { text: xe(i, s), ...i === null ? {} : { value: i }, ...typeof i == "number" ? { numberFormat: Re(s) } : {} }];
|
|
357
|
-
}));
|
|
358
|
-
}
|
|
359
|
-
function Be(e, t) {
|
|
360
|
-
const r = e.findIndex((o) => t.includes(o.field));
|
|
361
|
-
return r < 0 ? 1 : r;
|
|
362
|
-
}
|
|
363
|
-
function K(e, t, r, o, a, n) {
|
|
364
|
-
const s = [], i = Math.max(0, Math.min(n, e.columns.length)), c = I({ fontSize: e.fontSizePt }, a);
|
|
365
|
-
i && s.push({ text: r, colSpan: i, style: { bold: !0, ...c } });
|
|
366
|
-
for (let u = i; u < e.columns.length; u++) {
|
|
367
|
-
const g = e.columns[u], h = o.get(g.field), m = e.autoStyles[u]?.[Ee(h?.value, g.format)] ?? e.cellStyles[u];
|
|
368
|
-
s.push({ ...h, text: h?.text ?? "", style: I(m, a) });
|
|
369
|
-
}
|
|
370
|
-
const d = { text: r, colSpan: e.columns.length, style: { bold: !0, ...c } }, l = i ? [s] : [[d], s], f = l.map((u) => rr(e, u, t));
|
|
371
|
-
return {
|
|
372
|
-
grid: { cells: l, colWidthsMm: e.colWidthsMm, rowHeightsMm: f, paddingMm: e.paddingMm },
|
|
373
|
-
heightMm: f.reduce((u, g) => u + g, 0)
|
|
374
|
-
};
|
|
375
|
-
}
|
|
376
|
-
function rr(e, t, r) {
|
|
377
|
-
let o = e.rowHeightFloorMm, a = 0;
|
|
378
|
-
for (const n of t) {
|
|
379
|
-
let s = 0;
|
|
380
|
-
const i = a + (n.colSpan ?? 1);
|
|
381
|
-
for (; a < i; a++) s += e.colWidthsMm[a] ?? 0;
|
|
382
|
-
const c = He(e, n.style), d = q(n.text ?? "", s - e.paddingMm * 2, c.measureOptions, r);
|
|
383
|
-
o = Math.max(o, d.length * c.lineMm + e.paddingMm * 2);
|
|
384
|
-
}
|
|
385
|
-
return o;
|
|
386
|
-
}
|
|
387
|
-
function or(e, t, r) {
|
|
388
|
-
const { templatePage: o, current: a, warnings: n, nextId: s, pushCurrent: i } = r, c = () => _(o, a), d = Math.max(a.marginTopMm, B(o)), l = o.layout === "wide" ? B(o) : d, f = {
|
|
389
|
-
id: r.tableId,
|
|
390
|
-
columnKeys: e.columns.map((p) => p.field),
|
|
391
|
-
...e.layout === void 0 ? {} : { layout: e.layout },
|
|
392
|
-
...e.title === void 0 ? {} : { title: e.title }
|
|
393
|
-
}, u = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Map(), h = {
|
|
394
|
-
kind: "rect",
|
|
395
|
-
leftMm: e.leftMm,
|
|
396
|
-
topMm: 0,
|
|
397
|
-
widthMm: e.widthMm,
|
|
398
|
-
heightMm: t.headerHeightMm,
|
|
399
|
-
grid: t.headerGrid,
|
|
400
|
-
nid: s("listh"),
|
|
401
|
-
table: { ...f, role: "header", rowIndex: -1 },
|
|
402
|
-
style: t.borderStyle,
|
|
403
|
-
...e.meta ? { meta: e.meta } : {}
|
|
404
|
-
}, m = (p) => a.components.push({ ...h, topMm: p });
|
|
405
|
-
if (r.flow && e.header !== !1 && t.headerHeightMm > c() - d + 1e-3) throw new Error(`流式列表 ${e.id ?? e.dataset} 的表头高度超出单页可用范围`);
|
|
406
|
-
let w = Math.max(r.startTop ?? e.topMm, d);
|
|
407
|
-
e.header !== !1 && (m(w), w += t.headerHeightMm + r.mmPerRow);
|
|
408
|
-
function v() {
|
|
409
|
-
const p = Math.max(r.flow || o.layout === "wide" ? 0 : e.topMm, l);
|
|
410
|
-
return (e.header !== !1 && e.headerEveryPage !== !1 ? p + t.headerHeightMm : l) + [...g.values()].reduce((M, $) => M + $.heightMm, 0);
|
|
411
|
-
}
|
|
412
|
-
function S() {
|
|
413
|
-
const p = o.layout === "wide" ? 0 : a.marginBottomMm;
|
|
414
|
-
return Math.min(o.heightMm - p, _(o, a)) - v();
|
|
415
|
-
}
|
|
416
|
-
function k(p) {
|
|
417
|
-
if (w + p <= c()) return;
|
|
418
|
-
i(), a.components = [], a.heightMm = o.heightMm, o.layout === "wide" && (a.marginTopMm = 0, a.marginBottomMm = 0);
|
|
419
|
-
const y = Math.max(r.flow || o.layout === "wide" ? 0 : e.topMm, l);
|
|
420
|
-
e.header !== !1 && e.headerEveryPage !== !1 ? (m(y), w = y + t.headerHeightMm) : w = l;
|
|
421
|
-
for (const M of g.values()) A(M, "listgr", "group-header");
|
|
422
|
-
}
|
|
423
|
-
function b(p, y, M, $) {
|
|
424
|
-
const R = S();
|
|
425
|
-
if (r.flow && p.heightMm > R + 1e-3) throw new Error(`流式列表 ${e.id ?? e.dataset} 的单行高度超出单页可用范围`);
|
|
426
|
-
p.heightMm > R && n.push(`列表 ${e.id ?? e.dataset} 行高 ${p.heightMm.toFixed(2)}mm 超出单页可用高度 ${R.toFixed(2)}mm,预览与打印可能截断内容`), k(p.heightMm), A(p, y, M, $);
|
|
427
|
-
}
|
|
428
|
-
function A(p, y, M, $) {
|
|
429
|
-
const R = p.table?.id ?? f.id, F = M === "header" ? -1 : u.get(R) ?? 0;
|
|
430
|
-
M !== "header" && u.set(R, F + p.grid.cells.length), a.components.push({
|
|
431
|
-
kind: "rect",
|
|
432
|
-
leftMm: e.leftMm,
|
|
433
|
-
topMm: w,
|
|
434
|
-
widthMm: e.widthMm,
|
|
435
|
-
heightMm: p.heightMm,
|
|
436
|
-
grid: p.grid,
|
|
437
|
-
nid: s(y),
|
|
438
|
-
table: { ...f, ...p.table, role: M, rowIndex: F, ...$ ? { source: $ } : {} },
|
|
439
|
-
style: t.borderStyle,
|
|
440
|
-
...e.meta ? { meta: e.meta } : {}
|
|
441
|
-
}), w += p.heightMm;
|
|
442
|
-
}
|
|
443
|
-
function O(p) {
|
|
444
|
-
p <= S() && k(p);
|
|
445
|
-
}
|
|
446
|
-
return { keepTogether: O, placeGridRow: b, setGroupHeader: (p, y) => {
|
|
447
|
-
y ? g.set(p, y) : g.delete(p);
|
|
448
|
-
}, bottom: () => w };
|
|
449
|
-
}
|
|
450
|
-
function nr(e, t) {
|
|
451
|
-
if (!e.rowKey) return;
|
|
452
|
-
const r = t[e.rowKey];
|
|
453
|
-
if ((typeof r != "string" || !r.trim()) && !(typeof r == "number" && Number.isFinite(r)))
|
|
454
|
-
throw new Error(`数据集 ${e.dataset} 的 ${e.rowKey} 应为稳定的字符串或有限数字主键`);
|
|
455
|
-
const o = e.revisionField ? t[e.revisionField] : void 0, a = e.sourceTokenField ? t[e.sourceTokenField] : void 0;
|
|
456
|
-
if (o !== void 0 && typeof o != "string" && !(typeof o == "number" && Number.isFinite(o))) throw new Error("业务修订号应为字符串或有限数字");
|
|
457
|
-
if (a !== void 0 && typeof a != "string") throw new Error("来源令牌应为字符串");
|
|
458
|
-
return { datasetId: e.dataset, rowKey: r, ...o === void 0 ? {} : { revision: o }, ...a === void 0 ? {} : { sourceToken: a } };
|
|
459
|
-
}
|
|
460
|
-
function X(e, t) {
|
|
461
|
-
const r = /* @__PURE__ */ new Map();
|
|
462
|
-
if (!e.rowKey) return r;
|
|
463
|
-
const o = /* @__PURE__ */ new Set();
|
|
464
|
-
for (const a of t) {
|
|
465
|
-
const n = nr(e, a), s = JSON.stringify(n.rowKey);
|
|
466
|
-
if (o.has(s)) throw new Error(`数据集 ${e.dataset} 的业务主键重复:${String(n.rowKey)}`);
|
|
467
|
-
o.add(s), r.set(a, n);
|
|
468
|
-
}
|
|
469
|
-
return r;
|
|
470
|
-
}
|
|
471
|
-
function ar(e, t, r, o, a) {
|
|
472
|
-
if (!e.grandTotal) return;
|
|
473
|
-
const n = typeof e.grandTotal == "object" ? e.grandTotal : void 0, s = Y(e)[0], i = n?.fields ?? s?.subtotal ?? [], c = n?.aggregates ?? s?.aggregates ?? [];
|
|
474
|
-
if (i.length === 0 && c.length === 0) {
|
|
475
|
-
o.warnings.push(`列表 ${e.id ?? ""} 配置了 grandTotal 但未提供合计字段(groupBy.subtotal 或 grandTotal.fields)`);
|
|
476
|
-
return;
|
|
477
|
-
}
|
|
478
|
-
const d = K(r, o.measurer, n?.label ?? "合计", Ke(e.columns, t, i, c), n?.style ?? {}, Be(e.columns, [...i, ...c.map((l) => l.field)]));
|
|
479
|
-
a.placeGridRow(d, "listgt", "grand-total");
|
|
480
|
-
}
|
|
481
|
-
function G(e) {
|
|
482
|
-
if (e?.aborted) {
|
|
483
|
-
const t = new Error("报表排版已取消");
|
|
484
|
-
throw t.name = "AbortError", t;
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
function Y(e) {
|
|
488
|
-
const t = e.groups ?? (e.groupBy ? [e.groupBy] : []);
|
|
489
|
-
if (t.length > 16) throw new Error("列表最多支持 16 级分组");
|
|
490
|
-
return t;
|
|
491
|
-
}
|
|
492
|
-
function me(e) {
|
|
493
|
-
const t = Ht(e), r = t.columns.reduce((a, n) => a + n.widthMm, 0), o = r > t.widthMm ? t.widthMm / r : 1;
|
|
494
|
-
return o === 1 ? t : { ...t, columns: t.columns.map((a) => ({ ...a, widthMm: a.widthMm * o })) };
|
|
495
|
-
}
|
|
496
|
-
function sr(e, t, r) {
|
|
497
|
-
const o = e.detail;
|
|
498
|
-
if (!o) return;
|
|
499
|
-
const a = /* @__PURE__ */ new Set();
|
|
500
|
-
for (const d of t) {
|
|
501
|
-
const l = ne(d[o.parentKey]);
|
|
502
|
-
if (a.has(l)) throw new Error("主从明细的主表关联键重复");
|
|
503
|
-
a.add(l);
|
|
504
|
-
}
|
|
505
|
-
const n = r.datasets[o.dataset] ?? [], s = /* @__PURE__ */ new Map(), i = [];
|
|
506
|
-
for (const d of n) {
|
|
507
|
-
const l = d[o.foreignKey];
|
|
508
|
-
if (!We(l) && o.unmatched === "ignore") continue;
|
|
509
|
-
const f = ne(l);
|
|
510
|
-
if (!a.has(f)) {
|
|
511
|
-
if (o.unmatched !== "ignore") throw new Error(`明细数据集 ${o.dataset} 存在未关联的业务键`);
|
|
512
|
-
continue;
|
|
513
|
-
}
|
|
514
|
-
const u = s.get(f);
|
|
515
|
-
u ? u.push(d) : s.set(f, [d]), i.push(d);
|
|
516
|
-
}
|
|
517
|
-
const c = me({ ...e, id: `${e.id ?? e.dataset}:detail`, dataset: o.dataset, rowKey: o.rowKey, revisionField: o.revisionField, sourceTokenField: o.sourceTokenField, computed: void 0, columns: o.columns, headerGrid: void 0, rowHeightMm: o.rowHeightMm ?? e.rowHeightMm, detail: void 0 });
|
|
518
|
-
return { list: c, inter: { ...fe(c, r.measurer), rowHeightFloorMm: c.rowHeightMm ?? 0 }, rows: s, sources: X(c, i) };
|
|
519
|
-
}
|
|
520
|
-
function We(e) {
|
|
521
|
-
return typeof e == "string" && !!e.trim() || typeof e == "number" && Number.isFinite(e);
|
|
522
|
-
}
|
|
523
|
-
function ne(e) {
|
|
524
|
-
if (!We(e)) throw new Error("主从关联键必须是非空字符串或有限数字");
|
|
525
|
-
return Le(e);
|
|
526
|
-
}
|
|
527
|
-
function* ir(e, t, r, o, a) {
|
|
528
|
-
if (!r) return;
|
|
529
|
-
const n = r.rows.get(ne(t[e.detail.parentKey])) ?? [];
|
|
530
|
-
if (!n.length) return;
|
|
531
|
-
const s = { id: `${o.tableId}:detail`, columnKeys: r.list.columns.map((i) => i.field), title: e.detail.label };
|
|
532
|
-
e.detail.label && a.placeGridRow({ ...K(r.inter, o.measurer, e.detail.label, /* @__PURE__ */ new Map(), {}, r.list.columns.length), table: s }, "listdl", "group-header"), e.detail.header !== !1 && a.placeGridRow({ grid: r.inter.headerGrid, heightMm: r.inter.headerHeightMm, table: s }, "listdh", "header"), yield* o.takePages();
|
|
533
|
-
for (const i of n)
|
|
534
|
-
G(o.signal), a.placeGridRow({ ...W(r.inter, i, o.measurer), table: s }, "listdr", "body", r.sources.get(i)), yield* o.takePages();
|
|
535
|
-
}
|
|
536
|
-
function cr(e, t) {
|
|
537
|
-
if (!e.matrix) return { list: e, rows: t };
|
|
538
|
-
if (e.detail || e.groupBy || e.groups?.length || e.grandTotal) throw new Error("矩阵不能同时配置普通分组、总计或主从明细");
|
|
539
|
-
const r = vt(t, e.matrix), o = r.columns.map((n, s) => ({ ...n, widthMm: s === 0 ? e.matrix.rowWidthMm ?? 40 : e.matrix.columnWidthMm ?? 28, editable: !1, align: s === 0 ? "center" : "right" })), a = { ...e, columns: o, headerGrid: void 0, rowKey: void 0, revisionField: void 0, sourceTokenField: void 0 };
|
|
540
|
-
return e.layout === "wide" && (a.widthMm = o.reduce((n, s) => n + s.widthMm, 0)), { list: a, rows: r.rows };
|
|
541
|
-
}
|
|
542
|
-
function Ge(e) {
|
|
543
|
-
if (e.matrix || e.detail || e.groups?.length || e.groupBy || e.rowVisibleWhen) throw new Error("树形布局不能同时配置普通分组、矩阵、主从或行可见条件");
|
|
544
|
-
if (e.rowKey && e.rowKey !== e.tree.idField) throw new Error("树形布局的 rowKey 应与 idField 一致");
|
|
545
|
-
if (!e.columns.some((t) => t.field === e.tree.labelField && !t.hidden)) throw new Error("树形布局需要可见的标签列");
|
|
546
|
-
St(e.tree, e.computed);
|
|
547
|
-
}
|
|
548
|
-
function dr(e, t, r) {
|
|
549
|
-
Ge(e);
|
|
550
|
-
const o = Pt(t, e.tree, { signal: r.signal, computed: e.computed?.length ? { fields: e.computed, formula: r.formula } : void 0 }), a = { ...e, rowKey: e.tree.idField }, n = X(a, o.entries.map((c) => c.original)), s = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new WeakMap();
|
|
551
|
-
for (const c of o.entries)
|
|
552
|
-
s.set(c.row, n.get(c.original)), i.set(c.row, c);
|
|
553
|
-
return { list: a, rows: o.rows, sources: s, treeRows: i, totalRows: o.leaves };
|
|
554
|
-
}
|
|
555
|
-
function lr(e, t) {
|
|
556
|
-
if (e.cardinality === "record") {
|
|
557
|
-
if (t.length > 1) throw new Error(`单记录区域 ${e.id ?? e.dataset} 仅允许 0 或 1 行数据`);
|
|
558
|
-
if (e.tree || e.matrix || e.detail || e.groups?.length || e.groupBy || e.grandTotal || e.rowVisibleWhen) throw new Error("单记录区域不能配置树、矩阵、主从、分组、总计或行过滤");
|
|
559
|
-
if (!t.length) return { list: { ...e, columns: e.columns.map((r) => ({ ...r, editable: !1 })) }, rows: [{}], sources: /* @__PURE__ */ new Map() };
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
|
-
function Ve(e, t, r) {
|
|
563
|
-
const o = r.prepared.get(e);
|
|
564
|
-
if (o) return o;
|
|
565
|
-
const a = lr(e, t);
|
|
566
|
-
if (a)
|
|
567
|
-
return r.prepared.set(e, a), a;
|
|
568
|
-
if (e.tree) {
|
|
569
|
-
const c = dr(e, t, r);
|
|
570
|
-
return r.prepared.set(e, c), c;
|
|
571
|
-
}
|
|
572
|
-
let n = e.computed?.length ? Ce(t, { fields: e.computed, signal: r.signal, formula: r.formula }).rows : t;
|
|
573
|
-
const s = n === t ? void 0 : new Map(n.map((c, d) => [c, t[d]]));
|
|
574
|
-
e.rowVisibleWhen && (n = n.filter((c) => L(c, e.rowVisibleWhen)));
|
|
575
|
-
const i = cr(e, n);
|
|
576
|
-
if (!e.matrix) {
|
|
577
|
-
const c = X(e, s ? n.map((d) => s.get(d)) : n);
|
|
578
|
-
i.sources = s ? new Map(n.map((d) => [d, c.get(s.get(d))])) : c;
|
|
579
|
-
}
|
|
580
|
-
return r.prepared.set(e, i), i;
|
|
581
|
-
}
|
|
582
|
-
function ur(e, t, r, o) {
|
|
583
|
-
if (!o.flow) return;
|
|
584
|
-
const { current: a, templatePage: n } = o, s = Math.max(a.marginTopMm, B(n)), i = Math.max(o.startTop ?? e.topMm, s), c = (e.header === !1 ? 0 : t.headerHeightMm) + (r[0] ? W(t, r[0], o.measurer).heightMm : 0);
|
|
585
|
-
i + c <= _(n, a) + 1e-3 || i <= s + 1e-3 || (o.pushCurrent(), a.components = [], a.heightMm = n.heightMm, n.layout === "wide" && (a.marginTopMm = 0, a.marginBottomMm = 0), o.startTop = Math.max(a.marginTopMm, B(n)));
|
|
586
|
-
}
|
|
587
|
-
function* fr(e, t, r) {
|
|
588
|
-
const o = Ve(e, t, r), a = o.rows;
|
|
589
|
-
e = o.list, e.layout === "wide" && (r.current.widthMm = Math.max(r.current.widthMm, e.leftMm + e.widthMm + r.current.marginRightMm));
|
|
590
|
-
const n = o.sources ?? X(e, a), s = me(e), i = Y(s), c = { ...fe(s, r.measurer), rowHeightFloorMm: s.rowHeightMm ?? 0, ...o.treeRows ? { tree: { list: s, rows: o.treeRows } } : {} };
|
|
591
|
-
ur(s, c, a, r);
|
|
592
|
-
const d = or(s, c, r), l = sr(s, a, r);
|
|
593
|
-
let f;
|
|
594
|
-
for (const u of De(a, i)) {
|
|
595
|
-
if (G(r.signal), u.kind === "row")
|
|
596
|
-
d.placeGridRow(f ?? W(c, u.row, r.measurer), "listr", "body", n.get(u.row)), f = void 0, yield* r.takePages(), yield* ir(s, u.row, l, r, d);
|
|
597
|
-
else if (u.kind === "groupHeader") {
|
|
598
|
-
const g = K(c, r.measurer, u.label, /* @__PURE__ */ new Map(), u.group.headerStyle ?? {}, s.columns.length);
|
|
599
|
-
f ??= W(c, u.firstRow, r.measurer);
|
|
600
|
-
const h = i.slice(u.depth + 1).reduce((m, w) => m + K(c, r.measurer, (w.headerTemplate ?? "{value}").replace(/\{value\}/g, ce(u.firstRow[w.field])), /* @__PURE__ */ new Map(), w.headerStyle ?? {}, s.columns.length).heightMm, 0);
|
|
601
|
-
u.group.keepWithNext !== !1 && d.keepTogether(g.heightMm + h + f.heightMm), d.placeGridRow(g, "listg", "group-header"), u.group.repeatHeader && d.setGroupHeader(u.depth, g);
|
|
602
|
-
} else if (u.kind === "subtotal") {
|
|
603
|
-
const g = u.group.subtotal ?? [], h = u.group.aggregates ?? [], m = K(c, r.measurer, u.label, Ke(s.columns, u.rows, g, h), u.group.subtotalStyle ?? {}, Be(s.columns, [...g, ...h.map((w) => w.field)]));
|
|
604
|
-
d.placeGridRow(m, "listst", "subtotal");
|
|
605
|
-
} else d.setGroupHeader(u.depth);
|
|
606
|
-
yield* r.takePages();
|
|
607
|
-
}
|
|
608
|
-
ar(s, o.totalRows ?? a, c, r, d), r.finished?.(d.bottom()), yield* r.takePages();
|
|
609
|
-
}
|
|
610
|
-
function Q(e) {
|
|
611
|
-
return e.kind !== "list" && (e.pageAnchor !== void 0 || e.kind === "text" && typeof e.text == "string" && (e.text.includes("{page}") || e.text.includes("{totalPages}")));
|
|
612
|
-
}
|
|
613
|
-
function Z(e, t) {
|
|
614
|
-
return {
|
|
615
|
-
...e,
|
|
616
|
-
...e.text === void 0 ? {} : { text: t(e.text) },
|
|
617
|
-
...e.lines ? { lines: e.lines.map(t) } : {},
|
|
618
|
-
...e.richParagraphs ? { richParagraphs: e.richParagraphs.map((r) => ({ ...r, segments: r.segments.map((o) => ({ ...o, ...o.text === void 0 ? {} : { text: t(o.text) } })) })) } : {},
|
|
619
|
-
...e.grid ? { grid: { ...e.grid, cells: e.grid.cells.map((r) => r.map((o) => o ? { ...o, ...o.text === void 0 ? {} : { text: t(o.text) }, ...o.children ? { children: o.children.map((a) => Z(a, t)) } : {} } : null)) } } : {}
|
|
620
|
-
};
|
|
621
|
-
}
|
|
622
|
-
function mr(e) {
|
|
623
|
-
let t = !1;
|
|
624
|
-
for (const r of e.pages) for (const o of r.components) Q(o) && Z(o, (a) => (a.includes("{totalPages}") && (t = !0), a));
|
|
625
|
-
return t;
|
|
626
|
-
}
|
|
627
|
-
function gr(e, t, r, o, a, n) {
|
|
628
|
-
const s = {
|
|
629
|
-
pageWidthMm: t.widthMm,
|
|
630
|
-
pageHeightMm: t.heightMm,
|
|
631
|
-
...e.layout === void 0 ? {} : { layout: e.layout },
|
|
632
|
-
marginTopMm: t.marginTopMm,
|
|
633
|
-
marginBottomMm: t.marginBottomMm,
|
|
634
|
-
marginLeftMm: t.marginLeftMm,
|
|
635
|
-
marginRightMm: t.marginRightMm,
|
|
636
|
-
components: t.components,
|
|
637
|
-
...e.meta ? { meta: e.meta } : {}
|
|
638
|
-
}, i = (c) => {
|
|
639
|
-
const d = c.replace(/\{page\}/g, String(o));
|
|
640
|
-
return n === void 0 ? d : d.replace(/\{totalPages\}/g, String(n));
|
|
641
|
-
};
|
|
642
|
-
for (const c of r) s.components.push(Z(c, i));
|
|
643
|
-
if (e.layout === "wide") {
|
|
644
|
-
const c = s.components.reduce((d, l) => Math.max(d, l.topMm + l.heightMm), 0);
|
|
645
|
-
s.marginBottomMm = a ? e.marginBottomMm ?? 0 : 0, s.pageHeightMm = Math.max(1, c + s.marginBottomMm);
|
|
646
|
-
}
|
|
647
|
-
return s;
|
|
648
|
-
}
|
|
649
|
-
function ge(e) {
|
|
650
|
-
return e.cells.reduce((t, r) => t + r.reduce((o, a) => o + (a ? 1 + (a.children?.reduce((n, s) => n + _e(s), 0) ?? 0) : 0), 0), 0);
|
|
651
|
-
}
|
|
652
|
-
function _e(e) {
|
|
653
|
-
return e.grid ? ge(e.grid) : 0;
|
|
654
|
-
}
|
|
655
|
-
function he(e) {
|
|
656
|
-
for (const t of ["maxPages", "maxCells", "knownTotalPages"]) if (e[t] !== void 0 && (!Number.isSafeInteger(e[t]) || e[t] < 1)) throw new RangeError(`${t} 应为正安全整数`);
|
|
657
|
-
}
|
|
658
|
-
function hr(e, t) {
|
|
659
|
-
const r = Ve(e, t.datasets[e.dataset] ?? [], t), o = me(r.list), a = { ...fe(o, t.measurer), rowHeightFloorMm: o.rowHeightMm ?? 0 };
|
|
660
|
-
return (o.header === !1 ? 0 : a.headerHeightMm) + r.rows.reduce((n, s) => n + W(a, s, t.measurer).heightMm, 0);
|
|
661
|
-
}
|
|
662
|
-
function* pr(e) {
|
|
663
|
-
const { templatePage: t, current: r } = e, o = new Map(t.components.map((n, s) => [n, s])), a = (n, s, i) => {
|
|
664
|
-
const c = e.datasets[n.dataset];
|
|
665
|
-
return Array.isArray(c) || e.warnings.push(`数据集 ${n.dataset} 未提供数据,列表 ${n.id ?? ""} 输出为空`), fr(n, Array.isArray(c) ? c : [], { ...e, tableId: `${e.tableId}:${o.get(n)}`, startTop: s, finished: i, flow: !!t.flow });
|
|
666
|
-
};
|
|
667
|
-
if (t.flow) {
|
|
668
|
-
yield* Lt({
|
|
669
|
-
page: t,
|
|
670
|
-
active: () => G(e.signal),
|
|
671
|
-
top: () => Math.max(r.marginTopMm, B(t)),
|
|
672
|
-
bottom: () => _(t, r),
|
|
673
|
-
append: (n) => {
|
|
674
|
-
r.components.push(n);
|
|
675
|
-
},
|
|
676
|
-
nextPage: () => {
|
|
677
|
-
e.pushCurrent(), r.components = [], r.heightMm = t.heightMm, t.layout === "wide" && (r.marginTopMm = 0, r.marginBottomMm = 0);
|
|
678
|
-
},
|
|
679
|
-
takePages: e.takePages,
|
|
680
|
-
height: (n) => hr(n, e),
|
|
681
|
-
list: a
|
|
682
|
-
});
|
|
683
|
-
return;
|
|
684
|
-
}
|
|
685
|
-
for (const n of t.components)
|
|
686
|
-
Q(n) || (n.kind === "list" ? yield* a(n) : r.components.push(n));
|
|
687
|
-
}
|
|
688
|
-
function* J(e, t, r, o, a, n = /* @__PURE__ */ new WeakMap()) {
|
|
689
|
-
let s = 0, i = 0, c = 0;
|
|
690
|
-
const d = (l) => `${l}_${(++s).toString(36)}`;
|
|
691
|
-
for (const { pageIndex: l, page: f } of qt(e, t, r)) {
|
|
692
|
-
G(r.signal);
|
|
693
|
-
const u = Ut(f), g = f.components.filter(Q);
|
|
694
|
-
let h = [];
|
|
695
|
-
const m = (v = !1) => {
|
|
696
|
-
if (G(r.signal), r.maxPages !== void 0 && i >= r.maxPages) throw new N(r.maxPages, i + 1);
|
|
697
|
-
if (r.maxCells !== void 0 && (c += [...u.components, ...g].reduce((S, k) => S + _e(k), 0), c > r.maxCells))
|
|
698
|
-
throw new D(r.maxCells, c);
|
|
699
|
-
h.push(gr(f, u, g, ++i, v, a));
|
|
700
|
-
}, w = () => {
|
|
701
|
-
const v = h;
|
|
702
|
-
return h = [], v;
|
|
703
|
-
};
|
|
704
|
-
yield* pr({
|
|
705
|
-
templatePage: f,
|
|
706
|
-
current: u,
|
|
707
|
-
warnings: o,
|
|
708
|
-
nextId: d,
|
|
709
|
-
pushCurrent: m,
|
|
710
|
-
takePages: w,
|
|
711
|
-
datasets: t,
|
|
712
|
-
signal: r.signal,
|
|
713
|
-
formula: r.formula,
|
|
714
|
-
prepared: n,
|
|
715
|
-
measurer: r.measurer ?? ke,
|
|
716
|
-
mmPerRow: r.mmPerRow ?? 0,
|
|
717
|
-
tableId: `table:${l}`
|
|
718
|
-
}), m(!0), yield* w();
|
|
719
|
-
}
|
|
720
|
-
}
|
|
721
|
-
function Zr(e, t, r = {}) {
|
|
722
|
-
he(r);
|
|
723
|
-
let o = 0;
|
|
724
|
-
for (const a of J(e, t, { ...r, onWarning: void 0 }, [])) o++;
|
|
725
|
-
return o;
|
|
726
|
-
}
|
|
727
|
-
function* wr(e, t, r = {}) {
|
|
728
|
-
he(r);
|
|
729
|
-
const o = mr(e), a = /* @__PURE__ */ new WeakMap();
|
|
730
|
-
let n = r.knownTotalPages;
|
|
731
|
-
if (o && n === void 0) {
|
|
732
|
-
n = 0;
|
|
733
|
-
for (const c of J(e, t, r, [], void 0, a)) n++;
|
|
734
|
-
}
|
|
735
|
-
const s = [];
|
|
736
|
-
let i = 0;
|
|
737
|
-
for (const c of J(e, t, r, s, n, a)) {
|
|
738
|
-
for (; i < s.length; i++) r.onWarning?.(s[i]);
|
|
739
|
-
yield c;
|
|
740
|
-
}
|
|
741
|
-
}
|
|
742
|
-
function Je(e, t, r = {}) {
|
|
743
|
-
const o = typeof r == "number" ? { mmPerRow: r } : r;
|
|
744
|
-
he(o);
|
|
745
|
-
const a = [], n = [...J(e, t, o, a, o.knownTotalPages)];
|
|
746
|
-
for (const s of n) s.components = s.components.map((i) => Q(i) ? Z(i, (c) => c.replace(/\{totalPages\}/g, String(n.length))) : i);
|
|
747
|
-
return a.forEach((s) => o.onWarning?.(s)), { plan: { schemaVersion: z, ...U(e) ? { requiresRecalculation: !0 } : {}, pages: n }, warnings: a };
|
|
748
|
-
}
|
|
749
|
-
function yr(e) {
|
|
750
|
-
const t = e.columns.find((n) => !n.hidden)?.field;
|
|
751
|
-
if (!t) return { groups: 0, total: 0 };
|
|
752
|
-
const r = Y(e), o = (n = [], s = []) => n.includes(t) || s.some((i) => i.field === t), a = typeof e.grandTotal == "object" ? e.grandTotal : void 0;
|
|
753
|
-
return { groups: r.filter((n) => o(n.subtotal, n.aggregates)).length, total: Number(o(a?.fields ?? r[0]?.subtotal, a?.aggregates ?? r[0]?.aggregates)) };
|
|
754
|
-
}
|
|
755
|
-
function br(e, t, r) {
|
|
756
|
-
Ge(e);
|
|
757
|
-
const o = Oe(t[e.dataset] ?? [], e.tree, r), a = e.columns.filter((s) => !s.hidden).length, n = e.header === !1 ? 0 : e.headerGrid ? ge(e.headerGrid) : a;
|
|
758
|
-
return o.length * a + n + +!!e.grandTotal * 2 * a;
|
|
759
|
-
}
|
|
760
|
-
function eo(e, t, r = {}) {
|
|
761
|
-
if (e.tree) return br(e, t, r.signal);
|
|
762
|
-
if (e.matrix) {
|
|
763
|
-
let c = t[e.dataset] ?? [];
|
|
764
|
-
e.computed?.length && (c = Ce(c, { fields: e.computed, ...r }).rows), e.rowVisibleWhen && (c = c.filter((l) => L(l, e.rowVisibleWhen)));
|
|
765
|
-
const d = Mt(c, e.matrix);
|
|
766
|
-
return d.cells + d.columnCount;
|
|
767
|
-
}
|
|
768
|
-
const o = t[e.dataset]?.length ?? 0, a = e.columns.filter((c) => !c.hidden).length, n = Y(e).length, s = yr(e);
|
|
769
|
-
let i = (o * (1 + 2 * n + s.groups) + +!!e.grandTotal * (1 + s.total)) * a;
|
|
770
|
-
if (i += e.header === !1 ? 0 : e.headerGrid ? ge(e.headerGrid) : a, e.cardinality === "record" && o === 0 && (i += a), e.detail) {
|
|
771
|
-
const c = t[e.detail.dataset]?.length ?? 0, d = e.detail.columns.filter((l) => !l.hidden).length;
|
|
772
|
-
i += (c + o * (+(e.detail.header !== !1) + +!!e.detail.label)) * d;
|
|
773
|
-
}
|
|
774
|
-
if (!Number.isSafeInteger(i)) throw new RangeError("报表单元格估算超出安全整数预算");
|
|
775
|
-
return i;
|
|
776
|
-
}
|
|
777
|
-
function ze(e) {
|
|
778
|
-
const t = [];
|
|
779
|
-
for (const r of e.template.pages) for (const o of r.components)
|
|
780
|
-
o.kind === "list" && (t.push(o.tree ? { ...o, rowKey: o.tree.idField } : o), o.detail && t.push({ ...o.detail, relation: { detail: o.detail, parentRows: e.datasets[o.dataset] ?? [] } }));
|
|
781
|
-
return t;
|
|
782
|
-
}
|
|
783
|
-
function H(e) {
|
|
784
|
-
return JSON.stringify([e.sourceScope, e.datasetId]);
|
|
785
|
-
}
|
|
786
|
-
function ve(e) {
|
|
787
|
-
return JSON.stringify([e.sourceScope, e.datasetId, e.rowKey]);
|
|
788
|
-
}
|
|
789
|
-
function qe(e) {
|
|
790
|
-
const t = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Set();
|
|
791
|
-
return e.forEach((o, a) => {
|
|
792
|
-
for (const n of ze(o)) {
|
|
793
|
-
if (!n.rowKey) continue;
|
|
794
|
-
const s = n.relation, i = s ? new Set(s.parentRows.map((c) => JSON.stringify(c[s.detail.parentKey]))) : void 0;
|
|
795
|
-
(o.datasets[n.dataset] ?? []).forEach((c, d) => {
|
|
796
|
-
if (s && !i.has(JSON.stringify(c[s.detail.foreignKey]))) return;
|
|
797
|
-
const l = c[n.rowKey];
|
|
798
|
-
if (typeof l != "string" && typeof l != "number") return;
|
|
799
|
-
const f = `${a}:${n.dataset}:${d}:${n.rowKey}`;
|
|
800
|
-
if (r.has(f)) return;
|
|
801
|
-
r.add(f);
|
|
802
|
-
const u = ve({ sourceScope: o.sourceScope, datasetId: n.dataset, rowKey: l }), g = t.get(u) ?? [];
|
|
803
|
-
g.push({ partIndex: a, dataset: n.dataset, rowIndex: d, row: c, binding: n }), t.set(u, g);
|
|
804
|
-
});
|
|
805
|
-
}
|
|
806
|
-
}), (o) => {
|
|
807
|
-
const a = t.get(ve(o));
|
|
808
|
-
if (!a?.length) throw new P("missing");
|
|
809
|
-
if (new Set(a.map((n) => `${n.partIndex}:${n.dataset}`)).size !== a.length) throw new P("conflict");
|
|
810
|
-
return a;
|
|
811
|
-
};
|
|
812
|
-
}
|
|
813
|
-
function Ue(e, t) {
|
|
814
|
-
const r = e.map((a) => ({ ...a, datasets: { ...a.datasets } })), o = /* @__PURE__ */ new Set();
|
|
815
|
-
for (const { row: a, field: n, value: s } of t) {
|
|
816
|
-
const i = r[a.partIndex], c = `${a.partIndex}:${a.dataset}`;
|
|
817
|
-
o.has(c) || (i.datasets[a.dataset] = [...i.datasets[a.dataset]], o.add(c)), i.datasets[a.dataset][a.rowIndex] = { ...i.datasets[a.dataset][a.rowIndex], [n]: s };
|
|
818
|
-
}
|
|
819
|
-
return r;
|
|
820
|
-
}
|
|
821
|
-
function Mr(e, t, r) {
|
|
822
|
-
const o = [], a = /* @__PURE__ */ new Set();
|
|
823
|
-
return e.forEach((n, s) => {
|
|
824
|
-
for (const i of ze(n))
|
|
825
|
-
t.has(H({ sourceScope: n.sourceScope, datasetId: i.dataset })) && (n.datasets[i.dataset] ?? []).forEach((c, d) => {
|
|
826
|
-
const l = { partIndex: s, dataset: i.dataset, rowIndex: d, row: c, binding: i };
|
|
827
|
-
for (const [f, u] of [[i.revisionField, r.revision], [i.sourceTokenField, r.sourceToken]]) {
|
|
828
|
-
if (!f || u === void 0) continue;
|
|
829
|
-
const g = `${s}:${i.dataset}:${d}:${f}`;
|
|
830
|
-
a.has(g) || (a.add(g), o.push({ row: l, field: f, value: u }));
|
|
831
|
-
}
|
|
832
|
-
});
|
|
833
|
-
}), o;
|
|
834
|
-
}
|
|
835
|
-
function vr(e, t, r) {
|
|
836
|
-
if (!r || r.revision === void 0 && r.sourceToken === void 0) return e;
|
|
837
|
-
const o = new Set(t.edits.flatMap((a) => a.source ? [H(a.source)] : []));
|
|
838
|
-
return Xe(e, new Map([...o].map((a) => [a, r])));
|
|
839
|
-
}
|
|
840
|
-
function Xe(e, t) {
|
|
841
|
-
if (!t.size) return e;
|
|
842
|
-
function r(n) {
|
|
843
|
-
const s = n.datasetId && t.get(H({ ...n, datasetId: n.datasetId }));
|
|
844
|
-
return !s || (s.revision === void 0 || Object.is(s.revision, n.revision)) && (s.sourceToken === void 0 || s.sourceToken === n.sourceToken) ? n : { ...n, ...s.revision !== void 0 ? { revision: s.revision } : {}, ...s.sourceToken !== void 0 ? { sourceToken: s.sourceToken } : {} };
|
|
845
|
-
}
|
|
846
|
-
function o(n) {
|
|
847
|
-
const s = n.map((i) => {
|
|
848
|
-
const c = i.table?.source ? r(i.table.source) : void 0, d = i.table && c !== i.table.source ? { ...i.table, source: c } : i.table, l = i.grid?.cells.map((u) => {
|
|
849
|
-
const g = u.map((h) => {
|
|
850
|
-
if (!h) return h;
|
|
851
|
-
const m = h.source ? r(h.source) : void 0, w = h.children ? o(h.children) : void 0;
|
|
852
|
-
return m === h.source && w === h.children ? h : { ...h, source: m, children: w };
|
|
853
|
-
});
|
|
854
|
-
return g.some((h, m) => h !== u[m]) ? g : u;
|
|
855
|
-
}), f = i.grid && l?.some((u, g) => u !== i.grid.cells[g]) ? { ...i.grid, cells: l } : i.grid;
|
|
856
|
-
return d !== i.table || f !== i.grid ? { ...i, table: d, grid: f } : i;
|
|
857
|
-
});
|
|
858
|
-
return s.some((i, c) => i !== n[c]) ? s : n;
|
|
859
|
-
}
|
|
860
|
-
const a = e.pages.map((n) => {
|
|
861
|
-
const s = o(n.components);
|
|
862
|
-
return s !== n.components ? { ...n, components: s } : n;
|
|
863
|
-
});
|
|
864
|
-
return a.some((n, s) => n !== e.pages[s]) ? { ...e, pages: a } : e;
|
|
865
|
-
}
|
|
866
|
-
function Ye(e) {
|
|
867
|
-
const t = /* @__PURE__ */ new Map(), r = le(e);
|
|
868
|
-
return e.pages.forEach((o, a) => o.components.forEach((n, s) => {
|
|
869
|
-
if (!(!n.grid || n.table?.role !== "body"))
|
|
870
|
-
for (let i = 0; i < n.grid.cells.length; i++) for (let c = 0; c < n.table.columnKeys.length; c++) {
|
|
871
|
-
const d = r({ pageIndex: a, componentIndex: s, rowIndex: i, columnIndex: c });
|
|
872
|
-
d?.source && d.editable && t.set(j(d), d);
|
|
873
|
-
}
|
|
874
|
-
})), t;
|
|
875
|
-
}
|
|
876
|
-
function to(e, t, r) {
|
|
877
|
-
const o = Ye(e), a = le(e);
|
|
878
|
-
return t.map((n) => {
|
|
879
|
-
const s = n.source ? o.get(j(n)) : a(n.address);
|
|
880
|
-
if (!s || j(s) !== j(n)) throw new P("missing");
|
|
881
|
-
return { address: { ...s.address }, value: n[r] };
|
|
882
|
-
});
|
|
883
|
-
}
|
|
884
|
-
function Qe(e, t) {
|
|
885
|
-
if (++e.nodes > 1e6 || t > 128) throw new P("limit");
|
|
886
|
-
}
|
|
887
|
-
function pe(e, t) {
|
|
888
|
-
const r = Object.getOwnPropertyDescriptor(e, t);
|
|
889
|
-
if (!r || r.get || r.set) throw new P("conflict");
|
|
890
|
-
return r.value;
|
|
891
|
-
}
|
|
892
|
-
function Ze(e) {
|
|
893
|
-
if (Object.getOwnPropertyDescriptor(e, "toJSON")) throw new P("conflict");
|
|
894
|
-
const t = Object.getPrototypeOf(e);
|
|
895
|
-
if (!(e instanceof Date) && !Array.isArray(e) && t !== Object.prototype && t !== null) throw new P("conflict");
|
|
896
|
-
for (const r of Reflect.ownKeys(e))
|
|
897
|
-
if (!(Array.isArray(e) && r === "length")) {
|
|
898
|
-
if (typeof r == "symbol" || !Object.getOwnPropertyDescriptor(e, r)?.enumerable) throw new P("conflict");
|
|
899
|
-
if (e instanceof Date || Array.isArray(e) && !/^(0|[1-9]\d*)$/.test(r)) throw new P("conflict");
|
|
900
|
-
}
|
|
901
|
-
}
|
|
902
|
-
function et(e, t, r, o, a) {
|
|
903
|
-
if (Qe(o, a), typeof e == "function" || typeof e == "symbol") throw new P("conflict");
|
|
904
|
-
if (e === null || typeof e != "object") return;
|
|
905
|
-
if (Ze(e), r.has(e)) throw new P("conflict");
|
|
906
|
-
r.add(e);
|
|
907
|
-
const n = Object.keys(e), s = n.map((i) => pe(e, i));
|
|
908
|
-
t.push({
|
|
909
|
-
object: e,
|
|
910
|
-
prototype: Object.getPrototypeOf(e),
|
|
911
|
-
keys: n,
|
|
912
|
-
values: s,
|
|
913
|
-
...e instanceof Date ? { date: Date.prototype.getTime.call(e) } : {},
|
|
914
|
-
...Array.isArray(e) ? { length: e.length } : {}
|
|
915
|
-
});
|
|
916
|
-
for (const i of s) et(i, t, r, o, a + 1);
|
|
917
|
-
r.delete(e);
|
|
918
|
-
}
|
|
919
|
-
function Sr(e) {
|
|
920
|
-
const { object: t, keys: r, values: o } = e;
|
|
921
|
-
if (Ze(t), Object.getPrototypeOf(t) !== e.prototype || Object.getOwnPropertyDescriptor(t, "toJSON") || e.date !== void 0 && !Object.is(Date.prototype.getTime.call(t), e.date) || e.length !== void 0 && t.length !== e.length) return !1;
|
|
922
|
-
const a = Object.keys(t);
|
|
923
|
-
return a.length === r.length && r.every((n, s) => a[s] === n && Object.is(pe(t, n), o[s]));
|
|
924
|
-
}
|
|
925
|
-
function Pr(e) {
|
|
926
|
-
const t = [];
|
|
927
|
-
return et(e, t, /* @__PURE__ */ new Set(), { nodes: 0 }, 0), () => {
|
|
928
|
-
try {
|
|
929
|
-
return t.every(Sr);
|
|
930
|
-
} catch {
|
|
931
|
-
return !1;
|
|
932
|
-
}
|
|
933
|
-
};
|
|
934
|
-
}
|
|
935
|
-
function ae(e, t, r) {
|
|
936
|
-
return Qe(t, r), e === null || typeof e != "object" ? e : e instanceof Date ? new Date(Date.prototype.getTime.call(e)) : Array.isArray(e) ? e.map((o) => ae(o, t, r + 1)) : Object.fromEntries(Object.keys(e).map((o) => [o, ae(pe(e, o), t, r + 1)]));
|
|
937
|
-
}
|
|
938
|
-
function Tr(e) {
|
|
939
|
-
return ae(e, { nodes: 0 }, 0);
|
|
940
|
-
}
|
|
941
|
-
async function tt(e, t, r = {}) {
|
|
942
|
-
const o = [], a = { ...r, knownTotalPages: void 0 };
|
|
943
|
-
for (const n of wr(e, t, a))
|
|
944
|
-
o.push(n), o.length % 8 === 0 && await new Promise((s) => setTimeout(s, 0));
|
|
945
|
-
if (r.signal?.aborted) {
|
|
946
|
-
const n = new Error("报表重算已取消");
|
|
947
|
-
throw n.name = "AbortError", n;
|
|
948
|
-
}
|
|
949
|
-
return { schemaVersion: z, ...U(e) ? { requiresRecalculation: !0 } : {}, pages: o };
|
|
950
|
-
}
|
|
951
|
-
const se = /* @__PURE__ */ new WeakMap();
|
|
952
|
-
function ro(e) {
|
|
953
|
-
return se.get(e);
|
|
954
|
-
}
|
|
955
|
-
function V(e) {
|
|
956
|
-
if (e?.aborted) {
|
|
957
|
-
const t = new Error("报表重算已取消");
|
|
958
|
-
throw t.name = "AbortError", t;
|
|
959
|
-
}
|
|
960
|
-
}
|
|
961
|
-
function rt(e, t) {
|
|
962
|
-
return e[t] === void 0 ? "" : e[t];
|
|
963
|
-
}
|
|
964
|
-
function kr(e, t) {
|
|
965
|
-
if (t.edits.length > 1e4) throw new P("limit");
|
|
966
|
-
const r = le(e), o = /* @__PURE__ */ new Set(), a = [], n = t.edits.map((s) => {
|
|
967
|
-
const i = r(s.address);
|
|
968
|
-
if (!i?.source) throw new P("missing");
|
|
969
|
-
const c = j(s);
|
|
970
|
-
if (o.has(c)) throw new P("duplicate");
|
|
971
|
-
if (o.add(c), Ft(i, s) || !Object.is(i.value, s.previousValue) || (i.cell.text ?? "") !== s.previousText) throw new P("conflict");
|
|
972
|
-
return a.push(i), Ae(i, s.value);
|
|
973
|
-
});
|
|
974
|
-
return { batch: { requestId: t.requestId, edits: n }, contexts: a };
|
|
975
|
-
}
|
|
976
|
-
function $r(e, t) {
|
|
977
|
-
const r = qe(e);
|
|
978
|
-
return t.flatMap((o) => {
|
|
979
|
-
if (!o.source) throw new P("missing");
|
|
980
|
-
return r(o.source).map((a) => {
|
|
981
|
-
if (!Object.is(rt(a.row, o.source.field), o.previousValue)) throw new P("conflict");
|
|
982
|
-
if (a.binding.rowKey === o.source.field) throw new P("readonly");
|
|
983
|
-
return { row: a, field: o.source.field, value: o.value };
|
|
984
|
-
});
|
|
985
|
-
});
|
|
986
|
-
}
|
|
987
|
-
function oe(e, t, r) {
|
|
988
|
-
const o = { ...e, value: t, source: { ...e.source, ...r?.revision === void 0 ? {} : { revision: r.revision }, ...r?.sourceToken === void 0 ? {} : { sourceToken: r.sourceToken } } };
|
|
989
|
-
return o.cell = { ...e.cell, value: o.value, text: Ot(o, o.value) }, o;
|
|
990
|
-
}
|
|
991
|
-
function Rr(e, t, r) {
|
|
992
|
-
if (!r || r.revision === void 0 && r.sourceToken === void 0) return [...e];
|
|
993
|
-
const o = new Set(t.edits.flatMap((a) => a.source ? [H(a.source)] : []));
|
|
994
|
-
return Ue(e, Mr(e, o, r));
|
|
995
|
-
}
|
|
996
|
-
function Er(e, t, r) {
|
|
997
|
-
const o = new Set(t.edits.map((a) => H(a.source)));
|
|
998
|
-
for (const a of o) e.set(a, {
|
|
999
|
-
...e.get(a),
|
|
1000
|
-
...r.revision !== void 0 ? { revision: r.revision } : {},
|
|
1001
|
-
...r.sourceToken !== void 0 ? { sourceToken: r.sourceToken } : {}
|
|
1002
|
-
});
|
|
1003
|
-
return o;
|
|
1004
|
-
}
|
|
1005
|
-
function ot(e, t) {
|
|
1006
|
-
let r = t.parts;
|
|
1007
|
-
const o = t.rebuild;
|
|
1008
|
-
let a = Pr(r), n = e, s;
|
|
1009
|
-
const i = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map();
|
|
1010
|
-
function d(u) {
|
|
1011
|
-
if (u !== n) throw new P("conflict");
|
|
1012
|
-
if (s) return s;
|
|
1013
|
-
if (!a?.()) throw new P("conflict");
|
|
1014
|
-
return Tr(r);
|
|
1015
|
-
}
|
|
1016
|
-
async function l(u, g, h, m = {}) {
|
|
1017
|
-
V(m.signal), g = { requestId: g.requestId, edits: g.edits.map((b) => ({ ...b, address: { ...b.address }, source: b.source ? { ...b.source } : void 0, table: b.table ? { ...b.table } : void 0 })) }, h = h.map((b) => ({ ...b, address: { ...b.address }, source: b.source ? { ...b.source } : void 0, table: b.table ? { ...b.table } : void 0, cell: { ...b.cell } })), await new Promise((b) => setTimeout(b, 0)), V(m.signal);
|
|
1018
|
-
const w = d(u), v = Ue(w, $r(w, g.edits)), S = Xe(await o(v, m.signal), c);
|
|
1019
|
-
V(m.signal);
|
|
1020
|
-
let k = !1;
|
|
1021
|
-
return { plan: S, commit(b) {
|
|
1022
|
-
if (V(m.signal), k || n !== u) throw new P("conflict");
|
|
1023
|
-
if (b?.conflicts?.length) throw new P("conflict");
|
|
1024
|
-
const A = Rr(v, g, b), O = vr(S, g, b);
|
|
1025
|
-
if (b) {
|
|
1026
|
-
const x = Er(c, g, b);
|
|
1027
|
-
for (const [p, y] of i) x.has(H(y.source)) && i.set(p, oe(y, y.value, b));
|
|
1028
|
-
}
|
|
1029
|
-
return h.forEach((x, p) => i.set(j(x), oe(x, g.edits[p].value, b))), k = !0, s = A, r = void 0, a = void 0, n = O, se.set(n, f), n;
|
|
1030
|
-
} };
|
|
1031
|
-
}
|
|
1032
|
-
const f = {
|
|
1033
|
-
get plan() {
|
|
1034
|
-
return n;
|
|
1035
|
-
},
|
|
1036
|
-
async prepare(u, g, h) {
|
|
1037
|
-
const m = kr(u, g);
|
|
1038
|
-
return l(u, m.batch, m.contexts, h);
|
|
1039
|
-
},
|
|
1040
|
-
async prepareHistory(u, g, h, m, w) {
|
|
1041
|
-
if (!m.trim() || g.length > 1e4) throw new P("limit");
|
|
1042
|
-
const v = d(u), S = qe(v), k = Ye(u), b = /* @__PURE__ */ new Set(), O = g.map((y) => {
|
|
1043
|
-
if (!y.source) throw new P("missing");
|
|
1044
|
-
const M = j(y);
|
|
1045
|
-
if (b.has(M)) throw new P("duplicate");
|
|
1046
|
-
b.add(M);
|
|
1047
|
-
const $ = k.get(M) ?? i.get(M);
|
|
1048
|
-
if (!$?.source) throw new P("missing");
|
|
1049
|
-
const R = S($.source)[0];
|
|
1050
|
-
return oe($, rt(R.row, $.source.field));
|
|
1051
|
-
}).map((y, M) => ({ context: y, edit: Ae(y, g[M][h]) })).filter(({ edit: y }) => !Object.is(y.previousValue, y.value)), x = { requestId: m, edits: O.map(({ edit: y }) => y) }, p = O.map(({ context: y }) => y);
|
|
1052
|
-
return { batch: x, contexts: p, prepared: await l(u, x, p, w) };
|
|
1053
|
-
}
|
|
1054
|
-
};
|
|
1055
|
-
return se.set(e, f), f;
|
|
1056
|
-
}
|
|
1057
|
-
function oo(e) {
|
|
1058
|
-
const t = Je(e.template, e.datasets, e.pagination).plan;
|
|
1059
|
-
return ot(t, { parts: [{ template: e.template, datasets: e.datasets }], rebuild: (r, o) => tt(r[0].template, r[0].datasets, { ...e.pagination, signal: o }) });
|
|
1060
|
-
}
|
|
1061
|
-
let xr = 0;
|
|
1062
|
-
function Cr() {
|
|
1063
|
-
return `report-${Date.now()}-${++xr}`;
|
|
1064
|
-
}
|
|
1065
|
-
function Se(e, t, r) {
|
|
1066
|
-
if (!r?.aborted)
|
|
1067
|
-
try {
|
|
1068
|
-
const o = e?.({ ...t });
|
|
1069
|
-
o && typeof o.then == "function" && Promise.resolve(o).catch(() => {
|
|
1070
|
-
});
|
|
1071
|
-
} catch {
|
|
1072
|
-
}
|
|
1073
|
-
}
|
|
1074
|
-
function Or(e) {
|
|
1075
|
-
const t = e.taskId ?? Cr(), r = (o, a, n) => {
|
|
1076
|
-
Se(e.onEvent, { taskId: t, ...e.correlationId === void 0 ? {} : { correlationId: e.correlationId }, stage: o, status: a, ...n === void 0 ? {} : { reportId: n } }, e.signal);
|
|
1077
|
-
};
|
|
1078
|
-
return {
|
|
1079
|
-
taskId: t,
|
|
1080
|
-
progress(o, a, n) {
|
|
1081
|
-
Se(e.onEvent, { taskId: t, ...e.correlationId === void 0 ? {} : { correlationId: e.correlationId }, stage: o, status: "started", completed: a, total: n }, e.signal);
|
|
1082
|
-
},
|
|
1083
|
-
async run(o, a, n) {
|
|
1084
|
-
r(o, "started", n);
|
|
1085
|
-
try {
|
|
1086
|
-
const s = await a();
|
|
1087
|
-
return r(o, "completed", n), s;
|
|
1088
|
-
} catch (s) {
|
|
1089
|
-
throw r(o, "failed", n), s;
|
|
1090
|
-
}
|
|
1091
|
-
},
|
|
1092
|
-
runSync(o, a, n) {
|
|
1093
|
-
r(o, "started", n);
|
|
1094
|
-
try {
|
|
1095
|
-
const s = a();
|
|
1096
|
-
return r(o, "completed", n), s;
|
|
1097
|
-
} catch (s) {
|
|
1098
|
-
throw r(o, "failed", n), s;
|
|
1099
|
-
}
|
|
1100
|
-
}
|
|
1101
|
-
};
|
|
1102
|
-
}
|
|
1103
|
-
function nt(e, t, r = {}) {
|
|
1104
|
-
const o = /* @__PURE__ */ new Map();
|
|
1105
|
-
for (const n of e.pages) for (const s of n.components) {
|
|
1106
|
-
if (s.kind !== "list" || s.tree?.input !== "nested") continue;
|
|
1107
|
-
const i = o.get(s.dataset);
|
|
1108
|
-
if (i && (i.childrenField ?? "children") !== (s.tree.childrenField ?? "children")) throw new Error("同一数据集的嵌套树应使用相同 childrenField");
|
|
1109
|
-
o.set(s.dataset, s.tree);
|
|
1110
|
-
}
|
|
1111
|
-
if (!o.size) return t;
|
|
1112
|
-
const a = { ...t };
|
|
1113
|
-
for (const [n, s] of o) {
|
|
1114
|
-
const i = Math.min(s.maxRows ?? 1e5, r.maxRows ?? 1 / 0);
|
|
1115
|
-
a[n] = Oe(t[n] ?? [], { ...s, maxRows: i }, r.signal);
|
|
1116
|
-
}
|
|
1117
|
-
return a;
|
|
1118
|
-
}
|
|
1119
|
-
function no(e, t, r = {}) {
|
|
1120
|
-
return Object.values(nt(e, t, r)).reduce((o, a) => o + a.length, 0);
|
|
1121
|
-
}
|
|
1122
|
-
function ao(e, t, r) {
|
|
1123
|
-
const o = It(r), a = e?.pages.flatMap((i) => i.components).find((i) => i.kind === "list" && i.dataset === t && i.tree?.input === "nested");
|
|
1124
|
-
if (!a || a.kind !== "list" || !a.tree) return o;
|
|
1125
|
-
const n = o.items, s = a.tree.childrenField ?? "children";
|
|
1126
|
-
return { ...o, items: { $ref: "#/$defs/treeNode" }, $defs: { treeNode: { ...n, properties: { ...n.properties, [s]: { anyOf: [{ type: "null" }, { type: "array", items: { $ref: "#/$defs/treeNode" } }] } } } } };
|
|
1127
|
-
}
|
|
1128
|
-
function at(e, t) {
|
|
1129
|
-
return JSON.stringify([e, t]);
|
|
1130
|
-
}
|
|
1131
|
-
function st(e, t, r) {
|
|
1132
|
-
return r === void 0 ? at(e, t) : JSON.stringify(["shared", r]);
|
|
1133
|
-
}
|
|
1134
|
-
function it(e, t, r) {
|
|
1135
|
-
return e.map((o) => {
|
|
1136
|
-
const a = o.table ? {
|
|
1137
|
-
...o.table,
|
|
1138
|
-
id: r(o.table.id),
|
|
1139
|
-
...o.table.source ? { source: { ...o.table.source, sourceScope: t } } : {}
|
|
1140
|
-
} : void 0, n = o.grid?.cells.map((s) => s.map((i) => !i || !i.source && !i.children ? i : {
|
|
1141
|
-
...i,
|
|
1142
|
-
...i.source ? { source: { ...i.source, sourceScope: t } } : {},
|
|
1143
|
-
...i.children ? { children: it(i.children, t, r) } : {}
|
|
1144
|
-
}));
|
|
1145
|
-
return a || n ? {
|
|
1146
|
-
...o,
|
|
1147
|
-
...a ? { table: a } : {},
|
|
1148
|
-
...n ? { grid: { ...o.grid, cells: n } } : {}
|
|
1149
|
-
} : o;
|
|
1150
|
-
});
|
|
1151
|
-
}
|
|
1152
|
-
function so(e) {
|
|
1153
|
-
if (!("mapData" in e)) return e;
|
|
1154
|
-
const { load: t, mapData: r, ...o } = e;
|
|
1155
|
-
return { ...o, load: async (a) => {
|
|
1156
|
-
const n = await t(a);
|
|
1157
|
-
E(a.signal);
|
|
1158
|
-
try {
|
|
1159
|
-
return r(n, a);
|
|
1160
|
-
} catch (s) {
|
|
1161
|
-
throw new T("validate", `报表 ${a.reportId} 数据映射失败`, s);
|
|
1162
|
-
}
|
|
1163
|
-
} };
|
|
1164
|
-
}
|
|
1165
|
-
class T extends Error {
|
|
1166
|
-
constructor(t, r, o) {
|
|
1167
|
-
super(r), this.name = "ReportSourceError", this.code = t, this.cause = o;
|
|
1168
|
-
}
|
|
1169
|
-
}
|
|
1170
|
-
function ee(e) {
|
|
1171
|
-
const t = new Error("报表加载已取消");
|
|
1172
|
-
return t.name = "AbortError", Object.defineProperty(t, "cause", { value: e.reason }), t;
|
|
1173
|
-
}
|
|
1174
|
-
function E(e) {
|
|
1175
|
-
if (e?.aborted) throw ee(e);
|
|
1176
|
-
}
|
|
1177
|
-
function ie(e, t) {
|
|
1178
|
-
return t ? new Promise((r, o) => {
|
|
1179
|
-
const a = () => t.removeEventListener("abort", n), n = () => {
|
|
1180
|
-
a(), o(ee(t));
|
|
1181
|
-
};
|
|
1182
|
-
t.addEventListener("abort", n, { once: !0 }), t.aborted && n(), Promise.resolve(e).then(
|
|
1183
|
-
(s) => {
|
|
1184
|
-
a(), r(s);
|
|
1185
|
-
},
|
|
1186
|
-
(s) => {
|
|
1187
|
-
a(), o(s);
|
|
1188
|
-
}
|
|
1189
|
-
);
|
|
1190
|
-
}) : Promise.resolve(e);
|
|
1191
|
-
}
|
|
1192
|
-
function Fr(e, t) {
|
|
1193
|
-
if (!e || typeof e != "object" || Array.isArray(e))
|
|
1194
|
-
throw new T("validate", `报表 ${t} 的数据集应为对象`);
|
|
1195
|
-
for (const [r, o] of Object.entries(e))
|
|
1196
|
-
if (!Array.isArray(o) || o.some((a) => !a || typeof a != "object" || Array.isArray(a)))
|
|
1197
|
-
throw new T("validate", `报表 ${t} 的数据集 ${r} 应为对象数组`);
|
|
1198
|
-
}
|
|
1199
|
-
async function Ar(e, t, r) {
|
|
1200
|
-
const { reportId: o, signal: a } = t;
|
|
1201
|
-
try {
|
|
1202
|
-
const n = await ie(e(t), a);
|
|
1203
|
-
E(a);
|
|
1204
|
-
const s = Rt(n);
|
|
1205
|
-
if (!s.ok)
|
|
1206
|
-
throw new T("validate", `报表 ${o} 模板校验失败:${s.errors.slice(0, 3).map((i) => `${i.path}: ${i.message}`).join("; ")}`);
|
|
1207
|
-
return r.push(...s.warnings.map((i) => `${o}: ${i.path}: ${i.message}`)), n;
|
|
1208
|
-
} catch (n) {
|
|
1209
|
-
throw a?.aborted ? ee(a) : n instanceof T ? n : n instanceof Et ? new T("validate", `报表 ${o} 模板校验失败:${n.message}`, n) : new T("fetch", `报表 ${o} 模板加载失败:${n instanceof Error ? n.message : String(n)}`, n);
|
|
1210
|
-
}
|
|
1211
|
-
}
|
|
1212
|
-
async function Ir(e, t, r, o) {
|
|
1213
|
-
const a = t.signal;
|
|
1214
|
-
let n;
|
|
1215
|
-
try {
|
|
1216
|
-
if (e.load) n = await ie(e.load(t), a);
|
|
1217
|
-
else if (e.provider) {
|
|
1218
|
-
const s = await ie(e.provider.query(t), a);
|
|
1219
|
-
E(a), jr(s, r), n = s.datasets, o?.(r, s);
|
|
1220
|
-
} else n = e.datasets ?? {};
|
|
1221
|
-
} catch (s) {
|
|
1222
|
-
throw a?.aborted ? ee(a) : s instanceof T ? s : new T("fetch", `报表 ${r} 取数失败:${s instanceof Error ? s.message : String(s)}`, s);
|
|
1223
|
-
}
|
|
1224
|
-
return E(a), n;
|
|
1225
|
-
}
|
|
1226
|
-
function jr(e, t) {
|
|
1227
|
-
if (!e || typeof e != "object" || Array.isArray(e)) throw new T("validate", `报表 ${t} Provider 应返回 datasets 结果对象`);
|
|
1228
|
-
for (const r of ["revision", "sourceToken"])
|
|
1229
|
-
if (e[r] !== void 0 && typeof e[r] != "string") throw new T("validate", `报表 ${t} Provider ${r} 应为字符串`);
|
|
1230
|
-
if (e.diagnostics !== void 0 && (!Array.isArray(e.diagnostics) || e.diagnostics.some((r) => !r || typeof r.code != "string" || typeof r.message != "string" || !["info", "warning", "error"].includes(r.severity))))
|
|
1231
|
-
throw new T("validate", `报表 ${t} Provider diagnostics 不符合结构化诊断契约`);
|
|
1232
|
-
if (e.diagnostics?.some((r) => !At(r)))
|
|
1233
|
-
throw new T("validate", `报表 ${t} Provider 数据说明缺少有效的字段身份或值状态`);
|
|
1234
|
-
}
|
|
1235
|
-
function Nr(e, t, r, o, a) {
|
|
1236
|
-
try {
|
|
1237
|
-
t = nt(o, t, { maxRows: e.dataValidation?.maxRows, signal: a });
|
|
1238
|
-
} catch (n) {
|
|
1239
|
-
throw new T("validate", `报表 ${r} 树形数据无效:${n instanceof Error ? n.message : String(n)}`, n);
|
|
1240
|
-
}
|
|
1241
|
-
for (const [n, s] of Object.entries(e.dataSchema ?? {})) {
|
|
1242
|
-
let i;
|
|
1243
|
-
try {
|
|
1244
|
-
i = jt(Object.prototype.hasOwnProperty.call(t, n) ? t[n] : void 0, s, { ...e.dataValidation, path: `$.datasets.${n}` });
|
|
1245
|
-
} catch (c) {
|
|
1246
|
-
throw new T("config", `报表 ${r} 数据集 ${n} 字段契约配置无效`, c);
|
|
1247
|
-
}
|
|
1248
|
-
if (!i.ok) throw new T("validate", `报表 ${r} 数据集 ${n} 不符合字段契约:${i.issues[0]?.message}`, { issues: i.issues });
|
|
1249
|
-
}
|
|
1250
|
-
}
|
|
1251
|
-
function ct(e, t) {
|
|
1252
|
-
if (!e.repeat) return !1;
|
|
1253
|
-
const r = Object.prototype.hasOwnProperty.call(t, e.repeat.dataset) ? t[e.repeat.dataset] : void 0;
|
|
1254
|
-
return Array.isArray(r) && r.length === 0;
|
|
1255
|
-
}
|
|
1256
|
-
function dt(e) {
|
|
1257
|
-
const t = (r) => r.grid?.cells.reduce((o, a) => o + a.reduce((n, s) => n + (s ? 1 + (s.children?.reduce((i, c) => i + t(c), 0) ?? 0) : 0), 0), 0) ?? 0;
|
|
1258
|
-
return e.pages.reduce((r, o) => r + o.components.reduce((a, n) => a + t(n), 0), 0);
|
|
1259
|
-
}
|
|
1260
|
-
function lt(e, t, r, o) {
|
|
1261
|
-
return {
|
|
1262
|
-
...e,
|
|
1263
|
-
signal: o ?? e?.signal,
|
|
1264
|
-
...t === void 0 ? {} : { maxPages: Math.max(1, Math.min(t, e?.maxPages ?? t)) },
|
|
1265
|
-
...r === void 0 ? {} : { maxCells: Math.max(1, Math.min(r, e?.maxCells ?? r)) }
|
|
1266
|
-
};
|
|
1267
|
-
}
|
|
1268
|
-
function Hr(e, t, r, o, a, n) {
|
|
1269
|
-
const s = a.maxPages === void 0 ? void 0 : a.maxPages - a.usedPages, i = a.maxCells === void 0 ? void 0 : a.maxCells - a.usedCells;
|
|
1270
|
-
try {
|
|
1271
|
-
if (s !== void 0 && s < 1 && e.pages.length && !ct(e, t)) throw new N(0, 1);
|
|
1272
|
-
const c = lt(r.pagination, s, i, n), d = Je(e, t, c), l = dt(d.plan);
|
|
1273
|
-
if (i !== void 0 && l > i) throw new D(i, l);
|
|
1274
|
-
return { ...d, cells: l };
|
|
1275
|
-
} catch (c) {
|
|
1276
|
-
let d = c;
|
|
1277
|
-
throw c instanceof N && a.maxPages !== void 0 && c.limit === s && (d = new N(a.maxPages, a.usedPages + c.actual)), c instanceof D && a.maxCells !== void 0 && (d = new D(a.maxCells, a.usedCells + c.actual)), new T("validate", `报表 ${o} 排版失败:${d instanceof Error ? d.message : String(d)}`, d);
|
|
1278
|
-
}
|
|
1279
|
-
}
|
|
1280
|
-
function ut(e, t, r, o, a) {
|
|
1281
|
-
const n = /* @__PURE__ */ new Map(), s = (i) => {
|
|
1282
|
-
let c = n.get(i);
|
|
1283
|
-
return c === void 0 && (c = JSON.stringify([r, o, i]), n.set(i, c)), c;
|
|
1284
|
-
};
|
|
1285
|
-
for (const i of t.pages) e.push({
|
|
1286
|
-
...i,
|
|
1287
|
-
meta: { ...i.meta, reportScope: at(r, o) },
|
|
1288
|
-
components: it(i.components, a ?? st(r, o), s)
|
|
1289
|
-
});
|
|
1290
|
-
}
|
|
1291
|
-
async function Lr(e, t, r, o, a) {
|
|
1292
|
-
const n = [];
|
|
1293
|
-
let s = 0;
|
|
1294
|
-
for (const [d, l] of e.entries()) {
|
|
1295
|
-
E(a);
|
|
1296
|
-
const f = o.maxPages === void 0 ? void 0 : o.maxPages - n.length, u = o.maxCells === void 0 ? void 0 : o.maxCells - s;
|
|
1297
|
-
if (f !== void 0 && f < 1 && l.template.pages.length && !ct(l.template, l.datasets)) throw new N(o.maxPages, n.length + 1);
|
|
1298
|
-
const g = await tt(l.template, l.datasets, lt(t[d]?.pagination, f, u, a));
|
|
1299
|
-
if (s += dt(g), o.maxCells !== void 0 && s > o.maxCells) throw new D(o.maxCells, s);
|
|
1300
|
-
ut(n, g, d, r[d], l.sourceScope);
|
|
1301
|
-
}
|
|
1302
|
-
const i = { schemaVersion: z, ...e.some((d) => U(d.template)) ? { requiresRecalculation: !0 } : {}, pages: n }, c = Fe(i);
|
|
1303
|
-
if (!c.ok) throw new T("validate", `重算渲染计划校验失败:${c.errors[0]?.message}`);
|
|
1304
|
-
return i;
|
|
1305
|
-
}
|
|
1306
|
-
function io(e, t = {}) {
|
|
1307
|
-
if (t.maxPages !== void 0 && (!Number.isSafeInteger(t.maxPages) || t.maxPages < 1)) throw new T("config", "maxPages 应为正安全整数");
|
|
1308
|
-
if (t.maxCells !== void 0 && (!Number.isSafeInteger(t.maxCells) || t.maxCells < 1)) throw new T("config", "maxCells 应为正安全整数");
|
|
1309
|
-
function r(a) {
|
|
1310
|
-
const n = Object.prototype.hasOwnProperty.call(e, a) ? e[a] : void 0;
|
|
1311
|
-
if (!n) throw new T("config", `未注册报表 ${a}`);
|
|
1312
|
-
if (n.sourceScope !== void 0 && (typeof n.sourceScope != "string" || !n.sourceScope.trim() || n.sourceScope.length > 512)) throw new T("config", "sourceScope 应为不超过 512 字符的非空字符串");
|
|
1313
|
-
return n;
|
|
1314
|
-
}
|
|
1315
|
-
return Object.assign(async ({ reportIds: a, params: n, signal: s, onWarning: i, onQueryResult: c, ...d }) => {
|
|
1316
|
-
E(s);
|
|
1317
|
-
const l = Or({ ...d, signal: s }), f = [...a], u = { ...n };
|
|
1318
|
-
if (f.length === 0) throw new T("config", "缺少报表 ID");
|
|
1319
|
-
const g = f.map(r), h = l.runSync("validate", () => g.map((p) => ye(
|
|
1320
|
-
p.params ?? (typeof p.template == "function" ? [] : p.template.params) ?? [],
|
|
1321
|
-
u
|
|
1322
|
-
))), m = [], w = [];
|
|
1323
|
-
let v = 0;
|
|
1324
|
-
const S = [];
|
|
1325
|
-
for (const [p, y] of g.entries()) {
|
|
1326
|
-
E(s);
|
|
1327
|
-
const M = f[p], $ = { reportId: M, params: h[p], signal: s }, R = typeof y.template == "function" ? await l.run("query", () => Ar(y.template, $, S), M) : y.template;
|
|
1328
|
-
$.params = l.runSync("validate", () => ye(y.params ?? R.params ?? [], $.params), M);
|
|
1329
|
-
const F = await l.run("query", () => Ir(y, $, M, (re, ft) => c?.(re, ft, p)), M);
|
|
1330
|
-
l.runSync("validate", () => {
|
|
1331
|
-
Fr(F, M), t.onDatasets?.(M, F, R), Nr(y, F, M, R, s);
|
|
1332
|
-
}, M), E(s);
|
|
1333
|
-
const te = l.runSync("layout", () => Hr(R, F, y, M, { maxPages: t.maxPages, usedPages: m.length, maxCells: t.maxCells, usedCells: v }, s), M);
|
|
1334
|
-
v += te.cells;
|
|
1335
|
-
const we = st(p, M, y.sourceScope);
|
|
1336
|
-
w.push({ template: R, datasets: F, sourceScope: we }), ut(m, te.plan, p, M, we), S.push(...te.warnings.map((re) => `${M}: ${re}`));
|
|
1337
|
-
}
|
|
1338
|
-
E(s);
|
|
1339
|
-
const k = { schemaVersion: z, ...w.some((p) => U(p.template)) ? { requiresRecalculation: !0 } : {}, pages: m }, b = l.runSync("validate", () => {
|
|
1340
|
-
const p = Fe(k);
|
|
1341
|
-
if (!p.ok) throw new T("validate", `渲染计划校验失败:${p.errors.slice(0, 3).map((y) => `${y.path}: ${y.message}`).join("; ")}`);
|
|
1342
|
-
return p;
|
|
1343
|
-
});
|
|
1344
|
-
S.push(...b.warnings.map((p) => `${p.path}: ${p.message}`));
|
|
1345
|
-
const A = g.map((p) => ({ ...p, pagination: { ...p.pagination } })), O = { maxPages: t.maxPages, maxCells: t.maxCells };
|
|
1346
|
-
try {
|
|
1347
|
-
ot(k, { parts: w, rebuild: (p, y) => Lr(p, A, f, O, y) });
|
|
1348
|
-
} catch {
|
|
1349
|
-
S.push("来源数据无法建立本地重算口径;当前预览仅支持计划内编辑,请使用可序列化模板数据启用规则重算");
|
|
1350
|
-
}
|
|
1351
|
-
const x = i ?? t.onWarning ?? ((p) => console.warn("[mach-report]", p));
|
|
1352
|
-
for (const p of S)
|
|
1353
|
-
E(s), x(p);
|
|
1354
|
-
return E(s), k;
|
|
1355
|
-
}, {
|
|
1356
|
-
getParamDefs: (a) => Ct(e, a)
|
|
1357
|
-
});
|
|
1358
|
-
}
|
|
1359
|
-
function co(e, t) {
|
|
1360
|
-
let r = 0, o = 0;
|
|
1361
|
-
const a = /* @__PURE__ */ new Set();
|
|
1362
|
-
function n(c, d) {
|
|
1363
|
-
if (++r > 1e6 || d > 64) throw t.error("budget", "快照节点或深度超过预算");
|
|
1364
|
-
if (r % 1024 === 0 && t.check?.(), typeof c == "string" && (o += c.length, o > t.maxBytes))
|
|
1365
|
-
throw t.error("budget", "快照文本超过预算");
|
|
1366
|
-
if (c === null || ["string", "boolean"].includes(typeof c) || typeof c == "number" && Number.isFinite(c)) return c;
|
|
1367
|
-
if (!c || typeof c != "object" || a.has(c)) throw t.error("input", "快照应为无循环的有限 JSON 值");
|
|
1368
|
-
return s(c, d);
|
|
1369
|
-
}
|
|
1370
|
-
function s(c, d) {
|
|
1371
|
-
const l = Array.isArray(c), f = Object.getPrototypeOf(c);
|
|
1372
|
-
if (f !== (l ? Array.prototype : Object.prototype) && !(f === null && !l) || Object.getOwnPropertySymbols(c).length) throw t.error("input", "快照应为普通 JSON 对象");
|
|
1373
|
-
const u = Object.getOwnPropertyNames(c).filter((h) => !(l && h === "length"));
|
|
1374
|
-
if (l && (u.length !== c.length || u.some((h, m) => h !== String(m)))) throw t.error("input", "快照数组应为连续数组");
|
|
1375
|
-
a.add(c);
|
|
1376
|
-
const g = /* @__PURE__ */ Object.create(null);
|
|
1377
|
-
for (const h of u) {
|
|
1378
|
-
if (o += h.length, o > t.maxBytes) throw t.error("budget", "快照文本超过预算");
|
|
1379
|
-
const m = Object.getOwnPropertyDescriptor(c, h);
|
|
1380
|
-
if (m.get || m.set || !m.enumerable || ["__proto__", "constructor", "prototype"].includes(h)) throw t.error("input", "快照不允许访问器或危险键");
|
|
1381
|
-
m.value !== void 0 && (g[h] = n(m.value, d + 1));
|
|
1382
|
-
}
|
|
1383
|
-
return a.delete(c), l ? u.map((h) => g[h]) : g;
|
|
1384
|
-
}
|
|
1385
|
-
t.check?.();
|
|
1386
|
-
const i = JSON.stringify(n(e, 0));
|
|
1387
|
-
if (new TextEncoder().encode(i).byteLength > t.maxBytes) throw t.error("budget", "快照超过字节预算");
|
|
1388
|
-
return JSON.parse(i);
|
|
1389
|
-
}
|
|
1390
|
-
export {
|
|
1391
|
-
Wt as D,
|
|
1392
|
-
D as P,
|
|
1393
|
-
T as R,
|
|
1394
|
-
N as a,
|
|
1395
|
-
vr as b,
|
|
1396
|
-
Xe as c,
|
|
1397
|
-
so as d,
|
|
1398
|
-
Zr as e,
|
|
1399
|
-
oo as f,
|
|
1400
|
-
io as g,
|
|
1401
|
-
eo as h,
|
|
1402
|
-
ro as i,
|
|
1403
|
-
wr as j,
|
|
1404
|
-
Ht as k,
|
|
1405
|
-
to as l,
|
|
1406
|
-
Or as m,
|
|
1407
|
-
Cr as n,
|
|
1408
|
-
Se as o,
|
|
1409
|
-
Je as p,
|
|
1410
|
-
no as q,
|
|
1411
|
-
ot as r,
|
|
1412
|
-
co as s,
|
|
1413
|
-
ao as t,
|
|
1414
|
-
at as u,
|
|
1415
|
-
nt as v
|
|
1416
|
-
};
|