@agile-team/mach-report 2.1.0 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +130 -16
- package/dist/ReportPreview-CLENbOCL.cjs +6 -0
- package/dist/ReportPreview-CwTGfyTq.js +1679 -0
- package/dist/grid-geometry-CWmJ9c9y.js +130 -0
- package/dist/grid-geometry-DBH9ExuY.cjs +1 -0
- package/dist/index.cjs +5 -5
- package/dist/index.d.cts +110 -16
- package/dist/index.d.ts +110 -16
- package/dist/index.js +1099 -718
- package/dist/page-window-index-CIuT4BAv.js +43 -0
- package/dist/page-window-index-DEjnM6IB.cjs +1 -0
- package/dist/pdf.cjs +46 -46
- package/dist/pdf.d.cts +20 -0
- package/dist/pdf.d.ts +20 -0
- package/dist/pdf.js +6 -6
- package/dist/{plugin-Bl00j_CP.cjs → plugin-MSh_OhoW.cjs} +1 -1
- package/dist/{plugin-DVScnZ4C.js → plugin-uoO9VA6O.js} +2 -2
- package/dist/report-params-B3Fia6JO.js +10 -0
- package/dist/report-params-D1gZ1DME.cjs +1 -0
- package/dist/style.css +1 -1
- package/dist/textwrap-BQyrpYSR.js +117 -0
- package/dist/textwrap-DqiFwAV3.cjs +3 -0
- package/dist/vue/async.d.cts +77 -2
- package/dist/vue/async.d.ts +77 -2
- package/dist/vue/index.d.cts +91 -14
- package/dist/vue/index.d.ts +91 -14
- package/dist/vue-async.cjs +1 -1
- package/dist/vue-async.js +3 -3
- package/dist/vue.cjs +1 -1
- package/dist/vue.js +4 -4
- package/dist/xlsx.cjs +21 -21
- package/dist/xlsx.d.cts +28 -2
- package/dist/xlsx.d.ts +28 -2
- package/dist/xlsx.js +5637 -5515
- package/package.json +3 -2
- package/dist/ReportPreview-Dwdsyk9b.js +0 -1558
- package/dist/ReportPreview-VHAIfsz1.cjs +0 -6
- package/dist/grid-geometry-BXpOxznT.cjs +0 -1
- package/dist/grid-geometry-Bs8QXz1X.js +0 -65
- package/dist/report-params-BB85g7mg.js +0 -10
- package/dist/report-params-D1NeY-eR.cjs +0 -1
- package/dist/style-CFZ-HE2s.cjs +0 -3
- package/dist/style-DnmtG7Gl.js +0 -180
|
@@ -0,0 +1,1679 @@
|
|
|
1
|
+
import { computed as k, unref as x, ref as B, onScopeDispose as He, getCurrentScope as Ht, watch as Q, shallowRef as Ie, defineComponent as rt, nextTick as qt, openBlock as P, createElementBlock as $, createElementVNode as F, toDisplayString as M, Fragment as Ee, createCommentVNode as N, normalizeClass as oe, renderList as We, createTextVNode as et, withKeys as mt, inject as Be, provide as yt, useCssVars as Nt, watchEffect as vt, onMounted as jt, onUnmounted as Ut, normalizeStyle as re, createBlock as Vt, createVNode as Kt, renderSlot as Yt } from "vue";
|
|
2
|
+
import { renderPlanToImages as Zt, renderPage as xt, validateRenderPlan as Jt, ReportSourceError as Gt, renderPlanToCanvas as Xt } from "@agile-team/mach-report";
|
|
3
|
+
import { c as Pt } from "./page-window-index-CIuT4BAv.js";
|
|
4
|
+
import { b as tt, c as Qt, d as _t, a as en } from "./plugin-uoO9VA6O.js";
|
|
5
|
+
function Et(e) {
|
|
6
|
+
return e == null ? [] : Array.isArray(e) ? e.map(String).filter((t) => t !== "") : String(e).split(",").map((t) => t.trim()).filter((t) => t !== "");
|
|
7
|
+
}
|
|
8
|
+
function mr(e) {
|
|
9
|
+
return Et(e).join(",");
|
|
10
|
+
}
|
|
11
|
+
class _e extends Error {
|
|
12
|
+
constructor(t) {
|
|
13
|
+
super(t), this.name = "PlanLoadError";
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function vr(e = {}) {
|
|
17
|
+
const { baseUrl: t = "", headers: s, credentials: o, timeoutMs: n = 3e4 } = e, r = t.replace(/\/+$/, "");
|
|
18
|
+
return async ({ url: l, method: u, params: p, signal: m }) => {
|
|
19
|
+
let c = `${r}${l}`;
|
|
20
|
+
if (p && Object.keys(p).length > 0) {
|
|
21
|
+
const b = c.indexOf("#"), I = b >= 0 ? c.slice(b) : "", E = b >= 0 ? c.slice(0, b) : c, D = E.indexOf("?"), S = D >= 0 ? E.slice(0, D) : E, C = new URLSearchParams(D >= 0 ? E.slice(D + 1) : "");
|
|
22
|
+
for (const [H, j] of Object.entries(p)) C.set(H, j);
|
|
23
|
+
c = `${S}?${C}${I}`;
|
|
24
|
+
}
|
|
25
|
+
const f = (b, I) => {
|
|
26
|
+
const E = new _e(b);
|
|
27
|
+
return Object.defineProperty(E, "cause", { value: I, configurable: !0, writable: !0 }), E;
|
|
28
|
+
};
|
|
29
|
+
if (m?.aborted)
|
|
30
|
+
throw f(`请求已取消: ${l}`, m.reason);
|
|
31
|
+
const h = new AbortController();
|
|
32
|
+
let v;
|
|
33
|
+
const A = () => {
|
|
34
|
+
h.signal.aborted || (v = "external", h.abort(m?.reason));
|
|
35
|
+
};
|
|
36
|
+
m?.addEventListener("abort", A, { once: !0 });
|
|
37
|
+
const W = setTimeout(() => {
|
|
38
|
+
h.signal.aborted || (v = "timeout", h.abort());
|
|
39
|
+
}, n);
|
|
40
|
+
try {
|
|
41
|
+
const b = await fetch(c, {
|
|
42
|
+
method: u.toUpperCase(),
|
|
43
|
+
headers: { Accept: "application/json", ...s },
|
|
44
|
+
credentials: o,
|
|
45
|
+
signal: h.signal
|
|
46
|
+
});
|
|
47
|
+
if (!b.ok)
|
|
48
|
+
throw new _e(`HTTP ${b.status} ${l}`);
|
|
49
|
+
return await b.json();
|
|
50
|
+
} catch (b) {
|
|
51
|
+
throw v === "timeout" ? f(`请求超时(${n}ms): ${l}`, b) : v === "external" ? f(`请求已取消: ${l}`, b) : b instanceof _e ? b : f(`请求失败(${l}): ${b instanceof Error ? b.message : String(b)}`, b);
|
|
52
|
+
} finally {
|
|
53
|
+
clearTimeout(W), m?.removeEventListener("abort", A);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function tn(e, t, s = {}) {
|
|
58
|
+
const o = s.pxPerMm ?? 3.7795275590551185, n = k(() => Math.max(0, x(s.gapPx) ?? 18)), r = B(0), l = B(800), u = k(() => {
|
|
59
|
+
const b = e.value?.pages ?? [];
|
|
60
|
+
return Pt(b.map((I) => I.pageHeightMm * o), n.value);
|
|
61
|
+
}), p = k(() => {
|
|
62
|
+
let b = 0;
|
|
63
|
+
for (const I of e.value?.pages ?? []) b = Math.max(b, I.pageWidthMm * o);
|
|
64
|
+
return { w: b, h: u.value.totalHeightPx };
|
|
65
|
+
}), m = k(() => u.value.window(
|
|
66
|
+
l.value / t.value,
|
|
67
|
+
r.value / t.value,
|
|
68
|
+
x(s.overscan) ?? 1
|
|
69
|
+
)), c = k(() => {
|
|
70
|
+
const b = e.value;
|
|
71
|
+
if (!b) return [];
|
|
72
|
+
const { start: I, end: E } = m.value;
|
|
73
|
+
return b.pages.slice(I, E + 1).map((D, S) => ({ page: D, index: I + S }));
|
|
74
|
+
});
|
|
75
|
+
let f = 0, h = !1;
|
|
76
|
+
function v(b) {
|
|
77
|
+
b && (r.value = b.scrollTop, l.value = b.clientHeight || 800);
|
|
78
|
+
}
|
|
79
|
+
function A(b, I) {
|
|
80
|
+
return (E) => {
|
|
81
|
+
f || h || (f = requestAnimationFrame(() => {
|
|
82
|
+
if (f = 0, h || (v(E), I.value <= 0)) return;
|
|
83
|
+
const D = Math.max(0, E.scrollTop + 32) / t.value;
|
|
84
|
+
b.value = Math.min(I.value, u.value.pageAt(D) + 1);
|
|
85
|
+
}));
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
function W() {
|
|
89
|
+
h = !0, f && cancelAnimationFrame(f), f = 0;
|
|
90
|
+
}
|
|
91
|
+
return He(W), {
|
|
92
|
+
contentSize: p,
|
|
93
|
+
windowRange: m,
|
|
94
|
+
visiblePages: c,
|
|
95
|
+
makeScrollHandler: A,
|
|
96
|
+
refreshViewport: v,
|
|
97
|
+
pageOffsetPx: (b) => u.value.offsetAt(b),
|
|
98
|
+
destroy: W
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
function nn(e) {
|
|
102
|
+
const t = B(1), s = B("fit");
|
|
103
|
+
let o = 0;
|
|
104
|
+
function n() {
|
|
105
|
+
o && cancelAnimationFrame(o), o = 0;
|
|
106
|
+
}
|
|
107
|
+
function r() {
|
|
108
|
+
n(), o = requestAnimationFrame(() => {
|
|
109
|
+
if (o = 0, s.value !== "fit") return;
|
|
110
|
+
const u = e();
|
|
111
|
+
!u?.viewport || u.viewport.clientWidth <= 48 || !Number.isFinite(u.pageWidthPx) || (t.value = Math.min(1, (u.viewport.clientWidth - 48) / Math.max(1, u.pageWidthPx)));
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
function l(u) {
|
|
115
|
+
if (u === "fit")
|
|
116
|
+
s.value = "fit", r();
|
|
117
|
+
else {
|
|
118
|
+
if (!Number.isFinite(u)) return;
|
|
119
|
+
n(), s.value = "raw", t.value = Math.min(3, Math.max(0.3, u / 100));
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return Ht() && He(n), { zoom: t, zoomMode: s, applyFitZoom: r, setZoom: l };
|
|
123
|
+
}
|
|
124
|
+
const Ae = 8;
|
|
125
|
+
function Le() {
|
|
126
|
+
return new Promise((e) => setTimeout(e, 0));
|
|
127
|
+
}
|
|
128
|
+
function Oe(e) {
|
|
129
|
+
return `p${Math.round(e.pageWidthMm)}x${Math.round(e.pageHeightMm)}`;
|
|
130
|
+
}
|
|
131
|
+
function ot(e) {
|
|
132
|
+
const t = /* @__PURE__ */ new Map();
|
|
133
|
+
return e.pages.forEach((n) => {
|
|
134
|
+
t.has(Oe(n)) || t.set(Oe(n), n);
|
|
135
|
+
}), `<!doctype html><html><head><meta charset="utf-8"><style>${`.mr-page{margin:0 auto;page-break-after:always;}
|
|
136
|
+
.mr-page tr{break-inside:avoid;page-break-inside:avoid;}
|
|
137
|
+
.mr-comp{break-inside:avoid;page-break-inside:avoid;}
|
|
138
|
+
${[...t.values()].map(
|
|
139
|
+
(n) => `@page ${Oe(n)}{size:${Math.round(n.pageWidthMm)}mm ${Math.round(n.pageHeightMm)}mm;margin:0;}`
|
|
140
|
+
).join(`
|
|
141
|
+
`)}
|
|
142
|
+
body{margin:0;background:#fff;}`}</style></head><body>`;
|
|
143
|
+
}
|
|
144
|
+
function at(e) {
|
|
145
|
+
const t = xt(e, 96, {}, document);
|
|
146
|
+
return t.style.page = Oe(e), t.outerHTML;
|
|
147
|
+
}
|
|
148
|
+
function $t(e) {
|
|
149
|
+
return { head: ot(e), pageChunks: e.pages.map(at) };
|
|
150
|
+
}
|
|
151
|
+
async function hr(e, t = {}) {
|
|
152
|
+
const s = {
|
|
153
|
+
schemaVersion: "mach-report-batch-print",
|
|
154
|
+
pages: e.flatMap((l) => l.pages)
|
|
155
|
+
};
|
|
156
|
+
if (s.pages.length === 0) return;
|
|
157
|
+
const o = ot(s), n = document.createElement("iframe");
|
|
158
|
+
n.style.cssText = "position:fixed;right:0;bottom:0;width:0;height:0;border:0;visibility:hidden;", document.body.appendChild(n);
|
|
159
|
+
let r = !1;
|
|
160
|
+
try {
|
|
161
|
+
const l = n.contentDocument;
|
|
162
|
+
l.open(), l.write(o);
|
|
163
|
+
for (let u = 0; u < s.pages.length; u++)
|
|
164
|
+
l.write(at(s.pages[u])), u % Ae === Ae - 1 && (t.onProgress?.(u + 1, s.pages.length), await Le());
|
|
165
|
+
l.write("</body></html>"), l.close(), await Le(), t.onProgress?.(s.pages.length, s.pages.length), r = !0, n.contentWindow?.focus(), n.contentWindow?.print();
|
|
166
|
+
} catch (l) {
|
|
167
|
+
t.onError?.(l instanceof Error ? `批量打印失败: ${l.message}` : "批量打印失败");
|
|
168
|
+
} finally {
|
|
169
|
+
r ? setTimeout(() => n.remove(), 6e4) : n.remove();
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
function rn(e) {
|
|
173
|
+
const { head: t, pageChunks: s } = $t(e);
|
|
174
|
+
return {
|
|
175
|
+
html: `${`<!doctype html><html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40"><head><meta charset="utf-8"><!--[if gte mso 9]><xml><w:WordDocument><w:View>Print</w:View><w:Zoom>100</w:Zoom></w:WordDocument></xml><![endif]-->${t.replace(/^<!doctype html><html><head>/, "")}`}${s.join("")}</body></html>`,
|
|
176
|
+
filename: "mach-report.doc"
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
function on(e, t) {
|
|
180
|
+
let s = null, o = !1, n = !1, r = 0;
|
|
181
|
+
const l = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Map();
|
|
182
|
+
let p = null, m = null, c = null, f = null, h = null;
|
|
183
|
+
function v(a, d) {
|
|
184
|
+
return !n && e.value === a && r === d;
|
|
185
|
+
}
|
|
186
|
+
function A() {
|
|
187
|
+
if (n) return;
|
|
188
|
+
const a = [...l.values()].reverse().find((d) => v(d.plan, d.epoch))?.format ?? null;
|
|
189
|
+
a !== p && (p = a, t.onBusy?.(a));
|
|
190
|
+
}
|
|
191
|
+
function W(a, d, y) {
|
|
192
|
+
const R = {};
|
|
193
|
+
return l.set(R, { plan: a, epoch: d, format: y }), A(), R;
|
|
194
|
+
}
|
|
195
|
+
function b(a) {
|
|
196
|
+
l.delete(a), A();
|
|
197
|
+
}
|
|
198
|
+
function I() {
|
|
199
|
+
for (const [a, d] of u)
|
|
200
|
+
v(d.plan, d.epoch) || (a.close(), u.delete(a));
|
|
201
|
+
}
|
|
202
|
+
const E = Q(e, () => {
|
|
203
|
+
r++, A(), I();
|
|
204
|
+
}, { flush: "sync" });
|
|
205
|
+
function D() {
|
|
206
|
+
s?.remove(), s = null;
|
|
207
|
+
}
|
|
208
|
+
function S() {
|
|
209
|
+
n = !0, r++, E(), D(), I(), l.clear(), t.onPrinting?.(!1);
|
|
210
|
+
}
|
|
211
|
+
function C(a, d) {
|
|
212
|
+
const y = URL.createObjectURL(a);
|
|
213
|
+
setTimeout(() => URL.revokeObjectURL(y), 1e4);
|
|
214
|
+
const R = document.createElement("a");
|
|
215
|
+
R.href = y, R.download = d, R.click();
|
|
216
|
+
}
|
|
217
|
+
async function H() {
|
|
218
|
+
if (o) return;
|
|
219
|
+
const a = e.value;
|
|
220
|
+
if (n || !a || a.pages.length === 0) return;
|
|
221
|
+
const d = r;
|
|
222
|
+
o = !0, t.onPrinting?.(!0), D();
|
|
223
|
+
const y = ot(a);
|
|
224
|
+
s = document.createElement("iframe"), s.style.cssText = "position:fixed;right:0;bottom:0;width:0;height:0;border:0;visibility:hidden;", document.body.appendChild(s);
|
|
225
|
+
const R = s;
|
|
226
|
+
try {
|
|
227
|
+
const T = R.contentDocument;
|
|
228
|
+
T.open(), T.write(y);
|
|
229
|
+
for (let K = 0; K < a.pages.length; K++)
|
|
230
|
+
if (T.write(at(a.pages[K])), K % Ae === Ae - 1 && await Le(), R !== s) return;
|
|
231
|
+
if (T.write("</body></html>"), T.close(), await Le(), !v(a, d) || R !== s) return;
|
|
232
|
+
R.contentWindow?.focus(), R.contentWindow?.print();
|
|
233
|
+
} catch {
|
|
234
|
+
R === s && D(), v(a, d) && t.onError("调用打印失败,请改用导出 PDF", "print");
|
|
235
|
+
} finally {
|
|
236
|
+
o = !1, n || t.onPrinting?.(!1);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
function j(a, d) {
|
|
240
|
+
if (m?.plan === a && m.epoch === d) return m.promise;
|
|
241
|
+
const y = Promise.resolve().then(() => {
|
|
242
|
+
if (!v(a, d)) throw new Error("报表已切换或卸载");
|
|
243
|
+
return t.getPdfExporter()(a, (R) => {
|
|
244
|
+
v(a, d) && t.onWarning?.(R);
|
|
245
|
+
});
|
|
246
|
+
}).finally(() => {
|
|
247
|
+
m?.promise === y && (m = null);
|
|
248
|
+
});
|
|
249
|
+
return m = { plan: a, epoch: d, promise: y }, y;
|
|
250
|
+
}
|
|
251
|
+
async function q() {
|
|
252
|
+
const a = e.value;
|
|
253
|
+
if (n || !a || a.pages.length === 0) return;
|
|
254
|
+
const d = r;
|
|
255
|
+
if (c?.plan === a && c.epoch === d) return c.promise;
|
|
256
|
+
const y = W(a, d, "PDF"), R = (async () => {
|
|
257
|
+
try {
|
|
258
|
+
const T = await j(a, d);
|
|
259
|
+
if (!v(a, d)) return;
|
|
260
|
+
C(new Blob([T], { type: "application/pdf" }), "mach-report.pdf");
|
|
261
|
+
} catch (T) {
|
|
262
|
+
v(a, d) && t.onError(T instanceof Error ? `PDF 导出失败: ${T.message}` : "PDF 导出失败", "pdf");
|
|
263
|
+
} finally {
|
|
264
|
+
b(y), c?.token === y && (c = null);
|
|
265
|
+
}
|
|
266
|
+
})();
|
|
267
|
+
return c = { plan: a, epoch: d, promise: R, token: y }, R;
|
|
268
|
+
}
|
|
269
|
+
async function Y() {
|
|
270
|
+
const a = e.value;
|
|
271
|
+
if (n || !a || a.pages.length === 0) return;
|
|
272
|
+
const d = r;
|
|
273
|
+
if (f?.plan === a && f.epoch === d) return f.promise;
|
|
274
|
+
const y = { ...t.getXlsxOptions?.() }, R = W(a, d, "Excel"), T = (async () => {
|
|
275
|
+
try {
|
|
276
|
+
const { renderPlanToXlsx: K } = await import("@agile-team/mach-report/xlsx");
|
|
277
|
+
if (!v(a, d)) return;
|
|
278
|
+
const { buffer: J, warnings: G } = await K(a, y);
|
|
279
|
+
if (!v(a, d) || (G.length > 0 && t.onWarning?.(`Excel 导出有 ${G.length} 条提示:${G.slice(0, 2).join(";")}`), !v(a, d))) return;
|
|
280
|
+
C(new Blob([J], {
|
|
281
|
+
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
|
282
|
+
}), "mach-report.xlsx");
|
|
283
|
+
} catch (K) {
|
|
284
|
+
v(a, d) && t.onError(K instanceof Error ? `Excel 导出失败: ${K.message}` : "Excel 导出失败", "export");
|
|
285
|
+
} finally {
|
|
286
|
+
b(R), f?.token === R && (f = null);
|
|
287
|
+
}
|
|
288
|
+
})();
|
|
289
|
+
return f = { plan: a, epoch: d, promise: T, token: R }, T;
|
|
290
|
+
}
|
|
291
|
+
async function O() {
|
|
292
|
+
const a = e.value;
|
|
293
|
+
if (n || !a || a.pages.length === 0) return;
|
|
294
|
+
const d = r;
|
|
295
|
+
if (h?.plan === a && h.epoch === d) return h.promise;
|
|
296
|
+
const y = W(a, d, "图片"), R = (async () => {
|
|
297
|
+
try {
|
|
298
|
+
const { blobs: T } = await Zt(a, {
|
|
299
|
+
dpr: Math.min(2, typeof devicePixelRatio == "number" ? devicePixelRatio : 1)
|
|
300
|
+
});
|
|
301
|
+
if (!v(a, d)) return;
|
|
302
|
+
T.forEach((K, J) => {
|
|
303
|
+
C(K, T.length > 1 ? `mach-report-page-${J + 1}.png` : "mach-report.png");
|
|
304
|
+
});
|
|
305
|
+
} catch (T) {
|
|
306
|
+
v(a, d) && t.onError(
|
|
307
|
+
T instanceof Error ? `图片导出失败: ${T.message}` : "图片导出失败",
|
|
308
|
+
"export"
|
|
309
|
+
);
|
|
310
|
+
} finally {
|
|
311
|
+
b(y), h?.token === y && (h = null);
|
|
312
|
+
}
|
|
313
|
+
})();
|
|
314
|
+
return h = { plan: a, epoch: d, promise: R, token: y }, R;
|
|
315
|
+
}
|
|
316
|
+
function ae() {
|
|
317
|
+
const a = e.value;
|
|
318
|
+
if (!(n || !a || a.pages.length === 0))
|
|
319
|
+
try {
|
|
320
|
+
const { html: d, filename: y } = rn(a);
|
|
321
|
+
C(new Blob([d], { type: "application/msword;charset=utf-8" }), y);
|
|
322
|
+
} catch (d) {
|
|
323
|
+
t.onError(
|
|
324
|
+
d instanceof Error ? `Word 导出失败: ${d.message}` : "Word 导出失败",
|
|
325
|
+
"export"
|
|
326
|
+
);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
async function ee(a) {
|
|
330
|
+
const d = e.value;
|
|
331
|
+
if (!(n || !d || d.pages.length === 0)) {
|
|
332
|
+
if (a === "pdf") {
|
|
333
|
+
await q();
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
if (a === "xlsx" || a === "excel") {
|
|
337
|
+
await Y();
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
if (a === "png" || a === "image") {
|
|
341
|
+
await O();
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
if (a === "word" || a === "doc") {
|
|
345
|
+
ae();
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
if (a !== "html") {
|
|
349
|
+
t.onError(`不支持的导出格式:${a}`, "export");
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
try {
|
|
353
|
+
const { head: y, pageChunks: R } = $t(d), T = `${y}${R.join("")}</body></html>`;
|
|
354
|
+
C(new Blob([T], { type: "text/html;charset=utf-8" }), "mach-report.html");
|
|
355
|
+
} catch (y) {
|
|
356
|
+
t.onError(y instanceof Error ? `HTML 导出失败: ${y.message}` : "HTML 导出失败", "export");
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
function fe() {
|
|
361
|
+
const a = e.value;
|
|
362
|
+
if (n || !a || a.pages.length === 0) return;
|
|
363
|
+
const d = r, y = window.open("", "_blank");
|
|
364
|
+
if (!y) {
|
|
365
|
+
t.onError("浏览器拦截了弹窗,请允许弹窗后重试", "pdf");
|
|
366
|
+
return;
|
|
367
|
+
}
|
|
368
|
+
u.set(y, { plan: a, epoch: d });
|
|
369
|
+
const R = W(a, d, "PDF");
|
|
370
|
+
j(a, d).then((T) => {
|
|
371
|
+
if (!v(a, d) || y.closed) {
|
|
372
|
+
u.delete(y) && y.close();
|
|
373
|
+
return;
|
|
374
|
+
}
|
|
375
|
+
const K = URL.createObjectURL(new Blob([T], { type: "application/pdf" }));
|
|
376
|
+
setTimeout(() => URL.revokeObjectURL(K), 6e4);
|
|
377
|
+
const J = y.document;
|
|
378
|
+
J.title = "PDF 预览", J.documentElement.style.height = "100%", J.body.style.cssText = "margin:0;height:100%;";
|
|
379
|
+
const G = J.createElement("iframe");
|
|
380
|
+
G.title = "PDF 预览", G.style.cssText = "display:block;width:100%;height:100%;border:0;", G.src = K, J.body.replaceChildren(G), u.delete(y);
|
|
381
|
+
}).catch((T) => {
|
|
382
|
+
y.close(), u.delete(y), v(a, d) && t.onError(T instanceof Error ? `PDF 预览失败: ${T.message}` : "PDF 预览失败", "pdf");
|
|
383
|
+
}).finally(() => b(R));
|
|
384
|
+
}
|
|
385
|
+
return {
|
|
386
|
+
print: H,
|
|
387
|
+
exportAs: ee,
|
|
388
|
+
exportImages: O,
|
|
389
|
+
exportWord: ae,
|
|
390
|
+
openPdfWindow: fe,
|
|
391
|
+
releasePrintFrame: D,
|
|
392
|
+
dispose: S
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
const kt = "mrp-hit";
|
|
396
|
+
function an(e) {
|
|
397
|
+
e.querySelectorAll(`mark.${kt}`).forEach((s) => {
|
|
398
|
+
const o = s.parentNode;
|
|
399
|
+
if (o) {
|
|
400
|
+
for (; s.firstChild; ) o.insertBefore(s.firstChild, s);
|
|
401
|
+
s.remove(), o.normalize();
|
|
402
|
+
}
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
function sn(e, t) {
|
|
406
|
+
const s = t.trim();
|
|
407
|
+
if (!s) return 0;
|
|
408
|
+
const o = s.toLowerCase(), n = document.createTreeWalker(e, NodeFilter.SHOW_TEXT, {
|
|
409
|
+
acceptNode(u) {
|
|
410
|
+
const p = u.parentElement;
|
|
411
|
+
return !p || p.closest("mark") || /^(SCRIPT|STYLE)$/.test(p.tagName) ? NodeFilter.FILTER_REJECT : (u.nodeValue ?? "").toLowerCase().includes(o) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT;
|
|
412
|
+
}
|
|
413
|
+
}), r = [];
|
|
414
|
+
for (let u = n.nextNode(); u; u = n.nextNode()) r.push(u);
|
|
415
|
+
let l = 0;
|
|
416
|
+
for (const u of r) {
|
|
417
|
+
const p = u.nodeValue ?? "", m = p.toLowerCase(), c = u.parentElement;
|
|
418
|
+
if (!c) continue;
|
|
419
|
+
const f = document.createDocumentFragment();
|
|
420
|
+
let h = 0, v = m.indexOf(o);
|
|
421
|
+
for (; v >= 0; ) {
|
|
422
|
+
v > h && f.appendChild(document.createTextNode(p.slice(h, v)));
|
|
423
|
+
const A = document.createElement("mark");
|
|
424
|
+
A.className = kt, A.textContent = p.slice(v, v + s.length), f.appendChild(A), l++, h = v + s.length, v = m.indexOf(o, h);
|
|
425
|
+
}
|
|
426
|
+
h < p.length && f.appendChild(document.createTextNode(p.slice(h))), c.replaceChild(f, u);
|
|
427
|
+
}
|
|
428
|
+
return l;
|
|
429
|
+
}
|
|
430
|
+
function ln(e, t) {
|
|
431
|
+
const s = e.toLowerCase();
|
|
432
|
+
let o = 0;
|
|
433
|
+
for (let n = s.indexOf(t); n >= 0; n = s.indexOf(t, n + t.length)) o++;
|
|
434
|
+
return o;
|
|
435
|
+
}
|
|
436
|
+
function* un(e) {
|
|
437
|
+
const t = [...e].reverse();
|
|
438
|
+
for (; t.length > 0; ) {
|
|
439
|
+
const s = t.pop();
|
|
440
|
+
if (s.grid) {
|
|
441
|
+
for (const o of s.grid.cells ?? [])
|
|
442
|
+
for (const n of o ?? [])
|
|
443
|
+
if (yield n?.text ?? "", n?.children)
|
|
444
|
+
for (let r = n.children.length - 1; r >= 0; r--) t.push(n.children[r]);
|
|
445
|
+
} else if (s.kind === "text")
|
|
446
|
+
if (s.richParagraphs?.length)
|
|
447
|
+
for (const o of s.richParagraphs)
|
|
448
|
+
for (const n of o.segments ?? [])
|
|
449
|
+
yield (n.kind === "field" ? n.field : n.text) ?? "";
|
|
450
|
+
else s.lines?.length ? yield* s.lines : yield s.text ?? "";
|
|
451
|
+
yield "";
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
function* cn(e) {
|
|
455
|
+
for (let t = 0; t < e.pages.length; t++) {
|
|
456
|
+
for (const s of un(e.pages[t].components)) yield { text: s, pageIndex: t };
|
|
457
|
+
yield { text: "", pageIndex: t };
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
function dn(e) {
|
|
461
|
+
const { plan: t, gotoPage: s, highlight: o, clearHighlights: n } = e, r = B(!1), l = B(""), u = B(0), p = B(0), m = B(!1);
|
|
462
|
+
let c = [];
|
|
463
|
+
const f = k(() => {
|
|
464
|
+
if (p.value === 0) return null;
|
|
465
|
+
const S = u.value;
|
|
466
|
+
let C = 0, H = c.length - 1;
|
|
467
|
+
for (; C < H; ) {
|
|
468
|
+
const q = C + H >>> 1;
|
|
469
|
+
c[q].cumulative <= S ? C = q + 1 : H = q;
|
|
470
|
+
}
|
|
471
|
+
const j = c[C];
|
|
472
|
+
return j ? { pageIndex: j.pageIndex, occurrence: S - (c[C - 1]?.cumulative ?? 0) } : null;
|
|
473
|
+
});
|
|
474
|
+
let h = null, v = null, A = 0;
|
|
475
|
+
function W() {
|
|
476
|
+
A++, h && clearTimeout(h), v && clearTimeout(v), h = v = null, m.value = !1;
|
|
477
|
+
}
|
|
478
|
+
function b(S) {
|
|
479
|
+
l.value = S, u.value = 0, p.value = 0, c = [], m.value = !1;
|
|
480
|
+
const C = S.trim().toLowerCase(), H = t.value;
|
|
481
|
+
if (!C || !H) return;
|
|
482
|
+
m.value = !0;
|
|
483
|
+
const j = A, q = cn(H), Y = [];
|
|
484
|
+
let O = 0;
|
|
485
|
+
function ae() {
|
|
486
|
+
if (v = null, j !== A || H !== t.value) return;
|
|
487
|
+
const ee = performance.now();
|
|
488
|
+
let fe = 0;
|
|
489
|
+
for (; fe < 5e3 && performance.now() - ee < 4; ) {
|
|
490
|
+
const a = q.next();
|
|
491
|
+
if (a.done) {
|
|
492
|
+
c = Y, p.value = O, m.value = !1, c[0] && s(c[0].pageIndex + 1);
|
|
493
|
+
return;
|
|
494
|
+
}
|
|
495
|
+
const d = ln(a.value.text, C);
|
|
496
|
+
if (d > 0) {
|
|
497
|
+
O += d;
|
|
498
|
+
const y = Y[Y.length - 1];
|
|
499
|
+
y?.pageIndex === a.value.pageIndex ? y.cumulative = O : Y.push({ pageIndex: a.value.pageIndex, cumulative: O });
|
|
500
|
+
}
|
|
501
|
+
fe++;
|
|
502
|
+
}
|
|
503
|
+
v = setTimeout(ae, 0);
|
|
504
|
+
}
|
|
505
|
+
ae();
|
|
506
|
+
}
|
|
507
|
+
function I(S) {
|
|
508
|
+
if (W(), l.value = S, u.value = p.value = 0, c = [], !S.trim()) {
|
|
509
|
+
b("");
|
|
510
|
+
return;
|
|
511
|
+
}
|
|
512
|
+
m.value = !0, h = setTimeout(() => {
|
|
513
|
+
h = null, b(S);
|
|
514
|
+
}, Math.max(0, x(e.debounceMs) ?? 200));
|
|
515
|
+
}
|
|
516
|
+
function E(S) {
|
|
517
|
+
const C = p.value;
|
|
518
|
+
if (C === 0 || m.value) return;
|
|
519
|
+
u.value = (u.value + S + C) % C;
|
|
520
|
+
let H = 0, j = c.length - 1;
|
|
521
|
+
for (; H < j; ) {
|
|
522
|
+
const q = H + j >>> 1;
|
|
523
|
+
c[q].cumulative <= u.value ? H = q + 1 : j = q;
|
|
524
|
+
}
|
|
525
|
+
s(c[H].pageIndex + 1);
|
|
526
|
+
}
|
|
527
|
+
function D() {
|
|
528
|
+
W(), l.value = "", u.value = p.value = 0, c = [];
|
|
529
|
+
}
|
|
530
|
+
return Q(t, D, { flush: "sync" }), He(D), {
|
|
531
|
+
visible: r,
|
|
532
|
+
query: l,
|
|
533
|
+
matchIndex: u,
|
|
534
|
+
matchCount: p,
|
|
535
|
+
activeMatch: f,
|
|
536
|
+
searching: m,
|
|
537
|
+
toggle: () => {
|
|
538
|
+
r.value = !r.value;
|
|
539
|
+
},
|
|
540
|
+
onInput: I,
|
|
541
|
+
onNav: E,
|
|
542
|
+
apply: (S) => {
|
|
543
|
+
l.value.trim() && o(S, l.value.trim());
|
|
544
|
+
},
|
|
545
|
+
clear: (S) => {
|
|
546
|
+
n(S);
|
|
547
|
+
},
|
|
548
|
+
reset: D
|
|
549
|
+
};
|
|
550
|
+
}
|
|
551
|
+
function fn(e, t) {
|
|
552
|
+
const s = k(() => {
|
|
553
|
+
if (e.value) return !0;
|
|
554
|
+
if (typeof location > "u") return !1;
|
|
555
|
+
try {
|
|
556
|
+
return new URLSearchParams(location.search).get("mrp-debug") === "1";
|
|
557
|
+
} catch {
|
|
558
|
+
return !1;
|
|
559
|
+
}
|
|
560
|
+
}), o = k(() => !s.value || !t.plan.value ? 0 : Math.round(JSON.stringify(t.plan.value).length / 1024)), n = k(() => !s.value || !t.plan.value ? null : {
|
|
561
|
+
pages: t.pageCount.value,
|
|
562
|
+
window: `${t.windowRange.value.start}-${t.windowRange.value.end}`,
|
|
563
|
+
zoom: `${Math.round(t.zoom.value * 100)}%`,
|
|
564
|
+
loadMs: `${t.loadMs.value}ms`,
|
|
565
|
+
planKB: o.value
|
|
566
|
+
});
|
|
567
|
+
return { enabled: s, debugStats: n };
|
|
568
|
+
}
|
|
569
|
+
function pn(e, t) {
|
|
570
|
+
const { thumbsRoot: s, visible: o, renderThumbCanvas: n } = t, r = B(0), l = B(800), u = k(() => (e.value?.pages ?? []).map(
|
|
571
|
+
(E) => Math.round(E.pageHeightMm / E.pageWidthMm * 116)
|
|
572
|
+
)), p = k(() => Pt(u.value.map((E) => E + 20), 8)), m = k(() => p.value.window(l.value, r.value, 1)), c = k(() => {
|
|
573
|
+
if (!o.value) return [];
|
|
574
|
+
const { start: E, end: D } = m.value;
|
|
575
|
+
return u.value.slice(E, D + 1).map((S, C) => ({ index: E + C, height: S }));
|
|
576
|
+
});
|
|
577
|
+
let f = 0, h = 0, v = !1;
|
|
578
|
+
function A() {
|
|
579
|
+
const E = s.value;
|
|
580
|
+
E && (r.value = E.scrollTop, l.value = E.clientHeight || 800);
|
|
581
|
+
}
|
|
582
|
+
function W() {
|
|
583
|
+
v || h || (h = requestAnimationFrame(() => {
|
|
584
|
+
h = 0, A();
|
|
585
|
+
}));
|
|
586
|
+
}
|
|
587
|
+
function b() {
|
|
588
|
+
if (c.value, f && cancelAnimationFrame(f), f = 0, v || !o.value || !e.value || !s.value) return;
|
|
589
|
+
A();
|
|
590
|
+
const E = c.value, D = e.value, S = s.value;
|
|
591
|
+
let C = 0;
|
|
592
|
+
function H() {
|
|
593
|
+
if (f = 0, !(v || !o.value || e.value !== D || s.value !== S)) {
|
|
594
|
+
for (let j = 0; C < E.length && j < 2; j++, C++) {
|
|
595
|
+
const q = E[C].index, Y = S.querySelector(`[data-thumb="${q + 1}"]`);
|
|
596
|
+
if (!Y || Y.childElementCount > 0) continue;
|
|
597
|
+
const O = n(q);
|
|
598
|
+
O && (O.style.width = "100%", O.style.height = "100%", O.style.display = "block", Y.appendChild(O));
|
|
599
|
+
}
|
|
600
|
+
C < E.length && (f = requestAnimationFrame(H));
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
f = requestAnimationFrame(H);
|
|
604
|
+
}
|
|
605
|
+
function I() {
|
|
606
|
+
v = !0, f && cancelAnimationFrame(f), h && cancelAnimationFrame(h), f = h = 0;
|
|
607
|
+
}
|
|
608
|
+
return He(I), { schedule: b, destroy: I, onScroll: W, windowRange: m, visibleThumbs: c };
|
|
609
|
+
}
|
|
610
|
+
function mn() {
|
|
611
|
+
const e = Ie(0);
|
|
612
|
+
return {
|
|
613
|
+
loadMs: e,
|
|
614
|
+
start() {
|
|
615
|
+
return typeof performance < "u" ? performance.now() : 0;
|
|
616
|
+
},
|
|
617
|
+
end(t) {
|
|
618
|
+
e.value = t ? Math.round(performance.now() - t) : 0;
|
|
619
|
+
}
|
|
620
|
+
};
|
|
621
|
+
}
|
|
622
|
+
const vn = { class: "mrp-toolbar" }, hn = { class: "mrp-title" }, gn = ["disabled"], bn = { class: "mrp-pageinfo" }, wn = ["disabled"], yn = {
|
|
623
|
+
key: 1,
|
|
624
|
+
class: "mrp-search"
|
|
625
|
+
}, xn = ["placeholder", "value"], Pn = {
|
|
626
|
+
key: 0,
|
|
627
|
+
class: "mrp-search-count",
|
|
628
|
+
role: "status"
|
|
629
|
+
}, En = ["disabled"], $n = ["disabled"], kn = /* @__PURE__ */ rt({
|
|
630
|
+
__name: "ReportToolbar",
|
|
631
|
+
props: {
|
|
632
|
+
pageCount: {},
|
|
633
|
+
currentPage: {},
|
|
634
|
+
zoomMode: {},
|
|
635
|
+
zoom: {},
|
|
636
|
+
showExport: { type: Boolean },
|
|
637
|
+
showPrint: { type: Boolean },
|
|
638
|
+
showPdfWindow: { type: Boolean },
|
|
639
|
+
messages: {},
|
|
640
|
+
search: {},
|
|
641
|
+
thumbsVisible: { type: Boolean }
|
|
642
|
+
},
|
|
643
|
+
emits: ["goto", "zoom", "export", "print", "pdf-window", "search-input", "search-nav", "search-toggle", "thumbs-toggle"],
|
|
644
|
+
setup(e) {
|
|
645
|
+
const t = e, s = B(null);
|
|
646
|
+
Q(
|
|
647
|
+
() => t.search.visible,
|
|
648
|
+
(n) => {
|
|
649
|
+
n && qt(() => s.value?.focus());
|
|
650
|
+
}
|
|
651
|
+
);
|
|
652
|
+
function o(n, r, l) {
|
|
653
|
+
return n.replace("{cur}", String(r)).replace("{total}", String(l));
|
|
654
|
+
}
|
|
655
|
+
return (n, r) => (P(), $("div", vn, [
|
|
656
|
+
F("span", hn, M(e.messages.title), 1),
|
|
657
|
+
e.pageCount > 0 ? (P(), $(Ee, { key: 0 }, [
|
|
658
|
+
F("button", {
|
|
659
|
+
class: "mrp-nav",
|
|
660
|
+
type: "button",
|
|
661
|
+
disabled: e.currentPage <= 1,
|
|
662
|
+
onClick: r[0] || (r[0] = (l) => n.$emit("goto", e.currentPage - 1))
|
|
663
|
+
}, M(e.messages.prevPage), 9, gn),
|
|
664
|
+
F("span", bn, M(o(e.messages.pageInfo, e.currentPage, e.pageCount)), 1),
|
|
665
|
+
F("button", {
|
|
666
|
+
class: "mrp-nav",
|
|
667
|
+
type: "button",
|
|
668
|
+
disabled: e.currentPage >= e.pageCount,
|
|
669
|
+
onClick: r[1] || (r[1] = (l) => n.$emit("goto", e.currentPage + 1))
|
|
670
|
+
}, M(e.messages.nextPage), 9, wn)
|
|
671
|
+
], 64)) : N("", !0),
|
|
672
|
+
r[17] || (r[17] = F("span", { class: "mrp-spacer" }, null, -1)),
|
|
673
|
+
e.search.visible ? (P(), $("div", yn, [
|
|
674
|
+
F("input", {
|
|
675
|
+
ref_key: "searchInputRef",
|
|
676
|
+
ref: s,
|
|
677
|
+
class: "mrp-search-input",
|
|
678
|
+
type: "text",
|
|
679
|
+
placeholder: e.messages.searchPlaceholder,
|
|
680
|
+
value: e.search.query,
|
|
681
|
+
onInput: r[2] || (r[2] = (l) => n.$emit("search-input", l.target.value))
|
|
682
|
+
}, null, 40, xn),
|
|
683
|
+
e.search.query ? (P(), $("span", Pn, M(e.search.searching ? e.messages.searching ?? "搜索中…" : o(e.messages.matchInfo, e.search.matchCount > 0 ? e.search.matchIndex + 1 : 0, e.search.matchCount)), 1)) : N("", !0),
|
|
684
|
+
F("button", {
|
|
685
|
+
class: "mrp-nav",
|
|
686
|
+
type: "button",
|
|
687
|
+
disabled: e.search.matchCount === 0,
|
|
688
|
+
onClick: r[3] || (r[3] = (l) => n.$emit("search-nav", -1))
|
|
689
|
+
}, M(e.messages.prevMatch), 9, En),
|
|
690
|
+
F("button", {
|
|
691
|
+
class: "mrp-nav",
|
|
692
|
+
type: "button",
|
|
693
|
+
disabled: e.search.matchCount === 0,
|
|
694
|
+
onClick: r[4] || (r[4] = (l) => n.$emit("search-nav", 1))
|
|
695
|
+
}, M(e.messages.nextMatch), 9, $n)
|
|
696
|
+
])) : N("", !0),
|
|
697
|
+
F("button", {
|
|
698
|
+
class: oe(["mrp-nav", { "mrp-active": e.search.visible }]),
|
|
699
|
+
type: "button",
|
|
700
|
+
title: "Ctrl+F",
|
|
701
|
+
onClick: r[5] || (r[5] = (l) => n.$emit("search-toggle"))
|
|
702
|
+
}, " 🔍 ", 2),
|
|
703
|
+
F("button", {
|
|
704
|
+
class: oe(["mrp-nav", { "mrp-active": e.thumbsVisible }]),
|
|
705
|
+
type: "button",
|
|
706
|
+
onClick: r[6] || (r[6] = (l) => n.$emit("thumbs-toggle"))
|
|
707
|
+
}, " ▦ " + M(e.messages.thumbnails), 3),
|
|
708
|
+
F("button", {
|
|
709
|
+
class: oe(["mrp-nav", { "mrp-active": e.zoomMode === "fit" }]),
|
|
710
|
+
type: "button",
|
|
711
|
+
onClick: r[7] || (r[7] = (l) => n.$emit("zoom", "fit"))
|
|
712
|
+
}, M(e.messages.fitWidth), 3),
|
|
713
|
+
F("button", {
|
|
714
|
+
class: oe(["mrp-nav", { "mrp-active": e.zoomMode === "raw" && Math.round(e.zoom * 100) === 100 }]),
|
|
715
|
+
type: "button",
|
|
716
|
+
onClick: r[8] || (r[8] = (l) => n.$emit("zoom", 100))
|
|
717
|
+
}, " 100% ", 2),
|
|
718
|
+
F("button", {
|
|
719
|
+
class: oe(["mrp-nav", { "mrp-active": e.zoomMode === "raw" && Math.round(e.zoom * 100) === 150 }]),
|
|
720
|
+
type: "button",
|
|
721
|
+
onClick: r[9] || (r[9] = (l) => n.$emit("zoom", 150))
|
|
722
|
+
}, " 150% ", 2),
|
|
723
|
+
e.showExport ? (P(), $("button", {
|
|
724
|
+
key: 2,
|
|
725
|
+
class: "mrp-nav",
|
|
726
|
+
type: "button",
|
|
727
|
+
onClick: r[10] || (r[10] = (l) => n.$emit("export", "html"))
|
|
728
|
+
}, M(e.messages.exportHtml), 1)) : N("", !0),
|
|
729
|
+
e.showExport ? (P(), $("button", {
|
|
730
|
+
key: 3,
|
|
731
|
+
class: "mrp-nav",
|
|
732
|
+
type: "button",
|
|
733
|
+
onClick: r[11] || (r[11] = (l) => n.$emit("export", "pdf"))
|
|
734
|
+
}, M(e.messages.exportPdf), 1)) : N("", !0),
|
|
735
|
+
e.showExport ? (P(), $("button", {
|
|
736
|
+
key: 4,
|
|
737
|
+
class: "mrp-nav",
|
|
738
|
+
type: "button",
|
|
739
|
+
onClick: r[12] || (r[12] = (l) => n.$emit("export", "xlsx"))
|
|
740
|
+
}, M(e.messages.exportExcel), 1)) : N("", !0),
|
|
741
|
+
e.showExport ? (P(), $("button", {
|
|
742
|
+
key: 5,
|
|
743
|
+
class: "mrp-nav",
|
|
744
|
+
type: "button",
|
|
745
|
+
onClick: r[13] || (r[13] = (l) => n.$emit("export", "png"))
|
|
746
|
+
}, M(e.messages.exportImage), 1)) : N("", !0),
|
|
747
|
+
e.showExport ? (P(), $("button", {
|
|
748
|
+
key: 6,
|
|
749
|
+
class: "mrp-nav",
|
|
750
|
+
type: "button",
|
|
751
|
+
onClick: r[14] || (r[14] = (l) => n.$emit("export", "word"))
|
|
752
|
+
}, M(e.messages.exportWord), 1)) : N("", !0),
|
|
753
|
+
e.showPrint ? (P(), $("button", {
|
|
754
|
+
key: 7,
|
|
755
|
+
class: "mrp-nav",
|
|
756
|
+
type: "button",
|
|
757
|
+
onClick: r[15] || (r[15] = (l) => n.$emit("print"))
|
|
758
|
+
}, M(e.messages.print), 1)) : N("", !0),
|
|
759
|
+
e.showPdfWindow ? (P(), $("button", {
|
|
760
|
+
key: 8,
|
|
761
|
+
class: "mrp-nav",
|
|
762
|
+
type: "button",
|
|
763
|
+
onClick: r[16] || (r[16] = (l) => n.$emit("pdf-window"))
|
|
764
|
+
}, M(e.messages.pdfWindow), 1)) : N("", !0)
|
|
765
|
+
]));
|
|
766
|
+
}
|
|
767
|
+
}), st = (e, t) => {
|
|
768
|
+
const s = e.__vccOpts || e;
|
|
769
|
+
for (const [o, n] of t)
|
|
770
|
+
s[o] = n;
|
|
771
|
+
return s;
|
|
772
|
+
}, Mn = /* @__PURE__ */ st(kn, [["__scopeId", "data-v-601f8fa8"]]), Cn = { class: "mrp-params" }, Fn = { class: "mrp-params-title" }, Rn = { class: "mrp-params-grid" }, Tn = { class: "mrp-param-label" }, Sn = {
|
|
773
|
+
key: 0,
|
|
774
|
+
class: "mrp-param-star"
|
|
775
|
+
}, In = ["value", "onChange"], On = {
|
|
776
|
+
value: "",
|
|
777
|
+
disabled: "",
|
|
778
|
+
hidden: ""
|
|
779
|
+
}, Dn = ["value"], Wn = ["type", "placeholder", "value", "onInput"], Bn = { class: "mrp-params-actions" }, An = /* @__PURE__ */ rt({
|
|
780
|
+
__name: "ReportParamPanel",
|
|
781
|
+
props: {
|
|
782
|
+
defs: {},
|
|
783
|
+
modelValue: {},
|
|
784
|
+
messages: {},
|
|
785
|
+
attempted: { type: Boolean }
|
|
786
|
+
},
|
|
787
|
+
emits: ["update:modelValue", "query", "reset"],
|
|
788
|
+
setup(e, { emit: t }) {
|
|
789
|
+
const s = e, o = t, n = B({ ...s.modelValue });
|
|
790
|
+
Q(
|
|
791
|
+
() => s.modelValue,
|
|
792
|
+
(p) => {
|
|
793
|
+
n.value = { ...p };
|
|
794
|
+
}
|
|
795
|
+
);
|
|
796
|
+
const r = k(
|
|
797
|
+
() => s.defs.map((p) => ({
|
|
798
|
+
def: p,
|
|
799
|
+
label: p.label ?? p.field,
|
|
800
|
+
value: n.value[p.field] ?? ""
|
|
801
|
+
}))
|
|
802
|
+
);
|
|
803
|
+
function l(p, m) {
|
|
804
|
+
n.value = { ...n.value, [p]: m }, o("update:modelValue", { ...n.value });
|
|
805
|
+
}
|
|
806
|
+
function u(p) {
|
|
807
|
+
const m = s.defs.find((c) => c.field === p);
|
|
808
|
+
return s.attempted && m?.required === !0 && !(n.value[p] ?? "").trim();
|
|
809
|
+
}
|
|
810
|
+
return (p, m) => (P(), $("div", Cn, [
|
|
811
|
+
F("span", Fn, M(e.messages.paramsTitle), 1),
|
|
812
|
+
F("div", Rn, [
|
|
813
|
+
(P(!0), $(Ee, null, We(r.value, (c) => (P(), $("label", {
|
|
814
|
+
key: c.def.field,
|
|
815
|
+
class: oe(["mrp-param", { "mrp-param-missing": u(c.def.field) }])
|
|
816
|
+
}, [
|
|
817
|
+
F("span", Tn, [
|
|
818
|
+
et(M(c.label), 1),
|
|
819
|
+
c.def.required ? (P(), $("i", Sn, "*")) : N("", !0)
|
|
820
|
+
]),
|
|
821
|
+
(c.def.type ?? "text") === "select" ? (P(), $("select", {
|
|
822
|
+
key: 0,
|
|
823
|
+
class: "mrp-param-input",
|
|
824
|
+
value: c.value,
|
|
825
|
+
onChange: (f) => l(c.def.field, f.target.value),
|
|
826
|
+
onKeydown: m[0] || (m[0] = mt((f) => p.$emit("query"), ["enter"]))
|
|
827
|
+
}, [
|
|
828
|
+
F("option", On, M(c.def.placeholder ?? `请选择${c.label}`), 1),
|
|
829
|
+
(P(!0), $(Ee, null, We(c.def.options ?? [], (f) => (P(), $("option", {
|
|
830
|
+
key: f.value,
|
|
831
|
+
value: f.value
|
|
832
|
+
}, M(f.label), 9, Dn))), 128))
|
|
833
|
+
], 40, In)) : (P(), $("input", {
|
|
834
|
+
key: 1,
|
|
835
|
+
class: "mrp-param-input",
|
|
836
|
+
type: c.def.type === "number" ? "number" : c.def.type === "date" ? "date" : "text",
|
|
837
|
+
placeholder: c.def.placeholder ?? `请输入${c.label}`,
|
|
838
|
+
value: c.value,
|
|
839
|
+
onInput: (f) => l(c.def.field, f.target.value),
|
|
840
|
+
onKeydown: m[1] || (m[1] = mt((f) => p.$emit("query"), ["enter"]))
|
|
841
|
+
}, null, 40, Wn))
|
|
842
|
+
], 2))), 128))
|
|
843
|
+
]),
|
|
844
|
+
F("div", Bn, [
|
|
845
|
+
F("button", {
|
|
846
|
+
class: "mrp-nav mrp-param-query",
|
|
847
|
+
type: "button",
|
|
848
|
+
onClick: m[2] || (m[2] = (c) => p.$emit("query"))
|
|
849
|
+
}, M(e.messages.query), 1),
|
|
850
|
+
F("button", {
|
|
851
|
+
class: "mrp-nav",
|
|
852
|
+
type: "button",
|
|
853
|
+
onClick: m[3] || (m[3] = (c) => p.$emit("reset"))
|
|
854
|
+
}, M(e.messages.reset), 1)
|
|
855
|
+
])
|
|
856
|
+
]));
|
|
857
|
+
}
|
|
858
|
+
}), Ln = /* @__PURE__ */ st(An, [["__scopeId", "data-v-aafce92d"]]), zn = {
|
|
859
|
+
title: "报表预览",
|
|
860
|
+
prevPage: "‹ 上一页",
|
|
861
|
+
nextPage: "下一页 ›",
|
|
862
|
+
pageInfo: "{cur} / {total}",
|
|
863
|
+
fitWidth: "适宽",
|
|
864
|
+
exportHtml: "导出 HTML",
|
|
865
|
+
exportPdf: "导出 PDF",
|
|
866
|
+
exportExcel: "导出 Excel",
|
|
867
|
+
exportImage: "导出图片",
|
|
868
|
+
exportWord: "导出 Word",
|
|
869
|
+
exporting: "正在生成 {format}…",
|
|
870
|
+
print: "打印",
|
|
871
|
+
pdfWindow: "PDF 窗口",
|
|
872
|
+
loading: "报表渲染中…",
|
|
873
|
+
empty: "暂无预览数据",
|
|
874
|
+
errorPrefix: "",
|
|
875
|
+
retry: "重试",
|
|
876
|
+
pdfFontUnavailable: "PDF 字体尚未就绪,请联系管理员检查字体配置;预览及其它导出仍可使用。",
|
|
877
|
+
searchPlaceholder: "搜索报表内容",
|
|
878
|
+
matchInfo: "{cur}/{total}",
|
|
879
|
+
prevMatch: "‹",
|
|
880
|
+
nextMatch: "›",
|
|
881
|
+
thumbnails: "缩略图",
|
|
882
|
+
paramsTitle: "查询条件",
|
|
883
|
+
query: "查 询",
|
|
884
|
+
reset: "重 置",
|
|
885
|
+
paramRequired: "请填写{label}",
|
|
886
|
+
searching: "搜索中…"
|
|
887
|
+
}, Hn = {
|
|
888
|
+
shellBg: "#525659",
|
|
889
|
+
shellFg: "#e8e8e8",
|
|
890
|
+
toolbarBg: "#323639",
|
|
891
|
+
toolbarBorder: "#22252a",
|
|
892
|
+
toolbarFg: "#e8e8e8",
|
|
893
|
+
btnFg: "#cfcfcf",
|
|
894
|
+
btnBorder: "#4a4d52",
|
|
895
|
+
btnHoverBg: "#414549",
|
|
896
|
+
btnHoverFg: "#ffffff",
|
|
897
|
+
btnActiveBg: "#2d5fb8"
|
|
898
|
+
};
|
|
899
|
+
function qn(e = {}) {
|
|
900
|
+
return { ...e, defaults: e.defaults ?? {}, presets: e.presets ?? {} };
|
|
901
|
+
}
|
|
902
|
+
function gr(e) {
|
|
903
|
+
return e;
|
|
904
|
+
}
|
|
905
|
+
const de = {
|
|
906
|
+
showExport: !0,
|
|
907
|
+
showPrint: !0,
|
|
908
|
+
showPdfWindow: !0,
|
|
909
|
+
showParams: !0,
|
|
910
|
+
gapPx: 18,
|
|
911
|
+
pdfFontUrl: "/simhei.ttf",
|
|
912
|
+
logger: console
|
|
913
|
+
}, br = { warn: () => {
|
|
914
|
+
}, info: () => {
|
|
915
|
+
} };
|
|
916
|
+
function De(e, t) {
|
|
917
|
+
return {
|
|
918
|
+
...e,
|
|
919
|
+
...t,
|
|
920
|
+
theme: { ...e?.theme, ...t?.theme },
|
|
921
|
+
messages: { ...e?.messages, ...t?.messages },
|
|
922
|
+
preview: { ...e?.preview, ...t?.preview },
|
|
923
|
+
xlsx: { ...e?.xlsx, ...t?.xlsx }
|
|
924
|
+
};
|
|
925
|
+
}
|
|
926
|
+
function Nn(e, t) {
|
|
927
|
+
const s = t ? e?.presets?.[t] : e?.defaultPreset ? e?.presets?.[e.defaultPreset] : void 0, o = De(e?.defaults, s);
|
|
928
|
+
return {
|
|
929
|
+
showExport: o.showExport ?? de.showExport,
|
|
930
|
+
showPrint: o.showPrint ?? de.showPrint,
|
|
931
|
+
showPdfWindow: o.showPdfWindow ?? de.showPdfWindow,
|
|
932
|
+
showParams: o.showParams ?? de.showParams,
|
|
933
|
+
gapPx: o.gapPx ?? de.gapPx,
|
|
934
|
+
pdfFontUrl: o.pdfFontUrl ?? de.pdfFontUrl,
|
|
935
|
+
theme: { ...Hn, ...o.theme },
|
|
936
|
+
messages: { ...zn, ...o.messages },
|
|
937
|
+
logger: o.logger ?? de.logger,
|
|
938
|
+
preview: {
|
|
939
|
+
overscanPages: ht(o.preview?.overscanPages, 1, 10, !0),
|
|
940
|
+
searchDebounceMs: ht(o.preview?.searchDebounceMs, 200, 2e3)
|
|
941
|
+
},
|
|
942
|
+
xlsx: { ...o.xlsx }
|
|
943
|
+
};
|
|
944
|
+
}
|
|
945
|
+
function ht(e, t, s, o = !1) {
|
|
946
|
+
if (e == null || !Number.isFinite(e)) return t;
|
|
947
|
+
const n = Math.max(0, Math.min(s, e));
|
|
948
|
+
return o ? Math.floor(n) : n;
|
|
949
|
+
}
|
|
950
|
+
function jn(e) {
|
|
951
|
+
const t = {};
|
|
952
|
+
return e.shellBg != null && (t["--mrp-shell-bg"] = e.shellBg), e.shellFg != null && (t["--mrp-shell-fg"] = e.shellFg), e.toolbarBg != null && (t["--mrp-toolbar-bg"] = e.toolbarBg), e.toolbarBorder != null && (t["--mrp-toolbar-border"] = e.toolbarBorder), e.toolbarFg != null && (t["--mrp-toolbar-fg"] = e.toolbarFg), e.btnFg != null && (t["--mrp-btn-fg"] = e.btnFg), e.btnBorder != null && (t["--mrp-btn-border"] = e.btnBorder), e.btnHoverBg != null && (t["--mrp-btn-hover-bg"] = e.btnHoverBg), e.btnHoverFg != null && (t["--mrp-btn-hover-fg"] = e.btnHoverFg), e.btnActiveBg != null && (t["--mrp-btn-active-bg"] = e.btnActiveBg), t;
|
|
953
|
+
}
|
|
954
|
+
function wr(e) {
|
|
955
|
+
const t = Be(tt, null), s = k(() => {
|
|
956
|
+
const o = t?.value ?? null, n = "defaults" in e || "presets" in e || "defaultPreset" in e ? qn(e) : { defaults: e, presets: {} };
|
|
957
|
+
if (!o) return n;
|
|
958
|
+
const r = { ...o.presets, ...n.presets };
|
|
959
|
+
for (const l of Object.keys(r))
|
|
960
|
+
r[l] = De(
|
|
961
|
+
De(o.presets[l], n.defaults),
|
|
962
|
+
n.presets[l]
|
|
963
|
+
);
|
|
964
|
+
return {
|
|
965
|
+
defaults: De(o.defaults, n.defaults),
|
|
966
|
+
presets: r,
|
|
967
|
+
defaultPreset: n.defaultPreset ?? o.defaultPreset
|
|
968
|
+
};
|
|
969
|
+
});
|
|
970
|
+
yt(tt, s);
|
|
971
|
+
}
|
|
972
|
+
function Un() {
|
|
973
|
+
return Be(tt, k(() => null));
|
|
974
|
+
}
|
|
975
|
+
const gt = /* @__PURE__ */ new Map(), me = /* @__PURE__ */ new Map(), Vn = 15e3;
|
|
976
|
+
function nt(e, t) {
|
|
977
|
+
return Object.assign(new Error(e), { cause: t });
|
|
978
|
+
}
|
|
979
|
+
function Pe(e, t) {
|
|
980
|
+
return `PDF 字体 ${JSON.stringify(e)}:${t}。请部署支持报表文字的字体文件,并将 pdfFontUrl 配置为可访问的字体 URL;西文报表可设为空串`;
|
|
981
|
+
}
|
|
982
|
+
function ze(e) {
|
|
983
|
+
if (e?.reason instanceof Error && e.reason.name === "AbortError") return e.reason;
|
|
984
|
+
const t = nt("PDF 字体检查已取消", e?.reason);
|
|
985
|
+
return t.name = "AbortError", t;
|
|
986
|
+
}
|
|
987
|
+
async function Kn(e, t) {
|
|
988
|
+
let s = !1;
|
|
989
|
+
const o = setTimeout(() => {
|
|
990
|
+
s = !0, t.abort();
|
|
991
|
+
}, Vn);
|
|
992
|
+
try {
|
|
993
|
+
const n = await fetch(e, { method: "HEAD", signal: t.signal });
|
|
994
|
+
if (t.signal.aborted) throw ze(t.signal);
|
|
995
|
+
if (n.status === 405 || n.status === 501 || n.type === "opaque")
|
|
996
|
+
return {
|
|
997
|
+
status: "unverified",
|
|
998
|
+
fontUrl: e,
|
|
999
|
+
message: `PDF 字体 ${JSON.stringify(e)} 无法通过 HEAD 检查验证;仍可尝试导出,届时会加载并校验字体`
|
|
1000
|
+
};
|
|
1001
|
+
if (!n.ok) {
|
|
1002
|
+
const l = new Error(`字体请求返回 HTTP ${n.status}`);
|
|
1003
|
+
return { status: "error", fontUrl: e, message: Pe(e, l.message), cause: l };
|
|
1004
|
+
}
|
|
1005
|
+
const r = n.headers.get("content-type") ?? "";
|
|
1006
|
+
if (/text\/html|application\/xhtml\+xml/i.test(r)) {
|
|
1007
|
+
const l = new Error("字体 URL 返回 HTML 页面(可能是 SPA 路由回退),不是字体文件");
|
|
1008
|
+
return { status: "error", fontUrl: e, message: Pe(e, l.message), cause: l };
|
|
1009
|
+
}
|
|
1010
|
+
if (/^text\//i.test(r) || /(?:\/|\+)json(?:\s*;|$)/i.test(r)) {
|
|
1011
|
+
const l = new Error(`字体 URL 返回 ${r} 文本响应,不是字体文件`);
|
|
1012
|
+
return { status: "error", fontUrl: e, message: Pe(e, l.message), cause: l };
|
|
1013
|
+
}
|
|
1014
|
+
return {
|
|
1015
|
+
status: "available",
|
|
1016
|
+
fontUrl: e,
|
|
1017
|
+
message: "PDF 字体资源可达;文字覆盖范围将在实际导出时校验"
|
|
1018
|
+
};
|
|
1019
|
+
} catch (n) {
|
|
1020
|
+
if (t.signal.aborted && !s) throw ze(t.signal);
|
|
1021
|
+
return {
|
|
1022
|
+
status: "error",
|
|
1023
|
+
fontUrl: e,
|
|
1024
|
+
message: Pe(e, s ? "字体检查超时,请检查网络或字体服务" : "字体检查失败,请检查网络、字体服务或跨域访问配置"),
|
|
1025
|
+
cause: n
|
|
1026
|
+
};
|
|
1027
|
+
} finally {
|
|
1028
|
+
clearTimeout(o);
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1031
|
+
function Yn(e, t) {
|
|
1032
|
+
if (t?.aborted) return Promise.reject(ze(t));
|
|
1033
|
+
if (!e)
|
|
1034
|
+
return Promise.resolve({ status: "disabled", fontUrl: e, message: "已停用自定义 PDF 字体;内置字体用于西文,其他文字会在导出时校验" });
|
|
1035
|
+
const s = gt.get(e);
|
|
1036
|
+
if (s) return Promise.resolve(s);
|
|
1037
|
+
let o = me.get(e);
|
|
1038
|
+
if (!o) {
|
|
1039
|
+
const r = new AbortController();
|
|
1040
|
+
o = { controller: r, promise: Kn(e, r), subscribers: 0 };
|
|
1041
|
+
const l = o;
|
|
1042
|
+
me.set(e, l), l.promise = l.promise.then((u) => (!r.signal.aborted && u.status === "available" && gt.set(e, u), u)).finally(() => {
|
|
1043
|
+
me.get(e) === l && me.delete(e);
|
|
1044
|
+
});
|
|
1045
|
+
}
|
|
1046
|
+
const n = o;
|
|
1047
|
+
return n.subscribers++, new Promise((r, l) => {
|
|
1048
|
+
let u = !1;
|
|
1049
|
+
const p = () => u ? !1 : (u = !0, n.subscribers--, t?.removeEventListener("abort", m), !0), m = () => {
|
|
1050
|
+
p() && (n.subscribers === 0 && (me.get(e) === n && me.delete(e), n.controller.abort()), l(ze(t)));
|
|
1051
|
+
};
|
|
1052
|
+
t?.addEventListener("abort", m, { once: !0 }), n.promise.then(
|
|
1053
|
+
(c) => {
|
|
1054
|
+
p() && r(c);
|
|
1055
|
+
},
|
|
1056
|
+
(c) => {
|
|
1057
|
+
p() && l(c);
|
|
1058
|
+
}
|
|
1059
|
+
), t?.aborted && m();
|
|
1060
|
+
});
|
|
1061
|
+
}
|
|
1062
|
+
function Zn(e = { fontUrl: "/simhei.ttf" }) {
|
|
1063
|
+
let t = null;
|
|
1064
|
+
const s = async (o, n) => {
|
|
1065
|
+
t || (t = await import("@agile-team/mach-report/pdf"));
|
|
1066
|
+
let r = null;
|
|
1067
|
+
if (e.fontUrl)
|
|
1068
|
+
try {
|
|
1069
|
+
if (r = await t.loadFontWithCache(e.fontUrl, { strict: !0 }), !r?.byteLength) throw new Error("字体文件为空或加载失败");
|
|
1070
|
+
} catch (f) {
|
|
1071
|
+
const h = f instanceof Error ? f.message : String(f);
|
|
1072
|
+
throw nt(Pe(e.fontUrl, h), f);
|
|
1073
|
+
}
|
|
1074
|
+
let l;
|
|
1075
|
+
try {
|
|
1076
|
+
l = await t.renderPlanToPdf(o, r ? { customFontBytes: r } : {});
|
|
1077
|
+
} catch (f) {
|
|
1078
|
+
if (!r) throw f;
|
|
1079
|
+
const h = f instanceof Error ? f.message : String(f);
|
|
1080
|
+
throw nt(`PDF 生成失败:${h}。当前字体 URL 为 ${JSON.stringify(e.fontUrl)};请确认该文件是有效字体,或重新配置 pdfFontUrl`, f);
|
|
1081
|
+
}
|
|
1082
|
+
const { bytes: u, unsupportedTextCount: p, pageErrors: m, fidelityWarnings: c } = l;
|
|
1083
|
+
if (p > 0)
|
|
1084
|
+
throw new Error(`PDF 中有 ${p} 行文字无法编码;请部署支持所用文字的字体并配置 pdfFontUrl`);
|
|
1085
|
+
if (m.length > 0)
|
|
1086
|
+
throw new Error(`PDF 有 ${m.length} 页渲染失败:${m[0]}`);
|
|
1087
|
+
return c.length > 0 && n?.(`PDF 有 ${c.length} 处版式降级:${c.slice(0, 2).join(";")}`), u;
|
|
1088
|
+
};
|
|
1089
|
+
return s.checkFont = (o) => Yn(e.fontUrl, o), s;
|
|
1090
|
+
}
|
|
1091
|
+
class ve extends Error {
|
|
1092
|
+
constructor(t, s, o) {
|
|
1093
|
+
super(s), this.name = "MachReportError", this.code = t, this.cause = o;
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
function Jn(e) {
|
|
1097
|
+
return e instanceof ve ? { code: e.code, cause: e.cause } : { code: "render", cause: e };
|
|
1098
|
+
}
|
|
1099
|
+
const Gn = {
|
|
1100
|
+
key: 2,
|
|
1101
|
+
class: "mrp-export-notice mrp-export-warning",
|
|
1102
|
+
role: "status"
|
|
1103
|
+
}, Xn = { class: "mrp-main" }, Qn = {
|
|
1104
|
+
key: 0,
|
|
1105
|
+
class: "mrp-state"
|
|
1106
|
+
}, _n = {
|
|
1107
|
+
key: 1,
|
|
1108
|
+
class: "mrp-state mrp-error"
|
|
1109
|
+
}, er = {
|
|
1110
|
+
key: 2,
|
|
1111
|
+
class: "mrp-state"
|
|
1112
|
+
}, tr = ["data-page"], nr = ["onClick"], rr = ["data-thumb"], or = { class: "mrp-thumb-no" }, ar = { class: "mrp-overlay" }, sr = {
|
|
1113
|
+
key: 3,
|
|
1114
|
+
class: "mrp-debug",
|
|
1115
|
+
"aria-hidden": "true"
|
|
1116
|
+
}, Se = 96 / 25.4, bt = "mach-report:ui", wt = "mach-report:ui:wide", lr = /* @__PURE__ */ rt({
|
|
1117
|
+
__name: "ReportPreview",
|
|
1118
|
+
props: {
|
|
1119
|
+
reportId: {
|
|
1120
|
+
type: [String, Array],
|
|
1121
|
+
default: null
|
|
1122
|
+
},
|
|
1123
|
+
params: {
|
|
1124
|
+
type: Object,
|
|
1125
|
+
default: () => ({})
|
|
1126
|
+
},
|
|
1127
|
+
height: { type: String, default: "100vh" },
|
|
1128
|
+
autoLoad: { type: Boolean, default: !0 },
|
|
1129
|
+
/** 以下显隐/间距不传时走配置中心(preset > defaults > 内置缺省) */
|
|
1130
|
+
showExport: { type: Boolean, default: void 0 },
|
|
1131
|
+
showPrint: { type: Boolean, default: void 0 },
|
|
1132
|
+
showPdfWindow: { type: Boolean, default: void 0 },
|
|
1133
|
+
/** 页间距(px);不传走配置中心 */
|
|
1134
|
+
gapPx: { type: Number, default: void 0 },
|
|
1135
|
+
/** 工具栏/状态文案覆写(不传走配置中心 messages) */
|
|
1136
|
+
messages: { type: Object, default: void 0 },
|
|
1137
|
+
/** 启用的 preset 名(不传用配置中心 defaultPreset) */
|
|
1138
|
+
preset: { type: String, default: void 0 },
|
|
1139
|
+
/** 调试面板(也可用 URL ?mrp-debug=1 开启) */
|
|
1140
|
+
debug: { type: Boolean, default: !1 },
|
|
1141
|
+
/** 参数定义(优先级:prop > 模板 params;有定义且未关闭时显示查询面板) */
|
|
1142
|
+
paramDefs: {
|
|
1143
|
+
type: Array,
|
|
1144
|
+
default: void 0
|
|
1145
|
+
},
|
|
1146
|
+
/** 参数面板显隐(不传走配置中心,缺省 true;有参数定义才渲染) */
|
|
1147
|
+
showParams: { type: Boolean, default: void 0 },
|
|
1148
|
+
fetcher: {
|
|
1149
|
+
type: Function,
|
|
1150
|
+
default: null
|
|
1151
|
+
}
|
|
1152
|
+
},
|
|
1153
|
+
emits: ["loaded", "error", "warning"],
|
|
1154
|
+
setup(e, { expose: t, emit: s }) {
|
|
1155
|
+
Nt((i) => ({
|
|
1156
|
+
v5d32312f: S.value + "px"
|
|
1157
|
+
}));
|
|
1158
|
+
const o = e, n = s, r = Ie(null), l = B(!1), u = B(""), p = Ie(null), m = B(null), c = B(!1), f = Ie(Object.freeze({ status: "unchecked", fontUrl: "" })), h = B(null), v = B(1), A = B(null), W = B(null), b = B(null), I = B(!1), E = mn(), D = k(() => !!r.value?.pages.length && r.value.pages.every((i) => i.layout === "wide")), S = k(() => Math.max(0, K.value));
|
|
1159
|
+
let C = bt;
|
|
1160
|
+
const H = Be(Qt, null), j = Be(_t, null), q = k(() => Et(o.reportId)), Y = k(() => o.fetcher ?? H), O = k(() => r.value?.pages.length ?? 0), ae = k(() => Object.freeze({
|
|
1161
|
+
loading: l.value,
|
|
1162
|
+
hasPlan: O.value > 0,
|
|
1163
|
+
pageCount: O.value,
|
|
1164
|
+
currentPage: v.value,
|
|
1165
|
+
exporting: m.value,
|
|
1166
|
+
printing: c.value,
|
|
1167
|
+
canExport: !l.value && O.value > 0 && m.value === null,
|
|
1168
|
+
canPrint: !l.value && O.value > 0 && !c.value,
|
|
1169
|
+
error: p.value,
|
|
1170
|
+
pdfFont: f.value
|
|
1171
|
+
}));
|
|
1172
|
+
function ee(i, g, w) {
|
|
1173
|
+
p.value = Object.freeze({ message: i, code: g, cause: w }), n("error", i, { code: g, cause: w });
|
|
1174
|
+
}
|
|
1175
|
+
const fe = Un(), a = k(() => Nn(fe.value, o.preset)), d = k(() => ({
|
|
1176
|
+
...a.value.messages,
|
|
1177
|
+
...o.messages
|
|
1178
|
+
})), y = k(() => o.showExport ?? a.value.showExport), R = k(() => o.showPrint ?? a.value.showPrint), T = k(() => o.showPdfWindow ?? a.value.showPdfWindow), K = k(() => o.gapPx ?? (D.value ? 0 : a.value.gapPx)), J = k(() => o.showParams ?? a.value.showParams);
|
|
1179
|
+
let G = null, qe = null;
|
|
1180
|
+
function lt() {
|
|
1181
|
+
if (j) return j;
|
|
1182
|
+
const i = a.value.pdfFontUrl;
|
|
1183
|
+
return (!qe || G !== i) && (G = i, qe = Zn({ fontUrl: i })), qe;
|
|
1184
|
+
}
|
|
1185
|
+
let $e = 0, he = null, ke = null, ge = !1;
|
|
1186
|
+
function Ne() {
|
|
1187
|
+
$e++, he?.abort(), he = null;
|
|
1188
|
+
}
|
|
1189
|
+
async function Me() {
|
|
1190
|
+
if (ge) throw new ve("config", "报表预览已卸载");
|
|
1191
|
+
Ne();
|
|
1192
|
+
const i = $e, g = new AbortController();
|
|
1193
|
+
he = g;
|
|
1194
|
+
const w = a.value.pdfFontUrl;
|
|
1195
|
+
f.value = Object.freeze({ status: "checking", fontUrl: w });
|
|
1196
|
+
try {
|
|
1197
|
+
const U = lt(), V = U.checkFont ? await U.checkFont(g.signal) : { status: "unverified", fontUrl: "", message: "自定义 PDF 导出器未提供字体预检查;字体由宿主确认" };
|
|
1198
|
+
return !ge && i === $e && !g.signal.aborted && (f.value = Object.freeze({ ...V })), V;
|
|
1199
|
+
} catch (U) {
|
|
1200
|
+
if (g.signal.aborted) throw U;
|
|
1201
|
+
const V = {
|
|
1202
|
+
status: "error",
|
|
1203
|
+
fontUrl: w,
|
|
1204
|
+
message: U instanceof Error ? U.message : "PDF 字体检查失败",
|
|
1205
|
+
cause: U
|
|
1206
|
+
};
|
|
1207
|
+
return !ge && i === $e && (f.value = Object.freeze(V)), V;
|
|
1208
|
+
} finally {
|
|
1209
|
+
he === g && (he = null);
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
1212
|
+
function Mt() {
|
|
1213
|
+
Me().catch(() => {
|
|
1214
|
+
});
|
|
1215
|
+
}
|
|
1216
|
+
Q(
|
|
1217
|
+
[r, () => a.value.pdfFontUrl, y, T],
|
|
1218
|
+
() => {
|
|
1219
|
+
const i = f.value.fontUrl === a.value.pdfFontUrl;
|
|
1220
|
+
Ne(), (!i || f.value.status === "checking") && (f.value = Object.freeze({ status: "unchecked", fontUrl: a.value.pdfFontUrl })), !ge && O.value > 0 && (y.value || T.value) && Me().catch(() => {
|
|
1221
|
+
});
|
|
1222
|
+
},
|
|
1223
|
+
{ immediate: !0 }
|
|
1224
|
+
);
|
|
1225
|
+
const se = k(
|
|
1226
|
+
() => o.paramDefs ?? Y.value?.getParamDefs?.(q.value) ?? []
|
|
1227
|
+
), ue = B({}), je = B(!1);
|
|
1228
|
+
function be(i) {
|
|
1229
|
+
const g = {};
|
|
1230
|
+
for (const w of i)
|
|
1231
|
+
g[w.field] = o.params[w.field] ?? w.defaultValue ?? "";
|
|
1232
|
+
ue.value = g, je.value = !1;
|
|
1233
|
+
}
|
|
1234
|
+
be(se.value), Q(se, (i) => be(i)), Q(q, () => be(se.value)), Q(() => JSON.stringify(o.params), () => be(se.value));
|
|
1235
|
+
const Ct = k(() => {
|
|
1236
|
+
const i = { ...o.params };
|
|
1237
|
+
for (const [g, w] of Object.entries(ue.value))
|
|
1238
|
+
w === "" ? delete i[g] : i[g] = w;
|
|
1239
|
+
return i;
|
|
1240
|
+
});
|
|
1241
|
+
function Ft() {
|
|
1242
|
+
return se.value.filter(
|
|
1243
|
+
(i) => i.required === !0 && !(ue.value[i.field] ?? "").trim()
|
|
1244
|
+
);
|
|
1245
|
+
}
|
|
1246
|
+
function Rt() {
|
|
1247
|
+
je.value = !0;
|
|
1248
|
+
const i = Ft();
|
|
1249
|
+
if (i.length > 0) {
|
|
1250
|
+
const g = i[0].label ?? i[0].field, w = d.value.paramRequired.replace("{label}", g);
|
|
1251
|
+
u.value = w, ee(w, "param");
|
|
1252
|
+
return;
|
|
1253
|
+
}
|
|
1254
|
+
ce();
|
|
1255
|
+
}
|
|
1256
|
+
function Tt() {
|
|
1257
|
+
be(se.value);
|
|
1258
|
+
}
|
|
1259
|
+
const St = k(() => ({
|
|
1260
|
+
height: o.height,
|
|
1261
|
+
...jn(a.value.theme)
|
|
1262
|
+
})), { zoom: Z, zoomMode: we, applyFitZoom: it, setZoom: ye } = nn(() => ({
|
|
1263
|
+
viewport: W.value,
|
|
1264
|
+
pageWidthPx: Ue.contentSize.value.w || 210 * Se
|
|
1265
|
+
})), Ue = tn(r, Z, {
|
|
1266
|
+
pxPerMm: Se,
|
|
1267
|
+
gapPx: K,
|
|
1268
|
+
overscan: k(() => a.value.preview.overscanPages)
|
|
1269
|
+
}), { contentSize: Ve, windowRange: xe, visiblePages: ut, makeScrollHandler: It, refreshViewport: Ke } = Ue, Ot = It(v, O);
|
|
1270
|
+
function Ye(i) {
|
|
1271
|
+
ye(i * 100);
|
|
1272
|
+
}
|
|
1273
|
+
function Ce() {
|
|
1274
|
+
Dt(), r.value = null, v.value = 1, L.reset();
|
|
1275
|
+
}
|
|
1276
|
+
let le = 0, te = null;
|
|
1277
|
+
async function ce() {
|
|
1278
|
+
const i = ++le;
|
|
1279
|
+
te?.abort(), te = null;
|
|
1280
|
+
const g = Y.value;
|
|
1281
|
+
if (l.value = !1, p.value = null, q.value.length === 0) {
|
|
1282
|
+
u.value = "缺少报表 ID", Ce(), ee(u.value, "param");
|
|
1283
|
+
return;
|
|
1284
|
+
}
|
|
1285
|
+
if (!g) {
|
|
1286
|
+
u.value = "未提供渲染数据源 fetcher", Ce(), ee(u.value, "config");
|
|
1287
|
+
return;
|
|
1288
|
+
}
|
|
1289
|
+
l.value = !0, u.value = "", h.value = null, Ce();
|
|
1290
|
+
const w = E.start(), U = new AbortController();
|
|
1291
|
+
te = U;
|
|
1292
|
+
const V = /* @__PURE__ */ new Set();
|
|
1293
|
+
function Re(z) {
|
|
1294
|
+
i !== le || U.signal.aborted || V.has(z) || (V.add(z), a.value.logger.warn("[mach-report] 报表告警:", z), n("warning", z));
|
|
1295
|
+
}
|
|
1296
|
+
try {
|
|
1297
|
+
const z = await g({
|
|
1298
|
+
reportIds: q.value,
|
|
1299
|
+
params: { ...Ct.value },
|
|
1300
|
+
signal: U.signal,
|
|
1301
|
+
onWarning: Re
|
|
1302
|
+
});
|
|
1303
|
+
if (i !== le) return;
|
|
1304
|
+
const X = Jt(z);
|
|
1305
|
+
if (!X.ok) {
|
|
1306
|
+
const Te = X.errors.slice(0, 3).map((pt) => `${pt.path}: ${pt.message}`).join("; ");
|
|
1307
|
+
throw new ve(
|
|
1308
|
+
"validate",
|
|
1309
|
+
`渲染计划校验失败(${X.errors.length} 处): ${Te}`
|
|
1310
|
+
);
|
|
1311
|
+
}
|
|
1312
|
+
if (X.warnings.forEach((Te) => Re(`${Te.path}: ${Te.message}`)), i !== le || U.signal.aborted) return;
|
|
1313
|
+
r.value = z, v.value = 1, E.end(w), W.value && (W.value.scrollTop = 0, W.value.scrollLeft = 0);
|
|
1314
|
+
const ie = D.value ? wt : bt;
|
|
1315
|
+
ie !== C && (C = ie, ft()), we.value === "fit" && it(), n("loaded", z.pages.length);
|
|
1316
|
+
} catch (z) {
|
|
1317
|
+
if (i !== le) return;
|
|
1318
|
+
const X = z instanceof ve ? z : z instanceof Gt ? new ve(z.code, z.message, z.cause) : new ve(
|
|
1319
|
+
"fetch",
|
|
1320
|
+
z instanceof Error ? z.message : "预览加载失败",
|
|
1321
|
+
z
|
|
1322
|
+
);
|
|
1323
|
+
u.value = X.message;
|
|
1324
|
+
const ie = Jn(X);
|
|
1325
|
+
ee(X.message, ie.code, ie.cause);
|
|
1326
|
+
} finally {
|
|
1327
|
+
i === le && (l.value = !1), te === U && (te = null);
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1330
|
+
function ne(i) {
|
|
1331
|
+
if (O.value <= 0) return;
|
|
1332
|
+
const g = Math.max(1, Math.min(O.value, i));
|
|
1333
|
+
v.value = g;
|
|
1334
|
+
const w = W.value;
|
|
1335
|
+
w && (w.scrollTop = Ue.pageOffsetPx(g - 1) * Z.value, Ke(w));
|
|
1336
|
+
}
|
|
1337
|
+
const Fe = on(r, {
|
|
1338
|
+
getPdfExporter: lt,
|
|
1339
|
+
getXlsxOptions: () => a.value.xlsx,
|
|
1340
|
+
onError: (i, g) => {
|
|
1341
|
+
h.value = { kind: "error", message: i }, ee(i, g ?? "print");
|
|
1342
|
+
},
|
|
1343
|
+
onWarning: (i) => {
|
|
1344
|
+
h.value = { kind: "warning", message: i }, n("warning", i);
|
|
1345
|
+
},
|
|
1346
|
+
onBusy: (i) => {
|
|
1347
|
+
m.value = i, i ? h.value = {
|
|
1348
|
+
kind: "progress",
|
|
1349
|
+
message: d.value.exporting.replace("{format}", i)
|
|
1350
|
+
} : h.value?.kind === "progress" && (h.value = null);
|
|
1351
|
+
},
|
|
1352
|
+
onPrinting: (i) => {
|
|
1353
|
+
c.value = i;
|
|
1354
|
+
}
|
|
1355
|
+
}), { releasePrintFrame: Dt, dispose: Wt } = Fe;
|
|
1356
|
+
async function Ze() {
|
|
1357
|
+
p.value = null, await Fe.print();
|
|
1358
|
+
}
|
|
1359
|
+
async function Je(i) {
|
|
1360
|
+
p.value = null, await Fe.exportAs(i);
|
|
1361
|
+
}
|
|
1362
|
+
function Ge() {
|
|
1363
|
+
p.value = null, Fe.openPdfWindow();
|
|
1364
|
+
}
|
|
1365
|
+
async function ct(i, g = {}) {
|
|
1366
|
+
ue.value = { ...ue.value, ...i }, g.reload !== !1 && await ce();
|
|
1367
|
+
}
|
|
1368
|
+
yt(en, {
|
|
1369
|
+
reload: ce,
|
|
1370
|
+
print: Ze,
|
|
1371
|
+
exportAs: Je,
|
|
1372
|
+
openPdfWindow: Ge,
|
|
1373
|
+
gotoPage: ne,
|
|
1374
|
+
setParams: ct,
|
|
1375
|
+
checkPdfFont: Me,
|
|
1376
|
+
get state() {
|
|
1377
|
+
return ae.value;
|
|
1378
|
+
}
|
|
1379
|
+
});
|
|
1380
|
+
const L = dn({
|
|
1381
|
+
plan: r,
|
|
1382
|
+
gotoPage: ne,
|
|
1383
|
+
debounceMs: k(() => a.value.preview.searchDebounceMs),
|
|
1384
|
+
highlight: sn,
|
|
1385
|
+
clearHighlights: an
|
|
1386
|
+
});
|
|
1387
|
+
function Bt(i) {
|
|
1388
|
+
i.ctrlKey && (i.preventDefault(), Ye(Z.value * (i.deltaY < 0 ? 1.1 : 1 / 1.1)));
|
|
1389
|
+
}
|
|
1390
|
+
function At(i) {
|
|
1391
|
+
if ((i.ctrlKey || i.metaKey) && i.key.toLowerCase() === "f") {
|
|
1392
|
+
i.preventDefault(), L.visible.value || L.toggle();
|
|
1393
|
+
return;
|
|
1394
|
+
}
|
|
1395
|
+
switch (i.key) {
|
|
1396
|
+
case "PageDown":
|
|
1397
|
+
i.preventDefault(), ne(v.value + 1);
|
|
1398
|
+
break;
|
|
1399
|
+
case "PageUp":
|
|
1400
|
+
i.preventDefault(), ne(v.value - 1);
|
|
1401
|
+
break;
|
|
1402
|
+
case "Home":
|
|
1403
|
+
i.preventDefault(), ne(1);
|
|
1404
|
+
break;
|
|
1405
|
+
case "End":
|
|
1406
|
+
i.preventDefault(), ne(O.value);
|
|
1407
|
+
break;
|
|
1408
|
+
case "+":
|
|
1409
|
+
case "=":
|
|
1410
|
+
i.preventDefault(), Ye(Z.value * 1.1);
|
|
1411
|
+
break;
|
|
1412
|
+
case "-":
|
|
1413
|
+
i.preventDefault(), Ye(Z.value / 1.1);
|
|
1414
|
+
break;
|
|
1415
|
+
}
|
|
1416
|
+
}
|
|
1417
|
+
function Lt() {
|
|
1418
|
+
try {
|
|
1419
|
+
localStorage.setItem(
|
|
1420
|
+
C,
|
|
1421
|
+
JSON.stringify({ zoomMode: we.value === "fit" ? "fit" : Math.round(Z.value * 100) })
|
|
1422
|
+
);
|
|
1423
|
+
} catch {
|
|
1424
|
+
}
|
|
1425
|
+
}
|
|
1426
|
+
Q([we, Z], Lt);
|
|
1427
|
+
let Xe = "";
|
|
1428
|
+
function dt(i = !1) {
|
|
1429
|
+
const g = L.activeMatch.value;
|
|
1430
|
+
if (!D.value || !g) return;
|
|
1431
|
+
const w = `${L.query.value}:${L.matchIndex.value}:${g.pageIndex}`;
|
|
1432
|
+
if (!i && w === Xe) return;
|
|
1433
|
+
const V = A.value?.querySelector(`[data-page="${g.pageIndex + 1}"]`)?.querySelectorAll("mark.mrp-hit")[g.occurrence];
|
|
1434
|
+
V && (V.scrollIntoView?.({ block: "nearest", inline: "nearest" }), Xe = w);
|
|
1435
|
+
}
|
|
1436
|
+
vt(() => {
|
|
1437
|
+
const i = r.value;
|
|
1438
|
+
if (!i) return;
|
|
1439
|
+
const g = L.activeMatch.value;
|
|
1440
|
+
L.matchIndex.value, g || (Xe = ""), ut.value;
|
|
1441
|
+
const w = A.value;
|
|
1442
|
+
if (!w) return;
|
|
1443
|
+
w.querySelectorAll(".mrp-page-holder").forEach((V) => {
|
|
1444
|
+
const Re = Number(V.dataset.page ?? 0) - 1, z = i.pages[Re];
|
|
1445
|
+
if (!z || V.childElementCount > 0) {
|
|
1446
|
+
if (V.firstElementChild) {
|
|
1447
|
+
const ie = V.firstElementChild;
|
|
1448
|
+
L.clear(ie), L.apply(ie);
|
|
1449
|
+
}
|
|
1450
|
+
return;
|
|
1451
|
+
}
|
|
1452
|
+
V.style.width = `${z.pageWidthMm * Se}px`;
|
|
1453
|
+
const X = xt(z, 96, {}, document);
|
|
1454
|
+
L.apply(X), V.appendChild(X);
|
|
1455
|
+
}), dt();
|
|
1456
|
+
}, { flush: "post" }), Q(() => L.query.value, (i) => {
|
|
1457
|
+
i || A.value?.querySelectorAll(".mrp-page-holder").forEach((g) => {
|
|
1458
|
+
L.clear(g);
|
|
1459
|
+
});
|
|
1460
|
+
});
|
|
1461
|
+
const _ = pn(r, {
|
|
1462
|
+
thumbsRoot: b,
|
|
1463
|
+
visible: I,
|
|
1464
|
+
renderThumbCanvas: (i) => {
|
|
1465
|
+
try {
|
|
1466
|
+
const g = r.value.pages[i], w = Math.min(0.2, 116 / Math.max(1, g.pageWidthMm * Se)), { canvases: U } = Xt(r.value, { start: i, end: i, dpr: w });
|
|
1467
|
+
return U[0] ?? null;
|
|
1468
|
+
} catch {
|
|
1469
|
+
return null;
|
|
1470
|
+
}
|
|
1471
|
+
}
|
|
1472
|
+
});
|
|
1473
|
+
vt(() => {
|
|
1474
|
+
_.schedule();
|
|
1475
|
+
}, { flush: "post" });
|
|
1476
|
+
const zt = k(() => o.debug), { debugStats: pe } = fn(zt, {
|
|
1477
|
+
plan: r,
|
|
1478
|
+
pageCount: O,
|
|
1479
|
+
windowRange: xe,
|
|
1480
|
+
zoom: Z,
|
|
1481
|
+
loadMs: E.loadMs
|
|
1482
|
+
});
|
|
1483
|
+
function Qe() {
|
|
1484
|
+
Ke(W.value), _.schedule(), we.value === "fit" && it(), dt(!0);
|
|
1485
|
+
}
|
|
1486
|
+
function ft() {
|
|
1487
|
+
ye(C === wt ? 100 : "fit");
|
|
1488
|
+
try {
|
|
1489
|
+
const i = JSON.parse(localStorage.getItem(C) ?? "{}");
|
|
1490
|
+
i.zoomMode === "fit" ? ye("fit") : typeof i.zoomMode == "number" && ye(i.zoomMode);
|
|
1491
|
+
} catch {
|
|
1492
|
+
}
|
|
1493
|
+
}
|
|
1494
|
+
return jt(() => {
|
|
1495
|
+
window.addEventListener("resize", Qe), typeof ResizeObserver < "u" && W.value && (ke = new ResizeObserver(Qe), ke.observe(W.value)), Ke(W.value), ft(), o.autoLoad && ce();
|
|
1496
|
+
}), Ut(() => {
|
|
1497
|
+
ge = !0, Ne(), le++, te?.abort(), te = null, window.removeEventListener("resize", Qe), ke?.disconnect(), ke = null, _.destroy(), L.reset(), Wt();
|
|
1498
|
+
}), Q(
|
|
1499
|
+
() => [JSON.stringify(q.value), JSON.stringify(o.params), Y.value],
|
|
1500
|
+
() => {
|
|
1501
|
+
if (o.autoLoad) {
|
|
1502
|
+
ce();
|
|
1503
|
+
return;
|
|
1504
|
+
}
|
|
1505
|
+
le++, te?.abort(), te = null, l.value = !1, u.value = "", p.value = null, h.value = null, Ce();
|
|
1506
|
+
}
|
|
1507
|
+
), t({ reload: ce, print: Ze, exportAs: Je, openPdfWindow: Ge, gotoPage: ne, setParams: ct, checkPdfFont: Me, state: ae }), (i, g) => (P(), $("div", {
|
|
1508
|
+
class: oe(["mach-report-preview", { "mrp-wide-report": D.value }]),
|
|
1509
|
+
style: re(St.value)
|
|
1510
|
+
}, [
|
|
1511
|
+
J.value && se.value.length > 0 ? (P(), Vt(Ln, {
|
|
1512
|
+
key: 0,
|
|
1513
|
+
defs: se.value,
|
|
1514
|
+
modelValue: ue.value,
|
|
1515
|
+
"onUpdate:modelValue": g[0] || (g[0] = (w) => ue.value = w),
|
|
1516
|
+
messages: d.value,
|
|
1517
|
+
attempted: je.value,
|
|
1518
|
+
onQuery: Rt,
|
|
1519
|
+
onReset: Tt
|
|
1520
|
+
}, null, 8, ["defs", "modelValue", "messages", "attempted"])) : N("", !0),
|
|
1521
|
+
Kt(Mn, {
|
|
1522
|
+
"page-count": O.value,
|
|
1523
|
+
"current-page": v.value,
|
|
1524
|
+
"zoom-mode": x(we),
|
|
1525
|
+
zoom: x(Z),
|
|
1526
|
+
"show-export": y.value,
|
|
1527
|
+
"show-print": R.value,
|
|
1528
|
+
"show-pdf-window": T.value,
|
|
1529
|
+
messages: d.value,
|
|
1530
|
+
search: { visible: x(L).visible.value, query: x(L).query.value, matchIndex: x(L).matchIndex.value, matchCount: x(L).matchCount.value, searching: x(L).searching.value },
|
|
1531
|
+
"thumbs-visible": I.value,
|
|
1532
|
+
onGoto: ne,
|
|
1533
|
+
onZoom: x(ye),
|
|
1534
|
+
onExport: g[1] || (g[1] = (w) => Je(w)),
|
|
1535
|
+
onPrint: Ze,
|
|
1536
|
+
onPdfWindow: Ge,
|
|
1537
|
+
onSearchInput: x(L).onInput,
|
|
1538
|
+
onSearchNav: x(L).onNav,
|
|
1539
|
+
onSearchToggle: x(L).toggle,
|
|
1540
|
+
onThumbsToggle: g[2] || (g[2] = (w) => I.value = !I.value)
|
|
1541
|
+
}, null, 8, ["page-count", "current-page", "zoom-mode", "zoom", "show-export", "show-print", "show-pdf-window", "messages", "search", "thumbs-visible", "onZoom", "onSearchInput", "onSearchNav", "onSearchToggle"]),
|
|
1542
|
+
h.value ? (P(), $("div", {
|
|
1543
|
+
key: 1,
|
|
1544
|
+
class: oe(["mrp-export-notice", `mrp-export-${h.value.kind}`]),
|
|
1545
|
+
role: "alert"
|
|
1546
|
+
}, M(h.value.message), 3)) : N("", !0),
|
|
1547
|
+
f.value.status === "error" && (y.value || T.value) ? (P(), $("div", Gn, [
|
|
1548
|
+
et(M(d.value.pdfFontUnavailable) + " ", 1),
|
|
1549
|
+
F("button", {
|
|
1550
|
+
type: "button",
|
|
1551
|
+
onClick: Mt
|
|
1552
|
+
}, M(d.value.retry), 1)
|
|
1553
|
+
])) : N("", !0),
|
|
1554
|
+
F("div", Xn, [
|
|
1555
|
+
F("div", {
|
|
1556
|
+
ref_key: "viewportRef",
|
|
1557
|
+
ref: W,
|
|
1558
|
+
class: "mrp-body",
|
|
1559
|
+
tabindex: "0",
|
|
1560
|
+
onWheel: Bt,
|
|
1561
|
+
onKeydown: At,
|
|
1562
|
+
onScrollPassive: g[3] || (g[3] = (w) => x(Ot)(w.target))
|
|
1563
|
+
}, [
|
|
1564
|
+
l.value ? (P(), $("div", Qn, M(d.value.loading), 1)) : u.value ? (P(), $("div", _n, [
|
|
1565
|
+
et(M(u.value) + " ", 1),
|
|
1566
|
+
F("button", {
|
|
1567
|
+
class: "mrp-retry",
|
|
1568
|
+
type: "button",
|
|
1569
|
+
onClick: ce
|
|
1570
|
+
}, M(d.value.retry), 1)
|
|
1571
|
+
])) : !r.value || O.value === 0 ? (P(), $("div", er, M(d.value.empty), 1)) : (P(), $("div", {
|
|
1572
|
+
key: 3,
|
|
1573
|
+
class: "mrp-scale",
|
|
1574
|
+
style: re({ width: `${x(Ve).w * x(Z)}px`, height: `${x(Ve).h * x(Z)}px` })
|
|
1575
|
+
}, [
|
|
1576
|
+
F("div", {
|
|
1577
|
+
ref_key: "containerRef",
|
|
1578
|
+
ref: A,
|
|
1579
|
+
class: "mrp-scale-inner",
|
|
1580
|
+
style: re({ transform: `scale(${x(Z)})`, transformOrigin: "top left", width: `${x(Ve).w}px` })
|
|
1581
|
+
}, [
|
|
1582
|
+
x(xe).padTopPx > 0 ? (P(), $("div", {
|
|
1583
|
+
key: 0,
|
|
1584
|
+
class: "mrp-spacer-top",
|
|
1585
|
+
style: re({ height: `${x(xe).padTopPx}px` }),
|
|
1586
|
+
"aria-hidden": "true"
|
|
1587
|
+
}, null, 4)) : N("", !0),
|
|
1588
|
+
(P(!0), $(Ee, null, We(x(ut), (w) => (P(), $("div", {
|
|
1589
|
+
key: w.index,
|
|
1590
|
+
class: "mrp-page-holder",
|
|
1591
|
+
"data-page": w.index + 1
|
|
1592
|
+
}, null, 8, tr))), 128)),
|
|
1593
|
+
x(xe).padBottomPx > 0 ? (P(), $("div", {
|
|
1594
|
+
key: 1,
|
|
1595
|
+
class: "mrp-spacer-bottom",
|
|
1596
|
+
style: re({ height: `${x(xe).padBottomPx}px` }),
|
|
1597
|
+
"aria-hidden": "true"
|
|
1598
|
+
}, null, 4)) : N("", !0)
|
|
1599
|
+
], 4)
|
|
1600
|
+
], 4))
|
|
1601
|
+
], 544),
|
|
1602
|
+
I.value && O.value > 0 ? (P(), $("aside", {
|
|
1603
|
+
key: 0,
|
|
1604
|
+
ref_key: "thumbsRef",
|
|
1605
|
+
ref: b,
|
|
1606
|
+
class: "mrp-thumbs",
|
|
1607
|
+
onScrollPassive: g[4] || (g[4] = //@ts-ignore
|
|
1608
|
+
(...w) => x(_).onScroll && x(_).onScroll(...w))
|
|
1609
|
+
}, [
|
|
1610
|
+
x(_).windowRange.value.padTopPx > 0 ? (P(), $("div", {
|
|
1611
|
+
key: 0,
|
|
1612
|
+
class: "mrp-thumb-spacer",
|
|
1613
|
+
style: re({ height: `${x(_).windowRange.value.padTopPx}px` }),
|
|
1614
|
+
"aria-hidden": "true"
|
|
1615
|
+
}, null, 4)) : N("", !0),
|
|
1616
|
+
(P(!0), $(Ee, null, We(x(_).visibleThumbs.value, (w) => (P(), $("div", {
|
|
1617
|
+
key: w.index,
|
|
1618
|
+
class: oe(["mrp-thumb", { "mrp-thumb-active": w.index + 1 === v.value }]),
|
|
1619
|
+
style: re({ height: `${w.height + 20}px` }),
|
|
1620
|
+
onClick: (U) => ne(w.index + 1)
|
|
1621
|
+
}, [
|
|
1622
|
+
F("div", {
|
|
1623
|
+
class: "mrp-thumb-box",
|
|
1624
|
+
"data-thumb": w.index + 1,
|
|
1625
|
+
style: re({ height: `${w.height}px` })
|
|
1626
|
+
}, null, 12, rr),
|
|
1627
|
+
F("span", or, M(w.index + 1), 1)
|
|
1628
|
+
], 14, nr))), 128)),
|
|
1629
|
+
x(_).windowRange.value.padBottomPx > 0 ? (P(), $("div", {
|
|
1630
|
+
key: 1,
|
|
1631
|
+
class: "mrp-thumb-spacer",
|
|
1632
|
+
style: re({ height: `${x(_).windowRange.value.padBottomPx}px` }),
|
|
1633
|
+
"aria-hidden": "true"
|
|
1634
|
+
}, null, 4)) : N("", !0)
|
|
1635
|
+
], 544)) : N("", !0)
|
|
1636
|
+
]),
|
|
1637
|
+
F("div", ar, [
|
|
1638
|
+
Yt(i.$slots, "default", {}, void 0, !0)
|
|
1639
|
+
]),
|
|
1640
|
+
x(pe) ? (P(), $("div", sr, [
|
|
1641
|
+
g[5] || (g[5] = F("div", null, "mach-report debug", -1)),
|
|
1642
|
+
F("div", null, "pages: " + M(x(pe).pages) + " | window: [" + M(x(pe).window) + "]", 1),
|
|
1643
|
+
F("div", null, "zoom: " + M(x(pe).zoom) + " | load: " + M(x(pe).loadMs), 1),
|
|
1644
|
+
F("div", null, "plan: " + M(x(pe).planKB) + "KB", 1)
|
|
1645
|
+
])) : N("", !0)
|
|
1646
|
+
], 6));
|
|
1647
|
+
}
|
|
1648
|
+
}), ir = /* @__PURE__ */ st(lr, [["__scopeId", "data-v-449298a6"]]), yr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1649
|
+
__proto__: null,
|
|
1650
|
+
default: ir
|
|
1651
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
1652
|
+
export {
|
|
1653
|
+
zn as D,
|
|
1654
|
+
ve as M,
|
|
1655
|
+
_e as P,
|
|
1656
|
+
Ln as R,
|
|
1657
|
+
br as S,
|
|
1658
|
+
Hn as a,
|
|
1659
|
+
ir as b,
|
|
1660
|
+
Mn as c,
|
|
1661
|
+
$t as d,
|
|
1662
|
+
rn as e,
|
|
1663
|
+
Zn as f,
|
|
1664
|
+
vr as g,
|
|
1665
|
+
qn as h,
|
|
1666
|
+
gr as i,
|
|
1667
|
+
mr as j,
|
|
1668
|
+
wr as k,
|
|
1669
|
+
Jn as l,
|
|
1670
|
+
tn as m,
|
|
1671
|
+
Et as n,
|
|
1672
|
+
on as o,
|
|
1673
|
+
hr as p,
|
|
1674
|
+
nn as q,
|
|
1675
|
+
Nn as r,
|
|
1676
|
+
yr as s,
|
|
1677
|
+
jn as t,
|
|
1678
|
+
Un as u
|
|
1679
|
+
};
|