@agile-team/mach-report 2.11.2 → 2.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -5
- package/THIRD_PARTY_NOTICES.md +270 -0
- package/dist/{ExcelBindingWizard-LWX6G1A2.js → ExcelBindingWizard-CeAf4QSE.js} +2 -2
- package/dist/{ExcelBindingWizard-a4kslPHF.cjs → ExcelBindingWizard-y0mT-AHR.cjs} +1 -1
- package/dist/{RuleEditor-C2QsOHOs.cjs → RuleEditor-ChRzNQuF.cjs} +1 -1
- package/dist/{RuleEditor-D9wQHrkf.js → RuleEditor-DzAmW5YH.js} +1 -1
- package/dist/analytics.d.cts +28 -0
- package/dist/analytics.d.ts +28 -0
- package/dist/assets-C2U-e-Sz.cjs +4 -0
- package/dist/assets-Q0wUwNrV.js +217 -0
- package/dist/code-options-BKXXY7NI.js +18 -0
- package/dist/code-options-BUTChiZZ.cjs +1 -0
- package/dist/codes.cjs +9 -0
- package/dist/codes.d.cts +223 -0
- package/dist/codes.d.ts +223 -0
- package/dist/codes.js +26917 -0
- package/dist/designer.cjs +2 -2
- package/dist/designer.d.cts +267 -0
- package/dist/designer.d.ts +267 -0
- package/dist/designer.js +2737 -1941
- package/dist/grid-strokes-Cr7DwUux.cjs +1 -0
- package/dist/grid-strokes-DyyG1q_o.js +53 -0
- package/dist/index.cjs +7 -7
- package/dist/index.d.cts +80 -1
- package/dist/index.d.ts +80 -1
- package/dist/index.js +404 -374
- package/dist/pdf.cjs +76 -59
- package/dist/pdf.d.cts +51 -0
- package/dist/pdf.d.ts +51 -0
- package/dist/pdf.js +32128 -32048
- package/dist/record-bindings-By_UKZ2g.cjs +1 -0
- package/dist/{list-cell-ClFra1zS.js → record-bindings-D-5jQlTj.js} +67 -44
- package/dist/{region-binding-workflow-DhQvu1co.cjs → region-binding-workflow-BzfbxRiR.cjs} +1 -1
- package/dist/{region-binding-workflow-CXDmt9Bs.js → region-binding-workflow-CcUq8W2Q.js} +1 -1
- package/dist/server/node.d.cts +52 -1
- package/dist/server/node.d.ts +52 -1
- package/dist/server-node.cjs +1 -1
- package/dist/server-node.js +239 -210
- package/dist/server.cjs +1 -1
- package/dist/server.d.cts +95 -3
- package/dist/server.d.ts +95 -3
- package/dist/server.js +456 -433
- package/dist/style.css +1 -1
- package/dist/{template-registry-WNXdkiET.js → template-registry-BjE1VS6g.js} +221 -157
- package/dist/template-registry-D3SjENi6.cjs +1 -0
- package/dist/template-review-BfCC8Ng9.cjs +2 -0
- package/dist/{template-review-BdcXSYbx.js → template-review-BzpcI-tR.js} +772 -666
- package/dist/validate-BJ5HIWY8.cjs +1 -0
- package/dist/validate-DbgEM1Hh.js +163 -0
- package/dist/vue/async.d.cts +121 -2
- package/dist/vue/async.d.ts +121 -2
- package/dist/vue/index.d.cts +114 -6
- package/dist/vue/index.d.ts +114 -6
- package/dist/{workbook-session-BKOTwcoq.js → workbook-session-BPb3TMnT.js} +1 -1
- package/dist/{workbook-session-CLYLhZWu.cjs → workbook-session-DNa2RHNG.cjs} +1 -1
- package/dist/worker.cjs +1 -1
- package/dist/worker.d.cts +52 -1
- package/dist/worker.d.ts +52 -1
- package/dist/worker.js +2 -2
- package/dist/xlsx.cjs +1 -1
- package/dist/xlsx.d.cts +40 -0
- package/dist/xlsx.d.ts +40 -0
- package/dist/xlsx.js +3 -3
- package/package.json +16 -3
- package/dist/assets-Bu6UohJx.cjs +0 -1
- package/dist/assets-DegqDNqY.js +0 -160
- package/dist/list-cell-BuYn4tGF.cjs +0 -1
- package/dist/template-registry-ukBGlm8N.cjs +0 -1
- package/dist/template-review-BXp2oyqg.cjs +0 -1
- package/dist/textwrap-CWHyzkBH.cjs +0 -4
- package/dist/textwrap-DE1kgcJB.js +0 -110
- package/dist/validate-7s0yn6ii.js +0 -148
- package/dist/validate-DsRiNw8h.cjs +0 -1
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
import { R as
|
|
2
|
-
import { c as
|
|
3
|
-
import { g as
|
|
4
|
-
import { e as
|
|
5
|
-
import { a as
|
|
6
|
-
import { r as
|
|
7
|
-
import { f as
|
|
8
|
-
import { c as
|
|
9
|
-
import { d as
|
|
10
|
-
import { c as
|
|
11
|
-
import {
|
|
12
|
-
import { e as
|
|
13
|
-
import { d as
|
|
14
|
-
import { e as
|
|
15
|
-
import { f as
|
|
16
|
-
import {
|
|
17
|
-
import { i as
|
|
18
|
-
function
|
|
1
|
+
import { R as ee } from "./render-plan-Ck6koX9L.js";
|
|
2
|
+
import { c as Oe } from "./validate-DbgEM1Hh.js";
|
|
3
|
+
import { g as $t } from "./report-params-B44imUd4.js";
|
|
4
|
+
import { e as xt, r as St, f as Tt, v as It, R as Pt, p as de } from "./template-registry-BjE1VS6g.js";
|
|
5
|
+
import { a as Pe, d as kt } from "./param-validation-BlHHXs6u.js";
|
|
6
|
+
import { r as pe } from "./grid-geometry-BNptEcMm.js";
|
|
7
|
+
import { f as Rt, i as Et } from "./number-format-BA_KwrZe.js";
|
|
8
|
+
import { c as Ct } from "./task-events-Dpsvf_t2.js";
|
|
9
|
+
import { d as Ft, v as Ke } from "./dataset-H5pFuQGU.js";
|
|
10
|
+
import { c as At, D as je, L as Ne } from "./defaults-DXhiM1ZD.js";
|
|
11
|
+
import { w as te, h as Le } from "./assets-Q0wUwNrV.js";
|
|
12
|
+
import { R as F, g as He, b as Ot, i as Kt, e as D, l as he, c as jt, t as Be, h as We, f as De, j as Nt, k as Lt } from "./record-bindings-D-5jQlTj.js";
|
|
13
|
+
import { d as Ve, b as Ht } from "./computed-Bvk0W15F.js";
|
|
14
|
+
import { e as Bt, a as Wt } from "./matrix-yZsGnldA.js";
|
|
15
|
+
import { f as Ge, a as Dt, c as Vt } from "./tree-CqcQ99NM.js";
|
|
16
|
+
import { r as we, b as Gt, e as j } from "./style-CQ1PK8ZB.js";
|
|
17
|
+
import { i as zt } from "./capabilities-CK_7hizc.js";
|
|
18
|
+
function Jt(e, t, r) {
|
|
19
19
|
const n = /* @__PURE__ */ new Set(), o = e.cells.map((a, s) => {
|
|
20
|
-
const
|
|
20
|
+
const c = [];
|
|
21
21
|
let i = 0;
|
|
22
|
-
for (const
|
|
22
|
+
for (const l of a) {
|
|
23
23
|
for (; n.has(`${s}:${i}`); ) i++;
|
|
24
|
-
const d =
|
|
24
|
+
const d = l?.colSpan ?? 1, u = l?.rowSpan ?? 1;
|
|
25
25
|
let f = 0;
|
|
26
26
|
for (let m = i; m < i + d; m++) {
|
|
27
27
|
t.has(m) && f++;
|
|
28
28
|
for (let w = s + 1; w < s + u; w++)
|
|
29
29
|
n.add(`${w}:${m}`);
|
|
30
30
|
}
|
|
31
|
-
f &&
|
|
31
|
+
f && c.push(l ? { ...l, colSpan: f } : null), i += d;
|
|
32
32
|
}
|
|
33
|
-
return
|
|
33
|
+
return c;
|
|
34
34
|
});
|
|
35
35
|
return { ...e, cells: o, colWidthsMm: r };
|
|
36
36
|
}
|
|
37
|
-
function
|
|
37
|
+
function qt(e) {
|
|
38
38
|
if (!e.columns.some((n) => n.hidden)) return e;
|
|
39
39
|
const t = /* @__PURE__ */ new Set(), r = e.columns.filter((n, o) => n.hidden ? !1 : (t.add(o), !0));
|
|
40
40
|
if (!r.length) throw new Error("列表至少需要一列可见列");
|
|
@@ -42,7 +42,7 @@ function Kt(e) {
|
|
|
42
42
|
...e,
|
|
43
43
|
columns: r,
|
|
44
44
|
...e.headerGrid ? {
|
|
45
|
-
headerGrid:
|
|
45
|
+
headerGrid: Jt(
|
|
46
46
|
e.headerGrid,
|
|
47
47
|
t,
|
|
48
48
|
r.map((n) => n.widthMm)
|
|
@@ -50,33 +50,33 @@ function Kt(e) {
|
|
|
50
50
|
} : {}
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
|
-
function*
|
|
53
|
+
function* _t(e) {
|
|
54
54
|
const { page: t } = e;
|
|
55
|
-
|
|
55
|
+
xt(t.components, t.flow);
|
|
56
56
|
let r = 0, n = 0;
|
|
57
|
-
for (const o of
|
|
57
|
+
for (const o of St(t.components, t.flow)) {
|
|
58
58
|
e.active();
|
|
59
|
-
const a = o.band, s = o.components.some((d) => d.kind === "list" && d.cardinality !== "record"),
|
|
59
|
+
const a = o.band, s = o.components.some((d) => d.kind === "list" && d.cardinality !== "record"), c = s ? 0 : o.components.reduce((d, u) => Math.max(d, u.topMm - a.topMm + (u.kind === "list" ? e.height(u) : u.heightMm)), a.heightMm);
|
|
60
60
|
let i = Math.max(e.top(), n + a.topMm - r);
|
|
61
|
-
if (!s &&
|
|
62
|
-
!s && i +
|
|
63
|
-
let
|
|
61
|
+
if (!s && c > e.bottom() - e.top() + 1e-3) throw new Error(`静态区域 ${a.componentIds.join(",")} 高度超出单页可用范围`);
|
|
62
|
+
!s && i + c > e.bottom() + 1e-3 && (e.nextPage(), yield* e.takePages(), e.active(), i = e.top());
|
|
63
|
+
let l = i + c;
|
|
64
64
|
for (const d of o.components) {
|
|
65
65
|
const u = i + d.topMm - a.topMm;
|
|
66
66
|
d.kind === "list" ? (yield* e.list(d, u, (f) => {
|
|
67
|
-
|
|
67
|
+
l = s ? f : Math.max(l, f);
|
|
68
68
|
}), e.active()) : e.append({ ...d, topMm: u });
|
|
69
69
|
}
|
|
70
|
-
n =
|
|
70
|
+
n = l, r = a.topMm + a.heightMm;
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
|
-
function
|
|
73
|
+
function Ut(e) {
|
|
74
74
|
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));
|
|
75
75
|
}
|
|
76
|
-
function
|
|
77
|
-
return e.pages.some((t) => t.components.some((r) => r.kind === "list" &&
|
|
76
|
+
function re(e) {
|
|
77
|
+
return e.pages.some((t) => t.components.some((r) => r.kind === "list" && Ut(r)));
|
|
78
78
|
}
|
|
79
|
-
class
|
|
79
|
+
class H extends Error {
|
|
80
80
|
constructor(t, r) {
|
|
81
81
|
super(`报表页数超出上限 ${t}(至少 ${r} 页)`), this.limit = t, this.actual = r, this.code = "page-limit", this.name = "PaginatePageLimitError";
|
|
82
82
|
}
|
|
@@ -86,7 +86,98 @@ class V extends Error {
|
|
|
86
86
|
super(`报表单元格数量超出上限 ${t}(至少 ${r} 格)`), this.limit = t, this.actual = r, this.code = "cell-limit", this.name = "PaginateCellLimitError";
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
|
-
|
|
89
|
+
const Yt = 1e4, ke = 25e4;
|
|
90
|
+
function ye(e) {
|
|
91
|
+
if (e?.aborted) throw e.reason ?? new DOMException("标签生成已取消", "AbortError");
|
|
92
|
+
}
|
|
93
|
+
function ze(e, t, r) {
|
|
94
|
+
const n = typeof e.copies == "object" ? He(t, e.copies.field, r) : e.copies ?? 1;
|
|
95
|
+
if (typeof n != "number" || !Number.isSafeInteger(n) || n < 1 || n > 1e3) throw new F(`$.datasets.${r.dataset}[${r.rowIndex}]`, "每条记录复制数必须是 1..1000 的数值型整数", r.rowIndex, typeof e.copies == "object" ? e.copies.field : void 0);
|
|
96
|
+
return n;
|
|
97
|
+
}
|
|
98
|
+
function Je(e, t, r) {
|
|
99
|
+
if (e.rowKey === void 0) return;
|
|
100
|
+
const n = He(t, e.rowKey, r);
|
|
101
|
+
if (typeof n == "string" && n.trim() || typeof n == "number" && Number.isFinite(n)) return n;
|
|
102
|
+
throw new F(`$.datasets.${r.dataset}[${r.rowIndex}].${e.rowKey}`, "业务主键必须是非空字符串或有限数字", r.rowIndex, e.rowKey);
|
|
103
|
+
}
|
|
104
|
+
function Xt(e) {
|
|
105
|
+
const t = (r) => 1 + (r.grid?.cells.reduce((n, o) => n + 1 + o.length + o.reduce((a, s) => a + (s?.children?.reduce((c, i) => c + t(i), 0) ?? 0), 0), 0) ?? 0);
|
|
106
|
+
return e.pages.reduce((r, n) => r + n.components.reduce((o, a) => o + t(a), 0), 0);
|
|
107
|
+
}
|
|
108
|
+
function Qt(e, t, r) {
|
|
109
|
+
const n = e.repeat, o = Object.prototype.hasOwnProperty.call(t, n.dataset) ? t[n.dataset] : void 0;
|
|
110
|
+
if (!Array.isArray(o)) throw new F(`$.datasets.${n.dataset}`, "逐记录标签数据集缺失,应提供对象数组(允许空数组)");
|
|
111
|
+
const a = /* @__PURE__ */ new Set(), s = r.maxPages ?? Yt, c = Xt(e);
|
|
112
|
+
let i = 0, l = 0;
|
|
113
|
+
for (const [d, u] of o.entries()) {
|
|
114
|
+
if (ye(r.signal), !u || typeof u != "object" || Array.isArray(u)) throw new F(`$.datasets.${n.dataset}[${d}]`, "标签记录应为对象", d);
|
|
115
|
+
const f = { rowIndex: d, dataset: n.dataset }, m = Je(n, u, f);
|
|
116
|
+
if (m !== void 0) {
|
|
117
|
+
const g = JSON.stringify([typeof m, m]);
|
|
118
|
+
if (a.has(g)) throw new F(`$.datasets.${n.dataset}[${d}].${n.rowKey}`, "业务主键重复;请先确认记录来源,避免重复打印标签", d, n.rowKey);
|
|
119
|
+
a.add(g);
|
|
120
|
+
}
|
|
121
|
+
const w = ze(n, u, f);
|
|
122
|
+
if (i += w * e.pages.length, l += w * c, i > s) throw new H(s, i);
|
|
123
|
+
if (l > ke) throw new F("$.repeat", `标签组件总量(含网格行、槽位及嵌套组件)超过安全预算 ${ke},请分批生成`, d);
|
|
124
|
+
}
|
|
125
|
+
return o;
|
|
126
|
+
}
|
|
127
|
+
function Zt(e, t, r) {
|
|
128
|
+
if (!e.binding) return e;
|
|
129
|
+
const { binding: n, ...o } = e, a = Ot(n, t.row, t);
|
|
130
|
+
if (e.kind === "image") {
|
|
131
|
+
if (!a) return;
|
|
132
|
+
if (!Kt(a)) throw new F(`${r}.binding`, "图片字段只接受 PNG/JPEG base64 data URL;业务 URL 应由宿主安全加载后转换", t.rowIndex, n.field);
|
|
133
|
+
return { ...o, imageData: a };
|
|
134
|
+
}
|
|
135
|
+
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 });
|
|
136
|
+
}
|
|
137
|
+
function er(e, t, r) {
|
|
138
|
+
if (e.kind !== "text" || e.grid || e.richParagraphs?.length) return e;
|
|
139
|
+
const n = e.style ?? {}, o = we(n).fontSizePt, a = e.text ?? e.lines?.join(`
|
|
140
|
+
`) ?? "";
|
|
141
|
+
if (a.length > 16384) throw new F(r, "标签文本超过 16384 字符预算,请缩小字段内容", t.rowIndex);
|
|
142
|
+
const s = te(a, e.widthMm, { fontSizePt: o, bold: n.bold, italic: n.italic, fontFamily: n.fontFamily, letterSpacingPt: n.letterSpacing }, t.options.measurer ?? Le), c = s.length * o * Gt(n) * 25.4 / 72;
|
|
143
|
+
if (c > e.heightMm + 0.05) throw new F(r, `标签文字需要约 ${c.toFixed(2)}mm 高,超出 ${e.heightMm}mm;请增大文本区域、减少内容或调整字号`, t.rowIndex, e.binding?.field);
|
|
144
|
+
return { ...e, lines: s };
|
|
145
|
+
}
|
|
146
|
+
function qe(e, t, r) {
|
|
147
|
+
ye(t.options.signal);
|
|
148
|
+
const n = Zt(e, t, r);
|
|
149
|
+
if (!n) return;
|
|
150
|
+
let o = n.grid;
|
|
151
|
+
return o && (o = { ...o, cells: o.cells.map((a, s) => a.map((c, i) => c?.children?.length ? { ...c, children: c.children.flatMap((l, d) => {
|
|
152
|
+
const u = qe(l, t, `${r}.grid.cells.${s}.${i}.children.${d}`);
|
|
153
|
+
return u ? [u] : [];
|
|
154
|
+
}) } : c)) }), er(o === n.grid ? n : { ...n, grid: o }, t, r);
|
|
155
|
+
}
|
|
156
|
+
function tr(e, t, r, n, o, a) {
|
|
157
|
+
return {
|
|
158
|
+
...e,
|
|
159
|
+
components: e.components.flatMap((s, c) => {
|
|
160
|
+
const i = qe(s, r, `$.pages.${t}.components.${c}`);
|
|
161
|
+
return i ? [{ ...i, meta: { ...i.meta, labelSource: { pageIndex: t, componentIndex: c } } }] : [];
|
|
162
|
+
}),
|
|
163
|
+
meta: { ...e.meta, record: { dataset: r.dataset, rowIndex: r.rowIndex, ...a === void 0 ? {} : { rowKey: a }, copyIndex: n, copyCount: o, templatePageIndex: t } }
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
function* rr(e, t, r) {
|
|
167
|
+
const n = [];
|
|
168
|
+
if (Tt(e, n), n.length) throw new F(n[0].path, n[0].message);
|
|
169
|
+
if (!e.repeat) {
|
|
170
|
+
for (const [s, c] of e.pages.entries()) yield { page: c, pageIndex: s };
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
const o = e.repeat, a = Qt(e, t, r);
|
|
174
|
+
for (const [s, c] of a.entries()) {
|
|
175
|
+
const i = { row: c, rowIndex: s, dataset: o.dataset, options: r }, l = ze(o, c, i), d = Je(o, c, i);
|
|
176
|
+
for (let u = 0; u < l; u++) for (const [f, m] of e.pages.entries())
|
|
177
|
+
ye(r.signal), yield { page: tr(m, f, i, u, l, d), pageIndex: f };
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
function nr(e) {
|
|
90
181
|
return {
|
|
91
182
|
widthMm: e.widthMm,
|
|
92
183
|
heightMm: e.heightMm,
|
|
@@ -101,60 +192,60 @@ function Q(e, t) {
|
|
|
101
192
|
const r = t.heightMm - (e.layout === "wide" ? t.marginBottomMm : e.marginBottomMm ?? t.marginBottomMm);
|
|
102
193
|
return e.components.reduce((n, o) => o.kind !== "list" && o.pageAnchor === "footer" ? Math.min(n, o.topMm) : n, r);
|
|
103
194
|
}
|
|
104
|
-
function
|
|
195
|
+
function z(e) {
|
|
105
196
|
return e.components.reduce((t, r) => r.kind !== "list" && r.pageAnchor === "header" ? Math.max(t, r.topMm + r.heightMm) : t, 0);
|
|
106
197
|
}
|
|
107
|
-
function
|
|
198
|
+
function _e(e, t) {
|
|
108
199
|
let r = e.textMetrics.get(t);
|
|
109
200
|
if (!r) {
|
|
110
|
-
const n =
|
|
201
|
+
const n = we(t).fontSizePt;
|
|
111
202
|
r = {
|
|
112
203
|
measureOptions: {
|
|
113
204
|
fontSizePt: n,
|
|
114
|
-
fontFamily: t.fontFamily ??
|
|
205
|
+
fontFamily: t.fontFamily ?? je,
|
|
115
206
|
italic: t.italic,
|
|
116
207
|
bold: t.bold,
|
|
117
208
|
letterSpacingPt: t.letterSpacing
|
|
118
209
|
},
|
|
119
|
-
lineMm: n * (t.lineHeight ??
|
|
210
|
+
lineMm: n * (t.lineHeight ?? Ne) * 25.4 / 72
|
|
120
211
|
}, e.textMetrics.set(t, r);
|
|
121
212
|
}
|
|
122
213
|
return r;
|
|
123
214
|
}
|
|
124
|
-
function
|
|
215
|
+
function or(e) {
|
|
125
216
|
if (e === null || typeof e == "string" || typeof e == "boolean" || typeof e == "number" && Number.isFinite(e)) return e;
|
|
126
217
|
}
|
|
127
|
-
function
|
|
128
|
-
const r = e.fontSizePt ??
|
|
129
|
-
...
|
|
218
|
+
function be(e, t) {
|
|
219
|
+
const r = e.fontSizePt ?? At, n = e.paddingMm ?? 1, o = e.columns.map((g) => g.align ?? g.style?.align ?? e.align ?? "left"), a = e.columns.map((g, p) => ({
|
|
220
|
+
...j({
|
|
130
221
|
fontSize: r,
|
|
131
222
|
verticalAlign: "middle"
|
|
132
223
|
}, g.style),
|
|
133
|
-
align: o[
|
|
134
|
-
})), s = a.map((g,
|
|
135
|
-
const M = s[
|
|
224
|
+
align: o[p] === "auto" ? "left" : o[p]
|
|
225
|
+
})), s = a.map((g, p) => o[p] === "auto" ? { left: g, center: { ...g, align: "center" }, right: { ...g, align: "right" } } : void 0), c = e.columns.map((g, p) => g.rules?.map((v) => {
|
|
226
|
+
const M = s[p];
|
|
136
227
|
if (M) return {
|
|
137
|
-
left:
|
|
138
|
-
center:
|
|
139
|
-
right:
|
|
228
|
+
left: j(M.left, v.style),
|
|
229
|
+
center: j(M.center, v.style),
|
|
230
|
+
right: j(M.right, v.style)
|
|
140
231
|
};
|
|
141
|
-
const y =
|
|
232
|
+
const y = j(a[p], v.style);
|
|
142
233
|
return { left: y, center: y, right: y };
|
|
143
|
-
})), i = e.columns.map((g) =>
|
|
234
|
+
})), i = e.columns.map((g) => jt(e, g)), l = e.columns.map((g) => g.header);
|
|
144
235
|
let d = e.rowHeightMm ?? 0;
|
|
145
|
-
for (let g = 0; g <
|
|
146
|
-
const
|
|
147
|
-
|
|
236
|
+
for (let g = 0; g < l.length; g++) {
|
|
237
|
+
const p = i[g], v = we(p).fontSizePt, M = te(
|
|
238
|
+
l[g],
|
|
148
239
|
e.columns[g].widthMm - n * 2,
|
|
149
|
-
{ fontSizePt: v, fontFamily:
|
|
240
|
+
{ fontSizePt: v, fontFamily: p.fontFamily ?? je, italic: p.italic, bold: p.bold, letterSpacingPt: p.letterSpacing },
|
|
150
241
|
t
|
|
151
|
-
), y = v * (
|
|
242
|
+
), y = v * (p.lineHeight ?? Ne) * 25.4 / 72;
|
|
152
243
|
d = Math.max(d, Math.max(M.length, 1) * y + n * 2);
|
|
153
244
|
}
|
|
154
|
-
const u =
|
|
245
|
+
const u = l.map((g, p) => ({
|
|
155
246
|
text: g,
|
|
156
|
-
style: i[
|
|
157
|
-
})), f = e.border === !1 ? { borderTop: !1, borderRight: !1, borderBottom: !1, borderLeft: !1 } : { borderBottom: !0, borderLeft: !0, borderRight: !0, borderTop: !0 }, m = e.columns.map((g) => g.widthMm), w =
|
|
247
|
+
style: i[p]
|
|
248
|
+
})), f = e.border === !1 ? { borderTop: !1, borderRight: !1, borderBottom: !1, borderLeft: !1 } : { borderBottom: !0, borderLeft: !0, borderRight: !0, borderTop: !0 }, m = e.columns.map((g) => g.widthMm), w = ar(e.headerGrid, m, {
|
|
158
249
|
cells: [u],
|
|
159
250
|
colWidthsMm: m,
|
|
160
251
|
rowHeightsMm: [d],
|
|
@@ -165,69 +256,69 @@ function pe(e, t) {
|
|
|
165
256
|
paddingMm: n,
|
|
166
257
|
cellStyles: a,
|
|
167
258
|
autoStyles: s,
|
|
168
|
-
ruleStyles:
|
|
259
|
+
ruleStyles: c,
|
|
169
260
|
textMetrics: /* @__PURE__ */ new WeakMap(),
|
|
170
|
-
numberFormats: e.columns.map((g) =>
|
|
261
|
+
numberFormats: e.columns.map((g) => Be(g.format)),
|
|
171
262
|
derivedFields: new Set(e.computed?.map((g) => g.field)),
|
|
172
263
|
borderStyle: f,
|
|
173
|
-
headerHeightMm: w.rowHeightsMm.reduce((g,
|
|
264
|
+
headerHeightMm: w.rowHeightsMm.reduce((g, p) => g + p, 0),
|
|
174
265
|
headerGrid: w,
|
|
175
266
|
colWidthsMm: m,
|
|
176
267
|
columns: e.columns
|
|
177
268
|
};
|
|
178
269
|
}
|
|
179
|
-
function
|
|
270
|
+
function ar(e, t, r) {
|
|
180
271
|
if (!e) return r;
|
|
181
272
|
if (!e.cells.length) throw new Error("自定义列表表头至少需要一行");
|
|
182
273
|
const n = e.rowHeightsMm ?? e.cells.map(() => r.rowHeightsMm[0]);
|
|
183
274
|
if (n.length !== e.cells.length || n.some((o) => !Number.isFinite(o) || o <= 0)) throw new Error("自定义列表表头行高无效");
|
|
184
275
|
return { ...e, colWidthsMm: t, rowHeightsMm: n };
|
|
185
276
|
}
|
|
186
|
-
function
|
|
277
|
+
function sr(e, t, r) {
|
|
187
278
|
const n = t.format?.kind === "number" || t.format?.kind === "percent";
|
|
188
279
|
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);
|
|
189
280
|
}
|
|
190
|
-
function
|
|
281
|
+
function J(e, t, r) {
|
|
191
282
|
const n = e.columns, o = e.tree?.rows.get(t);
|
|
192
283
|
let a = e.rowHeightFloorMm;
|
|
193
284
|
const s = new Array(n.length);
|
|
194
|
-
for (let
|
|
195
|
-
const i = n[
|
|
196
|
-
let u = e.autoStyles[
|
|
285
|
+
for (let c = 0; c < n.length; c++) {
|
|
286
|
+
const i = n[c], l = i.visibleWhen && !D(t, i.visibleWhen) ? null : t[i.field], d = e.autoStyles[c] ? We(l, i.format, i.semanticRole) : "left";
|
|
287
|
+
let u = e.autoStyles[c]?.[d] ?? e.cellStyles[c];
|
|
197
288
|
if (i.rules)
|
|
198
289
|
for (let M = 0; M < i.rules.length; M++) {
|
|
199
290
|
const y = i.rules[M];
|
|
200
|
-
if (
|
|
201
|
-
u = e.ruleStyles[
|
|
291
|
+
if (D(t, y.when)) {
|
|
292
|
+
u = e.ruleStyles[c][M][d];
|
|
202
293
|
break;
|
|
203
294
|
}
|
|
204
295
|
}
|
|
205
|
-
const f = i.format ?
|
|
206
|
-
u =
|
|
207
|
-
const w =
|
|
296
|
+
const f = i.format ? De(l, i.format) : he(l), m = ir(e, i, o);
|
|
297
|
+
u = cr(e, i, u, o);
|
|
298
|
+
const w = _e(e, u), g = te(f, Math.max(1, i.widthMm - e.paddingMm * 2 - m), w.measureOptions, r);
|
|
208
299
|
a = Math.max(a, g.length * w.lineMm + e.paddingMm * 2);
|
|
209
|
-
const
|
|
210
|
-
|
|
300
|
+
const p = or(l), v = { text: f, style: u };
|
|
301
|
+
p !== void 0 && (v.value = p), sr(v, i, e.numberFormats[c]), lr(v, i, e, o, m), e.derivedFields.has(i.field) && (v.derived = !0, v.editable = !1), i.visibleWhen && l === null && !D(t, i.visibleWhen) && (v.editable = !1), s[c] = v;
|
|
211
302
|
}
|
|
212
303
|
return {
|
|
213
304
|
grid: { cells: [s], colWidthsMm: e.colWidthsMm, rowHeightsMm: [a], paddingMm: e.paddingMm },
|
|
214
305
|
heightMm: a
|
|
215
306
|
};
|
|
216
307
|
}
|
|
217
|
-
function
|
|
218
|
-
return !r || t.field !== e.tree.list.tree.labelField ? 0 :
|
|
308
|
+
function ir(e, t, r) {
|
|
309
|
+
return !r || t.field !== e.tree.list.tree.labelField ? 0 : Nt(e.tree.list, t, r, e.paddingMm);
|
|
219
310
|
}
|
|
220
|
-
function
|
|
311
|
+
function cr(e, t, r, n) {
|
|
221
312
|
return !n || t.field !== e.tree.list.tree.labelField || r.align === "left" ? r : { ...r, align: "left" };
|
|
222
313
|
}
|
|
223
|
-
function
|
|
224
|
-
n && (o && (e.indentMm = o),
|
|
314
|
+
function lr(e, t, r, n, o = 0) {
|
|
315
|
+
n && (o && (e.indentMm = o), Lt(e, t, n, r.tree.list));
|
|
225
316
|
}
|
|
226
|
-
function
|
|
317
|
+
function Ue(e) {
|
|
227
318
|
if (e != null && typeof e != "string" && typeof e != "boolean" && !(typeof e == "number" && Number.isFinite(e))) throw new Error("分组字段应为有限 JSON 标量");
|
|
228
319
|
return JSON.stringify([typeof e, e ?? null]);
|
|
229
320
|
}
|
|
230
|
-
function*
|
|
321
|
+
function* Ye(e, t, r = 0) {
|
|
231
322
|
const n = t[r];
|
|
232
323
|
if (!n) {
|
|
233
324
|
for (const a of e) yield { kind: "row", row: a };
|
|
@@ -235,51 +326,51 @@ function* Ve(e, t, r = 0) {
|
|
|
235
326
|
}
|
|
236
327
|
const o = /* @__PURE__ */ new Map();
|
|
237
328
|
for (const a of e) {
|
|
238
|
-
const s =
|
|
239
|
-
|
|
329
|
+
const s = Ue(a[n.field]), c = o.get(s);
|
|
330
|
+
c ? c.push(a) : o.set(s, [a]);
|
|
240
331
|
}
|
|
241
332
|
for (const a of o.values())
|
|
242
|
-
yield { kind: "groupHeader", label: (n.headerTemplate ?? "{value}").replace(/\{value\}/g, he(a[0][n.field])), firstRow: a[0], group: n, depth: r, rows: a }, yield*
|
|
333
|
+
yield { kind: "groupHeader", label: (n.headerTemplate ?? "{value}").replace(/\{value\}/g, he(a[0][n.field])), firstRow: a[0], group: n, depth: r, rows: a }, yield* Ye(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 };
|
|
243
334
|
}
|
|
244
|
-
function
|
|
335
|
+
function Xe(e, t, r, n = []) {
|
|
245
336
|
const o = [...r.filter((a) => !n.some((s) => s.field === a)).map((a) => ({ field: a, op: "sum" })), ...n];
|
|
246
337
|
return new Map(o.map((a) => {
|
|
247
|
-
const s = e.find((i) => i.field === a.field)?.format ?? { kind: "number", thousands: !0 },
|
|
248
|
-
return [a.field, { text:
|
|
338
|
+
const s = e.find((i) => i.field === a.field)?.format ?? { kind: "number", thousands: !0 }, c = Ht(t, { ...a, field: a.valueField ?? a.field });
|
|
339
|
+
return [a.field, { text: De(c, s), ...c === null ? {} : { value: c }, ...typeof c == "number" ? { numberFormat: Be(s) } : {} }];
|
|
249
340
|
}));
|
|
250
341
|
}
|
|
251
|
-
function
|
|
342
|
+
function Qe(e, t) {
|
|
252
343
|
const r = e.findIndex((n) => t.includes(n.field));
|
|
253
344
|
return r < 0 ? 1 : r;
|
|
254
345
|
}
|
|
255
346
|
function G(e, t, r, n, o, a) {
|
|
256
|
-
const s = [],
|
|
257
|
-
|
|
258
|
-
for (let f =
|
|
259
|
-
const m = e.columns[f], w = n.get(m.field), g = e.autoStyles[f]?.[
|
|
260
|
-
s.push({ ...w, text: w?.text ?? "", style:
|
|
347
|
+
const s = [], c = Math.max(0, Math.min(a, e.columns.length)), i = j({ fontSize: e.fontSizePt }, o);
|
|
348
|
+
c && s.push({ text: r, colSpan: c, style: { bold: !0, ...i } });
|
|
349
|
+
for (let f = c; f < e.columns.length; f++) {
|
|
350
|
+
const m = e.columns[f], w = n.get(m.field), g = e.autoStyles[f]?.[We(w?.value, m.format)] ?? e.cellStyles[f];
|
|
351
|
+
s.push({ ...w, text: w?.text ?? "", style: j(g, o) });
|
|
261
352
|
}
|
|
262
|
-
const
|
|
353
|
+
const l = { text: r, colSpan: e.columns.length, style: { bold: !0, ...i } }, d = c ? [s] : [[l], s], u = d.map((f) => dr(e, f, t));
|
|
263
354
|
return {
|
|
264
355
|
grid: { cells: d, colWidthsMm: e.colWidthsMm, rowHeightsMm: u, paddingMm: e.paddingMm },
|
|
265
356
|
heightMm: u.reduce((f, m) => f + m, 0)
|
|
266
357
|
};
|
|
267
358
|
}
|
|
268
|
-
function
|
|
359
|
+
function dr(e, t, r) {
|
|
269
360
|
let n = e.rowHeightFloorMm, o = 0;
|
|
270
361
|
for (const a of t) {
|
|
271
362
|
let s = 0;
|
|
272
|
-
const
|
|
273
|
-
for (; o <
|
|
274
|
-
const i =
|
|
275
|
-
n = Math.max(n,
|
|
363
|
+
const c = o + (a.colSpan ?? 1);
|
|
364
|
+
for (; o < c; o++) s += e.colWidthsMm[o] ?? 0;
|
|
365
|
+
const i = _e(e, a.style), l = te(a.text ?? "", s - e.paddingMm * 2, i.measureOptions, r);
|
|
366
|
+
n = Math.max(n, l.length * i.lineMm + e.paddingMm * 2);
|
|
276
367
|
}
|
|
277
368
|
return n;
|
|
278
369
|
}
|
|
279
|
-
function
|
|
280
|
-
const { templatePage: n, current: o, warnings: a, nextId: s, pushCurrent:
|
|
370
|
+
function ur(e, t, r) {
|
|
371
|
+
const { templatePage: n, current: o, warnings: a, nextId: s, pushCurrent: c } = r, i = () => Q(n, o), l = Math.max(o.marginTopMm, z(n)), d = n.layout === "wide" ? z(n) : l, u = {
|
|
281
372
|
id: r.tableId,
|
|
282
|
-
columnKeys: e.columns.map((
|
|
373
|
+
columnKeys: e.columns.map((h) => h.field),
|
|
283
374
|
...e.layout === void 0 ? {} : { layout: e.layout },
|
|
284
375
|
...e.title === void 0 ? {} : { title: e.title }
|
|
285
376
|
}, f = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), w = {
|
|
@@ -293,53 +384,53 @@ function qt(e, t, r) {
|
|
|
293
384
|
table: { ...u, role: "header", rowIndex: -1 },
|
|
294
385
|
style: t.borderStyle,
|
|
295
386
|
...e.meta ? { meta: e.meta } : {}
|
|
296
|
-
}, g = (
|
|
297
|
-
if (r.flow && e.header !== !1 && t.headerHeightMm > i() -
|
|
298
|
-
let
|
|
299
|
-
e.header !== !1 && (g(
|
|
387
|
+
}, g = (h) => o.components.push({ ...w, topMm: h });
|
|
388
|
+
if (r.flow && e.header !== !1 && t.headerHeightMm > i() - l + 1e-3) throw new Error(`流式列表 ${e.id ?? e.dataset} 的表头高度超出单页可用范围`);
|
|
389
|
+
let p = Math.max(r.startTop ?? e.topMm, l);
|
|
390
|
+
e.header !== !1 && (g(p), p += t.headerHeightMm + r.mmPerRow);
|
|
300
391
|
function v() {
|
|
301
|
-
const
|
|
302
|
-
return (e.header !== !1 && e.headerEveryPage !== !1 ?
|
|
392
|
+
const h = Math.max(r.flow || n.layout === "wide" ? 0 : e.topMm, d);
|
|
393
|
+
return (e.header !== !1 && e.headerEveryPage !== !1 ? h + t.headerHeightMm : d) + [...m.values()].reduce((x, I) => x + I.heightMm, 0);
|
|
303
394
|
}
|
|
304
395
|
function M() {
|
|
305
|
-
const
|
|
306
|
-
return Math.min(n.heightMm -
|
|
396
|
+
const h = n.layout === "wide" ? 0 : o.marginBottomMm;
|
|
397
|
+
return Math.min(n.heightMm - h, Q(n, o)) - v();
|
|
307
398
|
}
|
|
308
|
-
function y(
|
|
309
|
-
if (
|
|
310
|
-
|
|
399
|
+
function y(h) {
|
|
400
|
+
if (p + h <= i()) return;
|
|
401
|
+
c(), o.components = [], o.heightMm = n.heightMm, n.layout === "wide" && (o.marginTopMm = 0, o.marginBottomMm = 0);
|
|
311
402
|
const $ = Math.max(r.flow || n.layout === "wide" ? 0 : e.topMm, d);
|
|
312
|
-
e.header !== !1 && e.headerEveryPage !== !1 ? (g($),
|
|
313
|
-
for (const x of m.values())
|
|
403
|
+
e.header !== !1 && e.headerEveryPage !== !1 ? (g($), p = $ + t.headerHeightMm) : p = d;
|
|
404
|
+
for (const x of m.values()) O(x, "listgr", "group-header");
|
|
314
405
|
}
|
|
315
|
-
function
|
|
406
|
+
function N(h, $, x, I) {
|
|
316
407
|
const P = M();
|
|
317
|
-
if (r.flow &&
|
|
318
|
-
|
|
408
|
+
if (r.flow && h.heightMm > P + 1e-3) throw new Error(`流式列表 ${e.id ?? e.dataset} 的单行高度超出单页可用范围`);
|
|
409
|
+
h.heightMm > P && a.push(`列表 ${e.id ?? e.dataset} 行高 ${h.heightMm.toFixed(2)}mm 超出单页可用高度 ${P.toFixed(2)}mm,预览与打印可能截断内容`), y(h.heightMm), O(h, $, x, I);
|
|
319
410
|
}
|
|
320
|
-
function
|
|
321
|
-
const P =
|
|
322
|
-
x !== "header" && f.set(P,
|
|
411
|
+
function O(h, $, x, I) {
|
|
412
|
+
const P = h.table?.id ?? u.id, K = x === "header" ? -1 : f.get(P) ?? 0;
|
|
413
|
+
x !== "header" && f.set(P, K + h.grid.cells.length), o.components.push({
|
|
323
414
|
kind: "rect",
|
|
324
415
|
leftMm: e.leftMm,
|
|
325
|
-
topMm:
|
|
416
|
+
topMm: p,
|
|
326
417
|
widthMm: e.widthMm,
|
|
327
|
-
heightMm:
|
|
328
|
-
grid:
|
|
418
|
+
heightMm: h.heightMm,
|
|
419
|
+
grid: h.grid,
|
|
329
420
|
nid: s($),
|
|
330
|
-
table: { ...u, ...
|
|
421
|
+
table: { ...u, ...h.table, role: x, rowIndex: K, ...I ? { source: I } : {} },
|
|
331
422
|
style: t.borderStyle,
|
|
332
423
|
...e.meta ? { meta: e.meta } : {}
|
|
333
|
-
}),
|
|
424
|
+
}), p += h.heightMm;
|
|
334
425
|
}
|
|
335
|
-
function
|
|
336
|
-
|
|
426
|
+
function k(h) {
|
|
427
|
+
h <= M() && y(h);
|
|
337
428
|
}
|
|
338
|
-
return { keepTogether:
|
|
339
|
-
$ ? m.set(
|
|
340
|
-
}, bottom: () =>
|
|
429
|
+
return { keepTogether: k, placeGridRow: N, setGroupHeader: (h, $) => {
|
|
430
|
+
$ ? m.set(h, $) : m.delete(h);
|
|
431
|
+
}, bottom: () => p };
|
|
341
432
|
}
|
|
342
|
-
function
|
|
433
|
+
function fr(e, t) {
|
|
343
434
|
if (!e.rowKey) return;
|
|
344
435
|
const r = t[e.rowKey];
|
|
345
436
|
if ((typeof r != "string" || !r.trim()) && !(typeof r == "number" && Number.isFinite(r)))
|
|
@@ -349,26 +440,26 @@ function Jt(e, t) {
|
|
|
349
440
|
if (o !== void 0 && typeof o != "string") throw new Error("来源令牌应为字符串");
|
|
350
441
|
return { datasetId: e.dataset, rowKey: r, ...n === void 0 ? {} : { revision: n }, ...o === void 0 ? {} : { sourceToken: o } };
|
|
351
442
|
}
|
|
352
|
-
function
|
|
443
|
+
function ne(e, t) {
|
|
353
444
|
const r = /* @__PURE__ */ new Map();
|
|
354
445
|
if (!e.rowKey) return r;
|
|
355
446
|
const n = /* @__PURE__ */ new Set();
|
|
356
447
|
for (const o of t) {
|
|
357
|
-
const a =
|
|
448
|
+
const a = fr(e, o), s = JSON.stringify(a.rowKey);
|
|
358
449
|
if (n.has(s)) throw new Error(`数据集 ${e.dataset} 的业务主键重复:${String(a.rowKey)}`);
|
|
359
450
|
n.add(s), r.set(o, a);
|
|
360
451
|
}
|
|
361
452
|
return r;
|
|
362
453
|
}
|
|
363
|
-
function
|
|
454
|
+
function mr(e, t, r, n, o) {
|
|
364
455
|
if (!e.grandTotal) return;
|
|
365
|
-
const a = typeof e.grandTotal == "object" ? e.grandTotal : void 0, s =
|
|
366
|
-
if (
|
|
456
|
+
const a = typeof e.grandTotal == "object" ? e.grandTotal : void 0, s = oe(e)[0], c = a?.fields ?? s?.subtotal ?? [], i = a?.aggregates ?? s?.aggregates ?? [];
|
|
457
|
+
if (c.length === 0 && i.length === 0) {
|
|
367
458
|
n.warnings.push(`列表 ${e.id ?? ""} 配置了 grandTotal 但未提供合计字段(groupBy.subtotal 或 grandTotal.fields)`);
|
|
368
459
|
return;
|
|
369
460
|
}
|
|
370
|
-
const
|
|
371
|
-
o.placeGridRow(
|
|
461
|
+
const l = G(r, n.measurer, a?.label ?? "合计", Xe(e.columns, t, c, i), a?.style ?? {}, Qe(e.columns, [...c, ...i.map((d) => d.field)]));
|
|
462
|
+
o.placeGridRow(l, "listgt", "grand-total");
|
|
372
463
|
}
|
|
373
464
|
function q(e) {
|
|
374
465
|
if (e?.aborted) {
|
|
@@ -376,147 +467,147 @@ function q(e) {
|
|
|
376
467
|
throw t.name = "AbortError", t;
|
|
377
468
|
}
|
|
378
469
|
}
|
|
379
|
-
function
|
|
470
|
+
function oe(e) {
|
|
380
471
|
const t = e.groups ?? (e.groupBy ? [e.groupBy] : []);
|
|
381
472
|
if (t.length > 16) throw new Error("列表最多支持 16 级分组");
|
|
382
473
|
return t;
|
|
383
474
|
}
|
|
384
|
-
function
|
|
385
|
-
const t =
|
|
475
|
+
function ve(e) {
|
|
476
|
+
const t = qt(e), r = t.columns.reduce((o, a) => o + a.widthMm, 0), n = r > t.widthMm ? t.widthMm / r : 1;
|
|
386
477
|
return n === 1 ? t : { ...t, columns: t.columns.map((o) => ({ ...o, widthMm: o.widthMm * n })) };
|
|
387
478
|
}
|
|
388
|
-
function
|
|
479
|
+
function gr(e, t, r) {
|
|
389
480
|
const n = e.detail;
|
|
390
481
|
if (!n) return;
|
|
391
482
|
const o = /* @__PURE__ */ new Set();
|
|
392
|
-
for (const
|
|
393
|
-
const d =
|
|
483
|
+
for (const l of t) {
|
|
484
|
+
const d = ue(l[n.parentKey]);
|
|
394
485
|
if (o.has(d)) throw new Error("主从明细的主表关联键重复");
|
|
395
486
|
o.add(d);
|
|
396
487
|
}
|
|
397
|
-
const a = r.datasets[n.dataset] ?? [], s = /* @__PURE__ */ new Map(),
|
|
398
|
-
for (const
|
|
399
|
-
const d =
|
|
400
|
-
if (!
|
|
401
|
-
const u =
|
|
488
|
+
const a = r.datasets[n.dataset] ?? [], s = /* @__PURE__ */ new Map(), c = [];
|
|
489
|
+
for (const l of a) {
|
|
490
|
+
const d = l[n.foreignKey];
|
|
491
|
+
if (!Ze(d) && n.unmatched === "ignore") continue;
|
|
492
|
+
const u = ue(d);
|
|
402
493
|
if (!o.has(u)) {
|
|
403
494
|
if (n.unmatched !== "ignore") throw new Error(`明细数据集 ${n.dataset} 存在未关联的业务键`);
|
|
404
495
|
continue;
|
|
405
496
|
}
|
|
406
497
|
const f = s.get(u);
|
|
407
|
-
f ? f.push(
|
|
498
|
+
f ? f.push(l) : s.set(u, [l]), c.push(l);
|
|
408
499
|
}
|
|
409
|
-
const i =
|
|
410
|
-
return { list: i, inter: { ...
|
|
500
|
+
const i = ve({ ...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 });
|
|
501
|
+
return { list: i, inter: { ...be(i, r.measurer), rowHeightFloorMm: i.rowHeightMm ?? 0 }, rows: s, sources: ne(i, c) };
|
|
411
502
|
}
|
|
412
|
-
function
|
|
503
|
+
function Ze(e) {
|
|
413
504
|
return typeof e == "string" && !!e.trim() || typeof e == "number" && Number.isFinite(e);
|
|
414
505
|
}
|
|
415
|
-
function
|
|
416
|
-
if (!
|
|
417
|
-
return
|
|
506
|
+
function ue(e) {
|
|
507
|
+
if (!Ze(e)) throw new Error("主从关联键必须是非空字符串或有限数字");
|
|
508
|
+
return Ue(e);
|
|
418
509
|
}
|
|
419
|
-
function*
|
|
510
|
+
function* pr(e, t, r, n, o) {
|
|
420
511
|
if (!r) return;
|
|
421
|
-
const a = r.rows.get(
|
|
512
|
+
const a = r.rows.get(ue(t[e.detail.parentKey])) ?? [];
|
|
422
513
|
if (!a.length) return;
|
|
423
|
-
const s = { id: `${n.tableId}:detail`, columnKeys: r.list.columns.map((
|
|
514
|
+
const s = { id: `${n.tableId}:detail`, columnKeys: r.list.columns.map((c) => c.field), title: e.detail.label };
|
|
424
515
|
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();
|
|
425
|
-
for (const
|
|
426
|
-
q(n.signal), o.placeGridRow({ ...
|
|
516
|
+
for (const c of a)
|
|
517
|
+
q(n.signal), o.placeGridRow({ ...J(r.inter, c, n.measurer), table: s }, "listdr", "body", r.sources.get(c)), yield* n.takePages();
|
|
427
518
|
}
|
|
428
|
-
function
|
|
519
|
+
function hr(e, t) {
|
|
429
520
|
if (!e.matrix) return { list: e, rows: t };
|
|
430
521
|
if (e.detail || e.groupBy || e.groups?.length || e.grandTotal) throw new Error("矩阵不能同时配置普通分组、总计或主从明细");
|
|
431
|
-
const r =
|
|
522
|
+
const r = Wt(t, e.matrix), n = r.columns.map((a, s) => ({ ...a, widthMm: s === 0 ? e.matrix.rowWidthMm ?? 40 : e.matrix.columnWidthMm ?? 28, editable: !1, align: s === 0 ? "center" : "right" })), o = { ...e, columns: n, headerGrid: void 0, rowKey: void 0, revisionField: void 0, sourceTokenField: void 0 };
|
|
432
523
|
return e.layout === "wide" && (o.widthMm = n.reduce((a, s) => a + s.widthMm, 0)), { list: o, rows: r.rows };
|
|
433
524
|
}
|
|
434
|
-
function
|
|
525
|
+
function et(e) {
|
|
435
526
|
if (e.matrix || e.detail || e.groups?.length || e.groupBy || e.rowVisibleWhen) throw new Error("树形布局不能同时配置普通分组、矩阵、主从或行可见条件");
|
|
436
527
|
if (e.rowKey && e.rowKey !== e.tree.idField) throw new Error("树形布局的 rowKey 应与 idField 一致");
|
|
437
528
|
if (!e.columns.some((t) => t.field === e.tree.labelField && !t.hidden)) throw new Error("树形布局需要可见的标签列");
|
|
438
|
-
|
|
529
|
+
Dt(e.tree, e.computed);
|
|
439
530
|
}
|
|
440
|
-
function
|
|
441
|
-
|
|
442
|
-
const n =
|
|
531
|
+
function wr(e, t, r) {
|
|
532
|
+
et(e);
|
|
533
|
+
const n = Vt(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 = ne(o, n.entries.map((i) => i.original)), s = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new WeakMap();
|
|
443
534
|
for (const i of n.entries)
|
|
444
|
-
s.set(i.row, a.get(i.original)),
|
|
445
|
-
return { list: o, rows: n.rows, sources: s, treeRows:
|
|
535
|
+
s.set(i.row, a.get(i.original)), c.set(i.row, i);
|
|
536
|
+
return { list: o, rows: n.rows, sources: s, treeRows: c, totalRows: n.leaves };
|
|
446
537
|
}
|
|
447
|
-
function
|
|
538
|
+
function yr(e, t) {
|
|
448
539
|
if (e.cardinality === "record") {
|
|
449
540
|
if (t.length > 1) throw new Error(`单记录区域 ${e.id ?? e.dataset} 仅允许 0 或 1 行数据`);
|
|
450
541
|
if (e.tree || e.matrix || e.detail || e.groups?.length || e.groupBy || e.grandTotal || e.rowVisibleWhen) throw new Error("单记录区域不能配置树、矩阵、主从、分组、总计或行过滤");
|
|
451
542
|
if (!t.length) return { list: { ...e, columns: e.columns.map((r) => ({ ...r, editable: !1 })) }, rows: [{}], sources: /* @__PURE__ */ new Map() };
|
|
452
543
|
}
|
|
453
544
|
}
|
|
454
|
-
function
|
|
545
|
+
function tt(e, t, r) {
|
|
455
546
|
const n = r.prepared.get(e);
|
|
456
547
|
if (n) return n;
|
|
457
|
-
const o =
|
|
548
|
+
const o = yr(e, t);
|
|
458
549
|
if (o)
|
|
459
550
|
return r.prepared.set(e, o), o;
|
|
460
551
|
if (e.tree) {
|
|
461
|
-
const i =
|
|
552
|
+
const i = wr(e, t, r);
|
|
462
553
|
return r.prepared.set(e, i), i;
|
|
463
554
|
}
|
|
464
|
-
let a = e.computed?.length ?
|
|
465
|
-
const s = a === t ? void 0 : new Map(a.map((i,
|
|
466
|
-
e.rowVisibleWhen && (a = a.filter((i) =>
|
|
467
|
-
const
|
|
555
|
+
let a = e.computed?.length ? Ve(t, { fields: e.computed, signal: r.signal, formula: r.formula }).rows : t;
|
|
556
|
+
const s = a === t ? void 0 : new Map(a.map((i, l) => [i, t[l]]));
|
|
557
|
+
e.rowVisibleWhen && (a = a.filter((i) => D(i, e.rowVisibleWhen)));
|
|
558
|
+
const c = hr(e, a);
|
|
468
559
|
if (!e.matrix) {
|
|
469
|
-
const i =
|
|
470
|
-
|
|
560
|
+
const i = ne(e, s ? a.map((l) => s.get(l)) : a);
|
|
561
|
+
c.sources = s ? new Map(a.map((l) => [l, i.get(s.get(l))])) : i;
|
|
471
562
|
}
|
|
472
|
-
return r.prepared.set(e,
|
|
563
|
+
return r.prepared.set(e, c), c;
|
|
473
564
|
}
|
|
474
|
-
function
|
|
565
|
+
function br(e, t, r, n) {
|
|
475
566
|
if (!n.flow) return;
|
|
476
|
-
const { current: o, templatePage: a } = n, s = Math.max(o.marginTopMm,
|
|
477
|
-
|
|
567
|
+
const { current: o, templatePage: a } = n, s = Math.max(o.marginTopMm, z(a)), c = Math.max(n.startTop ?? e.topMm, s), i = (e.header === !1 ? 0 : t.headerHeightMm) + (r[0] ? J(t, r[0], n.measurer).heightMm : 0);
|
|
568
|
+
c + i <= Q(a, o) + 1e-3 || c <= 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, z(a)));
|
|
478
569
|
}
|
|
479
|
-
function*
|
|
480
|
-
const n =
|
|
570
|
+
function* vr(e, t, r) {
|
|
571
|
+
const n = tt(e, t, r), o = n.rows;
|
|
481
572
|
e = n.list, e.layout === "wide" && (r.current.widthMm = Math.max(r.current.widthMm, e.leftMm + e.widthMm + r.current.marginRightMm));
|
|
482
|
-
const a = n.sources ??
|
|
483
|
-
|
|
484
|
-
const
|
|
573
|
+
const a = n.sources ?? ne(e, o), s = ve(e), c = oe(s), i = { ...be(s, r.measurer), rowHeightFloorMm: s.rowHeightMm ?? 0, ...n.treeRows ? { tree: { list: s, rows: n.treeRows } } : {} };
|
|
574
|
+
br(s, i, o, r);
|
|
575
|
+
const l = ur(s, i, r), d = gr(s, o, r);
|
|
485
576
|
let u;
|
|
486
|
-
for (const f of
|
|
577
|
+
for (const f of Ye(o, c)) {
|
|
487
578
|
if (q(r.signal), f.kind === "row")
|
|
488
|
-
|
|
579
|
+
l.placeGridRow(u ?? J(i, f.row, r.measurer), "listr", "body", a.get(f.row)), u = void 0, yield* r.takePages(), yield* pr(s, f.row, d, r, l);
|
|
489
580
|
else if (f.kind === "groupHeader") {
|
|
490
581
|
const m = G(i, r.measurer, f.label, /* @__PURE__ */ new Map(), f.group.headerStyle ?? {}, s.columns.length);
|
|
491
|
-
u ??=
|
|
492
|
-
const w =
|
|
493
|
-
f.group.keepWithNext !== !1 &&
|
|
582
|
+
u ??= J(i, f.firstRow, r.measurer);
|
|
583
|
+
const w = c.slice(f.depth + 1).reduce((g, p) => g + G(i, r.measurer, (p.headerTemplate ?? "{value}").replace(/\{value\}/g, he(f.firstRow[p.field])), /* @__PURE__ */ new Map(), p.headerStyle ?? {}, s.columns.length).heightMm, 0);
|
|
584
|
+
f.group.keepWithNext !== !1 && l.keepTogether(m.heightMm + w + u.heightMm), l.placeGridRow(m, "listg", "group-header"), f.group.repeatHeader && l.setGroupHeader(f.depth, m);
|
|
494
585
|
} else if (f.kind === "subtotal") {
|
|
495
|
-
const m = f.group.subtotal ?? [], w = f.group.aggregates ?? [], g = G(i, r.measurer, f.label,
|
|
496
|
-
|
|
497
|
-
} else
|
|
586
|
+
const m = f.group.subtotal ?? [], w = f.group.aggregates ?? [], g = G(i, r.measurer, f.label, Xe(s.columns, f.rows, m, w), f.group.subtotalStyle ?? {}, Qe(s.columns, [...m, ...w.map((p) => p.field)]));
|
|
587
|
+
l.placeGridRow(g, "listst", "subtotal");
|
|
588
|
+
} else l.setGroupHeader(f.depth);
|
|
498
589
|
yield* r.takePages();
|
|
499
590
|
}
|
|
500
|
-
|
|
591
|
+
mr(s, n.totalRows ?? o, i, r, l), r.finished?.(l.bottom()), yield* r.takePages();
|
|
501
592
|
}
|
|
502
|
-
function
|
|
593
|
+
function ae(e) {
|
|
503
594
|
return e.kind !== "list" && (e.pageAnchor !== void 0 || e.kind === "text" && typeof e.text == "string" && (e.text.includes("{page}") || e.text.includes("{totalPages}")));
|
|
504
595
|
}
|
|
505
|
-
function
|
|
596
|
+
function se(e, t) {
|
|
506
597
|
return {
|
|
507
598
|
...e,
|
|
508
599
|
...e.text === void 0 ? {} : { text: t(e.text) },
|
|
509
600
|
...e.lines ? { lines: e.lines.map(t) } : {},
|
|
510
601
|
...e.richParagraphs ? { richParagraphs: e.richParagraphs.map((r) => ({ ...r, segments: r.segments.map((n) => ({ ...n, ...n.text === void 0 ? {} : { text: t(n.text) } })) })) } : {},
|
|
511
|
-
...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) =>
|
|
602
|
+
...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) => se(o, t)) } : {} } : null)) } } : {}
|
|
512
603
|
};
|
|
513
604
|
}
|
|
514
|
-
function
|
|
605
|
+
function Mr(e) {
|
|
515
606
|
let t = !1;
|
|
516
|
-
for (const r of e.pages) for (const n of r.components)
|
|
607
|
+
for (const r of e.pages) for (const n of r.components) ae(n) && se(n, (o) => (o.includes("{totalPages}") && (t = !0), o));
|
|
517
608
|
return t;
|
|
518
609
|
}
|
|
519
|
-
function
|
|
610
|
+
function $r(e, t, r, n, o, a) {
|
|
520
611
|
const s = {
|
|
521
612
|
pageWidthMm: t.widthMm,
|
|
522
613
|
pageHeightMm: t.heightMm,
|
|
@@ -527,40 +618,40 @@ function nr(e, t, r, n, o, a) {
|
|
|
527
618
|
marginRightMm: t.marginRightMm,
|
|
528
619
|
components: t.components,
|
|
529
620
|
...e.meta ? { meta: e.meta } : {}
|
|
530
|
-
},
|
|
531
|
-
const
|
|
532
|
-
return a === void 0 ?
|
|
621
|
+
}, c = (i) => {
|
|
622
|
+
const l = i.replace(/\{page\}/g, String(n));
|
|
623
|
+
return a === void 0 ? l : l.replace(/\{totalPages\}/g, String(a));
|
|
533
624
|
};
|
|
534
|
-
for (const i of r) s.components.push(
|
|
625
|
+
for (const i of r) s.components.push(se(i, c));
|
|
535
626
|
if (e.layout === "wide") {
|
|
536
|
-
const i = s.components.reduce((
|
|
627
|
+
const i = s.components.reduce((l, d) => Math.max(l, d.topMm + d.heightMm), 0);
|
|
537
628
|
s.marginBottomMm = o ? e.marginBottomMm ?? 0 : 0, s.pageHeightMm = Math.max(1, i + s.marginBottomMm);
|
|
538
629
|
}
|
|
539
630
|
return s;
|
|
540
631
|
}
|
|
541
|
-
function
|
|
542
|
-
return e.cells.reduce((t, r) => t + r.reduce((n, o) => n + (o ? 1 + (o.children?.reduce((a, s) => a +
|
|
632
|
+
function Me(e) {
|
|
633
|
+
return e.cells.reduce((t, r) => t + r.reduce((n, o) => n + (o ? 1 + (o.children?.reduce((a, s) => a + rt(s), 0) ?? 0) : 0), 0), 0);
|
|
543
634
|
}
|
|
544
|
-
function
|
|
545
|
-
return e.grid ?
|
|
635
|
+
function rt(e) {
|
|
636
|
+
return e.grid ? Me(e.grid) : 0;
|
|
546
637
|
}
|
|
547
|
-
function
|
|
638
|
+
function $e(e) {
|
|
548
639
|
for (const t of ["maxPages", "maxCells", "knownTotalPages"]) if (e[t] !== void 0 && (!Number.isSafeInteger(e[t]) || e[t] < 1)) throw new RangeError(`${t} 应为正安全整数`);
|
|
549
640
|
}
|
|
550
|
-
function
|
|
551
|
-
const r =
|
|
552
|
-
return (n.header === !1 ? 0 : o.headerHeightMm) + r.rows.reduce((a, s) => a +
|
|
641
|
+
function xr(e, t) {
|
|
642
|
+
const r = tt(e, t.datasets[e.dataset] ?? [], t), n = ve(r.list), o = { ...be(n, t.measurer), rowHeightFloorMm: n.rowHeightMm ?? 0 };
|
|
643
|
+
return (n.header === !1 ? 0 : o.headerHeightMm) + r.rows.reduce((a, s) => a + J(o, s, t.measurer).heightMm, 0);
|
|
553
644
|
}
|
|
554
|
-
function*
|
|
555
|
-
const { templatePage: t, current: r } = e, n = new Map(t.components.map((a, s) => [a, s])), o = (a, s,
|
|
645
|
+
function* Sr(e) {
|
|
646
|
+
const { templatePage: t, current: r } = e, n = new Map(t.components.map((a, s) => [a, s])), o = (a, s, c) => {
|
|
556
647
|
const i = e.datasets[a.dataset];
|
|
557
|
-
return Array.isArray(i) || e.warnings.push(`数据集 ${a.dataset} 未提供数据,列表 ${a.id ?? ""} 输出为空`),
|
|
648
|
+
return Array.isArray(i) || e.warnings.push(`数据集 ${a.dataset} 未提供数据,列表 ${a.id ?? ""} 输出为空`), vr(a, Array.isArray(i) ? i : [], { ...e, tableId: `${e.tableId}:${n.get(a)}`, startTop: s, finished: c, flow: !!t.flow });
|
|
558
649
|
};
|
|
559
650
|
if (t.flow) {
|
|
560
|
-
yield*
|
|
651
|
+
yield* _t({
|
|
561
652
|
page: t,
|
|
562
653
|
active: () => q(e.signal),
|
|
563
|
-
top: () => Math.max(r.marginTopMm,
|
|
654
|
+
top: () => Math.max(r.marginTopMm, z(t)),
|
|
564
655
|
bottom: () => Q(t, r),
|
|
565
656
|
append: (a) => {
|
|
566
657
|
r.components.push(a);
|
|
@@ -569,128 +660,128 @@ function* ar(e) {
|
|
|
569
660
|
e.pushCurrent(), r.components = [], r.heightMm = t.heightMm, t.layout === "wide" && (r.marginTopMm = 0, r.marginBottomMm = 0);
|
|
570
661
|
},
|
|
571
662
|
takePages: e.takePages,
|
|
572
|
-
height: (a) =>
|
|
663
|
+
height: (a) => xr(a, e),
|
|
573
664
|
list: o
|
|
574
665
|
});
|
|
575
666
|
return;
|
|
576
667
|
}
|
|
577
668
|
for (const a of t.components)
|
|
578
|
-
|
|
669
|
+
ae(a) || (a.kind === "list" ? yield* o(a) : r.components.push(a));
|
|
579
670
|
}
|
|
580
|
-
function*
|
|
581
|
-
let s = 0,
|
|
582
|
-
const
|
|
583
|
-
for (const
|
|
671
|
+
function* Z(e, t, r, n, o, a = /* @__PURE__ */ new WeakMap()) {
|
|
672
|
+
let s = 0, c = 0, i = 0;
|
|
673
|
+
const l = (d) => `${d}_${(++s).toString(36)}`;
|
|
674
|
+
for (const { pageIndex: d, page: u } of rr(e, t, r)) {
|
|
584
675
|
q(r.signal);
|
|
585
|
-
const f =
|
|
676
|
+
const f = nr(u), m = u.components.filter(ae);
|
|
586
677
|
let w = [];
|
|
587
678
|
const g = (v = !1) => {
|
|
588
|
-
if (q(r.signal), r.maxPages !== void 0 &&
|
|
589
|
-
if (r.maxCells !== void 0 && (i += [...f.components, ...m].reduce((M, y) => M +
|
|
679
|
+
if (q(r.signal), r.maxPages !== void 0 && c >= r.maxPages) throw new H(r.maxPages, c + 1);
|
|
680
|
+
if (r.maxCells !== void 0 && (i += [...f.components, ...m].reduce((M, y) => M + rt(y), 0), i > r.maxCells))
|
|
590
681
|
throw new V(r.maxCells, i);
|
|
591
|
-
w.push(
|
|
592
|
-
},
|
|
682
|
+
w.push($r(u, f, m, ++c, v, o));
|
|
683
|
+
}, p = () => {
|
|
593
684
|
const v = w;
|
|
594
685
|
return w = [], v;
|
|
595
686
|
};
|
|
596
|
-
yield*
|
|
687
|
+
yield* Sr({
|
|
597
688
|
templatePage: u,
|
|
598
689
|
current: f,
|
|
599
690
|
warnings: n,
|
|
600
|
-
nextId:
|
|
691
|
+
nextId: l,
|
|
601
692
|
pushCurrent: g,
|
|
602
|
-
takePages:
|
|
693
|
+
takePages: p,
|
|
603
694
|
datasets: t,
|
|
604
695
|
signal: r.signal,
|
|
605
696
|
formula: r.formula,
|
|
606
697
|
prepared: a,
|
|
607
|
-
measurer: r.measurer ??
|
|
698
|
+
measurer: r.measurer ?? Le,
|
|
608
699
|
mmPerRow: r.mmPerRow ?? 0,
|
|
609
700
|
tableId: `table:${d}`
|
|
610
|
-
}), g(!0), yield*
|
|
701
|
+
}), g(!0), yield* p();
|
|
611
702
|
}
|
|
612
703
|
}
|
|
613
|
-
function
|
|
614
|
-
|
|
704
|
+
function Fn(e, t, r = {}) {
|
|
705
|
+
$e(r);
|
|
615
706
|
let n = 0;
|
|
616
|
-
for (const o of
|
|
707
|
+
for (const o of Z(e, t, { ...r, onWarning: void 0 }, [])) n++;
|
|
617
708
|
return n;
|
|
618
709
|
}
|
|
619
|
-
function*
|
|
620
|
-
|
|
621
|
-
const n =
|
|
710
|
+
function* Tr(e, t, r = {}) {
|
|
711
|
+
$e(r);
|
|
712
|
+
const n = Mr(e), o = /* @__PURE__ */ new WeakMap();
|
|
622
713
|
let a = r.knownTotalPages;
|
|
623
714
|
if (n && a === void 0) {
|
|
624
715
|
a = 0;
|
|
625
|
-
for (const i of
|
|
716
|
+
for (const i of Z(e, t, r, [], void 0, o)) a++;
|
|
626
717
|
}
|
|
627
718
|
const s = [];
|
|
628
|
-
let
|
|
629
|
-
for (const i of
|
|
630
|
-
for (;
|
|
719
|
+
let c = 0;
|
|
720
|
+
for (const i of Z(e, t, r, s, a, o)) {
|
|
721
|
+
for (; c < s.length; c++) r.onWarning?.(s[c]);
|
|
631
722
|
yield i;
|
|
632
723
|
}
|
|
633
724
|
}
|
|
634
|
-
function
|
|
725
|
+
function xe(e, t, r = {}) {
|
|
635
726
|
const n = typeof r == "number" ? { mmPerRow: r } : r;
|
|
636
|
-
|
|
637
|
-
const o = [], a = [...
|
|
638
|
-
for (const s of a) s.components = s.components.map((
|
|
639
|
-
return o.forEach((s) => n.onWarning?.(s)), { plan: { schemaVersion:
|
|
727
|
+
$e(n);
|
|
728
|
+
const o = [], a = [...Z(e, t, n, o, n.knownTotalPages)];
|
|
729
|
+
for (const s of a) s.components = s.components.map((c) => ae(c) ? se(c, (i) => i.replace(/\{totalPages\}/g, String(a.length))) : c);
|
|
730
|
+
return o.forEach((s) => n.onWarning?.(s)), { plan: { schemaVersion: ee, ...re(e) ? { requiresRecalculation: !0 } : {}, pages: a }, warnings: o };
|
|
640
731
|
}
|
|
641
|
-
function
|
|
732
|
+
function Ir(e) {
|
|
642
733
|
const t = e.columns.find((a) => !a.hidden)?.field;
|
|
643
734
|
if (!t) return { groups: 0, total: 0 };
|
|
644
|
-
const r =
|
|
735
|
+
const r = oe(e), n = (a = [], s = []) => a.includes(t) || s.some((c) => c.field === t), o = typeof e.grandTotal == "object" ? e.grandTotal : void 0;
|
|
645
736
|
return { groups: r.filter((a) => n(a.subtotal, a.aggregates)).length, total: Number(n(o?.fields ?? r[0]?.subtotal, o?.aggregates ?? r[0]?.aggregates)) };
|
|
646
737
|
}
|
|
647
|
-
function
|
|
648
|
-
|
|
649
|
-
const n =
|
|
738
|
+
function Pr(e, t, r) {
|
|
739
|
+
et(e);
|
|
740
|
+
const n = Ge(t[e.dataset] ?? [], e.tree, r), o = e.columns.filter((s) => !s.hidden).length, a = e.header === !1 ? 0 : e.headerGrid ? Me(e.headerGrid) : o;
|
|
650
741
|
return n.length * o + a + +!!e.grandTotal * 2 * o;
|
|
651
742
|
}
|
|
652
|
-
function
|
|
653
|
-
if (e.tree) return
|
|
743
|
+
function An(e, t, r = {}) {
|
|
744
|
+
if (e.tree) return Pr(e, t, r.signal);
|
|
654
745
|
if (e.matrix) {
|
|
655
746
|
let i = t[e.dataset] ?? [];
|
|
656
|
-
e.computed?.length && (i =
|
|
657
|
-
const
|
|
658
|
-
return
|
|
747
|
+
e.computed?.length && (i = Ve(i, { fields: e.computed, ...r }).rows), e.rowVisibleWhen && (i = i.filter((d) => D(d, e.rowVisibleWhen)));
|
|
748
|
+
const l = Bt(i, e.matrix);
|
|
749
|
+
return l.cells + l.columnCount;
|
|
659
750
|
}
|
|
660
|
-
const n = t[e.dataset]?.length ?? 0, o = e.columns.filter((i) => !i.hidden).length, a =
|
|
661
|
-
let
|
|
662
|
-
if (
|
|
663
|
-
const i = t[e.detail.dataset]?.length ?? 0,
|
|
664
|
-
|
|
751
|
+
const n = t[e.dataset]?.length ?? 0, o = e.columns.filter((i) => !i.hidden).length, a = oe(e).length, s = Ir(e);
|
|
752
|
+
let c = (n * (1 + 2 * a + s.groups) + +!!e.grandTotal * (1 + s.total)) * o;
|
|
753
|
+
if (c += e.header === !1 ? 0 : e.headerGrid ? Me(e.headerGrid) : o, e.cardinality === "record" && n === 0 && (c += o), e.detail) {
|
|
754
|
+
const i = t[e.detail.dataset]?.length ?? 0, l = e.detail.columns.filter((d) => !d.hidden).length;
|
|
755
|
+
c += (i + n * (+(e.detail.header !== !1) + +!!e.detail.label)) * l;
|
|
665
756
|
}
|
|
666
|
-
if (!Number.isSafeInteger(
|
|
667
|
-
return
|
|
757
|
+
if (!Number.isSafeInteger(c)) throw new RangeError("报表单元格估算超出安全整数预算");
|
|
758
|
+
return c;
|
|
668
759
|
}
|
|
669
|
-
function
|
|
760
|
+
function nt(e) {
|
|
670
761
|
return !e || typeof e != "object" ? !1 : [e.pageIndex, e.componentIndex, e.rowIndex, e.columnIndex].every((t) => Number.isInteger(t) && t >= 0);
|
|
671
762
|
}
|
|
672
|
-
function
|
|
763
|
+
function ot(e, t, r) {
|
|
673
764
|
const n = e.grid;
|
|
674
765
|
if (!n) return null;
|
|
675
766
|
const o = n.cells[t];
|
|
676
767
|
if (!o) return null;
|
|
677
|
-
const s =
|
|
678
|
-
return
|
|
768
|
+
const s = pe(n, e.widthMm, e.heightMm).cells.filter((i) => i.ri === t).findIndex((i) => i.ci === r), c = o[s];
|
|
769
|
+
return c ? { cell: c, sourceColumnIndex: s } : null;
|
|
679
770
|
}
|
|
680
|
-
function
|
|
771
|
+
function kr(e) {
|
|
681
772
|
return e.value !== void 0 ? e.value : e.rawText ?? e.text ?? null;
|
|
682
773
|
}
|
|
683
|
-
function
|
|
774
|
+
function Rr(e, t) {
|
|
684
775
|
return e.valueType ? e.valueType : typeof t == "number" ? "number" : typeof t == "boolean" ? "boolean" : t === null && e.numberFormat && /[0#?]/.test(e.numberFormat) ? "number" : "text";
|
|
685
776
|
}
|
|
686
|
-
function
|
|
777
|
+
function Er(e, t) {
|
|
687
778
|
if (e.derived) return "derived";
|
|
688
779
|
if (e.editable === !1) return "cell";
|
|
689
780
|
if (e.formula !== void 0) return "formula";
|
|
690
781
|
if (e.children?.length) return "complex";
|
|
691
782
|
if (t.table && t.table.role !== "body" && e.editable !== !0) return "structure";
|
|
692
783
|
}
|
|
693
|
-
function
|
|
784
|
+
function Cr(e, t) {
|
|
694
785
|
const r = e.table;
|
|
695
786
|
if (r)
|
|
696
787
|
return {
|
|
@@ -700,54 +791,54 @@ function fr(e, t) {
|
|
|
700
791
|
columnKey: r.columnKeys[t.columnIndex]
|
|
701
792
|
};
|
|
702
793
|
}
|
|
703
|
-
function
|
|
794
|
+
function Fr(e, t, r) {
|
|
704
795
|
if (e.derived) return;
|
|
705
796
|
if (e.source) return { ...e.source };
|
|
706
797
|
const n = t.table?.source, o = t.table?.columnKeys[r.columnIndex];
|
|
707
798
|
if (!(!n || n.rowKey === void 0 || o === void 0))
|
|
708
799
|
return { ...n, rowKey: n.rowKey, field: o };
|
|
709
800
|
}
|
|
710
|
-
function
|
|
711
|
-
const n =
|
|
801
|
+
function at(e, t, r) {
|
|
802
|
+
const n = kr(r), o = Er(r, e);
|
|
712
803
|
return {
|
|
713
804
|
address: { ...t },
|
|
714
805
|
cell: r,
|
|
715
806
|
component: e,
|
|
716
807
|
value: n,
|
|
717
|
-
valueType:
|
|
718
|
-
table:
|
|
719
|
-
source:
|
|
808
|
+
valueType: Rr(r, n),
|
|
809
|
+
table: Cr(e, t),
|
|
810
|
+
source: Fr(r, e, t),
|
|
720
811
|
editable: o === void 0,
|
|
721
812
|
readOnlyReason: o
|
|
722
813
|
};
|
|
723
814
|
}
|
|
724
|
-
function
|
|
725
|
-
if (!
|
|
815
|
+
function Se(e, t) {
|
|
816
|
+
if (!nt(t)) return null;
|
|
726
817
|
const r = e.pages[t.pageIndex]?.components[t.componentIndex];
|
|
727
818
|
if (!r) return null;
|
|
728
|
-
const n =
|
|
729
|
-
return n ?
|
|
819
|
+
const n = ot(r, t.rowIndex, t.columnIndex);
|
|
820
|
+
return n ? at(r, t, n.cell) : null;
|
|
730
821
|
}
|
|
731
|
-
function
|
|
822
|
+
function W(e) {
|
|
732
823
|
const t = /* @__PURE__ */ new Map();
|
|
733
824
|
return (r) => {
|
|
734
|
-
if (!
|
|
825
|
+
if (!nt(r)) return null;
|
|
735
826
|
const n = e.pages[r.pageIndex]?.components[r.componentIndex];
|
|
736
827
|
if (!n?.grid) return null;
|
|
737
828
|
let o = t.get(n);
|
|
738
829
|
if (!o) {
|
|
739
830
|
const s = /* @__PURE__ */ new Map();
|
|
740
831
|
o = /* @__PURE__ */ new Map();
|
|
741
|
-
for (const
|
|
742
|
-
const i = s.get(
|
|
743
|
-
s.set(
|
|
744
|
-
const
|
|
745
|
-
|
|
832
|
+
for (const c of pe(n.grid, n.widthMm, n.heightMm).cells) {
|
|
833
|
+
const i = s.get(c.ri) ?? 0;
|
|
834
|
+
s.set(c.ri, i + 1);
|
|
835
|
+
const l = n.grid.cells[c.ri]?.[i];
|
|
836
|
+
l && o.set(`${c.ri}:${c.ci}`, l);
|
|
746
837
|
}
|
|
747
838
|
t.set(n, o);
|
|
748
839
|
}
|
|
749
840
|
const a = o.get(`${r.rowIndex}:${r.columnIndex}`);
|
|
750
|
-
return a ?
|
|
841
|
+
return a ? at(n, r, a) : null;
|
|
751
842
|
};
|
|
752
843
|
}
|
|
753
844
|
class b extends Error {
|
|
@@ -755,20 +846,20 @@ class b extends Error {
|
|
|
755
846
|
super(`Invalid report cell edit: ${t}`), this.code = t, this.name = "ReportCellEditError";
|
|
756
847
|
}
|
|
757
848
|
}
|
|
758
|
-
function
|
|
849
|
+
function Ar(e, t) {
|
|
759
850
|
let r = e.trim();
|
|
760
851
|
const n = t && r.endsWith("%");
|
|
761
852
|
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 b("number");
|
|
762
853
|
return Number(r) / (n ? 100 : 1);
|
|
763
854
|
}
|
|
764
|
-
function
|
|
855
|
+
function Or(e, t) {
|
|
765
856
|
if (e === null || typeof e == "string" && e.trim() === "") return null;
|
|
766
857
|
if (typeof e != "string" && typeof e != "number") throw new b("number");
|
|
767
|
-
const r = typeof e == "number" ? e :
|
|
858
|
+
const r = typeof e == "number" ? e : Ar(e, Et(t.cell.numberFormat));
|
|
768
859
|
if (!Number.isFinite(r) || Number.isInteger(r) && !Number.isSafeInteger(r)) throw new b("number");
|
|
769
860
|
return r;
|
|
770
861
|
}
|
|
771
|
-
function
|
|
862
|
+
function Kr(e) {
|
|
772
863
|
if (e === null || typeof e == "string" && e.trim() === "") return null;
|
|
773
864
|
if (typeof e == "boolean") return e;
|
|
774
865
|
const t = String(e).trim().toLowerCase();
|
|
@@ -776,24 +867,24 @@ function pr(e) {
|
|
|
776
867
|
if (["false", "no", "否", "0"].includes(t)) return !1;
|
|
777
868
|
throw new b("boolean");
|
|
778
869
|
}
|
|
779
|
-
function
|
|
780
|
-
return e.valueType === "number" ?
|
|
870
|
+
function st(e, t) {
|
|
871
|
+
return e.valueType === "number" ? Or(t, e) : e.valueType === "boolean" ? Kr(t) : t === null ? null : String(t);
|
|
781
872
|
}
|
|
782
|
-
function
|
|
873
|
+
function jr(e, t) {
|
|
783
874
|
const r = t.cell.text, o = [["是", "否"], ["TRUE", "FALSE"], ["True", "False"], ["true", "false"], ["1", "0"]].find((a) => a.includes(r ?? ""));
|
|
784
875
|
return o ? o[e ? 0 : 1] : String(e);
|
|
785
876
|
}
|
|
786
|
-
function
|
|
787
|
-
return t === null ? "" : typeof t == "boolean" ?
|
|
877
|
+
function _(e, t) {
|
|
878
|
+
return t === null ? "" : typeof t == "boolean" ? jr(t, e) : typeof t == "number" ? Rt(t, e.cell.numberFormat) : String(t);
|
|
788
879
|
}
|
|
789
|
-
function
|
|
790
|
-
const n =
|
|
880
|
+
function On(e, t, r) {
|
|
881
|
+
const n = Se(e, t);
|
|
791
882
|
if (!n) throw new b("missing");
|
|
792
|
-
return
|
|
883
|
+
return U(n, r);
|
|
793
884
|
}
|
|
794
|
-
function
|
|
885
|
+
function U(e, t) {
|
|
795
886
|
if (!e.editable) throw new b("readonly");
|
|
796
|
-
const r =
|
|
887
|
+
const r = st(e, t);
|
|
797
888
|
return {
|
|
798
889
|
address: { ...e.address },
|
|
799
890
|
table: e.table,
|
|
@@ -801,58 +892,58 @@ function _(e, t) {
|
|
|
801
892
|
previousValue: e.value,
|
|
802
893
|
previousText: e.cell.text ?? "",
|
|
803
894
|
value: r,
|
|
804
|
-
text:
|
|
895
|
+
text: _(e, r)
|
|
805
896
|
};
|
|
806
897
|
}
|
|
807
|
-
function
|
|
898
|
+
function Nr(e, t) {
|
|
808
899
|
const r = e.table, n = t.table;
|
|
809
900
|
return !r || !n || r.columnKey === void 0 ? !1 : r.id === n.id && r.rowIndex === n.rowIndex && r.role === n.role && r.columnKey === n.columnKey;
|
|
810
901
|
}
|
|
811
|
-
function
|
|
812
|
-
const n = e.grid, { rowIndex: o, columnIndex: a } = t.address, s =
|
|
813
|
-
return i[s.sourceColumnIndex] = d,
|
|
902
|
+
function it(e, t, r) {
|
|
903
|
+
const n = e.grid, { rowIndex: o, columnIndex: a } = t.address, s = ot(e, o, a), c = [...n.cells], i = [...c[o]], l = _(t, r.value), d = { ...s.cell, value: r.value, text: l, rawText: l };
|
|
904
|
+
return i[s.sourceColumnIndex] = d, c[o] = i, { ...e, grid: { ...n, cells: c } };
|
|
814
905
|
}
|
|
815
|
-
function
|
|
906
|
+
function Lr(e, t) {
|
|
816
907
|
const r = e.table?.columnKeys, n = t.table?.columnKey;
|
|
817
908
|
return r && n !== void 0 ? r.flatMap((o, a) => o === n ? [a] : []) : [];
|
|
818
909
|
}
|
|
819
|
-
function
|
|
820
|
-
const s = t.table,
|
|
821
|
-
if (!s || !
|
|
822
|
-
const i =
|
|
910
|
+
function Hr(e, t, r, n, o, a) {
|
|
911
|
+
const s = t.table, c = o.table;
|
|
912
|
+
if (!s || !c || s.id !== c.id || s.role !== c.role || !t.grid) return t;
|
|
913
|
+
const i = c.rowIndex - s.rowIndex;
|
|
823
914
|
if (i < 0 || i >= t.grid.cells.length) return t;
|
|
824
|
-
let
|
|
825
|
-
for (const d of
|
|
826
|
-
const u =
|
|
827
|
-
u?.editable &&
|
|
915
|
+
let l = t;
|
|
916
|
+
for (const d of Lr(t, o)) {
|
|
917
|
+
const u = Se(e, { pageIndex: r, componentIndex: n, rowIndex: i, columnIndex: d });
|
|
918
|
+
u?.editable && Nr(o, u) && (l = it(l, u, a));
|
|
828
919
|
}
|
|
829
|
-
return
|
|
920
|
+
return l;
|
|
830
921
|
}
|
|
831
|
-
function
|
|
922
|
+
function Br(e, t, r, n, o, a) {
|
|
832
923
|
const s = o.address;
|
|
833
|
-
return o.table?.columnKey !== void 0 ?
|
|
924
|
+
return o.table?.columnKey !== void 0 ? Hr(e, t, r, n, o, a) : s.pageIndex === r && s.componentIndex === n ? it(t, o, a) : t;
|
|
834
925
|
}
|
|
835
|
-
function
|
|
926
|
+
function Te(e, t) {
|
|
836
927
|
const r = t.source;
|
|
837
928
|
if (!r) return !1;
|
|
838
929
|
const n = e.source;
|
|
839
930
|
return !n || ["datasetId", "rowKey", "field", "revision", "sourceToken"].some((o) => !Object.is(n[o], r[o]));
|
|
840
931
|
}
|
|
841
|
-
function
|
|
842
|
-
const r =
|
|
932
|
+
function Kn(e, t) {
|
|
933
|
+
const r = Se(e, t.address);
|
|
843
934
|
if (!r) throw new b("missing");
|
|
844
935
|
if (!r.editable) throw new b("readonly");
|
|
845
|
-
if (
|
|
936
|
+
if (Te(r, t)) throw new b("conflict");
|
|
846
937
|
if (!Object.is(r.value, t.previousValue) || (r.cell.text ?? "") !== t.previousText) throw new b("conflict");
|
|
847
|
-
const n =
|
|
938
|
+
const n = st(r, t.value), o = { ...t, value: n, text: _(r, n) };
|
|
848
939
|
if (Object.is(n, r.value) && o.text === r.cell.text) return e;
|
|
849
|
-
const a = e.pages.map((s,
|
|
850
|
-
const i = s.components.map((
|
|
851
|
-
return i.every((
|
|
940
|
+
const a = e.pages.map((s, c) => {
|
|
941
|
+
const i = s.components.map((l, d) => Br(e, l, c, d, r, o));
|
|
942
|
+
return i.every((l, d) => l === s.components[d]) ? s : { ...s, components: i };
|
|
852
943
|
});
|
|
853
944
|
return { ...e, pages: a };
|
|
854
945
|
}
|
|
855
|
-
function
|
|
946
|
+
function Wr(e, t, r) {
|
|
856
947
|
if (!r || r.revision === void 0 && r.sourceToken === void 0) return e;
|
|
857
948
|
const n = new Set(t.edits.flatMap((s) => s.source ? [s.source.datasetId] : []));
|
|
858
949
|
if (!n.size) return e;
|
|
@@ -860,52 +951,52 @@ function $r(e, t, r) {
|
|
|
860
951
|
return !s.datasetId || !n.has(s.datasetId) || (r.revision === void 0 || Object.is(r.revision, s.revision)) && (r.sourceToken === void 0 || r.sourceToken === s.sourceToken) ? s : { ...s, ...r.revision !== void 0 ? { revision: r.revision } : {}, ...r.sourceToken !== void 0 ? { sourceToken: r.sourceToken } : {} };
|
|
861
952
|
}
|
|
862
953
|
const a = e.pages.map((s) => {
|
|
863
|
-
const
|
|
864
|
-
const
|
|
954
|
+
const c = s.components.map((i) => {
|
|
955
|
+
const l = i.table?.source ? o(i.table.source) : void 0, d = i.table && l !== i.table.source ? { ...i.table, source: l } : i.table, u = i.grid?.cells.map((m) => {
|
|
865
956
|
const w = m.map((g) => {
|
|
866
957
|
if (!g?.source) return g;
|
|
867
|
-
const
|
|
868
|
-
return
|
|
958
|
+
const p = o(g.source);
|
|
959
|
+
return p === g.source ? g : { ...g, source: p };
|
|
869
960
|
});
|
|
870
|
-
return w.some((g,
|
|
961
|
+
return w.some((g, p) => g !== m[p]) ? w : m;
|
|
871
962
|
}), f = i.grid && u?.some((m, w) => m !== i.grid.cells[w]) ? { ...i.grid, cells: u } : i.grid;
|
|
872
963
|
return d !== i.table || f !== i.grid ? { ...i, table: d, grid: f } : i;
|
|
873
964
|
});
|
|
874
|
-
return
|
|
965
|
+
return c.some((i, l) => i !== s.components[l]) ? { ...s, components: c } : s;
|
|
875
966
|
});
|
|
876
|
-
return a.some((s,
|
|
967
|
+
return a.some((s, c) => s !== e.pages[c]) ? { ...e, pages: a } : e;
|
|
877
968
|
}
|
|
878
|
-
function
|
|
969
|
+
function Dr(e) {
|
|
879
970
|
return JSON.stringify([e.pageIndex, e.componentIndex, e.rowIndex, e.columnIndex]);
|
|
880
971
|
}
|
|
881
|
-
function
|
|
972
|
+
function Re(e) {
|
|
882
973
|
const t = e.table;
|
|
883
|
-
return t?.columnKey !== void 0 ? JSON.stringify([t.id, t.role, t.rowIndex, t.columnKey]) :
|
|
974
|
+
return t?.columnKey !== void 0 ? JSON.stringify([t.id, t.role, t.rowIndex, t.columnKey]) : Dr(e.address);
|
|
884
975
|
}
|
|
885
|
-
function
|
|
976
|
+
function Vr(e, t) {
|
|
886
977
|
if (!t.length) return e;
|
|
887
|
-
const r = new Map(t.map((i) => [
|
|
888
|
-
function s(i,
|
|
978
|
+
const r = new Map(t.map((i) => [Re(i), i])), n = new Set(t.flatMap((i) => i.table ? [i.table.id] : [])), o = new Set(t.map((i) => `${i.address.pageIndex}:${i.address.componentIndex}`)), a = W(e);
|
|
979
|
+
function s(i, l, d) {
|
|
889
980
|
const u = i.grid;
|
|
890
|
-
if (!u || !o.has(`${
|
|
981
|
+
if (!u || !o.has(`${l}:${d}`) && !n.has(i.table?.id ?? "")) return i;
|
|
891
982
|
const f = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map();
|
|
892
|
-
for (const w of
|
|
983
|
+
for (const w of pe(u, i.widthMm, i.heightMm).cells) {
|
|
893
984
|
const g = m.get(w.ri) ?? 0;
|
|
894
985
|
m.set(w.ri, g + 1);
|
|
895
|
-
const
|
|
896
|
-
if (!v || !
|
|
897
|
-
const M = f.get(w.ri) ?? [...u.cells[w.ri]], y =
|
|
898
|
-
Object.is(
|
|
986
|
+
const p = a({ pageIndex: l, componentIndex: d, rowIndex: w.ri, columnIndex: w.ci }), v = p && r.get(Re(p));
|
|
987
|
+
if (!v || !p.editable) continue;
|
|
988
|
+
const M = f.get(w.ri) ?? [...u.cells[w.ri]], y = _(p, v.value);
|
|
989
|
+
Object.is(p.value, v.value) && y === p.cell.text || (M[g] = { ...w.cell, value: v.value, text: y, rawText: y }, f.set(w.ri, M));
|
|
899
990
|
}
|
|
900
991
|
return f.size ? { ...i, grid: { ...u, cells: u.cells.map((w, g) => f.get(g) ?? w) } } : i;
|
|
901
992
|
}
|
|
902
|
-
const
|
|
903
|
-
const d = i.components.map((u, f) => s(u,
|
|
993
|
+
const c = e.pages.map((i, l) => {
|
|
994
|
+
const d = i.components.map((u, f) => s(u, l, f));
|
|
904
995
|
return d.every((u, f) => u === i.components[f]) ? i : { ...i, components: d };
|
|
905
996
|
});
|
|
906
|
-
return
|
|
997
|
+
return c.every((i, l) => i === e.pages[l]) ? e : { ...e, pages: c };
|
|
907
998
|
}
|
|
908
|
-
function
|
|
999
|
+
function A(e) {
|
|
909
1000
|
const t = e.source;
|
|
910
1001
|
if (t) return JSON.stringify([t.datasetId, t.rowKey, t.field]);
|
|
911
1002
|
const r = e.table;
|
|
@@ -913,80 +1004,80 @@ function I(e) {
|
|
|
913
1004
|
const n = e.address;
|
|
914
1005
|
return JSON.stringify([n.pageIndex, n.componentIndex, n.rowIndex, n.columnIndex]);
|
|
915
1006
|
}
|
|
916
|
-
function
|
|
1007
|
+
function jn(e, t, r) {
|
|
917
1008
|
if (typeof r != "string" || !r.trim() || !Array.isArray(t)) throw new b("missing");
|
|
918
1009
|
if (t.length > 1e4) throw new b("limit");
|
|
919
|
-
const n = /* @__PURE__ */ new Set(), o =
|
|
1010
|
+
const n = /* @__PURE__ */ new Set(), o = W(e), a = t.map(({ address: s, value: c }) => {
|
|
920
1011
|
const i = o(s);
|
|
921
1012
|
if (!i) throw new b("missing");
|
|
922
|
-
const
|
|
1013
|
+
const l = U(i, c), d = A(l);
|
|
923
1014
|
if (n.has(d)) throw new b("duplicate");
|
|
924
|
-
return n.add(d),
|
|
1015
|
+
return n.add(d), l;
|
|
925
1016
|
});
|
|
926
1017
|
return { requestId: r, edits: a };
|
|
927
1018
|
}
|
|
928
|
-
function
|
|
1019
|
+
function Nn(e, t) {
|
|
929
1020
|
if (t.edits.length > 1e4) throw new b("limit");
|
|
930
|
-
const r =
|
|
1021
|
+
const r = W(e), n = /* @__PURE__ */ new Set(), o = t.edits.map((a) => {
|
|
931
1022
|
const s = r(a.address);
|
|
932
1023
|
if (!s) throw new b("missing");
|
|
933
|
-
const
|
|
934
|
-
if (n.has(
|
|
935
|
-
if (n.add(
|
|
936
|
-
return
|
|
1024
|
+
const c = A(a);
|
|
1025
|
+
if (n.has(c)) throw new b("duplicate");
|
|
1026
|
+
if (n.add(c), Te(s, a) || !Object.is(s.value, a.previousValue) || (s.cell.text ?? "") !== a.previousText) throw new b("conflict");
|
|
1027
|
+
return U(s, a.value);
|
|
937
1028
|
});
|
|
938
|
-
return
|
|
1029
|
+
return Vr(e, o);
|
|
939
1030
|
}
|
|
940
|
-
function
|
|
1031
|
+
function Ln(e) {
|
|
941
1032
|
const t = /* @__PURE__ */ new Map();
|
|
942
1033
|
for (const r of e) {
|
|
943
|
-
const n =
|
|
1034
|
+
const n = A(r), o = t.get(n), a = o ? { ...r, previousValue: o.previousValue, previousText: o.previousText } : { ...r };
|
|
944
1035
|
Object.is(a.previousValue, a.value) ? t.delete(n) : t.set(n, a);
|
|
945
1036
|
}
|
|
946
1037
|
return [...t.values()];
|
|
947
1038
|
}
|
|
948
|
-
function
|
|
1039
|
+
function B(e, t) {
|
|
949
1040
|
for (let r = 0; r < t.length; r++) {
|
|
950
1041
|
const n = t.charCodeAt(r);
|
|
951
1042
|
e.first = Math.imul(e.first ^ n, 16777619), e.second = Math.imul(e.second, 33) ^ n, e.count++;
|
|
952
1043
|
}
|
|
953
1044
|
}
|
|
954
|
-
function
|
|
1045
|
+
function Gr(e, t, r) {
|
|
955
1046
|
const n = Object.getOwnPropertyDescriptor(e, t);
|
|
956
1047
|
if (!n || n.get || n.set) throw new b("conflict");
|
|
957
|
-
|
|
1048
|
+
B(r, `${t.length}:${t}`), ct(n.value, r);
|
|
958
1049
|
}
|
|
959
|
-
function
|
|
1050
|
+
function zr(e, t) {
|
|
960
1051
|
if (Object.getOwnPropertyDescriptor(e, "toJSON")) throw new b("conflict");
|
|
961
1052
|
if (t.active.has(e)) throw new b("conflict");
|
|
962
|
-
if (t.active.add(e), e instanceof Date)
|
|
1053
|
+
if (t.active.add(e), e instanceof Date) B(t, `date:${Date.prototype.getTime.call(e)};`);
|
|
963
1054
|
else {
|
|
964
1055
|
const r = Object.getPrototypeOf(e);
|
|
965
1056
|
if (!Array.isArray(e) && r !== Object.prototype && r !== null) throw new b("conflict");
|
|
966
1057
|
const n = Object.keys(e);
|
|
967
|
-
|
|
1058
|
+
B(t, `${Array.isArray(e) ? "array" : "object"}:${Array.isArray(e) ? e.length : n.length}:{`), n.forEach((o) => Gr(e, o, t)), B(t, "}");
|
|
968
1059
|
}
|
|
969
1060
|
t.active.delete(e);
|
|
970
1061
|
}
|
|
971
|
-
function
|
|
1062
|
+
function ct(e, t) {
|
|
972
1063
|
if (++t.nodes > 1e6) throw new b("limit");
|
|
973
1064
|
if (e === null) {
|
|
974
|
-
|
|
1065
|
+
B(t, "null;");
|
|
975
1066
|
return;
|
|
976
1067
|
}
|
|
977
1068
|
if (typeof e == "object") {
|
|
978
|
-
|
|
1069
|
+
zr(e, t);
|
|
979
1070
|
return;
|
|
980
1071
|
}
|
|
981
1072
|
if (typeof e == "function" || typeof e == "symbol") throw new b("conflict");
|
|
982
1073
|
const r = String(e);
|
|
983
|
-
|
|
1074
|
+
B(t, `${typeof e}:${r.length}:${r};`);
|
|
984
1075
|
}
|
|
985
|
-
function
|
|
1076
|
+
function Ee(e) {
|
|
986
1077
|
const t = { first: 2166136261, second: 5381, count: 0, nodes: 0, active: /* @__PURE__ */ new Set() };
|
|
987
|
-
return
|
|
1078
|
+
return ct(e, t), `${t.count}:${t.first >>> 0}:${t.second >>> 0}`;
|
|
988
1079
|
}
|
|
989
|
-
function
|
|
1080
|
+
function fe(e, t, r) {
|
|
990
1081
|
if (++r.nodes > 1e6) throw new b("limit");
|
|
991
1082
|
if (typeof e == "string" && (r.text += e.length, r.text > 32 * 1024 * 1024))
|
|
992
1083
|
throw new b("limit");
|
|
@@ -994,165 +1085,165 @@ function de(e, t, r) {
|
|
|
994
1085
|
if (t.has(e)) throw new b("conflict");
|
|
995
1086
|
if (e instanceof Date) return new Date(Date.prototype.getTime.call(e));
|
|
996
1087
|
t.add(e);
|
|
997
|
-
const n = Array.isArray(e) ? e.map((o) =>
|
|
1088
|
+
const n = Array.isArray(e) ? e.map((o) => fe(o, t, r)) : Object.fromEntries(Object.entries(e).map(([o, a]) => [o, fe(a, t, r)]));
|
|
998
1089
|
return t.delete(e), n;
|
|
999
1090
|
}
|
|
1000
|
-
function
|
|
1001
|
-
return
|
|
1091
|
+
function Jr(e) {
|
|
1092
|
+
return fe(e, /* @__PURE__ */ new Set(), { nodes: 0, text: 0 });
|
|
1002
1093
|
}
|
|
1003
|
-
function
|
|
1094
|
+
function lt(e) {
|
|
1004
1095
|
const t = [];
|
|
1005
1096
|
for (const r of e.template.pages) for (const n of r.components)
|
|
1006
1097
|
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] ?? [] } }));
|
|
1007
1098
|
return t;
|
|
1008
1099
|
}
|
|
1009
|
-
function
|
|
1100
|
+
function Ce(e) {
|
|
1010
1101
|
return JSON.stringify([e.datasetId, e.rowKey]);
|
|
1011
1102
|
}
|
|
1012
|
-
function
|
|
1103
|
+
function dt(e) {
|
|
1013
1104
|
const t = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Set();
|
|
1014
1105
|
return e.forEach((n, o) => {
|
|
1015
|
-
for (const a of
|
|
1106
|
+
for (const a of lt(n)) {
|
|
1016
1107
|
if (!a.rowKey) continue;
|
|
1017
|
-
const s = a.relation,
|
|
1018
|
-
(n.datasets[a.dataset] ?? []).forEach((i,
|
|
1019
|
-
if (s && !
|
|
1108
|
+
const s = a.relation, c = s ? new Set(s.parentRows.map((i) => JSON.stringify(i[s.detail.parentKey]))) : void 0;
|
|
1109
|
+
(n.datasets[a.dataset] ?? []).forEach((i, l) => {
|
|
1110
|
+
if (s && !c.has(JSON.stringify(i[s.detail.foreignKey]))) return;
|
|
1020
1111
|
const d = i[a.rowKey];
|
|
1021
1112
|
if (typeof d != "string" && typeof d != "number") return;
|
|
1022
|
-
const u = `${o}:${a.dataset}:${
|
|
1113
|
+
const u = `${o}:${a.dataset}:${l}:${a.rowKey}`;
|
|
1023
1114
|
if (r.has(u)) return;
|
|
1024
1115
|
r.add(u);
|
|
1025
|
-
const f =
|
|
1026
|
-
m.push({ partIndex: o, dataset: a.dataset, rowIndex:
|
|
1116
|
+
const f = Ce({ datasetId: a.dataset, rowKey: d }), m = t.get(f) ?? [];
|
|
1117
|
+
m.push({ partIndex: o, dataset: a.dataset, rowIndex: l, row: i, binding: a }), t.set(f, m);
|
|
1027
1118
|
});
|
|
1028
1119
|
}
|
|
1029
1120
|
}), (n) => {
|
|
1030
|
-
const o = t.get(
|
|
1121
|
+
const o = t.get(Ce(n));
|
|
1031
1122
|
if (!o?.length) throw new b("missing");
|
|
1032
1123
|
if (new Set(o.map((a) => `${a.partIndex}:${a.dataset}`)).size !== o.length) throw new b("conflict");
|
|
1033
1124
|
return o;
|
|
1034
1125
|
};
|
|
1035
1126
|
}
|
|
1036
|
-
function
|
|
1127
|
+
function ut(e, t) {
|
|
1037
1128
|
const r = e.map((o) => ({ ...o, datasets: { ...o.datasets } })), n = /* @__PURE__ */ new Set();
|
|
1038
1129
|
for (const { row: o, field: a, value: s } of t) {
|
|
1039
|
-
const
|
|
1040
|
-
n.has(i) || (
|
|
1130
|
+
const c = r[o.partIndex], i = `${o.partIndex}:${o.dataset}`;
|
|
1131
|
+
n.has(i) || (c.datasets[o.dataset] = [...c.datasets[o.dataset]], n.add(i)), c.datasets[o.dataset][o.rowIndex] = { ...c.datasets[o.dataset][o.rowIndex], [a]: s };
|
|
1041
1132
|
}
|
|
1042
1133
|
return r;
|
|
1043
1134
|
}
|
|
1044
|
-
function
|
|
1135
|
+
function qr(e, t, r) {
|
|
1045
1136
|
const n = [], o = /* @__PURE__ */ new Set();
|
|
1046
1137
|
return e.forEach((a, s) => {
|
|
1047
|
-
for (const
|
|
1048
|
-
t.has(
|
|
1049
|
-
const d = { partIndex: s, dataset:
|
|
1050
|
-
for (const [u, f] of [[
|
|
1138
|
+
for (const c of lt(a))
|
|
1139
|
+
t.has(c.dataset) && (a.datasets[c.dataset] ?? []).forEach((i, l) => {
|
|
1140
|
+
const d = { partIndex: s, dataset: c.dataset, rowIndex: l, row: i, binding: c };
|
|
1141
|
+
for (const [u, f] of [[c.revisionField, r.revision], [c.sourceTokenField, r.sourceToken]]) {
|
|
1051
1142
|
if (!u || f === void 0) continue;
|
|
1052
|
-
const m = `${s}:${
|
|
1143
|
+
const m = `${s}:${c.dataset}:${l}:${u}`;
|
|
1053
1144
|
o.has(m) || (o.add(m), n.push({ row: d, field: u, value: f }));
|
|
1054
1145
|
}
|
|
1055
1146
|
});
|
|
1056
1147
|
}), n;
|
|
1057
1148
|
}
|
|
1058
|
-
function
|
|
1059
|
-
const t = /* @__PURE__ */ new Map(), r =
|
|
1149
|
+
function ft(e) {
|
|
1150
|
+
const t = /* @__PURE__ */ new Map(), r = W(e);
|
|
1060
1151
|
return e.pages.forEach((n, o) => n.components.forEach((a, s) => {
|
|
1061
1152
|
if (!(!a.grid || a.table?.role !== "body"))
|
|
1062
|
-
for (let
|
|
1063
|
-
const
|
|
1064
|
-
|
|
1153
|
+
for (let c = 0; c < a.grid.cells.length; c++) for (let i = 0; i < a.table.columnKeys.length; i++) {
|
|
1154
|
+
const l = r({ pageIndex: o, componentIndex: s, rowIndex: c, columnIndex: i });
|
|
1155
|
+
l?.source && l.editable && t.set(A(l), l);
|
|
1065
1156
|
}
|
|
1066
1157
|
})), t;
|
|
1067
1158
|
}
|
|
1068
|
-
function
|
|
1069
|
-
const n =
|
|
1159
|
+
function Hn(e, t, r) {
|
|
1160
|
+
const n = ft(e), o = W(e);
|
|
1070
1161
|
return t.map((a) => {
|
|
1071
|
-
const s = a.source ? n.get(
|
|
1072
|
-
if (!s ||
|
|
1162
|
+
const s = a.source ? n.get(A(a)) : o(a.address);
|
|
1163
|
+
if (!s || A(s) !== A(a)) throw new b("missing");
|
|
1073
1164
|
return { address: { ...s.address }, value: a[r] };
|
|
1074
1165
|
});
|
|
1075
1166
|
}
|
|
1076
|
-
async function
|
|
1167
|
+
async function mt(e, t, r = {}) {
|
|
1077
1168
|
const n = [], o = { ...r, knownTotalPages: void 0 };
|
|
1078
|
-
for (const a of
|
|
1169
|
+
for (const a of Tr(e, t, o))
|
|
1079
1170
|
n.push(a), n.length % 8 === 0 && await new Promise((s) => setTimeout(s, 0));
|
|
1080
1171
|
if (r.signal?.aborted) {
|
|
1081
1172
|
const a = new Error("报表重算已取消");
|
|
1082
1173
|
throw a.name = "AbortError", a;
|
|
1083
1174
|
}
|
|
1084
|
-
return { schemaVersion:
|
|
1175
|
+
return { schemaVersion: ee, ...re(e) ? { requiresRecalculation: !0 } : {}, pages: n };
|
|
1085
1176
|
}
|
|
1086
|
-
const
|
|
1087
|
-
function
|
|
1088
|
-
return
|
|
1177
|
+
const me = /* @__PURE__ */ new WeakMap();
|
|
1178
|
+
function Bn(e) {
|
|
1179
|
+
return me.get(e);
|
|
1089
1180
|
}
|
|
1090
|
-
function
|
|
1181
|
+
function Y(e) {
|
|
1091
1182
|
if (e?.aborted) {
|
|
1092
1183
|
const t = new Error("报表重算已取消");
|
|
1093
1184
|
throw t.name = "AbortError", t;
|
|
1094
1185
|
}
|
|
1095
1186
|
}
|
|
1096
|
-
function
|
|
1187
|
+
function gt(e, t) {
|
|
1097
1188
|
return e[t] === void 0 ? "" : e[t];
|
|
1098
1189
|
}
|
|
1099
|
-
function
|
|
1190
|
+
function _r(e, t) {
|
|
1100
1191
|
if (t.edits.length > 1e4) throw new b("limit");
|
|
1101
|
-
const r =
|
|
1102
|
-
const
|
|
1103
|
-
if (!
|
|
1104
|
-
const i =
|
|
1192
|
+
const r = W(e), n = /* @__PURE__ */ new Set(), o = [], a = t.edits.map((s) => {
|
|
1193
|
+
const c = r(s.address);
|
|
1194
|
+
if (!c?.source) throw new b("missing");
|
|
1195
|
+
const i = A(s);
|
|
1105
1196
|
if (n.has(i)) throw new b("duplicate");
|
|
1106
|
-
if (n.add(i),
|
|
1107
|
-
return o.push(
|
|
1197
|
+
if (n.add(i), Te(c, s) || !Object.is(c.value, s.previousValue) || (c.cell.text ?? "") !== s.previousText) throw new b("conflict");
|
|
1198
|
+
return o.push(c), U(c, s.value);
|
|
1108
1199
|
});
|
|
1109
1200
|
return { batch: { requestId: t.requestId, edits: a }, contexts: o };
|
|
1110
1201
|
}
|
|
1111
|
-
function
|
|
1112
|
-
const r =
|
|
1202
|
+
function Ur(e, t) {
|
|
1203
|
+
const r = dt(e);
|
|
1113
1204
|
return t.flatMap((n) => {
|
|
1114
1205
|
if (!n.source) throw new b("missing");
|
|
1115
1206
|
return r(n.source).map((o) => {
|
|
1116
|
-
if (!Object.is(
|
|
1207
|
+
if (!Object.is(gt(o.row, n.source.field), n.previousValue)) throw new b("conflict");
|
|
1117
1208
|
if (o.binding.rowKey === n.source.field) throw new b("readonly");
|
|
1118
1209
|
return { row: o, field: n.source.field, value: n.value };
|
|
1119
1210
|
});
|
|
1120
1211
|
});
|
|
1121
1212
|
}
|
|
1122
|
-
function
|
|
1213
|
+
function le(e, t, r) {
|
|
1123
1214
|
const n = { ...e, value: t, source: { ...e.source, ...r?.revision === void 0 ? {} : { revision: r.revision }, ...r?.sourceToken === void 0 ? {} : { sourceToken: r.sourceToken } } };
|
|
1124
|
-
return n.cell = { ...e.cell, value: n.value, text:
|
|
1215
|
+
return n.cell = { ...e.cell, value: n.value, text: _(n, n.value) }, n;
|
|
1125
1216
|
}
|
|
1126
|
-
function
|
|
1217
|
+
function Yr(e, t, r) {
|
|
1127
1218
|
if (!r || r.revision === void 0 && r.sourceToken === void 0) return [...e];
|
|
1128
1219
|
const n = new Set(t.edits.flatMap((o) => o.source ? [o.source.datasetId] : []));
|
|
1129
|
-
return
|
|
1220
|
+
return ut(e, qr(e, n, r));
|
|
1130
1221
|
}
|
|
1131
|
-
function
|
|
1222
|
+
function pt(e, t) {
|
|
1132
1223
|
let r = t.parts;
|
|
1133
|
-
const n = t.rebuild, o =
|
|
1224
|
+
const n = t.rebuild, o = Ee(r);
|
|
1134
1225
|
let a = e, s;
|
|
1135
|
-
const
|
|
1226
|
+
const c = /* @__PURE__ */ new Map();
|
|
1136
1227
|
function i(u) {
|
|
1137
1228
|
if (u !== a) throw new b("conflict");
|
|
1138
1229
|
if (s) return s;
|
|
1139
|
-
if (
|
|
1140
|
-
return
|
|
1230
|
+
if (Ee(r) !== o) throw new b("conflict");
|
|
1231
|
+
return Jr(r);
|
|
1141
1232
|
}
|
|
1142
|
-
async function
|
|
1143
|
-
|
|
1144
|
-
const g = i(u),
|
|
1145
|
-
|
|
1233
|
+
async function l(u, f, m, w = {}) {
|
|
1234
|
+
Y(w.signal), f = { requestId: f.requestId, edits: f.edits.map((y) => ({ ...y, address: { ...y.address }, source: y.source ? { ...y.source } : void 0, table: y.table ? { ...y.table } : void 0 })) }, m = m.map((y) => ({ ...y, address: { ...y.address }, source: y.source ? { ...y.source } : void 0, table: y.table ? { ...y.table } : void 0, cell: { ...y.cell } })), await new Promise((y) => setTimeout(y, 0)), Y(w.signal);
|
|
1235
|
+
const g = i(u), p = ut(g, Ur(g, f.edits)), v = await n(p, w.signal);
|
|
1236
|
+
Y(w.signal);
|
|
1146
1237
|
let M = !1;
|
|
1147
1238
|
return { plan: v, commit(y) {
|
|
1148
|
-
if (
|
|
1239
|
+
if (Y(w.signal), M || a !== u) throw new b("conflict");
|
|
1149
1240
|
if (y?.conflicts?.length) throw new b("conflict");
|
|
1150
|
-
const
|
|
1241
|
+
const N = Yr(p, f, y), O = Wr(v, f, y);
|
|
1151
1242
|
if (y) {
|
|
1152
|
-
const
|
|
1153
|
-
for (const [
|
|
1243
|
+
const k = new Set(f.edits.map((R) => R.source.datasetId));
|
|
1244
|
+
for (const [R, h] of c) k.has(h.source.datasetId) && c.set(R, le(h, h.value, y));
|
|
1154
1245
|
}
|
|
1155
|
-
return m.forEach((
|
|
1246
|
+
return m.forEach((k, R) => c.set(A(k), le(k, f.edits[R].value, y))), M = !0, s = N, r = void 0, a = O, me.set(a, d), a;
|
|
1156
1247
|
} };
|
|
1157
1248
|
}
|
|
1158
1249
|
const d = {
|
|
@@ -1160,61 +1251,61 @@ function it(e, t) {
|
|
|
1160
1251
|
return a;
|
|
1161
1252
|
},
|
|
1162
1253
|
async prepare(u, f, m) {
|
|
1163
|
-
const w =
|
|
1164
|
-
return
|
|
1254
|
+
const w = _r(u, f);
|
|
1255
|
+
return l(u, w.batch, w.contexts, m);
|
|
1165
1256
|
},
|
|
1166
1257
|
async prepareHistory(u, f, m, w, g) {
|
|
1167
1258
|
if (!w.trim() || f.length > 1e4) throw new b("limit");
|
|
1168
|
-
const
|
|
1169
|
-
if (!
|
|
1170
|
-
const $ =
|
|
1259
|
+
const p = i(u), v = dt(p), M = ft(u), y = /* @__PURE__ */ new Set(), O = f.map((h) => {
|
|
1260
|
+
if (!h.source) throw new b("missing");
|
|
1261
|
+
const $ = A(h);
|
|
1171
1262
|
if (y.has($)) throw new b("duplicate");
|
|
1172
1263
|
y.add($);
|
|
1173
|
-
const x = M.get($) ??
|
|
1264
|
+
const x = M.get($) ?? c.get($);
|
|
1174
1265
|
if (!x?.source) throw new b("missing");
|
|
1175
|
-
const
|
|
1176
|
-
return
|
|
1177
|
-
}).map((
|
|
1178
|
-
return { batch:
|
|
1266
|
+
const I = v(x.source)[0];
|
|
1267
|
+
return le(x, gt(I.row, x.source.field));
|
|
1268
|
+
}).map((h, $) => ({ context: h, edit: U(h, f[$][m]) })).filter(({ edit: h }) => !Object.is(h.previousValue, h.value)), k = { requestId: w, edits: O.map(({ edit: h }) => h) }, R = O.map(({ context: h }) => h);
|
|
1269
|
+
return { batch: k, contexts: R, prepared: await l(u, k, R, g) };
|
|
1179
1270
|
}
|
|
1180
1271
|
};
|
|
1181
|
-
return
|
|
1272
|
+
return me.set(e, d), d;
|
|
1182
1273
|
}
|
|
1183
|
-
function
|
|
1184
|
-
const t =
|
|
1185
|
-
return
|
|
1274
|
+
function Wn(e) {
|
|
1275
|
+
const t = xe(e.template, e.datasets, e.pagination).plan;
|
|
1276
|
+
return pt(t, { parts: [{ template: e.template, datasets: e.datasets }], rebuild: (r, n) => mt(r[0].template, r[0].datasets, { ...e.pagination, signal: n }) });
|
|
1186
1277
|
}
|
|
1187
|
-
function
|
|
1278
|
+
function Ie(e, t, r = {}) {
|
|
1188
1279
|
const n = /* @__PURE__ */ new Map();
|
|
1189
1280
|
for (const a of e.pages) for (const s of a.components) {
|
|
1190
1281
|
if (s.kind !== "list" || s.tree?.input !== "nested") continue;
|
|
1191
|
-
const
|
|
1192
|
-
if (
|
|
1282
|
+
const c = n.get(s.dataset);
|
|
1283
|
+
if (c && (c.childrenField ?? "children") !== (s.tree.childrenField ?? "children")) throw new Error("同一数据集的嵌套树应使用相同 childrenField");
|
|
1193
1284
|
n.set(s.dataset, s.tree);
|
|
1194
1285
|
}
|
|
1195
1286
|
if (!n.size) return t;
|
|
1196
1287
|
const o = { ...t };
|
|
1197
1288
|
for (const [a, s] of n) {
|
|
1198
|
-
const
|
|
1199
|
-
o[a] =
|
|
1289
|
+
const c = Math.min(s.maxRows ?? 1e5, r.maxRows ?? 1 / 0);
|
|
1290
|
+
o[a] = Ge(t[a] ?? [], { ...s, maxRows: c }, r.signal);
|
|
1200
1291
|
}
|
|
1201
1292
|
return o;
|
|
1202
1293
|
}
|
|
1203
|
-
function
|
|
1204
|
-
return Object.values(
|
|
1294
|
+
function Xr(e, t, r = {}) {
|
|
1295
|
+
return Object.values(Ie(e, t, r)).reduce((n, o) => n + o.length, 0);
|
|
1205
1296
|
}
|
|
1206
|
-
function
|
|
1207
|
-
const n =
|
|
1297
|
+
function Dn(e, t, r) {
|
|
1298
|
+
const n = Ft(r), o = e?.pages.flatMap((c) => c.components).find((c) => c.kind === "list" && c.dataset === t && c.tree?.input === "nested");
|
|
1208
1299
|
if (!o || o.kind !== "list" || !o.tree) return n;
|
|
1209
1300
|
const a = n.items, s = o.tree.childrenField ?? "children";
|
|
1210
1301
|
return { ...n, items: { $ref: "#/$defs/treeNode" }, $defs: { treeNode: { ...a, properties: { ...a.properties, [s]: { anyOf: [{ type: "null" }, { type: "array", items: { $ref: "#/$defs/treeNode" } }] } } } } };
|
|
1211
1302
|
}
|
|
1212
|
-
function
|
|
1303
|
+
function Vn(e) {
|
|
1213
1304
|
if (!("mapData" in e)) return e;
|
|
1214
1305
|
const { load: t, mapData: r, ...n } = e;
|
|
1215
1306
|
return { ...n, load: async (o) => {
|
|
1216
1307
|
const a = await t(o);
|
|
1217
|
-
|
|
1308
|
+
C(o.signal);
|
|
1218
1309
|
try {
|
|
1219
1310
|
return r(a, o);
|
|
1220
1311
|
} catch (s) {
|
|
@@ -1227,17 +1318,17 @@ class S extends Error {
|
|
|
1227
1318
|
super(r), this.name = "ReportSourceError", this.code = t, this.cause = n;
|
|
1228
1319
|
}
|
|
1229
1320
|
}
|
|
1230
|
-
function
|
|
1321
|
+
function ie(e) {
|
|
1231
1322
|
const t = new Error("报表加载已取消");
|
|
1232
1323
|
return t.name = "AbortError", Object.defineProperty(t, "cause", { value: e.reason }), t;
|
|
1233
1324
|
}
|
|
1234
|
-
function
|
|
1235
|
-
if (e?.aborted) throw
|
|
1325
|
+
function C(e) {
|
|
1326
|
+
if (e?.aborted) throw ie(e);
|
|
1236
1327
|
}
|
|
1237
|
-
function
|
|
1328
|
+
function ge(e, t) {
|
|
1238
1329
|
return t ? new Promise((r, n) => {
|
|
1239
1330
|
const o = () => t.removeEventListener("abort", a), a = () => {
|
|
1240
|
-
o(), n(
|
|
1331
|
+
o(), n(ie(t));
|
|
1241
1332
|
};
|
|
1242
1333
|
t.addEventListener("abort", a, { once: !0 }), t.aborted && a(), Promise.resolve(e).then(
|
|
1243
1334
|
(s) => {
|
|
@@ -1249,68 +1340,73 @@ function fe(e, t) {
|
|
|
1249
1340
|
);
|
|
1250
1341
|
}) : Promise.resolve(e);
|
|
1251
1342
|
}
|
|
1252
|
-
function
|
|
1343
|
+
function Qr(e, t) {
|
|
1253
1344
|
if (!e || typeof e != "object" || Array.isArray(e))
|
|
1254
1345
|
throw new S("validate", `报表 ${t} 的数据集应为对象`);
|
|
1255
1346
|
for (const [r, n] of Object.entries(e))
|
|
1256
1347
|
if (!Array.isArray(n) || n.some((o) => !o || typeof o != "object" || Array.isArray(o)))
|
|
1257
1348
|
throw new S("validate", `报表 ${t} 的数据集 ${r} 应为对象数组`);
|
|
1258
1349
|
}
|
|
1259
|
-
async function
|
|
1350
|
+
async function Zr(e, t, r) {
|
|
1260
1351
|
const { reportId: n, signal: o } = t;
|
|
1261
1352
|
try {
|
|
1262
|
-
const a = await
|
|
1263
|
-
|
|
1264
|
-
const s =
|
|
1353
|
+
const a = await ge(e(t), o);
|
|
1354
|
+
C(o);
|
|
1355
|
+
const s = It(a);
|
|
1265
1356
|
if (!s.ok)
|
|
1266
|
-
throw new S("validate", `报表 ${n} 模板校验失败:${s.errors.slice(0, 3).map((
|
|
1267
|
-
return r.push(...s.warnings.map((
|
|
1357
|
+
throw new S("validate", `报表 ${n} 模板校验失败:${s.errors.slice(0, 3).map((c) => `${c.path}: ${c.message}`).join("; ")}`);
|
|
1358
|
+
return r.push(...s.warnings.map((c) => `${n}: ${c.path}: ${c.message}`)), a;
|
|
1268
1359
|
} catch (a) {
|
|
1269
|
-
throw o?.aborted ?
|
|
1360
|
+
throw o?.aborted ? ie(o) : a instanceof S ? a : a instanceof Pt ? new S("validate", `报表 ${n} 模板校验失败:${a.message}`, a) : new S("fetch", `报表 ${n} 模板加载失败:${a instanceof Error ? a.message : String(a)}`, a);
|
|
1270
1361
|
}
|
|
1271
1362
|
}
|
|
1272
|
-
async function
|
|
1363
|
+
async function en(e, t, r, n) {
|
|
1273
1364
|
const o = t.signal;
|
|
1274
1365
|
let a;
|
|
1275
1366
|
try {
|
|
1276
|
-
if (e.load) a = await
|
|
1367
|
+
if (e.load) a = await ge(e.load(t), o);
|
|
1277
1368
|
else if (e.provider) {
|
|
1278
|
-
const s = await
|
|
1279
|
-
|
|
1369
|
+
const s = await ge(e.provider.query(t), o);
|
|
1370
|
+
C(o), tn(s, r), a = s.datasets, n?.(r, s);
|
|
1280
1371
|
} else a = e.datasets ?? {};
|
|
1281
1372
|
} catch (s) {
|
|
1282
|
-
throw o?.aborted ?
|
|
1373
|
+
throw o?.aborted ? ie(o) : s instanceof S ? s : new S("fetch", `报表 ${r} 取数失败:${s instanceof Error ? s.message : String(s)}`, s);
|
|
1283
1374
|
}
|
|
1284
|
-
return
|
|
1375
|
+
return C(o), a;
|
|
1285
1376
|
}
|
|
1286
|
-
function
|
|
1377
|
+
function tn(e, t) {
|
|
1287
1378
|
if (!e || typeof e != "object" || Array.isArray(e)) throw new S("validate", `报表 ${t} Provider 应返回 datasets 结果对象`);
|
|
1288
1379
|
for (const r of ["revision", "sourceToken"])
|
|
1289
1380
|
if (e[r] !== void 0 && typeof e[r] != "string") throw new S("validate", `报表 ${t} Provider ${r} 应为字符串`);
|
|
1290
1381
|
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))))
|
|
1291
1382
|
throw new S("validate", `报表 ${t} Provider diagnostics 不符合结构化诊断契约`);
|
|
1292
1383
|
}
|
|
1293
|
-
function
|
|
1384
|
+
function rn(e, t, r, n, o) {
|
|
1294
1385
|
try {
|
|
1295
|
-
t =
|
|
1386
|
+
t = Ie(n, t, { maxRows: e.dataValidation?.maxRows, signal: o });
|
|
1296
1387
|
} catch (a) {
|
|
1297
1388
|
throw new S("validate", `报表 ${r} 树形数据无效:${a instanceof Error ? a.message : String(a)}`, a);
|
|
1298
1389
|
}
|
|
1299
1390
|
for (const [a, s] of Object.entries(e.dataSchema ?? {})) {
|
|
1300
|
-
let
|
|
1391
|
+
let c;
|
|
1301
1392
|
try {
|
|
1302
|
-
|
|
1393
|
+
c = Ke(Object.prototype.hasOwnProperty.call(t, a) ? t[a] : void 0, s, { ...e.dataValidation, path: `$.datasets.${a}` });
|
|
1303
1394
|
} catch (i) {
|
|
1304
1395
|
throw new S("config", `报表 ${r} 数据集 ${a} 字段契约配置无效`, i);
|
|
1305
1396
|
}
|
|
1306
|
-
if (!
|
|
1397
|
+
if (!c.ok) throw new S("validate", `报表 ${r} 数据集 ${a} 不符合字段契约:${c.issues[0]?.message}`, { issues: c.issues });
|
|
1307
1398
|
}
|
|
1308
1399
|
}
|
|
1309
|
-
function
|
|
1310
|
-
|
|
1400
|
+
function ht(e, t) {
|
|
1401
|
+
if (!e.repeat) return !1;
|
|
1402
|
+
const r = Object.prototype.hasOwnProperty.call(t, e.repeat.dataset) ? t[e.repeat.dataset] : void 0;
|
|
1403
|
+
return Array.isArray(r) && r.length === 0;
|
|
1404
|
+
}
|
|
1405
|
+
function wt(e) {
|
|
1406
|
+
const t = (r) => r.grid?.cells.reduce((n, o) => n + o.reduce((a, s) => a + (s ? 1 + (s.children?.reduce((c, i) => c + t(i), 0) ?? 0) : 0), 0), 0) ?? 0;
|
|
1311
1407
|
return e.pages.reduce((r, n) => r + n.components.reduce((o, a) => o + t(a), 0), 0);
|
|
1312
1408
|
}
|
|
1313
|
-
function
|
|
1409
|
+
function yt(e, t, r, n) {
|
|
1314
1410
|
return {
|
|
1315
1411
|
...e,
|
|
1316
1412
|
signal: n ?? e?.signal,
|
|
@@ -1318,48 +1414,48 @@ function ct(e, t, r, n) {
|
|
|
1318
1414
|
...r === void 0 ? {} : { maxCells: Math.max(1, Math.min(r, e?.maxCells ?? r)) }
|
|
1319
1415
|
};
|
|
1320
1416
|
}
|
|
1321
|
-
function
|
|
1322
|
-
const s = o.maxPages === void 0 ? void 0 : o.maxPages - o.usedPages,
|
|
1417
|
+
function nn(e, t, r, n, o, a) {
|
|
1418
|
+
const s = o.maxPages === void 0 ? void 0 : o.maxPages - o.usedPages, c = o.maxCells === void 0 ? void 0 : o.maxCells - o.usedCells;
|
|
1323
1419
|
try {
|
|
1324
|
-
if (s !== void 0 && s < 1 && e.pages.length) throw new
|
|
1325
|
-
const i =
|
|
1326
|
-
if (
|
|
1327
|
-
return { ...
|
|
1420
|
+
if (s !== void 0 && s < 1 && e.pages.length && !ht(e, t)) throw new H(0, 1);
|
|
1421
|
+
const i = yt(r.pagination, s, c, a), l = xe(e, t, i), d = wt(l.plan);
|
|
1422
|
+
if (c !== void 0 && d > c) throw new V(c, d);
|
|
1423
|
+
return { ...l, cells: d };
|
|
1328
1424
|
} catch (i) {
|
|
1329
|
-
let
|
|
1330
|
-
throw i instanceof
|
|
1425
|
+
let l = i;
|
|
1426
|
+
throw i instanceof H && o.maxPages !== void 0 && i.limit === s && (l = new H(o.maxPages, o.usedPages + i.actual)), i instanceof V && o.maxCells !== void 0 && (l = new V(o.maxCells, o.usedCells + i.actual)), new S("validate", `报表 ${n} 排版失败:${l instanceof Error ? l.message : String(l)}`, l);
|
|
1331
1427
|
}
|
|
1332
1428
|
}
|
|
1333
|
-
function
|
|
1429
|
+
function bt(e, t, r, n) {
|
|
1334
1430
|
const o = /* @__PURE__ */ new Map(), a = (s) => {
|
|
1335
|
-
let
|
|
1336
|
-
return
|
|
1431
|
+
let c = o.get(s);
|
|
1432
|
+
return c === void 0 && (c = JSON.stringify([r, n, s]), o.set(s, c)), c;
|
|
1337
1433
|
};
|
|
1338
1434
|
for (const s of t.pages) e.push({
|
|
1339
1435
|
...s,
|
|
1340
1436
|
...s.meta ? { meta: { ...s.meta, reportScope: JSON.stringify([r, n]) } } : {},
|
|
1341
|
-
components: s.components.map((
|
|
1342
|
-
...
|
|
1343
|
-
table: { ...
|
|
1344
|
-
} :
|
|
1437
|
+
components: s.components.map((c) => c.table ? {
|
|
1438
|
+
...c,
|
|
1439
|
+
table: { ...c.table, id: a(c.table.id) }
|
|
1440
|
+
} : c)
|
|
1345
1441
|
});
|
|
1346
1442
|
}
|
|
1347
|
-
async function
|
|
1443
|
+
async function on(e, t, r, n, o) {
|
|
1348
1444
|
const a = [];
|
|
1349
1445
|
let s = 0;
|
|
1350
|
-
for (const [
|
|
1351
|
-
|
|
1446
|
+
for (const [l, d] of e.entries()) {
|
|
1447
|
+
C(o);
|
|
1352
1448
|
const u = n.maxPages === void 0 ? void 0 : n.maxPages - a.length, f = n.maxCells === void 0 ? void 0 : n.maxCells - s;
|
|
1353
|
-
if (u !== void 0 && u < 1 && d.template.pages.length) throw new
|
|
1354
|
-
const m = await
|
|
1355
|
-
if (s +=
|
|
1356
|
-
|
|
1449
|
+
if (u !== void 0 && u < 1 && d.template.pages.length && !ht(d.template, d.datasets)) throw new H(n.maxPages, a.length + 1);
|
|
1450
|
+
const m = await mt(d.template, d.datasets, yt(t[l]?.pagination, u, f, o));
|
|
1451
|
+
if (s += wt(m), n.maxCells !== void 0 && s > n.maxCells) throw new V(n.maxCells, s);
|
|
1452
|
+
bt(a, m, l, r[l]);
|
|
1357
1453
|
}
|
|
1358
|
-
const
|
|
1454
|
+
const c = { schemaVersion: ee, ...e.some((l) => re(l.template)) ? { requiresRecalculation: !0 } : {}, pages: a }, i = Oe(c);
|
|
1359
1455
|
if (!i.ok) throw new S("validate", `重算渲染计划校验失败:${i.errors[0]?.message}`);
|
|
1360
|
-
return
|
|
1456
|
+
return c;
|
|
1361
1457
|
}
|
|
1362
|
-
function
|
|
1458
|
+
function Gn(e, t = {}) {
|
|
1363
1459
|
if (t.maxPages !== void 0 && (!Number.isSafeInteger(t.maxPages) || t.maxPages < 1)) throw new S("config", "maxPages 应为正安全整数");
|
|
1364
1460
|
if (t.maxCells !== void 0 && (!Number.isSafeInteger(t.maxCells) || t.maxCells < 1)) throw new S("config", "maxCells 应为正安全整数");
|
|
1365
1461
|
function r(o) {
|
|
@@ -1367,57 +1463,57 @@ function Sn(e, t = {}) {
|
|
|
1367
1463
|
if (!a) throw new S("config", `未注册报表 ${o}`);
|
|
1368
1464
|
return a;
|
|
1369
1465
|
}
|
|
1370
|
-
return Object.assign(async ({ reportIds: o, params: a, signal: s, onWarning:
|
|
1371
|
-
|
|
1372
|
-
const d =
|
|
1466
|
+
return Object.assign(async ({ reportIds: o, params: a, signal: s, onWarning: c, onQueryResult: i, ...l }) => {
|
|
1467
|
+
C(s);
|
|
1468
|
+
const d = Ct({ ...l, signal: s }), u = [...o], f = { ...a };
|
|
1373
1469
|
if (u.length === 0) throw new S("config", "缺少报表 ID");
|
|
1374
|
-
const m = u.map(r), w = d.runSync("validate", () => m.map((
|
|
1375
|
-
|
|
1470
|
+
const m = u.map(r), w = d.runSync("validate", () => m.map((h) => Pe(
|
|
1471
|
+
h.params ?? (typeof h.template == "function" ? [] : h.template.params) ?? [],
|
|
1376
1472
|
f
|
|
1377
|
-
))), g = [],
|
|
1473
|
+
))), g = [], p = [];
|
|
1378
1474
|
let v = 0;
|
|
1379
1475
|
const M = [];
|
|
1380
|
-
for (const [
|
|
1381
|
-
|
|
1382
|
-
const x = u[
|
|
1383
|
-
|
|
1384
|
-
const
|
|
1476
|
+
for (const [h, $] of m.entries()) {
|
|
1477
|
+
C(s);
|
|
1478
|
+
const x = u[h], I = { reportId: x, params: w[h], signal: s }, P = typeof $.template == "function" ? await d.run("query", () => Zr($.template, I, M), x) : $.template;
|
|
1479
|
+
I.params = d.runSync("validate", () => Pe($.params ?? P.params ?? [], I.params), x);
|
|
1480
|
+
const K = await d.run("query", () => en($, I, x, i), x);
|
|
1385
1481
|
d.runSync("validate", () => {
|
|
1386
|
-
|
|
1387
|
-
}, x),
|
|
1388
|
-
const
|
|
1389
|
-
v +=
|
|
1482
|
+
Qr(K, x), t.onDatasets?.(x, K, P), rn($, K, x, P, s);
|
|
1483
|
+
}, x), C(s);
|
|
1484
|
+
const ce = d.runSync("layout", () => nn(P, K, $, x, { maxPages: t.maxPages, usedPages: g.length, maxCells: t.maxCells, usedCells: v }, s), x);
|
|
1485
|
+
v += ce.cells, p.push({ template: P, datasets: K }), bt(g, ce.plan, h, x), M.push(...ce.warnings.map((Mt) => `${x}: ${Mt}`));
|
|
1390
1486
|
}
|
|
1391
|
-
|
|
1392
|
-
const y = { schemaVersion:
|
|
1393
|
-
const
|
|
1394
|
-
if (!
|
|
1395
|
-
return
|
|
1487
|
+
C(s);
|
|
1488
|
+
const y = { schemaVersion: ee, ...p.some((h) => re(h.template)) ? { requiresRecalculation: !0 } : {}, pages: g }, N = d.runSync("validate", () => {
|
|
1489
|
+
const h = Oe(y);
|
|
1490
|
+
if (!h.ok) throw new S("validate", `渲染计划校验失败:${h.errors.slice(0, 3).map(($) => `${$.path}: ${$.message}`).join("; ")}`);
|
|
1491
|
+
return h;
|
|
1396
1492
|
});
|
|
1397
|
-
M.push(...
|
|
1398
|
-
const
|
|
1493
|
+
M.push(...N.warnings.map((h) => `${h.path}: ${h.message}`));
|
|
1494
|
+
const O = m.map((h) => ({ ...h, pagination: { ...h.pagination } })), k = { maxPages: t.maxPages, maxCells: t.maxCells };
|
|
1399
1495
|
try {
|
|
1400
|
-
|
|
1496
|
+
pt(y, { parts: p, rebuild: (h, $) => on(h, O, u, k, $) });
|
|
1401
1497
|
} catch {
|
|
1402
1498
|
M.push("来源数据无法建立本地重算口径;当前预览仅支持计划内编辑,请使用可序列化模板数据启用规则重算");
|
|
1403
1499
|
}
|
|
1404
|
-
const
|
|
1405
|
-
for (const
|
|
1406
|
-
|
|
1407
|
-
return
|
|
1500
|
+
const R = c ?? t.onWarning ?? ((h) => console.warn("[mach-report]", h));
|
|
1501
|
+
for (const h of M)
|
|
1502
|
+
C(s), R(h);
|
|
1503
|
+
return C(s), y;
|
|
1408
1504
|
}, {
|
|
1409
|
-
getParamDefs: (o) =>
|
|
1505
|
+
getParamDefs: (o) => $t(e, o)
|
|
1410
1506
|
});
|
|
1411
1507
|
}
|
|
1412
|
-
function
|
|
1508
|
+
function Fe(e) {
|
|
1413
1509
|
if (e === void 0) return;
|
|
1414
1510
|
const t = typeof e == "string" ? e : JSON.stringify(e);
|
|
1415
1511
|
return t.length > 160 ? t.slice(0, 157) + "…" : t;
|
|
1416
1512
|
}
|
|
1417
|
-
function
|
|
1418
|
-
return /\.tree\.(?:idField|parentField|childrenField|labelField|input)$/.test(e) ? "binding" : /\.tree\.parentValues$/.test(e) ? "calculation" : /\.tree\.indentMm$/.test(e) ? "format" : /\.(?:computed|computeOptions|groups|groupBy|aggregates|grandTotal)(?:\.|\[|$)/.test(e) ? "calculation" : /\.(?:dataset|field|rowKey|revisionField|sourceTokenField|foreignKey|parentKey)$/.test(e) ? "binding" : /\.(?:style|headerStyle|format|rules|align|headerAlign|semanticRole|unit)(?:\.|\[|$)/.test(e) ? "format" : e.startsWith("$.template") ? "structure" : "metadata";
|
|
1513
|
+
function an(e) {
|
|
1514
|
+
return /\.(?:repeat|binding)(?:\.|$)/.test(e) ? /\.format(?:\.|$)/.test(e) ? "format" : "binding" : /\.tree\.(?:idField|parentField|childrenField|labelField|input)$/.test(e) ? "binding" : /\.tree\.parentValues$/.test(e) ? "calculation" : /\.tree\.indentMm$/.test(e) ? "format" : /\.(?:computed|computeOptions|groups|groupBy|aggregates|grandTotal)(?:\.|\[|$)/.test(e) ? "calculation" : /\.(?:dataset|field|rowKey|revisionField|sourceTokenField|foreignKey|parentKey)$/.test(e) ? "binding" : /\.(?:style|headerStyle|format|rules|align|headerAlign|semanticRole|unit)(?:\.|\[|$)/.test(e) ? "format" : e.startsWith("$.template") ? "structure" : "metadata";
|
|
1419
1515
|
}
|
|
1420
|
-
function
|
|
1516
|
+
function Ae(e) {
|
|
1421
1517
|
const t = /* @__PURE__ */ new Map();
|
|
1422
1518
|
for (const r of e) {
|
|
1423
1519
|
if (!r || typeof r != "object" || !("field" in r) || typeof r.field != "string" || t.has(r.field)) return;
|
|
@@ -1425,157 +1521,166 @@ function Ce(e) {
|
|
|
1425
1521
|
}
|
|
1426
1522
|
return t;
|
|
1427
1523
|
}
|
|
1428
|
-
function
|
|
1524
|
+
function sn(e, t, r) {
|
|
1429
1525
|
return !e.startsWith("$.template.params") || t === "moved" ? !1 : /\.(?:type|required|min|max|minLength|maxLength|options|defaultValue)(?:\[|$)/.test(e) ? !0 : t !== "added" ? !1 : Array.isArray(r) ? r.some((n) => !!n && typeof n == "object" && "required" in n && n.required === !0) : !!r && typeof r == "object" && "required" in r && r.required === !0;
|
|
1430
1526
|
}
|
|
1431
|
-
function
|
|
1432
|
-
const n =
|
|
1527
|
+
function cn(e, t, r = {}) {
|
|
1528
|
+
const n = de(e), o = de(t), a = r.maxChanges ?? 500;
|
|
1433
1529
|
if (!Number.isSafeInteger(a) || a < 1 || a > 1e4) throw new RangeError("maxChanges must be between 1 and 10000");
|
|
1434
1530
|
const s = { changes: [], totalChanges: 0, breakingChanges: 0, truncated: !1 };
|
|
1435
|
-
function
|
|
1436
|
-
const w =
|
|
1437
|
-
s.totalChanges++, g && s.breakingChanges++, s.changes.length < a && s.changes.push({ kind: d, category: w, path: u, before:
|
|
1531
|
+
function c(d, u, f, m) {
|
|
1532
|
+
const w = an(u), g = d !== "moved" && (w === "binding" || u === "$.id" || d === "removed" && w === "structure" || sn(u, d, m));
|
|
1533
|
+
s.totalChanges++, g && s.breakingChanges++, s.changes.length < a && s.changes.push({ kind: d, category: w, path: u, before: Fe(f), after: Fe(m), breaking: g });
|
|
1438
1534
|
}
|
|
1439
1535
|
function i(d, u, f) {
|
|
1440
|
-
const m =
|
|
1536
|
+
const m = Ae(d), w = Ae(u);
|
|
1441
1537
|
if (!m || !w) return !1;
|
|
1442
|
-
const g = new Map(u.map((
|
|
1443
|
-
Array.from(m).forEach(([
|
|
1444
|
-
const y = `${f}[${JSON.stringify(
|
|
1445
|
-
w.has(
|
|
1538
|
+
const g = new Map(u.map((p, v) => [p.field, v]));
|
|
1539
|
+
Array.from(m).forEach(([p, v], M) => {
|
|
1540
|
+
const y = `${f}[${JSON.stringify(p)}]`;
|
|
1541
|
+
w.has(p) ? (g.get(p) !== M && c("moved", y, M, g.get(p)), l(v, w.get(p), y)) : c("removed", y, v, void 0);
|
|
1446
1542
|
});
|
|
1447
|
-
for (const [
|
|
1543
|
+
for (const [p, v] of w) m.has(p) || c("added", `${f}[${JSON.stringify(p)}]`, void 0, v);
|
|
1448
1544
|
return !0;
|
|
1449
1545
|
}
|
|
1450
|
-
function
|
|
1546
|
+
function l(d, u, f) {
|
|
1451
1547
|
if (!(Object.is(d, u) || f === "$.revision")) {
|
|
1452
1548
|
if (d === void 0 || u === void 0) {
|
|
1453
|
-
|
|
1549
|
+
c(d === void 0 ? "added" : "removed", f, d, u);
|
|
1454
1550
|
return;
|
|
1455
1551
|
}
|
|
1456
1552
|
if (Array.isArray(d) && Array.isArray(u)) {
|
|
1457
1553
|
if ((f.endsWith(".columns") || f.endsWith(".params")) && i(d, u, f)) return;
|
|
1458
|
-
for (let m = 0; m < Math.max(d.length, u.length); m++)
|
|
1554
|
+
for (let m = 0; m < Math.max(d.length, u.length); m++) l(d[m], u[m], `${f}[${m}]`);
|
|
1459
1555
|
} else if (d && u && typeof d == "object" && typeof u == "object" && !Array.isArray(d) && !Array.isArray(u)) {
|
|
1460
1556
|
const m = d, w = u;
|
|
1461
|
-
for (const g of /* @__PURE__ */ new Set([...Object.keys(m), ...Object.keys(w)]))
|
|
1462
|
-
} else
|
|
1557
|
+
for (const g of /* @__PURE__ */ new Set([...Object.keys(m), ...Object.keys(w)])) l(m[g], w[g], `${f}.${g}`);
|
|
1558
|
+
} else c("modified", f, d, u);
|
|
1463
1559
|
}
|
|
1464
1560
|
}
|
|
1465
|
-
return
|
|
1561
|
+
return l(n, o, "$"), s.truncated = s.totalChanges > s.changes.length, s;
|
|
1466
1562
|
}
|
|
1467
|
-
function
|
|
1563
|
+
function E(e) {
|
|
1468
1564
|
return !!e && typeof e == "object" && !Array.isArray(e);
|
|
1469
1565
|
}
|
|
1470
1566
|
function T(e, t, r) {
|
|
1471
1567
|
typeof e == "string" ? r.push({ field: e, path: t }) : Array.isArray(e) && e.forEach((n, o) => T(n, `${t}[${o}]`, r));
|
|
1472
1568
|
}
|
|
1473
|
-
function
|
|
1569
|
+
function L(e, t, r) {
|
|
1474
1570
|
if (Array.isArray(e)) {
|
|
1475
|
-
e.forEach((n, o) =>
|
|
1571
|
+
e.forEach((n, o) => L(n, `${t}[${o}]`, r));
|
|
1476
1572
|
return;
|
|
1477
1573
|
}
|
|
1478
|
-
if (
|
|
1574
|
+
if (E(e))
|
|
1479
1575
|
for (const [n, o] of Object.entries(e))
|
|
1480
|
-
["field", "weightField"].includes(n) ? T(o, `${t}.${n}`, r) : n !== "value" && n !== "style" &&
|
|
1576
|
+
["field", "weightField"].includes(n) ? T(o, `${t}.${n}`, r) : n !== "value" && n !== "style" && L(o, `${t}.${n}`, r);
|
|
1481
1577
|
}
|
|
1482
|
-
function
|
|
1578
|
+
function X(e, t, r) {
|
|
1483
1579
|
Array.isArray(e) && e.forEach((n, o) => {
|
|
1484
|
-
|
|
1580
|
+
E(n) && (typeof n.field == "string" && n.valueField !== void 0 && n.valueField !== n.field && r.summaries.add(n.field), T(n.valueField ?? n.field, `${t}[${o}].valueField`, r.fields), T(n.weightField, `${t}[${o}].weightField`, r.fields));
|
|
1485
1581
|
});
|
|
1486
1582
|
}
|
|
1487
|
-
function
|
|
1583
|
+
function ln(e, t, r) {
|
|
1488
1584
|
for (const o of ["rowKey", "revisionField", "sourceTokenField"]) T(e[o], `${t}.${o}`, r.fields);
|
|
1489
1585
|
if (!e.matrix && Array.isArray(e.columns) && e.columns.forEach((o, a) => {
|
|
1490
|
-
|
|
1491
|
-
}),
|
|
1492
|
-
|
|
1586
|
+
E(o) && (typeof o.field == "string" && r.fields.push({ field: o.field, path: `${t}.columns[${a}].field`, summary: !0 }), L(o.rules, `${t}.columns[${a}].rules`, r.fields), L(o.visibleWhen, `${t}.columns[${a}].visibleWhen`, r.fields));
|
|
1587
|
+
}), L(e.rowVisibleWhen, `${t}.rowVisibleWhen`, r.fields), Array.isArray(e.computed) && e.computed.forEach((o, a) => {
|
|
1588
|
+
E(o) && (typeof o.field == "string" && r.generated.add(o.field), L(o.expression, `${t}.computed[${a}].expression`, r.fields), T(o.dependsOn, `${t}.computed[${a}].dependsOn`, r.fields), T(o.groupBy, `${t}.computed[${a}].groupBy`, r.fields));
|
|
1493
1589
|
}), (Array.isArray(e.groups) ? e.groups : e.groupBy ? [e.groupBy] : []).forEach((o, a) => {
|
|
1494
|
-
|
|
1495
|
-
}),
|
|
1590
|
+
E(o) && (T(o.field, `${t}.groups[${a}].field`, r.fields), T(o.subtotal, `${t}.groups[${a}].subtotal`, r.fields), X(o.aggregates, `${t}.groups[${a}].aggregates`, r));
|
|
1591
|
+
}), E(e.grandTotal) && (T(e.grandTotal.fields, `${t}.grandTotal.fields`, r.fields), X(e.grandTotal.aggregates, `${t}.grandTotal.aggregates`, r)), E(e.matrix) && (T(e.matrix.rowFields, `${t}.matrix.rowFields`, r.fields), T(e.matrix.columnFields, `${t}.matrix.columnFields`, r.fields), X(e.matrix.measures, `${t}.matrix.measures`, r)), E(e.tree)) {
|
|
1496
1592
|
for (const o of ["idField", "parentField", "labelField"]) T(e.tree[o], `${t}.tree.${o}`, r.fields);
|
|
1497
|
-
|
|
1593
|
+
X(e.tree.aggregates, `${t}.tree.aggregates`, r);
|
|
1498
1594
|
}
|
|
1499
|
-
|
|
1595
|
+
E(e.detail) && T(e.detail.parentKey, `${t}.detail.parentKey`, r.fields);
|
|
1500
1596
|
}
|
|
1501
|
-
function
|
|
1502
|
-
const t = [];
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1597
|
+
function vt(e) {
|
|
1598
|
+
const t = [], r = e.repeat, n = r ? { dataset: r.dataset, path: "$.template.repeat", fields: [], generated: /* @__PURE__ */ new Set(), summaries: /* @__PURE__ */ new Set() } : void 0;
|
|
1599
|
+
n && r && (T(r.rowKey, "$.template.repeat.rowKey", n.fields), typeof r.copies == "object" && T(r.copies.field, "$.template.repeat.copies.field", n.fields), t.push(n));
|
|
1600
|
+
function o(a, s) {
|
|
1601
|
+
if (Array.isArray(a)) {
|
|
1602
|
+
a.forEach((c, i) => o(c, `${s}[${i}]`));
|
|
1506
1603
|
return;
|
|
1507
1604
|
}
|
|
1508
|
-
if (
|
|
1509
|
-
if (
|
|
1510
|
-
const
|
|
1511
|
-
|
|
1605
|
+
if (E(a)) {
|
|
1606
|
+
if (n && E(a.binding) && T(a.binding.field, `${s}.binding.field`, n.fields), typeof a.dataset == "string" && Array.isArray(a.columns)) {
|
|
1607
|
+
const c = { dataset: a.dataset, path: s, fields: [], generated: /* @__PURE__ */ new Set(), summaries: /* @__PURE__ */ new Set() };
|
|
1608
|
+
ln(a, s, c), typeof a.foreignKey == "string" && T(a.foreignKey, `${s}.foreignKey`, c.fields), t.push(c);
|
|
1512
1609
|
}
|
|
1513
|
-
for (const [
|
|
1610
|
+
for (const [c, i] of Object.entries(a)) o(i, `${s}.${c}`);
|
|
1514
1611
|
}
|
|
1515
1612
|
}
|
|
1516
|
-
return
|
|
1613
|
+
return o(e, "$.template"), t;
|
|
1517
1614
|
}
|
|
1518
|
-
function
|
|
1519
|
-
for (const n of
|
|
1615
|
+
function dn(e, t, r) {
|
|
1616
|
+
for (const n of vt(e)) {
|
|
1520
1617
|
const o = Object.prototype.hasOwnProperty.call(t, n.dataset) ? t[n.dataset] : void 0;
|
|
1521
1618
|
if (!o) {
|
|
1522
1619
|
r.push({ code: "dataset", severity: "error", path: `${n.path}.dataset`, message: `未声明数据集 ${n.dataset}` });
|
|
1523
1620
|
continue;
|
|
1524
1621
|
}
|
|
1525
1622
|
const a = new Set(o.fields.map((s) => s.field));
|
|
1526
|
-
n.fields.forEach(({ field: s, path:
|
|
1527
|
-
!a.has(s) && !n.generated.has(s) && !(i && n.summaries.has(s)) && r.push({ code: "field", severity: "error", path:
|
|
1623
|
+
n.fields.forEach(({ field: s, path: c, summary: i }) => {
|
|
1624
|
+
!a.has(s) && !n.generated.has(s) && !(i && n.summaries.has(s)) && r.push({ code: "field", severity: "error", path: c, field: s, message: `数据集 ${n.dataset} 缺少字段 ${s}` });
|
|
1528
1625
|
});
|
|
1529
1626
|
}
|
|
1530
1627
|
}
|
|
1531
|
-
function
|
|
1628
|
+
function un(e, t, r, n) {
|
|
1532
1629
|
const o = r.maxSampleRows ?? 1e3;
|
|
1533
1630
|
let a;
|
|
1534
1631
|
try {
|
|
1535
|
-
a =
|
|
1632
|
+
a = Ie(t, e.datasets, { maxRows: o });
|
|
1536
1633
|
} catch (i) {
|
|
1537
1634
|
return n.push({ code: "sample", severity: "error", path: "$.fixtures", fixture: e.name, message: i instanceof Error ? i.message : String(i) }), !1;
|
|
1538
1635
|
}
|
|
1539
|
-
const s = Object.values(a).reduce((i,
|
|
1636
|
+
const s = Object.values(a).reduce((i, l) => i + l.length, 0);
|
|
1540
1637
|
if (s > o)
|
|
1541
1638
|
return n.push({ code: "sample", severity: "error", path: "$.fixtures", fixture: e.name, message: `样例 ${s} 行超过预算 ${o},请显式选择验收样例` }), !1;
|
|
1542
|
-
const
|
|
1543
|
-
for (const [i,
|
|
1639
|
+
const c = new Set(vt(t).map((i) => i.dataset));
|
|
1640
|
+
for (const [i, l] of Object.entries(r.dataSchemas ?? {}).filter(([d]) => c.has(d)))
|
|
1544
1641
|
try {
|
|
1545
|
-
const d =
|
|
1642
|
+
const d = Ke(a[i], l, { path: `$.datasets.${i}`, maxRows: o });
|
|
1546
1643
|
if (n.push(...d.issues.map((u) => ({ ...u, code: "sample", severity: "error", fixture: e.name }))), !d.ok) return !1;
|
|
1547
1644
|
} catch (d) {
|
|
1548
1645
|
return n.push({ code: "dataset", severity: "error", path: `$.dataSchemas.${i}`, message: String(d) }), !1;
|
|
1549
1646
|
}
|
|
1550
1647
|
return !0;
|
|
1551
1648
|
}
|
|
1552
|
-
function
|
|
1553
|
-
const
|
|
1554
|
-
if (
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1649
|
+
function fn(e, t) {
|
|
1650
|
+
const r = e.pages[t.pageIndex]?.components[t.componentIndex]?.meta?.labelSource;
|
|
1651
|
+
if (r && typeof r == "object" && "pageIndex" in r && "componentIndex" in r && typeof r.pageIndex == "number" && typeof r.componentIndex == "number") return { path: `$.template.pages[${r.pageIndex}].components[${r.componentIndex}]`, pageIndex: r.pageIndex, componentIndex: r.componentIndex };
|
|
1652
|
+
const n = e.pages[t.pageIndex]?.meta?.record;
|
|
1653
|
+
if (n && typeof n == "object" && "templatePageIndex" in n && typeof n.templatePageIndex == "number") return { path: `$.template.pages[${n.templatePageIndex}].components[${t.componentIndex}]`, pageIndex: n.templatePageIndex, componentIndex: t.componentIndex };
|
|
1654
|
+
}
|
|
1655
|
+
function mn(e, t, r) {
|
|
1656
|
+
const n = fn(t, r);
|
|
1657
|
+
if (n) return n;
|
|
1658
|
+
const o = t.pages[r.pageIndex]?.components[r.componentIndex], a = /^table:(\d+):(\d+)(?::|$)/.exec(o?.table?.id ?? "");
|
|
1659
|
+
if (a) return { path: `$.template.pages[${a[1]}].components[${a[2]}]`, pageIndex: Number(a[1]), componentIndex: Number(a[2]) };
|
|
1660
|
+
for (const [s, c] of e.pages.entries()) {
|
|
1661
|
+
const i = c.components.findIndex((l) => l === o || o?.nid !== void 0 && "nid" in l && l.nid === o.nid);
|
|
1662
|
+
if (i >= 0) return { path: `$.template.pages[${s}].components[${i}]`, pageIndex: s, componentIndex: i };
|
|
1558
1663
|
}
|
|
1559
1664
|
return { path: "$.template" };
|
|
1560
1665
|
}
|
|
1561
|
-
function
|
|
1562
|
-
const a =
|
|
1563
|
-
if (o.issues.push(...a.issues.map((s) => ({ ...s, code: "params", severity: "error", fixture: t.name, path: s.path.replace(/^\$\.params/, `$.fixtures[${r}].params`) }))), !!a.ok &&
|
|
1666
|
+
function gn(e, t, r, n, o) {
|
|
1667
|
+
const a = kt(e.template.params ?? [], t.params ?? {});
|
|
1668
|
+
if (o.issues.push(...a.issues.map((s) => ({ ...s, code: "params", severity: "error", fixture: t.name, path: s.path.replace(/^\$\.params/, `$.fixtures[${r}].params`) }))), !!a.ok && un(t, e.template, n, o.issues))
|
|
1564
1669
|
try {
|
|
1565
|
-
const { plan: s, warnings:
|
|
1566
|
-
o.issues.push(...
|
|
1670
|
+
const { plan: s, warnings: c } = xe(e.template, t.datasets, { maxPages: n.maxPages ?? 100, maxCells: n.maxCells ?? 25e4 }), i = (n.formats ?? ["pdf", "xlsx"]).flatMap((l) => zt(s, l));
|
|
1671
|
+
o.issues.push(...c.map((l) => ({ code: "layout", severity: "warning", path: "$.template", fixture: t.name, message: l }))), o.issues.push(...i.map((l) => ({ code: "output", severity: n.strictOutputs ? "error" : "warning", ...mn(e.template, s, l), fixture: t.name, message: `${l.format}: ${l.message}`, diagnostic: l }))), o.samples.push({ name: t.name, pages: s.pages.length, rows: Xr(e.template, t.datasets), diagnostics: i });
|
|
1567
1672
|
} catch (s) {
|
|
1568
1673
|
o.issues.push({ code: "layout", severity: "error", path: "$.template", fixture: t.name, message: s instanceof Error ? s.message : String(s) });
|
|
1569
1674
|
}
|
|
1570
1675
|
}
|
|
1571
|
-
function
|
|
1676
|
+
function zn(e, t = {}) {
|
|
1572
1677
|
const r = { ok: !1, issues: [], samples: [] };
|
|
1573
1678
|
try {
|
|
1574
1679
|
for (const [o, a] of [["maxPages", t.maxPages], ["maxCells", t.maxCells], ["maxSampleRows", t.maxSampleRows]]) if (a !== void 0 && (!Number.isSafeInteger(a) || a < 1)) throw new RangeError(`${o} must be a positive safe integer`);
|
|
1575
1680
|
if ((t.fixtures?.length ?? 0) > 20) throw new RangeError("At most 20 review fixtures are allowed");
|
|
1576
|
-
const n =
|
|
1577
|
-
t.previous && (r.changes =
|
|
1578
|
-
for (const [o, a] of (t.fixtures ?? []).entries())
|
|
1681
|
+
const n = de(e);
|
|
1682
|
+
t.previous && (r.changes = cn(t.previous, n), r.changes.breakingChanges && !t.allowBreakingChanges && r.issues.push({ code: "compatibility", severity: "error", path: "$.template", message: `${r.changes.breakingChanges} 项字段或结构变更需要明确确认兼容性` })), t.dataSchemas && dn(n.template, t.dataSchemas, r.issues);
|
|
1683
|
+
for (const [o, a] of (t.fixtures ?? []).entries()) gn(n, a, o, t, r);
|
|
1579
1684
|
t.fixtures?.length || r.issues.push({ code: "sample", severity: "warning", path: "$.fixtures", message: "未提供验收样例,仅完成结构和字段检查,尚未验证排版与输出" });
|
|
1580
1685
|
} catch (n) {
|
|
1581
1686
|
r.issues.push({ code: "template", severity: "error", path: "$", message: n instanceof Error ? n.message : String(n) });
|
|
@@ -1583,34 +1688,35 @@ function Tn(e, t = {}) {
|
|
|
1583
1688
|
return r.ok = r.issues.every((n) => n.severity !== "error"), r;
|
|
1584
1689
|
}
|
|
1585
1690
|
export {
|
|
1586
|
-
|
|
1587
|
-
|
|
1691
|
+
Dn as A,
|
|
1692
|
+
Xr as B,
|
|
1693
|
+
Yt as D,
|
|
1588
1694
|
V as P,
|
|
1589
1695
|
b as R,
|
|
1590
|
-
|
|
1696
|
+
H as a,
|
|
1591
1697
|
S as b,
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1698
|
+
Kn as c,
|
|
1699
|
+
Nn as d,
|
|
1700
|
+
Wr as e,
|
|
1701
|
+
Fn as f,
|
|
1702
|
+
On as g,
|
|
1703
|
+
jn as h,
|
|
1704
|
+
W as i,
|
|
1705
|
+
Wn as j,
|
|
1706
|
+
Gn as k,
|
|
1707
|
+
Vn as l,
|
|
1708
|
+
cn as m,
|
|
1709
|
+
An as n,
|
|
1710
|
+
_ as o,
|
|
1711
|
+
st as p,
|
|
1712
|
+
Se as q,
|
|
1713
|
+
Bn as r,
|
|
1714
|
+
xe as s,
|
|
1715
|
+
Tr as t,
|
|
1716
|
+
qt as u,
|
|
1717
|
+
pt as v,
|
|
1718
|
+
Hn as w,
|
|
1719
|
+
A as x,
|
|
1720
|
+
zn as y,
|
|
1721
|
+
Ln as z
|
|
1616
1722
|
};
|