@agile-team/mach-report 2.19.1 → 2.21.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 +22 -3
- package/dist/ExcelBindingWizard-B2xXBOJu.cjs +1 -0
- package/dist/{ExcelBindingWizard-xJIYmnZ_.js → ExcelBindingWizard-CixTPQAL.js} +351 -351
- package/dist/ParamEditor-DhHlNxai.cjs +1 -0
- package/dist/{ParamEditor-D1wWemaf.js → ParamEditor-gKhvEsnr.js} +10 -10
- package/dist/{ReportBatchPanel-BkJFqeEW.cjs → ReportBatchPanel-BUdUfTdm.cjs} +1 -1
- package/dist/{ReportBatchPanel-B88R-fME.js → ReportBatchPanel-D-lyWKyf.js} +2 -2
- package/dist/ReportLabelStudio-BcjQt73a.cjs +1 -0
- package/dist/ReportLabelStudio-N2w6DdaZ.js +764 -0
- package/dist/ReportParamPanel-CVpK8mFc.cjs +1 -0
- package/dist/{ReportParamPanel-mQkeN70Q.js → ReportParamPanel-peB-KEmm.js} +10 -2
- package/dist/{ReportPreview-DBbctg6C.js → ReportPreview-BBJNlu2U.js} +2093 -1978
- package/dist/ReportPreview-nf4Dk1Jc.cjs +6 -0
- package/dist/{ReportTemplateLibrary-BOh2MgjQ.cjs → ReportTemplateLibrary-Cs9WKneQ.cjs} +1 -1
- package/dist/{ReportTemplateLibrary-BGELmgd3.js → ReportTemplateLibrary-WZl-AK-2.js} +1 -1
- package/dist/{RuleEditor-CoLqgehG.js → RuleEditor-DGpmjCko.js} +178 -174
- package/dist/RuleEditor-Dtcq-7LO.cjs +1 -0
- package/dist/{TemplateOutlinePanel-DiG8tRRe.cjs → TemplateOutlinePanel-CkCh506f.cjs} +1 -1
- package/dist/{TemplateOutlinePanel-DU95loB-.js → TemplateOutlinePanel-cxp95OT9.js} +1 -1
- package/dist/{TemplateReusePanel-DE1KSD6c.js → TemplateReusePanel-BZ8VTtrO.js} +2 -2
- package/dist/{TemplateReusePanel-G-Y299wc.cjs → TemplateReusePanel-CwttuSta.cjs} +1 -1
- package/dist/{TemplateReviewPanel-KQx9ts0D.cjs → TemplateReviewPanel-C2YjiaEC.cjs} +1 -1
- package/dist/{TemplateReviewPanel-vqFJ_Y9o.js → TemplateReviewPanel-C9cTvsRs.js} +1 -1
- package/dist/artifact-integrity.json +92 -94
- package/dist/{assets-2eC3mOcV.js → assets-CxHunY_9.js} +2 -2
- package/dist/{assets-B0Hxn4l6.cjs → assets-vbjAGgk8.cjs} +1 -1
- package/dist/{auto-BlchZ1b8.js → auto-BkdGiNtr.js} +4 -4
- package/dist/{auto-B0EZFIK1.cjs → auto-Tq7ReIC1.cjs} +1 -1
- package/dist/{component-tree-CvW4lzpv.js → component-tree-1_QCiQJX.js} +1 -1
- package/dist/component-tree-BjZIp6w9.cjs +1 -0
- package/dist/{data-bar-PtjXhMgN.js → data-bar-8baGYEZ9.js} +1 -1
- package/dist/{data-bar-Ce38juRZ.cjs → data-bar-YltqGTaC.cjs} +1 -1
- package/dist/designer-CDqok4S5.cjs +2 -0
- package/dist/designer-CIDHt5xz.js +6869 -0
- package/dist/designer.cjs +1 -1
- package/dist/designer.d.cts +166 -7
- package/dist/designer.d.ts +166 -7
- package/dist/designer.js +1 -1
- package/dist/{encoding-B--eZpp1.cjs → encoding-B79hW4zq.cjs} +1 -1
- package/dist/{encoding-mctOLocI.js → encoding-BSeUwrN7.js} +2 -2
- package/dist/{font-loader-DBBJ5KE9.cjs → font-loader-BB372_XN.cjs} +1 -1
- package/dist/{font-loader-DW8tIaNp.js → font-loader-Di0lQKFf.js} +1 -1
- package/dist/grid-geometry-D3SJgWFv.js +136 -0
- package/dist/grid-geometry-D8ReblRV.cjs +1 -0
- package/dist/index.cjs +6 -6
- package/dist/index.js +194 -195
- package/dist/json-snapshot-I5VI84Vp.cjs +2 -0
- package/dist/{json-snapshot-By4ZVVUt.js → json-snapshot-Kgn459Oj.js} +895 -879
- package/dist/{pdf-DqyxJ96U.cjs → pdf-CARdBcuw.cjs} +45 -45
- package/dist/{pdf-CKROKygt.js → pdf-DmlnL5eB.js} +13 -14
- package/dist/pdf.cjs +1 -1
- package/dist/pdf.js +2 -2
- package/dist/{plugin-CPyHs4UC.cjs → plugin-BaRUGORD.cjs} +1 -1
- package/dist/{plugin-DsXJRR6Q.js → plugin-D4kAxfLG.js} +1 -1
- package/dist/{prefill-D7EswyTI.cjs → prefill-Bpyn58AZ.cjs} +1 -1
- package/dist/{prefill-B8H9qwE4.js → prefill-CJSazcVY.js} +2 -2
- package/dist/{prepared-CGVphji3.cjs → prepared-BiSz_9vN.cjs} +1 -1
- package/dist/{prepared-BE-4jfX5.js → prepared-BwjwEzFz.js} +1 -1
- package/dist/{protocol-Cr81vFSQ.js → protocol-Bs9-ohHN.js} +3 -3
- package/dist/{protocol-ByRVzzQG.cjs → protocol-C8VWF9An.cjs} +1 -1
- package/dist/record-bindings-Ct1HkPrc.cjs +1 -0
- package/dist/{record-bindings-DEJtmo3p.js → record-bindings-VZGS-Qd8.js} +1 -1
- package/dist/{region-binding-workflow-CBg0l_tj.js → region-binding-workflow-Cy4GIOUo.js} +2 -2
- package/dist/{region-binding-workflow-D05tOYn3.cjs → region-binding-workflow-JNowHd0A.cjs} +1 -1
- package/dist/report-encoding-worker.cjs +1 -1
- package/dist/report-encoding-worker.js +1 -1
- package/dist/rich-text-layout-K48VHUoW.cjs +3 -0
- package/dist/{rich-text-layout-Ct5WrY1g.js → rich-text-layout-wxBhnAS7.js} +1 -1
- package/dist/{runtime-CEMvybO7.js → runtime-BDf5x1i1.js} +5 -5
- package/dist/runtime-DsJt1PIf.cjs +1 -0
- package/dist/sbom.cdx.json +1 -1
- package/dist/server-node.cjs +4 -4
- package/dist/server-node.js +1272 -1274
- package/dist/server.cjs +1 -1
- package/dist/server.js +8 -8
- package/dist/style.css +1 -1
- package/dist/{template-catalog-CmbWOJqy.js → template-catalog-DFwIS9aN.js} +3 -3
- package/dist/{template-catalog-Utu4GP09.cjs → template-catalog-D_2jdnkL.cjs} +1 -1
- package/dist/template-fragments-DZVUBhuB.cjs +1 -0
- package/dist/{template-fragments-DWgo9tlZ.js → template-fragments-Dng-AlHk.js} +11 -11
- package/dist/{template-registry-BIhIHOab.js → template-registry-DhBqoD7W.js} +120 -118
- package/dist/template-registry-DpLUSLwF.cjs +1 -0
- package/dist/{column-visual-BpgQVWwT.js → template-serialization-Cc3h-miv.js} +74 -65
- package/dist/{column-visual-CtYxnBCP.cjs → template-serialization-D1R5oAqh.cjs} +1 -1
- package/dist/{textwrap-BEIg2w8y.js → textwrap-CkGjRFT3.js} +1 -1
- package/dist/textwrap-OTOUMr4f.cjs +4 -0
- package/dist/vue/async.d.cts +8 -0
- package/dist/vue/async.d.ts +8 -0
- package/dist/vue/index.d.cts +10 -2
- package/dist/vue/index.d.ts +10 -2
- package/dist/vue-async.cjs +1 -1
- package/dist/vue-async.js +3 -3
- package/dist/vue.cjs +1 -1
- package/dist/vue.js +6 -6
- package/dist/{workbook-session-B94EwVa_.cjs → workbook-session-NYv01LHe.cjs} +1 -1
- package/dist/{workbook-session-BoScoOg-.js → workbook-session-oinxX3qo.js} +2 -2
- package/dist/worker.cjs +1 -1
- package/dist/worker.js +4 -4
- package/dist/xlsx.cjs +4 -4
- package/dist/xlsx.js +204 -205
- package/package.json +1 -1
- package/dist/ExcelBindingWizard-UHSApSG9.cjs +0 -1
- package/dist/ParamEditor-BZb-okUd.cjs +0 -1
- package/dist/ReportLabelStudio-B4WZ2XNN.js +0 -239
- package/dist/ReportLabelStudio-BN-fYNCr.cjs +0 -1
- package/dist/ReportParamPanel-sOANVRz-.cjs +0 -1
- package/dist/ReportPreview-CuoHl15N.cjs +0 -6
- package/dist/RuleEditor-XaLcCdTb.cjs +0 -1
- package/dist/component-tree-6TV7W6Yj.cjs +0 -1
- package/dist/designer-CyKXBhQg.cjs +0 -2
- package/dist/designer-fVvpYg8H.js +0 -5824
- package/dist/grid-geometry-BNptEcMm.js +0 -65
- package/dist/grid-geometry-CZ_cYB6O.cjs +0 -1
- package/dist/json-snapshot-jiXff4lc.cjs +0 -2
- package/dist/record-bindings-ehjnCDHt.cjs +0 -1
- package/dist/rich-text-layout-ALlMoYOG.cjs +0 -3
- package/dist/runtime-CDA6d263.cjs +0 -1
- package/dist/style-67OqfNed.js +0 -73
- package/dist/style-C22Pbv3T.cjs +0 -1
- package/dist/template-fragments-C_zSHJAa.cjs +0 -1
- package/dist/template-registry-DzWswQI5.cjs +0 -1
- package/dist/textwrap-BI-yJ6Wt.cjs +0 -4
|
@@ -1,28 +1,27 @@
|
|
|
1
|
-
import { R as
|
|
2
|
-
import { r as re, L as ve,
|
|
3
|
-
import { w as
|
|
4
|
-
import { e as Me, k as
|
|
5
|
-
import { c as
|
|
6
|
-
import { a as
|
|
7
|
-
import { b as
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
function mr(e) {
|
|
1
|
+
import { R as be } from "./component-tree-1_QCiQJX.js";
|
|
2
|
+
import { r as re, a as ne, L as ve, c as Vt, j as Jt, g as j, D as Ve } from "./grid-geometry-D3SJgWFv.js";
|
|
3
|
+
import { w as _, h as Je } from "./textwrap-CkGjRFT3.js";
|
|
4
|
+
import { e as Me, k as H, b as Se, n as K, o as zt, q as _t } from "./computed-C8NRZQss.js";
|
|
5
|
+
import { c as ze, R as I, g as _e, b as qt, i as Ut, l as xe, t as qe, h as Ue, f as Xe, j as Xt, k as Yt } from "./record-bindings-VZGS-Qd8.js";
|
|
6
|
+
import { a as Qt, c as Zt } from "./charts-Dlv8j2AG.js";
|
|
7
|
+
import { b as er, c as tr, e as rr } from "./matrix-Dy-tyY7E.js";
|
|
8
|
+
import { f as Ye, b as nr, d as or, c as Qe } from "./template-serialization-Cc3h-miv.js";
|
|
9
|
+
import { i as ar, r as sr, j as ir, b as Ze, v as cr, R as lr } from "./template-registry-DhBqoD7W.js";
|
|
10
|
+
import { g as dr } from "./report-params-D9tBuM9B.js";
|
|
11
|
+
import { a as Ae } from "./param-validation-CnDEd2l-.js";
|
|
12
|
+
import { f as ur, i as fr } from "./number-format-BA_KwrZe.js";
|
|
13
|
+
import { v as et, d as mr } from "./dataset-DL83majE.js";
|
|
14
|
+
const hr = 4096, Ne = 128 * 1024;
|
|
15
|
+
function gr(e) {
|
|
17
16
|
const t = /* @__PURE__ */ new Map();
|
|
18
17
|
let r = 0;
|
|
19
|
-
return { measureMm(
|
|
20
|
-
const a = JSON.stringify([
|
|
18
|
+
return { measureMm(n, o) {
|
|
19
|
+
const a = JSON.stringify([n, o.fontSizePt, o.fontFamily, o.bold, o.italic, o.letterSpacingPt]), s = t.get(a);
|
|
21
20
|
if (s !== void 0)
|
|
22
21
|
return t.delete(a), t.set(a, s), s;
|
|
23
|
-
const i = e.measureMm(
|
|
24
|
-
if (Number.isFinite(i) && a.length <=
|
|
25
|
-
for (; t.size >=
|
|
22
|
+
const i = e.measureMm(n, o);
|
|
23
|
+
if (Number.isFinite(i) && a.length <= Ne) {
|
|
24
|
+
for (; t.size >= hr || r + a.length > Ne; ) {
|
|
26
25
|
const c = t.keys().next().value;
|
|
27
26
|
r -= c.length, t.delete(c);
|
|
28
27
|
}
|
|
@@ -31,65 +30,65 @@ function mr(e) {
|
|
|
31
30
|
return i;
|
|
32
31
|
} };
|
|
33
32
|
}
|
|
34
|
-
class
|
|
33
|
+
class W extends Error {
|
|
35
34
|
constructor(t, r) {
|
|
36
35
|
super(`报表页数超出上限 ${t}(至少 ${r} 页)`), this.limit = t, this.actual = r, this.code = "page-limit", this.name = "PaginatePageLimitError";
|
|
37
36
|
}
|
|
38
37
|
}
|
|
39
|
-
class
|
|
38
|
+
class Y extends Error {
|
|
40
39
|
constructor(t, r) {
|
|
41
40
|
super(`报表单元格数量超出上限 ${t}(至少 ${r} 格)`), this.limit = t, this.actual = r, this.code = "cell-limit", this.name = "PaginateCellLimitError";
|
|
42
41
|
}
|
|
43
42
|
}
|
|
44
|
-
class
|
|
43
|
+
class Q extends Error {
|
|
45
44
|
constructor(t, r) {
|
|
46
45
|
super(`报表图表图元数量预计超出上限 ${t}(本次估算 ${r})`), this.limit = t, this.estimated = r, this.code = "chart-component-limit", this.name = "PaginateChartComponentLimitError";
|
|
47
46
|
}
|
|
48
47
|
}
|
|
49
48
|
const Ce = 5e4;
|
|
50
|
-
function
|
|
49
|
+
function oe(e = Ce) {
|
|
51
50
|
if (!Number.isSafeInteger(e) || e < 1 || e > 1e6) throw new RangeError("maxChartComponents 应为 1..1000000 的安全整数");
|
|
52
51
|
}
|
|
53
|
-
function
|
|
54
|
-
const
|
|
52
|
+
function pr(e, t, r) {
|
|
53
|
+
const n = e.chartBinding;
|
|
55
54
|
if (e.kind !== "chart" || e.grid || e.imageData || e.binding || e.pageAnchor) throw new TypeError("绑定图表不能同时设置图片、网格、记录绑定或页眉页脚");
|
|
56
|
-
const
|
|
57
|
-
if (!Array.isArray(
|
|
58
|
-
return { ...
|
|
55
|
+
const o = Object.prototype.hasOwnProperty.call(t, n.dataset) ? t[n.dataset] : void 0;
|
|
56
|
+
if (!Array.isArray(o)) throw new TypeError(`图表数据集 ${n.dataset} 未提供`);
|
|
57
|
+
return { ...er(o, n, r), type: n.type, leftMm: e.leftMm, topMm: e.topMm, widthMm: e.widthMm, heightMm: e.heightMm, title: n.title, showValues: n.showValues };
|
|
59
58
|
}
|
|
60
|
-
function
|
|
61
|
-
|
|
62
|
-
let
|
|
59
|
+
function wr(e, t, r = Ce) {
|
|
60
|
+
oe(r);
|
|
61
|
+
let n = 0;
|
|
63
62
|
return Object.assign((a) => {
|
|
64
63
|
if (!a.chartBinding) return [a];
|
|
65
|
-
const s =
|
|
64
|
+
const s = pr(a, e, t), i = n + (s.categories.length ? Qt(s) : 1);
|
|
66
65
|
if (!Number.isSafeInteger(i)) throw new RangeError("图表图元估算应为有限安全整数");
|
|
67
|
-
if (i > r) throw new
|
|
68
|
-
const c = s.categories.length ?
|
|
69
|
-
return
|
|
70
|
-
}, { used: () =>
|
|
66
|
+
if (i > r) throw new Q(r, i);
|
|
67
|
+
const c = s.categories.length ? Zt(s) : [{ kind: "text", leftMm: a.leftMm, topMm: a.topMm, widthMm: a.widthMm, heightMm: a.heightMm, text: "—", style: { align: "center", verticalAlign: "middle", color: "#94a3b8", fontSize: 10 } }];
|
|
68
|
+
return n += c.length, c;
|
|
69
|
+
}, { used: () => n });
|
|
71
70
|
}
|
|
72
|
-
function
|
|
71
|
+
function yr(e, t) {
|
|
73
72
|
return { member: "body", subtotal: "subtotal", total: "grand-total" }[e?.rows.get(t)?.kind ?? "member"];
|
|
74
73
|
}
|
|
75
|
-
function
|
|
74
|
+
function br(e) {
|
|
76
75
|
const t = e.matrix;
|
|
77
76
|
if (!t.hierarchy) return t;
|
|
78
|
-
const r = new Map(e.columns.map((
|
|
77
|
+
const r = new Map(e.columns.map((o) => [o.field, o.header])), n = { sum: "求和", count: "计数", avg: "平均", min: "最小", max: "最大", weightedAvg: "加权平均" };
|
|
79
78
|
return { ...t, hierarchy: {
|
|
80
79
|
...t.hierarchy,
|
|
81
|
-
row: { ...t.hierarchy.row, labels: t.hierarchy.row?.labels ?? t.rowFields.map((
|
|
82
|
-
column: { ...t.hierarchy.column, labels: t.hierarchy.column?.labels ?? t.columnFields.map((
|
|
83
|
-
}, measures: t.measures.map((
|
|
84
|
-
const a = r.get(
|
|
85
|
-
return
|
|
80
|
+
row: { ...t.hierarchy.row, labels: t.hierarchy.row?.labels ?? t.rowFields.map((o) => r.get(o) ?? o) },
|
|
81
|
+
column: { ...t.hierarchy.column, labels: t.hierarchy.column?.labels ?? t.columnFields.map((o) => r.get(o) ?? o) }
|
|
82
|
+
}, measures: t.measures.map((o) => {
|
|
83
|
+
const a = r.get(o.field) ?? r.get(o.valueField ?? o.field);
|
|
84
|
+
return o.label === void 0 && a ? { ...o, label: `${a}(${n[o.op]})` } : o;
|
|
86
85
|
}) };
|
|
87
86
|
}
|
|
88
|
-
function
|
|
87
|
+
function vr(e, t) {
|
|
89
88
|
if (!e.matrix) return { list: e, rows: t };
|
|
90
89
|
if (e.detail || e.groupBy || e.groups?.length || e.grandTotal) throw new Error("矩阵不能同时配置普通分组、总计或主从明细");
|
|
91
|
-
const r =
|
|
92
|
-
e.layout === "wide" && (
|
|
90
|
+
const r = tr(t, br(e)), n = r.columns.map((i) => ({ ...i, widthMm: i.semanticRole === "dimension" ? e.matrix.rowWidthMm ?? 40 : e.matrix.columnWidthMm ?? 28, editable: !1, align: i.semanticRole === "dimension" ? "center" : "right" })), o = { ...e, columns: n, headerGrid: r.headerGrid, rowKey: void 0, revisionField: void 0, sourceTokenField: void 0 };
|
|
91
|
+
e.layout === "wide" && (o.widthMm = n.reduce((i, c) => i + c.widthMm, 0));
|
|
93
92
|
const a = r.metadata, s = a ? { rows: new WeakMap(r.rows.map((i, c) => [i, a.rows[c]])), header: {
|
|
94
93
|
columns: a.columns,
|
|
95
94
|
rowFields: a.rowFields,
|
|
@@ -97,92 +96,92 @@ function yr(e, t) {
|
|
|
97
96
|
columnFields: a.columnFields,
|
|
98
97
|
columnLabels: a.columnLabels
|
|
99
98
|
} } : void 0;
|
|
100
|
-
return { list:
|
|
99
|
+
return { list: o, rows: r.rows, ...s ? { matrix: s } : {} };
|
|
101
100
|
}
|
|
102
|
-
function
|
|
101
|
+
function Mr(e, t) {
|
|
103
102
|
if (!e.matrix?.hierarchy || !e.headerGrid) return e.headerGrid;
|
|
104
|
-
const r = e.paddingMm ?? 1,
|
|
103
|
+
const r = e.paddingMm ?? 1, n = e.headerGrid.cells.map(() => e.rowHeightMm ?? 0), o = e.columns.map((c) => c.widthMm), a = re({ ...e.headerGrid, colWidthsMm: o }, o.reduce((c, l) => c + l, 0), n.length), s = /* @__PURE__ */ new WeakMap();
|
|
105
104
|
for (const { cell: c, ci: l, ri: d, widthMm: f } of a.cells) {
|
|
106
|
-
const u = { ...
|
|
107
|
-
for (let y = d; y < d + (c.rowSpan ?? 1); y++)
|
|
105
|
+
const u = { ...ze(e, e.columns[l]), ...c.style }, h = ne(u).fontSizePt, v = (_(c.text ?? "", Math.max(1, f - r * 2), { fontSizePt: h, fontFamily: u.fontFamily, bold: u.bold, italic: u.italic, letterSpacingPt: u.letterSpacing }, t).length * h * (u.lineHeight ?? ve) * 25.4 / 72 + r * 2) / (c.rowSpan ?? 1);
|
|
106
|
+
for (let y = d; y < d + (c.rowSpan ?? 1); y++) n[y] = Math.max(n[y] ?? 0, v);
|
|
108
107
|
s.set(c, u);
|
|
109
108
|
}
|
|
110
109
|
const i = e.headerGrid.cells.map((c) => c.map((l) => l ? { ...l, style: s.get(l) } : null));
|
|
111
|
-
return { ...e.headerGrid, cells: i, rowHeightsMm:
|
|
110
|
+
return { ...e.headerGrid, cells: i, rowHeightsMm: n };
|
|
112
111
|
}
|
|
113
|
-
function
|
|
114
|
-
const
|
|
112
|
+
function Sr(e, t, r) {
|
|
113
|
+
const n = /* @__PURE__ */ new Set(), o = e.cells.map((a, s) => {
|
|
115
114
|
const i = [];
|
|
116
115
|
let c = 0;
|
|
117
116
|
for (const l of a) {
|
|
118
|
-
for (;
|
|
117
|
+
for (; n.has(`${s}:${c}`); ) c++;
|
|
119
118
|
const d = l?.colSpan ?? 1, f = l?.rowSpan ?? 1;
|
|
120
119
|
let u = 0;
|
|
121
120
|
for (let h = c; h < c + d; h++) {
|
|
122
121
|
t.has(h) && u++;
|
|
123
122
|
for (let m = s + 1; m < s + f; m++)
|
|
124
|
-
|
|
123
|
+
n.add(`${m}:${h}`);
|
|
125
124
|
}
|
|
126
125
|
u && i.push(l ? { ...l, colSpan: u } : null), c += d;
|
|
127
126
|
}
|
|
128
127
|
return i;
|
|
129
128
|
});
|
|
130
|
-
return { ...e, cells:
|
|
129
|
+
return { ...e, cells: o, colWidthsMm: r };
|
|
131
130
|
}
|
|
132
|
-
function
|
|
133
|
-
if (!e.columns.some((
|
|
134
|
-
const t = /* @__PURE__ */ new Set(), r = e.columns.filter((
|
|
131
|
+
function xr(e) {
|
|
132
|
+
if (!e.columns.some((n) => n.hidden)) return e;
|
|
133
|
+
const t = /* @__PURE__ */ new Set(), r = e.columns.filter((n, o) => n.hidden ? !1 : (t.add(o), !0));
|
|
135
134
|
if (!r.length) throw new Error("列表至少需要一列可见列");
|
|
136
135
|
return {
|
|
137
136
|
...e,
|
|
138
137
|
columns: r,
|
|
139
138
|
...e.headerGrid ? {
|
|
140
|
-
headerGrid:
|
|
139
|
+
headerGrid: Sr(
|
|
141
140
|
e.headerGrid,
|
|
142
141
|
t,
|
|
143
|
-
r.map((
|
|
142
|
+
r.map((n) => n.widthMm)
|
|
144
143
|
)
|
|
145
144
|
} : {}
|
|
146
145
|
};
|
|
147
146
|
}
|
|
148
|
-
function*
|
|
147
|
+
function* Cr(e) {
|
|
149
148
|
const { page: t } = e;
|
|
150
|
-
|
|
151
|
-
let r = 0,
|
|
152
|
-
for (const
|
|
149
|
+
ar(t.components, t.flow);
|
|
150
|
+
let r = 0, n = 0;
|
|
151
|
+
for (const o of sr(t.components, t.flow)) {
|
|
153
152
|
e.active();
|
|
154
|
-
const a =
|
|
155
|
-
let c = Math.max(e.top(),
|
|
153
|
+
const a = o.band, s = o.components.some((d) => d.kind === "list" && d.cardinality !== "record"), i = s ? 0 : o.components.reduce((d, f) => Math.max(d, f.topMm - a.topMm + (f.kind === "list" ? e.height(f) : f.heightMm)), a.heightMm);
|
|
154
|
+
let c = Math.max(e.top(), n + a.topMm - r);
|
|
156
155
|
if (!s && i > e.bottom() - e.top() + 1e-3) throw new Error(`静态区域 ${a.componentIds.join(",")} 高度超出单页可用范围`);
|
|
157
156
|
!s && c + i > e.bottom() + 1e-3 && (e.nextPage(), yield* e.takePages(), e.active(), c = e.top());
|
|
158
157
|
let l = c + i;
|
|
159
|
-
for (const d of
|
|
158
|
+
for (const d of o.components) {
|
|
160
159
|
const f = c + d.topMm - a.topMm;
|
|
161
160
|
d.kind === "list" ? (yield* e.list(d, f, (u) => {
|
|
162
161
|
l = s ? u : Math.max(l, u);
|
|
163
162
|
}), e.active()) : e.append({ ...d, topMm: f });
|
|
164
163
|
}
|
|
165
|
-
|
|
164
|
+
n = l, r = a.topMm + a.heightMm;
|
|
166
165
|
}
|
|
167
166
|
}
|
|
168
|
-
function
|
|
167
|
+
function kr(e) {
|
|
169
168
|
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 || t.visual));
|
|
170
169
|
}
|
|
171
|
-
function
|
|
172
|
-
return e.pages.some((t) => t.components.some((r) => r.kind === "list" ?
|
|
170
|
+
function ke(e) {
|
|
171
|
+
return e.pages.some((t) => t.components.some((r) => r.kind === "list" ? kr(r) : !!r.chartBinding));
|
|
173
172
|
}
|
|
174
|
-
const
|
|
175
|
-
function
|
|
173
|
+
const Tr = 512, je = 256 * 1024;
|
|
174
|
+
function Pr() {
|
|
176
175
|
const e = /* @__PURE__ */ new Map();
|
|
177
176
|
let t = 0, r;
|
|
178
|
-
return (
|
|
177
|
+
return (n, o, a, s) => {
|
|
179
178
|
s !== r && (e.clear(), t = 0, r = s);
|
|
180
|
-
const i = JSON.stringify([
|
|
179
|
+
const i = JSON.stringify([n, o, a.fontSizePt, a.fontFamily, a.bold, a.italic, a.letterSpacingPt]), c = e.get(i);
|
|
181
180
|
if (c)
|
|
182
181
|
return e.delete(i), e.set(i, c), c.lines.slice();
|
|
183
|
-
const l =
|
|
184
|
-
if (d <=
|
|
185
|
-
for (; e.size >=
|
|
182
|
+
const l = _(n, o, a, s), d = i.length + l.reduce((f, u) => f + u.length, 0);
|
|
183
|
+
if (d <= je) {
|
|
184
|
+
for (; e.size >= Tr || t + d > je; ) {
|
|
186
185
|
const f = e.keys().next().value;
|
|
187
186
|
t -= e.get(f).units, e.delete(f);
|
|
188
187
|
}
|
|
@@ -192,97 +191,97 @@ function kr() {
|
|
|
192
191
|
};
|
|
193
192
|
}
|
|
194
193
|
const Er = 1e4, Ke = 25e4;
|
|
195
|
-
function
|
|
194
|
+
function Te(e) {
|
|
196
195
|
if (e?.aborted) throw e.reason ?? new DOMException("标签生成已取消", "AbortError");
|
|
197
196
|
}
|
|
198
|
-
function et(e, t, r) {
|
|
199
|
-
const o = typeof e.copies == "object" ? ze(t, e.copies.field, r) : e.copies ?? 1;
|
|
200
|
-
if (typeof o != "number" || !Number.isSafeInteger(o) || o < 1 || o > 1e3) throw new I(`$.datasets.${r.dataset}[${r.rowIndex}]`, "每条记录复制数必须是 1..1000 的数值型整数", r.rowIndex, typeof e.copies == "object" ? e.copies.field : void 0);
|
|
201
|
-
return o;
|
|
202
|
-
}
|
|
203
197
|
function tt(e, t, r) {
|
|
198
|
+
const n = typeof e.copies == "object" ? _e(t, e.copies.field, r) : e.copies ?? 1;
|
|
199
|
+
if (typeof n != "number" || !Number.isSafeInteger(n) || n < 1 || n > 1e3) throw new I(`$.datasets.${r.dataset}[${r.rowIndex}]`, "每条记录复制数必须是 1..1000 的数值型整数", r.rowIndex, typeof e.copies == "object" ? e.copies.field : void 0);
|
|
200
|
+
return n;
|
|
201
|
+
}
|
|
202
|
+
function rt(e, t, r) {
|
|
204
203
|
if (e.rowKey === void 0) return;
|
|
205
|
-
const
|
|
206
|
-
if (typeof
|
|
204
|
+
const n = _e(t, e.rowKey, r);
|
|
205
|
+
if (typeof n == "string" && n.trim() || typeof n == "number" && Number.isFinite(n)) return n;
|
|
207
206
|
throw new I(`$.datasets.${r.dataset}[${r.rowIndex}].${e.rowKey}`, "业务主键必须是非空字符串或有限数字", r.rowIndex, e.rowKey);
|
|
208
207
|
}
|
|
209
|
-
function
|
|
210
|
-
const t = (r) => 1 + (r.grid?.cells.reduce((
|
|
211
|
-
return e.pages.reduce((r,
|
|
208
|
+
function Rr(e) {
|
|
209
|
+
const t = (r) => 1 + (r.grid?.cells.reduce((n, o) => n + 1 + o.length + o.reduce((a, s) => a + (s?.children?.reduce((i, c) => i + t(c), 0) ?? 0), 0), 0) ?? 0);
|
|
210
|
+
return e.pages.reduce((r, n) => r + n.components.reduce((o, a) => o + t(a), 0), 0);
|
|
212
211
|
}
|
|
213
|
-
function
|
|
214
|
-
const
|
|
215
|
-
if (!Array.isArray(
|
|
216
|
-
const a = /* @__PURE__ */ new Set(), s = r.maxPages ?? Er, i =
|
|
212
|
+
function $r(e, t, r) {
|
|
213
|
+
const n = e.repeat, o = Object.prototype.hasOwnProperty.call(t, n.dataset) ? t[n.dataset] : void 0;
|
|
214
|
+
if (!Array.isArray(o)) throw new I(`$.datasets.${n.dataset}`, "逐记录标签数据集缺失,应提供对象数组(允许空数组)");
|
|
215
|
+
const a = /* @__PURE__ */ new Set(), s = r.maxPages ?? Er, i = Rr(e);
|
|
217
216
|
let c = 0, l = 0;
|
|
218
|
-
for (const [d, f] of
|
|
219
|
-
if (
|
|
220
|
-
const u = { rowIndex: d, dataset:
|
|
217
|
+
for (const [d, f] of o.entries()) {
|
|
218
|
+
if (Te(r.signal), !f || typeof f != "object" || Array.isArray(f)) throw new I(`$.datasets.${n.dataset}[${d}]`, "标签记录应为对象", d);
|
|
219
|
+
const u = { rowIndex: d, dataset: n.dataset }, h = rt(n, f, u);
|
|
221
220
|
if (h !== void 0) {
|
|
222
221
|
const v = JSON.stringify([typeof h, h]);
|
|
223
|
-
if (a.has(v)) throw new I(`$.datasets.${
|
|
222
|
+
if (a.has(v)) throw new I(`$.datasets.${n.dataset}[${d}].${n.rowKey}`, "业务主键重复;请先确认记录来源,避免重复打印标签", d, n.rowKey);
|
|
224
223
|
a.add(v);
|
|
225
224
|
}
|
|
226
|
-
const m =
|
|
227
|
-
if (c += m * e.pages.length, l += m * i, c > s) throw new
|
|
225
|
+
const m = tt(n, f, u);
|
|
226
|
+
if (c += m * e.pages.length, l += m * i, c > s) throw new W(s, c);
|
|
228
227
|
if (l > Ke) throw new I("$.repeat", `标签组件总量(含网格行、槽位及嵌套组件)超过安全预算 ${Ke},请分批生成`, d);
|
|
229
228
|
}
|
|
230
|
-
return
|
|
229
|
+
return o;
|
|
231
230
|
}
|
|
232
|
-
function
|
|
231
|
+
function Ir(e, t, r) {
|
|
233
232
|
if (!e.binding) return e;
|
|
234
|
-
const { binding:
|
|
233
|
+
const { binding: n, ...o } = e, a = qt(n, t.row, t);
|
|
235
234
|
if (e.kind === "image") {
|
|
236
235
|
if (!a) return;
|
|
237
|
-
if (!
|
|
238
|
-
return { ...
|
|
236
|
+
if (!Ut(a)) throw new I(`${r}.binding`, "图片字段只接受 PNG/JPEG base64 data URL;业务 URL 应由宿主安全加载后转换", t.rowIndex, n.field);
|
|
237
|
+
return { ...o, imageData: a };
|
|
239
238
|
}
|
|
240
|
-
return e.kind === "barcode" || e.kind === "qrcode" ? (delete
|
|
239
|
+
return e.kind === "barcode" || e.kind === "qrcode" ? (delete o.imageData, { ...o, code: { ...o.code, value: a }, fallbackText: a }) : (delete o.lines, delete o.richParagraphs, { ...o, text: a });
|
|
241
240
|
}
|
|
242
|
-
function
|
|
241
|
+
function Fr(e, t, r) {
|
|
243
242
|
if (e.kind !== "text" || e.grid || e.richParagraphs?.length) return e;
|
|
244
|
-
const
|
|
243
|
+
const n = e.style ?? {}, o = ne(n).fontSizePt, a = e.text ?? e.lines?.join(`
|
|
245
244
|
`) ?? "";
|
|
246
245
|
if (a.length > 16384) throw new I(r, "标签文本超过 16384 字符预算,请缩小字段内容", t.rowIndex);
|
|
247
|
-
const s = t.wrapText(a, e.widthMm, { fontSizePt:
|
|
246
|
+
const s = t.wrapText(a, e.widthMm, { fontSizePt: o, bold: n.bold, italic: n.italic, fontFamily: n.fontFamily, letterSpacingPt: n.letterSpacing }, t.options.measurer ?? Je), i = s.length * o * Vt(n) * 25.4 / 72;
|
|
248
247
|
if (i > e.heightMm + 0.05) throw new I(r, `标签文字需要约 ${i.toFixed(2)}mm 高,超出 ${e.heightMm}mm;请增大文本区域、减少内容或调整字号`, t.rowIndex, e.binding?.field);
|
|
249
248
|
return { ...e, lines: s };
|
|
250
249
|
}
|
|
251
|
-
function
|
|
252
|
-
|
|
253
|
-
const
|
|
254
|
-
if (!
|
|
255
|
-
let
|
|
256
|
-
return
|
|
257
|
-
const f =
|
|
250
|
+
function nt(e, t, r) {
|
|
251
|
+
Te(t.options.signal);
|
|
252
|
+
const n = Ir(e, t, r);
|
|
253
|
+
if (!n) return;
|
|
254
|
+
let o = n.grid;
|
|
255
|
+
return o && (o = { ...o, cells: o.cells.map((a, s) => a.map((i, c) => i?.children?.length ? { ...i, children: i.children.flatMap((l, d) => {
|
|
256
|
+
const f = nt(l, t, `${r}.grid.cells.${s}.${c}.children.${d}`);
|
|
258
257
|
return f ? [f] : [];
|
|
259
|
-
}) } : i)) }),
|
|
258
|
+
}) } : i)) }), Fr(o === n.grid ? n : { ...n, grid: o }, t, r);
|
|
260
259
|
}
|
|
261
|
-
function
|
|
260
|
+
function Or(e, t, r, n, o, a) {
|
|
262
261
|
return {
|
|
263
262
|
...e,
|
|
264
263
|
components: e.components.flatMap((s, i) => {
|
|
265
|
-
const c =
|
|
264
|
+
const c = nt(s, r, `$.pages.${t}.components.${i}`);
|
|
266
265
|
return c ? [{ ...c, meta: { ...c.meta, labelSource: { pageIndex: t, componentIndex: i } } }] : [];
|
|
267
266
|
}),
|
|
268
|
-
meta: { ...e.meta, record: { dataset: r.dataset, rowIndex: r.rowIndex, ...a === void 0 ? {} : { rowKey: a }, copyIndex:
|
|
267
|
+
meta: { ...e.meta, record: { dataset: r.dataset, rowIndex: r.rowIndex, ...a === void 0 ? {} : { rowKey: a }, copyIndex: n, copyCount: o, templatePageIndex: t } }
|
|
269
268
|
};
|
|
270
269
|
}
|
|
271
|
-
function*
|
|
272
|
-
const
|
|
273
|
-
if (
|
|
270
|
+
function* Ar(e, t, r) {
|
|
271
|
+
const n = [];
|
|
272
|
+
if (ir(e, n), n.length) throw new I(n[0].path, n[0].message);
|
|
274
273
|
if (!e.repeat) {
|
|
275
274
|
for (const [i, c] of e.pages.entries()) yield { page: c, pageIndex: i };
|
|
276
275
|
return;
|
|
277
276
|
}
|
|
278
|
-
const
|
|
277
|
+
const o = e.repeat, a = $r(e, t, r), s = Pr();
|
|
279
278
|
for (const [i, c] of a.entries()) {
|
|
280
|
-
const l = { row: c, rowIndex: i, dataset:
|
|
279
|
+
const l = { row: c, rowIndex: i, dataset: o.dataset, options: r, wrapText: s }, d = tt(o, c, l), f = rt(o, c, l);
|
|
281
280
|
for (let u = 0; u < d; u++) for (const [h, m] of e.pages.entries())
|
|
282
|
-
|
|
281
|
+
Te(r.signal), yield { page: Or(m, h, l, u, d, f), pageIndex: h };
|
|
283
282
|
}
|
|
284
283
|
}
|
|
285
|
-
function
|
|
284
|
+
function Nr(e) {
|
|
286
285
|
return {
|
|
287
286
|
widthMm: e.widthMm,
|
|
288
287
|
heightMm: e.heightMm,
|
|
@@ -293,9 +292,9 @@ function Or(e) {
|
|
|
293
292
|
components: []
|
|
294
293
|
};
|
|
295
294
|
}
|
|
296
|
-
function
|
|
295
|
+
function Z(e, t) {
|
|
297
296
|
const r = t.heightMm - (e.layout === "wide" ? t.marginBottomMm : e.marginBottomMm ?? t.marginBottomMm);
|
|
298
|
-
return e.components.reduce((
|
|
297
|
+
return e.components.reduce((n, o) => o.kind !== "list" && o.pageAnchor === "footer" ? Math.min(n, o.topMm) : n, r);
|
|
299
298
|
}
|
|
300
299
|
function V(e) {
|
|
301
300
|
return e.components.reduce((t, r) => r.kind !== "list" && r.pageAnchor === "header" ? Math.max(t, r.topMm + r.heightMm) : t, 0);
|
|
@@ -303,70 +302,70 @@ function V(e) {
|
|
|
303
302
|
function ot(e, t) {
|
|
304
303
|
let r = e.textMetrics.get(t);
|
|
305
304
|
if (!r) {
|
|
306
|
-
const
|
|
305
|
+
const n = ne(t).fontSizePt;
|
|
307
306
|
r = {
|
|
308
307
|
measureOptions: {
|
|
309
|
-
fontSizePt:
|
|
308
|
+
fontSizePt: n,
|
|
310
309
|
fontFamily: t.fontFamily ?? Ve,
|
|
311
310
|
italic: t.italic,
|
|
312
311
|
bold: t.bold,
|
|
313
312
|
letterSpacingPt: t.letterSpacing
|
|
314
313
|
},
|
|
315
|
-
lineMm:
|
|
314
|
+
lineMm: n * (t.lineHeight ?? ve) * 25.4 / 72
|
|
316
315
|
}, e.textMetrics.set(t, r);
|
|
317
316
|
}
|
|
318
317
|
return r;
|
|
319
318
|
}
|
|
320
|
-
function
|
|
319
|
+
function jr(e) {
|
|
321
320
|
if (e === null || typeof e == "string" || typeof e == "boolean" || typeof e == "number" && Number.isFinite(e)) return e;
|
|
322
321
|
}
|
|
323
|
-
function
|
|
324
|
-
const
|
|
325
|
-
...
|
|
326
|
-
fontSize:
|
|
322
|
+
function Pe(e, t, r = [], n) {
|
|
323
|
+
const o = e.fontSizePt ?? Jt, a = e.paddingMm ?? 1, s = e.columns.map((g) => g.align ?? g.style?.align ?? e.align ?? "left"), i = e.columns.map((g, w) => ({
|
|
324
|
+
...j({
|
|
325
|
+
fontSize: o,
|
|
327
326
|
verticalAlign: "middle"
|
|
328
327
|
}, g.style),
|
|
329
328
|
align: s[w] === "auto" ? "left" : s[w]
|
|
330
329
|
})), c = i.map((g, w) => s[w] === "auto" ? { left: g, center: { ...g, align: "center" }, right: { ...g, align: "right" } } : void 0), l = e.columns.map((g, w) => g.rules?.map((x) => {
|
|
331
|
-
const
|
|
332
|
-
if (
|
|
333
|
-
left:
|
|
334
|
-
center:
|
|
335
|
-
right:
|
|
330
|
+
const E = c[w];
|
|
331
|
+
if (E) return {
|
|
332
|
+
left: j(E.left, x.style),
|
|
333
|
+
center: j(E.center, x.style),
|
|
334
|
+
right: j(E.right, x.style)
|
|
336
335
|
};
|
|
337
|
-
const
|
|
338
|
-
return { left:
|
|
339
|
-
})), d = e.columns.map((g) =>
|
|
336
|
+
const k = j(i[w], x.style);
|
|
337
|
+
return { left: k, center: k, right: k };
|
|
338
|
+
})), d = e.columns.map((g) => ze(e, g)), f = e.columns.map((g) => g.header);
|
|
340
339
|
let u = e.rowHeightMm ?? 0;
|
|
341
340
|
for (let g = 0; g < f.length; g++) {
|
|
342
|
-
const w = d[g], x =
|
|
341
|
+
const w = d[g], x = ne(w).fontSizePt, E = _(
|
|
343
342
|
f[g],
|
|
344
343
|
e.columns[g].widthMm - a * 2,
|
|
345
344
|
{ fontSizePt: x, fontFamily: w.fontFamily ?? Ve, italic: w.italic, bold: w.bold, letterSpacingPt: w.letterSpacing },
|
|
346
345
|
t
|
|
347
|
-
),
|
|
348
|
-
u = Math.max(u, Math.max(
|
|
346
|
+
), k = x * (w.lineHeight ?? ve) * 25.4 / 72;
|
|
347
|
+
u = Math.max(u, Math.max(E.length, 1) * k + a * 2);
|
|
349
348
|
}
|
|
350
349
|
const h = f.map((g, w) => ({
|
|
351
350
|
text: g,
|
|
352
351
|
style: d[w]
|
|
353
|
-
})), m = e.border === !1 ? { borderTop: !1, borderRight: !1, borderBottom: !1, borderLeft: !1 } : { borderBottom: !0, borderLeft: !0, borderRight: !0, borderTop: !0 }, v = e.columns.map((g) => g.widthMm), y =
|
|
352
|
+
})), m = e.border === !1 ? { borderTop: !1, borderRight: !1, borderBottom: !1, borderLeft: !1 } : { borderBottom: !0, borderLeft: !0, borderRight: !0, borderTop: !0 }, v = e.columns.map((g) => g.widthMm), y = Kr(Mr(e, t), v, {
|
|
354
353
|
cells: [h],
|
|
355
354
|
colWidthsMm: v,
|
|
356
355
|
rowHeightsMm: [u],
|
|
357
356
|
paddingMm: a
|
|
358
357
|
});
|
|
359
358
|
return {
|
|
360
|
-
fontSizePt:
|
|
359
|
+
fontSizePt: o,
|
|
361
360
|
paddingMm: a,
|
|
362
|
-
visuals:
|
|
363
|
-
visibility: e.columns.map((g) => g.visibleWhen ?
|
|
364
|
-
ruleReaders: e.columns.map((g) => g.rules?.map((w) =>
|
|
361
|
+
visuals: or(e.columns, r, n),
|
|
362
|
+
visibility: e.columns.map((g) => g.visibleWhen ? H(g.visibleWhen) : void 0),
|
|
363
|
+
ruleReaders: e.columns.map((g) => g.rules?.map((w) => H(w.when))),
|
|
365
364
|
cellStyles: i,
|
|
366
365
|
autoStyles: c,
|
|
367
366
|
ruleStyles: l,
|
|
368
367
|
textMetrics: /* @__PURE__ */ new WeakMap(),
|
|
369
|
-
numberFormats: e.columns.map((g) =>
|
|
368
|
+
numberFormats: e.columns.map((g) => qe(g.format)),
|
|
370
369
|
derivedFields: new Set(e.computed?.map((g) => g.field)),
|
|
371
370
|
borderStyle: m,
|
|
372
371
|
headerHeightMm: y.rowHeightsMm.reduce((g, w) => g + w, 0),
|
|
@@ -375,23 +374,23 @@ function Ee(e, t, r = [], o) {
|
|
|
375
374
|
columns: e.columns
|
|
376
375
|
};
|
|
377
376
|
}
|
|
378
|
-
function
|
|
377
|
+
function Kr(e, t, r) {
|
|
379
378
|
if (!e) return r;
|
|
380
379
|
if (!e.cells.length) throw new Error("自定义列表表头至少需要一行");
|
|
381
|
-
const
|
|
382
|
-
if (
|
|
383
|
-
return { ...e, colWidthsMm: t, rowHeightsMm:
|
|
380
|
+
const n = e.rowHeightsMm ?? e.cells.map(() => r.rowHeightsMm[0]);
|
|
381
|
+
if (n.length !== e.cells.length || n.some((o) => !Number.isFinite(o) || o <= 0)) throw new Error("自定义列表表头行高无效");
|
|
382
|
+
return { ...e, colWidthsMm: t, rowHeightsMm: n };
|
|
384
383
|
}
|
|
385
|
-
function
|
|
386
|
-
const
|
|
387
|
-
t.valueType !== void 0 ? e.valueType = t.valueType :
|
|
384
|
+
function Lr(e, t, r) {
|
|
385
|
+
const n = t.format?.kind === "number" || t.format?.kind === "percent";
|
|
386
|
+
t.valueType !== void 0 ? e.valueType = t.valueType : n && (e.valueType = "number"), t.editable !== void 0 && (e.editable = t.editable), (typeof e.value == "number" || e.value == null) && r !== void 0 && (e.numberFormat = r);
|
|
388
387
|
}
|
|
389
|
-
function
|
|
390
|
-
const
|
|
388
|
+
function J(e, t, r) {
|
|
389
|
+
const n = e.columns, o = e.tree?.rows.get(t);
|
|
391
390
|
let a = e.rowHeightFloorMm;
|
|
392
|
-
const s = new Array(
|
|
393
|
-
for (let i = 0; i <
|
|
394
|
-
const c =
|
|
391
|
+
const s = new Array(n.length);
|
|
392
|
+
for (let i = 0; i < n.length; i++) {
|
|
393
|
+
const c = n[i], l = e.visibility[i]?.(t) !== !1, d = l ? t[c.field] : null, f = e.autoStyles[i] ? Ue(d, c.format, c.semanticRole) : "left";
|
|
395
394
|
let u = e.autoStyles[i]?.[f] ?? e.cellStyles[i];
|
|
396
395
|
if (c.rules) {
|
|
397
396
|
for (let x = 0; x < c.rules.length; x++)
|
|
@@ -400,12 +399,12 @@ function W(e, t, r) {
|
|
|
400
399
|
break;
|
|
401
400
|
}
|
|
402
401
|
}
|
|
403
|
-
const h = c.format ?
|
|
404
|
-
u =
|
|
405
|
-
const v = ot(e, u), y =
|
|
402
|
+
const h = c.format ? Xe(d, c.format) : xe(d), m = Hr(e, c, o);
|
|
403
|
+
u = Dr(e, c, u, o);
|
|
404
|
+
const v = ot(e, u), y = _(h, Math.max(1, c.widthMm - e.paddingMm * 2 - m), v.measureOptions, r);
|
|
406
405
|
a = Math.max(a, y.length * v.lineMm + e.paddingMm * 2);
|
|
407
|
-
const g =
|
|
408
|
-
d != null && e.visuals[i]?.apply(w, t), g !== void 0 && (w.value = g),
|
|
406
|
+
const g = jr(d), w = { text: h, style: u };
|
|
407
|
+
d != null && e.visuals[i]?.apply(w, t), g !== void 0 && (w.value = g), Lr(w, c, e.numberFormats[i]), Br(w, c, e, o, m), e.derivedFields.has(c.field) && (w.derived = !0, w.editable = !1), l || (w.editable = !1), s[i] = w;
|
|
409
408
|
}
|
|
410
409
|
return {
|
|
411
410
|
grid: { cells: [s], colWidthsMm: e.colWidthsMm, rowHeightsMm: [a], paddingMm: e.paddingMm },
|
|
@@ -413,70 +412,70 @@ function W(e, t, r) {
|
|
|
413
412
|
...e.matrix ? { meta: { matrix: { row: e.matrix.rows.get(t) } } } : {}
|
|
414
413
|
};
|
|
415
414
|
}
|
|
416
|
-
function
|
|
417
|
-
return !r || t.field !== e.tree.list.tree.labelField ? 0 :
|
|
415
|
+
function Hr(e, t, r) {
|
|
416
|
+
return !r || t.field !== e.tree.list.tree.labelField ? 0 : Xt(e.tree.list, t, r, e.paddingMm);
|
|
418
417
|
}
|
|
419
|
-
function
|
|
420
|
-
return !
|
|
418
|
+
function Dr(e, t, r, n) {
|
|
419
|
+
return !n || t.field !== e.tree.list.tree.labelField || r.align === "left" ? r : { ...r, align: "left" };
|
|
421
420
|
}
|
|
422
|
-
function
|
|
423
|
-
|
|
421
|
+
function Br(e, t, r, n, o = 0) {
|
|
422
|
+
n && (o && (e.indentMm = o), Yt(e, t, n, r.tree.list));
|
|
424
423
|
}
|
|
425
|
-
function
|
|
424
|
+
function at(e) {
|
|
426
425
|
if (e != null && typeof e != "string" && typeof e != "boolean" && !(typeof e == "number" && Number.isFinite(e))) throw new Error("分组字段应为有限 JSON 标量");
|
|
427
426
|
return JSON.stringify([typeof e, e ?? null]);
|
|
428
427
|
}
|
|
429
|
-
function*
|
|
430
|
-
const
|
|
431
|
-
if (!
|
|
428
|
+
function* st(e, t, r = 0) {
|
|
429
|
+
const n = t[r];
|
|
430
|
+
if (!n) {
|
|
432
431
|
for (const a of e) yield { kind: "row", row: a };
|
|
433
432
|
return;
|
|
434
433
|
}
|
|
435
|
-
const
|
|
434
|
+
const o = /* @__PURE__ */ new Map();
|
|
436
435
|
for (const a of e) {
|
|
437
|
-
const s =
|
|
438
|
-
i ? i.push(a) :
|
|
436
|
+
const s = at(a[n.field]), i = o.get(s);
|
|
437
|
+
i ? i.push(a) : o.set(s, [a]);
|
|
439
438
|
}
|
|
440
|
-
for (const a of
|
|
441
|
-
yield { kind: "groupHeader", label: (
|
|
439
|
+
for (const a of o.values())
|
|
440
|
+
yield { kind: "groupHeader", label: (n.headerTemplate ?? "{value}").replace(/\{value\}/g, xe(a[0][n.field])), firstRow: a[0], group: n, depth: r, rows: a }, yield* st(a, t, r + 1), (n.subtotal?.length || n.aggregates?.length) && (yield { kind: "subtotal", label: n.subtotalLabel ?? "小计", rows: a, group: n, depth: r }), yield { kind: "groupEnd", depth: r };
|
|
442
441
|
}
|
|
443
|
-
function
|
|
444
|
-
const
|
|
445
|
-
return new Map(
|
|
442
|
+
function it(e, t, r, n = []) {
|
|
443
|
+
const o = [...r.filter((a) => !n.some((s) => s.field === a)).map((a) => ({ field: a, op: "sum" })), ...n];
|
|
444
|
+
return new Map(o.map((a) => {
|
|
446
445
|
const s = e.find((c) => c.field === a.field)?.format ?? { kind: "number", thousands: !0 }, i = Se(t, { ...a, field: a.valueField ?? a.field });
|
|
447
|
-
return [a.field, { text:
|
|
446
|
+
return [a.field, { text: Xe(i, s), ...i === null ? {} : { value: i }, ...typeof i == "number" ? { numberFormat: qe(s) } : {} }];
|
|
448
447
|
}));
|
|
449
448
|
}
|
|
450
|
-
function
|
|
451
|
-
const r = e.findIndex((
|
|
449
|
+
function ct(e, t) {
|
|
450
|
+
const r = e.findIndex((n) => t.includes(n.field));
|
|
452
451
|
return r < 0 ? 1 : r;
|
|
453
452
|
}
|
|
454
|
-
function
|
|
455
|
-
const s = [], i = Math.max(0, Math.min(a, e.columns.length)), c =
|
|
453
|
+
function G(e, t, r, n, o, a) {
|
|
454
|
+
const s = [], i = Math.max(0, Math.min(a, e.columns.length)), c = j({ fontSize: e.fontSizePt }, o);
|
|
456
455
|
i && s.push({ text: r, colSpan: i, style: { bold: !0, ...c } });
|
|
457
456
|
for (let u = i; u < e.columns.length; u++) {
|
|
458
|
-
const h = e.columns[u], m =
|
|
459
|
-
s.push({ ...m, text: m?.text ?? "", style:
|
|
457
|
+
const h = e.columns[u], m = n.get(h.field), v = e.autoStyles[u]?.[Ue(m?.value, h.format)] ?? e.cellStyles[u];
|
|
458
|
+
s.push({ ...m, text: m?.text ?? "", style: j(v, o) });
|
|
460
459
|
}
|
|
461
|
-
const l = { text: r, colSpan: e.columns.length, style: { bold: !0, ...c } }, d = i ? [s] : [[l], s], f = d.map((u) =>
|
|
460
|
+
const l = { text: r, colSpan: e.columns.length, style: { bold: !0, ...c } }, d = i ? [s] : [[l], s], f = d.map((u) => Gr(e, u, t));
|
|
462
461
|
return {
|
|
463
462
|
grid: { cells: d, colWidthsMm: e.colWidthsMm, rowHeightsMm: f, paddingMm: e.paddingMm },
|
|
464
463
|
heightMm: f.reduce((u, h) => u + h, 0)
|
|
465
464
|
};
|
|
466
465
|
}
|
|
467
|
-
function
|
|
468
|
-
let
|
|
466
|
+
function Gr(e, t, r) {
|
|
467
|
+
let n = e.rowHeightFloorMm, o = 0;
|
|
469
468
|
for (const a of t) {
|
|
470
469
|
let s = 0;
|
|
471
|
-
const i =
|
|
472
|
-
for (;
|
|
473
|
-
const c = ot(e, a.style), l =
|
|
474
|
-
|
|
470
|
+
const i = o + (a.colSpan ?? 1);
|
|
471
|
+
for (; o < i; o++) s += e.colWidthsMm[o] ?? 0;
|
|
472
|
+
const c = ot(e, a.style), l = _(a.text ?? "", s - e.paddingMm * 2, c.measureOptions, r);
|
|
473
|
+
n = Math.max(n, l.length * c.lineMm + e.paddingMm * 2);
|
|
475
474
|
}
|
|
476
|
-
return
|
|
475
|
+
return n;
|
|
477
476
|
}
|
|
478
|
-
function
|
|
479
|
-
const { templatePage:
|
|
477
|
+
function Wr(e, t, r) {
|
|
478
|
+
const { templatePage: n, current: o, warnings: a, nextId: s, pushCurrent: i } = r, c = () => Z(n, o), l = Math.max(o.marginTopMm, V(n)), d = n.layout === "wide" ? V(n) : l, f = {
|
|
480
479
|
id: r.tableId,
|
|
481
480
|
columnKeys: e.columns.map((p) => p.field),
|
|
482
481
|
...e.layout === void 0 ? {} : { layout: e.layout },
|
|
@@ -492,33 +491,33 @@ function Br(e, t, r) {
|
|
|
492
491
|
table: { ...f, role: "header", rowIndex: -1 },
|
|
493
492
|
style: t.borderStyle,
|
|
494
493
|
...e.meta || t.matrix ? { meta: { ...e.meta, ...t.matrix ? { matrix: t.matrix.header } : {} } } : {}
|
|
495
|
-
}, v = (p) =>
|
|
494
|
+
}, v = (p) => o.components.push({ ...m, topMm: p });
|
|
496
495
|
if (r.flow && e.header !== !1 && t.headerHeightMm > c() - l + 1e-3) throw new Error(`流式列表 ${e.id ?? e.dataset} 的表头高度超出单页可用范围`);
|
|
497
496
|
let y = Math.max(r.startTop ?? e.topMm, l);
|
|
498
497
|
e.header !== !1 && (v(y), y += t.headerHeightMm + r.mmPerRow);
|
|
499
498
|
function g() {
|
|
500
|
-
const p = Math.max(r.flow ||
|
|
501
|
-
return (e.header !== !1 && e.headerEveryPage !== !1 ? p + t.headerHeightMm : d) + [...h.values()].reduce((S,
|
|
499
|
+
const p = Math.max(r.flow || n.layout === "wide" ? 0 : e.topMm, d);
|
|
500
|
+
return (e.header !== !1 && e.headerEveryPage !== !1 ? p + t.headerHeightMm : d) + [...h.values()].reduce((S, P) => S + P.heightMm, 0);
|
|
502
501
|
}
|
|
503
502
|
function w() {
|
|
504
|
-
const p =
|
|
505
|
-
return Math.min(
|
|
503
|
+
const p = n.layout === "wide" ? 0 : o.marginBottomMm;
|
|
504
|
+
return Math.min(n.heightMm - p, Z(n, o)) - g();
|
|
506
505
|
}
|
|
507
506
|
function x(p) {
|
|
508
507
|
if (y + p <= c()) return;
|
|
509
|
-
i(),
|
|
510
|
-
const b = Math.max(r.flow ||
|
|
508
|
+
i(), o.components = [], o.heightMm = n.heightMm, n.layout === "wide" && (o.marginTopMm = 0, o.marginBottomMm = 0);
|
|
509
|
+
const b = Math.max(r.flow || n.layout === "wide" ? 0 : e.topMm, d);
|
|
511
510
|
e.header !== !1 && e.headerEveryPage !== !1 ? (v(b), y = b + t.headerHeightMm) : y = d;
|
|
512
|
-
for (const S of h.values())
|
|
511
|
+
for (const S of h.values()) k(S, "listgr", "group-header");
|
|
513
512
|
}
|
|
514
|
-
function
|
|
515
|
-
const
|
|
516
|
-
if (r.flow && p.heightMm >
|
|
517
|
-
p.heightMm >
|
|
513
|
+
function E(p, b, S, P) {
|
|
514
|
+
const T = w();
|
|
515
|
+
if (r.flow && p.heightMm > T + 1e-3) throw new Error(`流式列表 ${e.id ?? e.dataset} 的单行高度超出单页可用范围`);
|
|
516
|
+
p.heightMm > T && a.push(`列表 ${e.id ?? e.dataset} 行高 ${p.heightMm.toFixed(2)}mm 超出单页可用高度 ${T.toFixed(2)}mm,预览与打印可能截断内容`), x(p.heightMm), k(p, b, S, P);
|
|
518
517
|
}
|
|
519
|
-
function
|
|
520
|
-
const
|
|
521
|
-
S !== "header" && u.set(
|
|
518
|
+
function k(p, b, S, P) {
|
|
519
|
+
const T = p.table?.id ?? f.id, R = S === "header" ? -1 : u.get(T) ?? 0;
|
|
520
|
+
S !== "header" && u.set(T, R + p.grid.cells.length), o.components.push({
|
|
522
521
|
kind: "rect",
|
|
523
522
|
leftMm: e.leftMm,
|
|
524
523
|
topMm: y,
|
|
@@ -526,7 +525,7 @@ function Br(e, t, r) {
|
|
|
526
525
|
heightMm: p.heightMm,
|
|
527
526
|
grid: p.grid,
|
|
528
527
|
nid: s(b),
|
|
529
|
-
table: { ...f, ...p.table, role: S, rowIndex: R, ...
|
|
528
|
+
table: { ...f, ...p.table, role: S, rowIndex: R, ...P ? { source: P } : {} },
|
|
530
529
|
style: t.borderStyle,
|
|
531
530
|
...e.meta || p.meta ? { meta: { ...e.meta, ...p.meta } } : {}
|
|
532
531
|
}), y += p.heightMm;
|
|
@@ -534,182 +533,182 @@ function Br(e, t, r) {
|
|
|
534
533
|
function O(p) {
|
|
535
534
|
p <= w() && x(p);
|
|
536
535
|
}
|
|
537
|
-
return { keepTogether: O, placeGridRow:
|
|
536
|
+
return { keepTogether: O, placeGridRow: E, setGroupHeader: (p, b) => {
|
|
538
537
|
b ? h.set(p, b) : h.delete(p);
|
|
539
538
|
}, bottom: () => y };
|
|
540
539
|
}
|
|
541
|
-
function
|
|
540
|
+
function Vr(e, t) {
|
|
542
541
|
if (!e.rowKey) return;
|
|
543
542
|
const r = t[e.rowKey];
|
|
544
543
|
if ((typeof r != "string" || !r.trim()) && !(typeof r == "number" && Number.isFinite(r)))
|
|
545
544
|
throw new Error(`数据集 ${e.dataset} 的 ${e.rowKey} 应为稳定的字符串或有限数字主键`);
|
|
546
|
-
const
|
|
547
|
-
if (
|
|
548
|
-
if (
|
|
549
|
-
return { datasetId: e.dataset, rowKey: r, ...
|
|
545
|
+
const n = e.revisionField ? t[e.revisionField] : void 0, o = e.sourceTokenField ? t[e.sourceTokenField] : void 0;
|
|
546
|
+
if (n !== void 0 && typeof n != "string" && !(typeof n == "number" && Number.isFinite(n))) throw new Error("业务修订号应为字符串或有限数字");
|
|
547
|
+
if (o !== void 0 && typeof o != "string") throw new Error("来源令牌应为字符串");
|
|
548
|
+
return { datasetId: e.dataset, rowKey: r, ...n === void 0 ? {} : { revision: n }, ...o === void 0 ? {} : { sourceToken: o } };
|
|
550
549
|
}
|
|
551
|
-
function
|
|
550
|
+
function ae(e, t) {
|
|
552
551
|
const r = /* @__PURE__ */ new Map();
|
|
553
552
|
if (!e.rowKey) return r;
|
|
554
|
-
const
|
|
555
|
-
for (const
|
|
556
|
-
const a =
|
|
557
|
-
if (
|
|
558
|
-
|
|
553
|
+
const n = /* @__PURE__ */ new Set();
|
|
554
|
+
for (const o of t) {
|
|
555
|
+
const a = Vr(e, o), s = JSON.stringify(a.rowKey);
|
|
556
|
+
if (n.has(s)) throw new Error(`数据集 ${e.dataset} 的业务主键重复:${String(a.rowKey)}`);
|
|
557
|
+
n.add(s), r.set(o, a);
|
|
559
558
|
}
|
|
560
559
|
return r;
|
|
561
560
|
}
|
|
562
|
-
function
|
|
561
|
+
function Jr(e, t, r, n, o) {
|
|
563
562
|
if (!e.grandTotal) return;
|
|
564
|
-
const a = typeof e.grandTotal == "object" ? e.grandTotal : void 0, s =
|
|
563
|
+
const a = typeof e.grandTotal == "object" ? e.grandTotal : void 0, s = se(e)[0], i = a?.fields ?? s?.subtotal ?? [], c = a?.aggregates ?? s?.aggregates ?? [];
|
|
565
564
|
if (i.length === 0 && c.length === 0) {
|
|
566
|
-
|
|
565
|
+
n.warnings.push(`列表 ${e.id ?? ""} 配置了 grandTotal 但未提供合计字段(groupBy.subtotal 或 grandTotal.fields)`);
|
|
567
566
|
return;
|
|
568
567
|
}
|
|
569
|
-
const l =
|
|
570
|
-
|
|
568
|
+
const l = G(r, n.measurer, a?.label ?? "合计", it(e.columns, t, i, c), a?.style ?? {}, ct(e.columns, [...i, ...c.map((d) => d.field)]));
|
|
569
|
+
o.placeGridRow(l, "listgt", "grand-total");
|
|
571
570
|
}
|
|
572
|
-
function
|
|
571
|
+
function N(e) {
|
|
573
572
|
if (e?.aborted) {
|
|
574
573
|
const t = new Error("报表排版已取消");
|
|
575
574
|
throw t.name = "AbortError", t;
|
|
576
575
|
}
|
|
577
576
|
}
|
|
578
|
-
function
|
|
577
|
+
function se(e) {
|
|
579
578
|
const t = e.groups ?? (e.groupBy ? [e.groupBy] : []);
|
|
580
579
|
if (t.length > 16) throw new Error("列表最多支持 16 级分组");
|
|
581
580
|
return t;
|
|
582
581
|
}
|
|
583
|
-
function
|
|
584
|
-
const t =
|
|
585
|
-
return
|
|
582
|
+
function Ee(e) {
|
|
583
|
+
const t = xr(e), r = t.columns.reduce((o, a) => o + a.widthMm, 0), n = r > t.widthMm ? t.widthMm / r : 1;
|
|
584
|
+
return n === 1 ? t : { ...t, columns: t.columns.map((o) => ({ ...o, widthMm: o.widthMm * n })) };
|
|
586
585
|
}
|
|
587
|
-
function
|
|
588
|
-
const
|
|
589
|
-
if (!
|
|
590
|
-
const
|
|
586
|
+
function zr(e, t, r) {
|
|
587
|
+
const n = e.detail;
|
|
588
|
+
if (!n) return;
|
|
589
|
+
const o = /* @__PURE__ */ new Set();
|
|
591
590
|
for (const l of t) {
|
|
592
|
-
const d = he(l[
|
|
593
|
-
if (
|
|
594
|
-
|
|
591
|
+
const d = he(l[n.parentKey]);
|
|
592
|
+
if (o.has(d)) throw new Error("主从明细的主表关联键重复");
|
|
593
|
+
o.add(d);
|
|
595
594
|
}
|
|
596
|
-
const a = r.datasets[
|
|
595
|
+
const a = r.datasets[n.dataset] ?? [], s = /* @__PURE__ */ new Map(), i = [];
|
|
597
596
|
for (const l of a) {
|
|
598
|
-
const d = l[
|
|
599
|
-
if (!
|
|
597
|
+
const d = l[n.foreignKey];
|
|
598
|
+
if (!lt(d) && n.unmatched === "ignore") continue;
|
|
600
599
|
const f = he(d);
|
|
601
|
-
if (!
|
|
602
|
-
if (
|
|
600
|
+
if (!o.has(f)) {
|
|
601
|
+
if (n.unmatched !== "ignore") throw new Error(`明细数据集 ${n.dataset} 存在未关联的业务键`);
|
|
603
602
|
continue;
|
|
604
603
|
}
|
|
605
604
|
const u = s.get(f);
|
|
606
605
|
u ? u.push(l) : s.set(f, [l]), i.push(l);
|
|
607
606
|
}
|
|
608
|
-
const c =
|
|
609
|
-
return { list: c, inter: { ...
|
|
607
|
+
const c = Ee({ ...e, id: `${e.id ?? e.dataset}:detail`, dataset: n.dataset, rowKey: n.rowKey, revisionField: n.revisionField, sourceTokenField: n.sourceTokenField, computed: void 0, columns: n.columns, headerGrid: void 0, rowHeightMm: n.rowHeightMm ?? e.rowHeightMm, detail: void 0 });
|
|
608
|
+
return { list: c, inter: { ...Pe(c, r.measurer, i, r.signal), rowHeightFloorMm: c.rowHeightMm ?? 0 }, rows: s, sources: ae(c, i) };
|
|
610
609
|
}
|
|
611
|
-
function
|
|
610
|
+
function lt(e) {
|
|
612
611
|
return typeof e == "string" && !!e.trim() || typeof e == "number" && Number.isFinite(e);
|
|
613
612
|
}
|
|
614
613
|
function he(e) {
|
|
615
|
-
if (!
|
|
616
|
-
return
|
|
614
|
+
if (!lt(e)) throw new Error("主从关联键必须是非空字符串或有限数字");
|
|
615
|
+
return at(e);
|
|
617
616
|
}
|
|
618
|
-
function*
|
|
617
|
+
function* _r(e, t, r, n, o) {
|
|
619
618
|
if (!r) return;
|
|
620
619
|
const a = r.rows.get(he(t[e.detail.parentKey])) ?? [];
|
|
621
620
|
if (!a.length) return;
|
|
622
|
-
const s = { id: `${
|
|
623
|
-
e.detail.label &&
|
|
621
|
+
const s = { id: `${n.tableId}:detail`, columnKeys: r.list.columns.map((i) => i.field), title: e.detail.label };
|
|
622
|
+
e.detail.label && o.placeGridRow({ ...G(r.inter, n.measurer, e.detail.label, /* @__PURE__ */ new Map(), {}, r.list.columns.length), table: s }, "listdl", "group-header"), e.detail.header !== !1 && o.placeGridRow({ grid: r.inter.headerGrid, heightMm: r.inter.headerHeightMm, table: s }, "listdh", "header"), yield* n.takePages();
|
|
624
623
|
for (const i of a)
|
|
625
|
-
|
|
624
|
+
N(n.signal), o.placeGridRow({ ...J(r.inter, i, n.measurer), table: s }, "listdr", "body", r.sources.get(i)), yield* n.takePages();
|
|
626
625
|
}
|
|
627
|
-
function
|
|
626
|
+
function dt(e) {
|
|
628
627
|
if (e.matrix || e.detail || e.groups?.length || e.groupBy || e.rowVisibleWhen) throw new Error("树形布局不能同时配置普通分组、矩阵、主从或行可见条件");
|
|
629
628
|
if (e.rowKey && e.rowKey !== e.tree.idField) throw new Error("树形布局的 rowKey 应与 idField 一致");
|
|
630
629
|
if (!e.columns.some((t) => t.field === e.tree.labelField && !t.hidden)) throw new Error("树形布局需要可见的标签列");
|
|
631
|
-
|
|
630
|
+
nr(e.tree, e.computed);
|
|
632
631
|
}
|
|
633
|
-
function
|
|
634
|
-
|
|
635
|
-
const
|
|
636
|
-
for (const c of
|
|
632
|
+
function qr(e, t, r) {
|
|
633
|
+
dt(e);
|
|
634
|
+
const n = Qe(t, e.tree, { signal: r.signal, computed: e.computed?.length ? { fields: e.computed, formula: r.formula } : void 0 }), o = { ...e, rowKey: e.tree.idField }, a = ae(o, n.entries.map((c) => c.original)), s = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new WeakMap();
|
|
635
|
+
for (const c of n.entries)
|
|
637
636
|
s.set(c.row, a.get(c.original)), i.set(c.row, c);
|
|
638
|
-
return { list:
|
|
637
|
+
return { list: o, rows: n.rows, sources: s, treeRows: i, totalRows: n.leaves };
|
|
639
638
|
}
|
|
640
|
-
function
|
|
639
|
+
function Ur(e, t) {
|
|
641
640
|
if (e.cardinality === "record") {
|
|
642
641
|
if (t.length > 1) throw new Error(`单记录区域 ${e.id ?? e.dataset} 仅允许 0 或 1 行数据`);
|
|
643
642
|
if (e.tree || e.matrix || e.detail || e.groups?.length || e.groupBy || e.grandTotal || e.rowVisibleWhen) throw new Error("单记录区域不能配置树、矩阵、主从、分组、总计或行过滤");
|
|
644
643
|
if (!t.length) return { list: { ...e, columns: e.columns.map((r) => ({ ...r, editable: !1 })) }, rows: [{}], sources: /* @__PURE__ */ new Map() };
|
|
645
644
|
}
|
|
646
645
|
}
|
|
647
|
-
function
|
|
648
|
-
const
|
|
649
|
-
if (
|
|
650
|
-
const
|
|
651
|
-
if (
|
|
652
|
-
return r.prepared.set(e,
|
|
646
|
+
function ut(e, t, r) {
|
|
647
|
+
const n = r.prepared.get(e);
|
|
648
|
+
if (n) return n;
|
|
649
|
+
const o = Ur(e, t);
|
|
650
|
+
if (o)
|
|
651
|
+
return r.prepared.set(e, o), o;
|
|
653
652
|
if (e.tree) {
|
|
654
|
-
const c =
|
|
653
|
+
const c = qr(e, t, r);
|
|
655
654
|
return r.prepared.set(e, c), c;
|
|
656
655
|
}
|
|
657
656
|
let a = e.computed?.length ? Me(t, { fields: e.computed, signal: r.signal, formula: r.formula }).rows : t;
|
|
658
657
|
const s = a === t ? void 0 : new Map(a.map((c, l) => [c, t[l]]));
|
|
659
|
-
e.rowVisibleWhen && (a = a.filter(
|
|
660
|
-
const i =
|
|
658
|
+
e.rowVisibleWhen && (a = a.filter(H(e.rowVisibleWhen)));
|
|
659
|
+
const i = vr(e, a);
|
|
661
660
|
if (!e.matrix) {
|
|
662
|
-
const c =
|
|
661
|
+
const c = ae(e, s ? a.map((l) => s.get(l)) : a);
|
|
663
662
|
i.sources = s ? new Map(a.map((l) => [l, c.get(s.get(l))])) : c;
|
|
664
663
|
}
|
|
665
664
|
return r.prepared.set(e, i), i;
|
|
666
665
|
}
|
|
667
|
-
function
|
|
668
|
-
if (!
|
|
669
|
-
const { current:
|
|
670
|
-
i + c <=
|
|
671
|
-
}
|
|
672
|
-
function*
|
|
673
|
-
const
|
|
674
|
-
e =
|
|
675
|
-
const a =
|
|
676
|
-
|
|
677
|
-
const l =
|
|
666
|
+
function Xr(e, t, r, n) {
|
|
667
|
+
if (!n.flow) return;
|
|
668
|
+
const { current: o, templatePage: a } = n, s = Math.max(o.marginTopMm, V(a)), i = Math.max(n.startTop ?? e.topMm, s), c = (e.header === !1 ? 0 : t.headerHeightMm) + (r[0] ? J(t, r[0], n.measurer).heightMm : 0);
|
|
669
|
+
i + c <= Z(a, o) + 1e-3 || i <= s + 1e-3 || (n.pushCurrent(), o.components = [], o.heightMm = a.heightMm, a.layout === "wide" && (o.marginTopMm = 0, o.marginBottomMm = 0), n.startTop = Math.max(o.marginTopMm, V(a)));
|
|
670
|
+
}
|
|
671
|
+
function* Yr(e, t, r) {
|
|
672
|
+
const n = ut(e, t, r), o = n.rows;
|
|
673
|
+
e = n.list, e.layout === "wide" && (r.current.widthMm = Math.max(r.current.widthMm, e.leftMm + e.widthMm + r.current.marginRightMm));
|
|
674
|
+
const a = n.sources ?? ae(e, o), s = Ee(e), i = se(s), c = { ...Pe(s, r.measurer, o, r.signal), rowHeightFloorMm: s.rowHeightMm ?? 0, matrix: n.matrix, ...n.treeRows ? { tree: { list: s, rows: n.treeRows } } : {} };
|
|
675
|
+
Xr(s, c, o, r);
|
|
676
|
+
const l = Wr(s, c, r), d = zr(s, o, r);
|
|
678
677
|
let f;
|
|
679
|
-
for (const u of
|
|
680
|
-
if (
|
|
681
|
-
l.placeGridRow(f ??
|
|
678
|
+
for (const u of st(o, i)) {
|
|
679
|
+
if (N(r.signal), u.kind === "row")
|
|
680
|
+
l.placeGridRow(f ?? J(c, u.row, r.measurer), "listr", yr(n.matrix, u.row), a.get(u.row)), f = void 0, yield* r.takePages(), yield* _r(s, u.row, d, r, l);
|
|
682
681
|
else if (u.kind === "groupHeader") {
|
|
683
|
-
const h =
|
|
684
|
-
f ??=
|
|
685
|
-
const m = i.slice(u.depth + 1).reduce((v, y) => v +
|
|
682
|
+
const h = G(c, r.measurer, u.label, /* @__PURE__ */ new Map(), u.group.headerStyle ?? {}, s.columns.length);
|
|
683
|
+
f ??= J(c, u.firstRow, r.measurer);
|
|
684
|
+
const m = i.slice(u.depth + 1).reduce((v, y) => v + G(c, r.measurer, (y.headerTemplate ?? "{value}").replace(/\{value\}/g, xe(u.firstRow[y.field])), /* @__PURE__ */ new Map(), y.headerStyle ?? {}, s.columns.length).heightMm, 0);
|
|
686
685
|
u.group.keepWithNext !== !1 && l.keepTogether(h.heightMm + m + f.heightMm), l.placeGridRow(h, "listg", "group-header"), u.group.repeatHeader && l.setGroupHeader(u.depth, h);
|
|
687
686
|
} else if (u.kind === "subtotal") {
|
|
688
|
-
const h = u.group.subtotal ?? [], m = u.group.aggregates ?? [], v =
|
|
687
|
+
const h = u.group.subtotal ?? [], m = u.group.aggregates ?? [], v = G(c, r.measurer, u.label, it(s.columns, u.rows, h, m), u.group.subtotalStyle ?? {}, ct(s.columns, [...h, ...m.map((y) => y.field)]));
|
|
689
688
|
l.placeGridRow(v, "listst", "subtotal");
|
|
690
689
|
} else l.setGroupHeader(u.depth);
|
|
691
690
|
yield* r.takePages();
|
|
692
691
|
}
|
|
693
|
-
|
|
692
|
+
Jr(s, n.totalRows ?? o, c, r, l), r.finished?.(l.bottom()), yield* r.takePages();
|
|
694
693
|
}
|
|
695
|
-
function
|
|
694
|
+
function ie(e) {
|
|
696
695
|
return e.kind !== "list" && (e.pageAnchor !== void 0 || e.kind === "text" && typeof e.text == "string" && (e.text.includes("{page}") || e.text.includes("{totalPages}")));
|
|
697
696
|
}
|
|
698
|
-
function
|
|
697
|
+
function ce(e, t) {
|
|
699
698
|
return {
|
|
700
699
|
...e,
|
|
701
700
|
...e.text === void 0 ? {} : { text: t(e.text) },
|
|
702
701
|
...e.lines ? { lines: e.lines.map(t) } : {},
|
|
703
|
-
...e.richParagraphs ? { richParagraphs: e.richParagraphs.map((r) => ({ ...r, segments: r.segments.map((
|
|
704
|
-
...e.grid ? { grid: { ...e.grid, cells: e.grid.cells.map((r) => r.map((
|
|
702
|
+
...e.richParagraphs ? { richParagraphs: e.richParagraphs.map((r) => ({ ...r, segments: r.segments.map((n) => ({ ...n, ...n.text === void 0 ? {} : { text: t(n.text) } })) })) } : {},
|
|
703
|
+
...e.grid ? { grid: { ...e.grid, cells: e.grid.cells.map((r) => r.map((n) => n ? { ...n, ...n.text === void 0 ? {} : { text: t(n.text) }, ...n.children ? { children: n.children.map((o) => ce(o, t)) } : {} } : null)) } } : {}
|
|
705
704
|
};
|
|
706
705
|
}
|
|
707
|
-
function
|
|
706
|
+
function Qr(e) {
|
|
708
707
|
let t = !1;
|
|
709
|
-
for (const r of e.pages) for (const
|
|
708
|
+
for (const r of e.pages) for (const n of r.components) ie(n) && ce(n, (o) => (o.includes("{totalPages}") && (t = !0), o));
|
|
710
709
|
return t;
|
|
711
710
|
}
|
|
712
|
-
function
|
|
711
|
+
function Zr(e, t, r, n, o, a) {
|
|
713
712
|
const s = {
|
|
714
713
|
pageWidthMm: t.widthMm,
|
|
715
714
|
pageHeightMm: t.heightMm,
|
|
@@ -721,41 +720,41 @@ function Yr(e, t, r, o, n, a) {
|
|
|
721
720
|
components: t.components,
|
|
722
721
|
...e.meta ? { meta: e.meta } : {}
|
|
723
722
|
}, i = (c) => {
|
|
724
|
-
const l = c.replace(/\{page\}/g, String(
|
|
723
|
+
const l = c.replace(/\{page\}/g, String(n));
|
|
725
724
|
return a === void 0 ? l : l.replace(/\{totalPages\}/g, String(a));
|
|
726
725
|
};
|
|
727
|
-
for (const c of r) s.components.push(
|
|
726
|
+
for (const c of r) s.components.push(ce(c, i));
|
|
728
727
|
if (e.layout === "wide") {
|
|
729
728
|
const c = s.components.reduce((l, d) => Math.max(l, d.topMm + d.heightMm), 0);
|
|
730
|
-
s.marginBottomMm =
|
|
729
|
+
s.marginBottomMm = o ? e.marginBottomMm ?? 0 : 0, s.pageHeightMm = Math.max(1, c + s.marginBottomMm);
|
|
731
730
|
}
|
|
732
731
|
return s;
|
|
733
732
|
}
|
|
734
|
-
function
|
|
735
|
-
return e.cells.reduce((t, r) => t + r.reduce((
|
|
733
|
+
function Re(e) {
|
|
734
|
+
return e.cells.reduce((t, r) => t + r.reduce((n, o) => n + (o ? 1 + (o.children?.reduce((a, s) => a + ft(s), 0) ?? 0) : 0), 0), 0);
|
|
736
735
|
}
|
|
737
|
-
function
|
|
738
|
-
return e.grid ?
|
|
736
|
+
function ft(e) {
|
|
737
|
+
return e.grid ? Re(e.grid) : 0;
|
|
739
738
|
}
|
|
740
|
-
function
|
|
739
|
+
function le(e) {
|
|
741
740
|
for (const t of ["maxPages", "maxCells", "knownTotalPages"]) if (e[t] !== void 0 && (!Number.isSafeInteger(e[t]) || e[t] < 1)) throw new RangeError(`${t} 应为正安全整数`);
|
|
742
|
-
|
|
741
|
+
oe(e.maxChartComponents);
|
|
743
742
|
}
|
|
744
|
-
function
|
|
745
|
-
const r =
|
|
746
|
-
return (
|
|
743
|
+
function en(e, t) {
|
|
744
|
+
const r = ut(e, t.datasets[e.dataset] ?? [], t), n = Ee(r.list), o = { ...Pe(n, t.measurer, r.rows, t.signal), rowHeightFloorMm: n.rowHeightMm ?? 0 };
|
|
745
|
+
return (n.header === !1 ? 0 : o.headerHeightMm) + r.rows.reduce((a, s) => a + J(o, s, t.measurer).heightMm, 0);
|
|
747
746
|
}
|
|
748
|
-
function*
|
|
749
|
-
const { templatePage: t, current: r } = e,
|
|
747
|
+
function* tn(e) {
|
|
748
|
+
const { templatePage: t, current: r } = e, n = new Map(t.components.map((a, s) => [a, s])), o = (a, s, i) => {
|
|
750
749
|
const c = e.datasets[a.dataset];
|
|
751
|
-
return Array.isArray(c) || e.warnings.push(`数据集 ${a.dataset} 未提供数据,列表 ${a.id ?? ""} 输出为空`),
|
|
750
|
+
return Array.isArray(c) || e.warnings.push(`数据集 ${a.dataset} 未提供数据,列表 ${a.id ?? ""} 输出为空`), Yr(a, Array.isArray(c) ? c : [], { ...e, tableId: `${e.tableId}:${n.get(a)}`, startTop: s, finished: i, flow: !!t.flow });
|
|
752
751
|
};
|
|
753
752
|
if (t.flow) {
|
|
754
|
-
yield*
|
|
753
|
+
yield* Cr({
|
|
755
754
|
page: t,
|
|
756
|
-
active: () =>
|
|
755
|
+
active: () => N(e.signal),
|
|
757
756
|
top: () => Math.max(r.marginTopMm, V(t)),
|
|
758
|
-
bottom: () =>
|
|
757
|
+
bottom: () => Z(t, r),
|
|
759
758
|
append: (a) => {
|
|
760
759
|
r.components.push(...e.resolveChart(a));
|
|
761
760
|
},
|
|
@@ -763,34 +762,34 @@ function* Zr(e) {
|
|
|
763
762
|
e.pushCurrent(), r.components = [], r.heightMm = t.heightMm, t.layout === "wide" && (r.marginTopMm = 0, r.marginBottomMm = 0);
|
|
764
763
|
},
|
|
765
764
|
takePages: e.takePages,
|
|
766
|
-
height: (a) =>
|
|
767
|
-
list:
|
|
765
|
+
height: (a) => en(a, e),
|
|
766
|
+
list: o
|
|
768
767
|
});
|
|
769
768
|
return;
|
|
770
769
|
}
|
|
771
770
|
for (const a of t.components)
|
|
772
|
-
|
|
771
|
+
ie(a) || (a.kind === "list" ? yield* o(a) : r.components.push(...e.resolveChart(a)));
|
|
773
772
|
}
|
|
774
|
-
function*
|
|
773
|
+
function* z(e, t, r, n, o, a = /* @__PURE__ */ new WeakMap(), s) {
|
|
775
774
|
let i = 0, c = 0, l = 0;
|
|
776
|
-
const d =
|
|
777
|
-
for (const { pageIndex: h, page: m } of
|
|
778
|
-
|
|
779
|
-
const v =
|
|
775
|
+
const d = gr(r.measurer ?? Je), f = wr(t, r.signal, r.maxChartComponents), u = (h) => `${h}_${(++i).toString(36)}`;
|
|
776
|
+
for (const { pageIndex: h, page: m } of Ar(e, t, r)) {
|
|
777
|
+
N(r.signal);
|
|
778
|
+
const v = Nr(m), y = m.components.filter(ie);
|
|
780
779
|
let g = [];
|
|
781
|
-
const w = (
|
|
782
|
-
if (
|
|
783
|
-
if (r.maxCells !== void 0 && (l += [...v.components, ...y].reduce((
|
|
784
|
-
throw new
|
|
785
|
-
g.push(
|
|
780
|
+
const w = (E = !1) => {
|
|
781
|
+
if (N(r.signal), r.maxPages !== void 0 && c >= r.maxPages) throw new W(r.maxPages, c + 1);
|
|
782
|
+
if (r.maxCells !== void 0 && (l += [...v.components, ...y].reduce((k, O) => k + ft(O), 0), l > r.maxCells))
|
|
783
|
+
throw new Y(r.maxCells, l);
|
|
784
|
+
g.push(Zr(m, v, y, ++c, E, o));
|
|
786
785
|
}, x = () => {
|
|
787
|
-
const
|
|
788
|
-
return g = [],
|
|
786
|
+
const E = g;
|
|
787
|
+
return g = [], E;
|
|
789
788
|
};
|
|
790
|
-
yield*
|
|
789
|
+
yield* tn({
|
|
791
790
|
templatePage: m,
|
|
792
791
|
current: v,
|
|
793
|
-
warnings:
|
|
792
|
+
warnings: n,
|
|
794
793
|
nextId: u,
|
|
795
794
|
pushCurrent: w,
|
|
796
795
|
takePages: x,
|
|
@@ -806,75 +805,86 @@ function* Z(e, t, r, o, n, a = /* @__PURE__ */ new WeakMap(), s) {
|
|
|
806
805
|
}
|
|
807
806
|
s && (s.chartComponents = f.used());
|
|
808
807
|
}
|
|
809
|
-
function
|
|
810
|
-
|
|
811
|
-
let
|
|
812
|
-
for (const
|
|
813
|
-
return
|
|
808
|
+
function mo(e, t, r = {}) {
|
|
809
|
+
le(r);
|
|
810
|
+
let n = 0;
|
|
811
|
+
for (const o of z(e, t, { ...r, onWarning: void 0 }, [])) n++;
|
|
812
|
+
return n;
|
|
814
813
|
}
|
|
815
|
-
function*
|
|
816
|
-
yield*
|
|
814
|
+
function* ho(e, t, r = {}) {
|
|
815
|
+
yield* rn(e, t, r);
|
|
817
816
|
}
|
|
818
|
-
function*
|
|
819
|
-
|
|
820
|
-
const
|
|
817
|
+
function* rn(e, t, r, n) {
|
|
818
|
+
le(r);
|
|
819
|
+
const o = Qr(e), a = /* @__PURE__ */ new WeakMap();
|
|
821
820
|
let s = r.knownTotalPages;
|
|
822
|
-
if (
|
|
821
|
+
if (o && s === void 0) {
|
|
823
822
|
s = 0;
|
|
824
|
-
for (const l of
|
|
823
|
+
for (const l of z(e, t, r, [], void 0, a)) s++;
|
|
825
824
|
}
|
|
826
825
|
const i = [];
|
|
827
826
|
let c = 0;
|
|
828
|
-
for (const l of
|
|
827
|
+
for (const l of z(e, t, r, i, s, a, n)) {
|
|
829
828
|
for (; c < i.length; c++) r.onWarning?.(i[c]);
|
|
830
829
|
yield l;
|
|
831
830
|
}
|
|
832
831
|
}
|
|
833
832
|
function mt(e, t, r = {}) {
|
|
834
|
-
const
|
|
835
|
-
|
|
836
|
-
const
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
}
|
|
840
|
-
|
|
833
|
+
const n = typeof r == "number" ? { mmPerRow: r } : r;
|
|
834
|
+
le(n);
|
|
835
|
+
const o = [], a = { chartComponents: 0 }, s = [...z(e, t, n, o, n.knownTotalPages, void 0, a)];
|
|
836
|
+
return gt(e, n, s, o, a);
|
|
837
|
+
}
|
|
838
|
+
async function ht(e, t, r = {}) {
|
|
839
|
+
le(r), N(r.signal);
|
|
840
|
+
const n = [], o = [], a = { chartComponents: 0 };
|
|
841
|
+
let s = performance.now(), i = 0;
|
|
842
|
+
for (const c of z(e, t, r, n, r.knownTotalPages, void 0, a))
|
|
843
|
+
o.push(c), (++i >= 8 || performance.now() - s >= 8) && (await new Promise((l) => setTimeout(l, 0)), N(r.signal), s = performance.now(), i = 0);
|
|
844
|
+
return N(r.signal), gt(e, r, o, n, a);
|
|
845
|
+
}
|
|
846
|
+
function gt(e, t, r, n, o) {
|
|
847
|
+
for (const a of r) a.components = a.components.map((s) => ie(s) ? ce(s, (i) => i.replace(/\{totalPages\}/g, String(r.length))) : s);
|
|
848
|
+
return n.forEach((a) => t.onWarning?.(a)), { plan: { schemaVersion: be, ...ke(e) ? { requiresRecalculation: !0 } : {}, pages: r }, warnings: n, ...o };
|
|
849
|
+
}
|
|
850
|
+
function nn(e) {
|
|
841
851
|
const t = e.columns.find((a) => !a.hidden)?.field;
|
|
842
852
|
if (!t) return { groups: 0, total: 0 };
|
|
843
|
-
const r =
|
|
844
|
-
return { groups: r.filter((a) =>
|
|
853
|
+
const r = se(e), n = (a = [], s = []) => a.includes(t) || s.some((i) => i.field === t), o = typeof e.grandTotal == "object" ? e.grandTotal : void 0;
|
|
854
|
+
return { groups: r.filter((a) => n(a.subtotal, a.aggregates)).length, total: Number(n(o?.fields ?? r[0]?.subtotal, o?.aggregates ?? r[0]?.aggregates)) };
|
|
845
855
|
}
|
|
846
|
-
function
|
|
847
|
-
|
|
848
|
-
const
|
|
849
|
-
return
|
|
856
|
+
function on(e, t, r) {
|
|
857
|
+
dt(e);
|
|
858
|
+
const n = Ye(t[e.dataset] ?? [], e.tree, r), o = e.columns.filter((s) => !s.hidden).length, a = e.header === !1 ? 0 : e.headerGrid ? Re(e.headerGrid) : o;
|
|
859
|
+
return n.length * o + a + +!!e.grandTotal * 2 * o;
|
|
850
860
|
}
|
|
851
|
-
function
|
|
852
|
-
if (e.tree) return
|
|
861
|
+
function go(e, t, r = {}) {
|
|
862
|
+
if (e.tree) return on(e, t, r.signal);
|
|
853
863
|
if (e.matrix) {
|
|
854
864
|
let c = t[e.dataset] ?? [];
|
|
855
|
-
e.computed?.length && (c = Me(c, { fields: e.computed, ...r }).rows), e.rowVisibleWhen && (c = c.filter(
|
|
856
|
-
const l =
|
|
865
|
+
e.computed?.length && (c = Me(c, { fields: e.computed, ...r }).rows), e.rowVisibleWhen && (c = c.filter(H(e.rowVisibleWhen)));
|
|
866
|
+
const l = rr(c, e.matrix);
|
|
857
867
|
return l.cells + (e.header === !1 ? 0 : l.columnCount * (e.matrix.hierarchy ? e.matrix.columnFields.length + 1 : 1));
|
|
858
868
|
}
|
|
859
|
-
const
|
|
860
|
-
let i = (
|
|
861
|
-
if (i += e.header === !1 ? 0 : e.headerGrid ?
|
|
869
|
+
const n = t[e.dataset]?.length ?? 0, o = e.columns.filter((c) => !c.hidden).length, a = se(e).length, s = nn(e);
|
|
870
|
+
let i = (n * (1 + 2 * a + s.groups) + +!!e.grandTotal * (1 + s.total)) * o;
|
|
871
|
+
if (i += e.header === !1 ? 0 : e.headerGrid ? Re(e.headerGrid) : o, e.cardinality === "record" && n === 0 && (i += o), e.detail) {
|
|
862
872
|
const c = t[e.detail.dataset]?.length ?? 0, l = e.detail.columns.filter((d) => !d.hidden).length;
|
|
863
|
-
i += (c +
|
|
873
|
+
i += (c + n * (+(e.detail.header !== !1) + +!!e.detail.label)) * l;
|
|
864
874
|
}
|
|
865
875
|
if (!Number.isSafeInteger(i)) throw new RangeError("报表单元格估算超出安全整数预算");
|
|
866
876
|
return i;
|
|
867
877
|
}
|
|
868
|
-
class
|
|
878
|
+
class an extends Error {
|
|
869
879
|
constructor(t) {
|
|
870
880
|
super(t.map((r) => r.message).join(";")), this.issues = t, this.name = "ReportValidationError";
|
|
871
881
|
}
|
|
872
882
|
}
|
|
873
|
-
function
|
|
883
|
+
function Le(e, t, r) {
|
|
874
884
|
if (!Number.isSafeInteger(e) || e < 1 || e > r) throw new Error(`校验 ${t} 超出预算`);
|
|
875
885
|
return e;
|
|
876
886
|
}
|
|
877
|
-
function
|
|
887
|
+
function sn(e) {
|
|
878
888
|
if (e.aggregates && e.scope !== "dataset") throw new Error("仅数据集规则允许汇总");
|
|
879
889
|
if (e.aggregates && (!Array.isArray(e.aggregates) || e.aggregates.length > 64)) throw new Error("校验汇总最多 64 项");
|
|
880
890
|
const t = /* @__PURE__ */ new Set();
|
|
@@ -883,7 +893,7 @@ function oo(e) {
|
|
|
883
893
|
t.add(r.field), r.valueField !== void 0 && K(r.valueField), r.weightField !== void 0 && K(r.weightField), Se([], { ...r, field: r.valueField ?? r.field });
|
|
884
894
|
}
|
|
885
895
|
}
|
|
886
|
-
function
|
|
896
|
+
function pt(e) {
|
|
887
897
|
if (!Array.isArray(e) || e.length > 256 || Object.keys(e).length !== e.length) throw new Error("校验规则最多 256 条且不允许空位");
|
|
888
898
|
const t = /* @__PURE__ */ new Set();
|
|
889
899
|
return e.map((r) => {
|
|
@@ -892,118 +902,118 @@ function ht(e) {
|
|
|
892
902
|
if (t.add(r.id), r.field !== void 0 && K(r.field), r.dataset !== void 0 && K(r.dataset), typeof r.message != "string" || !r.message.trim() || r.message.length > 2048) throw new Error("校验规则需要有界提示文案");
|
|
893
903
|
if (r.severity !== void 0 && !["error", "warning"].includes(r.severity)) throw new Error("未知校验严重程度");
|
|
894
904
|
if (r.scope !== void 0 && !["row", "dataset"].includes(r.scope)) throw new Error("未知校验范围");
|
|
895
|
-
|
|
896
|
-
const
|
|
897
|
-
return { rule: r, assert:
|
|
905
|
+
sn(r);
|
|
906
|
+
const n = { nodes: 0 }, o = H(r.assert, n), a = r.when ? H(r.when, n) : void 0;
|
|
907
|
+
return { rule: r, assert: o, when: a, checks: n.nodes };
|
|
898
908
|
});
|
|
899
909
|
}
|
|
900
|
-
function
|
|
910
|
+
function He(e) {
|
|
901
911
|
if (e?.aborted) {
|
|
902
912
|
const t = new Error("报表校验已取消");
|
|
903
913
|
throw t.name = "AbortError", t;
|
|
904
914
|
}
|
|
905
915
|
}
|
|
906
|
-
function
|
|
907
|
-
const
|
|
908
|
-
if (
|
|
909
|
-
return { ruleId: e.id, rowIndex: r, ...
|
|
916
|
+
function cn(e, t, r, n) {
|
|
917
|
+
const o = n && Object.prototype.hasOwnProperty.call(t, n) ? t[n] : void 0;
|
|
918
|
+
if (o !== void 0 && typeof o != "string" && !(typeof o == "number" && Number.isFinite(o))) throw new Error("校验定位需要稳定的文本或数值业务键");
|
|
919
|
+
return { ruleId: e.id, rowIndex: r, ...o === void 0 ? {} : { rowKey: o }, field: e.field, severity: e.severity ?? "error", message: e.message };
|
|
910
920
|
}
|
|
911
|
-
function
|
|
921
|
+
function ln(e, t) {
|
|
912
922
|
const r = t.computed?.length ? { fields: t.computed, formula: t.formula, signal: t.signal } : void 0;
|
|
913
923
|
if (t.tree) {
|
|
914
|
-
const
|
|
915
|
-
if (
|
|
916
|
-
return { rows:
|
|
924
|
+
const o = Qe(e, t.tree, { signal: t.signal, computed: r });
|
|
925
|
+
if (o.rows.length > 1e5) throw new Error("校验展开后数据最多 100000 行");
|
|
926
|
+
return { rows: o.rows, summaryRows: o.leaves, rowKey: t.tree.idField };
|
|
917
927
|
}
|
|
918
|
-
const
|
|
919
|
-
return { rows:
|
|
928
|
+
const n = r ? Me(e, r).rows : e;
|
|
929
|
+
return { rows: n, summaryRows: n, rowKey: t.rowKey };
|
|
920
930
|
}
|
|
921
|
-
function
|
|
931
|
+
function dn(e, t) {
|
|
922
932
|
const r = /* @__PURE__ */ new Set();
|
|
923
|
-
e.forEach((
|
|
924
|
-
if (!
|
|
933
|
+
e.forEach((n) => {
|
|
934
|
+
if (!n || typeof n != "object" || Array.isArray(n)) throw new Error("校验数据行应为对象");
|
|
925
935
|
if (!t) return;
|
|
926
|
-
const
|
|
927
|
-
if (!(typeof
|
|
928
|
-
if (r.has(
|
|
929
|
-
r.add(
|
|
936
|
+
const o = Object.prototype.hasOwnProperty.call(n, t) ? n[t] : void 0;
|
|
937
|
+
if (!(typeof o == "string" && o.trim()) && !(typeof o == "number" && Number.isFinite(o))) throw new Error("校验定位需要稳定业务键");
|
|
938
|
+
if (r.has(o)) throw new Error("校验业务键重复");
|
|
939
|
+
r.add(o);
|
|
930
940
|
});
|
|
931
941
|
}
|
|
932
|
-
function
|
|
933
|
-
return
|
|
942
|
+
function po(e, t) {
|
|
943
|
+
return wt(e, t, { checks: 0 });
|
|
934
944
|
}
|
|
935
|
-
function
|
|
945
|
+
function wt(e, t, r) {
|
|
936
946
|
if (!Array.isArray(e) || e.length > 1e5) throw new Error("校验数据最多 100000 行");
|
|
937
|
-
|
|
938
|
-
const
|
|
947
|
+
He(t.signal);
|
|
948
|
+
const n = Le(t.maxChecks ?? 2e6, "maxChecks", 1e7), o = Le(t.maxIssues ?? 1e3, "maxIssues", 1e4);
|
|
939
949
|
t.rowKey !== void 0 && K(t.rowKey);
|
|
940
|
-
const a =
|
|
941
|
-
|
|
942
|
-
const l =
|
|
943
|
-
if (r.checks += d, r.checks >
|
|
950
|
+
const a = ln(e, t), { rows: s, summaryRows: i, rowKey: c } = a;
|
|
951
|
+
dn(s, c);
|
|
952
|
+
const l = pt(t.rules), d = l.reduce((u, h) => u + (h.rule.scope === "dataset" ? h.checks + i.length * (h.rule.aggregates?.length ?? 0) : s.length * h.checks), 0);
|
|
953
|
+
if (r.checks += d, r.checks > n) throw new Error("整批校验超出 maxChecks 预算");
|
|
944
954
|
const f = [];
|
|
945
955
|
for (const u of l)
|
|
946
956
|
(u.rule.scope === "dataset" ? [Object.fromEntries((u.rule.aggregates ?? []).map((m) => [m.field, Se(i, { ...m, field: m.valueField ?? m.field })]))] : s).forEach((m, v) => {
|
|
947
|
-
if (
|
|
957
|
+
if (He(t.signal), !m || typeof m != "object" || Array.isArray(m)) throw new Error("校验数据行应为对象");
|
|
948
958
|
if (!(u.when && !u.when(m) || u.assert(m))) {
|
|
949
|
-
if (f.length >=
|
|
950
|
-
f.push(
|
|
959
|
+
if (f.length >= o) throw new Error("校验问题超出 maxIssues 预算,请缩小范围");
|
|
960
|
+
f.push(cn(u.rule, m, u.rule.scope === "dataset" ? void 0 : v, u.rule.scope === "dataset" ? void 0 : c));
|
|
951
961
|
}
|
|
952
962
|
});
|
|
953
963
|
return f;
|
|
954
964
|
}
|
|
955
|
-
function
|
|
965
|
+
function un(e, t = "allow") {
|
|
956
966
|
if (!["allow", "block"].includes(t)) throw new Error("未知校验警告策略");
|
|
957
967
|
if (!Array.isArray(e) || e.length > 1e4 || e.some((r) => !r || !["error", "warning"].includes(r.severity) || typeof r.ruleId != "string" || !r.ruleId.trim() || typeof r.message != "string" || !r.message.trim())) throw new Error("校验问题结构无效");
|
|
958
|
-
if (e.some((r) => r.severity === "error" || t === "block")) throw new
|
|
968
|
+
if (e.some((r) => r.severity === "error" || t === "block")) throw new an(e);
|
|
959
969
|
}
|
|
960
|
-
function
|
|
961
|
-
const
|
|
962
|
-
if (
|
|
970
|
+
function De(e, t, r) {
|
|
971
|
+
const n = e.get(t);
|
|
972
|
+
if (n && JSON.stringify(n) !== JSON.stringify(r)) throw new Error("同一数据集的校验计算/业务键存在歧义,请统一绑定");
|
|
963
973
|
e.set(t, r);
|
|
964
974
|
}
|
|
965
|
-
function
|
|
966
|
-
|
|
967
|
-
const
|
|
975
|
+
function fn(e, t, r, n = []) {
|
|
976
|
+
pt(t.rules);
|
|
977
|
+
const o = [], a = { checks: 0 };
|
|
968
978
|
for (const [i, c] of e.entries()) {
|
|
969
979
|
const l = /* @__PURE__ */ new Map();
|
|
970
980
|
for (const d of c.template.pages) for (const f of d.components)
|
|
971
|
-
f.kind === "list" && (
|
|
981
|
+
f.kind === "list" && (De(l, f.dataset, { rowKey: f.tree?.idField ?? f.rowKey, computed: f.computed, tree: f.tree }), f.detail && De(l, f.detail.dataset, { rowKey: f.detail.rowKey }));
|
|
972
982
|
for (const [d, f] of l) {
|
|
973
983
|
const u = t.rules.filter((h) => !h.dataset || h.dataset === d);
|
|
974
|
-
if (u.length && (
|
|
984
|
+
if (u.length && (o.push(...wt(c.datasets[d] ?? [], { ...t, rules: u, ...f, formula: n[i], signal: r }, a).map((h) => ({ ...h, dataset: d, sourceScope: c.sourceScope }))), o.length > (t.maxIssues ?? 1e3)))
|
|
975
985
|
throw new Error("整批候选校验问题超出 maxIssues 预算");
|
|
976
986
|
}
|
|
977
987
|
}
|
|
978
988
|
const s = new Set(e.flatMap((i) => i.template.pages.flatMap((c) => c.components.flatMap((l) => l.kind === "list" ? [l.dataset, ...l.detail ? [l.detail.dataset] : []] : []))));
|
|
979
989
|
if (t.rules.some((i) => i.dataset && !s.has(i.dataset))) throw new Error("校验目标数据集不存在");
|
|
980
|
-
return
|
|
990
|
+
return o;
|
|
981
991
|
}
|
|
982
|
-
function
|
|
992
|
+
function yt(e) {
|
|
983
993
|
return !e || typeof e != "object" ? !1 : [e.pageIndex, e.componentIndex, e.rowIndex, e.columnIndex].every((t) => Number.isInteger(t) && t >= 0);
|
|
984
994
|
}
|
|
985
|
-
function
|
|
986
|
-
const
|
|
987
|
-
if (!o) return null;
|
|
988
|
-
const n = o.cells[t];
|
|
995
|
+
function bt(e, t, r) {
|
|
996
|
+
const n = e.grid;
|
|
989
997
|
if (!n) return null;
|
|
990
|
-
const
|
|
998
|
+
const o = n.cells[t];
|
|
999
|
+
if (!o) return null;
|
|
1000
|
+
const s = re(n, e.widthMm, e.heightMm).cells.filter((c) => c.ri === t).findIndex((c) => c.ci === r), i = o[s];
|
|
991
1001
|
return i ? { cell: i, sourceColumnIndex: s } : null;
|
|
992
1002
|
}
|
|
993
|
-
function
|
|
1003
|
+
function mn(e) {
|
|
994
1004
|
return e.value !== void 0 ? e.value : e.rawText ?? e.text ?? null;
|
|
995
1005
|
}
|
|
996
|
-
function
|
|
1006
|
+
function hn(e, t) {
|
|
997
1007
|
return e.valueType ? e.valueType : typeof t == "number" ? "number" : typeof t == "boolean" ? "boolean" : t === null && e.numberFormat && /[0#?]/.test(e.numberFormat) ? "number" : "text";
|
|
998
1008
|
}
|
|
999
|
-
function
|
|
1009
|
+
function gn(e, t) {
|
|
1000
1010
|
if (e.derived) return "derived";
|
|
1001
1011
|
if (e.editable === !1) return "cell";
|
|
1002
1012
|
if (e.formula !== void 0) return "formula";
|
|
1003
1013
|
if (e.children?.length || e.richParagraphs?.length) return "complex";
|
|
1004
1014
|
if (t.table && t.table.role !== "body" && e.editable !== !0) return "structure";
|
|
1005
1015
|
}
|
|
1006
|
-
function
|
|
1016
|
+
function pn(e, t) {
|
|
1007
1017
|
const r = e.table;
|
|
1008
1018
|
if (r)
|
|
1009
1019
|
return {
|
|
@@ -1013,54 +1023,54 @@ function mo(e, t) {
|
|
|
1013
1023
|
columnKey: r.columnKeys[t.columnIndex]
|
|
1014
1024
|
};
|
|
1015
1025
|
}
|
|
1016
|
-
function
|
|
1026
|
+
function wn(e, t, r) {
|
|
1017
1027
|
if (e.derived) return;
|
|
1018
1028
|
if (e.source) return { ...e.source };
|
|
1019
|
-
const
|
|
1020
|
-
if (!(!
|
|
1021
|
-
return { ...
|
|
1029
|
+
const n = t.table?.source, o = t.table?.columnKeys[r.columnIndex];
|
|
1030
|
+
if (!(!n || n.rowKey === void 0 || o === void 0))
|
|
1031
|
+
return { ...n, rowKey: n.rowKey, field: o };
|
|
1022
1032
|
}
|
|
1023
|
-
function
|
|
1024
|
-
const
|
|
1033
|
+
function vt(e, t, r) {
|
|
1034
|
+
const n = mn(r), o = gn(r, e);
|
|
1025
1035
|
return {
|
|
1026
1036
|
address: { ...t },
|
|
1027
1037
|
cell: r,
|
|
1028
1038
|
component: e,
|
|
1029
|
-
value:
|
|
1030
|
-
valueType:
|
|
1031
|
-
table:
|
|
1032
|
-
source:
|
|
1033
|
-
editable:
|
|
1034
|
-
readOnlyReason:
|
|
1039
|
+
value: n,
|
|
1040
|
+
valueType: hn(r, n),
|
|
1041
|
+
table: pn(e, t),
|
|
1042
|
+
source: wn(r, e, t),
|
|
1043
|
+
editable: o === void 0,
|
|
1044
|
+
readOnlyReason: o
|
|
1035
1045
|
};
|
|
1036
1046
|
}
|
|
1037
1047
|
function $e(e, t) {
|
|
1038
|
-
if (!
|
|
1048
|
+
if (!yt(t)) return null;
|
|
1039
1049
|
const r = e.pages[t.pageIndex]?.components[t.componentIndex];
|
|
1040
1050
|
if (!r) return null;
|
|
1041
|
-
const
|
|
1042
|
-
return
|
|
1051
|
+
const n = bt(r, t.rowIndex, t.columnIndex);
|
|
1052
|
+
return n ? vt(r, t, n.cell) : null;
|
|
1043
1053
|
}
|
|
1044
|
-
function
|
|
1054
|
+
function D(e) {
|
|
1045
1055
|
const t = /* @__PURE__ */ new Map();
|
|
1046
1056
|
return (r) => {
|
|
1047
|
-
if (!
|
|
1048
|
-
const
|
|
1049
|
-
if (!
|
|
1050
|
-
let
|
|
1051
|
-
if (!
|
|
1057
|
+
if (!yt(r)) return null;
|
|
1058
|
+
const n = e.pages[r.pageIndex]?.components[r.componentIndex];
|
|
1059
|
+
if (!n?.grid) return null;
|
|
1060
|
+
let o = t.get(n);
|
|
1061
|
+
if (!o) {
|
|
1052
1062
|
const s = /* @__PURE__ */ new Map();
|
|
1053
|
-
|
|
1054
|
-
for (const i of
|
|
1063
|
+
o = /* @__PURE__ */ new Map();
|
|
1064
|
+
for (const i of re(n.grid, n.widthMm, n.heightMm).cells) {
|
|
1055
1065
|
const c = s.get(i.ri) ?? 0;
|
|
1056
1066
|
s.set(i.ri, c + 1);
|
|
1057
|
-
const l =
|
|
1058
|
-
l &&
|
|
1067
|
+
const l = n.grid.cells[i.ri]?.[c];
|
|
1068
|
+
l && o.set(`${i.ri}:${i.ci}`, l);
|
|
1059
1069
|
}
|
|
1060
|
-
t.set(
|
|
1070
|
+
t.set(n, o);
|
|
1061
1071
|
}
|
|
1062
|
-
const a =
|
|
1063
|
-
return a ?
|
|
1072
|
+
const a = o.get(`${r.rowIndex}:${r.columnIndex}`);
|
|
1073
|
+
return a ? vt(n, r, a) : null;
|
|
1064
1074
|
};
|
|
1065
1075
|
}
|
|
1066
1076
|
class M extends Error {
|
|
@@ -1068,20 +1078,20 @@ class M extends Error {
|
|
|
1068
1078
|
super(`Invalid report cell edit: ${t}`), this.code = t, this.name = "ReportCellEditError";
|
|
1069
1079
|
}
|
|
1070
1080
|
}
|
|
1071
|
-
function
|
|
1081
|
+
function yn(e, t) {
|
|
1072
1082
|
let r = e.trim();
|
|
1073
|
-
const
|
|
1074
|
-
if (
|
|
1075
|
-
return Number(r) / (
|
|
1083
|
+
const n = t && r.endsWith("%");
|
|
1084
|
+
if (n && (r = r.slice(0, -1).trim()), /^[+-]?\d{1,3}(?:,\d{3})+(?:\.\d*)?(?:[eE][+-]?\d+)?$/.test(r) && (r = r.replace(/,/g, "")), !/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/.test(r)) throw new M("number");
|
|
1085
|
+
return Number(r) / (n ? 100 : 1);
|
|
1076
1086
|
}
|
|
1077
|
-
function
|
|
1087
|
+
function bn(e, t) {
|
|
1078
1088
|
if (e === null || typeof e == "string" && e.trim() === "") return null;
|
|
1079
1089
|
if (typeof e != "string" && typeof e != "number") throw new M("number");
|
|
1080
|
-
const r = typeof e == "number" ? e :
|
|
1090
|
+
const r = typeof e == "number" ? e : yn(e, fr(t.cell.numberFormat));
|
|
1081
1091
|
if (!Number.isFinite(r) || Number.isInteger(r) && !Number.isSafeInteger(r)) throw new M("number");
|
|
1082
1092
|
return r;
|
|
1083
1093
|
}
|
|
1084
|
-
function
|
|
1094
|
+
function vn(e) {
|
|
1085
1095
|
if (e === null || typeof e == "string" && e.trim() === "") return null;
|
|
1086
1096
|
if (typeof e == "boolean") return e;
|
|
1087
1097
|
const t = String(e).trim().toLowerCase();
|
|
@@ -1089,24 +1099,24 @@ function wo(e) {
|
|
|
1089
1099
|
if (["false", "no", "否", "0"].includes(t)) return !1;
|
|
1090
1100
|
throw new M("boolean");
|
|
1091
1101
|
}
|
|
1092
|
-
function
|
|
1093
|
-
return e.valueType === "number" ?
|
|
1102
|
+
function Mt(e, t) {
|
|
1103
|
+
return e.valueType === "number" ? bn(t, e) : e.valueType === "boolean" ? vn(t) : t === null ? null : String(t);
|
|
1094
1104
|
}
|
|
1095
|
-
function
|
|
1096
|
-
const r = t.cell.text,
|
|
1097
|
-
return
|
|
1105
|
+
function Mn(e, t) {
|
|
1106
|
+
const r = t.cell.text, o = [["是", "否"], ["TRUE", "FALSE"], ["True", "False"], ["true", "false"], ["1", "0"]].find((a) => a.includes(r ?? ""));
|
|
1107
|
+
return o ? o[e ? 0 : 1] : String(e);
|
|
1098
1108
|
}
|
|
1099
|
-
function
|
|
1100
|
-
return t === null ? "" : typeof t == "boolean" ?
|
|
1109
|
+
function q(e, t) {
|
|
1110
|
+
return t === null ? "" : typeof t == "boolean" ? Mn(t, e) : typeof t == "number" ? ur(t, e.cell.numberFormat) : String(t);
|
|
1101
1111
|
}
|
|
1102
|
-
function
|
|
1103
|
-
const
|
|
1104
|
-
if (!
|
|
1105
|
-
return
|
|
1112
|
+
function wo(e, t, r) {
|
|
1113
|
+
const n = $e(e, t);
|
|
1114
|
+
if (!n) throw new M("missing");
|
|
1115
|
+
return U(n, r);
|
|
1106
1116
|
}
|
|
1107
|
-
function
|
|
1117
|
+
function U(e, t) {
|
|
1108
1118
|
if (!e.editable) throw new M("readonly");
|
|
1109
|
-
const r =
|
|
1119
|
+
const r = Mt(e, t);
|
|
1110
1120
|
return {
|
|
1111
1121
|
address: { ...e.address },
|
|
1112
1122
|
table: e.table,
|
|
@@ -1114,136 +1124,136 @@ function q(e, t) {
|
|
|
1114
1124
|
previousValue: e.value,
|
|
1115
1125
|
previousText: e.cell.text ?? "",
|
|
1116
1126
|
value: r,
|
|
1117
|
-
text:
|
|
1127
|
+
text: q(e, r)
|
|
1118
1128
|
};
|
|
1119
1129
|
}
|
|
1120
|
-
function
|
|
1121
|
-
const r = e.table,
|
|
1122
|
-
return !r || !
|
|
1130
|
+
function Sn(e, t) {
|
|
1131
|
+
const r = e.table, n = t.table;
|
|
1132
|
+
return !r || !n || r.columnKey === void 0 ? !1 : r.id === n.id && r.rowIndex === n.rowIndex && r.role === n.role && r.columnKey === n.columnKey;
|
|
1123
1133
|
}
|
|
1124
|
-
function
|
|
1125
|
-
const
|
|
1126
|
-
return c[s.sourceColumnIndex] = d, i[
|
|
1134
|
+
function St(e, t, r) {
|
|
1135
|
+
const n = e.grid, { rowIndex: o, columnIndex: a } = t.address, s = bt(e, o, a), i = [...n.cells], c = [...i[o]], l = q(t, r.value), d = { ...s.cell, value: r.value, text: l, rawText: l };
|
|
1136
|
+
return c[s.sourceColumnIndex] = d, i[o] = c, { ...e, grid: { ...n, cells: i } };
|
|
1127
1137
|
}
|
|
1128
|
-
function
|
|
1129
|
-
const r = e.table?.columnKeys,
|
|
1130
|
-
return r &&
|
|
1138
|
+
function xn(e, t) {
|
|
1139
|
+
const r = e.table?.columnKeys, n = t.table?.columnKey;
|
|
1140
|
+
return r && n !== void 0 ? r.flatMap((o, a) => o === n ? [a] : []) : [];
|
|
1131
1141
|
}
|
|
1132
|
-
function
|
|
1133
|
-
const s = t.table, i =
|
|
1142
|
+
function Cn(e, t, r, n, o, a) {
|
|
1143
|
+
const s = t.table, i = o.table;
|
|
1134
1144
|
if (!s || !i || s.id !== i.id || s.role !== i.role || !t.grid) return t;
|
|
1135
1145
|
const c = i.rowIndex - s.rowIndex;
|
|
1136
1146
|
if (c < 0 || c >= t.grid.cells.length) return t;
|
|
1137
1147
|
let l = t;
|
|
1138
|
-
for (const d of
|
|
1139
|
-
const f = $e(e, { pageIndex: r, componentIndex:
|
|
1140
|
-
f?.editable &&
|
|
1148
|
+
for (const d of xn(t, o)) {
|
|
1149
|
+
const f = $e(e, { pageIndex: r, componentIndex: n, rowIndex: c, columnIndex: d });
|
|
1150
|
+
f?.editable && Sn(o, f) && (l = St(l, f, a));
|
|
1141
1151
|
}
|
|
1142
1152
|
return l;
|
|
1143
1153
|
}
|
|
1144
|
-
function
|
|
1145
|
-
const s =
|
|
1146
|
-
return
|
|
1154
|
+
function kn(e, t, r, n, o, a) {
|
|
1155
|
+
const s = o.address;
|
|
1156
|
+
return o.table?.columnKey !== void 0 ? Cn(e, t, r, n, o, a) : s.pageIndex === r && s.componentIndex === n ? St(t, o, a) : t;
|
|
1147
1157
|
}
|
|
1148
1158
|
function Ie(e, t) {
|
|
1149
1159
|
const r = t.source;
|
|
1150
1160
|
if (!r) return !1;
|
|
1151
|
-
const
|
|
1152
|
-
return !
|
|
1161
|
+
const n = e.source;
|
|
1162
|
+
return !n || ["sourceScope", "datasetId", "rowKey", "field", "revision", "sourceToken"].some((o) => !Object.is(n[o], r[o]));
|
|
1153
1163
|
}
|
|
1154
|
-
function
|
|
1164
|
+
function yo(e, t) {
|
|
1155
1165
|
const r = $e(e, t.address);
|
|
1156
1166
|
if (!r) throw new M("missing");
|
|
1157
1167
|
if (!r.editable) throw new M("readonly");
|
|
1158
1168
|
if (Ie(r, t)) throw new M("conflict");
|
|
1159
1169
|
if (!Object.is(r.value, t.previousValue) || (r.cell.text ?? "") !== t.previousText) throw new M("conflict");
|
|
1160
|
-
const
|
|
1161
|
-
if (Object.is(
|
|
1170
|
+
const n = Mt(r, t.value), o = { ...t, value: n, text: q(r, n) };
|
|
1171
|
+
if (Object.is(n, r.value) && o.text === r.cell.text) return e;
|
|
1162
1172
|
const a = e.pages.map((s, i) => {
|
|
1163
|
-
const c = s.components.map((l, d) =>
|
|
1173
|
+
const c = s.components.map((l, d) => kn(e, l, i, d, r, o));
|
|
1164
1174
|
return c.every((l, d) => l === s.components[d]) ? s : { ...s, components: c };
|
|
1165
1175
|
});
|
|
1166
1176
|
return { ...e, pages: a };
|
|
1167
1177
|
}
|
|
1168
|
-
function
|
|
1178
|
+
function xt(e) {
|
|
1169
1179
|
const t = [];
|
|
1170
|
-
for (const r of e.template.pages) for (const
|
|
1171
|
-
|
|
1180
|
+
for (const r of e.template.pages) for (const n of r.components)
|
|
1181
|
+
n.kind === "list" && (t.push(n.tree ? { ...n, rowKey: n.tree.idField } : n), n.detail && t.push({ ...n.detail, relation: { detail: n.detail, parentRows: e.datasets[n.dataset] ?? [] } }));
|
|
1172
1182
|
return t;
|
|
1173
1183
|
}
|
|
1174
|
-
function
|
|
1184
|
+
function B(e) {
|
|
1175
1185
|
return JSON.stringify([e.sourceScope, e.datasetId]);
|
|
1176
1186
|
}
|
|
1177
|
-
function
|
|
1187
|
+
function Be(e) {
|
|
1178
1188
|
return JSON.stringify([e.sourceScope, e.datasetId, e.rowKey]);
|
|
1179
1189
|
}
|
|
1180
|
-
function
|
|
1190
|
+
function Ct(e) {
|
|
1181
1191
|
const t = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Set();
|
|
1182
|
-
return e.forEach((
|
|
1183
|
-
for (const a of
|
|
1192
|
+
return e.forEach((n, o) => {
|
|
1193
|
+
for (const a of xt(n)) {
|
|
1184
1194
|
if (!a.rowKey) continue;
|
|
1185
1195
|
const s = a.relation, i = s ? new Set(s.parentRows.map((c) => JSON.stringify(c[s.detail.parentKey]))) : void 0;
|
|
1186
|
-
(
|
|
1196
|
+
(n.datasets[a.dataset] ?? []).forEach((c, l) => {
|
|
1187
1197
|
if (s && !i.has(JSON.stringify(c[s.detail.foreignKey]))) return;
|
|
1188
1198
|
const d = c[a.rowKey];
|
|
1189
1199
|
if (typeof d != "string" && typeof d != "number") return;
|
|
1190
|
-
const f = `${
|
|
1200
|
+
const f = `${o}:${a.dataset}:${l}:${a.rowKey}`;
|
|
1191
1201
|
if (r.has(f)) return;
|
|
1192
1202
|
r.add(f);
|
|
1193
|
-
const u =
|
|
1194
|
-
h.push({ partIndex:
|
|
1203
|
+
const u = Be({ sourceScope: n.sourceScope, datasetId: a.dataset, rowKey: d }), h = t.get(u) ?? [];
|
|
1204
|
+
h.push({ partIndex: o, dataset: a.dataset, rowIndex: l, row: c, binding: a }), t.set(u, h);
|
|
1195
1205
|
});
|
|
1196
1206
|
}
|
|
1197
|
-
}), (
|
|
1198
|
-
const
|
|
1199
|
-
if (!
|
|
1200
|
-
if (new Set(
|
|
1201
|
-
return
|
|
1207
|
+
}), (n) => {
|
|
1208
|
+
const o = t.get(Be(n));
|
|
1209
|
+
if (!o?.length) throw new M("missing");
|
|
1210
|
+
if (new Set(o.map((a) => `${a.partIndex}:${a.dataset}`)).size !== o.length) throw new M("conflict");
|
|
1211
|
+
return o;
|
|
1202
1212
|
};
|
|
1203
1213
|
}
|
|
1204
|
-
function
|
|
1205
|
-
const r = e.map((
|
|
1206
|
-
for (const { row:
|
|
1207
|
-
const i = r[
|
|
1208
|
-
|
|
1214
|
+
function kt(e, t) {
|
|
1215
|
+
const r = e.map((o) => ({ ...o, datasets: { ...o.datasets } })), n = /* @__PURE__ */ new Set();
|
|
1216
|
+
for (const { row: o, field: a, value: s } of t) {
|
|
1217
|
+
const i = r[o.partIndex], c = JSON.stringify([o.partIndex, o.dataset]);
|
|
1218
|
+
n.has(c) || (i.datasets[o.dataset] = [...i.datasets[o.dataset]], n.add(c)), i.datasets[o.dataset][o.rowIndex] = { ...i.datasets[o.dataset][o.rowIndex], [a]: s };
|
|
1209
1219
|
}
|
|
1210
|
-
for (const
|
|
1211
|
-
const [a, s] = JSON.parse(
|
|
1212
|
-
|
|
1220
|
+
for (const o of n) {
|
|
1221
|
+
const [a, s] = JSON.parse(o);
|
|
1222
|
+
zt(e[a].datasets[s], r[a].datasets[s]);
|
|
1213
1223
|
}
|
|
1214
1224
|
return r;
|
|
1215
1225
|
}
|
|
1216
|
-
function
|
|
1217
|
-
const
|
|
1226
|
+
function Tn(e, t, r) {
|
|
1227
|
+
const n = [], o = /* @__PURE__ */ new Set();
|
|
1218
1228
|
return e.forEach((a, s) => {
|
|
1219
|
-
for (const i of
|
|
1220
|
-
t.has(
|
|
1229
|
+
for (const i of xt(a))
|
|
1230
|
+
t.has(B({ sourceScope: a.sourceScope, datasetId: i.dataset })) && (a.datasets[i.dataset] ?? []).forEach((c, l) => {
|
|
1221
1231
|
const d = { partIndex: s, dataset: i.dataset, rowIndex: l, row: c, binding: i };
|
|
1222
1232
|
for (const [f, u] of [[i.revisionField, r.revision], [i.sourceTokenField, r.sourceToken]]) {
|
|
1223
1233
|
if (!f || u === void 0) continue;
|
|
1224
1234
|
const h = `${s}:${i.dataset}:${l}:${f}`;
|
|
1225
|
-
|
|
1235
|
+
o.has(h) || (o.add(h), n.push({ row: d, field: f, value: u }));
|
|
1226
1236
|
}
|
|
1227
1237
|
});
|
|
1228
|
-
}),
|
|
1238
|
+
}), n;
|
|
1229
1239
|
}
|
|
1230
|
-
function
|
|
1240
|
+
function Pn(e, t, r) {
|
|
1231
1241
|
if (!r || r.revision === void 0 && r.sourceToken === void 0) return e;
|
|
1232
|
-
const
|
|
1233
|
-
return
|
|
1242
|
+
const n = new Set(t.edits.flatMap((o) => o.source ? [B(o.source)] : []));
|
|
1243
|
+
return Tt(e, new Map([...n].map((o) => [o, r])));
|
|
1234
1244
|
}
|
|
1235
|
-
function
|
|
1245
|
+
function Tt(e, t) {
|
|
1236
1246
|
if (!t.size) return e;
|
|
1237
1247
|
function r(a) {
|
|
1238
|
-
const s = a.datasetId && t.get(
|
|
1248
|
+
const s = a.datasetId && t.get(B({ ...a, datasetId: a.datasetId }));
|
|
1239
1249
|
return !s || (s.revision === void 0 || Object.is(s.revision, a.revision)) && (s.sourceToken === void 0 || s.sourceToken === a.sourceToken) ? a : { ...a, ...s.revision !== void 0 ? { revision: s.revision } : {}, ...s.sourceToken !== void 0 ? { sourceToken: s.sourceToken } : {} };
|
|
1240
1250
|
}
|
|
1241
|
-
function
|
|
1251
|
+
function n(a) {
|
|
1242
1252
|
const s = a.map((i) => {
|
|
1243
1253
|
const c = i.table?.source ? r(i.table.source) : void 0, l = i.table && c !== i.table.source ? { ...i.table, source: c } : i.table, d = i.grid?.cells.map((u) => {
|
|
1244
1254
|
const h = u.map((m) => {
|
|
1245
1255
|
if (!m) return m;
|
|
1246
|
-
const v = m.source ? r(m.source) : void 0, y = m.children ?
|
|
1256
|
+
const v = m.source ? r(m.source) : void 0, y = m.children ? n(m.children) : void 0;
|
|
1247
1257
|
return v === m.source && y === m.children ? m : { ...m, source: v, children: y };
|
|
1248
1258
|
});
|
|
1249
1259
|
return h.some((m, v) => m !== u[v]) ? h : u;
|
|
@@ -1252,32 +1262,32 @@ function Ct(e, t) {
|
|
|
1252
1262
|
});
|
|
1253
1263
|
return s.some((i, c) => i !== a[c]) ? s : a;
|
|
1254
1264
|
}
|
|
1255
|
-
const
|
|
1256
|
-
const s =
|
|
1265
|
+
const o = e.pages.map((a) => {
|
|
1266
|
+
const s = n(a.components);
|
|
1257
1267
|
return s !== a.components ? { ...a, components: s } : a;
|
|
1258
1268
|
});
|
|
1259
|
-
return
|
|
1269
|
+
return o.some((a, s) => a !== e.pages[s]) ? { ...e, pages: o } : e;
|
|
1260
1270
|
}
|
|
1261
|
-
function
|
|
1271
|
+
function En(e) {
|
|
1262
1272
|
return JSON.stringify([e.pageIndex, e.componentIndex, e.rowIndex, e.columnIndex]);
|
|
1263
1273
|
}
|
|
1264
|
-
function
|
|
1274
|
+
function Ge(e) {
|
|
1265
1275
|
const t = e.table;
|
|
1266
|
-
return t?.columnKey !== void 0 ? JSON.stringify([t.id, t.role, t.rowIndex, t.columnKey]) :
|
|
1276
|
+
return t?.columnKey !== void 0 ? JSON.stringify([t.id, t.role, t.rowIndex, t.columnKey]) : En(e.address);
|
|
1267
1277
|
}
|
|
1268
|
-
function
|
|
1278
|
+
function Rn(e, t) {
|
|
1269
1279
|
if (!t.length) return e;
|
|
1270
|
-
const r = new Map(t.map((c) => [
|
|
1280
|
+
const r = new Map(t.map((c) => [Ge(c), c])), n = new Set(t.flatMap((c) => c.table ? [c.table.id] : [])), o = new Set(t.map((c) => `${c.address.pageIndex}:${c.address.componentIndex}`)), a = D(e);
|
|
1271
1281
|
function s(c, l, d) {
|
|
1272
1282
|
const f = c.grid;
|
|
1273
|
-
if (!f || !
|
|
1283
|
+
if (!f || !o.has(`${l}:${d}`) && !n.has(c.table?.id ?? "")) return c;
|
|
1274
1284
|
const u = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map();
|
|
1275
|
-
for (const m of
|
|
1285
|
+
for (const m of re(f, c.widthMm, c.heightMm).cells) {
|
|
1276
1286
|
const v = h.get(m.ri) ?? 0;
|
|
1277
1287
|
h.set(m.ri, v + 1);
|
|
1278
|
-
const y = a({ pageIndex: l, componentIndex: d, rowIndex: m.ri, columnIndex: m.ci }), g = y && r.get(
|
|
1288
|
+
const y = a({ pageIndex: l, componentIndex: d, rowIndex: m.ri, columnIndex: m.ci }), g = y && r.get(Ge(y));
|
|
1279
1289
|
if (!g || !y.editable) continue;
|
|
1280
|
-
const w = u.get(m.ri) ?? [...f.cells[m.ri]], x =
|
|
1290
|
+
const w = u.get(m.ri) ?? [...f.cells[m.ri]], x = q(y, g.value);
|
|
1281
1291
|
Object.is(y.value, g.value) && x === y.cell.text || (w[v] = { ...m.cell, value: g.value, text: x, rawText: x }, u.set(m.ri, w));
|
|
1282
1292
|
}
|
|
1283
1293
|
return u.size ? { ...c, grid: { ...f, cells: f.cells.map((m, v) => u.get(v) ?? m) } } : c;
|
|
@@ -1293,55 +1303,55 @@ function F(e) {
|
|
|
1293
1303
|
if (t) return JSON.stringify([t.sourceScope, t.datasetId, t.rowKey, t.field]);
|
|
1294
1304
|
const r = e.table;
|
|
1295
1305
|
if (r?.columnKey !== void 0) return JSON.stringify([r.id, r.role, r.rowIndex, r.columnKey]);
|
|
1296
|
-
const
|
|
1297
|
-
return JSON.stringify([
|
|
1306
|
+
const n = e.address;
|
|
1307
|
+
return JSON.stringify([n.pageIndex, n.componentIndex, n.rowIndex, n.columnIndex]);
|
|
1298
1308
|
}
|
|
1299
|
-
function
|
|
1309
|
+
function bo(e, t, r) {
|
|
1300
1310
|
if (typeof r != "string" || !r.trim() || !Array.isArray(t)) throw new M("missing");
|
|
1301
1311
|
if (t.length > 1e4) throw new M("limit");
|
|
1302
|
-
const
|
|
1303
|
-
const c =
|
|
1312
|
+
const n = /* @__PURE__ */ new Set(), o = D(e), a = t.map(({ address: s, value: i }) => {
|
|
1313
|
+
const c = o(s);
|
|
1304
1314
|
if (!c) throw new M("missing");
|
|
1305
|
-
const l =
|
|
1306
|
-
if (
|
|
1307
|
-
return
|
|
1315
|
+
const l = U(c, i), d = F(l);
|
|
1316
|
+
if (n.has(d)) throw new M("duplicate");
|
|
1317
|
+
return n.add(d), l;
|
|
1308
1318
|
});
|
|
1309
1319
|
return { requestId: r, edits: a };
|
|
1310
1320
|
}
|
|
1311
|
-
function
|
|
1321
|
+
function vo(e, t) {
|
|
1312
1322
|
if (t.edits.length > 1e4) throw new M("limit");
|
|
1313
|
-
const r =
|
|
1323
|
+
const r = D(e), n = /* @__PURE__ */ new Set(), o = t.edits.map((a) => {
|
|
1314
1324
|
const s = r(a.address);
|
|
1315
1325
|
if (!s) throw new M("missing");
|
|
1316
1326
|
const i = F(a);
|
|
1317
|
-
if (
|
|
1318
|
-
if (
|
|
1319
|
-
return
|
|
1327
|
+
if (n.has(i)) throw new M("duplicate");
|
|
1328
|
+
if (n.add(i), Ie(s, a) || !Object.is(s.value, a.previousValue) || (s.cell.text ?? "") !== a.previousText) throw new M("conflict");
|
|
1329
|
+
return U(s, a.value);
|
|
1320
1330
|
});
|
|
1321
|
-
return
|
|
1331
|
+
return Rn(e, o);
|
|
1322
1332
|
}
|
|
1323
|
-
function
|
|
1333
|
+
function Mo(e) {
|
|
1324
1334
|
const t = /* @__PURE__ */ new Map();
|
|
1325
1335
|
for (const r of e) {
|
|
1326
|
-
const
|
|
1327
|
-
Object.is(a.previousValue, a.value) ? t.delete(
|
|
1336
|
+
const n = F(r), o = t.get(n), a = o ? { ...r, previousValue: o.previousValue, previousText: o.previousText } : { ...r };
|
|
1337
|
+
Object.is(a.previousValue, a.value) ? t.delete(n) : t.set(n, a);
|
|
1328
1338
|
}
|
|
1329
1339
|
return [...t.values()];
|
|
1330
1340
|
}
|
|
1331
|
-
function
|
|
1332
|
-
const t = /* @__PURE__ */ new Map(), r =
|
|
1333
|
-
return e.pages.forEach((
|
|
1341
|
+
function Pt(e) {
|
|
1342
|
+
const t = /* @__PURE__ */ new Map(), r = D(e);
|
|
1343
|
+
return e.pages.forEach((n, o) => n.components.forEach((a, s) => {
|
|
1334
1344
|
if (!(!a.grid || a.table?.role !== "body"))
|
|
1335
1345
|
for (let i = 0; i < a.grid.cells.length; i++) for (let c = 0; c < a.table.columnKeys.length; c++) {
|
|
1336
|
-
const l = r({ pageIndex:
|
|
1346
|
+
const l = r({ pageIndex: o, componentIndex: s, rowIndex: i, columnIndex: c });
|
|
1337
1347
|
l?.source && l.editable && t.set(F(l), l);
|
|
1338
1348
|
}
|
|
1339
1349
|
})), t;
|
|
1340
1350
|
}
|
|
1341
|
-
function
|
|
1342
|
-
const
|
|
1351
|
+
function So(e, t, r) {
|
|
1352
|
+
const n = Pt(e), o = D(e);
|
|
1343
1353
|
return t.map((a) => {
|
|
1344
|
-
const s = a.source ?
|
|
1354
|
+
const s = a.source ? n.get(F(a)) : o(a.address);
|
|
1345
1355
|
if (!s || F(s) !== F(a)) throw new M("missing");
|
|
1346
1356
|
return { address: { ...s.address }, value: a[r] };
|
|
1347
1357
|
});
|
|
@@ -1354,7 +1364,7 @@ function ee(e, t) {
|
|
|
1354
1364
|
if (!r || r.get || r.set) throw new M("conflict");
|
|
1355
1365
|
return r.value;
|
|
1356
1366
|
}
|
|
1357
|
-
function
|
|
1367
|
+
function Fe(e) {
|
|
1358
1368
|
if (Object.getOwnPropertyDescriptor(e, "toJSON")) throw new M("conflict");
|
|
1359
1369
|
const t = Object.getPrototypeOf(e);
|
|
1360
1370
|
if (Array.isArray(e) && (t !== Array.prototype || Object.keys(e).length !== e.length)) throw new M("conflict");
|
|
@@ -1365,10 +1375,10 @@ function Tt(e) {
|
|
|
1365
1375
|
if (e instanceof Date || Array.isArray(e) && !/^(0|[1-9]\d*)$/.test(r)) throw new M("conflict");
|
|
1366
1376
|
}
|
|
1367
1377
|
}
|
|
1368
|
-
function
|
|
1369
|
-
if (Et(
|
|
1378
|
+
function Rt(e, t, r, n, o) {
|
|
1379
|
+
if (Et(n, o), typeof e == "function" || typeof e == "symbol") throw new M("conflict");
|
|
1370
1380
|
if (e === null || typeof e != "object") return;
|
|
1371
|
-
if (
|
|
1381
|
+
if (Fe(e), r.has(e)) throw new M("conflict");
|
|
1372
1382
|
r.add(e);
|
|
1373
1383
|
const a = Object.keys(e), s = a.map((i) => ee(e, i));
|
|
1374
1384
|
t.push({
|
|
@@ -1379,139 +1389,139 @@ function Pt(e, t, r, o, n) {
|
|
|
1379
1389
|
...e instanceof Date ? { date: Date.prototype.getTime.call(e) } : {},
|
|
1380
1390
|
...Array.isArray(e) ? { length: e.length } : {}
|
|
1381
1391
|
});
|
|
1382
|
-
for (const i of s)
|
|
1392
|
+
for (const i of s) Rt(i, t, r, n, o + 1);
|
|
1383
1393
|
r.delete(e);
|
|
1384
1394
|
}
|
|
1385
|
-
function
|
|
1386
|
-
const { object: t, keys: r, values:
|
|
1387
|
-
if (
|
|
1388
|
-
const
|
|
1389
|
-
return
|
|
1395
|
+
function $n(e) {
|
|
1396
|
+
const { object: t, keys: r, values: n } = e;
|
|
1397
|
+
if (Fe(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;
|
|
1398
|
+
const o = Object.keys(t);
|
|
1399
|
+
return o.length === r.length && r.every((a, s) => o[s] === a && Object.is(ee(t, a), n[s]));
|
|
1390
1400
|
}
|
|
1391
|
-
function
|
|
1401
|
+
function In(e) {
|
|
1392
1402
|
const t = [];
|
|
1393
|
-
return
|
|
1403
|
+
return Rt(e, t, /* @__PURE__ */ new Set(), { nodes: 0 }, 0), () => {
|
|
1394
1404
|
try {
|
|
1395
|
-
return t.every(
|
|
1405
|
+
return t.every($n);
|
|
1396
1406
|
} catch {
|
|
1397
1407
|
return !1;
|
|
1398
1408
|
}
|
|
1399
1409
|
};
|
|
1400
1410
|
}
|
|
1401
|
-
function
|
|
1402
|
-
if (Et(t, r),
|
|
1411
|
+
function te(e, t, r, n = !1) {
|
|
1412
|
+
if (Et(t, r), n) {
|
|
1413
|
+
if (typeof e == "function" || typeof e == "symbol") throw new M("conflict");
|
|
1414
|
+
e !== null && typeof e == "object" && Fe(e);
|
|
1415
|
+
}
|
|
1416
|
+
if (e === null || typeof e != "object") return e;
|
|
1403
1417
|
if (e instanceof Date) return new Date(Date.prototype.getTime.call(e));
|
|
1404
1418
|
if (Array.isArray(e)) {
|
|
1405
1419
|
const o = [];
|
|
1406
|
-
for (let
|
|
1420
|
+
for (let a = 0; a < e.length; a++) o[a] = te(ee(e, String(a)), t, r + 1, n);
|
|
1407
1421
|
return o;
|
|
1408
1422
|
}
|
|
1409
|
-
return Object.fromEntries(Object.keys(e).map((o) => [o,
|
|
1423
|
+
return Object.fromEntries(Object.keys(e).map((o) => [o, te(ee(e, o), t, r + 1, n)]));
|
|
1424
|
+
}
|
|
1425
|
+
function Fn(e) {
|
|
1426
|
+
return te(e, { nodes: 0 }, 0, !0);
|
|
1410
1427
|
}
|
|
1411
|
-
function
|
|
1412
|
-
const t =
|
|
1413
|
-
for (const r of t) for (const
|
|
1428
|
+
function On(e) {
|
|
1429
|
+
const t = te(e, { nodes: 0 }, 0);
|
|
1430
|
+
for (const r of t) for (const n of Object.values(r.datasets)) _t(n);
|
|
1414
1431
|
return t;
|
|
1415
1432
|
}
|
|
1416
|
-
async function
|
|
1417
|
-
return (await
|
|
1433
|
+
async function An(e, t, r = {}) {
|
|
1434
|
+
return (await $t(e, t, r)).plan;
|
|
1418
1435
|
}
|
|
1419
|
-
async function
|
|
1420
|
-
|
|
1421
|
-
for (const s of ft(e, t, a, n))
|
|
1422
|
-
o.push(s), o.length % 8 === 0 && await new Promise((i) => setTimeout(i, 0));
|
|
1423
|
-
if (r.signal?.aborted) {
|
|
1424
|
-
const s = new Error("报表重算已取消");
|
|
1425
|
-
throw s.name = "AbortError", s;
|
|
1426
|
-
}
|
|
1427
|
-
return { plan: { schemaVersion: te, ...ae(e) ? { requiresRecalculation: !0 } : {}, pages: o }, ...n };
|
|
1436
|
+
async function $t(e, t, r = {}) {
|
|
1437
|
+
return ht(e, t, { ...r, knownTotalPages: void 0 });
|
|
1428
1438
|
}
|
|
1429
|
-
const
|
|
1430
|
-
function
|
|
1431
|
-
return
|
|
1439
|
+
const ge = /* @__PURE__ */ new WeakMap();
|
|
1440
|
+
function xo(e) {
|
|
1441
|
+
return ge.get(e);
|
|
1432
1442
|
}
|
|
1433
|
-
function
|
|
1443
|
+
function X(e) {
|
|
1434
1444
|
if (e?.aborted) {
|
|
1435
1445
|
const t = new Error("报表重算已取消");
|
|
1436
1446
|
throw t.name = "AbortError", t;
|
|
1437
1447
|
}
|
|
1438
1448
|
}
|
|
1439
|
-
function
|
|
1449
|
+
function It(e, t) {
|
|
1440
1450
|
return e[t] === void 0 ? "" : e[t];
|
|
1441
1451
|
}
|
|
1442
|
-
function
|
|
1452
|
+
function Nn(e, t) {
|
|
1443
1453
|
if (t.edits.length > 1e4) throw new M("limit");
|
|
1444
|
-
const r =
|
|
1454
|
+
const r = D(e), n = /* @__PURE__ */ new Set(), o = [], a = t.edits.map((s) => {
|
|
1445
1455
|
const i = r(s.address);
|
|
1446
1456
|
if (!i?.source) throw new M("missing");
|
|
1447
1457
|
const c = F(s);
|
|
1448
|
-
if (
|
|
1449
|
-
if (
|
|
1450
|
-
return
|
|
1458
|
+
if (n.has(c)) throw new M("duplicate");
|
|
1459
|
+
if (n.add(c), Ie(i, s) || !Object.is(i.value, s.previousValue) || (i.cell.text ?? "") !== s.previousText) throw new M("conflict");
|
|
1460
|
+
return o.push(i), U(i, s.value);
|
|
1451
1461
|
});
|
|
1452
|
-
return { batch: { requestId: t.requestId, edits: a }, contexts:
|
|
1453
|
-
}
|
|
1454
|
-
function
|
|
1455
|
-
const r =
|
|
1456
|
-
return t.flatMap((
|
|
1457
|
-
if (!
|
|
1458
|
-
return r(
|
|
1459
|
-
if (!Object.is(
|
|
1460
|
-
if (
|
|
1461
|
-
return { row:
|
|
1462
|
+
return { batch: { requestId: t.requestId, edits: a }, contexts: o };
|
|
1463
|
+
}
|
|
1464
|
+
function jn(e, t) {
|
|
1465
|
+
const r = Ct(e);
|
|
1466
|
+
return t.flatMap((n) => {
|
|
1467
|
+
if (!n.source) throw new M("missing");
|
|
1468
|
+
return r(n.source).map((o) => {
|
|
1469
|
+
if (!Object.is(It(o.row, n.source.field), n.previousValue)) throw new M("conflict");
|
|
1470
|
+
if (o.binding.rowKey === n.source.field) throw new M("readonly");
|
|
1471
|
+
return { row: o, field: n.source.field, value: n.value };
|
|
1462
1472
|
});
|
|
1463
1473
|
});
|
|
1464
1474
|
}
|
|
1465
1475
|
function fe(e, t, r) {
|
|
1466
|
-
const
|
|
1467
|
-
return
|
|
1476
|
+
const n = { ...e, value: t, source: { ...e.source, ...r?.revision === void 0 ? {} : { revision: r.revision }, ...r?.sourceToken === void 0 ? {} : { sourceToken: r.sourceToken } } };
|
|
1477
|
+
return n.cell = { ...e.cell, value: n.value, text: q(n, n.value) }, n;
|
|
1468
1478
|
}
|
|
1469
|
-
function
|
|
1479
|
+
function Kn(e, t, r) {
|
|
1470
1480
|
if (!r || r.revision === void 0 && r.sourceToken === void 0) return [...e];
|
|
1471
|
-
const
|
|
1472
|
-
return
|
|
1481
|
+
const n = new Set(t.edits.flatMap((o) => o.source ? [B(o.source)] : []));
|
|
1482
|
+
return kt(e, Tn(e, n, r));
|
|
1473
1483
|
}
|
|
1474
|
-
function
|
|
1475
|
-
const
|
|
1476
|
-
for (const
|
|
1477
|
-
...e.get(
|
|
1484
|
+
function Ln(e, t, r) {
|
|
1485
|
+
const n = new Set(t.edits.map((o) => B(o.source)));
|
|
1486
|
+
for (const o of n) e.set(o, {
|
|
1487
|
+
...e.get(o),
|
|
1478
1488
|
...r.revision !== void 0 ? { revision: r.revision } : {},
|
|
1479
1489
|
...r.sourceToken !== void 0 ? { sourceToken: r.sourceToken } : {}
|
|
1480
1490
|
});
|
|
1481
|
-
return
|
|
1491
|
+
return n;
|
|
1482
1492
|
}
|
|
1483
|
-
function
|
|
1493
|
+
function Ft(e, t) {
|
|
1484
1494
|
let r = t.parts;
|
|
1485
|
-
const
|
|
1486
|
-
let a =
|
|
1495
|
+
const n = t.rebuild, o = [...t.validationFormulas ?? []];
|
|
1496
|
+
let a = In(r), s = e, i;
|
|
1487
1497
|
const c = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map();
|
|
1488
1498
|
function d(h) {
|
|
1489
1499
|
if (h !== s) throw new M("conflict");
|
|
1490
1500
|
if (i) return i;
|
|
1491
1501
|
if (!a?.()) throw new M("conflict");
|
|
1492
|
-
return
|
|
1502
|
+
return On(r);
|
|
1493
1503
|
}
|
|
1494
1504
|
async function f(h, m, v, y = {}) {
|
|
1495
|
-
|
|
1496
|
-
const g = d(h), w =
|
|
1497
|
-
|
|
1498
|
-
let
|
|
1505
|
+
X(y.signal), m = { requestId: m.requestId, edits: m.edits.map((b) => ({ ...b, address: { ...b.address }, source: b.source ? { ...b.source } : void 0, table: b.table ? { ...b.table } : void 0 })) }, v = v.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)), X(y.signal);
|
|
1506
|
+
const g = d(h), w = kt(g, jn(g, m.edits)), x = Tt(await n(w, y.signal), l);
|
|
1507
|
+
X(y.signal);
|
|
1508
|
+
let E = !1, k = [], O = "allow", A = !1;
|
|
1499
1509
|
function p(b) {
|
|
1500
|
-
return A = !0,
|
|
1510
|
+
return A = !0, k = Object.freeze(fn(w, b, y.signal, o).map((S) => Object.freeze({ ...S }))), A = !1, O = b.warningPolicy ?? "allow", k;
|
|
1501
1511
|
}
|
|
1502
1512
|
return y.validation && p(y.validation), { plan: x, get validationIssues() {
|
|
1503
|
-
return
|
|
1513
|
+
return k;
|
|
1504
1514
|
}, validate: p, commit(b) {
|
|
1505
|
-
if (
|
|
1515
|
+
if (X(y.signal), E || s !== h) throw new M("conflict");
|
|
1506
1516
|
if (b?.conflicts?.length) throw new M("conflict");
|
|
1507
1517
|
if (A) throw new Error("候选规则校验未完成,不能提交");
|
|
1508
|
-
|
|
1509
|
-
const S =
|
|
1518
|
+
un(k, O);
|
|
1519
|
+
const S = Kn(w, m, b), P = Pn(x, m, b);
|
|
1510
1520
|
if (b) {
|
|
1511
|
-
const
|
|
1512
|
-
for (const [R,
|
|
1521
|
+
const T = Ln(l, m, b);
|
|
1522
|
+
for (const [R, L] of c) T.has(B(L.source)) && c.set(R, fe(L, L.value, b));
|
|
1513
1523
|
}
|
|
1514
|
-
return v.forEach((
|
|
1524
|
+
return v.forEach((T, R) => c.set(F(T), fe(T, m.edits[R].value, b))), E = !0, i = S, r = void 0, a = void 0, s = P, ge.set(s, u), s;
|
|
1515
1525
|
} };
|
|
1516
1526
|
}
|
|
1517
1527
|
const u = {
|
|
@@ -1519,194 +1529,194 @@ function It(e, t) {
|
|
|
1519
1529
|
return s;
|
|
1520
1530
|
},
|
|
1521
1531
|
async prepare(h, m, v) {
|
|
1522
|
-
const y =
|
|
1532
|
+
const y = Nn(h, m);
|
|
1523
1533
|
return f(h, y.batch, y.contexts, v);
|
|
1524
1534
|
},
|
|
1525
1535
|
async prepareHistory(h, m, v, y, g) {
|
|
1526
1536
|
if (!y.trim() || m.length > 1e4) throw new M("limit");
|
|
1527
|
-
const w = d(h), x =
|
|
1537
|
+
const w = d(h), x = Ct(w), E = Pt(h), k = /* @__PURE__ */ new Set(), A = m.map((S) => {
|
|
1528
1538
|
if (!S.source) throw new M("missing");
|
|
1529
|
-
const
|
|
1530
|
-
if (
|
|
1531
|
-
|
|
1532
|
-
const
|
|
1533
|
-
if (!
|
|
1534
|
-
const R = x(
|
|
1535
|
-
return fe(
|
|
1536
|
-
}).map((S,
|
|
1539
|
+
const P = F(S);
|
|
1540
|
+
if (k.has(P)) throw new M("duplicate");
|
|
1541
|
+
k.add(P);
|
|
1542
|
+
const T = E.get(P) ?? c.get(P);
|
|
1543
|
+
if (!T?.source) throw new M("missing");
|
|
1544
|
+
const R = x(T.source)[0];
|
|
1545
|
+
return fe(T, It(R.row, T.source.field));
|
|
1546
|
+
}).map((S, P) => ({ context: S, edit: U(S, m[P][v]) })).filter(({ edit: S }) => !Object.is(S.previousValue, S.value)), p = { requestId: y, edits: A.map(({ edit: S }) => S) }, b = A.map(({ context: S }) => S);
|
|
1537
1547
|
return { batch: p, contexts: b, prepared: await f(h, p, b, g) };
|
|
1538
1548
|
}
|
|
1539
1549
|
};
|
|
1540
|
-
return
|
|
1550
|
+
return ge.set(e, u), u;
|
|
1541
1551
|
}
|
|
1542
|
-
function
|
|
1552
|
+
function Co(e) {
|
|
1543
1553
|
const t = mt(e.template, e.datasets, e.pagination).plan;
|
|
1544
|
-
return
|
|
1554
|
+
return Ft(t, { validationFormulas: [e.pagination?.formula], parts: [{ template: e.template, datasets: e.datasets }], rebuild: (r, n) => An(r[0].template, r[0].datasets, { ...e.pagination, signal: n }) });
|
|
1545
1555
|
}
|
|
1546
|
-
let
|
|
1547
|
-
function
|
|
1548
|
-
return `report-${Date.now()}-${++
|
|
1556
|
+
let Hn = 0;
|
|
1557
|
+
function Dn() {
|
|
1558
|
+
return `report-${Date.now()}-${++Hn}`;
|
|
1549
1559
|
}
|
|
1550
|
-
function
|
|
1560
|
+
function We(e, t, r) {
|
|
1551
1561
|
if (!r?.aborted)
|
|
1552
1562
|
try {
|
|
1553
|
-
const
|
|
1554
|
-
|
|
1563
|
+
const n = e?.({ ...t });
|
|
1564
|
+
n && typeof n.then == "function" && Promise.resolve(n).catch(() => {
|
|
1555
1565
|
});
|
|
1556
1566
|
} catch {
|
|
1557
1567
|
}
|
|
1558
1568
|
}
|
|
1559
|
-
function
|
|
1560
|
-
const t = e.taskId ??
|
|
1561
|
-
|
|
1569
|
+
function Bn(e) {
|
|
1570
|
+
const t = e.taskId ?? Dn(), r = (n, o, a) => {
|
|
1571
|
+
We(e.onEvent, { taskId: t, ...e.correlationId === void 0 ? {} : { correlationId: e.correlationId }, stage: n, status: o, ...a === void 0 ? {} : { reportId: a } }, e.signal);
|
|
1562
1572
|
};
|
|
1563
1573
|
return {
|
|
1564
1574
|
taskId: t,
|
|
1565
|
-
progress(
|
|
1566
|
-
|
|
1575
|
+
progress(n, o, a) {
|
|
1576
|
+
We(e.onEvent, { taskId: t, ...e.correlationId === void 0 ? {} : { correlationId: e.correlationId }, stage: n, status: "started", completed: o, total: a }, e.signal);
|
|
1567
1577
|
},
|
|
1568
|
-
async run(
|
|
1569
|
-
r(
|
|
1578
|
+
async run(n, o, a) {
|
|
1579
|
+
r(n, "started", a);
|
|
1570
1580
|
try {
|
|
1571
|
-
const s = await
|
|
1572
|
-
return r(
|
|
1581
|
+
const s = await o();
|
|
1582
|
+
return r(n, "completed", a), s;
|
|
1573
1583
|
} catch (s) {
|
|
1574
|
-
throw r(
|
|
1584
|
+
throw r(n, "failed", a), s;
|
|
1575
1585
|
}
|
|
1576
1586
|
},
|
|
1577
|
-
runSync(
|
|
1578
|
-
r(
|
|
1587
|
+
runSync(n, o, a) {
|
|
1588
|
+
r(n, "started", a);
|
|
1579
1589
|
try {
|
|
1580
|
-
const s =
|
|
1581
|
-
return r(
|
|
1590
|
+
const s = o();
|
|
1591
|
+
return r(n, "completed", a), s;
|
|
1582
1592
|
} catch (s) {
|
|
1583
|
-
throw r(
|
|
1593
|
+
throw r(n, "failed", a), s;
|
|
1584
1594
|
}
|
|
1585
1595
|
}
|
|
1586
1596
|
};
|
|
1587
1597
|
}
|
|
1588
|
-
function
|
|
1598
|
+
function Ot(e) {
|
|
1589
1599
|
if (!e || typeof e != "object" || Array.isArray(e)) return !1;
|
|
1590
|
-
const t = e, r = (
|
|
1600
|
+
const t = e, r = (n) => typeof n == "string" && n.trim().length > 0 && n.length <= 256;
|
|
1591
1601
|
return !r(t.datasetId) || !r(t.field) || t.tableId !== void 0 && !r(t.tableId) || t.reportScope !== void 0 && (typeof t.reportScope != "string" || !t.reportScope.trim() || t.reportScope.length > 4096) ? !1 : t.rowKey === void 0 ? !0 : typeof t.rowKey == "string" ? t.rowKey.trim().length > 0 && t.rowKey.length <= 1024 : typeof t.rowKey == "number" && Number.isFinite(t.rowKey);
|
|
1592
1602
|
}
|
|
1593
|
-
function
|
|
1603
|
+
function Gn(e) {
|
|
1594
1604
|
return e === "missing-source" || e === "not-applicable" || e === "not-calculable";
|
|
1595
1605
|
}
|
|
1596
|
-
function
|
|
1597
|
-
return e.target !== void 0 && !
|
|
1606
|
+
function Wn(e) {
|
|
1607
|
+
return e.target !== void 0 && !Ot(e.target) ? !1 : e.valueState === void 0 || Gn(e.valueState) && e.target !== void 0;
|
|
1598
1608
|
}
|
|
1599
|
-
function
|
|
1600
|
-
if (
|
|
1601
|
-
const r = e.fields.find((
|
|
1609
|
+
function ko(e, t) {
|
|
1610
|
+
if (et([], e), !Ot(t)) throw new Error("数据说明目标无效");
|
|
1611
|
+
const r = e.fields.find((o) => o.field === t.field);
|
|
1602
1612
|
if (!r) throw new Error("数据说明字段未在契约中声明");
|
|
1603
|
-
const
|
|
1604
|
-
return r.description &&
|
|
1613
|
+
const n = [];
|
|
1614
|
+
return r.description && n.push({ code: "field-definition", severity: "info", message: r.description, target: { ...t } }), r.calculation && n.push({ code: "field-calculation", severity: "info", message: r.calculation.description, target: { ...t } }), n;
|
|
1605
1615
|
}
|
|
1606
|
-
function
|
|
1607
|
-
const
|
|
1616
|
+
function At(e, t, r = {}) {
|
|
1617
|
+
const n = /* @__PURE__ */ new Map();
|
|
1608
1618
|
for (const a of e.pages) for (const s of a.components) {
|
|
1609
1619
|
if (s.kind !== "list" || s.tree?.input !== "nested") continue;
|
|
1610
|
-
const i =
|
|
1620
|
+
const i = n.get(s.dataset);
|
|
1611
1621
|
if (i && (i.childrenField ?? "children") !== (s.tree.childrenField ?? "children")) throw new Error("同一数据集的嵌套树应使用相同 childrenField");
|
|
1612
|
-
|
|
1622
|
+
n.set(s.dataset, s.tree);
|
|
1613
1623
|
}
|
|
1614
|
-
if (!
|
|
1615
|
-
const
|
|
1616
|
-
for (const [a, s] of
|
|
1624
|
+
if (!n.size) return t;
|
|
1625
|
+
const o = { ...t };
|
|
1626
|
+
for (const [a, s] of n) {
|
|
1617
1627
|
const i = Math.min(s.maxRows ?? 1e5, r.maxRows ?? 1 / 0);
|
|
1618
|
-
|
|
1628
|
+
o[a] = Ye(t[a] ?? [], { ...s, maxRows: i }, r.signal);
|
|
1619
1629
|
}
|
|
1620
|
-
return
|
|
1630
|
+
return o;
|
|
1621
1631
|
}
|
|
1622
|
-
function
|
|
1623
|
-
return Object.values(
|
|
1632
|
+
function To(e, t, r = {}) {
|
|
1633
|
+
return Object.values(At(e, t, r)).reduce((n, o) => n + o.length, 0);
|
|
1624
1634
|
}
|
|
1625
|
-
function
|
|
1626
|
-
const
|
|
1627
|
-
if (!
|
|
1628
|
-
const a =
|
|
1629
|
-
return { ...
|
|
1635
|
+
function Po(e, t, r) {
|
|
1636
|
+
const n = mr(r), o = e?.pages.flatMap((i) => i.components).find((i) => i.kind === "list" && i.dataset === t && i.tree?.input === "nested");
|
|
1637
|
+
if (!o || o.kind !== "list" || !o.tree) return n;
|
|
1638
|
+
const a = n.items, s = o.tree.childrenField ?? "children";
|
|
1639
|
+
return { ...n, items: { $ref: "#/$defs/treeNode" }, $defs: { treeNode: { ...a, properties: { ...a.properties, [s]: { anyOf: [{ type: "null" }, { type: "array", items: { $ref: "#/$defs/treeNode" } }] } } } } };
|
|
1630
1640
|
}
|
|
1631
|
-
function
|
|
1641
|
+
function Nt(e, t) {
|
|
1632
1642
|
return JSON.stringify([e, t]);
|
|
1633
1643
|
}
|
|
1634
|
-
function
|
|
1635
|
-
return r === void 0 ?
|
|
1644
|
+
function jt(e, t, r) {
|
|
1645
|
+
return r === void 0 ? Nt(e, t) : JSON.stringify(["shared", r]);
|
|
1636
1646
|
}
|
|
1637
1647
|
function Kt(e, t, r) {
|
|
1638
|
-
return e.map((
|
|
1639
|
-
const
|
|
1640
|
-
...
|
|
1641
|
-
id: r(
|
|
1642
|
-
...
|
|
1643
|
-
} : void 0, a =
|
|
1648
|
+
return e.map((n) => {
|
|
1649
|
+
const o = n.table ? {
|
|
1650
|
+
...n.table,
|
|
1651
|
+
id: r(n.table.id),
|
|
1652
|
+
...n.table.source ? { source: { ...n.table.source, sourceScope: t } } : {}
|
|
1653
|
+
} : void 0, a = n.grid?.cells.map((s) => s.map((i) => !i || !i.source && !i.children ? i : {
|
|
1644
1654
|
...i,
|
|
1645
1655
|
...i.source ? { source: { ...i.source, sourceScope: t } } : {},
|
|
1646
1656
|
...i.children ? { children: Kt(i.children, t, r) } : {}
|
|
1647
1657
|
}));
|
|
1648
|
-
return
|
|
1649
|
-
...
|
|
1650
|
-
...
|
|
1651
|
-
...a ? { grid: { ...
|
|
1652
|
-
} :
|
|
1658
|
+
return o || a ? {
|
|
1659
|
+
...n,
|
|
1660
|
+
...o ? { table: o } : {},
|
|
1661
|
+
...a ? { grid: { ...n.grid, cells: a } } : {}
|
|
1662
|
+
} : n;
|
|
1653
1663
|
});
|
|
1654
1664
|
}
|
|
1655
|
-
function
|
|
1656
|
-
return
|
|
1665
|
+
function pe(e) {
|
|
1666
|
+
return oe(e.maxChartComponents), { maxPages: e.maxPages, maxCells: e.maxCells, maxChartComponents: e.maxChartComponents ?? Ce, usedPages: 0, usedCells: 0, usedChartComponents: 0 };
|
|
1657
1667
|
}
|
|
1658
|
-
function
|
|
1668
|
+
function Vn(e, t) {
|
|
1659
1669
|
if (!e.repeat) return !1;
|
|
1660
1670
|
const r = Object.prototype.hasOwnProperty.call(t, e.repeat.dataset) ? t[e.repeat.dataset] : void 0;
|
|
1661
1671
|
return Array.isArray(r) && r.length === 0;
|
|
1662
1672
|
}
|
|
1663
|
-
function
|
|
1664
|
-
const t = (r) => r.grid?.cells.reduce((
|
|
1665
|
-
return e.pages.reduce((r,
|
|
1673
|
+
function Jn(e) {
|
|
1674
|
+
const t = (r) => r.grid?.cells.reduce((n, o) => n + o.reduce((a, s) => a + (s ? 1 + (s.children?.reduce((i, c) => i + t(c), 0) ?? 0) : 0), 0), 0) ?? 0;
|
|
1675
|
+
return e.pages.reduce((r, n) => r + n.components.reduce((o, a) => o + t(a), 0), 0);
|
|
1666
1676
|
}
|
|
1667
|
-
function
|
|
1677
|
+
function we(e, t) {
|
|
1668
1678
|
return e === void 0 ? void 0 : e - t;
|
|
1669
1679
|
}
|
|
1670
1680
|
function me(e, t) {
|
|
1671
1681
|
return e === void 0 ? t : Math.max(1, Math.min(e, t ?? e));
|
|
1672
1682
|
}
|
|
1673
|
-
function
|
|
1674
|
-
|
|
1675
|
-
const a =
|
|
1676
|
-
if (a !== void 0 && a < 1 && r.pages.length && !
|
|
1677
|
-
if (s < 1 && r.pages.some((i) => i.components.some((c) => c.kind !== "list" && c.chartBinding))) throw new
|
|
1683
|
+
function Lt(e, t, r, n, o) {
|
|
1684
|
+
oe(e?.maxChartComponents);
|
|
1685
|
+
const a = we(t.maxPages, t.usedPages), s = t.maxChartComponents - t.usedChartComponents;
|
|
1686
|
+
if (a !== void 0 && a < 1 && r.pages.length && !Vn(r, n)) throw new W(0, 1);
|
|
1687
|
+
if (s < 1 && r.pages.some((i) => i.components.some((c) => c.kind !== "list" && c.chartBinding))) throw new Q(s, 1);
|
|
1678
1688
|
return {
|
|
1679
1689
|
...e,
|
|
1680
|
-
signal:
|
|
1690
|
+
signal: o ?? e?.signal,
|
|
1681
1691
|
maxPages: me(a, e?.maxPages),
|
|
1682
|
-
maxCells: me(
|
|
1692
|
+
maxCells: me(we(t.maxCells, t.usedCells), e?.maxCells),
|
|
1683
1693
|
maxChartComponents: me(s, e?.maxChartComponents)
|
|
1684
1694
|
};
|
|
1685
1695
|
}
|
|
1686
|
-
function
|
|
1687
|
-
const r =
|
|
1688
|
-
if (
|
|
1696
|
+
function Ht(e, t) {
|
|
1697
|
+
const r = Jn(t.plan), n = we(e.maxCells, e.usedCells);
|
|
1698
|
+
if (n !== void 0 && r > n) throw new Y(n, r);
|
|
1689
1699
|
e.usedPages += t.plan.pages.length, e.usedCells += r, e.usedChartComponents += t.chartComponents;
|
|
1690
1700
|
}
|
|
1691
|
-
function
|
|
1692
|
-
return e instanceof
|
|
1701
|
+
function Dt(e, t) {
|
|
1702
|
+
return e instanceof W && t.maxPages !== void 0 && (e.limit === t.maxPages - t.usedPages || e.limit === 0) ? new W(t.maxPages, t.usedPages + e.actual) : e instanceof Y && t.maxCells !== void 0 ? new Y(t.maxCells, t.usedCells + e.actual) : e instanceof Q && e.limit === t.maxChartComponents - t.usedChartComponents ? new Q(t.maxChartComponents, t.usedChartComponents + e.estimated) : e;
|
|
1693
1703
|
}
|
|
1694
|
-
function
|
|
1704
|
+
function Eo(e) {
|
|
1695
1705
|
if (!("mapData" in e)) return e;
|
|
1696
|
-
const { load: t, mapData: r, ...
|
|
1697
|
-
return { ...
|
|
1698
|
-
const a = await t(
|
|
1699
|
-
$(
|
|
1706
|
+
const { load: t, mapData: r, ...n } = e;
|
|
1707
|
+
return { ...n, load: async (o) => {
|
|
1708
|
+
const a = await t(o);
|
|
1709
|
+
$(o.signal);
|
|
1700
1710
|
try {
|
|
1701
|
-
return r(a,
|
|
1711
|
+
return r(a, o);
|
|
1702
1712
|
} catch (s) {
|
|
1703
|
-
throw new C("validate", `报表 ${
|
|
1713
|
+
throw new C("validate", `报表 ${o.reportId} 数据映射失败`, s);
|
|
1704
1714
|
}
|
|
1705
1715
|
} };
|
|
1706
1716
|
}
|
|
1707
1717
|
class C extends Error {
|
|
1708
|
-
constructor(t, r,
|
|
1709
|
-
super(r), this.name = "ReportSourceError", this.code = t, this.cause =
|
|
1718
|
+
constructor(t, r, n) {
|
|
1719
|
+
super(r), this.name = "ReportSourceError", this.code = t, this.cause = n;
|
|
1710
1720
|
}
|
|
1711
1721
|
}
|
|
1712
1722
|
function de(e) {
|
|
@@ -1716,158 +1726,164 @@ function de(e) {
|
|
|
1716
1726
|
function $(e) {
|
|
1717
1727
|
if (e?.aborted) throw de(e);
|
|
1718
1728
|
}
|
|
1719
|
-
function
|
|
1720
|
-
return t ? new Promise((r,
|
|
1721
|
-
const
|
|
1722
|
-
|
|
1729
|
+
function ye(e, t) {
|
|
1730
|
+
return t ? new Promise((r, n) => {
|
|
1731
|
+
const o = () => t.removeEventListener("abort", a), a = () => {
|
|
1732
|
+
o(), n(de(t));
|
|
1723
1733
|
};
|
|
1724
1734
|
t.addEventListener("abort", a, { once: !0 }), t.aborted && a(), Promise.resolve(e).then(
|
|
1725
1735
|
(s) => {
|
|
1726
|
-
|
|
1736
|
+
o(), r(s);
|
|
1727
1737
|
},
|
|
1728
1738
|
(s) => {
|
|
1729
|
-
|
|
1739
|
+
o(), n(s);
|
|
1730
1740
|
}
|
|
1731
1741
|
);
|
|
1732
1742
|
}) : Promise.resolve(e);
|
|
1733
1743
|
}
|
|
1734
|
-
function
|
|
1744
|
+
function zn(e, t) {
|
|
1735
1745
|
if (!e || typeof e != "object" || Array.isArray(e))
|
|
1736
1746
|
throw new C("validate", `报表 ${t} 的数据集应为对象`);
|
|
1737
|
-
for (const [r,
|
|
1738
|
-
if (!Array.isArray(
|
|
1747
|
+
for (const [r, n] of Object.entries(e))
|
|
1748
|
+
if (!Array.isArray(n) || n.some((o) => !o || typeof o != "object" || Array.isArray(o)))
|
|
1739
1749
|
throw new C("validate", `报表 ${t} 的数据集 ${r} 应为对象数组`);
|
|
1740
1750
|
}
|
|
1741
|
-
async function
|
|
1742
|
-
const { reportId:
|
|
1751
|
+
async function _n(e, t, r) {
|
|
1752
|
+
const { reportId: n, signal: o } = t;
|
|
1743
1753
|
try {
|
|
1744
|
-
const a = await
|
|
1745
|
-
$(
|
|
1746
|
-
const s =
|
|
1754
|
+
const a = await ye(e(t), o);
|
|
1755
|
+
$(o);
|
|
1756
|
+
const s = cr(a);
|
|
1747
1757
|
if (!s.ok)
|
|
1748
|
-
throw new C("validate", `报表 ${
|
|
1749
|
-
return r.push(...s.warnings.map((i) => `${
|
|
1758
|
+
throw new C("validate", `报表 ${n} 模板校验失败:${s.errors.slice(0, 3).map((i) => `${i.path}: ${i.message}`).join("; ")}`);
|
|
1759
|
+
return r.push(...s.warnings.map((i) => `${n}: ${i.path}: ${i.message}`)), a;
|
|
1750
1760
|
} catch (a) {
|
|
1751
|
-
throw
|
|
1761
|
+
throw o?.aborted ? de(o) : a instanceof C ? a : a instanceof lr ? new C("validate", `报表 ${n} 模板校验失败:${a.message}`, a) : new C("fetch", `报表 ${n} 模板加载失败:${a instanceof Error ? a.message : String(a)}`, a);
|
|
1752
1762
|
}
|
|
1753
1763
|
}
|
|
1754
|
-
async function
|
|
1755
|
-
const
|
|
1764
|
+
async function qn(e, t, r, n) {
|
|
1765
|
+
const o = t.signal;
|
|
1756
1766
|
let a;
|
|
1757
1767
|
try {
|
|
1758
|
-
if (e.load) a = await
|
|
1768
|
+
if (e.load) a = await ye(e.load(t), o);
|
|
1759
1769
|
else if (e.provider) {
|
|
1760
|
-
const s = await
|
|
1761
|
-
$(
|
|
1770
|
+
const s = await ye(e.provider.query(t), o);
|
|
1771
|
+
$(o), Un(s, r), a = s.datasets, n?.(r, s);
|
|
1762
1772
|
} else a = e.datasets ?? {};
|
|
1763
1773
|
} catch (s) {
|
|
1764
|
-
throw
|
|
1774
|
+
throw o?.aborted ? de(o) : s instanceof C ? s : new C("fetch", `报表 ${r} 取数失败:${s instanceof Error ? s.message : String(s)}`, s);
|
|
1765
1775
|
}
|
|
1766
|
-
return $(
|
|
1776
|
+
return $(o), a;
|
|
1767
1777
|
}
|
|
1768
|
-
function
|
|
1778
|
+
function Un(e, t) {
|
|
1769
1779
|
if (!e || typeof e != "object" || Array.isArray(e)) throw new C("validate", `报表 ${t} Provider 应返回 datasets 结果对象`);
|
|
1770
1780
|
for (const r of ["revision", "sourceToken"])
|
|
1771
1781
|
if (e[r] !== void 0 && typeof e[r] != "string") throw new C("validate", `报表 ${t} Provider ${r} 应为字符串`);
|
|
1772
1782
|
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))))
|
|
1773
1783
|
throw new C("validate", `报表 ${t} Provider diagnostics 不符合结构化诊断契约`);
|
|
1774
|
-
if (e.diagnostics?.some((r) => !
|
|
1784
|
+
if (e.diagnostics?.some((r) => !Wn(r)))
|
|
1775
1785
|
throw new C("validate", `报表 ${t} Provider 数据说明缺少有效的字段身份或值状态`);
|
|
1776
1786
|
}
|
|
1777
|
-
function
|
|
1787
|
+
function Xn(e, t, r, n, o) {
|
|
1778
1788
|
try {
|
|
1779
|
-
t =
|
|
1789
|
+
t = At(n, t, { maxRows: e.dataValidation?.maxRows, signal: o });
|
|
1780
1790
|
} catch (a) {
|
|
1781
1791
|
throw new C("validate", `报表 ${r} 树形数据无效:${a instanceof Error ? a.message : String(a)}`, a);
|
|
1782
1792
|
}
|
|
1783
1793
|
for (const [a, s] of Object.entries(e.dataSchema ?? {})) {
|
|
1784
1794
|
let i;
|
|
1785
1795
|
try {
|
|
1786
|
-
i =
|
|
1796
|
+
i = et(Object.prototype.hasOwnProperty.call(t, a) ? t[a] : void 0, s, { ...e.dataValidation, path: `$.datasets.${a}` });
|
|
1787
1797
|
} catch (c) {
|
|
1788
1798
|
throw new C("config", `报表 ${r} 数据集 ${a} 字段契约配置无效`, c);
|
|
1789
1799
|
}
|
|
1790
1800
|
if (!i.ok) throw new C("validate", `报表 ${r} 数据集 ${a} 不符合字段契约:${i.issues[0]?.message}`, { issues: i.issues });
|
|
1791
1801
|
}
|
|
1792
1802
|
}
|
|
1793
|
-
function
|
|
1803
|
+
async function Yn(e, t, r, n, o) {
|
|
1794
1804
|
try {
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1805
|
+
let a;
|
|
1806
|
+
try {
|
|
1807
|
+
a = Fn(e);
|
|
1808
|
+
} catch {
|
|
1809
|
+
}
|
|
1810
|
+
const s = a ?? e, i = Lt(t.pagination, n, s.template, s.datasets, o), c = a ? await ht(s.template, s.datasets, i) : mt(s.template, s.datasets, i);
|
|
1811
|
+
return Ht(n, c), { result: c, part: s };
|
|
1812
|
+
} catch (a) {
|
|
1813
|
+
$(o);
|
|
1814
|
+
const s = Dt(a, n);
|
|
1815
|
+
throw new C("validate", `报表 ${r} 排版失败:${s instanceof Error ? s.message : String(s)}`, s);
|
|
1800
1816
|
}
|
|
1801
1817
|
}
|
|
1802
|
-
function
|
|
1818
|
+
function Bt(e, t, r, n, o) {
|
|
1803
1819
|
const a = /* @__PURE__ */ new Map(), s = (i) => {
|
|
1804
1820
|
let c = a.get(i);
|
|
1805
|
-
return c === void 0 && (c = JSON.stringify([r,
|
|
1821
|
+
return c === void 0 && (c = JSON.stringify([r, n, i]), a.set(i, c)), c;
|
|
1806
1822
|
};
|
|
1807
1823
|
for (const i of t.pages) e.push({
|
|
1808
1824
|
...i,
|
|
1809
|
-
meta: { ...i.meta, reportScope:
|
|
1810
|
-
components: Kt(i.components,
|
|
1825
|
+
meta: { ...i.meta, reportScope: Nt(r, n) },
|
|
1826
|
+
components: Kt(i.components, o ?? jt(r, n), s)
|
|
1811
1827
|
});
|
|
1812
1828
|
}
|
|
1813
|
-
async function
|
|
1814
|
-
const a = [], s =
|
|
1829
|
+
async function Qn(e, t, r, n, o) {
|
|
1830
|
+
const a = [], s = pe(n);
|
|
1815
1831
|
for (const [l, d] of e.entries()) {
|
|
1816
|
-
$(
|
|
1832
|
+
$(o);
|
|
1817
1833
|
try {
|
|
1818
|
-
const f = await
|
|
1819
|
-
|
|
1834
|
+
const f = await $t(d.template, d.datasets, Lt(t[l]?.pagination, s, d.template, d.datasets, o));
|
|
1835
|
+
Ht(s, f), Bt(a, f.plan, l, r[l], d.sourceScope);
|
|
1820
1836
|
} catch (f) {
|
|
1821
|
-
throw
|
|
1837
|
+
throw Dt(f, s);
|
|
1822
1838
|
}
|
|
1823
1839
|
}
|
|
1824
|
-
const i = { schemaVersion:
|
|
1840
|
+
const i = { schemaVersion: be, ...e.some((l) => ke(l.template)) ? { requiresRecalculation: !0 } : {}, pages: a }, c = Ze(i);
|
|
1825
1841
|
if (!c.ok) throw new C("validate", `重算渲染计划校验失败:${c.errors[0]?.message}`);
|
|
1826
1842
|
return i;
|
|
1827
1843
|
}
|
|
1828
|
-
function
|
|
1844
|
+
function Ro(e, t = {}) {
|
|
1829
1845
|
if (t.maxPages !== void 0 && (!Number.isSafeInteger(t.maxPages) || t.maxPages < 1)) throw new C("config", "maxPages 应为正安全整数");
|
|
1830
1846
|
if (t.maxCells !== void 0 && (!Number.isSafeInteger(t.maxCells) || t.maxCells < 1)) throw new C("config", "maxCells 应为正安全整数");
|
|
1831
1847
|
try {
|
|
1832
|
-
|
|
1833
|
-
} catch (
|
|
1834
|
-
throw new C("config", "maxChartComponents 应为 1..1000000 的安全整数",
|
|
1848
|
+
pe(t);
|
|
1849
|
+
} catch (o) {
|
|
1850
|
+
throw new C("config", "maxChartComponents 应为 1..1000000 的安全整数", o);
|
|
1835
1851
|
}
|
|
1836
|
-
function r(
|
|
1837
|
-
const a = Object.prototype.hasOwnProperty.call(e,
|
|
1838
|
-
if (!a) throw new C("config", `未注册报表 ${
|
|
1852
|
+
function r(o) {
|
|
1853
|
+
const a = Object.prototype.hasOwnProperty.call(e, o) ? e[o] : void 0;
|
|
1854
|
+
if (!a) throw new C("config", `未注册报表 ${o}`);
|
|
1839
1855
|
if (a.sourceScope !== void 0 && (typeof a.sourceScope != "string" || !a.sourceScope.trim() || a.sourceScope.length > 512)) throw new C("config", "sourceScope 应为不超过 512 字符的非空字符串");
|
|
1840
1856
|
return a;
|
|
1841
1857
|
}
|
|
1842
|
-
return Object.assign(async ({ reportIds:
|
|
1858
|
+
return Object.assign(async ({ reportIds: o, params: a, signal: s, onWarning: i, onQueryResult: c, ...l }) => {
|
|
1843
1859
|
$(s);
|
|
1844
|
-
const d =
|
|
1860
|
+
const d = Bn({ ...l, signal: s }), f = [...o], u = { ...a };
|
|
1845
1861
|
if (f.length === 0) throw new C("config", "缺少报表 ID");
|
|
1846
|
-
const h = f.map(r), m = d.runSync("validate", () => h.map((p) =>
|
|
1862
|
+
const h = f.map(r), m = d.runSync("validate", () => h.map((p) => Ae(
|
|
1847
1863
|
p.params ?? (typeof p.template == "function" ? [] : p.template.params) ?? [],
|
|
1848
1864
|
u
|
|
1849
|
-
))), v = [], y = [], g =
|
|
1865
|
+
))), v = [], y = [], g = pe(t), w = [];
|
|
1850
1866
|
for (const [p, b] of h.entries()) {
|
|
1851
1867
|
$(s);
|
|
1852
|
-
const S = f[p],
|
|
1853
|
-
|
|
1854
|
-
const R = await d.run("query", () =>
|
|
1868
|
+
const S = f[p], P = { reportId: S, params: m[p], signal: s }, T = typeof b.template == "function" ? await d.run("query", () => _n(b.template, P, w), S) : b.template;
|
|
1869
|
+
P.params = d.runSync("validate", () => Ae(b.params ?? T.params ?? [], P.params), S);
|
|
1870
|
+
const R = await d.run("query", () => qn(b, P, S, (ue, Wt) => c?.(ue, Wt, p)), S);
|
|
1855
1871
|
d.runSync("validate", () => {
|
|
1856
|
-
|
|
1872
|
+
zn(R, S), t.onDatasets?.(S, R, T), Xn(b, R, S, T, s);
|
|
1857
1873
|
}, S), $(s);
|
|
1858
|
-
const
|
|
1859
|
-
y.push(
|
|
1874
|
+
const L = jt(p, S, b.sourceScope), { result: Oe, part: Gt } = await d.run("layout", () => Yn({ template: T, datasets: R, sourceScope: L }, b, S, g, s), S);
|
|
1875
|
+
y.push(Gt), Bt(v, Oe.plan, p, S, L), w.push(...Oe.warnings.map((ue) => `${S}: ${ue}`));
|
|
1860
1876
|
}
|
|
1861
1877
|
$(s);
|
|
1862
|
-
const x = { schemaVersion:
|
|
1863
|
-
const p =
|
|
1878
|
+
const x = { schemaVersion: be, ...y.some((p) => ke(p.template)) ? { requiresRecalculation: !0 } : {}, pages: v }, E = d.runSync("validate", () => {
|
|
1879
|
+
const p = Ze(x);
|
|
1864
1880
|
if (!p.ok) throw new C("validate", `渲染计划校验失败:${p.errors.slice(0, 3).map((b) => `${b.path}: ${b.message}`).join("; ")}`);
|
|
1865
1881
|
return p;
|
|
1866
1882
|
});
|
|
1867
|
-
w.push(...
|
|
1868
|
-
const
|
|
1883
|
+
w.push(...E.warnings.map((p) => `${p.path}: ${p.message}`));
|
|
1884
|
+
const k = h.map((p) => ({ ...p, pagination: { ...p.pagination } })), O = { maxPages: t.maxPages, maxCells: t.maxCells, maxChartComponents: t.maxChartComponents };
|
|
1869
1885
|
try {
|
|
1870
|
-
|
|
1886
|
+
Ft(x, { parts: y, validationFormulas: k.map((p) => p.pagination?.formula), rebuild: (p, b) => Qn(p, k, f, O, b) });
|
|
1871
1887
|
} catch {
|
|
1872
1888
|
w.push("来源数据无法建立本地重算口径;当前预览仅支持计划内编辑,请使用可序列化模板数据启用规则重算");
|
|
1873
1889
|
}
|
|
@@ -1876,20 +1892,20 @@ function En(e, t = {}) {
|
|
|
1876
1892
|
$(s), A(p);
|
|
1877
1893
|
return $(s), x;
|
|
1878
1894
|
}, {
|
|
1879
|
-
getParamDefs: (
|
|
1895
|
+
getParamDefs: (o) => dr(e, o)
|
|
1880
1896
|
});
|
|
1881
1897
|
}
|
|
1882
|
-
function
|
|
1898
|
+
function $o(e, t) {
|
|
1883
1899
|
const r = t.maxNodes ?? 1e6;
|
|
1884
1900
|
if (![t.maxBytes, r].every((d) => Number.isSafeInteger(d) && d > 0)) throw t.error("budget", "快照预算应为正安全整数");
|
|
1885
|
-
let
|
|
1901
|
+
let n = 0, o = 0;
|
|
1886
1902
|
const a = /* @__PURE__ */ new Set();
|
|
1887
1903
|
function s(d) {
|
|
1888
|
-
if (
|
|
1904
|
+
if (o += d, o > t.maxBytes) throw t.error("budget", "快照超过字节预算");
|
|
1889
1905
|
}
|
|
1890
1906
|
function i(d, f) {
|
|
1891
|
-
if (++
|
|
1892
|
-
if (
|
|
1907
|
+
if (++n > r || f > 64) throw t.error("budget", "快照节点或深度超过预算");
|
|
1908
|
+
if (n % 1024 === 0 && t.check?.(), typeof d == "string")
|
|
1893
1909
|
return s(d.length + 2), d;
|
|
1894
1910
|
if (d === null || typeof d == "boolean" || typeof d == "number" && Number.isFinite(d))
|
|
1895
1911
|
return s(String(d).length), d;
|
|
@@ -1918,50 +1934,50 @@ function Tn(e, t) {
|
|
|
1918
1934
|
}
|
|
1919
1935
|
export {
|
|
1920
1936
|
mt as A,
|
|
1921
|
-
|
|
1922
|
-
|
|
1937
|
+
ho as B,
|
|
1938
|
+
xr as C,
|
|
1923
1939
|
Er as D,
|
|
1924
|
-
|
|
1925
|
-
|
|
1940
|
+
Ft as E,
|
|
1941
|
+
So as F,
|
|
1926
1942
|
F as G,
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1943
|
+
Mo as H,
|
|
1944
|
+
po as I,
|
|
1945
|
+
We as J,
|
|
1946
|
+
At as K,
|
|
1947
|
+
To as L,
|
|
1948
|
+
jt as M,
|
|
1933
1949
|
Ie as N,
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1950
|
+
U as O,
|
|
1951
|
+
Y as P,
|
|
1952
|
+
Bn as Q,
|
|
1937
1953
|
C as R,
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1954
|
+
Po as S,
|
|
1955
|
+
Dn as T,
|
|
1956
|
+
Nt as U,
|
|
1941
1957
|
M as a,
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1958
|
+
Q as b,
|
|
1959
|
+
W as c,
|
|
1960
|
+
Eo as d,
|
|
1961
|
+
an as e,
|
|
1962
|
+
yo as f,
|
|
1963
|
+
vo as g,
|
|
1964
|
+
Pn as h,
|
|
1965
|
+
Tt as i,
|
|
1966
|
+
un as j,
|
|
1967
|
+
mo as k,
|
|
1968
|
+
wo as l,
|
|
1969
|
+
bo as m,
|
|
1970
|
+
D as n,
|
|
1971
|
+
Co as o,
|
|
1972
|
+
Mt as p,
|
|
1973
|
+
Ro as q,
|
|
1974
|
+
go as r,
|
|
1975
|
+
$o as s,
|
|
1976
|
+
ko as t,
|
|
1977
|
+
q as u,
|
|
1962
1978
|
$e as v,
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1979
|
+
xo as w,
|
|
1980
|
+
Wn as x,
|
|
1981
|
+
Ot as y,
|
|
1982
|
+
Gn as z
|
|
1967
1983
|
};
|