@agile-team/mach-report 0.9.1 → 0.10.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/dist/ReportPreview--ElcAKoi.cjs +6 -0
- package/dist/ReportPreview-C6b5TOzz.js +1068 -0
- package/dist/builder/template-builder.d.ts +16 -0
- package/dist/index.cjs +3 -3
- package/dist/index.js +50 -33
- package/dist/layout/paginate.d.ts +18 -0
- package/dist/{plugin-Bo8QqzCz.js → plugin-QjAiSBP6.js} +1 -1
- package/dist/{plugin-Dh1exwdD.cjs → plugin-gftml2ST.cjs} +1 -1
- package/dist/style.css +1 -1
- package/dist/vue/ReportParamPanel.d.ts +19 -0
- package/dist/vue/ReportPreview.d.ts +23 -0
- package/dist/vue/async.d.cts +30 -0
- package/dist/vue/async.d.ts +30 -0
- package/dist/vue/config.d.ts +9 -1
- package/dist/vue/index.d.cts +1 -0
- package/dist/vue/index.d.ts +1 -0
- package/dist/vue/plugin.d.ts +30 -0
- package/dist/vue-async.cjs +1 -1
- package/dist/vue-async.js +3 -3
- package/dist/vue.cjs +1 -1
- package/dist/vue.js +32 -31
- package/package.json +10 -1
- package/dist/ReportPreview-D-Us9mrX.cjs +0 -6
- package/dist/ReportPreview-VCx59rSt.js +0 -926
|
@@ -0,0 +1,1068 @@
|
|
|
1
|
+
import { ref as k, computed as x, shallowRef as Be, defineComponent as xe, watch as A, nextTick as _e, openBlock as b, createElementBlock as w, createElementVNode as h, toDisplayString as y, Fragment as ee, createCommentVNode as B, normalizeClass as V, renderList as ie, createTextVNode as Le, withKeys as Te, inject as ue, provide as ze, useCssVars as et, watchEffect as Se, onMounted as tt, onUnmounted as nt, normalizeStyle as Y, createBlock as ot, createVNode as at, unref as g, renderSlot as rt } from "vue";
|
|
2
|
+
import { computePageWindow as st, renderPage as We, validateRenderPlan as lt, renderPlanToCanvas as it } from "@agile-team/mach-report";
|
|
3
|
+
import { a as Pe, b as ut, c as ct, n as dt, M as ft, e as pt } from "./plugin-QjAiSBP6.js";
|
|
4
|
+
function mt(e, o, r = {}) {
|
|
5
|
+
const n = r.pxPerMm ?? 3.7795275590551185, a = r.gapPx ?? 18, t = k(0), s = k(800), d = x(
|
|
6
|
+
() => (e.value?.pages ?? []).map((f) => f.pageHeightMm * n)
|
|
7
|
+
), u = x(() => {
|
|
8
|
+
const f = e.value?.pages ?? [];
|
|
9
|
+
let m = 0, v = 0;
|
|
10
|
+
for (const C of f)
|
|
11
|
+
m += C.pageHeightMm * n + a, v = Math.max(v, C.pageWidthMm * n);
|
|
12
|
+
return { w: v, h: m };
|
|
13
|
+
}), p = x(
|
|
14
|
+
() => st({
|
|
15
|
+
pageHeightsPx: d.value,
|
|
16
|
+
viewportHeightPx: s.value / o.value,
|
|
17
|
+
scrollTopPx: t.value / o.value,
|
|
18
|
+
overscan: 1,
|
|
19
|
+
gapPx: a
|
|
20
|
+
})
|
|
21
|
+
), c = x(() => {
|
|
22
|
+
const f = e.value;
|
|
23
|
+
if (!f) return [];
|
|
24
|
+
const { start: m, end: v } = p.value;
|
|
25
|
+
return v < m ? [] : f.pages.slice(m, v + 1).map((C, R) => ({ page: C, index: m + R }));
|
|
26
|
+
});
|
|
27
|
+
function i(f, m) {
|
|
28
|
+
let v = 0;
|
|
29
|
+
return (C) => {
|
|
30
|
+
v || (v = requestAnimationFrame(() => {
|
|
31
|
+
if (v = 0, t.value = C.scrollTop, s.value = C.clientHeight || 800, m.value <= 0) return;
|
|
32
|
+
const R = C.querySelectorAll(".mrp-page-holder");
|
|
33
|
+
if (!R.length) return;
|
|
34
|
+
const W = C.getBoundingClientRect().top + 56;
|
|
35
|
+
let H = 1;
|
|
36
|
+
R.forEach((M) => {
|
|
37
|
+
M.getBoundingClientRect().top <= W && (H = Number(M.dataset.page ?? 1));
|
|
38
|
+
}), f.value = Math.max(1, Math.min(m.value, H));
|
|
39
|
+
}));
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
contentSize: u,
|
|
44
|
+
windowRange: p,
|
|
45
|
+
visiblePages: c,
|
|
46
|
+
makeScrollHandler: i,
|
|
47
|
+
refreshViewport(f) {
|
|
48
|
+
f && (s.value = f.clientHeight || 800);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function vt(e) {
|
|
53
|
+
const o = k(1), r = k("fit");
|
|
54
|
+
function n() {
|
|
55
|
+
requestAnimationFrame(() => {
|
|
56
|
+
const t = e();
|
|
57
|
+
!t || !t.viewport || (o.value = Math.min(
|
|
58
|
+
1,
|
|
59
|
+
Math.max(0.3, (t.viewport.clientWidth - 48) / Math.max(1, t.pageWidthPx))
|
|
60
|
+
));
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
function a(t) {
|
|
64
|
+
t === "fit" ? (r.value = "fit", n()) : (r.value = "raw", o.value = t / 100);
|
|
65
|
+
}
|
|
66
|
+
return { zoom: o, zoomMode: r, applyFitZoom: n, setZoom: a };
|
|
67
|
+
}
|
|
68
|
+
const ce = 8;
|
|
69
|
+
function de() {
|
|
70
|
+
return new Promise((e) => setTimeout(e, 0));
|
|
71
|
+
}
|
|
72
|
+
function ae(e) {
|
|
73
|
+
return `p${Math.round(e.pageWidthMm)}x${Math.round(e.pageHeightMm)}`;
|
|
74
|
+
}
|
|
75
|
+
function se(e) {
|
|
76
|
+
const o = /* @__PURE__ */ new Map();
|
|
77
|
+
e.pages.forEach((s) => {
|
|
78
|
+
o.has(ae(s)) || o.set(ae(s), s);
|
|
79
|
+
});
|
|
80
|
+
const a = `<!doctype html><html><head><meta charset="utf-8"><style>${`.mr-page{margin:0 auto;page-break-after:always;}
|
|
81
|
+
.mr-page tr{break-inside:avoid;page-break-inside:avoid;}
|
|
82
|
+
.mr-comp{break-inside:avoid;page-break-inside:avoid;}
|
|
83
|
+
${[...o.values()].map(
|
|
84
|
+
(s) => `@page ${ae(s)}{size:${Math.round(s.pageWidthMm)}mm ${Math.round(s.pageHeightMm)}mm;margin:0;}`
|
|
85
|
+
).join(`
|
|
86
|
+
`)}
|
|
87
|
+
body{margin:0;background:#fff;}`}</style></head><body>`, t = e.pages.map((s) => {
|
|
88
|
+
const d = We(s, 96, {}, document);
|
|
89
|
+
return d.style.page = ae(s), d.outerHTML;
|
|
90
|
+
});
|
|
91
|
+
return { head: a, pageChunks: t };
|
|
92
|
+
}
|
|
93
|
+
async function gn(e, o = {}) {
|
|
94
|
+
const r = {
|
|
95
|
+
pages: e.flatMap((d) => d.pages)
|
|
96
|
+
};
|
|
97
|
+
if (r.pages.length === 0) return;
|
|
98
|
+
const { head: n, pageChunks: a } = se(r), t = document.createElement("iframe");
|
|
99
|
+
t.style.cssText = "position:fixed;right:0;bottom:0;width:0;height:0;border:0;visibility:hidden;", document.body.appendChild(t);
|
|
100
|
+
let s = !1;
|
|
101
|
+
try {
|
|
102
|
+
const d = t.contentDocument;
|
|
103
|
+
d.open(), d.write(n);
|
|
104
|
+
for (let u = 0; u < a.length; u++)
|
|
105
|
+
d.write(a[u]), u % ce === ce - 1 && (o.onProgress?.(u + 1, a.length), await de());
|
|
106
|
+
d.write("</body></html>"), d.close(), await de(), o.onProgress?.(a.length, a.length), s = !0, t.contentWindow?.focus(), t.contentWindow?.print();
|
|
107
|
+
} catch (d) {
|
|
108
|
+
o.onError?.(d instanceof Error ? `批量打印失败: ${d.message}` : "批量打印失败");
|
|
109
|
+
} finally {
|
|
110
|
+
s ? setTimeout(() => t.remove(), 6e4) : t.remove();
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
function gt(e, o) {
|
|
114
|
+
let r = null, n = !1, a = null;
|
|
115
|
+
function t() {
|
|
116
|
+
r?.remove(), r = null;
|
|
117
|
+
}
|
|
118
|
+
function s(i, f) {
|
|
119
|
+
const m = URL.createObjectURL(i), v = document.createElement("a");
|
|
120
|
+
v.href = m, v.download = f, v.click(), setTimeout(() => URL.revokeObjectURL(m), 1e4);
|
|
121
|
+
}
|
|
122
|
+
async function d() {
|
|
123
|
+
if (n) return;
|
|
124
|
+
const i = e.value;
|
|
125
|
+
if (!i || i.pages.length === 0) return;
|
|
126
|
+
n = !0, t();
|
|
127
|
+
const { head: f, pageChunks: m } = se(i);
|
|
128
|
+
r = document.createElement("iframe"), r.style.cssText = "position:fixed;right:0;bottom:0;width:0;height:0;border:0;visibility:hidden;", document.body.appendChild(r);
|
|
129
|
+
const v = r;
|
|
130
|
+
try {
|
|
131
|
+
const C = v.contentDocument;
|
|
132
|
+
C.open(), C.write(f);
|
|
133
|
+
for (let R = 0; R < m.length; R++)
|
|
134
|
+
if (C.write(m[R]), R % ce === ce - 1 && await de(), v !== r) return;
|
|
135
|
+
C.write("</body></html>"), C.close(), await de(), v.contentWindow?.focus(), v.contentWindow?.print();
|
|
136
|
+
} catch {
|
|
137
|
+
o.onError("调用打印失败,请改用导出 PDF");
|
|
138
|
+
} finally {
|
|
139
|
+
n = !1;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
async function u() {
|
|
143
|
+
if (a) return a;
|
|
144
|
+
const i = e.value;
|
|
145
|
+
if (!(!i || i.pages.length === 0))
|
|
146
|
+
return a = (async () => {
|
|
147
|
+
try {
|
|
148
|
+
const f = await o.getPdfExporter()(i);
|
|
149
|
+
s(
|
|
150
|
+
new Blob([f], { type: "application/pdf" }),
|
|
151
|
+
"mach-report.pdf"
|
|
152
|
+
);
|
|
153
|
+
} catch (f) {
|
|
154
|
+
o.onError(f instanceof Error ? `PDF 导出失败: ${f.message}` : "PDF 导出失败");
|
|
155
|
+
} finally {
|
|
156
|
+
a = null;
|
|
157
|
+
}
|
|
158
|
+
})(), a;
|
|
159
|
+
}
|
|
160
|
+
function p(i) {
|
|
161
|
+
const f = e.value;
|
|
162
|
+
if (!f || f.pages.length === 0) return;
|
|
163
|
+
if (i === "pdf") {
|
|
164
|
+
u();
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
const { head: m, pageChunks: v } = se(f), C = `${m}${v.join("")}</body></html>`;
|
|
168
|
+
s(new Blob([C], { type: "text/html;charset=utf-8" }), `mach-report.${i === "html" ? "html" : i}`);
|
|
169
|
+
}
|
|
170
|
+
function c() {
|
|
171
|
+
const i = e.value;
|
|
172
|
+
if (!i || i.pages.length === 0) return;
|
|
173
|
+
const { head: f, pageChunks: m } = se(i), v = `${f}${m.join("")}</body></html>`, C = new Blob([v], { type: "text/html;charset=utf-8" }), R = URL.createObjectURL(C), W = window.open(R, "_blank");
|
|
174
|
+
if (!W) {
|
|
175
|
+
o.onError("浏览器拦截了弹窗,请允许弹窗后重试"), URL.revokeObjectURL(R);
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
setTimeout(() => W.print(), 400), setTimeout(() => URL.revokeObjectURL(R), 1e4);
|
|
179
|
+
}
|
|
180
|
+
return {
|
|
181
|
+
print: d,
|
|
182
|
+
exportAs: p,
|
|
183
|
+
openPdfWindow: c,
|
|
184
|
+
releasePrintFrame: t
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
const Oe = "mrp-hit";
|
|
188
|
+
function ht(e) {
|
|
189
|
+
e.querySelectorAll(`mark.${Oe}`).forEach((r) => {
|
|
190
|
+
const n = r.parentNode;
|
|
191
|
+
if (n) {
|
|
192
|
+
for (; r.firstChild; ) n.insertBefore(r.firstChild, r);
|
|
193
|
+
r.remove(), n.normalize();
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
function bt(e, o) {
|
|
198
|
+
const r = o.trim();
|
|
199
|
+
if (!r) return 0;
|
|
200
|
+
const n = r.toLowerCase(), a = document.createTreeWalker(e, NodeFilter.SHOW_TEXT, {
|
|
201
|
+
acceptNode(d) {
|
|
202
|
+
const u = d.parentElement;
|
|
203
|
+
return !u || u.closest("mark") || /^(SCRIPT|STYLE)$/.test(u.tagName) ? NodeFilter.FILTER_REJECT : (d.nodeValue ?? "").toLowerCase().includes(n) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT;
|
|
204
|
+
}
|
|
205
|
+
}), t = [];
|
|
206
|
+
for (let d = a.nextNode(); d; d = a.nextNode()) t.push(d);
|
|
207
|
+
let s = 0;
|
|
208
|
+
for (const d of t) {
|
|
209
|
+
const u = d.nodeValue ?? "", p = u.toLowerCase(), c = d.parentElement;
|
|
210
|
+
if (!c) continue;
|
|
211
|
+
const i = document.createDocumentFragment();
|
|
212
|
+
let f = 0, m = p.indexOf(n);
|
|
213
|
+
for (; m >= 0; ) {
|
|
214
|
+
m > f && i.appendChild(document.createTextNode(u.slice(f, m)));
|
|
215
|
+
const v = document.createElement("mark");
|
|
216
|
+
v.className = Oe, v.textContent = u.slice(m, m + r.length), i.appendChild(v), s++, f = m + r.length, m = p.indexOf(n, f);
|
|
217
|
+
}
|
|
218
|
+
f < u.length && i.appendChild(document.createTextNode(u.slice(f))), c.replaceChild(i, d);
|
|
219
|
+
}
|
|
220
|
+
return s;
|
|
221
|
+
}
|
|
222
|
+
function Fe(e, o) {
|
|
223
|
+
let r = 0, n = e.toLowerCase().indexOf(o);
|
|
224
|
+
for (; n >= 0; )
|
|
225
|
+
r++, n = e.toLowerCase().indexOf(o, n + o.length);
|
|
226
|
+
return r;
|
|
227
|
+
}
|
|
228
|
+
function wt(e) {
|
|
229
|
+
const { plan: o, gotoPage: r, highlight: n, clearHighlights: a } = e, t = e.debounceMs ?? 200, s = k(!1), d = k(""), u = k(""), p = k(0);
|
|
230
|
+
let c = null;
|
|
231
|
+
const i = x(() => {
|
|
232
|
+
const M = d.value.trim().toLowerCase(), F = o.value;
|
|
233
|
+
if (!M || !F) return [];
|
|
234
|
+
const L = [];
|
|
235
|
+
return F.pages.forEach((O, te) => {
|
|
236
|
+
for (const N of O.components)
|
|
237
|
+
if (N.grid) {
|
|
238
|
+
for (const U of N.grid.cells ?? [])
|
|
239
|
+
for (const Z of U ?? [])
|
|
240
|
+
if (typeof Z?.text == "string")
|
|
241
|
+
for (let ne = 0; ne < Fe(Z.text, M); ne++) L.push(te);
|
|
242
|
+
} else if (N.kind === "text" && typeof N.text == "string")
|
|
243
|
+
for (let U = 0; U < Fe(N.text, M); U++) L.push(te);
|
|
244
|
+
}), L;
|
|
245
|
+
}), f = x(() => i.value.length);
|
|
246
|
+
function m(M) {
|
|
247
|
+
if (u.value = M, c && clearTimeout(c), M.trim() === "") {
|
|
248
|
+
c = null, d.value = "", p.value = 0;
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
c = setTimeout(() => {
|
|
252
|
+
c = null, d.value = u.value, p.value = 0;
|
|
253
|
+
const F = i.value[0];
|
|
254
|
+
F != null && r(F + 1);
|
|
255
|
+
}, t);
|
|
256
|
+
}
|
|
257
|
+
function v(M) {
|
|
258
|
+
const F = i.value.length;
|
|
259
|
+
F !== 0 && (p.value = (p.value + M + F) % F, r(i.value[p.value] + 1));
|
|
260
|
+
}
|
|
261
|
+
function C() {
|
|
262
|
+
s.value = !s.value;
|
|
263
|
+
}
|
|
264
|
+
function R(M) {
|
|
265
|
+
const F = d.value.trim();
|
|
266
|
+
F && n(M, F);
|
|
267
|
+
}
|
|
268
|
+
function W(M) {
|
|
269
|
+
a(M);
|
|
270
|
+
}
|
|
271
|
+
function H() {
|
|
272
|
+
u.value = "", d.value = "", p.value = 0, c && clearTimeout(c), c = null;
|
|
273
|
+
}
|
|
274
|
+
return {
|
|
275
|
+
visible: s,
|
|
276
|
+
query: d,
|
|
277
|
+
matchIndex: p,
|
|
278
|
+
matchCount: f,
|
|
279
|
+
toggle: C,
|
|
280
|
+
onInput: m,
|
|
281
|
+
onNav: v,
|
|
282
|
+
apply: R,
|
|
283
|
+
clear: W,
|
|
284
|
+
reset: H
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
function yt(e, o) {
|
|
288
|
+
const r = x(() => {
|
|
289
|
+
if (e.value) return !0;
|
|
290
|
+
if (typeof location > "u") return !1;
|
|
291
|
+
try {
|
|
292
|
+
return new URLSearchParams(location.search).get("mrp-debug") === "1";
|
|
293
|
+
} catch {
|
|
294
|
+
return !1;
|
|
295
|
+
}
|
|
296
|
+
}), n = x(() => !r.value || !o.plan.value ? 0 : Math.round(JSON.stringify(o.plan.value).length / 1024)), a = x(() => !r.value || !o.plan.value ? null : {
|
|
297
|
+
pages: o.pageCount.value,
|
|
298
|
+
window: `${o.windowRange.value.start}-${o.windowRange.value.end}`,
|
|
299
|
+
zoom: `${Math.round(o.zoom.value * 100)}%`,
|
|
300
|
+
loadMs: `${o.loadMs.value}ms`,
|
|
301
|
+
planKB: n.value
|
|
302
|
+
});
|
|
303
|
+
return { enabled: r, debugStats: a };
|
|
304
|
+
}
|
|
305
|
+
function Pt(e, o) {
|
|
306
|
+
const { thumbsRoot: r, visible: n, renderThumbCanvas: a } = o;
|
|
307
|
+
let t = null;
|
|
308
|
+
function s(p, c) {
|
|
309
|
+
if (!e.value || p.childElementCount > 0) return;
|
|
310
|
+
const i = a(c);
|
|
311
|
+
i && (i.style.width = "100%", i.style.height = "100%", i.style.display = "block", p.appendChild(i));
|
|
312
|
+
}
|
|
313
|
+
return { schedule: () => {
|
|
314
|
+
!n.value || !e.value || !r.value || typeof IntersectionObserver > "u" || (t?.disconnect(), t = new IntersectionObserver(
|
|
315
|
+
(p) => {
|
|
316
|
+
for (const c of p) {
|
|
317
|
+
if (!c.isIntersecting) continue;
|
|
318
|
+
const i = c.target;
|
|
319
|
+
s(i, Number(i.dataset.thumb ?? 1) - 1), t?.unobserve(i);
|
|
320
|
+
}
|
|
321
|
+
},
|
|
322
|
+
{ root: r.value, rootMargin: "200px" }
|
|
323
|
+
), r.value.querySelectorAll("[data-thumb]").forEach((p) => {
|
|
324
|
+
t.observe(p);
|
|
325
|
+
}));
|
|
326
|
+
}, destroy: () => {
|
|
327
|
+
t?.disconnect(), t = null;
|
|
328
|
+
} };
|
|
329
|
+
}
|
|
330
|
+
function xt() {
|
|
331
|
+
const e = Be(0);
|
|
332
|
+
return {
|
|
333
|
+
loadMs: e,
|
|
334
|
+
start() {
|
|
335
|
+
return typeof performance < "u" ? performance.now() : 0;
|
|
336
|
+
},
|
|
337
|
+
end(o) {
|
|
338
|
+
e.value = o ? Math.round(performance.now() - o) : 0;
|
|
339
|
+
}
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
const Et = { class: "mrp-toolbar" }, $t = { class: "mrp-title" }, Ct = ["disabled"], Mt = { class: "mrp-pageinfo" }, kt = ["disabled"], Rt = {
|
|
343
|
+
key: 1,
|
|
344
|
+
class: "mrp-search"
|
|
345
|
+
}, Tt = ["placeholder", "value"], St = {
|
|
346
|
+
key: 0,
|
|
347
|
+
class: "mrp-search-count"
|
|
348
|
+
}, Ft = ["disabled"], It = ["disabled"], Bt = /* @__PURE__ */ xe({
|
|
349
|
+
__name: "ReportToolbar",
|
|
350
|
+
props: {
|
|
351
|
+
pageCount: {},
|
|
352
|
+
currentPage: {},
|
|
353
|
+
zoomMode: {},
|
|
354
|
+
zoom: {},
|
|
355
|
+
showExport: { type: Boolean },
|
|
356
|
+
showPrint: { type: Boolean },
|
|
357
|
+
showPdfWindow: { type: Boolean },
|
|
358
|
+
messages: {},
|
|
359
|
+
search: {},
|
|
360
|
+
thumbsVisible: { type: Boolean }
|
|
361
|
+
},
|
|
362
|
+
emits: ["goto", "zoom", "export", "print", "pdf-window", "search-input", "search-nav", "search-toggle", "thumbs-toggle"],
|
|
363
|
+
setup(e) {
|
|
364
|
+
const o = e, r = k(null);
|
|
365
|
+
A(
|
|
366
|
+
() => o.search.visible,
|
|
367
|
+
(a) => {
|
|
368
|
+
a && _e(() => r.value?.focus());
|
|
369
|
+
}
|
|
370
|
+
);
|
|
371
|
+
function n(a, t, s) {
|
|
372
|
+
return a.replace("{cur}", String(t)).replace("{total}", String(s));
|
|
373
|
+
}
|
|
374
|
+
return (a, t) => (b(), w("div", Et, [
|
|
375
|
+
h("span", $t, y(e.messages.title), 1),
|
|
376
|
+
e.pageCount > 0 ? (b(), w(ee, { key: 0 }, [
|
|
377
|
+
h("button", {
|
|
378
|
+
class: "mrp-nav",
|
|
379
|
+
type: "button",
|
|
380
|
+
disabled: e.currentPage <= 1,
|
|
381
|
+
onClick: t[0] || (t[0] = (s) => a.$emit("goto", e.currentPage - 1))
|
|
382
|
+
}, y(e.messages.prevPage), 9, Ct),
|
|
383
|
+
h("span", Mt, y(n(e.messages.pageInfo, e.currentPage, e.pageCount)), 1),
|
|
384
|
+
h("button", {
|
|
385
|
+
class: "mrp-nav",
|
|
386
|
+
type: "button",
|
|
387
|
+
disabled: e.currentPage >= e.pageCount,
|
|
388
|
+
onClick: t[1] || (t[1] = (s) => a.$emit("goto", e.currentPage + 1))
|
|
389
|
+
}, y(e.messages.nextPage), 9, kt)
|
|
390
|
+
], 64)) : B("", !0),
|
|
391
|
+
t[14] || (t[14] = h("span", { class: "mrp-spacer" }, null, -1)),
|
|
392
|
+
e.search.visible ? (b(), w("div", Rt, [
|
|
393
|
+
h("input", {
|
|
394
|
+
ref_key: "searchInputRef",
|
|
395
|
+
ref: r,
|
|
396
|
+
class: "mrp-search-input",
|
|
397
|
+
type: "text",
|
|
398
|
+
placeholder: e.messages.searchPlaceholder,
|
|
399
|
+
value: e.search.query,
|
|
400
|
+
onInput: t[2] || (t[2] = (s) => a.$emit("search-input", s.target.value))
|
|
401
|
+
}, null, 40, Tt),
|
|
402
|
+
e.search.query ? (b(), w("span", St, y(n(e.messages.matchInfo, e.search.matchIndex + 1, e.search.matchCount)), 1)) : B("", !0),
|
|
403
|
+
h("button", {
|
|
404
|
+
class: "mrp-nav",
|
|
405
|
+
type: "button",
|
|
406
|
+
disabled: e.search.matchCount === 0,
|
|
407
|
+
onClick: t[3] || (t[3] = (s) => a.$emit("search-nav", -1))
|
|
408
|
+
}, y(e.messages.prevMatch), 9, Ft),
|
|
409
|
+
h("button", {
|
|
410
|
+
class: "mrp-nav",
|
|
411
|
+
type: "button",
|
|
412
|
+
disabled: e.search.matchCount === 0,
|
|
413
|
+
onClick: t[4] || (t[4] = (s) => a.$emit("search-nav", 1))
|
|
414
|
+
}, y(e.messages.nextMatch), 9, It)
|
|
415
|
+
])) : B("", !0),
|
|
416
|
+
h("button", {
|
|
417
|
+
class: V(["mrp-nav", { "mrp-active": e.search.visible }]),
|
|
418
|
+
type: "button",
|
|
419
|
+
title: "Ctrl+F",
|
|
420
|
+
onClick: t[5] || (t[5] = (s) => a.$emit("search-toggle"))
|
|
421
|
+
}, " 🔍 ", 2),
|
|
422
|
+
h("button", {
|
|
423
|
+
class: V(["mrp-nav", { "mrp-active": e.thumbsVisible }]),
|
|
424
|
+
type: "button",
|
|
425
|
+
onClick: t[6] || (t[6] = (s) => a.$emit("thumbs-toggle"))
|
|
426
|
+
}, " ▦ " + y(e.messages.thumbnails), 3),
|
|
427
|
+
h("button", {
|
|
428
|
+
class: V(["mrp-nav", { "mrp-active": e.zoomMode === "fit" }]),
|
|
429
|
+
type: "button",
|
|
430
|
+
onClick: t[7] || (t[7] = (s) => a.$emit("zoom", "fit"))
|
|
431
|
+
}, y(e.messages.fitWidth), 3),
|
|
432
|
+
h("button", {
|
|
433
|
+
class: V(["mrp-nav", { "mrp-active": e.zoomMode === "raw" && Math.round(e.zoom * 100) === 100 }]),
|
|
434
|
+
type: "button",
|
|
435
|
+
onClick: t[8] || (t[8] = (s) => a.$emit("zoom", 100))
|
|
436
|
+
}, " 100% ", 2),
|
|
437
|
+
h("button", {
|
|
438
|
+
class: V(["mrp-nav", { "mrp-active": e.zoomMode === "raw" && Math.round(e.zoom * 100) === 150 }]),
|
|
439
|
+
type: "button",
|
|
440
|
+
onClick: t[9] || (t[9] = (s) => a.$emit("zoom", 150))
|
|
441
|
+
}, " 150% ", 2),
|
|
442
|
+
e.showExport ? (b(), w("button", {
|
|
443
|
+
key: 2,
|
|
444
|
+
class: "mrp-nav",
|
|
445
|
+
type: "button",
|
|
446
|
+
onClick: t[10] || (t[10] = (s) => a.$emit("export", "html"))
|
|
447
|
+
}, y(e.messages.exportHtml), 1)) : B("", !0),
|
|
448
|
+
e.showExport ? (b(), w("button", {
|
|
449
|
+
key: 3,
|
|
450
|
+
class: "mrp-nav",
|
|
451
|
+
type: "button",
|
|
452
|
+
onClick: t[11] || (t[11] = (s) => a.$emit("export", "pdf"))
|
|
453
|
+
}, y(e.messages.exportPdf), 1)) : B("", !0),
|
|
454
|
+
e.showPrint ? (b(), w("button", {
|
|
455
|
+
key: 4,
|
|
456
|
+
class: "mrp-nav",
|
|
457
|
+
type: "button",
|
|
458
|
+
onClick: t[12] || (t[12] = (s) => a.$emit("print"))
|
|
459
|
+
}, y(e.messages.print), 1)) : B("", !0),
|
|
460
|
+
e.showPdfWindow ? (b(), w("button", {
|
|
461
|
+
key: 5,
|
|
462
|
+
class: "mrp-nav",
|
|
463
|
+
type: "button",
|
|
464
|
+
onClick: t[13] || (t[13] = (s) => a.$emit("pdf-window"))
|
|
465
|
+
}, y(e.messages.pdfWindow), 1)) : B("", !0)
|
|
466
|
+
]));
|
|
467
|
+
}
|
|
468
|
+
}), Ee = (e, o) => {
|
|
469
|
+
const r = e.__vccOpts || e;
|
|
470
|
+
for (const [n, a] of o)
|
|
471
|
+
r[n] = a;
|
|
472
|
+
return r;
|
|
473
|
+
}, Lt = /* @__PURE__ */ Ee(Bt, [["__scopeId", "data-v-f50c26e8"]]), zt = { class: "mrp-params" }, Wt = { class: "mrp-params-title" }, Ot = { class: "mrp-params-grid" }, Ht = { class: "mrp-param-label" }, Nt = {
|
|
474
|
+
key: 0,
|
|
475
|
+
class: "mrp-param-star"
|
|
476
|
+
}, Dt = ["value", "onChange"], qt = {
|
|
477
|
+
value: "",
|
|
478
|
+
disabled: "",
|
|
479
|
+
hidden: ""
|
|
480
|
+
}, At = ["value"], Vt = ["type", "placeholder", "value", "onInput"], Ut = { class: "mrp-params-actions" }, jt = /* @__PURE__ */ xe({
|
|
481
|
+
__name: "ReportParamPanel",
|
|
482
|
+
props: {
|
|
483
|
+
defs: {},
|
|
484
|
+
modelValue: {},
|
|
485
|
+
messages: {},
|
|
486
|
+
attempted: { type: Boolean }
|
|
487
|
+
},
|
|
488
|
+
emits: ["update:modelValue", "query", "reset"],
|
|
489
|
+
setup(e, { emit: o }) {
|
|
490
|
+
const r = e, n = o, a = k({ ...r.modelValue });
|
|
491
|
+
A(
|
|
492
|
+
() => r.modelValue,
|
|
493
|
+
(u) => {
|
|
494
|
+
a.value = { ...u };
|
|
495
|
+
}
|
|
496
|
+
);
|
|
497
|
+
const t = x(
|
|
498
|
+
() => r.defs.map((u) => ({
|
|
499
|
+
def: u,
|
|
500
|
+
label: u.label ?? u.field,
|
|
501
|
+
value: a.value[u.field] ?? ""
|
|
502
|
+
}))
|
|
503
|
+
);
|
|
504
|
+
function s(u, p) {
|
|
505
|
+
a.value = { ...a.value, [u]: p }, n("update:modelValue", { ...a.value });
|
|
506
|
+
}
|
|
507
|
+
function d(u) {
|
|
508
|
+
const p = r.defs.find((c) => c.field === u);
|
|
509
|
+
return r.attempted && p?.required === !0 && !(a.value[u] ?? "").trim();
|
|
510
|
+
}
|
|
511
|
+
return (u, p) => (b(), w("div", zt, [
|
|
512
|
+
h("span", Wt, y(e.messages.paramsTitle), 1),
|
|
513
|
+
h("div", Ot, [
|
|
514
|
+
(b(!0), w(ee, null, ie(t.value, (c) => (b(), w("label", {
|
|
515
|
+
key: c.def.field,
|
|
516
|
+
class: V(["mrp-param", { "mrp-param-missing": d(c.def.field) }])
|
|
517
|
+
}, [
|
|
518
|
+
h("span", Ht, [
|
|
519
|
+
Le(y(c.label), 1),
|
|
520
|
+
c.def.required ? (b(), w("i", Nt, "*")) : B("", !0)
|
|
521
|
+
]),
|
|
522
|
+
(c.def.type ?? "text") === "select" ? (b(), w("select", {
|
|
523
|
+
key: 0,
|
|
524
|
+
class: "mrp-param-input",
|
|
525
|
+
value: c.value,
|
|
526
|
+
onChange: (i) => s(c.def.field, i.target.value),
|
|
527
|
+
onKeydown: p[0] || (p[0] = Te((i) => u.$emit("query"), ["enter"]))
|
|
528
|
+
}, [
|
|
529
|
+
h("option", qt, y(c.def.placeholder ?? `请选择${c.label}`), 1),
|
|
530
|
+
(b(!0), w(ee, null, ie(c.def.options ?? [], (i) => (b(), w("option", {
|
|
531
|
+
key: i.value,
|
|
532
|
+
value: i.value
|
|
533
|
+
}, y(i.label), 9, At))), 128))
|
|
534
|
+
], 40, Dt)) : (b(), w("input", {
|
|
535
|
+
key: 1,
|
|
536
|
+
class: "mrp-param-input",
|
|
537
|
+
type: c.def.type === "number" ? "number" : c.def.type === "date" ? "date" : "text",
|
|
538
|
+
placeholder: c.def.placeholder ?? `请输入${c.label}`,
|
|
539
|
+
value: c.value,
|
|
540
|
+
onInput: (i) => s(c.def.field, i.target.value),
|
|
541
|
+
onKeydown: p[1] || (p[1] = Te((i) => u.$emit("query"), ["enter"]))
|
|
542
|
+
}, null, 40, Vt))
|
|
543
|
+
], 2))), 128))
|
|
544
|
+
]),
|
|
545
|
+
h("div", Ut, [
|
|
546
|
+
h("button", {
|
|
547
|
+
class: "mrp-nav mrp-param-query",
|
|
548
|
+
type: "button",
|
|
549
|
+
onClick: p[2] || (p[2] = (c) => u.$emit("query"))
|
|
550
|
+
}, y(e.messages.query), 1),
|
|
551
|
+
h("button", {
|
|
552
|
+
class: "mrp-nav",
|
|
553
|
+
type: "button",
|
|
554
|
+
onClick: p[3] || (p[3] = (c) => u.$emit("reset"))
|
|
555
|
+
}, y(e.messages.reset), 1)
|
|
556
|
+
])
|
|
557
|
+
]));
|
|
558
|
+
}
|
|
559
|
+
}), Kt = /* @__PURE__ */ Ee(jt, [["__scopeId", "data-v-aafce92d"]]), Gt = {
|
|
560
|
+
title: "报表预览",
|
|
561
|
+
prevPage: "‹ 上一页",
|
|
562
|
+
nextPage: "下一页 ›",
|
|
563
|
+
pageInfo: "{cur} / {total}",
|
|
564
|
+
fitWidth: "适宽",
|
|
565
|
+
exportHtml: "导出 HTML",
|
|
566
|
+
exportPdf: "导出 PDF",
|
|
567
|
+
print: "打印",
|
|
568
|
+
pdfWindow: "PDF 窗口",
|
|
569
|
+
loading: "报表渲染中…",
|
|
570
|
+
empty: "暂无预览数据",
|
|
571
|
+
errorPrefix: "",
|
|
572
|
+
retry: "重试",
|
|
573
|
+
searchPlaceholder: "搜索报表内容",
|
|
574
|
+
matchInfo: "{cur}/{total}",
|
|
575
|
+
prevMatch: "‹",
|
|
576
|
+
nextMatch: "›",
|
|
577
|
+
thumbnails: "缩略图",
|
|
578
|
+
paramsTitle: "查询条件",
|
|
579
|
+
query: "查 询",
|
|
580
|
+
reset: "重 置",
|
|
581
|
+
paramRequired: "请填写{label}"
|
|
582
|
+
}, Yt = {
|
|
583
|
+
shellBg: "#525659",
|
|
584
|
+
shellFg: "#e8e8e8",
|
|
585
|
+
toolbarBg: "#323639",
|
|
586
|
+
toolbarBorder: "#22252a",
|
|
587
|
+
toolbarFg: "#e8e8e8",
|
|
588
|
+
btnFg: "#cfcfcf",
|
|
589
|
+
btnBorder: "#4a4d52",
|
|
590
|
+
btnHoverBg: "#414549",
|
|
591
|
+
btnHoverFg: "#ffffff",
|
|
592
|
+
btnActiveBg: "#2d5fb8"
|
|
593
|
+
};
|
|
594
|
+
function hn(e) {
|
|
595
|
+
return e;
|
|
596
|
+
}
|
|
597
|
+
function bn(e) {
|
|
598
|
+
return e;
|
|
599
|
+
}
|
|
600
|
+
const q = {
|
|
601
|
+
showExport: !0,
|
|
602
|
+
showPrint: !0,
|
|
603
|
+
showPdfWindow: !0,
|
|
604
|
+
showParams: !0,
|
|
605
|
+
gapPx: 18,
|
|
606
|
+
pdfFontUrl: "/simhei.ttf",
|
|
607
|
+
logger: console
|
|
608
|
+
}, wn = { warn: () => {
|
|
609
|
+
}, info: () => {
|
|
610
|
+
} };
|
|
611
|
+
function Zt(e, o) {
|
|
612
|
+
const r = o ? e?.presets?.[o] : e?.defaultPreset ? e?.presets?.[e.defaultPreset] : void 0, n = { ...e?.defaults, ...r };
|
|
613
|
+
return {
|
|
614
|
+
showExport: n.showExport ?? q.showExport,
|
|
615
|
+
showPrint: n.showPrint ?? q.showPrint,
|
|
616
|
+
showPdfWindow: n.showPdfWindow ?? q.showPdfWindow,
|
|
617
|
+
showParams: n.showParams ?? q.showParams,
|
|
618
|
+
gapPx: n.gapPx ?? q.gapPx,
|
|
619
|
+
pdfFontUrl: n.pdfFontUrl ?? q.pdfFontUrl,
|
|
620
|
+
theme: { ...Yt, ...n.theme },
|
|
621
|
+
messages: { ...Gt, ...n.messages },
|
|
622
|
+
logger: n.logger ?? q.logger
|
|
623
|
+
};
|
|
624
|
+
}
|
|
625
|
+
function Jt(e) {
|
|
626
|
+
const o = {};
|
|
627
|
+
return e.shellBg != null && (o["--mrp-shell-bg"] = e.shellBg), e.shellFg != null && (o["--mrp-shell-fg"] = e.shellFg), e.toolbarBg != null && (o["--mrp-toolbar-bg"] = e.toolbarBg), e.toolbarBorder != null && (o["--mrp-toolbar-border"] = e.toolbarBorder), e.toolbarFg != null && (o["--mrp-toolbar-fg"] = e.toolbarFg), e.btnFg != null && (o["--mrp-btn-fg"] = e.btnFg), e.btnBorder != null && (o["--mrp-btn-border"] = e.btnBorder), e.btnHoverBg != null && (o["--mrp-btn-hover-bg"] = e.btnHoverBg), e.btnHoverFg != null && (o["--mrp-btn-hover-fg"] = e.btnHoverFg), e.btnActiveBg != null && (o["--mrp-btn-active-bg"] = e.btnActiveBg), o;
|
|
628
|
+
}
|
|
629
|
+
function yn(e) {
|
|
630
|
+
const o = ue(Pe, null), r = x(() => {
|
|
631
|
+
const n = o?.value ?? null, a = "defaults" in e && "presets" in e ? e : { defaults: e, presets: {} };
|
|
632
|
+
return n ? {
|
|
633
|
+
defaults: { ...n.defaults, ...a.defaults },
|
|
634
|
+
presets: { ...n.presets, ...a.presets },
|
|
635
|
+
defaultPreset: a.defaultPreset ?? n.defaultPreset
|
|
636
|
+
} : a;
|
|
637
|
+
});
|
|
638
|
+
ze(Pe, r);
|
|
639
|
+
}
|
|
640
|
+
function Xt() {
|
|
641
|
+
return ue(Pe, x(() => null));
|
|
642
|
+
}
|
|
643
|
+
class le extends Error {
|
|
644
|
+
constructor(o, r, n) {
|
|
645
|
+
super(r), this.name = "MachReportError", this.code = o, this.cause = n;
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
function Qt(e) {
|
|
649
|
+
return e instanceof le ? { code: e.code, cause: e.cause } : { code: "render", cause: e };
|
|
650
|
+
}
|
|
651
|
+
const _t = { class: "mrp-main" }, en = {
|
|
652
|
+
key: 0,
|
|
653
|
+
class: "mrp-state"
|
|
654
|
+
}, tn = {
|
|
655
|
+
key: 1,
|
|
656
|
+
class: "mrp-state mrp-error"
|
|
657
|
+
}, nn = {
|
|
658
|
+
key: 2,
|
|
659
|
+
class: "mrp-state"
|
|
660
|
+
}, on = ["data-page"], an = ["onClick"], rn = ["data-thumb"], sn = { class: "mrp-thumb-no" }, ln = { class: "mrp-overlay" }, un = {
|
|
661
|
+
key: 1,
|
|
662
|
+
class: "mrp-debug",
|
|
663
|
+
"aria-hidden": "true"
|
|
664
|
+
}, re = 96 / 25.4, Ie = "mach-report:ui", cn = /* @__PURE__ */ xe({
|
|
665
|
+
__name: "ReportPreview",
|
|
666
|
+
props: {
|
|
667
|
+
tempId: {
|
|
668
|
+
type: [String, Array],
|
|
669
|
+
default: null
|
|
670
|
+
},
|
|
671
|
+
furnitureTempId: { type: String, default: "" },
|
|
672
|
+
params: {
|
|
673
|
+
type: Object,
|
|
674
|
+
default: () => ({})
|
|
675
|
+
},
|
|
676
|
+
height: { type: String, default: "100vh" },
|
|
677
|
+
autoLoad: { type: Boolean, default: !0 },
|
|
678
|
+
/** 以下显隐/间距不传时走配置中心(preset > defaults > 内置缺省) */
|
|
679
|
+
showExport: { type: Boolean, default: void 0 },
|
|
680
|
+
showPrint: { type: Boolean, default: void 0 },
|
|
681
|
+
showPdfWindow: { type: Boolean, default: void 0 },
|
|
682
|
+
/** 页间距(px);不传走配置中心 */
|
|
683
|
+
gapPx: { type: Number, default: void 0 },
|
|
684
|
+
/** 工具栏/状态文案覆写(不传走配置中心 messages) */
|
|
685
|
+
messages: { type: Object, default: void 0 },
|
|
686
|
+
/** 启用的 preset 名(不传用配置中心 defaultPreset) */
|
|
687
|
+
preset: { type: String, default: void 0 },
|
|
688
|
+
/** 调试面板(也可用 URL ?mrp-debug=1 开启) */
|
|
689
|
+
debug: { type: Boolean, default: !1 },
|
|
690
|
+
/** 参数定义(优先级:prop > 模板 params;有定义且未关闭时显示查询面板) */
|
|
691
|
+
paramDefs: {
|
|
692
|
+
type: Array,
|
|
693
|
+
default: void 0
|
|
694
|
+
},
|
|
695
|
+
/** 参数面板显隐(不传走配置中心,缺省 true;有参数定义才渲染) */
|
|
696
|
+
showParams: { type: Boolean, default: void 0 },
|
|
697
|
+
fetcher: {
|
|
698
|
+
type: Function,
|
|
699
|
+
default: null
|
|
700
|
+
}
|
|
701
|
+
},
|
|
702
|
+
emits: ["loaded", "error"],
|
|
703
|
+
setup(e, { expose: o, emit: r }) {
|
|
704
|
+
et((l) => ({
|
|
705
|
+
v06e552ba: v.value + "px"
|
|
706
|
+
}));
|
|
707
|
+
const n = e, a = r, t = Be(null), s = k(!1), d = k(""), u = k(1), p = k(null), c = k(null), i = k(null), f = k(!1), m = xt(), v = x(() => Math.max(0, Z.value)), C = ue(ut, null), W = ue(ct, null) ?? pt({ fontUrl: "/simhei.ttf" }), H = x(() => dt(n.tempId)), M = x(() => t.value?.pages.length ?? 0), F = Xt(), L = x(() => Zt(F.value, n.preset)), O = x(() => ({
|
|
708
|
+
...L.value.messages,
|
|
709
|
+
...n.messages
|
|
710
|
+
})), te = x(() => n.showExport ?? L.value.showExport), N = x(() => n.showPrint ?? L.value.showPrint), U = x(() => n.showPdfWindow ?? L.value.showPdfWindow), Z = x(() => n.gapPx ?? L.value.gapPx), ne = x(() => n.showParams ?? L.value.showParams), j = x(() => n.paramDefs ?? []), J = k({}), fe = k(!1);
|
|
711
|
+
function pe(l) {
|
|
712
|
+
const P = {};
|
|
713
|
+
for (const E of l)
|
|
714
|
+
P[E.field] = n.params[E.field] ?? E.defaultValue ?? "";
|
|
715
|
+
J.value = P, fe.value = !1;
|
|
716
|
+
}
|
|
717
|
+
pe(j.value), A(j, (l) => pe(l));
|
|
718
|
+
const He = x(() => ({
|
|
719
|
+
...n.params,
|
|
720
|
+
...Object.fromEntries(
|
|
721
|
+
Object.entries(J.value).filter(([, l]) => l !== "")
|
|
722
|
+
)
|
|
723
|
+
}));
|
|
724
|
+
function Ne() {
|
|
725
|
+
return j.value.filter(
|
|
726
|
+
(l) => l.required === !0 && !(J.value[l.field] ?? "").trim()
|
|
727
|
+
);
|
|
728
|
+
}
|
|
729
|
+
function De() {
|
|
730
|
+
fe.value = !0;
|
|
731
|
+
const l = Ne();
|
|
732
|
+
if (l.length > 0) {
|
|
733
|
+
const P = l[0].label ?? l[0].field, E = O.value.paramRequired.replace("{label}", P);
|
|
734
|
+
d.value = E, a("error", E, { code: "param" });
|
|
735
|
+
return;
|
|
736
|
+
}
|
|
737
|
+
D();
|
|
738
|
+
}
|
|
739
|
+
function qe() {
|
|
740
|
+
pe(j.value);
|
|
741
|
+
}
|
|
742
|
+
const Ae = x(() => ({
|
|
743
|
+
height: n.height,
|
|
744
|
+
...Jt(L.value.theme)
|
|
745
|
+
})), { zoom: I, zoomMode: K, applyFitZoom: $e, setZoom: me } = vt(() => ({
|
|
746
|
+
viewport: c.value,
|
|
747
|
+
pageWidthPx: (t.value?.pages[0]?.pageWidthMm ?? 210) * re
|
|
748
|
+
})), Ve = mt(t, I, {
|
|
749
|
+
pxPerMm: re,
|
|
750
|
+
gapPx: Z.value
|
|
751
|
+
}), { contentSize: ve, windowRange: X, visiblePages: Ue, makeScrollHandler: je, refreshViewport: Ce } = Ve, Ke = je(u, M);
|
|
752
|
+
function ge(l) {
|
|
753
|
+
K.value = "raw", I.value = Math.min(3, Math.max(0.3, l));
|
|
754
|
+
}
|
|
755
|
+
function he() {
|
|
756
|
+
t.value = null, u.value = 1, T.reset();
|
|
757
|
+
}
|
|
758
|
+
let oe = 0;
|
|
759
|
+
async function D() {
|
|
760
|
+
const l = ++oe, P = n.fetcher ?? C;
|
|
761
|
+
if (H.value.length === 0) {
|
|
762
|
+
d.value = "缺少报表模板 ID", he(), a("error", d.value, { code: "param" });
|
|
763
|
+
return;
|
|
764
|
+
}
|
|
765
|
+
if (!P) {
|
|
766
|
+
d.value = "未提供渲染数据源 fetcher", he(), a("error", d.value, { code: "config" });
|
|
767
|
+
return;
|
|
768
|
+
}
|
|
769
|
+
s.value = !0, d.value = "", he();
|
|
770
|
+
const E = m.start();
|
|
771
|
+
try {
|
|
772
|
+
const $ = await P({
|
|
773
|
+
tempIds: H.value,
|
|
774
|
+
furnitureTempId: n.furnitureTempId || void 0,
|
|
775
|
+
params: { ...He.value }
|
|
776
|
+
});
|
|
777
|
+
if (l !== oe) return;
|
|
778
|
+
const S = lt($);
|
|
779
|
+
if (!S.ok) {
|
|
780
|
+
const Q = S.errors.slice(0, 3).map((_) => `${_.path}: ${_.message}`).join("; ");
|
|
781
|
+
throw new le(
|
|
782
|
+
"validate",
|
|
783
|
+
`渲染计划校验失败(${S.errors.length} 处): ${Q}`
|
|
784
|
+
);
|
|
785
|
+
}
|
|
786
|
+
S.warnings.length > 0 && L.value.logger.warn("[mach-report] 渲染计划告警:", S.warnings), t.value = $, u.value = 1, m.end(E), c.value && (c.value.scrollTop = 0), K.value === "fit" && $e(), a("loaded", $.pages.length);
|
|
787
|
+
} catch ($) {
|
|
788
|
+
if (l !== oe) return;
|
|
789
|
+
const S = $ instanceof le ? $ : new le(
|
|
790
|
+
"fetch",
|
|
791
|
+
$ instanceof Error ? $.message : "预览加载失败",
|
|
792
|
+
$
|
|
793
|
+
);
|
|
794
|
+
d.value = S.message, a("error", S.message, Qt(S));
|
|
795
|
+
} finally {
|
|
796
|
+
l === oe && (s.value = !1);
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
function z(l) {
|
|
800
|
+
if (M.value <= 0) return;
|
|
801
|
+
const P = Math.max(1, Math.min(M.value, l));
|
|
802
|
+
u.value = P;
|
|
803
|
+
const E = c.value;
|
|
804
|
+
if (!E) return;
|
|
805
|
+
let $ = 0;
|
|
806
|
+
for (let S = 0; S < P - 1; S++)
|
|
807
|
+
$ += (t.value?.pages[S]?.pageHeightMm ?? 0) * re + v.value;
|
|
808
|
+
E.scrollTop = $ * I.value;
|
|
809
|
+
}
|
|
810
|
+
const { print: be, exportAs: we, openPdfWindow: ye, releasePrintFrame: Ge } = gt(t, {
|
|
811
|
+
getPdfExporter: () => W,
|
|
812
|
+
onError: (l) => a("error", l, { code: "print" })
|
|
813
|
+
});
|
|
814
|
+
ze(ft, { reload: D, print: be, exportAs: we, openPdfWindow: ye, gotoPage: z });
|
|
815
|
+
const T = wt({
|
|
816
|
+
plan: t,
|
|
817
|
+
gotoPage: z,
|
|
818
|
+
highlight: bt,
|
|
819
|
+
clearHighlights: ht
|
|
820
|
+
});
|
|
821
|
+
function Ye(l) {
|
|
822
|
+
l.ctrlKey && (l.preventDefault(), ge(I.value * (l.deltaY < 0 ? 1.1 : 1 / 1.1)));
|
|
823
|
+
}
|
|
824
|
+
function Ze(l) {
|
|
825
|
+
if ((l.ctrlKey || l.metaKey) && l.key.toLowerCase() === "f") {
|
|
826
|
+
l.preventDefault(), T.visible.value || T.toggle();
|
|
827
|
+
return;
|
|
828
|
+
}
|
|
829
|
+
switch (l.key) {
|
|
830
|
+
case "PageDown":
|
|
831
|
+
l.preventDefault(), z(u.value + 1);
|
|
832
|
+
break;
|
|
833
|
+
case "PageUp":
|
|
834
|
+
l.preventDefault(), z(u.value - 1);
|
|
835
|
+
break;
|
|
836
|
+
case "Home":
|
|
837
|
+
l.preventDefault(), z(1);
|
|
838
|
+
break;
|
|
839
|
+
case "End":
|
|
840
|
+
l.preventDefault(), z(M.value);
|
|
841
|
+
break;
|
|
842
|
+
case "+":
|
|
843
|
+
case "=":
|
|
844
|
+
l.preventDefault(), ge(I.value * 1.1);
|
|
845
|
+
break;
|
|
846
|
+
case "-":
|
|
847
|
+
l.preventDefault(), ge(I.value / 1.1);
|
|
848
|
+
break;
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
function Je() {
|
|
852
|
+
try {
|
|
853
|
+
localStorage.setItem(
|
|
854
|
+
Ie,
|
|
855
|
+
JSON.stringify({ zoomMode: K.value === "fit" ? "fit" : Math.round(I.value * 100) })
|
|
856
|
+
);
|
|
857
|
+
} catch {
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
A([K, I], Je), Se(() => {
|
|
861
|
+
const l = t.value;
|
|
862
|
+
if (!l) return;
|
|
863
|
+
const P = p.value;
|
|
864
|
+
if (!P) return;
|
|
865
|
+
P.querySelectorAll(".mrp-page-holder").forEach(($) => {
|
|
866
|
+
const S = Number($.dataset.page ?? 0) - 1, Q = l.pages[S];
|
|
867
|
+
if (!Q || $.childElementCount > 0) {
|
|
868
|
+
if ($.firstElementChild) {
|
|
869
|
+
const Re = $.firstElementChild;
|
|
870
|
+
T.clear(Re), T.apply(Re);
|
|
871
|
+
}
|
|
872
|
+
return;
|
|
873
|
+
}
|
|
874
|
+
$.style.width = `${Q.pageWidthMm * re}px`;
|
|
875
|
+
const _ = We(Q, 96, {}, document);
|
|
876
|
+
T.apply(_), $.appendChild(_);
|
|
877
|
+
});
|
|
878
|
+
}, { flush: "post" }), A(() => T.query.value, (l) => {
|
|
879
|
+
l || p.value?.querySelectorAll(".mrp-page-holder").forEach((P) => {
|
|
880
|
+
T.clear(P);
|
|
881
|
+
});
|
|
882
|
+
});
|
|
883
|
+
const Me = Pt(t, {
|
|
884
|
+
thumbsRoot: i,
|
|
885
|
+
visible: f,
|
|
886
|
+
renderThumbCanvas: (l) => {
|
|
887
|
+
try {
|
|
888
|
+
const { canvases: P } = it(t.value, { start: l, end: l, dpr: 0.2 });
|
|
889
|
+
return P[0] ?? null;
|
|
890
|
+
} catch {
|
|
891
|
+
return null;
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
});
|
|
895
|
+
Se(() => {
|
|
896
|
+
Me.schedule();
|
|
897
|
+
}, { flush: "post" });
|
|
898
|
+
const Xe = x(() => n.debug), { debugStats: G } = yt(Xe, {
|
|
899
|
+
plan: t,
|
|
900
|
+
pageCount: M,
|
|
901
|
+
windowRange: X,
|
|
902
|
+
zoom: I,
|
|
903
|
+
loadMs: m.loadMs
|
|
904
|
+
});
|
|
905
|
+
function ke() {
|
|
906
|
+
Ce(c.value), K.value === "fit" && $e();
|
|
907
|
+
}
|
|
908
|
+
function Qe() {
|
|
909
|
+
try {
|
|
910
|
+
const l = JSON.parse(localStorage.getItem(Ie) ?? "{}");
|
|
911
|
+
l.zoomMode === "fit" ? me("fit") : typeof l.zoomMode == "number" && me(l.zoomMode);
|
|
912
|
+
} catch {
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
return tt(() => {
|
|
916
|
+
window.addEventListener("resize", ke), Ce(c.value), Qe(), n.autoLoad && D();
|
|
917
|
+
}), nt(() => {
|
|
918
|
+
window.removeEventListener("resize", ke), Me.destroy(), T.reset(), Ge();
|
|
919
|
+
}), A(
|
|
920
|
+
() => [n.tempId, n.furnitureTempId, JSON.stringify(n.params)],
|
|
921
|
+
() => {
|
|
922
|
+
n.autoLoad && D();
|
|
923
|
+
}
|
|
924
|
+
), A(
|
|
925
|
+
() => n.fetcher ?? C,
|
|
926
|
+
() => {
|
|
927
|
+
n.autoLoad && D();
|
|
928
|
+
}
|
|
929
|
+
), o({ reload: D, print: be, exportAs: we, openPdfWindow: ye, gotoPage: z }), (l, P) => (b(), w("div", {
|
|
930
|
+
class: "mach-report-preview",
|
|
931
|
+
style: Y(Ae.value)
|
|
932
|
+
}, [
|
|
933
|
+
ne.value && j.value.length > 0 ? (b(), ot(Kt, {
|
|
934
|
+
key: 0,
|
|
935
|
+
defs: j.value,
|
|
936
|
+
modelValue: J.value,
|
|
937
|
+
"onUpdate:modelValue": P[0] || (P[0] = (E) => J.value = E),
|
|
938
|
+
messages: O.value,
|
|
939
|
+
attempted: fe.value,
|
|
940
|
+
onQuery: De,
|
|
941
|
+
onReset: qe
|
|
942
|
+
}, null, 8, ["defs", "modelValue", "messages", "attempted"])) : B("", !0),
|
|
943
|
+
at(Lt, {
|
|
944
|
+
"page-count": M.value,
|
|
945
|
+
"current-page": u.value,
|
|
946
|
+
"zoom-mode": g(K),
|
|
947
|
+
zoom: g(I),
|
|
948
|
+
"show-export": te.value,
|
|
949
|
+
"show-print": N.value,
|
|
950
|
+
"show-pdf-window": U.value,
|
|
951
|
+
messages: O.value,
|
|
952
|
+
search: { visible: g(T).visible.value, query: g(T).query.value, matchIndex: g(T).matchIndex.value, matchCount: g(T).matchCount.value },
|
|
953
|
+
"thumbs-visible": f.value,
|
|
954
|
+
onGoto: z,
|
|
955
|
+
onZoom: g(me),
|
|
956
|
+
onExport: P[1] || (P[1] = (E) => g(we)(E)),
|
|
957
|
+
onPrint: g(be),
|
|
958
|
+
onPdfWindow: g(ye),
|
|
959
|
+
onSearchInput: g(T).onInput,
|
|
960
|
+
onSearchNav: g(T).onNav,
|
|
961
|
+
onSearchToggle: g(T).toggle,
|
|
962
|
+
onThumbsToggle: P[2] || (P[2] = (E) => f.value = !f.value)
|
|
963
|
+
}, null, 8, ["page-count", "current-page", "zoom-mode", "zoom", "show-export", "show-print", "show-pdf-window", "messages", "search", "thumbs-visible", "onZoom", "onPrint", "onPdfWindow", "onSearchInput", "onSearchNav", "onSearchToggle"]),
|
|
964
|
+
h("div", _t, [
|
|
965
|
+
h("div", {
|
|
966
|
+
ref_key: "viewportRef",
|
|
967
|
+
ref: c,
|
|
968
|
+
class: "mrp-body",
|
|
969
|
+
tabindex: "0",
|
|
970
|
+
onWheel: Ye,
|
|
971
|
+
onKeydown: Ze,
|
|
972
|
+
onScrollPassive: P[3] || (P[3] = (E) => g(Ke)(E.target))
|
|
973
|
+
}, [
|
|
974
|
+
s.value ? (b(), w("div", en, y(O.value.loading), 1)) : d.value ? (b(), w("div", tn, [
|
|
975
|
+
Le(y(d.value) + " ", 1),
|
|
976
|
+
h("button", {
|
|
977
|
+
class: "mrp-retry",
|
|
978
|
+
type: "button",
|
|
979
|
+
onClick: D
|
|
980
|
+
}, y(O.value.retry), 1)
|
|
981
|
+
])) : !t.value || M.value === 0 ? (b(), w("div", nn, y(O.value.empty), 1)) : (b(), w("div", {
|
|
982
|
+
key: 3,
|
|
983
|
+
class: "mrp-scale",
|
|
984
|
+
style: Y({ width: `${g(ve).w * g(I)}px`, height: `${g(ve).h * g(I)}px` })
|
|
985
|
+
}, [
|
|
986
|
+
h("div", {
|
|
987
|
+
ref_key: "containerRef",
|
|
988
|
+
ref: p,
|
|
989
|
+
class: "mrp-scale-inner",
|
|
990
|
+
style: Y({ transform: `scale(${g(I)})`, transformOrigin: "top left", width: `${g(ve).w}px` })
|
|
991
|
+
}, [
|
|
992
|
+
g(X).padTopPx > 0 ? (b(), w("div", {
|
|
993
|
+
key: 0,
|
|
994
|
+
class: "mrp-spacer-top",
|
|
995
|
+
style: Y({ height: `${g(X).padTopPx}px` }),
|
|
996
|
+
"aria-hidden": "true"
|
|
997
|
+
}, null, 4)) : B("", !0),
|
|
998
|
+
(b(!0), w(ee, null, ie(g(Ue), (E) => (b(), w("div", {
|
|
999
|
+
key: E.index,
|
|
1000
|
+
class: "mrp-page-holder",
|
|
1001
|
+
"data-page": E.index + 1
|
|
1002
|
+
}, null, 8, on))), 128)),
|
|
1003
|
+
g(X).padBottomPx > 0 ? (b(), w("div", {
|
|
1004
|
+
key: 1,
|
|
1005
|
+
class: "mrp-spacer-bottom",
|
|
1006
|
+
style: Y({ height: `${g(X).padBottomPx}px` }),
|
|
1007
|
+
"aria-hidden": "true"
|
|
1008
|
+
}, null, 4)) : B("", !0)
|
|
1009
|
+
], 4)
|
|
1010
|
+
], 4))
|
|
1011
|
+
], 544),
|
|
1012
|
+
f.value && M.value > 0 ? (b(), w("aside", {
|
|
1013
|
+
key: 0,
|
|
1014
|
+
ref_key: "thumbsRef",
|
|
1015
|
+
ref: i,
|
|
1016
|
+
class: "mrp-thumbs"
|
|
1017
|
+
}, [
|
|
1018
|
+
(b(!0), w(ee, null, ie(t.value?.pages ?? [], (E, $) => (b(), w("div", {
|
|
1019
|
+
key: $,
|
|
1020
|
+
class: V(["mrp-thumb", { "mrp-thumb-active": $ + 1 === u.value }]),
|
|
1021
|
+
onClick: (S) => z($ + 1)
|
|
1022
|
+
}, [
|
|
1023
|
+
h("div", {
|
|
1024
|
+
class: "mrp-thumb-box",
|
|
1025
|
+
"data-thumb": $ + 1,
|
|
1026
|
+
style: Y({ height: `${Math.round(E.pageHeightMm / E.pageWidthMm * 116)}px` })
|
|
1027
|
+
}, null, 12, rn),
|
|
1028
|
+
h("span", sn, y($ + 1), 1)
|
|
1029
|
+
], 10, an))), 128))
|
|
1030
|
+
], 512)) : B("", !0)
|
|
1031
|
+
]),
|
|
1032
|
+
h("div", ln, [
|
|
1033
|
+
rt(l.$slots, "default", {}, void 0, !0)
|
|
1034
|
+
]),
|
|
1035
|
+
g(G) ? (b(), w("div", un, [
|
|
1036
|
+
P[4] || (P[4] = h("div", null, "mach-report debug", -1)),
|
|
1037
|
+
h("div", null, "pages: " + y(g(G).pages) + " | window: [" + y(g(G).window) + "]", 1),
|
|
1038
|
+
h("div", null, "zoom: " + y(g(G).zoom) + " | load: " + y(g(G).loadMs), 1),
|
|
1039
|
+
h("div", null, "plan: " + y(g(G).planKB) + "KB", 1)
|
|
1040
|
+
])) : B("", !0)
|
|
1041
|
+
], 4));
|
|
1042
|
+
}
|
|
1043
|
+
}), dn = /* @__PURE__ */ Ee(cn, [["__scopeId", "data-v-dbf59a36"]]), Pn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1044
|
+
__proto__: null,
|
|
1045
|
+
default: dn
|
|
1046
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
1047
|
+
export {
|
|
1048
|
+
Gt as D,
|
|
1049
|
+
le as M,
|
|
1050
|
+
Kt as R,
|
|
1051
|
+
wn as S,
|
|
1052
|
+
Yt as a,
|
|
1053
|
+
dn as b,
|
|
1054
|
+
Lt as c,
|
|
1055
|
+
se as d,
|
|
1056
|
+
hn as e,
|
|
1057
|
+
bn as f,
|
|
1058
|
+
yn as g,
|
|
1059
|
+
Qt as h,
|
|
1060
|
+
mt as i,
|
|
1061
|
+
gt as j,
|
|
1062
|
+
vt as k,
|
|
1063
|
+
Pn as l,
|
|
1064
|
+
gn as p,
|
|
1065
|
+
Zt as r,
|
|
1066
|
+
Jt as t,
|
|
1067
|
+
Xt as u
|
|
1068
|
+
};
|