@agile-team/mach-report 0.8.0 → 0.9.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/LICENSE +107 -0
- package/dist/ReportPreview-BFTfls8h.js +923 -0
- package/dist/ReportPreview-D6VHDUvR.cjs +6 -0
- package/dist/format.d.ts +16 -3
- package/dist/index.cjs +4 -4
- package/dist/index.js +433 -419
- package/dist/layout/paginate.d.ts +1 -2
- package/dist/{plugin-7W2Zy3Xc.cjs → plugin-9eBK7khj.cjs} +1 -1
- package/dist/{plugin-Bc6Px9Lq.js → plugin-vi2GjP43.js} +1 -1
- package/dist/style.css +1 -1
- package/dist/vue/ReportPreview.d.ts +1 -1
- package/dist/vue/ReportToolbar.d.ts +5 -3
- package/dist/vue/async.d.cts +3 -3
- package/dist/vue/async.d.ts +3 -3
- package/dist/vue/composables/usePageWindow.d.ts +0 -3
- package/dist/vue/composables/usePrintExport.d.ts +1 -0
- package/dist/vue/composables/useReportSearch.d.ts +72 -0
- package/dist/vue/config.d.ts +8 -1
- package/dist/vue/plugin.d.ts +3 -3
- package/dist/vue-async.cjs +1 -1
- package/dist/vue-async.js +3 -3
- package/dist/vue.cjs +1 -1
- package/dist/vue.js +26 -25
- package/dist/xlsx.cjs +4 -4
- package/dist/xlsx.js +31 -30
- package/package.json +3 -1
- package/dist/ReportPreview-BQE0C_37.cjs +0 -6
- package/dist/ReportPreview-D8X75aLV.js +0 -825
package/dist/index.js
CHANGED
|
@@ -1,42 +1,57 @@
|
|
|
1
|
-
import { h as
|
|
2
|
-
import { C as
|
|
1
|
+
import { h as ot, R as At, D as X, w as Z, L as Q, i as Et, r as G, m as $t, a as V, b as ut, c as O, d as tt, p as K, e as Ht, f as pt, g as Nt, P as ht } from "./style-6ihHKVCM.js";
|
|
2
|
+
import { C as be, j as ye, k as we, M as Se, S as Te, l as xe, n as ke, o as ve, q as Ce, s as Pe, t as Ae, u as Ee, v as $e, x as He } from "./style-6ihHKVCM.js";
|
|
3
3
|
import { r as Rt } from "./grid-geometry-Bs8QXz1X.js";
|
|
4
|
-
function
|
|
5
|
-
|
|
4
|
+
function Bt(t) {
|
|
5
|
+
const e = /^(\d{4})[-/](\d{1,2})[-/](\d{1,2})$/.exec(t.trim());
|
|
6
|
+
if (e) {
|
|
7
|
+
const n = new Date(Number(e[1]), Number(e[2]) - 1, Number(e[3]));
|
|
8
|
+
return Number.isNaN(n.getTime()) ? null : n;
|
|
9
|
+
}
|
|
10
|
+
const r = new Date(t);
|
|
11
|
+
return Number.isNaN(r.getTime()) ? null : r;
|
|
12
|
+
}
|
|
13
|
+
function nt(t, e) {
|
|
14
|
+
return t.toLocaleString("en-US", {
|
|
6
15
|
minimumFractionDigits: e,
|
|
7
16
|
maximumFractionDigits: e
|
|
8
|
-
})
|
|
17
|
+
});
|
|
9
18
|
}
|
|
10
|
-
function
|
|
11
|
-
const r = (n
|
|
19
|
+
function Lt(t, e) {
|
|
20
|
+
const r = (n) => String(n).padStart(2, "0");
|
|
12
21
|
return e.replace(/YYYY/g, String(t.getFullYear())).replace(/MM/g, r(t.getMonth() + 1)).replace(/DD/g, r(t.getDate())).replace(/hh/g, r(t.getHours())).replace(/mm/g, r(t.getMinutes())).replace(/ss/g, r(t.getSeconds()));
|
|
13
22
|
}
|
|
23
|
+
function Ft(t, e, r) {
|
|
24
|
+
return r != null ? e ? nt(t, r) : t.toFixed(r) : e ? nt(t) : String(t);
|
|
25
|
+
}
|
|
26
|
+
function rt(t) {
|
|
27
|
+
const e = typeof t == "number" ? t : Number(String(t).replace(/,/g, ""));
|
|
28
|
+
return Number.isFinite(e) ? e : null;
|
|
29
|
+
}
|
|
14
30
|
function Mt(t, e) {
|
|
15
31
|
if (t == null || t === "" || !e) return String(t ?? "");
|
|
16
32
|
switch (e.kind) {
|
|
17
33
|
case "number": {
|
|
18
|
-
const r =
|
|
19
|
-
return
|
|
34
|
+
const r = rt(t);
|
|
35
|
+
return r == null ? String(t) : Ft(r, e.thousands === !0, e.digits);
|
|
20
36
|
}
|
|
21
37
|
case "percent": {
|
|
22
|
-
const r =
|
|
23
|
-
|
|
24
|
-
const n = e.digits ?? 2;
|
|
25
|
-
return `${ht(r * 100, n)}%`;
|
|
38
|
+
const r = rt(t);
|
|
39
|
+
return r == null ? String(t) : `${nt(r * 100, e.digits ?? 2)}%`;
|
|
26
40
|
}
|
|
27
41
|
case "date": {
|
|
28
|
-
const r = e.pattern ?? "YYYY-MM-DD", n = t instanceof Date ? t :
|
|
29
|
-
return
|
|
42
|
+
const r = e.pattern ?? "YYYY-MM-DD", n = t instanceof Date ? t : Bt(String(t));
|
|
43
|
+
return n ? Lt(n, r) : String(t);
|
|
30
44
|
}
|
|
31
45
|
default:
|
|
32
46
|
return String(t);
|
|
33
47
|
}
|
|
34
48
|
}
|
|
35
|
-
function
|
|
49
|
+
function zt(t, e) {
|
|
36
50
|
const r = t[e.field];
|
|
51
|
+
if (r == null || r === "") return !1;
|
|
37
52
|
if (typeof e.value == "number") {
|
|
38
|
-
const s =
|
|
39
|
-
if (
|
|
53
|
+
const s = rt(r);
|
|
54
|
+
if (s == null) return !1;
|
|
40
55
|
switch (e.op) {
|
|
41
56
|
case ">":
|
|
42
57
|
return s > e.value;
|
|
@@ -52,24 +67,24 @@ function Bt(t, e) {
|
|
|
52
67
|
return s !== e.value;
|
|
53
68
|
}
|
|
54
69
|
}
|
|
55
|
-
const n = String(r
|
|
70
|
+
const n = String(r), o = String(e.value);
|
|
56
71
|
switch (e.op) {
|
|
57
72
|
case "==":
|
|
58
|
-
return n ===
|
|
73
|
+
return n === o;
|
|
59
74
|
case "!=":
|
|
60
|
-
return n !==
|
|
75
|
+
return n !== o;
|
|
61
76
|
case ">":
|
|
62
|
-
return n >
|
|
77
|
+
return n > o;
|
|
63
78
|
case ">=":
|
|
64
|
-
return n >=
|
|
79
|
+
return n >= o;
|
|
65
80
|
case "<":
|
|
66
|
-
return n <
|
|
81
|
+
return n < o;
|
|
67
82
|
case "<=":
|
|
68
|
-
return n <=
|
|
83
|
+
return n <= o;
|
|
69
84
|
}
|
|
70
85
|
return !1;
|
|
71
86
|
}
|
|
72
|
-
const
|
|
87
|
+
const Dt = /* @__PURE__ */ new Set([
|
|
73
88
|
"text",
|
|
74
89
|
"image",
|
|
75
90
|
"barcode",
|
|
@@ -82,53 +97,53 @@ const Ft = /* @__PURE__ */ new Set([
|
|
|
82
97
|
function I(t) {
|
|
83
98
|
return typeof t == "object" && t !== null && !Array.isArray(t);
|
|
84
99
|
}
|
|
85
|
-
function
|
|
86
|
-
const
|
|
87
|
-
|
|
100
|
+
function _t(t, e, r, n) {
|
|
101
|
+
const o = t[e];
|
|
102
|
+
o != null && (typeof o != "number" || !Number.isFinite(o)) && n.push({ path: `${r}.${e}`, message: `应为有限数字,实际 ${JSON.stringify(o)}` });
|
|
88
103
|
}
|
|
89
104
|
function bt(t, e, r, n = []) {
|
|
90
105
|
if (!I(t)) {
|
|
91
106
|
r.push({ path: e, message: "组件应为对象" });
|
|
92
107
|
return;
|
|
93
108
|
}
|
|
94
|
-
const
|
|
95
|
-
typeof
|
|
109
|
+
const o = t.kind;
|
|
110
|
+
typeof o != "string" ? r.push({ path: `${e}.kind`, message: "组件缺少 kind 字符串" }) : Dt.has(o) || n.push({
|
|
96
111
|
path: `${e}.kind`,
|
|
97
|
-
message: `未知组件类型 ${JSON.stringify(
|
|
112
|
+
message: `未知组件类型 ${JSON.stringify(o)},将以兜底方式渲染`
|
|
98
113
|
});
|
|
99
|
-
for (const
|
|
100
|
-
|
|
114
|
+
for (const i of ["leftMm", "topMm", "widthMm", "heightMm"])
|
|
115
|
+
_t(t, i, e, r);
|
|
101
116
|
t.leftMm != null && t.widthMm != null && (t.leftMm < -100 || t.widthMm < 0) && r.push({ path: e, message: "几何数值异常(leftMm<-100 或 widthMm<0)" });
|
|
102
117
|
const s = t.grid;
|
|
103
|
-
s !== void 0 && (!I(s) || !Array.isArray(s.cells) ? r.push({ path: `${e}.grid.cells`, message: "grid.cells 应为二维数组" }) : s.cells.forEach((
|
|
104
|
-
if (!Array.isArray(
|
|
118
|
+
s !== void 0 && (!I(s) || !Array.isArray(s.cells) ? r.push({ path: `${e}.grid.cells`, message: "grid.cells 应为二维数组" }) : s.cells.forEach((i, d) => {
|
|
119
|
+
if (!Array.isArray(i)) {
|
|
105
120
|
r.push({ path: `${e}.grid.cells.${d}`, message: "行应为数组" });
|
|
106
121
|
return;
|
|
107
122
|
}
|
|
108
|
-
|
|
109
|
-
c != null && I(c) && Array.isArray(c.children) && c.children.forEach((
|
|
110
|
-
bt(
|
|
123
|
+
i.forEach((c, h) => {
|
|
124
|
+
c != null && I(c) && Array.isArray(c.children) && c.children.forEach((m, l) => {
|
|
125
|
+
bt(m, `${e}.grid.cells.${d}.${h}.children.${l}`, r, n);
|
|
111
126
|
});
|
|
112
127
|
});
|
|
113
128
|
}));
|
|
114
129
|
const a = t.richParagraphs;
|
|
115
|
-
a !== void 0 && (Array.isArray(a) ? a.forEach((
|
|
116
|
-
(!I(
|
|
130
|
+
a !== void 0 && (Array.isArray(a) ? a.forEach((i, d) => {
|
|
131
|
+
(!I(i) || !Array.isArray(i.segments)) && r.push({ path: `${e}.richParagraphs.${d}`, message: "段落缺少 segments 数组" });
|
|
117
132
|
}) : r.push({ path: `${e}.richParagraphs`, message: "richParagraphs 应为数组" }));
|
|
118
133
|
}
|
|
119
|
-
function
|
|
134
|
+
function Wt(t, e, r, n = []) {
|
|
120
135
|
if (!I(t)) {
|
|
121
136
|
r.push({ path: e, message: "页应为对象" });
|
|
122
137
|
return;
|
|
123
138
|
}
|
|
124
|
-
const
|
|
125
|
-
(typeof
|
|
139
|
+
const o = t.pageWidthMm, s = t.pageHeightMm;
|
|
140
|
+
(typeof o != "number" || !(o > 0 && o < 3e3)) && r.push({ path: `${e}.pageWidthMm`, message: `页宽非法: ${JSON.stringify(o)}` }), (typeof s != "number" || !(s > 0 && s < 5e3)) && r.push({ path: `${e}.pageHeightMm`, message: `页高非法: ${JSON.stringify(s)}` });
|
|
126
141
|
const a = t.components;
|
|
127
142
|
a !== void 0 && !Array.isArray(a) ? r.push({ path: `${e}.components`, message: "components 应为数组" }) : Array.isArray(a) && a.forEach(
|
|
128
|
-
(
|
|
143
|
+
(i, d) => bt(i, `${e}.components.${d}`, r, n)
|
|
129
144
|
);
|
|
130
145
|
}
|
|
131
|
-
function
|
|
146
|
+
function It(t) {
|
|
132
147
|
const e = [], r = [], n = I(t) ? t.pages : void 0;
|
|
133
148
|
if (!Array.isArray(n))
|
|
134
149
|
e.push({
|
|
@@ -136,30 +151,30 @@ function _t(t) {
|
|
|
136
151
|
message: t == null ? "渲染计划为空" : "渲染计划缺少 pages 数组"
|
|
137
152
|
});
|
|
138
153
|
else {
|
|
139
|
-
n.forEach((s, a) =>
|
|
154
|
+
n.forEach((s, a) => Wt(s, `$.pages.${a}`, e, r)), n.length > 2e3 && r.push({
|
|
140
155
|
path: "$.pages",
|
|
141
156
|
message: `页数异常大(${n.length} 页),渲染与打印耗时可能显著增加`
|
|
142
157
|
});
|
|
143
|
-
const
|
|
158
|
+
const o = n.reduce(
|
|
144
159
|
(s, a) => s + (I(a) && Array.isArray(a.components) ? a.components.length : 0),
|
|
145
160
|
0
|
|
146
161
|
);
|
|
147
|
-
|
|
162
|
+
o > 5e4 && r.push({
|
|
148
163
|
path: "$.pages",
|
|
149
|
-
message: `组件总数异常大(${
|
|
164
|
+
message: `组件总数异常大(${o} 个),可能触发浏览器性能限制`
|
|
150
165
|
});
|
|
151
166
|
}
|
|
152
167
|
return { ok: e.length === 0, errors: e, warnings: r };
|
|
153
168
|
}
|
|
154
|
-
function
|
|
155
|
-
const e =
|
|
169
|
+
function le(t) {
|
|
170
|
+
const e = It(t);
|
|
156
171
|
if (!e.ok) {
|
|
157
172
|
const r = e.errors.slice(0, 3).map((n) => `${n.path}: ${n.message}`).join("; ");
|
|
158
173
|
throw new Error(`渲染计划校验失败(${e.errors.length} 处): ${r}`);
|
|
159
174
|
}
|
|
160
175
|
return t.pages;
|
|
161
176
|
}
|
|
162
|
-
function
|
|
177
|
+
function mt(t) {
|
|
163
178
|
return {
|
|
164
179
|
widthMm: t.widthMm,
|
|
165
180
|
heightMm: t.heightMm,
|
|
@@ -170,14 +185,14 @@ function gt(t) {
|
|
|
170
185
|
components: []
|
|
171
186
|
};
|
|
172
187
|
}
|
|
173
|
-
function
|
|
188
|
+
function jt(t, e) {
|
|
174
189
|
return e.heightMm - (t.marginBottomMm ?? e.marginBottomMm);
|
|
175
190
|
}
|
|
176
|
-
function
|
|
177
|
-
const n = (t.fontSizePt ?? X) * Q * 25.4 / 72,
|
|
178
|
-
return Math.max(t.rowHeightMm ?? 0, e * n +
|
|
191
|
+
function Ot(t, e) {
|
|
192
|
+
const n = (t.fontSizePt ?? X) * Q * 25.4 / 72, o = (t.paddingMm ?? 1) * 2;
|
|
193
|
+
return Math.max(t.rowHeightMm ?? 0, e * n + o);
|
|
179
194
|
}
|
|
180
|
-
function
|
|
195
|
+
function yt(t) {
|
|
181
196
|
if (t == null) return "";
|
|
182
197
|
if (typeof t == "string") return t;
|
|
183
198
|
if (typeof t == "number") return String(t);
|
|
@@ -189,8 +204,8 @@ function nt(t) {
|
|
|
189
204
|
return String(t);
|
|
190
205
|
}
|
|
191
206
|
}
|
|
192
|
-
function
|
|
193
|
-
const r = t.fontSizePt ?? X, n = t.paddingMm ?? 1,
|
|
207
|
+
function Gt(t, e) {
|
|
208
|
+
const r = t.fontSizePt ?? X, n = t.paddingMm ?? 1, o = t.columns.map(
|
|
194
209
|
(l) => l.style ? { align: "left", verticalAlign: "middle", ...l.style } : { align: "left", verticalAlign: "middle" }
|
|
195
210
|
), s = t.columns.map(
|
|
196
211
|
(l) => ({
|
|
@@ -200,69 +215,69 @@ function It(t, e) {
|
|
|
200
215
|
backgroundColor: t.headerBackgroundColor,
|
|
201
216
|
...l.style || {}
|
|
202
217
|
})
|
|
203
|
-
), a = t.columns.map((l) => l.header),
|
|
218
|
+
), a = t.columns.map((l) => l.header), i = a.map(
|
|
204
219
|
(l, f) => Z(
|
|
205
220
|
l,
|
|
206
221
|
t.columns[f].widthMm - n * 2,
|
|
207
222
|
{ fontSizePt: r, bold: t.headerBold ?? !0 },
|
|
208
223
|
e
|
|
209
224
|
)
|
|
210
|
-
), d = Math.max(...
|
|
225
|
+
), d = Math.max(...i.map((l) => l.length), 1), c = Ot(t, d), h = a.map((l, f) => ({
|
|
211
226
|
text: l,
|
|
212
227
|
style: s[f]
|
|
213
|
-
})),
|
|
228
|
+
})), m = t.border === !1 ? { borderTop: !1, borderRight: !1, borderBottom: !1, borderLeft: !1 } : { borderBottom: !0, borderLeft: !0, borderRight: !0, borderTop: !0 };
|
|
214
229
|
return {
|
|
215
230
|
fontSizePt: r,
|
|
216
231
|
paddingMm: n,
|
|
217
|
-
cellStyles:
|
|
218
|
-
borderStyle:
|
|
232
|
+
cellStyles: o,
|
|
233
|
+
borderStyle: m,
|
|
219
234
|
headerHeightMm: c,
|
|
220
235
|
headerGrid: { cells: [h], rowHeightsMm: [c] },
|
|
221
236
|
columns: t.columns
|
|
222
237
|
};
|
|
223
238
|
}
|
|
224
|
-
function
|
|
225
|
-
const n = t.columns,
|
|
239
|
+
function gt(t, e, r) {
|
|
240
|
+
const n = t.columns, o = new Array(n.length);
|
|
226
241
|
let s = 1;
|
|
227
242
|
for (let h = 0; h < n.length; h++) {
|
|
228
|
-
const
|
|
229
|
-
|
|
243
|
+
const m = n[h];
|
|
244
|
+
o[h] = m.format ? Mt(e[m.field], m.format) : yt(e[m.field]);
|
|
230
245
|
}
|
|
231
246
|
const a = new Array(n.length);
|
|
232
247
|
for (let h = 0; h < n.length; h++) {
|
|
233
|
-
const
|
|
234
|
-
|
|
248
|
+
const m = Z(
|
|
249
|
+
o[h],
|
|
235
250
|
n[h].widthMm - t.paddingMm * 2,
|
|
236
251
|
{ fontSizePt: t.fontSizePt },
|
|
237
252
|
r
|
|
238
253
|
);
|
|
239
|
-
a[h] =
|
|
254
|
+
a[h] = m, m.length > s && (s = m.length);
|
|
240
255
|
}
|
|
241
|
-
const
|
|
256
|
+
const i = t.fontSizePt * Q * 25.4 / 72, d = Math.max(
|
|
242
257
|
t.rowHeightFloorMm,
|
|
243
|
-
s *
|
|
258
|
+
s * i + t.paddingMm * 2
|
|
244
259
|
), c = new Array(n.length);
|
|
245
260
|
for (let h = 0; h < n.length; h++) {
|
|
246
|
-
const
|
|
261
|
+
const m = n[h];
|
|
247
262
|
let l = t.cellStyles[h];
|
|
248
|
-
if (
|
|
249
|
-
for (const f of
|
|
250
|
-
if (
|
|
263
|
+
if (m.rules) {
|
|
264
|
+
for (const f of m.rules)
|
|
265
|
+
if (zt(e, f.when)) {
|
|
251
266
|
l = { ...l ?? {}, ...f.style };
|
|
252
267
|
break;
|
|
253
268
|
}
|
|
254
269
|
}
|
|
255
|
-
c[h] = { text:
|
|
270
|
+
c[h] = { text: o[h], style: l };
|
|
256
271
|
}
|
|
257
272
|
return { grid: { cells: [c], rowHeightsMm: [d] }, heightMm: d };
|
|
258
273
|
}
|
|
259
|
-
function
|
|
260
|
-
const n = typeof r == "number" ? { mmPerRow: r } : r,
|
|
274
|
+
function de(t, e, r = {}) {
|
|
275
|
+
const n = typeof r == "number" ? { mmPerRow: r } : r, o = n.mmPerRow ?? 0, s = n.measurer ?? ot, a = [], i = [];
|
|
261
276
|
let d = 0;
|
|
262
|
-
const c = (
|
|
263
|
-
for (const
|
|
264
|
-
const l =
|
|
265
|
-
if (
|
|
277
|
+
const c = (m) => `${m}_${(++d).toString(36)}`, h = [];
|
|
278
|
+
for (const m of t.pages) {
|
|
279
|
+
const l = mt(m), f = () => jt(m, l), g = l.marginTopMm, w = [], E = () => {
|
|
280
|
+
if (i.push({
|
|
266
281
|
pageWidthMm: l.widthMm,
|
|
267
282
|
pageHeightMm: l.heightMm,
|
|
268
283
|
marginTopMm: l.marginTopMm,
|
|
@@ -271,33 +286,33 @@ function se(t, e, r = {}) {
|
|
|
271
286
|
marginRightMm: l.marginRightMm,
|
|
272
287
|
components: l.components
|
|
273
288
|
}), w.length > 0) {
|
|
274
|
-
const
|
|
289
|
+
const x = i.length;
|
|
275
290
|
for (const b of w) {
|
|
276
291
|
const C = {
|
|
277
292
|
...b,
|
|
278
|
-
text: String(b.text ?? "").replace(/\{page\}/g, String(
|
|
293
|
+
text: String(b.text ?? "").replace(/\{page\}/g, String(x))
|
|
279
294
|
};
|
|
280
|
-
|
|
295
|
+
i[i.length - 1].components.push(C), C.text.includes("{totalPages}") && h.push(C);
|
|
281
296
|
}
|
|
282
297
|
}
|
|
283
298
|
};
|
|
284
|
-
for (const
|
|
285
|
-
if (
|
|
286
|
-
if (
|
|
287
|
-
const p =
|
|
299
|
+
for (const x of m.components) {
|
|
300
|
+
if (x.kind !== "list") {
|
|
301
|
+
if (x.kind === "text" && typeof x.text == "string") {
|
|
302
|
+
const p = x.text;
|
|
288
303
|
if (p.includes("{page}") || p.includes("{totalPages}")) {
|
|
289
|
-
w.push(
|
|
304
|
+
w.push(x);
|
|
290
305
|
continue;
|
|
291
306
|
}
|
|
292
307
|
}
|
|
293
|
-
l.components.push(
|
|
308
|
+
l.components.push(x);
|
|
294
309
|
continue;
|
|
295
310
|
}
|
|
296
|
-
const b =
|
|
311
|
+
const b = x, C = e[b.dataset];
|
|
297
312
|
Array.isArray(C) || a.push(`数据集 ${b.dataset} 未提供数据,列表 ${b.id ?? ""} 输出为空`);
|
|
298
|
-
const S = Array.isArray(C) ? C : [], J = b.columns.reduce((p, M) => p + M.widthMm, 0), q = J > b.widthMm ? b.widthMm / J : 1,
|
|
299
|
-
...
|
|
300
|
-
rowHeightFloorMm:
|
|
313
|
+
const S = Array.isArray(C) ? C : [], J = b.columns.reduce((p, M) => p + M.widthMm, 0), q = J > b.widthMm ? b.widthMm / J : 1, k = q === 1 ? b : { ...b, columns: b.columns.map((p) => ({ ...p, widthMm: p.widthMm * q })) }, $ = {
|
|
314
|
+
...Gt(k, s),
|
|
315
|
+
rowHeightFloorMm: k.rowHeightMm ?? 0
|
|
301
316
|
}, j = {
|
|
302
317
|
kind: "rect",
|
|
303
318
|
leftMm: b.leftMm,
|
|
@@ -312,14 +327,14 @@ function se(t, e, r = {}) {
|
|
|
312
327
|
const H = (p, M) => {
|
|
313
328
|
p.components.push({ ...j, topMm: M });
|
|
314
329
|
};
|
|
315
|
-
H(l, u), u += $.headerHeightMm +
|
|
330
|
+
H(l, u), u += $.headerHeightMm + o;
|
|
316
331
|
const L = (p) => {
|
|
317
332
|
if (u + p > f()) {
|
|
318
333
|
E();
|
|
319
|
-
const M =
|
|
320
|
-
l.components = M.components, l.heightMm = M.heightMm,
|
|
334
|
+
const M = mt(m);
|
|
335
|
+
l.components = M.components, l.heightMm = M.heightMm, k.headerEveryPage !== !1 ? (H(l, b.topMm), u = b.topMm + $.headerHeightMm) : u = g;
|
|
321
336
|
}
|
|
322
|
-
}, y = (p, M,
|
|
337
|
+
}, y = (p, M, T) => {
|
|
323
338
|
L(M), l.components.push({
|
|
324
339
|
kind: "rect",
|
|
325
340
|
leftMm: b.leftMm,
|
|
@@ -327,86 +342,83 @@ function se(t, e, r = {}) {
|
|
|
327
342
|
widthMm: b.widthMm,
|
|
328
343
|
heightMm: M,
|
|
329
344
|
grid: p,
|
|
330
|
-
nid: c(
|
|
345
|
+
nid: c(T),
|
|
331
346
|
style: $.borderStyle
|
|
332
347
|
}), u += M;
|
|
333
|
-
},
|
|
334
|
-
const
|
|
335
|
-
|
|
336
|
-
for (let et =
|
|
337
|
-
const
|
|
338
|
-
|
|
348
|
+
}, N = () => gt($, {}, s).heightMm, P = (p, M, T, v) => {
|
|
349
|
+
const D = [], dt = Math.max(1, Math.min(v, k.columns.length));
|
|
350
|
+
D.push({ text: p, colSpan: dt, style: { bold: !0, ...T } });
|
|
351
|
+
for (let et = dt; et < k.columns.length; et++) {
|
|
352
|
+
const Pt = k.columns[et];
|
|
353
|
+
D.push({ text: M.get(Pt.field) ?? "", style: T });
|
|
339
354
|
}
|
|
340
|
-
const
|
|
341
|
-
return { grid: { cells: [
|
|
342
|
-
},
|
|
343
|
-
let
|
|
355
|
+
const Ct = $.fontSizePt * Q * 25.4 / 72, ct = Math.max($.rowHeightFloorMm, Ct + $.paddingMm * 2);
|
|
356
|
+
return { grid: { cells: [D], rowHeightsMm: [ct] }, heightMm: ct };
|
|
357
|
+
}, _ = (p, M) => {
|
|
358
|
+
let T = 0;
|
|
344
359
|
for (const v of p) {
|
|
345
|
-
const
|
|
346
|
-
Number.isFinite(
|
|
360
|
+
const D = typeof v[M] == "number" ? v[M] : Number(v[M]);
|
|
361
|
+
Number.isFinite(D) && (T += D);
|
|
347
362
|
}
|
|
348
|
-
return
|
|
363
|
+
return T;
|
|
349
364
|
}, U = (p, M) => {
|
|
350
|
-
const
|
|
351
|
-
return Mt(
|
|
352
|
-
},
|
|
353
|
-
if (
|
|
354
|
-
|
|
355
|
-
const
|
|
356
|
-
|
|
357
|
-
|
|
365
|
+
const T = k.columns.find((v) => v.field === M);
|
|
366
|
+
return Mt(_(p, M), T?.format ?? { kind: "number", thousands: !0 });
|
|
367
|
+
}, F = k.groupBy, vt = typeof k.grandTotal == "object" && k.grandTotal.fields || F?.subtotal || [], st = k.columns.findIndex((p) => vt.includes(p.field)), at = st > 0 ? st : 1, Y = [];
|
|
368
|
+
if (F) {
|
|
369
|
+
const p = /* @__PURE__ */ new Map();
|
|
370
|
+
for (const M of S) {
|
|
371
|
+
const T = yt(M[F.field]), v = p.get(T);
|
|
372
|
+
v ? v.push(M) : p.set(T, [M]);
|
|
373
|
+
}
|
|
374
|
+
for (const [M, T] of p) {
|
|
358
375
|
Y.push({
|
|
359
376
|
kind: "groupHeader",
|
|
360
|
-
label: (
|
|
377
|
+
label: (F.headerTemplate ?? "{value}").replace(/\{value\}/g, M)
|
|
361
378
|
});
|
|
362
|
-
for (const
|
|
363
|
-
|
|
379
|
+
for (const v of T) Y.push({ kind: "row", row: v });
|
|
380
|
+
F.subtotal && F.subtotal.length > 0 && Y.push({
|
|
364
381
|
kind: "subtotal",
|
|
365
|
-
label:
|
|
366
|
-
rows:
|
|
382
|
+
label: F.subtotalLabel ?? "小计",
|
|
383
|
+
rows: T
|
|
367
384
|
});
|
|
368
|
-
};
|
|
369
|
-
for (const v of S) {
|
|
370
|
-
const B = nt(v[z.field]);
|
|
371
|
-
p === null && (p = B), B !== p && (k(), M = [], p = B), M.push(v);
|
|
372
385
|
}
|
|
373
|
-
k();
|
|
374
386
|
} else
|
|
375
387
|
for (const p of S) Y.push({ kind: "row", row: p });
|
|
376
|
-
const
|
|
388
|
+
const lt = N();
|
|
377
389
|
for (const p of Y)
|
|
378
390
|
if (p.kind === "row") {
|
|
379
|
-
const M =
|
|
391
|
+
const M = gt($, p.row, s);
|
|
380
392
|
y(M.grid, M.heightMm, "listr");
|
|
381
393
|
} else if (p.kind === "groupHeader") {
|
|
382
394
|
const M = P(
|
|
383
395
|
p.label,
|
|
384
396
|
/* @__PURE__ */ new Map(),
|
|
385
|
-
|
|
386
|
-
|
|
397
|
+
F?.headerStyle ?? {},
|
|
398
|
+
k.columns.length
|
|
387
399
|
);
|
|
388
|
-
|
|
400
|
+
F?.keepWithNext !== !1 && u + M.heightMm + lt > f() && L(M.heightMm + lt), y(M.grid, M.heightMm, "listg");
|
|
389
401
|
} else if (p.kind === "subtotal") {
|
|
390
402
|
const M = /* @__PURE__ */ new Map();
|
|
391
|
-
for (const v of
|
|
392
|
-
const
|
|
403
|
+
for (const v of F.subtotal ?? []) M.set(v, U(p.rows, v));
|
|
404
|
+
const T = P(
|
|
393
405
|
p.label,
|
|
394
406
|
M,
|
|
395
|
-
|
|
396
|
-
|
|
407
|
+
F?.subtotalStyle ?? {},
|
|
408
|
+
at
|
|
397
409
|
);
|
|
398
|
-
y(
|
|
410
|
+
y(T.grid, T.heightMm, "listst");
|
|
399
411
|
}
|
|
400
|
-
if (
|
|
401
|
-
const p = typeof
|
|
412
|
+
if (k.grandTotal) {
|
|
413
|
+
const p = typeof k.grandTotal == "object" ? k.grandTotal : void 0, M = p?.fields ?? F?.subtotal ?? [];
|
|
402
414
|
if (M.length > 0) {
|
|
403
|
-
const
|
|
404
|
-
for (const
|
|
415
|
+
const T = /* @__PURE__ */ new Map();
|
|
416
|
+
for (const D of M) T.set(D, U(S, D));
|
|
405
417
|
const v = P(
|
|
406
418
|
p?.label ?? "合计",
|
|
407
|
-
|
|
419
|
+
T,
|
|
408
420
|
p?.style ?? {},
|
|
409
|
-
|
|
421
|
+
at
|
|
410
422
|
);
|
|
411
423
|
y(v.grid, v.heightMm, "listgt");
|
|
412
424
|
} else
|
|
@@ -415,16 +427,16 @@ function se(t, e, r = {}) {
|
|
|
415
427
|
}
|
|
416
428
|
E();
|
|
417
429
|
}
|
|
418
|
-
for (const
|
|
419
|
-
const l =
|
|
420
|
-
typeof l == "string" && l.includes("{totalPages}") && (
|
|
430
|
+
for (const m of h) {
|
|
431
|
+
const l = m.text;
|
|
432
|
+
typeof l == "string" && l.includes("{totalPages}") && (m.text = l.replace(/\{totalPages\}/g, String(i.length)));
|
|
421
433
|
}
|
|
422
434
|
return {
|
|
423
|
-
plan: { schemaVersion:
|
|
435
|
+
plan: { schemaVersion: At, pages: i },
|
|
424
436
|
warnings: a
|
|
425
437
|
};
|
|
426
438
|
}
|
|
427
|
-
const
|
|
439
|
+
const Vt = {
|
|
428
440
|
root: "mr-root",
|
|
429
441
|
page: "mr-page",
|
|
430
442
|
comp: "mr-comp",
|
|
@@ -441,18 +453,18 @@ const jt = {
|
|
|
441
453
|
cell: "mr-cell",
|
|
442
454
|
unknown: "mr-unknown"
|
|
443
455
|
};
|
|
444
|
-
function
|
|
445
|
-
return e?.classNames?.[t] ??
|
|
456
|
+
function B(t, e) {
|
|
457
|
+
return e?.classNames?.[t] ?? Vt[t];
|
|
446
458
|
}
|
|
447
|
-
class
|
|
459
|
+
class z {
|
|
448
460
|
constructor() {
|
|
449
461
|
this.props = [];
|
|
450
462
|
}
|
|
451
463
|
add(e, r) {
|
|
452
464
|
return r == null || r === !1 || r === "" ? this : (this.props.push([e, String(r)]), this);
|
|
453
465
|
}
|
|
454
|
-
mm(e, r, n,
|
|
455
|
-
return this.add(e, `${G(
|
|
466
|
+
mm(e, r, n, o = 2) {
|
|
467
|
+
return this.add(e, `${G($t(r, n), o)}px`);
|
|
456
468
|
}
|
|
457
469
|
toString() {
|
|
458
470
|
let e = "";
|
|
@@ -465,228 +477,228 @@ class _ {
|
|
|
465
477
|
r && (e.style.cssText = r);
|
|
466
478
|
}
|
|
467
479
|
}
|
|
468
|
-
function
|
|
480
|
+
function wt(t, e, r) {
|
|
469
481
|
const n = e.style || {};
|
|
470
482
|
t.add("color", n.color).add("background-color", n.backgroundColor).add("font-family", n.fontFamily).add("font-weight", n.bold ? "700" : void 0).add("font-style", n.italic ? "italic" : void 0).add("text-decoration", n.underline ? "underline" : void 0).add("letter-spacing", n.letterSpacing != null ? `${n.letterSpacing}pt` : void 0).add("opacity", n.opacity != null ? String(n.opacity) : void 0).add("transform", n.rotateDeg ? `rotate(${n.rotateDeg}deg)` : void 0);
|
|
471
|
-
const
|
|
472
|
-
t.add("font-size", `${G(
|
|
483
|
+
const o = V(n, r);
|
|
484
|
+
t.add("font-size", `${G(o.fontSizePx, 2)}px`);
|
|
473
485
|
}
|
|
474
|
-
function
|
|
475
|
-
const s =
|
|
476
|
-
if (s.className =
|
|
477
|
-
const c =
|
|
486
|
+
function Yt(t, e, r, n, o) {
|
|
487
|
+
const s = o.createElement("table");
|
|
488
|
+
if (s.className = B("grid", n), new z().add("width", "100%").add("height", "100%").add("border-collapse", "collapse").add("table-layout", t.colWidthsMm ? "fixed" : "auto").applyTo(s), t.colWidthsMm) {
|
|
489
|
+
const c = o.createElement("colgroup");
|
|
478
490
|
for (const h of t.colWidthsMm) {
|
|
479
|
-
const
|
|
480
|
-
new
|
|
491
|
+
const m = o.createElement("col");
|
|
492
|
+
new z().mm("width", h, r).applyTo(m), c.appendChild(m);
|
|
481
493
|
}
|
|
482
494
|
s.appendChild(c);
|
|
483
495
|
}
|
|
484
|
-
const a = tt(e.style),
|
|
496
|
+
const a = tt(e.style), i = O(e.style), d = a.inner ? `${G(i.widthPt * r / 72, 2)}px solid ${i.color}` : "";
|
|
485
497
|
return t.cells.forEach((c, h) => {
|
|
486
|
-
const
|
|
487
|
-
|
|
488
|
-
const f =
|
|
489
|
-
f.className =
|
|
490
|
-
const
|
|
491
|
-
if (d &&
|
|
498
|
+
const m = o.createElement("tr");
|
|
499
|
+
m.className = B("row", n), t.rowHeightsMm?.[h] != null && new z().mm("height", t.rowHeightsMm[h], r).applyTo(m), (c || []).forEach((l) => {
|
|
500
|
+
const f = o.createElement("td");
|
|
501
|
+
f.className = B("cell", n), l?.colSpan && (f.colSpan = l.colSpan), l?.rowSpan && (f.rowSpan = l.rowSpan);
|
|
502
|
+
const g = new z();
|
|
503
|
+
if (d && g.add("border", d), l?.style) {
|
|
492
504
|
const w = l.style;
|
|
493
|
-
|
|
505
|
+
g.add("text-align", w.align).add("vertical-align", w.verticalAlign).add("background-color", w.backgroundColor).add("color", w.color).add("font-weight", w.bold ? "700" : void 0), g.add("font-size", `${G(V(w, r).fontSizePx, 2)}px`);
|
|
494
506
|
}
|
|
495
|
-
if (
|
|
507
|
+
if (g.applyTo(f), l?.text != null && (f.textContent = l.text), l?.children?.length)
|
|
496
508
|
for (const w of l.children)
|
|
497
|
-
f.appendChild(
|
|
498
|
-
|
|
499
|
-
}), s.appendChild(
|
|
509
|
+
f.appendChild(St(w, r, n, o));
|
|
510
|
+
m.appendChild(f);
|
|
511
|
+
}), s.appendChild(m);
|
|
500
512
|
}), s;
|
|
501
513
|
}
|
|
502
|
-
function
|
|
503
|
-
const
|
|
504
|
-
|
|
505
|
-
const s = t.style || {}, a = new
|
|
514
|
+
function Jt(t, e, r, n) {
|
|
515
|
+
const o = n.createElement("div");
|
|
516
|
+
o.className = B("text", r);
|
|
517
|
+
const s = t.style || {}, a = new z().add("text-align", s.align).add("display", "flex").add("flex-direction", "column").add(
|
|
506
518
|
"justify-content",
|
|
507
519
|
s.verticalAlign === "middle" ? "center" : s.verticalAlign === "bottom" ? "flex-end" : "flex-start"
|
|
508
520
|
).add("overflow", "hidden");
|
|
509
|
-
if (
|
|
510
|
-
const
|
|
511
|
-
|
|
521
|
+
if (wt(a, t, e), a.applyTo(o), ut(t)) {
|
|
522
|
+
const i = n.createElement("div");
|
|
523
|
+
i.className = B("rich", r);
|
|
512
524
|
for (const d of t.richParagraphs) {
|
|
513
525
|
const c = n.createElement("div");
|
|
514
|
-
c.className =
|
|
515
|
-
for (const
|
|
526
|
+
c.className = B("paragraph", r), new z().add("text-align", d.align).add("line-height", d.lineHeight != null ? String(d.lineHeight) : void 0).mm("margin-top", d.spaceBeforeMm ?? 0, e).mm("margin-bottom", d.spaceAfterMm ?? 0, e).mm("text-indent", d.indentMm ?? 0, e).applyTo(c);
|
|
527
|
+
for (const m of d.segments || []) {
|
|
516
528
|
const l = n.createElement("span");
|
|
517
|
-
if (l.className =
|
|
518
|
-
const f = new
|
|
519
|
-
f.add("font-size", `${G(V(
|
|
529
|
+
if (l.className = B("segment", r), l.textContent = m.kind === "field" ? m.field ?? "" : m.text ?? "", m.style) {
|
|
530
|
+
const f = new z().add("color", m.style.color).add("font-weight", m.style.bold ? "700" : void 0);
|
|
531
|
+
f.add("font-size", `${G(V(m.style, e).fontSizePx, 2)}px`), f.applyTo(l);
|
|
520
532
|
}
|
|
521
533
|
c.appendChild(l);
|
|
522
534
|
}
|
|
523
|
-
|
|
535
|
+
i.appendChild(c);
|
|
524
536
|
}
|
|
525
|
-
return
|
|
537
|
+
return o.appendChild(i), o;
|
|
526
538
|
}
|
|
527
539
|
if (Array.isArray(t.lines) && t.lines.length > 0) {
|
|
528
|
-
const
|
|
529
|
-
|
|
540
|
+
const i = n.createElement("div");
|
|
541
|
+
i.className = B("lines", r), s.lineHeight != null && new z().add("line-height", String(s.lineHeight)).applyTo(i);
|
|
530
542
|
for (const d of t.lines) {
|
|
531
543
|
const c = n.createElement("div");
|
|
532
|
-
c.className =
|
|
544
|
+
c.className = B("line", r), c.textContent = d, i.appendChild(c);
|
|
533
545
|
}
|
|
534
|
-
return
|
|
546
|
+
return o.appendChild(i), o;
|
|
535
547
|
}
|
|
536
|
-
return
|
|
548
|
+
return o.textContent = t.text ?? "", o;
|
|
537
549
|
}
|
|
538
|
-
function
|
|
550
|
+
function qt(t, e, r) {
|
|
539
551
|
const n = r.createElement("img");
|
|
540
|
-
return n.className =
|
|
552
|
+
return n.className = B("image", e), n.src = t.imageData, new z().add("width", "100%").add("height", "100%").add("object-fit", "contain").add("display", "block").applyTo(n), n.alt = t.kind, n;
|
|
541
553
|
}
|
|
542
554
|
function ft(t, e, r, n) {
|
|
543
|
-
const
|
|
544
|
-
|
|
545
|
-
const s = t.style || {}, a = O(s),
|
|
546
|
-
return t.grid || t.kind === "rect" ? (
|
|
555
|
+
const o = n.createElement("div");
|
|
556
|
+
o.className = B("shape", r);
|
|
557
|
+
const s = t.style || {}, a = O(s), i = tt(s), d = `${G(a.widthPt * e / 72, 2)}px solid ${a.color}`, c = new z();
|
|
558
|
+
return t.grid || t.kind === "rect" ? (i.top && c.add("border-top", d), i.right && c.add("border-right", d), i.bottom && c.add("border-bottom", d), i.left && c.add("border-left", d)) : t.kind === "ellipse" ? (i.inner && c.add("border", d).add("border-radius", "50%"), s.backgroundColor && c.add("background-color", s.backgroundColor)) : t.kind === "line" && c.add("height", "0").add("border-top", d), c.add("box-sizing", "border-box").add("width", "100%").add("height", "100%"), c.applyTo(o), o;
|
|
547
559
|
}
|
|
548
|
-
function
|
|
549
|
-
const
|
|
550
|
-
|
|
551
|
-
const s = new
|
|
552
|
-
if (
|
|
553
|
-
return
|
|
560
|
+
function St(t, e, r, n) {
|
|
561
|
+
const o = n.createElement("div");
|
|
562
|
+
o.className = `${B("comp", r)} mr-kind-${t.kind}`;
|
|
563
|
+
const s = new z().add("position", "absolute").mm("left", t.leftMm, e).mm("top", t.topMm, e).mm("width", t.widthMm, e).mm("height", t.heightMm, e).add("box-sizing", "border-box");
|
|
564
|
+
if (wt(s, t, e), s.applyTo(o), Et(t))
|
|
565
|
+
return o.appendChild(qt(t, r, n)), o;
|
|
554
566
|
if (t.kind === "text")
|
|
555
|
-
return
|
|
567
|
+
return o.appendChild(Jt(t, e, r, n)), o;
|
|
556
568
|
if (t.grid) {
|
|
557
|
-
const
|
|
558
|
-
return
|
|
569
|
+
const i = ft(t, e, r, n);
|
|
570
|
+
return i.appendChild(Yt(t.grid, t, e, r, n)), o.appendChild(i), o;
|
|
559
571
|
}
|
|
560
572
|
if (t.kind === "line" || t.kind === "rect" || t.kind === "ellipse" || t.kind === "chart")
|
|
561
|
-
return
|
|
573
|
+
return o.appendChild(ft(t, e, r, n)), o;
|
|
562
574
|
const a = n.createElement("div");
|
|
563
|
-
return a.className =
|
|
575
|
+
return a.className = B("unknown", r), a.textContent = t.fallbackText ?? "", o.appendChild(a), o;
|
|
564
576
|
}
|
|
565
|
-
function
|
|
566
|
-
const
|
|
567
|
-
|
|
577
|
+
function Ut(t, e, r, n) {
|
|
578
|
+
const o = n.createElement("div");
|
|
579
|
+
o.className = B("page", r), new z().add("position", "relative").mm("width", t.pageWidthMm, e).mm("height", t.pageHeightMm, e).add("background-color", "#fff").add("overflow", "hidden").add("box-sizing", "border-box").applyTo(o);
|
|
568
580
|
for (const s of t.components)
|
|
569
|
-
|
|
570
|
-
return
|
|
581
|
+
o.appendChild(St(s, e, r, n));
|
|
582
|
+
return o;
|
|
571
583
|
}
|
|
572
|
-
function
|
|
573
|
-
const n = r.dpi ?? 96,
|
|
574
|
-
return
|
|
575
|
-
|
|
576
|
-
}),
|
|
584
|
+
function ce(t, e, r = {}) {
|
|
585
|
+
const n = r.dpi ?? 96, o = e.createElement("div");
|
|
586
|
+
return o.className = B("root", r), o.dataset.schemaVersion = t.schemaVersion, t.pages.forEach((s) => {
|
|
587
|
+
o.appendChild(Ut(s, n, r, e));
|
|
588
|
+
}), o;
|
|
577
589
|
}
|
|
578
|
-
function
|
|
579
|
-
const { pageHeightsPx: e, viewportHeightPx: r, scrollTopPx: n, overscan:
|
|
590
|
+
function Kt(t) {
|
|
591
|
+
const { pageHeightsPx: e, viewportHeightPx: r, scrollTopPx: n, overscan: o = 1, gapPx: s = 0 } = t, a = e.length;
|
|
580
592
|
if (a === 0)
|
|
581
593
|
return { start: 0, end: -1, padTopPx: 0, padBottomPx: 0 };
|
|
582
|
-
const
|
|
594
|
+
const i = Math.max(0, s), d = new Array(a + 1);
|
|
583
595
|
d[0] = 0;
|
|
584
596
|
for (let S = 0; S < a; S++)
|
|
585
|
-
d[S + 1] = d[S] + Math.max(0, e[S] ?? 0) +
|
|
597
|
+
d[S + 1] = d[S] + Math.max(0, e[S] ?? 0) + i;
|
|
586
598
|
const c = d[a], h = Math.max(0, n);
|
|
587
|
-
let
|
|
599
|
+
let m = 0, l = 0, f = a - 1;
|
|
588
600
|
for (; l <= f; ) {
|
|
589
601
|
const S = l + f >> 1;
|
|
590
|
-
d[S] <= h ? (
|
|
602
|
+
d[S] <= h ? (m = S, l = S + 1) : f = S - 1;
|
|
591
603
|
}
|
|
592
|
-
const
|
|
604
|
+
const g = Math.max(0, Math.min(a - 1, m - o)), w = d[m] + Math.max(0, r);
|
|
593
605
|
let E = a - 1;
|
|
594
606
|
for (l = 0, f = a - 1; l <= f; ) {
|
|
595
607
|
const S = l + f >> 1;
|
|
596
608
|
d[S + 1] < w ? l = S + 1 : (E = S, f = S - 1);
|
|
597
609
|
}
|
|
598
|
-
const
|
|
599
|
-
return { start:
|
|
610
|
+
const x = Math.min(a - 1, E + o), b = d[g], C = Math.max(0, c - d[x + 1]);
|
|
611
|
+
return { start: g, end: x, padTopPx: b, padBottomPx: C };
|
|
600
612
|
}
|
|
601
613
|
const it = 96 / 25.4;
|
|
602
|
-
function
|
|
614
|
+
function Tt(t, e = 96) {
|
|
603
615
|
const r = e / 96 * it;
|
|
604
616
|
return {
|
|
605
617
|
widthPx: Math.max(1, Math.round(t.pageWidthMm * r)),
|
|
606
618
|
heightPx: Math.max(1, Math.round(t.pageHeightMm * r))
|
|
607
619
|
};
|
|
608
620
|
}
|
|
609
|
-
function
|
|
610
|
-
const n = document.createElement("canvas"), { widthPx:
|
|
611
|
-
n.width = Math.round(
|
|
621
|
+
function Xt(t, e, r) {
|
|
622
|
+
const n = document.createElement("canvas"), { widthPx: o, heightPx: s } = Tt(t, r);
|
|
623
|
+
n.width = Math.round(o * e), n.height = Math.round(s * e), n.style.width = `${o}px`, n.style.height = `${s}px`;
|
|
612
624
|
const a = n.getContext("2d");
|
|
613
625
|
if (!a)
|
|
614
626
|
throw new Error("当前环境不支持 Canvas 2D(测试需真浏览器,见 e2e/canvas.spec.ts)");
|
|
615
|
-
return a.scale(e, e), a.fillStyle = "#ffffff", a.fillRect(0, 0,
|
|
627
|
+
return a.scale(e, e), a.fillStyle = "#ffffff", a.fillRect(0, 0, o, s), { canvas: n, ctx: a };
|
|
616
628
|
}
|
|
617
|
-
function
|
|
629
|
+
function he(t, e = 96) {
|
|
618
630
|
return V(t, e).fontSizePx;
|
|
619
631
|
}
|
|
620
|
-
function
|
|
632
|
+
function xt(t, e, r, n, o, s, a, i = "top") {
|
|
621
633
|
t.font = `${e.bold ? "bold " : ""}${e.fontSizePx}px ${a}`, t.fillStyle = e.color, t.textBaseline = "alphabetic";
|
|
622
634
|
const d = e.fontSizePx * e.lineHeight, c = e.text === "" ? [""] : e.text.split(`
|
|
623
635
|
`), h = c.length * d;
|
|
624
|
-
let
|
|
625
|
-
|
|
636
|
+
let m = n;
|
|
637
|
+
i === "middle" ? m = n + (s - h) / 2 : i === "bottom" && (m = n + s - h), c.forEach((l, f) => {
|
|
626
638
|
t.textAlign = e.align === "center" ? "center" : e.align === "right" ? "right" : "left";
|
|
627
|
-
const
|
|
628
|
-
t.fillText(l,
|
|
639
|
+
const g = e.align === "center" ? r + o / 2 : e.align === "right" ? r + o : r;
|
|
640
|
+
t.fillText(l, g, m + f * d + e.fontSizePx * 0.8, o);
|
|
629
641
|
}), t.textAlign = "left";
|
|
630
642
|
}
|
|
631
|
-
function
|
|
632
|
-
const
|
|
633
|
-
for (const
|
|
634
|
-
const w =
|
|
643
|
+
function Zt(t, e, r, n, o, s, a, i, d, c, h) {
|
|
644
|
+
const m = Rt(e, s / i, a / i), l = tt(r.style), f = O(r.style);
|
|
645
|
+
for (const g of m.cells) {
|
|
646
|
+
const w = g.cell.style?.backgroundColor;
|
|
635
647
|
w && (t.fillStyle = w, t.fillRect(
|
|
636
|
-
n +
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
648
|
+
n + g.xMm * i,
|
|
649
|
+
o + g.yMm * i,
|
|
650
|
+
g.widthMm * i,
|
|
651
|
+
g.heightMm * i
|
|
640
652
|
));
|
|
641
653
|
}
|
|
642
654
|
if (l.inner) {
|
|
643
655
|
t.strokeStyle = f.color, t.lineWidth = K(f.widthPt, d);
|
|
644
|
-
for (const
|
|
645
|
-
t.beginPath(),
|
|
646
|
-
t.beginPath(), l.top && (t.moveTo(n,
|
|
656
|
+
for (const g of m.edges)
|
|
657
|
+
t.beginPath(), g.kind === "v" ? (t.moveTo(n + g.pos * i, o + g.from * i), t.lineTo(n + g.pos * i, o + g.to * i)) : (t.moveTo(n + g.from * i, o + g.pos * i), t.lineTo(n + g.to * i, o + g.pos * i)), t.stroke();
|
|
658
|
+
t.beginPath(), l.top && (t.moveTo(n, o), t.lineTo(n + s, o)), l.right && (t.moveTo(n + s, o), t.lineTo(n + s, o + a)), l.bottom && (t.moveTo(n + s, o + a), t.lineTo(n, o + a)), l.left && (t.moveTo(n, o + a), t.lineTo(n, o)), t.stroke();
|
|
647
659
|
}
|
|
648
|
-
for (const
|
|
649
|
-
const w = typeof
|
|
660
|
+
for (const g of m.cells) {
|
|
661
|
+
const w = typeof g.cell.text == "string" ? g.cell.text : "";
|
|
650
662
|
if (!w) continue;
|
|
651
|
-
const E =
|
|
663
|
+
const E = g.cell.style, x = E?.fontSize ?? X, b = Z(
|
|
652
664
|
w,
|
|
653
|
-
|
|
654
|
-
{ fontSizePt:
|
|
665
|
+
g.widthMm - 1,
|
|
666
|
+
{ fontSizePt: x },
|
|
655
667
|
h
|
|
656
668
|
).join(`
|
|
657
669
|
`);
|
|
658
|
-
|
|
670
|
+
xt(
|
|
659
671
|
t,
|
|
660
672
|
{
|
|
661
673
|
text: b,
|
|
662
674
|
fontSizePx: V(E, d).fontSizePx,
|
|
663
675
|
bold: E?.bold ?? !1,
|
|
664
|
-
color: E?.color ?? pt(r.style,
|
|
676
|
+
color: E?.color ?? pt(r.style, Nt),
|
|
665
677
|
align: E?.align ?? "left",
|
|
666
678
|
lineHeight: Q
|
|
667
679
|
},
|
|
668
|
-
n + (
|
|
669
|
-
|
|
670
|
-
Math.max(0, (
|
|
671
|
-
|
|
680
|
+
n + (g.xMm + 0.5) * i,
|
|
681
|
+
o + g.yMm * i,
|
|
682
|
+
Math.max(0, (g.widthMm - 1) * i),
|
|
683
|
+
g.heightMm * i,
|
|
672
684
|
c,
|
|
673
685
|
E?.verticalAlign ?? "middle"
|
|
674
686
|
);
|
|
675
687
|
}
|
|
676
688
|
}
|
|
677
|
-
function
|
|
678
|
-
const a = e.leftMm * r,
|
|
689
|
+
function kt(t, e, r, n, o, s) {
|
|
690
|
+
const a = e.leftMm * r, i = e.topMm * r, d = e.widthMm * r, c = e.heightMm * r, h = e.style ?? {};
|
|
679
691
|
if (e.grid) {
|
|
680
|
-
|
|
692
|
+
Zt(t, e.grid, e, a, i, d, c, r, n, o, s);
|
|
681
693
|
return;
|
|
682
694
|
}
|
|
683
695
|
switch (e.kind) {
|
|
684
696
|
case "text": {
|
|
685
|
-
const
|
|
697
|
+
const m = h.fontSize ?? X, l = ut(e) ? e.richParagraphs.map((f) => (f.segments ?? []).map((g) => g.text ?? g.field ?? "").join("")).join(`
|
|
686
698
|
`) : Array.isArray(e.lines) && e.lines.length > 0 ? e.lines.join(`
|
|
687
|
-
`) : Z(e.text ?? "", e.widthMm, { fontSizePt:
|
|
699
|
+
`) : Z(e.text ?? "", e.widthMm, { fontSizePt: m }, s).join(`
|
|
688
700
|
`);
|
|
689
|
-
|
|
701
|
+
xt(
|
|
690
702
|
t,
|
|
691
703
|
{
|
|
692
704
|
text: l,
|
|
@@ -694,113 +706,113 @@ function xt(t, e, r, n, i, s) {
|
|
|
694
706
|
bold: h.bold ?? !1,
|
|
695
707
|
color: pt(h),
|
|
696
708
|
align: h.align ?? "left",
|
|
697
|
-
lineHeight:
|
|
709
|
+
lineHeight: Ht(h)
|
|
698
710
|
},
|
|
699
711
|
a,
|
|
700
|
-
|
|
712
|
+
i,
|
|
701
713
|
d,
|
|
702
714
|
c,
|
|
703
|
-
|
|
715
|
+
o,
|
|
704
716
|
h.verticalAlign
|
|
705
717
|
);
|
|
706
718
|
break;
|
|
707
719
|
}
|
|
708
720
|
case "rect": {
|
|
709
|
-
const
|
|
710
|
-
h.backgroundColor && (t.fillStyle = h.backgroundColor, t.fillRect(a,
|
|
721
|
+
const m = O(h), l = tt(h);
|
|
722
|
+
h.backgroundColor && (t.fillStyle = h.backgroundColor, t.fillRect(a, i, d, c)), l.inner && (t.strokeStyle = m.color, t.lineWidth = K(m.widthPt, n), t.beginPath(), l.top && (t.moveTo(a, i), t.lineTo(a + d, i)), l.right && (t.moveTo(a + d, i), t.lineTo(a + d, i + c)), l.bottom && (t.moveTo(a + d, i + c), t.lineTo(a, i + c)), l.left && (t.moveTo(a, i + c), t.lineTo(a, i)), t.stroke());
|
|
711
723
|
break;
|
|
712
724
|
}
|
|
713
725
|
case "line": {
|
|
714
|
-
const
|
|
715
|
-
t.strokeStyle =
|
|
726
|
+
const m = O({ ...h, borderColor: h.lineColor ?? h.borderColor });
|
|
727
|
+
t.strokeStyle = m.color, t.lineWidth = K(m.widthPt, n), t.beginPath(), t.moveTo(a, i + c / 2), t.lineTo(a + d, i + c / 2), t.stroke();
|
|
716
728
|
break;
|
|
717
729
|
}
|
|
718
730
|
case "ellipse": {
|
|
719
|
-
const
|
|
720
|
-
t.strokeStyle =
|
|
731
|
+
const m = O(h);
|
|
732
|
+
t.strokeStyle = m.color, t.lineWidth = K(m.widthPt, n), h.backgroundColor && (t.fillStyle = h.backgroundColor, t.beginPath(), t.ellipse(a + d / 2, i + c / 2, d / 2, c / 2, 0, 0, Math.PI * 2), t.fill()), t.beginPath(), t.ellipse(a + d / 2, i + c / 2, d / 2, c / 2, 0, 0, Math.PI * 2), t.stroke();
|
|
721
733
|
break;
|
|
722
734
|
}
|
|
723
735
|
}
|
|
724
736
|
}
|
|
725
|
-
function
|
|
737
|
+
function me(t, e = {}) {
|
|
726
738
|
if (typeof document > "u")
|
|
727
739
|
throw new Error("renderPlanToCanvas 需要浏览器环境(SSR 请在客户端钩子中调用)");
|
|
728
|
-
const r = e.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), n = e.dpi ?? 96,
|
|
729
|
-
for (let h =
|
|
730
|
-
const
|
|
731
|
-
for (const
|
|
732
|
-
|
|
740
|
+
const r = e.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), n = e.dpi ?? 96, o = n / 96 * it, s = e.fontFamily ?? '"Microsoft YaHei", sans-serif', a = e.measurer ?? ot, i = Math.max(0, e.start ?? 0), d = Math.min(t.pages.length - 1, e.end ?? t.pages.length - 1), c = [];
|
|
741
|
+
for (let h = i; h <= d; h++) {
|
|
742
|
+
const m = t.pages[h], { canvas: l, ctx: f } = Xt(m, r, n);
|
|
743
|
+
for (const g of m.components)
|
|
744
|
+
kt(f, g, o, n, s, a);
|
|
733
745
|
c.push(l);
|
|
734
746
|
}
|
|
735
747
|
return { canvases: c };
|
|
736
748
|
}
|
|
737
|
-
function
|
|
738
|
-
const r = e.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), n = e.dpi ?? 96,
|
|
739
|
-
let f = null,
|
|
749
|
+
function ge(t, e = {}) {
|
|
750
|
+
const r = e.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), n = e.dpi ?? 96, o = n / 96 * it, s = e.fontFamily ?? '"Microsoft YaHei", sans-serif', a = e.measurer ?? ot, i = e.overscan ?? 1, d = e.gapPx ?? 18, c = e.pagesPerFrame ?? 1, h = t.pages.map((u) => u.pageHeightMm * o), m = Math.max(1, ...t.pages.map((u) => u.pageWidthMm * o)), l = { start: 0, end: -1 };
|
|
751
|
+
let f = null, g = null, w = null, E = null, x = [], b = 0, C = [];
|
|
740
752
|
function S() {
|
|
741
753
|
const u = f;
|
|
742
|
-
u.innerHTML = "",
|
|
743
|
-
const H = Math.min(t.pages.length, 3 +
|
|
754
|
+
u.innerHTML = "", g = document.createElement("div"), g.style.cssText = `width:${m}px;margin:0 auto;`, w = document.createElement("div"), E = document.createElement("div"), g.appendChild(w), x = [];
|
|
755
|
+
const H = Math.min(t.pages.length, 3 + i * 2);
|
|
744
756
|
for (let L = 0; L < H; L++) {
|
|
745
757
|
const y = document.createElement("div");
|
|
746
|
-
y.style.cssText = `margin:0 auto ${d}px;box-shadow:0 2px 8px rgba(0,0,0,.35);background:#fff;`,
|
|
758
|
+
y.style.cssText = `margin:0 auto ${d}px;box-shadow:0 2px 8px rgba(0,0,0,.35);background:#fff;`, g.appendChild(y), x.push(y);
|
|
747
759
|
}
|
|
748
|
-
|
|
760
|
+
g.appendChild(E), u.appendChild(g);
|
|
749
761
|
}
|
|
750
762
|
function J(u, H) {
|
|
751
|
-
const L = t.pages[H], { widthPx: y, heightPx:
|
|
763
|
+
const L = t.pages[H], { widthPx: y, heightPx: N } = Tt(L, n);
|
|
752
764
|
let P = u.firstElementChild;
|
|
753
|
-
(!P || P.tagName !== "CANVAS") && (P = document.createElement("canvas"), u.innerHTML = "", u.appendChild(P)), P.width = Math.round(y * r), P.height = Math.round(
|
|
754
|
-
const
|
|
755
|
-
if (
|
|
756
|
-
|
|
765
|
+
(!P || P.tagName !== "CANVAS") && (P = document.createElement("canvas"), u.innerHTML = "", u.appendChild(P)), P.width = Math.round(y * r), P.height = Math.round(N * r), P.style.width = `${y}px`, P.style.height = `${N}px`;
|
|
766
|
+
const _ = P.getContext("2d");
|
|
767
|
+
if (_) {
|
|
768
|
+
_.setTransform(1, 0, 0, 1, 0, 0), _.scale(r, r), _.fillStyle = "#ffffff", _.fillRect(0, 0, y, N);
|
|
757
769
|
for (const U of L.components)
|
|
758
|
-
|
|
759
|
-
P.dataset.canvasPage = String(H), u.style.height = `${
|
|
770
|
+
kt(_, U, o, n, s, a);
|
|
771
|
+
P.dataset.canvasPage = String(H), u.style.height = `${N}px`, u.style.width = `${y}px`;
|
|
760
772
|
}
|
|
761
773
|
}
|
|
762
774
|
function q(u) {
|
|
763
|
-
l.start = u.start, l.end = u.end, w.style.height = `${u.start * d + h.slice(0, u.start).reduce((y,
|
|
775
|
+
l.start = u.start, l.end = u.end, w.style.height = `${u.start * d + h.slice(0, u.start).reduce((y, N) => y + N, 0)}px`;
|
|
764
776
|
const H = t.pages.length - 1 - u.end;
|
|
765
|
-
E.style.height = `${H * d + h.slice(u.end + 1).reduce((y,
|
|
777
|
+
E.style.height = `${H * d + h.slice(u.end + 1).reduce((y, N) => y + N, 0)}px`;
|
|
766
778
|
const L = u.end - u.start + 1;
|
|
767
|
-
|
|
768
|
-
if (
|
|
779
|
+
x.forEach((y, N) => {
|
|
780
|
+
if (N < L) {
|
|
769
781
|
y.style.display = "";
|
|
770
|
-
const P = u.start +
|
|
782
|
+
const P = u.start + N;
|
|
771
783
|
y.style.height = `${h[P] ?? 0}px`;
|
|
772
784
|
} else
|
|
773
785
|
y.style.display = "none";
|
|
774
786
|
}), C = [];
|
|
775
787
|
for (let y = u.start; y <= u.end; y++) {
|
|
776
|
-
const
|
|
777
|
-
if (!
|
|
778
|
-
|
|
788
|
+
const N = x[y - u.start];
|
|
789
|
+
if (!N) continue;
|
|
790
|
+
N.firstElementChild?.dataset?.canvasPage !== String(y) && C.push(y);
|
|
779
791
|
}
|
|
780
|
-
|
|
792
|
+
k();
|
|
781
793
|
}
|
|
782
|
-
function
|
|
794
|
+
function k() {
|
|
783
795
|
b || C.length === 0 || (b = requestAnimationFrame(() => {
|
|
784
796
|
b = 0;
|
|
785
797
|
let u = Math.max(1, c);
|
|
786
798
|
for (; C.length > 0 && u-- > 0; ) {
|
|
787
|
-
const H = C.shift(), L =
|
|
799
|
+
const H = C.shift(), L = x[H - l.start];
|
|
788
800
|
L && J(L, H);
|
|
789
801
|
}
|
|
790
|
-
C.length > 0 &&
|
|
802
|
+
C.length > 0 && k();
|
|
791
803
|
}));
|
|
792
804
|
}
|
|
793
805
|
function $() {
|
|
794
806
|
b || (b = requestAnimationFrame(() => {
|
|
795
807
|
b = 0;
|
|
796
|
-
const u = f, H =
|
|
808
|
+
const u = f, H = Kt({
|
|
797
809
|
pageHeightsPx: h,
|
|
798
810
|
viewportHeightPx: u.clientHeight,
|
|
799
811
|
scrollTopPx: u.scrollTop,
|
|
800
|
-
overscan:
|
|
812
|
+
overscan: i,
|
|
801
813
|
gapPx: d
|
|
802
814
|
});
|
|
803
|
-
H.start !== l.start || H.end !== l.end ? q(H) :
|
|
815
|
+
H.start !== l.start || H.end !== l.end ? q(H) : k();
|
|
804
816
|
}));
|
|
805
817
|
}
|
|
806
818
|
let j = null;
|
|
@@ -811,7 +823,7 @@ function ce(t, e = {}) {
|
|
|
811
823
|
f = u, S(), u.addEventListener("scroll", $, { passive: !0 }), typeof ResizeObserver < "u" && (j = new ResizeObserver(() => $()), j.observe(u)), $();
|
|
812
824
|
},
|
|
813
825
|
destroy() {
|
|
814
|
-
b && cancelAnimationFrame(b), b = 0, j?.disconnect(), j = null, f?.removeEventListener("scroll", $), C = [],
|
|
826
|
+
b && cancelAnimationFrame(b), b = 0, j?.disconnect(), j = null, f?.removeEventListener("scroll", $), C = [], g?.remove(), f = null;
|
|
815
827
|
},
|
|
816
828
|
window() {
|
|
817
829
|
return { ...l };
|
|
@@ -821,61 +833,61 @@ function ce(t, e = {}) {
|
|
|
821
833
|
function A(t, e) {
|
|
822
834
|
return typeof t == "number" && Number.isFinite(t) ? t : e;
|
|
823
835
|
}
|
|
824
|
-
function
|
|
836
|
+
function R(t, e = "") {
|
|
825
837
|
return typeof t == "string" ? t : e;
|
|
826
838
|
}
|
|
827
839
|
function W(t) {
|
|
828
840
|
return typeof t == "object" && t !== null && !Array.isArray(t);
|
|
829
841
|
}
|
|
830
|
-
function
|
|
842
|
+
function Qt(t) {
|
|
831
843
|
return t === "Center" ? "center" : t === "Right" ? "right" : "left";
|
|
832
844
|
}
|
|
833
|
-
function
|
|
845
|
+
function te(t) {
|
|
834
846
|
return t === "Center" ? "middle" : t === "Bottom" ? "bottom" : "top";
|
|
835
847
|
}
|
|
836
|
-
function
|
|
837
|
-
const e = parseFloat(
|
|
848
|
+
function ee(t) {
|
|
849
|
+
const e = parseFloat(R(t.FontSize, "10.5"));
|
|
838
850
|
return {
|
|
839
851
|
fontSize: Number.isFinite(e) ? e : 10.5,
|
|
840
|
-
fontFamily:
|
|
841
|
-
bold:
|
|
842
|
-
italic:
|
|
852
|
+
fontFamily: R(t.FontFamily, "黑体") || void 0,
|
|
853
|
+
bold: R(t.FontWeight) === "bold" || void 0,
|
|
854
|
+
italic: R(t.FontStyle) === "italic" || void 0,
|
|
843
855
|
underline: t.Underline === !0 || void 0,
|
|
844
|
-
color:
|
|
845
|
-
backgroundColor:
|
|
846
|
-
align:
|
|
847
|
-
verticalAlign:
|
|
856
|
+
color: R(t.FontColor) || void 0,
|
|
857
|
+
backgroundColor: R(t.BackgroundColor) || void 0,
|
|
858
|
+
align: Qt(R(t.HorAlignment, "Left")),
|
|
859
|
+
verticalAlign: te(R(t.VertAlignment, "Top")),
|
|
848
860
|
lineHeight: (() => {
|
|
849
|
-
const r = parseFloat(
|
|
861
|
+
const r = parseFloat(R(t.RowSpace, "1"));
|
|
850
862
|
return Number.isFinite(r) && r !== 1 ? r : void 0;
|
|
851
863
|
})(),
|
|
852
|
-
borderColor:
|
|
864
|
+
borderColor: R(t.BorderColor) || void 0,
|
|
853
865
|
borderTop: t.BorderTop !== !1,
|
|
854
866
|
borderRight: t.BorderRight !== !1,
|
|
855
867
|
borderBottom: t.BorderBottom !== !1,
|
|
856
868
|
borderLeft: t.BorderLeft !== !1
|
|
857
869
|
};
|
|
858
870
|
}
|
|
859
|
-
function
|
|
860
|
-
const r =
|
|
871
|
+
function ne(t, e) {
|
|
872
|
+
const r = R(t.uitype), n = {
|
|
861
873
|
kind: "text",
|
|
862
874
|
leftMm: A(t.left, 0),
|
|
863
875
|
topMm: A(t.top, 0),
|
|
864
876
|
widthMm: A(t.width, 40),
|
|
865
877
|
heightMm: A(t.height, 8),
|
|
866
|
-
nid:
|
|
867
|
-
style:
|
|
878
|
+
nid: R(t.nid) || void 0,
|
|
879
|
+
style: ee(t)
|
|
868
880
|
};
|
|
869
881
|
switch (r) {
|
|
870
882
|
case "text": {
|
|
871
883
|
n.kind = "text";
|
|
872
|
-
const
|
|
873
|
-
n.text =
|
|
884
|
+
const o = t.Text ?? t.text ?? t.Value;
|
|
885
|
+
n.text = o == null ? "" : String(o);
|
|
874
886
|
const s = t.Lines ?? t.lines;
|
|
875
887
|
return Array.isArray(s) && (n.lines = s.map((a) => String(a))), n;
|
|
876
888
|
}
|
|
877
889
|
case "richtext":
|
|
878
|
-
return n.kind = "text", n.text =
|
|
890
|
+
return n.kind = "text", n.text = R(t.Text), e.push(`富文本 ${n.nid ?? ""} 导入为纯文本(版式细节可能损失)`), n;
|
|
879
891
|
case "image":
|
|
880
892
|
case "barcode":
|
|
881
893
|
case "qrcode":
|
|
@@ -883,13 +895,13 @@ function Qt(t, e) {
|
|
|
883
895
|
return n.kind = r === "image" ? "image" : r, n.fallbackText = `[${r}]`, e.push(`图片类组件 ${n.nid ?? ""} 需运行时数据(imageData),已导入为占位`), n;
|
|
884
896
|
case "table": {
|
|
885
897
|
n.kind = "rect";
|
|
886
|
-
const
|
|
887
|
-
if (Array.isArray(
|
|
898
|
+
const o = t.Cells ?? t.cells;
|
|
899
|
+
if (Array.isArray(o)) {
|
|
888
900
|
const s = {
|
|
889
|
-
cells:
|
|
890
|
-
(a) => Array.isArray(a) ? a.map((
|
|
891
|
-
text: W(
|
|
892
|
-
colSpan: W(
|
|
901
|
+
cells: o.map(
|
|
902
|
+
(a) => Array.isArray(a) ? a.map((i) => ({
|
|
903
|
+
text: W(i) ? R(i.Text ?? i.text) : "",
|
|
904
|
+
colSpan: W(i) ? A(i.ColSpan, 1) : 1
|
|
893
905
|
})) : []
|
|
894
906
|
)
|
|
895
907
|
};
|
|
@@ -901,10 +913,10 @@ function Qt(t, e) {
|
|
|
901
913
|
case "subreport":
|
|
902
914
|
return e.push(`子报表 ${n.nid ?? ""} 暂不支持导入,已跳过`), null;
|
|
903
915
|
default:
|
|
904
|
-
return
|
|
916
|
+
return R(t.ShapeType) === "hline" || r === "hline" || r === "vline" ? (n.kind = "line", n) : r === "rect" || r === "oval" || r === "shape" ? (n.kind = r === "oval" ? "ellipse" : "rect", n) : (e.push(`未知组件类型 ${r},已跳过`), null);
|
|
905
917
|
}
|
|
906
918
|
}
|
|
907
|
-
function
|
|
919
|
+
function fe(t) {
|
|
908
920
|
const e = [];
|
|
909
921
|
let r = null;
|
|
910
922
|
if (typeof t == "string")
|
|
@@ -920,22 +932,22 @@ function he(t) {
|
|
|
920
932
|
else W(t) && (r = t);
|
|
921
933
|
if (!r)
|
|
922
934
|
return { template: { pages: [] }, warnings: ["content 为空"] };
|
|
923
|
-
const n = W(r.GlobalConfig) ? r.GlobalConfig : {},
|
|
935
|
+
const n = W(r.GlobalConfig) ? r.GlobalConfig : {}, o = A(n.paperWidthMm, 210), s = A(n.paperHeightMm, 297), a = {
|
|
924
936
|
top: A(n.marginTop, 10),
|
|
925
937
|
bottom: A(n.marginBottom, 10),
|
|
926
938
|
left: A(n.marginLeft, 10),
|
|
927
939
|
right: A(n.marginRight, 10)
|
|
928
|
-
},
|
|
929
|
-
|
|
930
|
-
const d =
|
|
931
|
-
const h = c,
|
|
932
|
-
for (const f of
|
|
940
|
+
}, i = Array.isArray(r.children) ? r.children.filter((c) => W(c) && R(c.uitype) === "page") : [];
|
|
941
|
+
i.length === 0 && e.push("content 中没有 uitype=page 的页节点");
|
|
942
|
+
const d = i.map((c) => {
|
|
943
|
+
const h = c, m = Array.isArray(h.children) ? h.children : [], l = [];
|
|
944
|
+
for (const f of m) {
|
|
933
945
|
if (!W(f)) continue;
|
|
934
|
-
const
|
|
935
|
-
|
|
946
|
+
const g = ne(f, e);
|
|
947
|
+
g && l.push(g);
|
|
936
948
|
}
|
|
937
949
|
return {
|
|
938
|
-
widthMm: A(h.width,
|
|
950
|
+
widthMm: A(h.width, o),
|
|
939
951
|
heightMm: A(h.DesignHeight, s),
|
|
940
952
|
marginTopMm: A(h.MarginTop, a.top),
|
|
941
953
|
marginBottomMm: A(h.MarginBottom, a.bottom),
|
|
@@ -945,22 +957,22 @@ function he(t) {
|
|
|
945
957
|
};
|
|
946
958
|
});
|
|
947
959
|
return d.length === 0 && (e.push("转换结果为空页,已回退一张空白页"), d.push({
|
|
948
|
-
widthMm:
|
|
960
|
+
widthMm: o,
|
|
949
961
|
heightMm: s,
|
|
950
962
|
...a,
|
|
951
963
|
components: []
|
|
952
964
|
})), { template: { pages: d }, warnings: e };
|
|
953
965
|
}
|
|
954
|
-
function
|
|
955
|
-
let n,
|
|
966
|
+
function re(t, e, r) {
|
|
967
|
+
let n, o;
|
|
956
968
|
if (typeof t == "string") {
|
|
957
|
-
const s =
|
|
958
|
-
if (!s) throw new Error(`未知纸张预设 "${t}"(可用:${Object.keys(
|
|
959
|
-
n = s.widthMm,
|
|
960
|
-
} else typeof t == "number" ? (n = t,
|
|
961
|
-
return r ? { widthMm:
|
|
969
|
+
const s = ht[t];
|
|
970
|
+
if (!s) throw new Error(`未知纸张预设 "${t}"(可用:${Object.keys(ht).join("/")})`);
|
|
971
|
+
n = s.widthMm, o = s.heightMm;
|
|
972
|
+
} else typeof t == "number" ? (n = t, o = e ?? 297) : (n = t.widthMm, o = t.heightMm);
|
|
973
|
+
return r ? { widthMm: o, heightMm: n } : { widthMm: n, heightMm: o };
|
|
962
974
|
}
|
|
963
|
-
class
|
|
975
|
+
class oe {
|
|
964
976
|
constructor() {
|
|
965
977
|
this.pages = [], this.pending = null;
|
|
966
978
|
}
|
|
@@ -972,14 +984,14 @@ class ee {
|
|
|
972
984
|
*/
|
|
973
985
|
page(e = "a4", r = {}, n) {
|
|
974
986
|
this.collect();
|
|
975
|
-
const s = n != null && !("margins" in n) && !("landscape" in n) && ("marginTopMm" in n || "marginBottomMm" in n || "marginLeftMm" in n || "marginRightMm" in n) ? { margins: n } : n ?? {}, { widthMm: a, heightMm:
|
|
987
|
+
const s = n != null && !("margins" in n) && !("landscape" in n) && ("marginTopMm" in n || "marginBottomMm" in n || "marginLeftMm" in n || "marginRightMm" in n) ? { margins: n } : n ?? {}, { widthMm: a, heightMm: i } = re(
|
|
976
988
|
e,
|
|
977
989
|
typeof r == "number" ? r : void 0,
|
|
978
990
|
s.landscape
|
|
979
991
|
), d = s.margins ?? {};
|
|
980
|
-
return this.pending = new
|
|
992
|
+
return this.pending = new ie(this, {
|
|
981
993
|
widthMm: a,
|
|
982
|
-
heightMm:
|
|
994
|
+
heightMm: i,
|
|
983
995
|
marginTopMm: d.marginTopMm ?? 10,
|
|
984
996
|
marginBottomMm: d.marginBottomMm ?? 10,
|
|
985
997
|
marginLeftMm: d.marginLeftMm ?? 10,
|
|
@@ -995,7 +1007,7 @@ class ee {
|
|
|
995
1007
|
return { pages: this.pages };
|
|
996
1008
|
}
|
|
997
1009
|
}
|
|
998
|
-
class
|
|
1010
|
+
class ie {
|
|
999
1011
|
constructor(e, r) {
|
|
1000
1012
|
this.parent = e, this.page = r, this.components = [];
|
|
1001
1013
|
}
|
|
@@ -1010,7 +1022,7 @@ class ne {
|
|
|
1010
1022
|
style: n
|
|
1011
1023
|
}), this;
|
|
1012
1024
|
}
|
|
1013
|
-
list(e, r, n,
|
|
1025
|
+
list(e, r, n, o = {}) {
|
|
1014
1026
|
return this.components.push({
|
|
1015
1027
|
kind: "list",
|
|
1016
1028
|
leftMm: r.leftMm ?? 10,
|
|
@@ -1018,20 +1030,20 @@ class ne {
|
|
|
1018
1030
|
widthMm: r.widthMm ?? 180,
|
|
1019
1031
|
dataset: e,
|
|
1020
1032
|
columns: n,
|
|
1021
|
-
...
|
|
1033
|
+
...o
|
|
1022
1034
|
}), this;
|
|
1023
1035
|
}
|
|
1024
1036
|
rect(e, r = {}) {
|
|
1025
1037
|
return this.components.push({ kind: "rect", ...e, style: r }), this;
|
|
1026
1038
|
}
|
|
1027
|
-
line(e, r, n,
|
|
1039
|
+
line(e, r, n, o = {}) {
|
|
1028
1040
|
return this.components.push({
|
|
1029
1041
|
kind: "line",
|
|
1030
1042
|
leftMm: e,
|
|
1031
1043
|
topMm: r,
|
|
1032
1044
|
widthMm: n,
|
|
1033
1045
|
heightMm: 0.5,
|
|
1034
|
-
style:
|
|
1046
|
+
style: o
|
|
1035
1047
|
}), this;
|
|
1036
1048
|
}
|
|
1037
1049
|
barcode(e, r) {
|
|
@@ -1044,11 +1056,11 @@ class ne {
|
|
|
1044
1056
|
fallbackText: e
|
|
1045
1057
|
}), this;
|
|
1046
1058
|
}
|
|
1047
|
-
qrcode(e, r, n,
|
|
1059
|
+
qrcode(e, r, n, o) {
|
|
1048
1060
|
return this.components.push({
|
|
1049
1061
|
kind: "qrcode",
|
|
1050
1062
|
leftMm: n,
|
|
1051
|
-
topMm:
|
|
1063
|
+
topMm: o,
|
|
1052
1064
|
widthMm: r,
|
|
1053
1065
|
heightMm: r,
|
|
1054
1066
|
fallbackText: e
|
|
@@ -1064,61 +1076,63 @@ class ne {
|
|
|
1064
1076
|
return this.done().build();
|
|
1065
1077
|
}
|
|
1066
1078
|
}
|
|
1067
|
-
function
|
|
1068
|
-
return new
|
|
1079
|
+
function ue() {
|
|
1080
|
+
return new oe();
|
|
1069
1081
|
}
|
|
1070
1082
|
export {
|
|
1071
|
-
|
|
1072
|
-
|
|
1083
|
+
be as CSS_DPI,
|
|
1084
|
+
ye as DEFAULT_BORDER_PT,
|
|
1073
1085
|
X as DEFAULT_FONT_PT,
|
|
1074
|
-
|
|
1075
|
-
|
|
1086
|
+
we as DEFAULT_STROKE_COLOR,
|
|
1087
|
+
Nt as DEFAULT_TEXT_COLOR,
|
|
1076
1088
|
Q as LINE_HEIGHT,
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1089
|
+
Se as MM_PER_INCH,
|
|
1090
|
+
ht as PAPER_SIZES,
|
|
1091
|
+
ie as PageBuilder,
|
|
1092
|
+
At as RENDER_PLAN_SCHEMA_VERSION,
|
|
1093
|
+
Te as SCHEMA_VERSION_JH4J,
|
|
1094
|
+
xe as SCHEMA_VERSION_LOCAL,
|
|
1095
|
+
ke as SCHEMA_VERSION_MACH,
|
|
1096
|
+
oe as TemplateBuilder,
|
|
1097
|
+
le as assertRenderPlan,
|
|
1098
|
+
ve as charWidthEm,
|
|
1099
|
+
B as classOf,
|
|
1100
|
+
Kt as computePageWindow,
|
|
1101
|
+
Ce as createCanvasMeasurer,
|
|
1102
|
+
ge as createCanvasPager,
|
|
1103
|
+
Pe as createHeuristicMeasurer,
|
|
1104
|
+
ue as createTemplate,
|
|
1105
|
+
zt as evalStyleRule,
|
|
1094
1106
|
Mt as formatValue,
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1107
|
+
ot as heuristicMeasurer,
|
|
1108
|
+
fe as importJh4jTemplateContent,
|
|
1109
|
+
Et as isImageBackedComponent,
|
|
1098
1110
|
ut as isRichText,
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1111
|
+
Tt as measurePageSizePx,
|
|
1112
|
+
Ae as measureTextMm,
|
|
1113
|
+
$t as mmToPx,
|
|
1114
|
+
Ee as mmToPxFactor,
|
|
1115
|
+
de as paginateTemplate,
|
|
1116
|
+
Bt as parseDateLocal,
|
|
1117
|
+
he as planFontSizePx,
|
|
1105
1118
|
K as ptToPx,
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1119
|
+
$e as pxToMm,
|
|
1120
|
+
St as renderComponent,
|
|
1121
|
+
Ut as renderPage,
|
|
1122
|
+
ce as renderPlan,
|
|
1123
|
+
me as renderPlanToCanvas,
|
|
1111
1124
|
tt as resolveBoxBorders,
|
|
1112
1125
|
V as resolveFontSize,
|
|
1113
1126
|
Rt as resolveGridLayout,
|
|
1114
|
-
|
|
1115
|
-
|
|
1127
|
+
Ht as resolveLineHeight,
|
|
1128
|
+
re as resolvePaper,
|
|
1116
1129
|
O as resolveStroke,
|
|
1117
1130
|
pt as resolveTextColor,
|
|
1118
1131
|
G as round,
|
|
1119
|
-
|
|
1132
|
+
rt as toNumber,
|
|
1133
|
+
He as toRenderPlan,
|
|
1120
1134
|
bt as validateComponent,
|
|
1121
|
-
|
|
1122
|
-
|
|
1135
|
+
Wt as validatePage,
|
|
1136
|
+
It as validateRenderPlan,
|
|
1123
1137
|
Z as wrapText
|
|
1124
1138
|
};
|