@agile-team/mach-report 2.6.1 → 2.7.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 +37 -4
- package/dist/ReportPreview-BdvoqdOd.cjs +6 -0
- package/dist/ReportPreview-COFkbeEM.js +3719 -0
- package/dist/{assets-NVA_sftu.js → assets-B9qJku3V.js} +54 -57
- package/dist/assets-RZan7EyL.cjs +1 -0
- package/dist/capabilities-joSutDF8.js +63 -0
- package/dist/capabilities-xGTpnPjJ.cjs +1 -0
- package/dist/designer.cjs +1 -1
- package/dist/designer.d.cts +869 -753
- package/dist/designer.d.ts +869 -753
- package/dist/designer.js +490 -234
- package/dist/index.cjs +8 -8
- package/dist/index.d.cts +86 -3
- package/dist/index.d.ts +86 -3
- package/dist/index.js +582 -508
- package/dist/pdf.cjs +30 -30
- package/dist/pdf.d.cts +11 -3
- package/dist/pdf.d.ts +11 -3
- package/dist/pdf.js +1501 -1500
- package/dist/{plugin-BqBkn_kI.cjs → plugin-9t_ZFwhz.cjs} +1 -1
- package/dist/{plugin-Ds10VnQO.js → plugin-s8Ay8kKk.js} +1 -1
- package/dist/progress-DD964VAB.js +102 -0
- package/dist/progress-KvhwXZ1Q.cjs +1 -0
- package/dist/{report-source-B9bENO0F.js → report-source-BXHNy_AD.js} +337 -332
- package/dist/report-source-CCAvFE3t.cjs +1 -0
- package/dist/server/node.d.cts +26 -3
- package/dist/server/node.d.ts +26 -3
- package/dist/server-node.cjs +1 -1
- package/dist/server-node.js +125 -92
- package/dist/server.cjs +1 -1
- package/dist/server.d.cts +28 -3
- package/dist/server.d.ts +28 -3
- package/dist/server.js +172 -164
- package/dist/style.css +1 -1
- package/dist/task-events-DQ276fn2.cjs +1 -0
- package/dist/task-events-Dpsvf_t2.js +47 -0
- package/dist/vue/async.d.cts +1507 -2083
- package/dist/vue/async.d.ts +1507 -2083
- package/dist/vue/index.d.cts +2376 -3310
- package/dist/vue/index.d.ts +2376 -3310
- package/dist/vue-async.cjs +1 -1
- package/dist/vue-async.js +3 -3
- package/dist/vue.cjs +1 -1
- package/dist/vue.js +131 -107
- package/dist/worker.cjs +1 -1
- package/dist/worker.d.cts +26 -3
- package/dist/worker.d.ts +26 -3
- package/dist/worker.js +110 -85
- package/dist/xlsx.cjs +14 -14
- package/dist/xlsx.d.cts +11 -3
- package/dist/xlsx.d.ts +11 -3
- package/dist/xlsx.js +656 -652
- package/package.json +2 -2
- package/dist/ReportPreview-Dk-28QAi.js +0 -2946
- package/dist/ReportPreview-FSvcBLjH.cjs +0 -6
- package/dist/assets-66UBlhES.cjs +0 -1
- package/dist/capabilities-CNjIirfo.js +0 -36
- package/dist/capabilities-D4xeVYSR.cjs +0 -1
- package/dist/grid-geometry-BNptEcMm.js +0 -65
- package/dist/grid-geometry-CZ_cYB6O.cjs +0 -1
- package/dist/report-source-BbNkkBDy.cjs +0 -1
|
@@ -0,0 +1,3719 @@
|
|
|
1
|
+
import { computed as A, unref as b, ref as J, onScopeDispose as Oe, watch as le, getCurrentScope as ha, shallowRef as ae, nextTick as Qe, defineComponent as xe, openBlock as I, createElementBlock as P, createElementVNode as R, toDisplayString as C, Fragment as fe, createCommentVNode as j, normalizeClass as ye, createStaticVNode as xn, createTextVNode as we, onMounted as Wt, onUnmounted as Ht, withModifiers as ut, renderSlot as Ot, renderList as pe, withDirectives as kn, vModelText as In, withKeys as At, inject as ct, provide as En, watchEffect as ba, normalizeStyle as Re, createBlock as Te, isRef as ya, createVNode as Pt, withCtx as wa } from "vue";
|
|
2
|
+
import { renderPage as Cn, renderPlanToImages as xa, ReportParamValidationError as ka, ReportSourceError as Ia, inspectOutputCapabilities as Ea, validateReportParams as $n, summarizeReportCellEdits as dn, createReportCellEditBatch as Ca, ReportCellEditError as De, createReportCellResolver as Lt, parseReportCellFieldInput as $a, applyReportEditResult as Pa, applyReportCellEditBatch as Sa, reportCellEditKey as fn, getReportCellContext as ot, validateReportCellFieldDefinition as Ra, parseReportClipboard as Ma, formatReportClipboard as Ta, resolvePlanAssets as Fa, paginateTemplate as Da, validateRenderPlan as Oa, renderPlanToCanvas as Aa } from "@agile-team/mach-report";
|
|
3
|
+
import { c as Pn } from "./page-window-index-CIuT4BAv.js";
|
|
4
|
+
import { a as Me, n as mn, w as Ke, r as Sn, f as La } from "./progress-DD964VAB.js";
|
|
5
|
+
import { i as za, b as qa } from "./render-plan-uzZYYSy1.js";
|
|
6
|
+
import { _ as ke } from "./_plugin-vue_export-helper-CHgC5LLL.js";
|
|
7
|
+
import { b as zt, c as Ba, d as ja, a as Na } from "./plugin-s8Ay8kKk.js";
|
|
8
|
+
function Rn(e) {
|
|
9
|
+
return e == null ? [] : Array.isArray(e) ? e.map(String).filter((t) => t !== "") : String(e).split(",").map((t) => t.trim()).filter((t) => t !== "");
|
|
10
|
+
}
|
|
11
|
+
function yl(e) {
|
|
12
|
+
return Rn(e).join(",");
|
|
13
|
+
}
|
|
14
|
+
class St extends Error {
|
|
15
|
+
constructor(t) {
|
|
16
|
+
super(t), this.name = "PlanLoadError";
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function wl(e = {}) {
|
|
20
|
+
const { baseUrl: t = "", headers: a, credentials: n, timeoutMs: o = 3e4 } = e, r = t.replace(/\/+$/, "");
|
|
21
|
+
return async ({ url: s, method: l, params: f, signal: p }) => {
|
|
22
|
+
let u = `${r}${s}`;
|
|
23
|
+
if (f && Object.keys(f).length > 0) {
|
|
24
|
+
const c = u.indexOf("#"), T = c >= 0 ? u.slice(c) : "", D = c >= 0 ? u.slice(0, c) : u, L = D.indexOf("?"), q = L >= 0 ? D.slice(0, L) : D, B = new URLSearchParams(L >= 0 ? D.slice(L + 1) : "");
|
|
25
|
+
for (const [U, X] of Object.entries(f)) B.set(U, X);
|
|
26
|
+
u = `${q}?${B}${T}`;
|
|
27
|
+
}
|
|
28
|
+
const i = (c, T) => {
|
|
29
|
+
const D = new St(c);
|
|
30
|
+
return Object.defineProperty(D, "cause", { value: T, configurable: !0, writable: !0 }), D;
|
|
31
|
+
};
|
|
32
|
+
if (p?.aborted)
|
|
33
|
+
throw i(`请求已取消: ${s}`, p.reason);
|
|
34
|
+
const m = new AbortController();
|
|
35
|
+
let g;
|
|
36
|
+
const y = () => {
|
|
37
|
+
m.signal.aborted || (g = "external", m.abort(p?.reason));
|
|
38
|
+
};
|
|
39
|
+
p?.addEventListener("abort", y, { once: !0 });
|
|
40
|
+
const v = setTimeout(() => {
|
|
41
|
+
m.signal.aborted || (g = "timeout", m.abort());
|
|
42
|
+
}, o);
|
|
43
|
+
try {
|
|
44
|
+
const c = await fetch(u, {
|
|
45
|
+
method: l.toUpperCase(),
|
|
46
|
+
headers: { Accept: "application/json", ...a },
|
|
47
|
+
credentials: n,
|
|
48
|
+
signal: m.signal
|
|
49
|
+
});
|
|
50
|
+
if (!c.ok)
|
|
51
|
+
throw new St(`HTTP ${c.status} ${s}`);
|
|
52
|
+
return await c.json();
|
|
53
|
+
} catch (c) {
|
|
54
|
+
throw g === "timeout" ? i(`请求超时(${o}ms): ${s}`, c) : g === "external" ? i(`请求已取消: ${s}`, c) : c instanceof St ? c : i(`请求失败(${s}): ${c instanceof Error ? c.message : String(c)}`, c);
|
|
55
|
+
} finally {
|
|
56
|
+
clearTimeout(v), p?.removeEventListener("abort", y);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function Wa(e, t, a = {}) {
|
|
61
|
+
const n = a.pxPerMm ?? 3.7795275590551185, o = A(() => Math.max(0, b(a.gapPx) ?? 18)), r = J(0), s = J(800), l = A(() => {
|
|
62
|
+
const c = e.value?.pages ?? [];
|
|
63
|
+
return Pn(c.map((T) => T.pageHeightMm * n), o.value);
|
|
64
|
+
}), f = A(() => {
|
|
65
|
+
let c = 0;
|
|
66
|
+
for (const T of e.value?.pages ?? []) c = Math.max(c, T.pageWidthMm * n);
|
|
67
|
+
return { w: c, h: l.value.totalHeightPx };
|
|
68
|
+
}), p = A(() => l.value.window(
|
|
69
|
+
s.value / t.value,
|
|
70
|
+
r.value / t.value,
|
|
71
|
+
b(a.overscan) ?? 1
|
|
72
|
+
)), u = A(() => {
|
|
73
|
+
const c = e.value;
|
|
74
|
+
if (!c) return [];
|
|
75
|
+
const { start: T, end: D } = p.value;
|
|
76
|
+
return c.pages.slice(T, D + 1).map((L, q) => ({ page: L, index: T + q }));
|
|
77
|
+
});
|
|
78
|
+
let i = 0, m = !1;
|
|
79
|
+
function g(c) {
|
|
80
|
+
c && (r.value = c.scrollTop, s.value = c.clientHeight || 800);
|
|
81
|
+
}
|
|
82
|
+
function y(c, T) {
|
|
83
|
+
return (D) => {
|
|
84
|
+
i || m || (i = requestAnimationFrame(() => {
|
|
85
|
+
if (i = 0, m || (g(D), T.value <= 0)) return;
|
|
86
|
+
const L = Math.max(0, D.scrollTop + 32) / t.value;
|
|
87
|
+
c.value = Math.min(T.value, l.value.pageAt(L) + 1);
|
|
88
|
+
}));
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
function v() {
|
|
92
|
+
m = !0, i && cancelAnimationFrame(i), i = 0;
|
|
93
|
+
}
|
|
94
|
+
return Oe(v), {
|
|
95
|
+
contentSize: f,
|
|
96
|
+
windowRange: p,
|
|
97
|
+
visiblePages: u,
|
|
98
|
+
makeScrollHandler: y,
|
|
99
|
+
refreshViewport: g,
|
|
100
|
+
pageOffsetPx: (c) => l.value.offsetAt(c),
|
|
101
|
+
destroy: v
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
const pn = 96 / 25.4;
|
|
105
|
+
function Ha(e) {
|
|
106
|
+
const t = /* @__PURE__ */ new WeakMap(), a = J(0);
|
|
107
|
+
let n, o = 0, r = 0, s = !1;
|
|
108
|
+
function l() {
|
|
109
|
+
o++, r && cancelAnimationFrame(r), r = 0;
|
|
110
|
+
}
|
|
111
|
+
function f(v, c, T, D) {
|
|
112
|
+
return !s && c === o && e.plan.value === T && e.root.value === D && D.contains(v.holder) && Number(v.holder.dataset.page) === v.index + 1;
|
|
113
|
+
}
|
|
114
|
+
function p(v) {
|
|
115
|
+
const { holder: c, page: T } = v;
|
|
116
|
+
t.delete(c), c.style.width = `${T.pageWidthMm * pn}px`, c.style.height = `${T.pageHeightMm * pn}px`, c.setAttribute("aria-busy", "true");
|
|
117
|
+
const D = c.ownerDocument.createElement("div");
|
|
118
|
+
D.className = "mrp-page-loading";
|
|
119
|
+
const L = c.ownerDocument.createElement("span");
|
|
120
|
+
L.textContent = e.loading(), L.style.transform = `scale(${1 / Math.max(1e-4, e.zoom())})`, D.append(L), c.replaceChildren(D);
|
|
121
|
+
}
|
|
122
|
+
function u(v) {
|
|
123
|
+
const c = t.get(v.holder);
|
|
124
|
+
return !c || c.page !== v.page || c.element.parentElement !== v.holder ? !1 : (c.query !== e.query() && (e.clear(c.element), e.highlight(c.element), c.query = e.query()), !0);
|
|
125
|
+
}
|
|
126
|
+
function i(v, c, T, D) {
|
|
127
|
+
if (f(v, c, T, D))
|
|
128
|
+
try {
|
|
129
|
+
const L = Cn(v.page, 96, {}, v.holder.ownerDocument);
|
|
130
|
+
if (e.highlight(L), !f(v, c, T, D)) return;
|
|
131
|
+
v.holder.replaceChildren(L), v.holder.removeAttribute("aria-busy"), t.set(v.holder, { page: v.page, element: L, query: e.query() }), e.mounted(v.holder), e.ready();
|
|
132
|
+
} catch (L) {
|
|
133
|
+
if (!f(v, c, T, D)) return;
|
|
134
|
+
v.holder.removeAttribute("aria-busy");
|
|
135
|
+
const q = v.holder.ownerDocument.createElement("div");
|
|
136
|
+
q.className = "mrp-page-render-error", q.setAttribute("role", "alert"), q.textContent = L instanceof Error ? L.message : String(L), v.holder.replaceChildren(q), e.error(L);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
function m(v, c, T, D) {
|
|
140
|
+
v.length && (r = requestAnimationFrame(() => {
|
|
141
|
+
if (c !== o || s) return;
|
|
142
|
+
r = 0;
|
|
143
|
+
const L = v.shift();
|
|
144
|
+
L && i(L, c, T, D), c === o && e.plan.value === T && e.root.value === D && m(v, c, T, D);
|
|
145
|
+
}));
|
|
146
|
+
}
|
|
147
|
+
function g() {
|
|
148
|
+
l();
|
|
149
|
+
const v = e.plan.value, c = e.root.value;
|
|
150
|
+
if (s || !v || !c) {
|
|
151
|
+
n = void 0;
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
const T = o, D = n?.plan === v ? n.index : e.priority();
|
|
155
|
+
n = void 0;
|
|
156
|
+
const L = [];
|
|
157
|
+
c.querySelectorAll(".mrp-page-holder").forEach((U) => {
|
|
158
|
+
const X = Number(U.dataset.page) - 1, G = v.pages[X];
|
|
159
|
+
if (!G) return;
|
|
160
|
+
const Q = { holder: U, page: G, index: X };
|
|
161
|
+
u(Q) || (p(Q), L.push(Q));
|
|
162
|
+
});
|
|
163
|
+
const q = L.findIndex((U) => U.index === D), B = q < 0 ? void 0 : L.splice(q, 1)[0];
|
|
164
|
+
B && i(B, T, v, c), e.ready(), m(L, T, v, c);
|
|
165
|
+
}
|
|
166
|
+
function y(v) {
|
|
167
|
+
s || !e.plan.value || (n = { plan: e.plan.value, index: v }, a.value++);
|
|
168
|
+
}
|
|
169
|
+
return le([e.plan, e.root, e.pages, e.priority, e.focusToken, e.query, e.zoom, e.loading, a], g, { flush: "post", immediate: !0 }), Oe(() => {
|
|
170
|
+
s = !0, n = void 0, l();
|
|
171
|
+
}), { prioritize: y, cancel: l };
|
|
172
|
+
}
|
|
173
|
+
function Ka(e) {
|
|
174
|
+
const t = J(1), a = J("fit");
|
|
175
|
+
let n = 0;
|
|
176
|
+
function o() {
|
|
177
|
+
n && cancelAnimationFrame(n), n = 0;
|
|
178
|
+
}
|
|
179
|
+
function r() {
|
|
180
|
+
o(), n = requestAnimationFrame(() => {
|
|
181
|
+
if (n = 0, a.value !== "fit") return;
|
|
182
|
+
const l = e();
|
|
183
|
+
!l?.viewport || l.viewport.clientWidth <= 48 || !Number.isFinite(l.pageWidthPx) || (t.value = Math.min(1, (l.viewport.clientWidth - 48) / Math.max(1, l.pageWidthPx)));
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
function s(l) {
|
|
187
|
+
if (l === "fit")
|
|
188
|
+
a.value = "fit", r();
|
|
189
|
+
else {
|
|
190
|
+
if (!Number.isFinite(l)) return;
|
|
191
|
+
o(), a.value = "raw", t.value = Math.min(3, Math.max(0.3, l / 100));
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
return ha() && Oe(o), { zoom: t, zoomMode: a, applyFitZoom: r, setZoom: s };
|
|
195
|
+
}
|
|
196
|
+
let Ua = 0;
|
|
197
|
+
function gn(e, t) {
|
|
198
|
+
const a = new AbortController();
|
|
199
|
+
let n = { taskId: `mr-output-${Date.now().toString(36)}-${++Ua}`, kind: e, stage: e === "print" ? "print" : "encode", status: "running", cancellable: !0 };
|
|
200
|
+
function o() {
|
|
201
|
+
try {
|
|
202
|
+
t?.(Object.freeze({ ...n }));
|
|
203
|
+
} catch {
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
return {
|
|
207
|
+
controller: a,
|
|
208
|
+
get task() {
|
|
209
|
+
return n;
|
|
210
|
+
},
|
|
211
|
+
start: o,
|
|
212
|
+
update(r, s, l) {
|
|
213
|
+
a.signal.aborted || n.status !== "running" || (n = { ...n, stage: r, completed: s, total: l }, o());
|
|
214
|
+
},
|
|
215
|
+
finish(r = "completed") {
|
|
216
|
+
n.status === "running" && (n = { ...n, status: r, cancellable: !1 }, o(), r === "cancelled" && a.abort());
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
const He = 8;
|
|
221
|
+
function Xe() {
|
|
222
|
+
return new Promise((e) => setTimeout(e, 0));
|
|
223
|
+
}
|
|
224
|
+
function st(e) {
|
|
225
|
+
return `p${e.pageWidthMm}x${e.pageHeightMm}`.replace(/[.+]/g, "_");
|
|
226
|
+
}
|
|
227
|
+
function dt(e) {
|
|
228
|
+
const t = /* @__PURE__ */ new Map();
|
|
229
|
+
return e.pages.forEach((o) => {
|
|
230
|
+
t.has(st(o)) || t.set(st(o), o);
|
|
231
|
+
}), `<!doctype html><html><head><meta charset="utf-8"><style>${`.mr-page{margin:0 auto;page-break-after:always;}
|
|
232
|
+
.mr-page tr{break-inside:avoid;page-break-inside:avoid;}
|
|
233
|
+
.mr-comp{break-inside:avoid;page-break-inside:avoid;}
|
|
234
|
+
${[...t.values()].map(
|
|
235
|
+
(o) => `@page ${st(o)}{size:${o.pageWidthMm}mm ${o.pageHeightMm}mm;margin:0;}`
|
|
236
|
+
).join(`
|
|
237
|
+
`)}
|
|
238
|
+
body{margin:0;background:#fff;}`}</style></head><body>`;
|
|
239
|
+
}
|
|
240
|
+
function ft(e) {
|
|
241
|
+
const t = Cn(e, 96, {}, document);
|
|
242
|
+
return t.style.page = st(e), t.outerHTML;
|
|
243
|
+
}
|
|
244
|
+
function Va(e) {
|
|
245
|
+
return { head: dt(e), pageChunks: e.pages.map(ft) };
|
|
246
|
+
}
|
|
247
|
+
async function xl(e, t = {}) {
|
|
248
|
+
const a = {
|
|
249
|
+
schemaVersion: "mach-report-batch-print",
|
|
250
|
+
pages: e.flatMap((s) => s.pages)
|
|
251
|
+
};
|
|
252
|
+
if (a.pages.length === 0) return;
|
|
253
|
+
const n = dt(a), o = document.createElement("iframe");
|
|
254
|
+
o.style.cssText = "position:fixed;right:0;bottom:0;width:0;height:0;border:0;visibility:hidden;", document.body.appendChild(o);
|
|
255
|
+
let r = !1;
|
|
256
|
+
try {
|
|
257
|
+
const s = o.contentDocument;
|
|
258
|
+
s.open(), s.write(n);
|
|
259
|
+
for (let l = 0; l < a.pages.length; l++)
|
|
260
|
+
Me(t.signal), s.write(ft(a.pages[l])), l % He === He - 1 && (mn(t, l + 1, a.pages.length), await Xe());
|
|
261
|
+
s.write("</body></html>"), s.close(), await Xe(), mn(t, a.pages.length, a.pages.length), r = !0, o.contentWindow?.focus(), o.contentWindow?.print();
|
|
262
|
+
} catch (s) {
|
|
263
|
+
if (t.signal?.aborted) throw s;
|
|
264
|
+
t.onError?.(s instanceof Error ? `批量打印失败: ${s.message}` : "批量打印失败");
|
|
265
|
+
} finally {
|
|
266
|
+
r ? setTimeout(() => o.remove(), 6e4) : o.remove();
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
function Mn(e) {
|
|
270
|
+
return `<!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]-->${e.replace(/^<!doctype html><html><head>/, "")}`;
|
|
271
|
+
}
|
|
272
|
+
function kl(e) {
|
|
273
|
+
const { head: t, pageChunks: a } = Va(e);
|
|
274
|
+
return {
|
|
275
|
+
html: `${Mn(t)}${a.join("")}</body></html>`,
|
|
276
|
+
filename: "mach-report.doc"
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
function Ga(e, t) {
|
|
280
|
+
let a = null, n = !1, o = !1, r = 0;
|
|
281
|
+
const s = /* @__PURE__ */ new Map();
|
|
282
|
+
let l = null;
|
|
283
|
+
const f = /* @__PURE__ */ new Map();
|
|
284
|
+
let p = null, u = null, i = null, m = null, g = null;
|
|
285
|
+
function y(w, S) {
|
|
286
|
+
return !o && e.value === w && r === S;
|
|
287
|
+
}
|
|
288
|
+
function v() {
|
|
289
|
+
if (o) return;
|
|
290
|
+
const w = [...s.values()].reverse().find((S) => y(S.plan, S.epoch))?.format ?? null;
|
|
291
|
+
w !== p && (p = w, t.onBusy?.(w));
|
|
292
|
+
}
|
|
293
|
+
function c(w, S, x) {
|
|
294
|
+
const K = {};
|
|
295
|
+
return s.set(K, { plan: w, epoch: S, format: x, run: gn("export", t.onTask) }), s.get(K).run.start(), v(), K;
|
|
296
|
+
}
|
|
297
|
+
function T(w) {
|
|
298
|
+
s.get(w)?.run.finish(), s.delete(w), v();
|
|
299
|
+
}
|
|
300
|
+
function D() {
|
|
301
|
+
for (const [w, S] of f)
|
|
302
|
+
y(S.plan, S.epoch) || (w.close(), f.delete(w));
|
|
303
|
+
}
|
|
304
|
+
function L() {
|
|
305
|
+
for (const w of s.values()) w.run.finish("cancelled");
|
|
306
|
+
l?.finish("cancelled"), r++, B(), v(), D();
|
|
307
|
+
}
|
|
308
|
+
const q = le(e, L, { flush: "sync" });
|
|
309
|
+
function B() {
|
|
310
|
+
a?.remove(), a = null;
|
|
311
|
+
}
|
|
312
|
+
function U() {
|
|
313
|
+
L(), o = !0, r++, q(), B(), D(), s.clear(), t.onPrinting?.(!1);
|
|
314
|
+
}
|
|
315
|
+
function X(w, S) {
|
|
316
|
+
const x = URL.createObjectURL(w);
|
|
317
|
+
setTimeout(() => URL.revokeObjectURL(x), 1e4);
|
|
318
|
+
const K = document.createElement("a");
|
|
319
|
+
K.href = x, K.download = S, K.click();
|
|
320
|
+
}
|
|
321
|
+
function G(w, S, x, K, Y) {
|
|
322
|
+
x.update("download"), y(w, S) && !x.controller.signal.aborted && X(K, Y);
|
|
323
|
+
}
|
|
324
|
+
async function Q(w, S, x, K) {
|
|
325
|
+
const Y = w.contentDocument;
|
|
326
|
+
Y.open(), Y.write(dt(S));
|
|
327
|
+
for (let _ = 0; _ < S.pages.length; _++)
|
|
328
|
+
if (K.controller.signal.aborted || (Y.write(ft(S.pages[_])), K.update("print", _ + 1, S.pages.length), _ % He === He - 1 && await Xe(), w !== a)) return !1;
|
|
329
|
+
return Y.write("</body></html>"), Y.close(), await Xe(), !(!y(S, x) || w !== a);
|
|
330
|
+
}
|
|
331
|
+
async function h() {
|
|
332
|
+
if (n) return;
|
|
333
|
+
const w = e.value;
|
|
334
|
+
if (o || !w || w.pages.length === 0) return;
|
|
335
|
+
const S = r;
|
|
336
|
+
n = !0;
|
|
337
|
+
const x = gn("print", t.onTask);
|
|
338
|
+
l = x, x.start(), t.onPrinting?.(!0), B(), a = document.createElement("iframe"), a.style.cssText = "position:fixed;right:0;bottom:0;width:0;height:0;border:0;visibility:hidden;", document.body.appendChild(a);
|
|
339
|
+
const K = a;
|
|
340
|
+
try {
|
|
341
|
+
if (!y(w, S) || x.controller.signal.aborted) {
|
|
342
|
+
B();
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
if (!await Q(K, w, S, x)) return;
|
|
346
|
+
K.contentWindow?.focus(), K.contentWindow?.print();
|
|
347
|
+
} catch {
|
|
348
|
+
x.finish("failed"), K === a && B(), y(w, S) && t.onError("调用打印失败,请改用导出 PDF", "print");
|
|
349
|
+
} finally {
|
|
350
|
+
x.finish(), l === x && (l = null), n = !1, o || t.onPrinting?.(!1);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
function M(w, S, x) {
|
|
354
|
+
return {
|
|
355
|
+
signal: x.controller.signal,
|
|
356
|
+
onDiagnostic: (K) => {
|
|
357
|
+
y(w, S) && !x.controller.signal.aborted && t.onDiagnostic?.(K);
|
|
358
|
+
},
|
|
359
|
+
onProgress: (K, Y) => x.update("encode", K, Y)
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
function $(w, S, x) {
|
|
363
|
+
if (u?.plan === w && u.epoch === S) return u.promise;
|
|
364
|
+
const K = Promise.resolve().then(() => {
|
|
365
|
+
if (!y(w, S)) throw new Error("报表已切换或卸载");
|
|
366
|
+
return Ke(t.getPdfExporter()(w, (Y) => {
|
|
367
|
+
y(w, S) && t.onWarning?.(Y);
|
|
368
|
+
}, x ? M(w, S, x) : void 0), x?.controller.signal);
|
|
369
|
+
}).finally(() => {
|
|
370
|
+
u?.promise === K && (u = null);
|
|
371
|
+
});
|
|
372
|
+
return u = { plan: w, epoch: S, promise: K }, K;
|
|
373
|
+
}
|
|
374
|
+
async function k() {
|
|
375
|
+
const w = e.value;
|
|
376
|
+
if (o || !w || w.pages.length === 0) return;
|
|
377
|
+
const S = r;
|
|
378
|
+
if (i?.plan === w && i.epoch === S) return i.promise;
|
|
379
|
+
const x = c(w, S, "PDF"), K = (async () => {
|
|
380
|
+
try {
|
|
381
|
+
const Y = s.get(x).run, _ = await $(w, S, Y);
|
|
382
|
+
if (!y(w, S)) return;
|
|
383
|
+
G(w, S, Y, new Blob([_], { type: "application/pdf" }), "mach-report.pdf");
|
|
384
|
+
} catch (Y) {
|
|
385
|
+
s.get(x)?.run.finish("failed"), y(w, S) && t.onError(Y instanceof Error ? `PDF 导出失败: ${Y.message}` : "PDF 导出失败", "pdf");
|
|
386
|
+
} finally {
|
|
387
|
+
T(x), i?.token === x && (i = null);
|
|
388
|
+
}
|
|
389
|
+
})();
|
|
390
|
+
return i = { plan: w, epoch: S, promise: K, token: x }, K;
|
|
391
|
+
}
|
|
392
|
+
async function F() {
|
|
393
|
+
const w = e.value;
|
|
394
|
+
if (o || !w || w.pages.length === 0) return;
|
|
395
|
+
const S = r;
|
|
396
|
+
if (m?.plan === w && m.epoch === S) return m.promise;
|
|
397
|
+
const x = { ...t.getXlsxOptions?.() }, K = c(w, S, "Excel"), Y = (async () => {
|
|
398
|
+
try {
|
|
399
|
+
const { renderPlanToXlsx: _ } = await import("@agile-team/mach-report/xlsx");
|
|
400
|
+
if (!y(w, S)) return;
|
|
401
|
+
const ie = s.get(K).run, { buffer: ce, warnings: Pe } = await Ke(_(w, { ...x, ...M(w, S, ie) }), ie.controller.signal);
|
|
402
|
+
if (!y(w, S) || (Pe.length > 0 && t.onWarning?.(`Excel 导出有 ${Pe.length} 条提示:${Pe.slice(0, 2).join(";")}`), !y(w, S))) return;
|
|
403
|
+
G(w, S, ie, new Blob([ce], {
|
|
404
|
+
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
|
405
|
+
}), "mach-report.xlsx");
|
|
406
|
+
} catch (_) {
|
|
407
|
+
s.get(K)?.run.finish("failed"), y(w, S) && t.onError(_ instanceof Error ? `Excel 导出失败: ${_.message}` : "Excel 导出失败", "export");
|
|
408
|
+
} finally {
|
|
409
|
+
T(K), m?.token === K && (m = null);
|
|
410
|
+
}
|
|
411
|
+
})();
|
|
412
|
+
return m = { plan: w, epoch: S, promise: Y, token: K }, Y;
|
|
413
|
+
}
|
|
414
|
+
async function z() {
|
|
415
|
+
const w = e.value;
|
|
416
|
+
if (o || !w || w.pages.length === 0) return;
|
|
417
|
+
const S = r;
|
|
418
|
+
if (g?.plan === w && g.epoch === S) return g.promise;
|
|
419
|
+
const x = c(w, S, "图片"), K = (async () => {
|
|
420
|
+
try {
|
|
421
|
+
const Y = s.get(x).run, { blobs: _ } = await Ke(xa(w, {
|
|
422
|
+
...M(w, S, Y),
|
|
423
|
+
dpr: Math.min(2, typeof devicePixelRatio == "number" ? devicePixelRatio : 1)
|
|
424
|
+
}), Y.controller.signal);
|
|
425
|
+
if (!y(w, S)) return;
|
|
426
|
+
_.forEach((ie, ce) => {
|
|
427
|
+
G(w, S, Y, ie, _.length > 1 ? `mach-report-page-${ce + 1}.png` : "mach-report.png");
|
|
428
|
+
});
|
|
429
|
+
} catch (Y) {
|
|
430
|
+
s.get(x)?.run.finish("failed"), y(w, S) && t.onError(
|
|
431
|
+
Y instanceof Error ? `图片导出失败: ${Y.message}` : "图片导出失败",
|
|
432
|
+
"export"
|
|
433
|
+
);
|
|
434
|
+
} finally {
|
|
435
|
+
T(x), g?.token === x && (g = null);
|
|
436
|
+
}
|
|
437
|
+
})();
|
|
438
|
+
return g = { plan: w, epoch: S, promise: K, token: x }, K;
|
|
439
|
+
}
|
|
440
|
+
async function N(w) {
|
|
441
|
+
const S = e.value;
|
|
442
|
+
if (o || !S || !S.pages.length) return;
|
|
443
|
+
const x = r, K = c(S, x, w === "word" ? "Word" : "HTML"), Y = s.get(K).run;
|
|
444
|
+
try {
|
|
445
|
+
const _ = [];
|
|
446
|
+
for (const [Pe, _e] of S.pages.entries()) {
|
|
447
|
+
if (!y(S, x)) return;
|
|
448
|
+
_.push(ft(_e)), Y.update("encode", Pe + 1, S.pages.length), Pe % He === He - 1 && await Xe();
|
|
449
|
+
}
|
|
450
|
+
if (!y(S, x)) return;
|
|
451
|
+
const ie = dt(S), ce = `${w === "word" ? Mn(ie) : ie}${_.join("")}</body></html>`;
|
|
452
|
+
G(S, x, Y, new Blob([ce], { type: w === "word" ? "application/msword;charset=utf-8" : "text/html;charset=utf-8" }), w === "word" ? "mach-report.doc" : "mach-report.html");
|
|
453
|
+
} catch (_) {
|
|
454
|
+
Y.finish("failed"), y(S, x) && t.onError(_ instanceof Error ? `导出失败: ${_.message}` : "导出失败", "export");
|
|
455
|
+
} finally {
|
|
456
|
+
T(K);
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
async function Z() {
|
|
460
|
+
await N("word");
|
|
461
|
+
}
|
|
462
|
+
async function H(w) {
|
|
463
|
+
const S = e.value;
|
|
464
|
+
if (!(o || !S || S.pages.length === 0)) {
|
|
465
|
+
if (w === "pdf") {
|
|
466
|
+
await k();
|
|
467
|
+
return;
|
|
468
|
+
}
|
|
469
|
+
if (w === "xlsx" || w === "excel") {
|
|
470
|
+
await F();
|
|
471
|
+
return;
|
|
472
|
+
}
|
|
473
|
+
if (w === "png" || w === "image") {
|
|
474
|
+
await z();
|
|
475
|
+
return;
|
|
476
|
+
}
|
|
477
|
+
if (w === "word" || w === "doc") {
|
|
478
|
+
await Z();
|
|
479
|
+
return;
|
|
480
|
+
}
|
|
481
|
+
if (w !== "html") {
|
|
482
|
+
t.onError(`不支持的导出格式:${w}`, "export");
|
|
483
|
+
return;
|
|
484
|
+
}
|
|
485
|
+
await N("html");
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
function V() {
|
|
489
|
+
const w = e.value;
|
|
490
|
+
if (o || !w || w.pages.length === 0) return;
|
|
491
|
+
const S = r, x = window.open("", "_blank");
|
|
492
|
+
if (!x) {
|
|
493
|
+
t.onError("浏览器拦截了弹窗,请允许弹窗后重试", "pdf");
|
|
494
|
+
return;
|
|
495
|
+
}
|
|
496
|
+
f.set(x, { plan: w, epoch: S });
|
|
497
|
+
const K = c(w, S, "PDF");
|
|
498
|
+
$(w, S, s.get(K).run).then((Y) => {
|
|
499
|
+
if (!y(w, S) || x.closed) {
|
|
500
|
+
f.delete(x) && x.close();
|
|
501
|
+
return;
|
|
502
|
+
}
|
|
503
|
+
const _ = URL.createObjectURL(new Blob([Y], { type: "application/pdf" }));
|
|
504
|
+
setTimeout(() => URL.revokeObjectURL(_), 6e4);
|
|
505
|
+
const ie = x.document;
|
|
506
|
+
ie.title = "PDF 预览", ie.documentElement.style.height = "100%", ie.body.style.cssText = "margin:0;height:100%;";
|
|
507
|
+
const ce = ie.createElement("iframe");
|
|
508
|
+
ce.title = "PDF 预览", ce.style.cssText = "display:block;width:100%;height:100%;border:0;", ce.src = _, ie.body.replaceChildren(ce), f.delete(x);
|
|
509
|
+
}).catch((Y) => {
|
|
510
|
+
s.get(K)?.run.finish("failed"), x.close(), f.delete(x), y(w, S) && t.onError(Y instanceof Error ? `PDF 预览失败: ${Y.message}` : "PDF 预览失败", "pdf");
|
|
511
|
+
}).finally(() => T(K));
|
|
512
|
+
}
|
|
513
|
+
return {
|
|
514
|
+
print: h,
|
|
515
|
+
exportAs: H,
|
|
516
|
+
exportImages: z,
|
|
517
|
+
exportWord: Z,
|
|
518
|
+
openPdfWindow: V,
|
|
519
|
+
invalidatePending: L,
|
|
520
|
+
cancel: L,
|
|
521
|
+
releasePrintFrame: B,
|
|
522
|
+
dispose: U
|
|
523
|
+
};
|
|
524
|
+
}
|
|
525
|
+
const Tn = "mrp-hit";
|
|
526
|
+
function Ja(e) {
|
|
527
|
+
e.querySelectorAll(`mark.${Tn}`).forEach((a) => {
|
|
528
|
+
const n = a.parentNode;
|
|
529
|
+
if (n) {
|
|
530
|
+
for (; a.firstChild; ) n.insertBefore(a.firstChild, a);
|
|
531
|
+
a.remove(), n.normalize();
|
|
532
|
+
}
|
|
533
|
+
});
|
|
534
|
+
}
|
|
535
|
+
function Za(e, t) {
|
|
536
|
+
const a = t.trim();
|
|
537
|
+
if (!a) return 0;
|
|
538
|
+
const n = a.toLowerCase(), o = document.createTreeWalker(e, NodeFilter.SHOW_TEXT, {
|
|
539
|
+
acceptNode(l) {
|
|
540
|
+
const f = l.parentElement;
|
|
541
|
+
return !f || f.closest("mark") || /^(SCRIPT|STYLE)$/.test(f.tagName) ? NodeFilter.FILTER_REJECT : (l.nodeValue ?? "").toLowerCase().includes(n) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT;
|
|
542
|
+
}
|
|
543
|
+
}), r = [];
|
|
544
|
+
for (let l = o.nextNode(); l; l = o.nextNode()) r.push(l);
|
|
545
|
+
let s = 0;
|
|
546
|
+
for (const l of r) {
|
|
547
|
+
const f = l.nodeValue ?? "", p = f.toLowerCase(), u = l.parentElement;
|
|
548
|
+
if (!u) continue;
|
|
549
|
+
const i = document.createDocumentFragment();
|
|
550
|
+
let m = 0, g = p.indexOf(n);
|
|
551
|
+
for (; g >= 0; ) {
|
|
552
|
+
g > m && i.appendChild(document.createTextNode(f.slice(m, g)));
|
|
553
|
+
const y = document.createElement("mark");
|
|
554
|
+
y.className = Tn, y.textContent = f.slice(g, g + a.length), i.appendChild(y), s++, m = g + a.length, g = p.indexOf(n, m);
|
|
555
|
+
}
|
|
556
|
+
m < f.length && i.appendChild(document.createTextNode(f.slice(m))), u.replaceChild(i, l);
|
|
557
|
+
}
|
|
558
|
+
return s;
|
|
559
|
+
}
|
|
560
|
+
const Ya = /* @__PURE__ */ new Set(["line", "rect", "ellipse", "chart"]);
|
|
561
|
+
function* Xa(e) {
|
|
562
|
+
for (const t of e.cells ?? [])
|
|
563
|
+
for (const a of t ?? [])
|
|
564
|
+
yield a?.text ?? "", yield* a?.children ?? [];
|
|
565
|
+
}
|
|
566
|
+
function* Qa(e) {
|
|
567
|
+
if (qa(e))
|
|
568
|
+
for (const t of e.richParagraphs)
|
|
569
|
+
for (const a of t.segments ?? [])
|
|
570
|
+
yield (a.kind === "field" ? a.field : a.text) ?? "";
|
|
571
|
+
else e.lines?.length ? yield* e.lines : yield e.text ?? "";
|
|
572
|
+
}
|
|
573
|
+
function* _a(e) {
|
|
574
|
+
const t = [e.values()];
|
|
575
|
+
for (; t.length > 0; ) {
|
|
576
|
+
const a = t[t.length - 1].next();
|
|
577
|
+
if (a.done) {
|
|
578
|
+
t.pop();
|
|
579
|
+
continue;
|
|
580
|
+
}
|
|
581
|
+
const n = a.value;
|
|
582
|
+
if (typeof n == "string") {
|
|
583
|
+
yield n;
|
|
584
|
+
continue;
|
|
585
|
+
}
|
|
586
|
+
yield "", !za(n) && (n.kind === "text" ? t.push(Qa(n)) : n.grid ? t.push(Xa(n.grid)) : Ya.has(n.kind) || (yield n.fallbackText ?? ""));
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
function* er(e) {
|
|
590
|
+
for (let t = 0; t < e.pages.length; t++) {
|
|
591
|
+
for (const a of _a(e.pages[t].components)) yield { text: a, pageIndex: t };
|
|
592
|
+
yield { text: "", pageIndex: t };
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
function tr(e, t) {
|
|
596
|
+
const a = e.toLowerCase();
|
|
597
|
+
let n = 0;
|
|
598
|
+
for (let o = a.indexOf(t); o >= 0; o = a.indexOf(t, o + t.length)) n++;
|
|
599
|
+
return n;
|
|
600
|
+
}
|
|
601
|
+
function nr(e) {
|
|
602
|
+
const { plan: t, gotoPage: a, highlight: n, clearHighlights: o } = e, r = J(!1), s = J(""), l = J(0), f = J(0), p = J(!1);
|
|
603
|
+
let u = [];
|
|
604
|
+
const i = A(() => {
|
|
605
|
+
if (f.value === 0) return null;
|
|
606
|
+
const q = l.value;
|
|
607
|
+
let B = 0, U = u.length - 1;
|
|
608
|
+
for (; B < U; ) {
|
|
609
|
+
const G = B + U >>> 1;
|
|
610
|
+
u[G].cumulative <= q ? B = G + 1 : U = G;
|
|
611
|
+
}
|
|
612
|
+
const X = u[B];
|
|
613
|
+
return X ? { pageIndex: X.pageIndex, occurrence: q - (u[B - 1]?.cumulative ?? 0) } : null;
|
|
614
|
+
});
|
|
615
|
+
let m = null, g = null, y = 0;
|
|
616
|
+
function v() {
|
|
617
|
+
y++, m && clearTimeout(m), g && clearTimeout(g), m = g = null, p.value = !1;
|
|
618
|
+
}
|
|
619
|
+
function c(q) {
|
|
620
|
+
s.value = q, l.value = 0, f.value = 0, u = [], p.value = !1;
|
|
621
|
+
const B = q.trim().toLowerCase(), U = t.value;
|
|
622
|
+
if (!B || !U) return;
|
|
623
|
+
p.value = !0;
|
|
624
|
+
const X = y, G = er(U), Q = [];
|
|
625
|
+
let h = 0;
|
|
626
|
+
function M() {
|
|
627
|
+
if (g = null, X !== y || U !== t.value) return;
|
|
628
|
+
const $ = performance.now();
|
|
629
|
+
let k = 0;
|
|
630
|
+
for (; k < 5e3 && performance.now() - $ < 4; ) {
|
|
631
|
+
const F = G.next();
|
|
632
|
+
if (F.done) {
|
|
633
|
+
u = Q, f.value = h, p.value = !1, u[0] && a(u[0].pageIndex + 1);
|
|
634
|
+
return;
|
|
635
|
+
}
|
|
636
|
+
const z = tr(F.value.text, B);
|
|
637
|
+
if (z > 0) {
|
|
638
|
+
h += z;
|
|
639
|
+
const N = Q[Q.length - 1];
|
|
640
|
+
N?.pageIndex === F.value.pageIndex ? N.cumulative = h : Q.push({ pageIndex: F.value.pageIndex, cumulative: h });
|
|
641
|
+
}
|
|
642
|
+
k++;
|
|
643
|
+
}
|
|
644
|
+
g = setTimeout(M, 0);
|
|
645
|
+
}
|
|
646
|
+
M();
|
|
647
|
+
}
|
|
648
|
+
function T(q) {
|
|
649
|
+
if (v(), s.value = q, l.value = f.value = 0, u = [], !q.trim()) {
|
|
650
|
+
c("");
|
|
651
|
+
return;
|
|
652
|
+
}
|
|
653
|
+
p.value = !0, m = setTimeout(() => {
|
|
654
|
+
m = null, c(q);
|
|
655
|
+
}, Math.max(0, b(e.debounceMs) ?? 200));
|
|
656
|
+
}
|
|
657
|
+
function D(q) {
|
|
658
|
+
const B = f.value;
|
|
659
|
+
if (B === 0 || p.value) return;
|
|
660
|
+
l.value = (l.value + q + B) % B;
|
|
661
|
+
const U = i.value;
|
|
662
|
+
U && a(U.pageIndex + 1);
|
|
663
|
+
}
|
|
664
|
+
function L() {
|
|
665
|
+
v(), s.value = "", l.value = f.value = 0, u = [];
|
|
666
|
+
}
|
|
667
|
+
return le(t, L, { flush: "sync" }), Oe(L), {
|
|
668
|
+
visible: r,
|
|
669
|
+
query: s,
|
|
670
|
+
matchIndex: l,
|
|
671
|
+
matchCount: f,
|
|
672
|
+
activeMatch: i,
|
|
673
|
+
searching: p,
|
|
674
|
+
toggle: () => {
|
|
675
|
+
r.value = !r.value;
|
|
676
|
+
},
|
|
677
|
+
onInput: T,
|
|
678
|
+
onNav: D,
|
|
679
|
+
apply: (q) => {
|
|
680
|
+
s.value.trim() && n(q, s.value.trim());
|
|
681
|
+
},
|
|
682
|
+
clear: (q) => {
|
|
683
|
+
o(q);
|
|
684
|
+
},
|
|
685
|
+
reset: L
|
|
686
|
+
};
|
|
687
|
+
}
|
|
688
|
+
function ar(e, t) {
|
|
689
|
+
const a = A(() => {
|
|
690
|
+
if (e.value) return !0;
|
|
691
|
+
if (typeof location > "u") return !1;
|
|
692
|
+
try {
|
|
693
|
+
return new URLSearchParams(location.search).get("mrp-debug") === "1";
|
|
694
|
+
} catch {
|
|
695
|
+
return !1;
|
|
696
|
+
}
|
|
697
|
+
}), n = A(() => !a.value || !t.plan.value ? 0 : Math.round(JSON.stringify(t.plan.value).length / 1024)), o = A(() => !a.value || !t.plan.value ? null : {
|
|
698
|
+
pages: t.pageCount.value,
|
|
699
|
+
window: `${t.windowRange.value.start}-${t.windowRange.value.end}`,
|
|
700
|
+
zoom: `${Math.round(t.zoom.value * 100)}%`,
|
|
701
|
+
loadMs: `${t.loadMs.value}ms`,
|
|
702
|
+
planKB: n.value
|
|
703
|
+
});
|
|
704
|
+
return { enabled: a, debugStats: o };
|
|
705
|
+
}
|
|
706
|
+
function rr(e, t) {
|
|
707
|
+
const { thumbsRoot: a, visible: n, renderThumbCanvas: o } = t, r = J(0), s = J(800), l = A(() => (e.value?.pages ?? []).map(
|
|
708
|
+
(D) => Math.round(D.pageHeightMm / D.pageWidthMm * 116)
|
|
709
|
+
)), f = A(() => Pn(l.value.map((D) => D + 20), 8)), p = A(() => f.value.window(s.value, r.value, 1)), u = A(() => {
|
|
710
|
+
if (!n.value) return [];
|
|
711
|
+
const { start: D, end: L } = p.value;
|
|
712
|
+
return l.value.slice(D, L + 1).map((q, B) => ({ index: D + B, height: q }));
|
|
713
|
+
});
|
|
714
|
+
let i = 0, m = 0, g = !1;
|
|
715
|
+
function y() {
|
|
716
|
+
const D = a.value;
|
|
717
|
+
D && (r.value = D.scrollTop, s.value = D.clientHeight || 800);
|
|
718
|
+
}
|
|
719
|
+
function v() {
|
|
720
|
+
g || m || (m = requestAnimationFrame(() => {
|
|
721
|
+
m = 0, y();
|
|
722
|
+
}));
|
|
723
|
+
}
|
|
724
|
+
function c() {
|
|
725
|
+
if (u.value, i && cancelAnimationFrame(i), i = 0, g || !n.value || !e.value || !a.value) return;
|
|
726
|
+
y();
|
|
727
|
+
const D = u.value, L = e.value, q = a.value;
|
|
728
|
+
let B = 0;
|
|
729
|
+
function U() {
|
|
730
|
+
if (i = 0, !(g || !n.value || e.value !== L || a.value !== q)) {
|
|
731
|
+
for (let X = 0; B < D.length && X < 2; X++, B++) {
|
|
732
|
+
const G = D[B].index, Q = q.querySelector(`[data-thumb="${G + 1}"]`);
|
|
733
|
+
if (!Q || Q.childElementCount > 0) continue;
|
|
734
|
+
const h = o(G);
|
|
735
|
+
h && (h.style.width = "100%", h.style.height = "100%", h.style.display = "block", Q.appendChild(h));
|
|
736
|
+
}
|
|
737
|
+
B < D.length && (i = requestAnimationFrame(U));
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
i = requestAnimationFrame(U);
|
|
741
|
+
}
|
|
742
|
+
function T() {
|
|
743
|
+
g = !0, i && cancelAnimationFrame(i), m && cancelAnimationFrame(m), i = m = 0;
|
|
744
|
+
}
|
|
745
|
+
return Oe(T), { schedule: c, destroy: T, onScroll: v, windowRange: p, visibleThumbs: u };
|
|
746
|
+
}
|
|
747
|
+
function or() {
|
|
748
|
+
const e = ae(0);
|
|
749
|
+
return {
|
|
750
|
+
loadMs: e,
|
|
751
|
+
start() {
|
|
752
|
+
return typeof performance < "u" ? performance.now() : 0;
|
|
753
|
+
},
|
|
754
|
+
end(t) {
|
|
755
|
+
e.value = t ? Math.round(performance.now() - t) : 0;
|
|
756
|
+
}
|
|
757
|
+
};
|
|
758
|
+
}
|
|
759
|
+
function sr(e) {
|
|
760
|
+
const t = J(null), a = J(null);
|
|
761
|
+
function n() {
|
|
762
|
+
t.value?.focus(), t.value?.select();
|
|
763
|
+
}
|
|
764
|
+
le(e.visible, (s) => {
|
|
765
|
+
s && Qe(n);
|
|
766
|
+
});
|
|
767
|
+
function o() {
|
|
768
|
+
e.close(), Qe(() => a.value?.focus());
|
|
769
|
+
}
|
|
770
|
+
function r(s) {
|
|
771
|
+
s.isComposing || s.keyCode === 229 || s.key !== "Enter" && s.key !== "Escape" || (s.preventDefault(), s.stopPropagation(), s.key === "Escape" ? o() : e.navigate(s.shiftKey ? -1 : 1));
|
|
772
|
+
}
|
|
773
|
+
return { input: t, toggle: a, focus: n, close: o, onKeydown: r };
|
|
774
|
+
}
|
|
775
|
+
const lr = ["aria-label"], ir = { class: "mrp-title" }, ur = ["disabled"], cr = { class: "mrp-pageinfo" }, dr = ["disabled"], fr = ["disabled"], mr = {
|
|
776
|
+
key: 2,
|
|
777
|
+
class: "mrp-search"
|
|
778
|
+
}, pr = ["placeholder", "aria-label", "value"], gr = {
|
|
779
|
+
key: 0,
|
|
780
|
+
class: "mrp-search-count",
|
|
781
|
+
role: "status"
|
|
782
|
+
}, vr = ["disabled", "aria-label"], hr = ["disabled", "aria-label"], br = ["aria-label"], yr = ["aria-label", "aria-pressed"], wr = ["aria-pressed"], xr = ["disabled"], kr = ["disabled"], Ir = ["disabled"], Er = ["disabled"], Cr = ["disabled"], $r = ["disabled"], Pr = ["disabled"], Sr = ["aria-label", "aria-expanded"], Rr = /* @__PURE__ */ xe({
|
|
783
|
+
__name: "ReportToolbar",
|
|
784
|
+
props: {
|
|
785
|
+
pageCount: {},
|
|
786
|
+
currentPage: {},
|
|
787
|
+
zoomMode: {},
|
|
788
|
+
zoom: {},
|
|
789
|
+
showExport: { type: Boolean },
|
|
790
|
+
showPrint: { type: Boolean },
|
|
791
|
+
showPdfWindow: { type: Boolean },
|
|
792
|
+
messages: {},
|
|
793
|
+
search: {},
|
|
794
|
+
thumbsVisible: { type: Boolean },
|
|
795
|
+
showImport: { type: Boolean },
|
|
796
|
+
showSearch: { type: Boolean },
|
|
797
|
+
showThumbnails: { type: Boolean },
|
|
798
|
+
showZoom: { type: Boolean },
|
|
799
|
+
exportFormats: {},
|
|
800
|
+
showSettings: { type: Boolean },
|
|
801
|
+
settingsOpen: { type: Boolean },
|
|
802
|
+
busy: { type: Boolean }
|
|
803
|
+
},
|
|
804
|
+
emits: ["goto", "zoom", "export", "print", "pdf-window", "search-input", "search-nav", "search-toggle", "thumbs-toggle", "import-excel", "settings-toggle"],
|
|
805
|
+
setup(e, { expose: t, emit: a }) {
|
|
806
|
+
const n = e, o = a, r = sr({
|
|
807
|
+
visible: () => n.search.visible,
|
|
808
|
+
navigate: (p) => o("search-nav", p),
|
|
809
|
+
close: () => {
|
|
810
|
+
n.search.visible && o("search-toggle");
|
|
811
|
+
}
|
|
812
|
+
}), { input: s, toggle: l } = r;
|
|
813
|
+
t({ focusSearch: r.focus });
|
|
814
|
+
function f(p, u, i) {
|
|
815
|
+
return p.replace("{cur}", String(u)).replace("{total}", String(i));
|
|
816
|
+
}
|
|
817
|
+
return (p, u) => (I(), P("div", {
|
|
818
|
+
class: "mrp-toolbar",
|
|
819
|
+
role: "toolbar",
|
|
820
|
+
"aria-label": e.messages.title
|
|
821
|
+
}, [
|
|
822
|
+
R("span", ir, C(e.messages.title), 1),
|
|
823
|
+
e.pageCount > 0 ? (I(), P(fe, { key: 0 }, [
|
|
824
|
+
R("button", {
|
|
825
|
+
class: "mrp-nav",
|
|
826
|
+
type: "button",
|
|
827
|
+
disabled: e.currentPage <= 1,
|
|
828
|
+
onClick: u[0] || (u[0] = (i) => p.$emit("goto", e.currentPage - 1))
|
|
829
|
+
}, C(e.messages.prevPage), 9, ur),
|
|
830
|
+
R("span", cr, C(f(e.messages.pageInfo, e.currentPage, e.pageCount)), 1),
|
|
831
|
+
R("button", {
|
|
832
|
+
class: "mrp-nav",
|
|
833
|
+
type: "button",
|
|
834
|
+
disabled: e.currentPage >= e.pageCount,
|
|
835
|
+
onClick: u[1] || (u[1] = (i) => p.$emit("goto", e.currentPage + 1))
|
|
836
|
+
}, C(e.messages.nextPage), 9, dr)
|
|
837
|
+
], 64)) : j("", !0),
|
|
838
|
+
u[23] || (u[23] = R("span", { class: "mrp-spacer" }, null, -1)),
|
|
839
|
+
e.showImport ? (I(), P("button", {
|
|
840
|
+
key: 1,
|
|
841
|
+
class: "mrp-nav mrp-import-excel",
|
|
842
|
+
type: "button",
|
|
843
|
+
disabled: e.busy,
|
|
844
|
+
onClick: u[2] || (u[2] = (i) => p.$emit("import-excel"))
|
|
845
|
+
}, C(e.messages.importExcel ?? "导入 Excel 模板"), 9, fr)) : j("", !0),
|
|
846
|
+
e.showSearch !== !1 && e.search.visible ? (I(), P("div", mr, [
|
|
847
|
+
R("input", {
|
|
848
|
+
ref_key: "searchInputRef",
|
|
849
|
+
ref: s,
|
|
850
|
+
class: "mrp-search-input",
|
|
851
|
+
type: "text",
|
|
852
|
+
placeholder: e.messages.searchPlaceholder,
|
|
853
|
+
"aria-label": e.messages.search ?? e.messages.searchPlaceholder,
|
|
854
|
+
value: e.search.query,
|
|
855
|
+
onInput: u[3] || (u[3] = (i) => p.$emit("search-input", i.target.value)),
|
|
856
|
+
onKeydown: u[4] || (u[4] = //@ts-ignore
|
|
857
|
+
(...i) => b(r).onKeydown && b(r).onKeydown(...i))
|
|
858
|
+
}, null, 40, pr),
|
|
859
|
+
e.search.query ? (I(), P("span", gr, C(e.search.searching ? e.messages.searching ?? "搜索中…" : f(e.messages.matchInfo, e.search.matchCount > 0 ? e.search.matchIndex + 1 : 0, e.search.matchCount)), 1)) : j("", !0),
|
|
860
|
+
R("button", {
|
|
861
|
+
class: "mrp-nav",
|
|
862
|
+
type: "button",
|
|
863
|
+
disabled: e.search.matchCount === 0,
|
|
864
|
+
"aria-label": e.messages.prevSearchMatch,
|
|
865
|
+
onClick: u[5] || (u[5] = (i) => p.$emit("search-nav", -1))
|
|
866
|
+
}, C(e.messages.prevMatch), 9, vr),
|
|
867
|
+
R("button", {
|
|
868
|
+
class: "mrp-nav",
|
|
869
|
+
type: "button",
|
|
870
|
+
disabled: e.search.matchCount === 0,
|
|
871
|
+
"aria-label": e.messages.nextSearchMatch,
|
|
872
|
+
onClick: u[6] || (u[6] = (i) => p.$emit("search-nav", 1))
|
|
873
|
+
}, C(e.messages.nextMatch), 9, hr),
|
|
874
|
+
R("button", {
|
|
875
|
+
class: "mrp-nav mrp-search-close",
|
|
876
|
+
type: "button",
|
|
877
|
+
"aria-label": e.messages.closeSearch,
|
|
878
|
+
onClick: u[7] || (u[7] = //@ts-ignore
|
|
879
|
+
(...i) => b(r).close && b(r).close(...i))
|
|
880
|
+
}, "×", 8, br)
|
|
881
|
+
])) : j("", !0),
|
|
882
|
+
e.showSearch !== !1 ? (I(), P("button", {
|
|
883
|
+
key: 3,
|
|
884
|
+
ref_key: "searchToggleRef",
|
|
885
|
+
ref: l,
|
|
886
|
+
class: ye(["mrp-nav", { "mrp-active": e.search.visible }]),
|
|
887
|
+
type: "button",
|
|
888
|
+
title: "Ctrl+F",
|
|
889
|
+
"aria-label": e.messages.search ?? e.messages.searchPlaceholder,
|
|
890
|
+
"aria-pressed": e.search.visible,
|
|
891
|
+
onClick: u[8] || (u[8] = (i) => p.$emit("search-toggle"))
|
|
892
|
+
}, [...u[21] || (u[21] = [
|
|
893
|
+
R("svg", {
|
|
894
|
+
width: "13",
|
|
895
|
+
height: "13",
|
|
896
|
+
viewBox: "0 0 20 20",
|
|
897
|
+
fill: "none",
|
|
898
|
+
"aria-hidden": "true"
|
|
899
|
+
}, [
|
|
900
|
+
R("circle", {
|
|
901
|
+
cx: "8.5",
|
|
902
|
+
cy: "8.5",
|
|
903
|
+
r: "5.5",
|
|
904
|
+
stroke: "currentColor",
|
|
905
|
+
"stroke-width": "1.6"
|
|
906
|
+
}),
|
|
907
|
+
R("path", {
|
|
908
|
+
d: "m13 13 4 4",
|
|
909
|
+
stroke: "currentColor",
|
|
910
|
+
"stroke-width": "1.6",
|
|
911
|
+
"stroke-linecap": "round"
|
|
912
|
+
})
|
|
913
|
+
], -1)
|
|
914
|
+
])], 10, yr)) : j("", !0),
|
|
915
|
+
e.showThumbnails !== !1 ? (I(), P("button", {
|
|
916
|
+
key: 4,
|
|
917
|
+
class: ye(["mrp-nav", { "mrp-active": e.thumbsVisible }]),
|
|
918
|
+
type: "button",
|
|
919
|
+
"aria-pressed": e.thumbsVisible,
|
|
920
|
+
onClick: u[9] || (u[9] = (i) => p.$emit("thumbs-toggle"))
|
|
921
|
+
}, " ▦ " + C(e.messages.thumbnails), 11, wr)) : j("", !0),
|
|
922
|
+
e.showZoom !== !1 ? (I(), P("button", {
|
|
923
|
+
key: 5,
|
|
924
|
+
class: ye(["mrp-nav", { "mrp-active": e.zoomMode === "fit" }]),
|
|
925
|
+
type: "button",
|
|
926
|
+
onClick: u[10] || (u[10] = (i) => p.$emit("zoom", "fit"))
|
|
927
|
+
}, C(e.messages.fitWidth), 3)) : j("", !0),
|
|
928
|
+
e.showZoom !== !1 ? (I(), P("button", {
|
|
929
|
+
key: 6,
|
|
930
|
+
class: ye(["mrp-nav", { "mrp-active": e.zoomMode === "raw" && Math.round(e.zoom * 100) === 100 }]),
|
|
931
|
+
type: "button",
|
|
932
|
+
onClick: u[11] || (u[11] = (i) => p.$emit("zoom", 100))
|
|
933
|
+
}, " 100% ", 2)) : j("", !0),
|
|
934
|
+
e.showZoom !== !1 ? (I(), P("button", {
|
|
935
|
+
key: 7,
|
|
936
|
+
class: ye(["mrp-nav", { "mrp-active": e.zoomMode === "raw" && Math.round(e.zoom * 100) === 150 }]),
|
|
937
|
+
type: "button",
|
|
938
|
+
onClick: u[12] || (u[12] = (i) => p.$emit("zoom", 150))
|
|
939
|
+
}, " 150% ", 2)) : j("", !0),
|
|
940
|
+
e.showExport && (!e.exportFormats || e.exportFormats.includes("html")) ? (I(), P("button", {
|
|
941
|
+
key: 8,
|
|
942
|
+
class: "mrp-nav",
|
|
943
|
+
type: "button",
|
|
944
|
+
disabled: e.busy,
|
|
945
|
+
onClick: u[13] || (u[13] = (i) => p.$emit("export", "html"))
|
|
946
|
+
}, C(e.messages.exportHtml), 9, xr)) : j("", !0),
|
|
947
|
+
e.showExport && (!e.exportFormats || e.exportFormats.includes("pdf")) ? (I(), P("button", {
|
|
948
|
+
key: 9,
|
|
949
|
+
class: "mrp-nav",
|
|
950
|
+
type: "button",
|
|
951
|
+
disabled: e.busy,
|
|
952
|
+
onClick: u[14] || (u[14] = (i) => p.$emit("export", "pdf"))
|
|
953
|
+
}, C(e.messages.exportPdf), 9, kr)) : j("", !0),
|
|
954
|
+
e.showExport && (!e.exportFormats || e.exportFormats.includes("xlsx")) ? (I(), P("button", {
|
|
955
|
+
key: 10,
|
|
956
|
+
class: "mrp-nav",
|
|
957
|
+
type: "button",
|
|
958
|
+
disabled: e.busy,
|
|
959
|
+
onClick: u[15] || (u[15] = (i) => p.$emit("export", "xlsx"))
|
|
960
|
+
}, C(e.messages.exportExcel), 9, Ir)) : j("", !0),
|
|
961
|
+
e.showExport && (!e.exportFormats || e.exportFormats.includes("png")) ? (I(), P("button", {
|
|
962
|
+
key: 11,
|
|
963
|
+
class: "mrp-nav",
|
|
964
|
+
type: "button",
|
|
965
|
+
disabled: e.busy,
|
|
966
|
+
onClick: u[16] || (u[16] = (i) => p.$emit("export", "png"))
|
|
967
|
+
}, C(e.messages.exportImage), 9, Er)) : j("", !0),
|
|
968
|
+
e.showExport && (!e.exportFormats || e.exportFormats.includes("word")) ? (I(), P("button", {
|
|
969
|
+
key: 12,
|
|
970
|
+
class: "mrp-nav",
|
|
971
|
+
type: "button",
|
|
972
|
+
disabled: e.busy,
|
|
973
|
+
onClick: u[17] || (u[17] = (i) => p.$emit("export", "word"))
|
|
974
|
+
}, C(e.messages.exportWord), 9, Cr)) : j("", !0),
|
|
975
|
+
e.showPrint ? (I(), P("button", {
|
|
976
|
+
key: 13,
|
|
977
|
+
class: "mrp-nav",
|
|
978
|
+
type: "button",
|
|
979
|
+
disabled: e.busy,
|
|
980
|
+
onClick: u[18] || (u[18] = (i) => p.$emit("print"))
|
|
981
|
+
}, C(e.messages.print), 9, $r)) : j("", !0),
|
|
982
|
+
e.showPdfWindow ? (I(), P("button", {
|
|
983
|
+
key: 14,
|
|
984
|
+
class: "mrp-nav",
|
|
985
|
+
type: "button",
|
|
986
|
+
disabled: e.busy,
|
|
987
|
+
onClick: u[19] || (u[19] = (i) => p.$emit("pdf-window"))
|
|
988
|
+
}, C(e.messages.pdfWindow), 9, Pr)) : j("", !0),
|
|
989
|
+
e.showSettings ? (I(), P("button", {
|
|
990
|
+
key: 15,
|
|
991
|
+
class: "mrp-nav mrp-settings-toggle",
|
|
992
|
+
type: "button",
|
|
993
|
+
"aria-label": e.messages.settings,
|
|
994
|
+
"aria-haspopup": "dialog",
|
|
995
|
+
"aria-expanded": !!e.settingsOpen,
|
|
996
|
+
onClick: u[20] || (u[20] = (i) => p.$emit("settings-toggle"))
|
|
997
|
+
}, [
|
|
998
|
+
u[22] || (u[22] = xn('<svg width="14" height="14" viewBox="0 0 20 20" fill="none" aria-hidden="true" data-v-249cf7b0><path d="M3 5h14M3 10h14M3 15h14" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" data-v-249cf7b0></path><circle cx="7" cy="5" r="2" fill="var(--mrp-toolbar-bg)" stroke="currentColor" stroke-width="1.5" data-v-249cf7b0></circle><circle cx="13" cy="10" r="2" fill="var(--mrp-toolbar-bg)" stroke="currentColor" stroke-width="1.5" data-v-249cf7b0></circle><circle cx="8" cy="15" r="2" fill="var(--mrp-toolbar-bg)" stroke="currentColor" stroke-width="1.5" data-v-249cf7b0></circle></svg>', 1)),
|
|
999
|
+
we(" " + C(e.messages.settings), 1)
|
|
1000
|
+
], 8, Sr)) : j("", !0)
|
|
1001
|
+
], 8, lr));
|
|
1002
|
+
}
|
|
1003
|
+
}), Mr = /* @__PURE__ */ ke(Rr, [["__scopeId", "data-v-249cf7b0"]]), Tr = ["aria-label"], Fr = { class: "mrp-settings-header" }, Dr = ["aria-label"], Or = { class: "mrp-settings-content" }, Ar = { key: 0 }, Lr = { class: "mrp-settings-option" }, zr = ["checked", "disabled"], qr = { class: "mrp-settings-option" }, Br = ["value", "disabled"], jr = { key: 0 }, Nr = ["checked", "disabled", "onChange"], Wr = {
|
|
1004
|
+
key: 1,
|
|
1005
|
+
class: "mrp-settings-note"
|
|
1006
|
+
}, Hr = {
|
|
1007
|
+
key: 2,
|
|
1008
|
+
class: "mrp-settings-note"
|
|
1009
|
+
}, Kr = ["disabled"], Ur = /* @__PURE__ */ xe({
|
|
1010
|
+
__name: "ReportSettings",
|
|
1011
|
+
props: {
|
|
1012
|
+
available: {},
|
|
1013
|
+
enabled: {},
|
|
1014
|
+
messages: {},
|
|
1015
|
+
persistedEditing: { type: Boolean },
|
|
1016
|
+
busy: { type: Boolean },
|
|
1017
|
+
interaction: {}
|
|
1018
|
+
},
|
|
1019
|
+
emits: ["change", "reset", "close", "interaction"],
|
|
1020
|
+
setup(e, { emit: t }) {
|
|
1021
|
+
const a = e, n = t, o = J(null), r = J(null);
|
|
1022
|
+
let s = null;
|
|
1023
|
+
const l = A(() => [
|
|
1024
|
+
{ label: a.messages.settingsDisplay, tools: [
|
|
1025
|
+
["search", a.messages.search],
|
|
1026
|
+
["thumbnails", a.messages.thumbnails],
|
|
1027
|
+
["zoom", a.messages.zoom]
|
|
1028
|
+
] },
|
|
1029
|
+
{ label: a.messages.settingsExport, tools: [
|
|
1030
|
+
["html", a.messages.exportHtml],
|
|
1031
|
+
["pdf", a.messages.exportPdf],
|
|
1032
|
+
["xlsx", a.messages.exportExcel],
|
|
1033
|
+
["png", a.messages.exportImage],
|
|
1034
|
+
["word", a.messages.exportWord],
|
|
1035
|
+
["print", a.messages.print],
|
|
1036
|
+
["pdfWindow", a.messages.pdfWindow]
|
|
1037
|
+
] },
|
|
1038
|
+
{ label: a.messages.settingsData, tools: [
|
|
1039
|
+
["editing", a.messages.editCell],
|
|
1040
|
+
["import", a.messages.importExcel]
|
|
1041
|
+
] }
|
|
1042
|
+
].map((i) => ({ ...i, tools: i.tools.map(([m, g]) => ({ key: m, label: g })) })));
|
|
1043
|
+
function f(i, m) {
|
|
1044
|
+
const g = i.target, y = g.checked;
|
|
1045
|
+
g.checked = a.enabled[m], n("change", m, y);
|
|
1046
|
+
}
|
|
1047
|
+
function p(i) {
|
|
1048
|
+
return !o.value || i.defaultPrevented ? !1 : i.target instanceof Node && o.value.contains(i.target) ? !0 : i.target instanceof Element && i.target.closest('[role="dialog"],dialog[open]') ? !1 : !Array.from(document.querySelectorAll('[aria-modal="true"],dialog[open]')).some((m) => m !== o.value && !o.value.contains(m));
|
|
1049
|
+
}
|
|
1050
|
+
function u(i) {
|
|
1051
|
+
if (!p(i)) return;
|
|
1052
|
+
if (i.key === "Escape") {
|
|
1053
|
+
i.preventDefault(), i.stopPropagation(), n("close");
|
|
1054
|
+
return;
|
|
1055
|
+
}
|
|
1056
|
+
if (i.key !== "Tab") return;
|
|
1057
|
+
const m = o.value?.querySelectorAll("a[href],button:not(:disabled),input:not(:disabled),textarea:not(:disabled),select:not(:disabled),[tabindex='0']"), g = m?.[0], y = m?.[m.length - 1];
|
|
1058
|
+
(!o.value?.contains(document.activeElement) || i.shiftKey && document.activeElement === g || !i.shiftKey && document.activeElement === y) && (i.preventDefault(), i.stopPropagation(), (i.shiftKey ? y : g)?.focus());
|
|
1059
|
+
}
|
|
1060
|
+
return Wt(() => {
|
|
1061
|
+
s = o.value?.closest(".mach-report-preview")?.querySelector(".mrp-settings-toggle") ?? (document.activeElement instanceof HTMLElement ? document.activeElement : null), r.value?.focus(), document.addEventListener("keydown", u);
|
|
1062
|
+
}), Ht(() => {
|
|
1063
|
+
document.removeEventListener("keydown", u), s?.isConnected && s.focus();
|
|
1064
|
+
}), (i, m) => (I(), P("div", {
|
|
1065
|
+
class: "mrp-settings-backdrop",
|
|
1066
|
+
onClick: m[4] || (m[4] = ut((g) => i.$emit("close"), ["self"]))
|
|
1067
|
+
}, [
|
|
1068
|
+
R("section", {
|
|
1069
|
+
ref_key: "panel",
|
|
1070
|
+
ref: o,
|
|
1071
|
+
class: "mrp-settings-panel",
|
|
1072
|
+
role: "dialog",
|
|
1073
|
+
"aria-modal": "true",
|
|
1074
|
+
"aria-label": e.messages.settings
|
|
1075
|
+
}, [
|
|
1076
|
+
R("header", Fr, [
|
|
1077
|
+
R("div", null, [
|
|
1078
|
+
R("strong", null, C(e.messages.settings), 1),
|
|
1079
|
+
R("p", null, C(e.messages.settingsLocal), 1)
|
|
1080
|
+
]),
|
|
1081
|
+
R("button", {
|
|
1082
|
+
ref_key: "closeButton",
|
|
1083
|
+
ref: r,
|
|
1084
|
+
class: "mrp-settings-close",
|
|
1085
|
+
type: "button",
|
|
1086
|
+
"aria-label": e.messages.settingsClose,
|
|
1087
|
+
onClick: m[0] || (m[0] = (g) => i.$emit("close"))
|
|
1088
|
+
}, "×", 8, Dr)
|
|
1089
|
+
]),
|
|
1090
|
+
R("div", Or, [
|
|
1091
|
+
Ot(i.$slots, "default", {}, void 0, !0),
|
|
1092
|
+
e.interaction ? (I(), P("fieldset", Ar, [
|
|
1093
|
+
R("legend", null, C(e.messages.settingsPanes), 1),
|
|
1094
|
+
R("label", Lr, [
|
|
1095
|
+
R("span", null, C(e.messages.freezeHeaders), 1),
|
|
1096
|
+
R("input", {
|
|
1097
|
+
type: "checkbox",
|
|
1098
|
+
checked: e.interaction.freezeHeaders,
|
|
1099
|
+
disabled: e.busy,
|
|
1100
|
+
onChange: m[1] || (m[1] = (g) => i.$emit("interaction", { freezeHeaders: g.target.checked }))
|
|
1101
|
+
}, null, 40, zr)
|
|
1102
|
+
]),
|
|
1103
|
+
R("label", qr, [
|
|
1104
|
+
R("span", null, C(e.messages.frozenColumns), 1),
|
|
1105
|
+
R("input", {
|
|
1106
|
+
class: "mrp-frozen-count",
|
|
1107
|
+
type: "number",
|
|
1108
|
+
min: "0",
|
|
1109
|
+
max: "20",
|
|
1110
|
+
value: e.interaction.frozenColumns ?? 0,
|
|
1111
|
+
disabled: e.busy,
|
|
1112
|
+
onChange: m[2] || (m[2] = (g) => i.$emit("interaction", { frozenColumns: Math.max(0, Math.min(20, Number(g.target.value) || 0)) }))
|
|
1113
|
+
}, null, 40, Br)
|
|
1114
|
+
])
|
|
1115
|
+
])) : j("", !0),
|
|
1116
|
+
(I(!0), P(fe, null, pe(l.value, (g) => (I(), P("fieldset", {
|
|
1117
|
+
key: g.label
|
|
1118
|
+
}, [
|
|
1119
|
+
R("legend", null, C(g.label), 1),
|
|
1120
|
+
(I(!0), P(fe, null, pe(g.tools, (y) => (I(), P("label", {
|
|
1121
|
+
key: y.key,
|
|
1122
|
+
class: ye(["mrp-settings-option", { "mrp-settings-unavailable": !e.available[y.key] }])
|
|
1123
|
+
}, [
|
|
1124
|
+
R("span", null, [
|
|
1125
|
+
we(C(y.label), 1),
|
|
1126
|
+
e.available[y.key] ? j("", !0) : (I(), P("small", jr, C(e.messages.settingsUnavailable), 1))
|
|
1127
|
+
]),
|
|
1128
|
+
R("input", {
|
|
1129
|
+
type: "checkbox",
|
|
1130
|
+
checked: e.enabled[y.key],
|
|
1131
|
+
disabled: e.busy || !e.available[y.key],
|
|
1132
|
+
onChange: (v) => f(v, y.key)
|
|
1133
|
+
}, null, 40, Nr)
|
|
1134
|
+
], 2))), 128))
|
|
1135
|
+
]))), 128)),
|
|
1136
|
+
e.available.editing ? (I(), P("p", Wr, C(e.persistedEditing ? e.messages.editingSaved : e.messages.editingLocal), 1)) : j("", !0),
|
|
1137
|
+
e.available.import ? (I(), P("p", Hr, C(e.messages.importLocal), 1)) : j("", !0)
|
|
1138
|
+
]),
|
|
1139
|
+
R("footer", null, [
|
|
1140
|
+
R("button", {
|
|
1141
|
+
type: "button",
|
|
1142
|
+
disabled: e.busy,
|
|
1143
|
+
onClick: m[3] || (m[3] = (g) => i.$emit("reset"))
|
|
1144
|
+
}, C(e.messages.settingsReset), 9, Kr)
|
|
1145
|
+
])
|
|
1146
|
+
], 8, Tr)
|
|
1147
|
+
]));
|
|
1148
|
+
}
|
|
1149
|
+
}), Vr = /* @__PURE__ */ ke(Ur, [["__scopeId", "data-v-f92f2c66"]]), Gr = {
|
|
1150
|
+
class: "mrp-empty",
|
|
1151
|
+
role: "status"
|
|
1152
|
+
}, Jr = { key: 0 }, Zr = /* @__PURE__ */ xe({
|
|
1153
|
+
__name: "ReportEmpty",
|
|
1154
|
+
props: {
|
|
1155
|
+
title: {},
|
|
1156
|
+
description: {}
|
|
1157
|
+
},
|
|
1158
|
+
setup(e) {
|
|
1159
|
+
return (t, a) => (I(), P("div", Gr, [
|
|
1160
|
+
a[0] || (a[0] = xn('<svg class="mrp-empty-art" viewBox="0 0 160 112" fill="none" aria-hidden="true" data-v-07e9cb82><ellipse cx="80" cy="100" rx="54" ry="7" fill="currentColor" opacity=".05" data-v-07e9cb82></ellipse><rect x="34" y="15" width="92" height="78" rx="9" fill="currentColor" opacity=".04" data-v-07e9cb82></rect><rect x="42" y="9" width="76" height="78" rx="7" fill="var(--mrp-toolbar-bg, #fff)" stroke="currentColor" stroke-opacity=".2" stroke-width="1.5" data-v-07e9cb82></rect><path d="M55 27H105M55 42H105M55 57H85M55 72H76M71 27V72M89 27V57" stroke="currentColor" stroke-opacity=".15" stroke-width="1.5" stroke-linecap="round" data-v-07e9cb82></path><circle cx="112" cy="76" r="16" fill="var(--mrp-toolbar-bg, #fff)" stroke="currentColor" stroke-opacity=".35" stroke-width="2" data-v-07e9cb82></circle><path d="M124 88L137 101M106 76H118" stroke="currentColor" stroke-opacity=".45" stroke-width="3" stroke-linecap="round" data-v-07e9cb82></path><circle cx="27" cy="38" r="3" fill="currentColor" opacity=".12" data-v-07e9cb82></circle><circle cx="132" cy="24" r="2" fill="currentColor" opacity=".2" data-v-07e9cb82></circle></svg>', 1)),
|
|
1161
|
+
R("strong", null, C(e.title), 1),
|
|
1162
|
+
e.description ? (I(), P("p", Jr, C(e.description), 1)) : j("", !0)
|
|
1163
|
+
]));
|
|
1164
|
+
}
|
|
1165
|
+
}), vn = /* @__PURE__ */ ke(Zr, [["__scopeId", "data-v-07e9cb82"]]), Yr = ["aria-label"], Xr = /* @__PURE__ */ xe({
|
|
1166
|
+
__name: "ReportDiscardDialog",
|
|
1167
|
+
props: {
|
|
1168
|
+
messages: {}
|
|
1169
|
+
},
|
|
1170
|
+
emits: ["answer"],
|
|
1171
|
+
setup(e, { emit: t }) {
|
|
1172
|
+
const a = t, n = J(null), o = J(null);
|
|
1173
|
+
let r = null;
|
|
1174
|
+
function s(l) {
|
|
1175
|
+
l.key === "Escape" && (l.preventDefault(), a("answer", !1)), l.key === "Tab" && (l.preventDefault(), document.activeElement === n.value ? o.value?.focus() : n.value?.focus());
|
|
1176
|
+
}
|
|
1177
|
+
return Wt(() => {
|
|
1178
|
+
r = document.activeElement instanceof HTMLElement ? document.activeElement : null, n.value?.focus();
|
|
1179
|
+
}), Ht(() => {
|
|
1180
|
+
r?.isConnected && r.focus();
|
|
1181
|
+
}), (l, f) => (I(), P("div", {
|
|
1182
|
+
class: "mrp-discard-backdrop",
|
|
1183
|
+
onKeydown: s,
|
|
1184
|
+
onClick: f[2] || (f[2] = ut((p) => a("answer", !1), ["self"]))
|
|
1185
|
+
}, [
|
|
1186
|
+
R("section", {
|
|
1187
|
+
class: "mrp-discard-dialog",
|
|
1188
|
+
role: "alertdialog",
|
|
1189
|
+
"aria-modal": "true",
|
|
1190
|
+
"aria-label": e.messages.discardTitle
|
|
1191
|
+
}, [
|
|
1192
|
+
R("strong", null, C(e.messages.discardTitle), 1),
|
|
1193
|
+
R("p", null, C(e.messages.discardDescription), 1),
|
|
1194
|
+
R("footer", null, [
|
|
1195
|
+
R("button", {
|
|
1196
|
+
ref_key: "keep",
|
|
1197
|
+
ref: n,
|
|
1198
|
+
type: "button",
|
|
1199
|
+
onClick: f[0] || (f[0] = (p) => a("answer", !1))
|
|
1200
|
+
}, C(e.messages.discardKeep), 513),
|
|
1201
|
+
R("button", {
|
|
1202
|
+
ref_key: "discard",
|
|
1203
|
+
ref: o,
|
|
1204
|
+
type: "button",
|
|
1205
|
+
onClick: f[1] || (f[1] = (p) => a("answer", !0))
|
|
1206
|
+
}, C(e.messages.discardProceed), 513)
|
|
1207
|
+
])
|
|
1208
|
+
], 8, Yr)
|
|
1209
|
+
], 32));
|
|
1210
|
+
}
|
|
1211
|
+
}), Qr = /* @__PURE__ */ ke(Xr, [["__scopeId", "data-v-f7590294"]]), _r = {
|
|
1212
|
+
key: 0,
|
|
1213
|
+
class: "mrp-task-status",
|
|
1214
|
+
role: "status",
|
|
1215
|
+
"aria-live": "polite"
|
|
1216
|
+
}, eo = { key: 0 }, to = ["value", "max", "aria-label"], no = /* @__PURE__ */ xe({
|
|
1217
|
+
__name: "ReportTaskStatus",
|
|
1218
|
+
props: {
|
|
1219
|
+
task: {},
|
|
1220
|
+
messages: {}
|
|
1221
|
+
},
|
|
1222
|
+
emits: ["cancel"],
|
|
1223
|
+
setup(e) {
|
|
1224
|
+
const t = e, a = A(() => ({ query: t.messages.taskQuery, validate: t.messages.taskValidate, layout: t.messages.taskLayout, assets: t.messages.taskAssets, import: t.messages.importing, encode: t.messages.taskEncode, download: t.messages.taskDownload, print: t.messages.taskPrint })), n = A(() => t.task?.total === void 0 ? "" : `${t.task.completed ?? 0} / ${t.task.total}`);
|
|
1225
|
+
return (o, r) => e.task && (e.task.status === "running" || e.task.status === "cancelled") ? (I(), P("div", _r, [
|
|
1226
|
+
R("span", null, [
|
|
1227
|
+
we(C(e.task.status === "cancelled" ? e.messages.taskCancelled : a.value[e.task.stage]) + " ", 1),
|
|
1228
|
+
e.task.status === "running" ? (I(), P("small", eo, C(n.value), 1)) : j("", !0)
|
|
1229
|
+
]),
|
|
1230
|
+
e.task.status === "running" && e.task.total !== void 0 ? (I(), P("progress", {
|
|
1231
|
+
key: 0,
|
|
1232
|
+
value: e.task.completed ?? 0,
|
|
1233
|
+
max: e.task.total,
|
|
1234
|
+
"aria-label": a.value[e.task.stage]
|
|
1235
|
+
}, null, 8, to)) : j("", !0),
|
|
1236
|
+
e.task.status === "running" && e.task.cancellable ? (I(), P("button", {
|
|
1237
|
+
key: 1,
|
|
1238
|
+
type: "button",
|
|
1239
|
+
onClick: r[0] || (r[0] = (s) => o.$emit("cancel"))
|
|
1240
|
+
}, C(e.messages.taskCancel), 1)) : j("", !0)
|
|
1241
|
+
])) : j("", !0);
|
|
1242
|
+
}
|
|
1243
|
+
}), ao = /* @__PURE__ */ ke(no, [["__scopeId", "data-v-657ac599"]]), ro = {
|
|
1244
|
+
key: 0,
|
|
1245
|
+
class: "mrp-diagnostics"
|
|
1246
|
+
}, oo = ["aria-label", "placeholder"], so = { key: 0 }, lo = ["onClick"], io = { key: 0 }, uo = /* @__PURE__ */ xe({
|
|
1247
|
+
__name: "ReportDiagnostics",
|
|
1248
|
+
props: {
|
|
1249
|
+
entries: {},
|
|
1250
|
+
messages: {}
|
|
1251
|
+
},
|
|
1252
|
+
emits: ["locate"],
|
|
1253
|
+
setup(e) {
|
|
1254
|
+
const t = e, a = J(""), n = A(() => ({
|
|
1255
|
+
"unsupported-style": t.messages.diagnosticUnsupportedStyle,
|
|
1256
|
+
"missing-image": t.messages.diagnosticMissingImage,
|
|
1257
|
+
"unsupported-component": t.messages.diagnosticUnsupported,
|
|
1258
|
+
"unsupported-image-format": t.messages.diagnosticImageFormat,
|
|
1259
|
+
"rich-text-flattened": t.messages.diagnosticRichText,
|
|
1260
|
+
"nested-components-omitted": t.messages.diagnosticNested,
|
|
1261
|
+
"async-image-required": t.messages.diagnosticImageAsync,
|
|
1262
|
+
"image-decode-failed": t.messages.diagnosticImageDecode,
|
|
1263
|
+
"asset-render-failed": t.messages.diagnosticAssetFailed,
|
|
1264
|
+
"asset-budget-exceeded": t.messages.diagnosticAssetBudget
|
|
1265
|
+
})), o = A(() => {
|
|
1266
|
+
const l = a.value.trim().toLocaleLowerCase();
|
|
1267
|
+
return l ? t.entries.filter((f) => `${f.code} ${f.message} ${n.value[f.code] ?? ""} ${f.path ?? ""} ${s(f)} ${f.format ?? ""}`.toLocaleLowerCase().includes(l)) : t.entries;
|
|
1268
|
+
}), r = A(() => o.value.slice(0, 100));
|
|
1269
|
+
function s(l) {
|
|
1270
|
+
return l.pageIndex === void 0 ? l.path ?? "" : (t.messages.diagnosticsLocation ?? "").replace("{page}", String(l.pageIndex + 1)).replace("{component}", String((l.componentIndex ?? 0) + 1));
|
|
1271
|
+
}
|
|
1272
|
+
return (l, f) => e.entries.length ? (I(), P("details", ro, [
|
|
1273
|
+
R("summary", null, [
|
|
1274
|
+
we(C(e.messages.diagnosticsTitle) + " ", 1),
|
|
1275
|
+
R("span", null, C(e.entries.length), 1)
|
|
1276
|
+
]),
|
|
1277
|
+
kn(R("input", {
|
|
1278
|
+
"onUpdate:modelValue": f[0] || (f[0] = (p) => a.value = p),
|
|
1279
|
+
type: "search",
|
|
1280
|
+
"aria-label": e.messages.diagnosticsSearch,
|
|
1281
|
+
placeholder: e.messages.diagnosticsSearch
|
|
1282
|
+
}, null, 8, oo), [
|
|
1283
|
+
[In, a.value]
|
|
1284
|
+
]),
|
|
1285
|
+
R("ol", null, [
|
|
1286
|
+
(I(!0), P(fe, null, pe(r.value, (p, u) => (I(), P("li", { key: u }, [
|
|
1287
|
+
R("div", null, [
|
|
1288
|
+
R("b", null, C(p.format?.toUpperCase() ?? p.severity) + " · " + C(p.code), 1),
|
|
1289
|
+
R("p", null, C(n.value[p.code] ?? p.message), 1),
|
|
1290
|
+
n.value[p.code] ? (I(), P("details", so, [
|
|
1291
|
+
R("summary", null, C(e.messages.diagnosticsDetails), 1),
|
|
1292
|
+
we(C(p.message), 1)
|
|
1293
|
+
])) : j("", !0),
|
|
1294
|
+
R("small", null, C(s(p)), 1)
|
|
1295
|
+
]),
|
|
1296
|
+
p.pageIndex !== void 0 ? (I(), P("button", {
|
|
1297
|
+
key: 0,
|
|
1298
|
+
type: "button",
|
|
1299
|
+
onClick: (i) => l.$emit("locate", p)
|
|
1300
|
+
}, C(e.messages.diagnosticsLocate), 9, lo)) : j("", !0)
|
|
1301
|
+
]))), 128))
|
|
1302
|
+
]),
|
|
1303
|
+
o.value.length > r.value.length ? (I(), P("small", io, C((e.messages.diagnosticsMore ?? "").replace("{count}", String(o.value.length))), 1)) : j("", !0)
|
|
1304
|
+
])) : j("", !0);
|
|
1305
|
+
}
|
|
1306
|
+
}), co = /* @__PURE__ */ ke(uo, [["__scopeId", "data-v-3b7804ce"]]);
|
|
1307
|
+
class ge extends Error {
|
|
1308
|
+
constructor(t, a, n) {
|
|
1309
|
+
super(a), this.name = "MachReportError", this.code = t, this.cause = n;
|
|
1310
|
+
}
|
|
1311
|
+
}
|
|
1312
|
+
function fo(e) {
|
|
1313
|
+
return e instanceof ge ? { code: e.code, cause: e.cause } : { code: "render", cause: e };
|
|
1314
|
+
}
|
|
1315
|
+
function mo(e) {
|
|
1316
|
+
if (e instanceof ge) return e;
|
|
1317
|
+
if (e instanceof ka) return new ge("param", e.message, e);
|
|
1318
|
+
if (e instanceof Ia) return new ge(e.code, e.message, e.cause);
|
|
1319
|
+
if (e instanceof Error) {
|
|
1320
|
+
const t = { params: "param", config: "config", validate: "validate", fetch: "fetch" }, a = e.code;
|
|
1321
|
+
if (typeof a == "string" && Object.prototype.hasOwnProperty.call(t, a)) return new ge(t[a], e.message, e);
|
|
1322
|
+
}
|
|
1323
|
+
return new ge("fetch", e instanceof Error ? e.message : "预览加载失败", e);
|
|
1324
|
+
}
|
|
1325
|
+
const hn = /* @__PURE__ */ new Map(), We = /* @__PURE__ */ new Map(), po = 15e3;
|
|
1326
|
+
function qt(e, t) {
|
|
1327
|
+
return Object.assign(new Error(e), { cause: t });
|
|
1328
|
+
}
|
|
1329
|
+
function Ye(e, t) {
|
|
1330
|
+
return `PDF 字体 ${JSON.stringify(e)}:${t}。请部署支持报表文字的字体文件,并将 pdfFontUrl 配置为可访问的字体 URL;西文报表可设为空串`;
|
|
1331
|
+
}
|
|
1332
|
+
function mt(e) {
|
|
1333
|
+
if (e?.reason instanceof Error && e.reason.name === "AbortError") return e.reason;
|
|
1334
|
+
const t = qt("PDF 字体检查已取消", e?.reason);
|
|
1335
|
+
return t.name = "AbortError", t;
|
|
1336
|
+
}
|
|
1337
|
+
async function go(e, t) {
|
|
1338
|
+
let a = !1;
|
|
1339
|
+
const n = setTimeout(() => {
|
|
1340
|
+
a = !0, t.abort();
|
|
1341
|
+
}, po);
|
|
1342
|
+
try {
|
|
1343
|
+
const o = await fetch(e, { method: "HEAD", signal: t.signal });
|
|
1344
|
+
if (t.signal.aborted) throw mt(t.signal);
|
|
1345
|
+
if (o.status === 405 || o.status === 501 || o.type === "opaque")
|
|
1346
|
+
return {
|
|
1347
|
+
status: "unverified",
|
|
1348
|
+
fontUrl: e,
|
|
1349
|
+
message: `PDF 字体 ${JSON.stringify(e)} 无法通过 HEAD 检查验证;仍可尝试导出,届时会加载并校验字体`
|
|
1350
|
+
};
|
|
1351
|
+
if (!o.ok) {
|
|
1352
|
+
const s = new Error(`字体请求返回 HTTP ${o.status}`);
|
|
1353
|
+
return { status: "error", fontUrl: e, message: Ye(e, s.message), cause: s };
|
|
1354
|
+
}
|
|
1355
|
+
const r = o.headers.get("content-type") ?? "";
|
|
1356
|
+
if (/text\/html|application\/xhtml\+xml/i.test(r)) {
|
|
1357
|
+
const s = new Error("字体 URL 返回 HTML 页面(可能是 SPA 路由回退),不是字体文件");
|
|
1358
|
+
return { status: "error", fontUrl: e, message: Ye(e, s.message), cause: s };
|
|
1359
|
+
}
|
|
1360
|
+
if (/^text\//i.test(r) || /(?:\/|\+)json(?:\s*;|$)/i.test(r)) {
|
|
1361
|
+
const s = new Error(`字体 URL 返回 ${r} 文本响应,不是字体文件`);
|
|
1362
|
+
return { status: "error", fontUrl: e, message: Ye(e, s.message), cause: s };
|
|
1363
|
+
}
|
|
1364
|
+
return {
|
|
1365
|
+
status: "available",
|
|
1366
|
+
fontUrl: e,
|
|
1367
|
+
message: "PDF 字体资源可达;文字覆盖范围将在实际导出时校验"
|
|
1368
|
+
};
|
|
1369
|
+
} catch (o) {
|
|
1370
|
+
if (t.signal.aborted && !a) throw mt(t.signal);
|
|
1371
|
+
return {
|
|
1372
|
+
status: "error",
|
|
1373
|
+
fontUrl: e,
|
|
1374
|
+
message: Ye(e, a ? "字体检查超时,请检查网络或字体服务" : "字体检查失败,请检查网络、字体服务或跨域访问配置"),
|
|
1375
|
+
cause: o
|
|
1376
|
+
};
|
|
1377
|
+
} finally {
|
|
1378
|
+
clearTimeout(n);
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1381
|
+
function vo(e, t) {
|
|
1382
|
+
if (t?.aborted) return Promise.reject(mt(t));
|
|
1383
|
+
if (!e)
|
|
1384
|
+
return Promise.resolve({ status: "disabled", fontUrl: e, message: "已停用自定义 PDF 字体;内置字体用于西文,其他文字会在导出时校验" });
|
|
1385
|
+
const a = hn.get(e);
|
|
1386
|
+
if (a) return Promise.resolve(a);
|
|
1387
|
+
let n = We.get(e);
|
|
1388
|
+
if (!n) {
|
|
1389
|
+
const r = new AbortController();
|
|
1390
|
+
n = { controller: r, promise: go(e, r), subscribers: 0 };
|
|
1391
|
+
const s = n;
|
|
1392
|
+
We.set(e, s), s.promise = s.promise.then((l) => (!r.signal.aborted && l.status === "available" && hn.set(e, l), l)).finally(() => {
|
|
1393
|
+
We.get(e) === s && We.delete(e);
|
|
1394
|
+
});
|
|
1395
|
+
}
|
|
1396
|
+
const o = n;
|
|
1397
|
+
return o.subscribers++, new Promise((r, s) => {
|
|
1398
|
+
let l = !1;
|
|
1399
|
+
const f = () => l ? !1 : (l = !0, o.subscribers--, t?.removeEventListener("abort", p), !0), p = () => {
|
|
1400
|
+
f() && (o.subscribers === 0 && (We.get(e) === o && We.delete(e), o.controller.abort()), s(mt(t)));
|
|
1401
|
+
};
|
|
1402
|
+
t?.addEventListener("abort", p, { once: !0 }), o.promise.then(
|
|
1403
|
+
(u) => {
|
|
1404
|
+
f() && r(u);
|
|
1405
|
+
},
|
|
1406
|
+
(u) => {
|
|
1407
|
+
f() && s(u);
|
|
1408
|
+
}
|
|
1409
|
+
), t?.aborted && p();
|
|
1410
|
+
});
|
|
1411
|
+
}
|
|
1412
|
+
function ho(e = { fontUrl: "/simhei.ttf" }) {
|
|
1413
|
+
let t = null;
|
|
1414
|
+
const a = async (n, o, r = {}) => {
|
|
1415
|
+
Me(r.signal), t || (t = await import("@agile-team/mach-report/pdf")), Me(r.signal);
|
|
1416
|
+
let s = null;
|
|
1417
|
+
if (e.fontUrl)
|
|
1418
|
+
try {
|
|
1419
|
+
if (s = await Ke(t.loadFontWithCache(e.fontUrl, { strict: !0 }), r.signal), !s?.byteLength) throw new Error("字体文件为空或加载失败");
|
|
1420
|
+
} catch (m) {
|
|
1421
|
+
const g = m instanceof Error ? m.message : String(m);
|
|
1422
|
+
throw qt(Ye(e.fontUrl, g), m);
|
|
1423
|
+
}
|
|
1424
|
+
let l;
|
|
1425
|
+
try {
|
|
1426
|
+
Me(r.signal), l = await t.renderPlanToPdf(n, { ...r, ...s ? { customFontBytes: s } : {} });
|
|
1427
|
+
} catch (m) {
|
|
1428
|
+
if (!s) throw m;
|
|
1429
|
+
const g = m instanceof Error ? m.message : String(m);
|
|
1430
|
+
throw qt(`PDF 生成失败:${g}。当前字体 URL 为 ${JSON.stringify(e.fontUrl)};请确认该文件是有效字体,或重新配置 pdfFontUrl`, m);
|
|
1431
|
+
}
|
|
1432
|
+
Me(r.signal), l.diagnostics?.forEach((m) => {
|
|
1433
|
+
try {
|
|
1434
|
+
r.onDiagnostic?.(m);
|
|
1435
|
+
} catch {
|
|
1436
|
+
}
|
|
1437
|
+
});
|
|
1438
|
+
const { bytes: f, unsupportedTextCount: p, pageErrors: u, fidelityWarnings: i } = l;
|
|
1439
|
+
if (p > 0)
|
|
1440
|
+
throw new Error(`PDF 中有 ${p} 行文字无法编码;请部署支持所用文字的字体并配置 pdfFontUrl`);
|
|
1441
|
+
if (u.length > 0)
|
|
1442
|
+
throw new Error(`PDF 有 ${u.length} 页渲染失败:${u[0]}`);
|
|
1443
|
+
return i.length > 0 && o?.(`PDF 有 ${i.length} 处版式降级:${i.slice(0, 2).join(";")}`), f;
|
|
1444
|
+
};
|
|
1445
|
+
return a.checkFont = (n) => vo(e.fontUrl, n), a;
|
|
1446
|
+
}
|
|
1447
|
+
function bo(e) {
|
|
1448
|
+
const t = ae(Object.freeze({ status: "unchecked", fontUrl: "" }));
|
|
1449
|
+
let a = null, n = null, o = 0, r = null;
|
|
1450
|
+
function s() {
|
|
1451
|
+
if (e.injectedExporter) return e.injectedExporter;
|
|
1452
|
+
const u = e.fontUrl();
|
|
1453
|
+
return (!n || a !== u) && (a = u, n = ho({ fontUrl: u })), n;
|
|
1454
|
+
}
|
|
1455
|
+
function l() {
|
|
1456
|
+
o++, r?.abort(), r = null;
|
|
1457
|
+
}
|
|
1458
|
+
async function f() {
|
|
1459
|
+
if (e.destroyed()) throw new ge("config", "报表预览已卸载");
|
|
1460
|
+
l();
|
|
1461
|
+
const u = o, i = new AbortController();
|
|
1462
|
+
r = i;
|
|
1463
|
+
const m = e.fontUrl();
|
|
1464
|
+
t.value = Object.freeze({ status: "checking", fontUrl: m });
|
|
1465
|
+
try {
|
|
1466
|
+
const g = s(), y = g.checkFont ? await g.checkFont(i.signal) : { status: "unverified", fontUrl: "", message: "自定义 PDF 导出器未提供字体预检查;字体由宿主确认" };
|
|
1467
|
+
return !e.destroyed() && u === o && !i.signal.aborted && (t.value = Object.freeze({ ...y })), y;
|
|
1468
|
+
} catch (g) {
|
|
1469
|
+
if (i.signal.aborted) throw g;
|
|
1470
|
+
const y = { status: "error", fontUrl: m, message: g instanceof Error ? g.message : "PDF 字体检查失败", cause: g };
|
|
1471
|
+
return !e.destroyed() && u === o && (t.value = Object.freeze(y)), y;
|
|
1472
|
+
} finally {
|
|
1473
|
+
r === i && (r = null);
|
|
1474
|
+
}
|
|
1475
|
+
}
|
|
1476
|
+
function p() {
|
|
1477
|
+
f().catch(() => {
|
|
1478
|
+
});
|
|
1479
|
+
}
|
|
1480
|
+
return le([e.plan, A(e.fontUrl), A(e.enabled)], () => {
|
|
1481
|
+
const u = t.value.fontUrl === e.fontUrl();
|
|
1482
|
+
u && t.value.status === "available" || (l(), (!u || t.value.status === "checking") && (t.value = Object.freeze({ status: "unchecked", fontUrl: e.fontUrl() })), !e.destroyed() && e.plan.value?.pages.length && e.enabled() && p());
|
|
1483
|
+
}, { immediate: !0 }), { pdfFont: t, getPdfExporter: s, checkPdfFont: f, retryPdfFont: p, cancelFontCheck: l };
|
|
1484
|
+
}
|
|
1485
|
+
function yo(e) {
|
|
1486
|
+
const t = ae(null), a = ae(!1);
|
|
1487
|
+
let n = 0, o = null;
|
|
1488
|
+
function r(f) {
|
|
1489
|
+
const p = o;
|
|
1490
|
+
o = null, t.value = null, a.value = !1, p?.(f);
|
|
1491
|
+
}
|
|
1492
|
+
function s() {
|
|
1493
|
+
n++, r(!1);
|
|
1494
|
+
}
|
|
1495
|
+
async function l(f) {
|
|
1496
|
+
if (s(), !e.enabled() || !e.pending()) return !0;
|
|
1497
|
+
const p = n, u = [...e.snapshot?.() ?? []];
|
|
1498
|
+
a.value = !0;
|
|
1499
|
+
const i = Object.freeze({ reason: f, reportIds: Object.freeze([...e.reportIds()]), pendingLocalChanges: !0 });
|
|
1500
|
+
try {
|
|
1501
|
+
const m = e.hook(), g = await new Promise((v) => {
|
|
1502
|
+
if (o = v, !m) {
|
|
1503
|
+
t.value = i;
|
|
1504
|
+
return;
|
|
1505
|
+
}
|
|
1506
|
+
Promise.resolve().then(() => m(i)).then((c) => {
|
|
1507
|
+
p === n && r(c === !0);
|
|
1508
|
+
}, (c) => {
|
|
1509
|
+
if (p === n) {
|
|
1510
|
+
try {
|
|
1511
|
+
e.error(c);
|
|
1512
|
+
} catch {
|
|
1513
|
+
}
|
|
1514
|
+
r(!1);
|
|
1515
|
+
}
|
|
1516
|
+
});
|
|
1517
|
+
}), y = e.snapshot?.() ?? [];
|
|
1518
|
+
return p === n && g === !0 && y.length === u.length && u.every((v, c) => Object.is(v, y[c]));
|
|
1519
|
+
} catch (m) {
|
|
1520
|
+
if (p === n) {
|
|
1521
|
+
try {
|
|
1522
|
+
e.error(m);
|
|
1523
|
+
} catch {
|
|
1524
|
+
}
|
|
1525
|
+
r(!1);
|
|
1526
|
+
}
|
|
1527
|
+
return !1;
|
|
1528
|
+
}
|
|
1529
|
+
}
|
|
1530
|
+
return { request: t, pending: a, check: l, settle: r, cancel: s };
|
|
1531
|
+
}
|
|
1532
|
+
let wo = 0;
|
|
1533
|
+
function xo(e) {
|
|
1534
|
+
const t = ae(null), a = /* @__PURE__ */ new Set();
|
|
1535
|
+
let n = null;
|
|
1536
|
+
function o(f) {
|
|
1537
|
+
t.value = Object.freeze(f);
|
|
1538
|
+
try {
|
|
1539
|
+
e(t.value);
|
|
1540
|
+
} catch {
|
|
1541
|
+
}
|
|
1542
|
+
}
|
|
1543
|
+
function r(f, p, u) {
|
|
1544
|
+
const i = `mr-task-${Date.now().toString(36)}-${++wo}`;
|
|
1545
|
+
a.add(i), n = u, o({ taskId: i, kind: f, stage: p, status: "running", cancellable: !0 });
|
|
1546
|
+
function m(y, v, c) {
|
|
1547
|
+
t.value?.taskId !== i || t.value.status !== "running" || o({ ...t.value, stage: y, completed: v, total: c });
|
|
1548
|
+
}
|
|
1549
|
+
function g(y = "completed") {
|
|
1550
|
+
t.value?.taskId !== i || t.value.status !== "running" || (n = null, o({ ...t.value, status: y, cancellable: !1 }));
|
|
1551
|
+
}
|
|
1552
|
+
return { taskId: i, update: m, finish: g };
|
|
1553
|
+
}
|
|
1554
|
+
function s() {
|
|
1555
|
+
if (t.value?.status !== "running") return;
|
|
1556
|
+
const f = n;
|
|
1557
|
+
n = null, o({ ...t.value, status: "cancelled", cancellable: !1 }), f?.();
|
|
1558
|
+
}
|
|
1559
|
+
function l(f, p) {
|
|
1560
|
+
t.value?.taskId !== f.taskId && (f.status !== "running" || a.has(f.taskId)) || (a.add(f.taskId), a.size > 100 && a.delete(a.values().next().value), n = f.status === "running" ? p : null, o({ ...f }));
|
|
1561
|
+
}
|
|
1562
|
+
return { state: t, start: r, cancel: s, receive: l };
|
|
1563
|
+
}
|
|
1564
|
+
function ko(e) {
|
|
1565
|
+
const t = ae(Object.freeze([])), a = /* @__PURE__ */ new Set();
|
|
1566
|
+
let n = 0;
|
|
1567
|
+
function o() {
|
|
1568
|
+
n++, t.value = Object.freeze([]), a.clear();
|
|
1569
|
+
}
|
|
1570
|
+
function r(f) {
|
|
1571
|
+
const p = n, u = [];
|
|
1572
|
+
for (const i of f) {
|
|
1573
|
+
const m = JSON.stringify([i.code, i.format, i.pageIndex, i.componentIndex, i.componentPath, i.path, i.message]);
|
|
1574
|
+
if (a.has(m)) continue;
|
|
1575
|
+
a.add(m);
|
|
1576
|
+
const g = Object.freeze({ ...i, ...i.componentPath ? { componentPath: Object.freeze([...i.componentPath]) } : {} });
|
|
1577
|
+
u.push(g);
|
|
1578
|
+
}
|
|
1579
|
+
u.length && (t.value = Object.freeze([...t.value, ...u]));
|
|
1580
|
+
for (const i of u) {
|
|
1581
|
+
if (p !== n) break;
|
|
1582
|
+
try {
|
|
1583
|
+
e(i);
|
|
1584
|
+
} catch {
|
|
1585
|
+
}
|
|
1586
|
+
}
|
|
1587
|
+
}
|
|
1588
|
+
function s(f) {
|
|
1589
|
+
r([f]);
|
|
1590
|
+
}
|
|
1591
|
+
function l(f, p) {
|
|
1592
|
+
const u = Ea(f, p);
|
|
1593
|
+
return r(u), u;
|
|
1594
|
+
}
|
|
1595
|
+
return { entries: t, reset: o, add: s, addMany: r, inspect: l };
|
|
1596
|
+
}
|
|
1597
|
+
let Io = 0;
|
|
1598
|
+
function Eo() {
|
|
1599
|
+
return `mrp-params-${++Io}`;
|
|
1600
|
+
}
|
|
1601
|
+
function Fn(e, t, a) {
|
|
1602
|
+
const n = (Array.isArray(t) ? t.find((o) => o?.field === e.field)?.label : void 0) ?? e.field;
|
|
1603
|
+
return e.code === "required" ? a.paramRequired.replace("{label}", n) : (a.paramInvalid ?? "{label}:{message}").replace("{label}", n).replace("{message}", e.message);
|
|
1604
|
+
}
|
|
1605
|
+
function Co(e) {
|
|
1606
|
+
const t = J({}), a = J(!1);
|
|
1607
|
+
function n() {
|
|
1608
|
+
const l = {};
|
|
1609
|
+
for (const f of Array.isArray(e.defs.value) ? e.defs.value : [])
|
|
1610
|
+
typeof f?.field == "string" && Object.defineProperty(l, f.field, { value: e.params()[f.field] ?? f.defaultValue ?? "", writable: !0, enumerable: !0, configurable: !0 });
|
|
1611
|
+
t.value = l, a.value = !1;
|
|
1612
|
+
}
|
|
1613
|
+
n(), le(e.defs, n), le(e.reportIds, n), le(() => JSON.stringify(e.params()), n);
|
|
1614
|
+
const o = A(() => $n(e.defs.value, { ...e.params(), ...t.value })), r = A(() => !a.value && o.value.issues.length > 0 && o.value.issues.every((l) => l.code === "required"));
|
|
1615
|
+
function s() {
|
|
1616
|
+
const l = o.value;
|
|
1617
|
+
if (!l.ok) {
|
|
1618
|
+
const u = l.issues[0];
|
|
1619
|
+
return { quiet: r.value, error: new ge(u.code === "definition" ? "config" : "param", Fn(u, e.defs.value, e.messages()), { issues: l.issues }) };
|
|
1620
|
+
}
|
|
1621
|
+
const f = { ...l.values }, p = new Set(e.defs.value.filter((u) => u.defaultValue !== void 0).map((u) => u.field));
|
|
1622
|
+
for (const [u, i] of Object.entries(f)) i === "" && !p.has(u) && delete f[u];
|
|
1623
|
+
return { params: f, quiet: !1 };
|
|
1624
|
+
}
|
|
1625
|
+
return { values: t, attempted: a, validation: o, pendingRequired: r, reset: n, query: s };
|
|
1626
|
+
}
|
|
1627
|
+
const $o = { class: "mrp-params-title" }, Po = { class: "mrp-params-grid" }, So = ["id"], Ro = {
|
|
1628
|
+
key: 0,
|
|
1629
|
+
class: "mrp-param-star"
|
|
1630
|
+
}, Mo = ["value", "aria-labelledby", "aria-invalid", "aria-describedby", "aria-required", "onChange"], To = ["disabled", "hidden"], Fo = ["value"], Do = ["type", "placeholder", "value", "min", "max", "step", "aria-labelledby", "aria-invalid", "aria-describedby", "aria-required", "onInput"], Oo = ["id"], Ao = { class: "mrp-params-actions" }, Lo = /* @__PURE__ */ xe({
|
|
1631
|
+
__name: "ReportParamPanel",
|
|
1632
|
+
props: {
|
|
1633
|
+
defs: {},
|
|
1634
|
+
modelValue: {},
|
|
1635
|
+
messages: {},
|
|
1636
|
+
attempted: { type: Boolean },
|
|
1637
|
+
issues: {}
|
|
1638
|
+
},
|
|
1639
|
+
emits: ["update:modelValue", "query", "reset"],
|
|
1640
|
+
setup(e, { expose: t, emit: a }) {
|
|
1641
|
+
const n = e, o = a, r = J({ ...n.modelValue }), s = J(null), l = Eo();
|
|
1642
|
+
le(
|
|
1643
|
+
() => n.modelValue,
|
|
1644
|
+
(g) => {
|
|
1645
|
+
r.value = { ...g };
|
|
1646
|
+
}
|
|
1647
|
+
);
|
|
1648
|
+
const f = A(() => n.issues ?? $n(n.defs, r.value).issues), p = A(
|
|
1649
|
+
() => (Array.isArray(n.defs) ? n.defs : []).filter((g) => g && typeof g.field == "string").map((g, y) => ({
|
|
1650
|
+
def: g,
|
|
1651
|
+
id: `${l}-${y}`,
|
|
1652
|
+
label: g.label ?? g.field,
|
|
1653
|
+
value: r.value[g.field] ?? "",
|
|
1654
|
+
error: n.attempted ? f.value.find((v) => v.field === g.field) : void 0
|
|
1655
|
+
}))
|
|
1656
|
+
);
|
|
1657
|
+
function u(g, y) {
|
|
1658
|
+
r.value = { ...r.value, [g]: y }, o("update:modelValue", { ...r.value });
|
|
1659
|
+
}
|
|
1660
|
+
function i(g) {
|
|
1661
|
+
g.isComposing || o("query");
|
|
1662
|
+
}
|
|
1663
|
+
function m() {
|
|
1664
|
+
s.value?.querySelector('[aria-invalid="true"]')?.focus();
|
|
1665
|
+
}
|
|
1666
|
+
return t({ focusInvalid: m }), (g, y) => (I(), P("div", {
|
|
1667
|
+
ref_key: "root",
|
|
1668
|
+
ref: s,
|
|
1669
|
+
class: "mrp-params"
|
|
1670
|
+
}, [
|
|
1671
|
+
R("span", $o, C(e.messages.paramsTitle), 1),
|
|
1672
|
+
R("div", Po, [
|
|
1673
|
+
(I(!0), P(fe, null, pe(p.value, (v) => (I(), P("label", {
|
|
1674
|
+
key: v.id,
|
|
1675
|
+
class: ye(["mrp-param", { "mrp-param-missing": !!v.error }])
|
|
1676
|
+
}, [
|
|
1677
|
+
R("span", {
|
|
1678
|
+
id: `${v.id}-label`,
|
|
1679
|
+
class: "mrp-param-label"
|
|
1680
|
+
}, [
|
|
1681
|
+
we(C(v.label), 1),
|
|
1682
|
+
v.def.required ? (I(), P("i", Ro, "*")) : j("", !0)
|
|
1683
|
+
], 8, So),
|
|
1684
|
+
(v.def.type ?? "text") === "select" ? (I(), P("select", {
|
|
1685
|
+
key: 0,
|
|
1686
|
+
class: "mrp-param-input",
|
|
1687
|
+
value: v.value,
|
|
1688
|
+
"aria-labelledby": `${v.id}-label`,
|
|
1689
|
+
"aria-invalid": v.error ? !0 : void 0,
|
|
1690
|
+
"aria-describedby": v.error ? `${v.id}-error` : void 0,
|
|
1691
|
+
"aria-required": v.def.required || void 0,
|
|
1692
|
+
onChange: (c) => u(v.def.field, c.target.value),
|
|
1693
|
+
onKeydown: At(i, ["enter"])
|
|
1694
|
+
}, [
|
|
1695
|
+
R("option", {
|
|
1696
|
+
value: "",
|
|
1697
|
+
disabled: v.def.required,
|
|
1698
|
+
hidden: v.def.required
|
|
1699
|
+
}, C(v.def.placeholder ?? (e.messages.paramSelectPlaceholder ?? "请选择{label}").replace("{label}", v.label)), 9, To),
|
|
1700
|
+
(I(!0), P(fe, null, pe(v.def.options ?? [], (c) => (I(), P("option", {
|
|
1701
|
+
key: c.value,
|
|
1702
|
+
value: c.value
|
|
1703
|
+
}, C(c.label), 9, Fo))), 128))
|
|
1704
|
+
], 40, Mo)) : (I(), P("input", {
|
|
1705
|
+
key: 1,
|
|
1706
|
+
class: "mrp-param-input",
|
|
1707
|
+
type: v.def.type === "number" ? "number" : v.def.type === "date" ? "date" : "text",
|
|
1708
|
+
placeholder: v.def.placeholder ?? (e.messages.paramTextPlaceholder ?? "请输入{label}").replace("{label}", v.label),
|
|
1709
|
+
value: v.value,
|
|
1710
|
+
min: v.def.min,
|
|
1711
|
+
max: v.def.max,
|
|
1712
|
+
step: v.def.type === "number" ? "any" : void 0,
|
|
1713
|
+
"aria-labelledby": `${v.id}-label`,
|
|
1714
|
+
"aria-invalid": v.error ? !0 : void 0,
|
|
1715
|
+
"aria-describedby": v.error ? `${v.id}-error` : void 0,
|
|
1716
|
+
"aria-required": v.def.required || void 0,
|
|
1717
|
+
onInput: (c) => u(v.def.field, c.target.value),
|
|
1718
|
+
onKeydown: At(i, ["enter"])
|
|
1719
|
+
}, null, 40, Do)),
|
|
1720
|
+
v.error ? (I(), P("small", {
|
|
1721
|
+
key: 2,
|
|
1722
|
+
id: `${v.id}-error`,
|
|
1723
|
+
class: "mrp-param-error",
|
|
1724
|
+
role: "status"
|
|
1725
|
+
}, C(b(Fn)(v.error, e.defs, e.messages)), 9, Oo)) : j("", !0)
|
|
1726
|
+
], 2))), 128))
|
|
1727
|
+
]),
|
|
1728
|
+
R("div", Ao, [
|
|
1729
|
+
R("button", {
|
|
1730
|
+
class: "mrp-nav mrp-param-query",
|
|
1731
|
+
type: "button",
|
|
1732
|
+
onClick: y[0] || (y[0] = (v) => g.$emit("query"))
|
|
1733
|
+
}, C(e.messages.query), 1),
|
|
1734
|
+
R("button", {
|
|
1735
|
+
class: "mrp-nav",
|
|
1736
|
+
type: "button",
|
|
1737
|
+
onClick: y[1] || (y[1] = (v) => g.$emit("reset"))
|
|
1738
|
+
}, C(e.messages.reset), 1)
|
|
1739
|
+
])
|
|
1740
|
+
], 512));
|
|
1741
|
+
}
|
|
1742
|
+
}), zo = /* @__PURE__ */ ke(Lo, [["__scopeId", "data-v-156737bc"]]), qo = { class: "mrp-edit-bar" }, Bo = ["disabled"], jo = ["disabled"], No = { class: "mrp-changes" }, Wo = ["aria-label"], Ho = { key: 0 }, Ko = { key: 1 }, Uo = ["onClick"], Vo = ["title"], Go = ["title"], Jo = ["disabled"], Zo = {
|
|
1743
|
+
key: 0,
|
|
1744
|
+
role: "status"
|
|
1745
|
+
}, Yo = {
|
|
1746
|
+
key: 1,
|
|
1747
|
+
role: "status"
|
|
1748
|
+
}, Xo = {
|
|
1749
|
+
key: 2,
|
|
1750
|
+
class: "mrp-conflicts",
|
|
1751
|
+
open: ""
|
|
1752
|
+
}, Qo = /* @__PURE__ */ xe({
|
|
1753
|
+
__name: "ReportEditBar",
|
|
1754
|
+
props: {
|
|
1755
|
+
differences: {},
|
|
1756
|
+
conflicts: {},
|
|
1757
|
+
messages: {},
|
|
1758
|
+
saving: { type: Boolean },
|
|
1759
|
+
canUndo: { type: Boolean },
|
|
1760
|
+
canRedo: { type: Boolean },
|
|
1761
|
+
busy: { type: Boolean },
|
|
1762
|
+
persisted: { type: Boolean }
|
|
1763
|
+
},
|
|
1764
|
+
emits: ["undo", "redo", "restore", "locate"],
|
|
1765
|
+
setup(e) {
|
|
1766
|
+
function t(a) {
|
|
1767
|
+
return a.source ? `${a.source.rowKey} · ${a.source.field}` : `${a.address.pageIndex + 1} / ${a.address.rowIndex + 1}:${a.address.columnIndex + 1}`;
|
|
1768
|
+
}
|
|
1769
|
+
return (a, n) => (I(), P("div", qo, [
|
|
1770
|
+
R("button", {
|
|
1771
|
+
type: "button",
|
|
1772
|
+
disabled: e.busy || e.saving || !e.canUndo,
|
|
1773
|
+
onClick: n[0] || (n[0] = (o) => a.$emit("undo"))
|
|
1774
|
+
}, C(e.messages.undo), 9, Bo),
|
|
1775
|
+
R("button", {
|
|
1776
|
+
type: "button",
|
|
1777
|
+
disabled: e.busy || e.saving || !e.canRedo,
|
|
1778
|
+
onClick: n[1] || (n[1] = (o) => a.$emit("redo"))
|
|
1779
|
+
}, C(e.messages.redo), 9, jo),
|
|
1780
|
+
R("details", No, [
|
|
1781
|
+
R("summary", null, C(e.messages.changes) + " · " + C(e.messages.changesCount?.replace("{count}", String(e.differences.length))), 1),
|
|
1782
|
+
R("section", {
|
|
1783
|
+
"aria-label": e.messages.changes
|
|
1784
|
+
}, [
|
|
1785
|
+
e.differences.length ? (I(), P("ol", Ko, [
|
|
1786
|
+
(I(!0), P(fe, null, pe(e.differences, (o, r) => (I(), P("li", { key: r }, [
|
|
1787
|
+
R("button", {
|
|
1788
|
+
type: "button",
|
|
1789
|
+
onClick: (s) => a.$emit("locate", o)
|
|
1790
|
+
}, C(t(o)), 9, Uo),
|
|
1791
|
+
R("span", null, [
|
|
1792
|
+
R("s", {
|
|
1793
|
+
title: e.messages.changesBefore
|
|
1794
|
+
}, C(o.previousText || "∅"), 9, Vo),
|
|
1795
|
+
n[3] || (n[3] = we(" → ", -1)),
|
|
1796
|
+
R("strong", {
|
|
1797
|
+
title: e.messages.changesAfter
|
|
1798
|
+
}, C(o.text || "∅"), 9, Go)
|
|
1799
|
+
])
|
|
1800
|
+
]))), 128))
|
|
1801
|
+
])) : (I(), P("p", Ho, C(e.messages.changesEmpty), 1))
|
|
1802
|
+
], 8, Wo)
|
|
1803
|
+
]),
|
|
1804
|
+
R("button", {
|
|
1805
|
+
type: "button",
|
|
1806
|
+
disabled: e.busy || e.saving || !e.differences.length,
|
|
1807
|
+
onClick: n[2] || (n[2] = (o) => a.$emit("restore"))
|
|
1808
|
+
}, C(e.messages.restoreChanges), 9, Jo),
|
|
1809
|
+
e.saving ? (I(), P("span", Zo, C(e.messages.saving), 1)) : e.differences.length && !e.conflicts.length ? (I(), P("span", Yo, C(e.persisted ? e.messages.editSaved : e.messages.editingLocal), 1)) : j("", !0),
|
|
1810
|
+
e.conflicts.length ? (I(), P("details", Xo, [
|
|
1811
|
+
R("summary", null, C(e.messages.conflicts) + " · " + C(e.conflicts.length), 1),
|
|
1812
|
+
R("ul", null, [
|
|
1813
|
+
(I(!0), P(fe, null, pe(e.conflicts, (o, r) => (I(), P("li", { key: r }, C(o.message), 1))), 128))
|
|
1814
|
+
])
|
|
1815
|
+
])) : j("", !0)
|
|
1816
|
+
]));
|
|
1817
|
+
}
|
|
1818
|
+
}), _o = /* @__PURE__ */ ke(Qo, [["__scopeId", "data-v-df1c7b86"]]);
|
|
1819
|
+
function es(e) {
|
|
1820
|
+
const t = e.table?.columnKeys ?? [], a = t.map(() => []);
|
|
1821
|
+
if (!e.grid) return t;
|
|
1822
|
+
for (const { ci: n, cell: o } of Sn(e.grid, e.widthMm, e.heightMm).cells) {
|
|
1823
|
+
const r = (o.text ?? o.rawText ?? "").trim();
|
|
1824
|
+
if (r)
|
|
1825
|
+
for (let s = n; s < Math.min(t.length, n + (o.colSpan ?? 1)); s++)
|
|
1826
|
+
a[s].includes(r) || a[s].push(r);
|
|
1827
|
+
}
|
|
1828
|
+
return t.map((n, o) => a[o].join(" / ") || n);
|
|
1829
|
+
}
|
|
1830
|
+
function ts(e, t = []) {
|
|
1831
|
+
const a = /* @__PURE__ */ new Set(), n = [];
|
|
1832
|
+
for (const [o, r] of (e?.pages ?? []).entries())
|
|
1833
|
+
for (const s of r.components) {
|
|
1834
|
+
const l = s.table;
|
|
1835
|
+
if (!l || l.role !== "header" || a.has(l.id)) continue;
|
|
1836
|
+
a.add(l.id);
|
|
1837
|
+
const f = es(s), p = t.filter((g) => g.pageIndex <= o), u = p[p.length - 1]?.label, i = l.source?.datasetId, m = [...new Set([u, l.title, i].filter(Boolean))].join(" · ") || l.id;
|
|
1838
|
+
l.columnKeys.forEach((g, y) => {
|
|
1839
|
+
g && n.push({ key: JSON.stringify([l.id, y]), field: g, label: f[y], group: m, pageIndex: o, tableId: l.id, ...i ? { datasetId: i } : {} });
|
|
1840
|
+
});
|
|
1841
|
+
}
|
|
1842
|
+
return n;
|
|
1843
|
+
}
|
|
1844
|
+
function ns(e, t) {
|
|
1845
|
+
const a = t.trim().toLocaleLowerCase().split(/\s+/).filter(Boolean);
|
|
1846
|
+
return e.filter((n) => {
|
|
1847
|
+
const o = `${n.label} ${n.field} ${n.group}`.toLocaleLowerCase();
|
|
1848
|
+
return a.every((r) => o.includes(r));
|
|
1849
|
+
});
|
|
1850
|
+
}
|
|
1851
|
+
const as = ["aria-label"], rs = {
|
|
1852
|
+
key: 0,
|
|
1853
|
+
class: "mrp-section-tabs"
|
|
1854
|
+
}, os = ["disabled", "onClick"], ss = ["aria-expanded", "disabled"], ls = ["aria-label", "placeholder", "disabled"], is = ["disabled"], us = ["aria-label"], cs = {
|
|
1855
|
+
key: 0,
|
|
1856
|
+
role: "status"
|
|
1857
|
+
}, ds = ["aria-label"], fs = ["disabled", "onClick"], ms = /* @__PURE__ */ xe({
|
|
1858
|
+
__name: "ReportNavigation",
|
|
1859
|
+
props: {
|
|
1860
|
+
sections: {},
|
|
1861
|
+
currentPage: {},
|
|
1862
|
+
messages: {},
|
|
1863
|
+
busy: { type: Boolean },
|
|
1864
|
+
plan: {}
|
|
1865
|
+
},
|
|
1866
|
+
emits: ["goto", "locate", "locate-target"],
|
|
1867
|
+
setup(e, { emit: t }) {
|
|
1868
|
+
const a = e, n = t, o = J(""), r = J(!1), s = A(() => ({ columnDirectory: "字段目录", columnSearch: "搜索列名或字段", columnNoMatches: "未找到匹配字段", columnResults: "匹配字段", ...a.messages })), l = A(() => ts(a.plan, a.sections)), f = A(() => ns(l.value, o.value)), p = A(() => [...new Set(f.value.map((g) => g.group))]);
|
|
1869
|
+
function u(g) {
|
|
1870
|
+
n("locate-target", g), r.value = !1;
|
|
1871
|
+
}
|
|
1872
|
+
function i() {
|
|
1873
|
+
f.value.length === 1 ? u(f.value[0]) : n("locate", o.value.trim());
|
|
1874
|
+
}
|
|
1875
|
+
function m(g) {
|
|
1876
|
+
(!(g.relatedTarget instanceof Node) || !g.currentTarget.contains(g.relatedTarget)) && (r.value = !1);
|
|
1877
|
+
}
|
|
1878
|
+
return (g, y) => (I(), P("nav", {
|
|
1879
|
+
class: "mrp-section-nav",
|
|
1880
|
+
"aria-label": e.messages.sections
|
|
1881
|
+
}, [
|
|
1882
|
+
e.sections.length > 1 ? (I(), P("div", rs, [
|
|
1883
|
+
(I(!0), P(fe, null, pe(e.sections, (v, c) => (I(), P("button", {
|
|
1884
|
+
key: c,
|
|
1885
|
+
type: "button",
|
|
1886
|
+
class: ye({ active: e.currentPage >= v.pageIndex + 1 && (!e.sections[c + 1] || e.currentPage <= e.sections[c + 1].pageIndex) }),
|
|
1887
|
+
disabled: e.busy,
|
|
1888
|
+
onClick: (T) => n("goto", v.pageIndex + 1)
|
|
1889
|
+
}, C(v.label), 11, os))), 128))
|
|
1890
|
+
])) : j("", !0),
|
|
1891
|
+
R("div", {
|
|
1892
|
+
class: "mrp-column-locator",
|
|
1893
|
+
onKeydown: y[4] || (y[4] = At((v) => r.value = !1, ["esc"])),
|
|
1894
|
+
onFocusout: m
|
|
1895
|
+
}, [
|
|
1896
|
+
R("form", {
|
|
1897
|
+
onSubmit: ut(i, ["prevent"])
|
|
1898
|
+
}, [
|
|
1899
|
+
l.value.length ? (I(), P("button", {
|
|
1900
|
+
key: 0,
|
|
1901
|
+
type: "button",
|
|
1902
|
+
"aria-expanded": r.value,
|
|
1903
|
+
disabled: e.busy,
|
|
1904
|
+
onClick: y[0] || (y[0] = (v) => r.value = !r.value)
|
|
1905
|
+
}, [
|
|
1906
|
+
we(C(s.value.columnDirectory) + " ", 1),
|
|
1907
|
+
R("span", null, C(l.value.length), 1)
|
|
1908
|
+
], 8, ss)) : j("", !0),
|
|
1909
|
+
kn(R("input", {
|
|
1910
|
+
"onUpdate:modelValue": y[1] || (y[1] = (v) => o.value = v),
|
|
1911
|
+
type: "search",
|
|
1912
|
+
"aria-label": e.messages.locateField,
|
|
1913
|
+
placeholder: l.value.length ? s.value.columnSearch : e.messages.locateFieldPlaceholder,
|
|
1914
|
+
disabled: e.busy,
|
|
1915
|
+
onInput: y[2] || (y[2] = (v) => r.value = l.value.length > 0)
|
|
1916
|
+
}, null, 40, ls), [
|
|
1917
|
+
[In, o.value]
|
|
1918
|
+
]),
|
|
1919
|
+
R("button", {
|
|
1920
|
+
type: "submit",
|
|
1921
|
+
disabled: e.busy || !o.value.trim()
|
|
1922
|
+
}, C(e.messages.locateField), 9, is)
|
|
1923
|
+
], 32),
|
|
1924
|
+
r.value && l.value.length ? (I(), P("div", {
|
|
1925
|
+
key: 0,
|
|
1926
|
+
class: "mrp-column-directory",
|
|
1927
|
+
"aria-label": s.value.columnResults
|
|
1928
|
+
}, [
|
|
1929
|
+
f.value.length ? j("", !0) : (I(), P("p", cs, C(s.value.columnNoMatches), 1)),
|
|
1930
|
+
(I(!0), P(fe, null, pe(p.value, (v) => (I(), P("section", {
|
|
1931
|
+
key: v,
|
|
1932
|
+
"aria-label": v
|
|
1933
|
+
}, [
|
|
1934
|
+
R("strong", null, C(v), 1),
|
|
1935
|
+
(I(!0), P(fe, null, pe(f.value.filter((c) => c.group === v), (c) => (I(), P("button", {
|
|
1936
|
+
key: c.key,
|
|
1937
|
+
type: "button",
|
|
1938
|
+
disabled: e.busy,
|
|
1939
|
+
onMousedown: y[3] || (y[3] = ut(() => {
|
|
1940
|
+
}, ["prevent"])),
|
|
1941
|
+
onClick: (T) => u(c)
|
|
1942
|
+
}, [
|
|
1943
|
+
R("span", null, C(c.label), 1),
|
|
1944
|
+
R("code", null, C(c.field), 1)
|
|
1945
|
+
], 40, fs))), 128))
|
|
1946
|
+
], 8, ds))), 128))
|
|
1947
|
+
], 8, us)) : j("", !0)
|
|
1948
|
+
], 32)
|
|
1949
|
+
], 8, as));
|
|
1950
|
+
}
|
|
1951
|
+
}), ps = /* @__PURE__ */ ke(ms, [["__scopeId", "data-v-3a2eb8c8"]]), gs = { class: "mrp-import-summary" }, vs = { key: 0 }, hs = { key: 0 }, bs = /* @__PURE__ */ xe({
|
|
1952
|
+
__name: "ReportImportSummary",
|
|
1953
|
+
props: {
|
|
1954
|
+
result: {},
|
|
1955
|
+
messages: {}
|
|
1956
|
+
},
|
|
1957
|
+
setup(e) {
|
|
1958
|
+
return (t, a) => (I(), P("details", gs, [
|
|
1959
|
+
R("summary", null, [
|
|
1960
|
+
we(C(e.messages.importSummary) + " · " + C(e.messages.importPreserved?.replace("{sheets}", String(e.result.sheets.length))) + " ", 1),
|
|
1961
|
+
e.result.warnings.length ? (I(), P("span", vs, " · " + C(e.result.warnings.length) + " " + C(e.messages.importWarnings), 1)) : j("", !0)
|
|
1962
|
+
]),
|
|
1963
|
+
R("p", null, C(e.messages.importReadOnly), 1),
|
|
1964
|
+
R("ul", null, [
|
|
1965
|
+
(I(!0), P(fe, null, pe(e.result.sheets, (n) => (I(), P("li", {
|
|
1966
|
+
key: n.index
|
|
1967
|
+
}, C(n.name) + " · " + C(n.range) + " · " + C(n.rowCount) + " × " + C(n.columnCount), 1))), 128))
|
|
1968
|
+
]),
|
|
1969
|
+
e.result.warnings.length ? (I(), P("ul", hs, [
|
|
1970
|
+
(I(!0), P(fe, null, pe(e.result.warnings, (n, o) => (I(), P("li", { key: o }, C(n), 1))), 128))
|
|
1971
|
+
])) : j("", !0)
|
|
1972
|
+
]));
|
|
1973
|
+
}
|
|
1974
|
+
}), ys = /* @__PURE__ */ ke(bs, [["__scopeId", "data-v-54f275e8"]]), ws = {
|
|
1975
|
+
title: "报表预览",
|
|
1976
|
+
prevPage: "‹ 上一页",
|
|
1977
|
+
nextPage: "下一页 ›",
|
|
1978
|
+
pageInfo: "{cur} / {total}",
|
|
1979
|
+
fitWidth: "适宽",
|
|
1980
|
+
exportHtml: "导出 HTML",
|
|
1981
|
+
exportPdf: "导出 PDF",
|
|
1982
|
+
exportExcel: "导出 Excel",
|
|
1983
|
+
exportImage: "导出图片",
|
|
1984
|
+
exportWord: "导出 Word",
|
|
1985
|
+
exporting: "正在生成 {format}…",
|
|
1986
|
+
print: "打印",
|
|
1987
|
+
pdfWindow: "PDF 窗口",
|
|
1988
|
+
loading: "报表渲染中…",
|
|
1989
|
+
empty: "暂无预览数据",
|
|
1990
|
+
errorPrefix: "",
|
|
1991
|
+
retry: "重试",
|
|
1992
|
+
pdfFontUnavailable: "PDF 字体尚未就绪,请联系管理员检查字体配置;预览及其它导出仍可使用。",
|
|
1993
|
+
searchPlaceholder: "搜索报表内容",
|
|
1994
|
+
matchInfo: "{cur}/{total}",
|
|
1995
|
+
prevMatch: "‹",
|
|
1996
|
+
nextMatch: "›",
|
|
1997
|
+
thumbnails: "缩略图",
|
|
1998
|
+
paramsTitle: "查询条件",
|
|
1999
|
+
query: "查 询",
|
|
2000
|
+
reset: "重 置",
|
|
2001
|
+
paramRequired: "请填写{label}",
|
|
2002
|
+
paramInvalid: "{label}:{message}",
|
|
2003
|
+
paramPrompt: "请先完善查询条件",
|
|
2004
|
+
paramPromptDescription: "填写必填条件后点击查询,即可生成报表。",
|
|
2005
|
+
paramSelectPlaceholder: "请选择{label}",
|
|
2006
|
+
paramTextPlaceholder: "请输入{label}",
|
|
2007
|
+
searching: "搜索中…",
|
|
2008
|
+
importExcel: "导入 Excel 模板",
|
|
2009
|
+
importing: "正在导入 Excel…",
|
|
2010
|
+
editCell: "编辑单元格",
|
|
2011
|
+
editingHint: "双击单元格编辑 · Enter 确认 · Esc 取消",
|
|
2012
|
+
saving: "正在保存修改…",
|
|
2013
|
+
editInvalidNumber: "请输入有效数字;清空表示无值",
|
|
2014
|
+
editInvalidBoolean: "请输入 true / false、是 / 否或 1 / 0",
|
|
2015
|
+
editConflict: "该单元格已变化,请重新打开编辑",
|
|
2016
|
+
settings: "设置",
|
|
2017
|
+
settingsDisplay: "阅读工具",
|
|
2018
|
+
settingsExport: "导出与打印",
|
|
2019
|
+
settingsData: "数据操作",
|
|
2020
|
+
settingsUnavailable: "需由接入方配置启用",
|
|
2021
|
+
settingsReset: "恢复默认",
|
|
2022
|
+
settingsClose: "关闭设置",
|
|
2023
|
+
search: "内容搜索",
|
|
2024
|
+
closeSearch: "关闭搜索",
|
|
2025
|
+
prevSearchMatch: "上一个匹配",
|
|
2026
|
+
nextSearchMatch: "下一个匹配",
|
|
2027
|
+
zoom: "缩放工具",
|
|
2028
|
+
settingsLocal: "按需启用工具,仅作用于当前预览。",
|
|
2029
|
+
editingLocal: "修改为本地草稿;不会自动写入业务数据库。",
|
|
2030
|
+
editingSaved: "修改将通过接入方配置的保存回调提交。",
|
|
2031
|
+
importLocal: "导入仅生成本地预览,不自动替换业务数据。",
|
|
2032
|
+
emptyDescription: "当前查询没有明细,请调整查询条件后重试。",
|
|
2033
|
+
undo: "撤销",
|
|
2034
|
+
redo: "重做",
|
|
2035
|
+
restoreChanges: "恢复来源值",
|
|
2036
|
+
changes: "修改明细",
|
|
2037
|
+
changesCount: "{count} 处修改",
|
|
2038
|
+
changesEmpty: "尚无修改",
|
|
2039
|
+
changesBefore: "来源值",
|
|
2040
|
+
changesAfter: "当前值",
|
|
2041
|
+
editAtomicRequired: "批量保存需要接入方提供原子 saveBatch 回调;本次未写入任何单元格。",
|
|
2042
|
+
clipboardLimit: "单次最多粘贴 10000 个单元格,请分批处理。",
|
|
2043
|
+
preferencesError: "偏好存储不可用,设置仍在当前预览中生效。",
|
|
2044
|
+
freezeHeaders: "冻结表头",
|
|
2045
|
+
frozenColumns: "冻结前列",
|
|
2046
|
+
sections: "工作表与章节",
|
|
2047
|
+
locateField: "定位字段",
|
|
2048
|
+
locateFieldPlaceholder: "输入字段标识,Enter 定位",
|
|
2049
|
+
locateFieldMissing: "未找到该字段,请核对字段标识。",
|
|
2050
|
+
importSummary: "Excel 导入摘要",
|
|
2051
|
+
importPreserved: "已导入 {sheets} 个工作表,保留内容、合并和样式。",
|
|
2052
|
+
importWarnings: "兼容性提示",
|
|
2053
|
+
importReadOnly: "公式、日期及受保护单元格保持只读;公式不重算。",
|
|
2054
|
+
conflicts: "保存冲突",
|
|
2055
|
+
editReadOnly: "选区包含只读或无权限单元格,本次修改未应用。",
|
|
2056
|
+
editMissing: "选区超出报表范围或缺少业务来源,请重新选择。",
|
|
2057
|
+
editDuplicate: "选区包含同一业务字段的重复单元格,请缩小选区。",
|
|
2058
|
+
clipboardInvalid: "剪贴板内容无法识别,请使用矩形表格文本重新粘贴。",
|
|
2059
|
+
editSaved: "修改已通过保存回调确认",
|
|
2060
|
+
settingsPanes: "冻结窗格",
|
|
2061
|
+
columnDirectory: "字段目录",
|
|
2062
|
+
columnSearch: "搜索列名或字段",
|
|
2063
|
+
columnNoMatches: "未找到匹配字段",
|
|
2064
|
+
columnResults: "匹配字段",
|
|
2065
|
+
columnGroup: "明细区域",
|
|
2066
|
+
discardTitle: "保留当前修改?",
|
|
2067
|
+
discardDescription: "当前报表有尚未保存的输入或本地草稿,继续操作将替换这些内容。",
|
|
2068
|
+
discardKeep: "继续编辑",
|
|
2069
|
+
discardProceed: "放弃修改并继续",
|
|
2070
|
+
taskQuery: "正在获取数据…",
|
|
2071
|
+
taskValidate: "正在校验数据…",
|
|
2072
|
+
taskLayout: "正在生成版式…",
|
|
2073
|
+
taskAssets: "正在准备图片和字体…",
|
|
2074
|
+
taskEncode: "正在生成文件…",
|
|
2075
|
+
taskDownload: "正在准备下载…",
|
|
2076
|
+
taskPrint: "正在准备打印…",
|
|
2077
|
+
taskCancel: "取消任务",
|
|
2078
|
+
taskCancelled: "任务已取消,可重新操作。",
|
|
2079
|
+
diagnosticsSearch: "搜索提示、错误码或位置",
|
|
2080
|
+
diagnosticsMore: "共 {count} 条匹配,当前展示前 100 条;请搜索缩小范围。",
|
|
2081
|
+
diagnosticsTitle: "输出兼容性提示",
|
|
2082
|
+
diagnosticsLocate: "定位",
|
|
2083
|
+
diagnosticsLocation: "第 {page} 页 · 组件 {component}",
|
|
2084
|
+
diagnosticsStrict: "当前格式存在已知内容降级,请查看兼容性提示或选择其他输出格式。",
|
|
2085
|
+
diagnosticsDetails: "查看技术详情",
|
|
2086
|
+
diagnosticMissingImage: "图片或图表资源尚未准备完成,请重试或联系管理员。",
|
|
2087
|
+
diagnosticUnsupported: "当前输出格式会省略此内容,建议选择 PDF 或图片格式。",
|
|
2088
|
+
diagnosticUnsupportedStyle: "当前格式无法保留部分样式,请查看位置并选择适合的输出格式。",
|
|
2089
|
+
diagnosticImageFormat: "当前图片格式无法直接导出,请转换资源后重试。",
|
|
2090
|
+
diagnosticRichText: "文字内容会保留,部分字体与段落样式将简化。",
|
|
2091
|
+
diagnosticNested: "单元格中的嵌套内容会省略,单元格文字会保留。",
|
|
2092
|
+
diagnosticImageAsync: "图片需要完成加载后才能输出。",
|
|
2093
|
+
diagnosticImageDecode: "图片加载失败,请检查资源后重试。",
|
|
2094
|
+
diagnosticAssetFailed: "图表或图片生成失败,请重试或联系管理员。",
|
|
2095
|
+
diagnosticAssetBudget: "图片资源超出处理范围,请减少资源或缩小报表范围。"
|
|
2096
|
+
}, xs = {
|
|
2097
|
+
shellBg: "#525659",
|
|
2098
|
+
shellFg: "#e8e8e8",
|
|
2099
|
+
toolbarBg: "#323639",
|
|
2100
|
+
toolbarBorder: "#22252a",
|
|
2101
|
+
toolbarFg: "#e8e8e8",
|
|
2102
|
+
btnFg: "#cfcfcf",
|
|
2103
|
+
btnBorder: "#4a4d52",
|
|
2104
|
+
btnHoverBg: "#414549",
|
|
2105
|
+
btnHoverFg: "#ffffff",
|
|
2106
|
+
btnActiveBg: "#2d5fb8"
|
|
2107
|
+
};
|
|
2108
|
+
function ks(e = {}) {
|
|
2109
|
+
return { ...e, defaults: e.defaults ?? {}, presets: e.presets ?? {} };
|
|
2110
|
+
}
|
|
2111
|
+
function Il(e) {
|
|
2112
|
+
return e;
|
|
2113
|
+
}
|
|
2114
|
+
const Fe = {
|
|
2115
|
+
showExport: !0,
|
|
2116
|
+
showPrint: !0,
|
|
2117
|
+
showPdfWindow: !0,
|
|
2118
|
+
showSettings: !0,
|
|
2119
|
+
showParams: !0,
|
|
2120
|
+
gapPx: 18,
|
|
2121
|
+
pdfFontUrl: "/simhei.ttf",
|
|
2122
|
+
logger: console
|
|
2123
|
+
}, El = { warn: () => {
|
|
2124
|
+
}, info: () => {
|
|
2125
|
+
} };
|
|
2126
|
+
function lt(e, t) {
|
|
2127
|
+
return {
|
|
2128
|
+
...e,
|
|
2129
|
+
...t,
|
|
2130
|
+
theme: { ...e?.theme, ...t?.theme },
|
|
2131
|
+
messages: { ...e?.messages, ...t?.messages },
|
|
2132
|
+
preview: { ...e?.preview, ...t?.preview },
|
|
2133
|
+
xlsx: { ...e?.xlsx, ...t?.xlsx },
|
|
2134
|
+
toolbar: { ...e?.toolbar, ...t?.toolbar },
|
|
2135
|
+
interaction: { ...e?.interaction, ...t?.interaction },
|
|
2136
|
+
output: { ...e?.output, ...t?.output }
|
|
2137
|
+
};
|
|
2138
|
+
}
|
|
2139
|
+
function Is(e) {
|
|
2140
|
+
return {
|
|
2141
|
+
showExport: e.showExport ?? Fe.showExport,
|
|
2142
|
+
showPrint: e.showPrint ?? Fe.showPrint,
|
|
2143
|
+
showPdfWindow: e.showPdfWindow ?? Fe.showPdfWindow,
|
|
2144
|
+
showSettings: e.showSettings ?? Fe.showSettings,
|
|
2145
|
+
showParams: e.showParams ?? Fe.showParams,
|
|
2146
|
+
gapPx: e.gapPx ?? Fe.gapPx
|
|
2147
|
+
};
|
|
2148
|
+
}
|
|
2149
|
+
function Es(e, t) {
|
|
2150
|
+
const a = t ? e?.presets?.[t] : e?.defaultPreset ? e?.presets?.[e.defaultPreset] : void 0, n = lt(e?.defaults, a);
|
|
2151
|
+
return {
|
|
2152
|
+
...Is(n),
|
|
2153
|
+
pdfFontUrl: n.pdfFontUrl ?? Fe.pdfFontUrl,
|
|
2154
|
+
theme: { ...xs, ...n.theme },
|
|
2155
|
+
messages: { ...ws, ...n.messages },
|
|
2156
|
+
logger: n.logger ?? Fe.logger,
|
|
2157
|
+
preview: {
|
|
2158
|
+
overscanPages: bn(n.preview?.overscanPages, 1, 10, !0),
|
|
2159
|
+
searchDebounceMs: bn(n.preview?.searchDebounceMs, 200, 2e3)
|
|
2160
|
+
},
|
|
2161
|
+
xlsx: { ...n.xlsx },
|
|
2162
|
+
editable: n.editable ?? !1,
|
|
2163
|
+
excelImport: n.excelImport ?? !1,
|
|
2164
|
+
toolbar: { ...n.toolbar },
|
|
2165
|
+
interaction: { ...n.interaction },
|
|
2166
|
+
preferences: n.preferences,
|
|
2167
|
+
assets: n.assets,
|
|
2168
|
+
guardChanges: n.guardChanges ?? !0,
|
|
2169
|
+
beforeDiscard: n.beforeDiscard,
|
|
2170
|
+
output: { ...n.output }
|
|
2171
|
+
};
|
|
2172
|
+
}
|
|
2173
|
+
function bn(e, t, a, n = !1) {
|
|
2174
|
+
if (e == null || !Number.isFinite(e)) return t;
|
|
2175
|
+
const o = Math.max(0, Math.min(a, e));
|
|
2176
|
+
return n ? Math.floor(o) : o;
|
|
2177
|
+
}
|
|
2178
|
+
function Cs(e) {
|
|
2179
|
+
const t = {};
|
|
2180
|
+
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;
|
|
2181
|
+
}
|
|
2182
|
+
function Cl(e) {
|
|
2183
|
+
const t = ct(zt, null), a = A(() => {
|
|
2184
|
+
const n = t?.value ?? null, o = "defaults" in e || "presets" in e || "defaultPreset" in e ? ks(e) : { defaults: e, presets: {} };
|
|
2185
|
+
if (!n) return o;
|
|
2186
|
+
const r = { ...n.presets, ...o.presets };
|
|
2187
|
+
for (const s of Object.keys(r))
|
|
2188
|
+
r[s] = lt(
|
|
2189
|
+
lt(n.presets[s], o.defaults),
|
|
2190
|
+
o.presets[s]
|
|
2191
|
+
);
|
|
2192
|
+
return {
|
|
2193
|
+
defaults: lt(n.defaults, o.defaults),
|
|
2194
|
+
presets: r,
|
|
2195
|
+
defaultPreset: o.defaultPreset ?? n.defaultPreset
|
|
2196
|
+
};
|
|
2197
|
+
});
|
|
2198
|
+
En(zt, a);
|
|
2199
|
+
}
|
|
2200
|
+
function $s() {
|
|
2201
|
+
return ct(zt, A(() => null));
|
|
2202
|
+
}
|
|
2203
|
+
function ve(e) {
|
|
2204
|
+
return JSON.parse(JSON.stringify(e));
|
|
2205
|
+
}
|
|
2206
|
+
function Dn(e, t) {
|
|
2207
|
+
const a = t.fields;
|
|
2208
|
+
if (typeof a == "function") return a(e);
|
|
2209
|
+
const n = e.source?.field ?? e.table?.columnKey;
|
|
2210
|
+
return n === void 0 || !a || !Object.prototype.hasOwnProperty.call(a, n) ? void 0 : a[n];
|
|
2211
|
+
}
|
|
2212
|
+
class Ps extends Error {
|
|
2213
|
+
constructor(t) {
|
|
2214
|
+
super(t.map((a) => a.message).join(";")), this.conflicts = t, this.name = "ReportEditConflictError";
|
|
2215
|
+
}
|
|
2216
|
+
}
|
|
2217
|
+
function Ss() {
|
|
2218
|
+
return globalThis.crypto?.randomUUID?.() ?? `mr-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
|
|
2219
|
+
}
|
|
2220
|
+
function Rs(e) {
|
|
2221
|
+
const t = ae([]), a = ae([]), n = ae([]), o = ae([]), r = ae(!1), s = ae(null), l = ae([]), f = A(() => l.value.length > 0), p = A(() => dn(t.value)), u = A(() => !!e.options.value && !r.value && !e.blocked() && a.value.length > 0), i = A(() => !!e.options.value && !r.value && !e.blocked() && n.value.length > 0);
|
|
2222
|
+
let m = null, g = null, y = 0, v = null;
|
|
2223
|
+
function c() {
|
|
2224
|
+
m?.abort(), m = null, r.value = !1, g = null;
|
|
2225
|
+
}
|
|
2226
|
+
function T() {
|
|
2227
|
+
y++, c(), v = null, t.value = [], a.value = [], n.value = [], o.value = [], l.value = [], s.value = null;
|
|
2228
|
+
}
|
|
2229
|
+
function D() {
|
|
2230
|
+
const $ = e.options.value;
|
|
2231
|
+
return $ ? typeof $ == "object" ? $ : {} : null;
|
|
2232
|
+
}
|
|
2233
|
+
function L($, k, F) {
|
|
2234
|
+
if (!e.options.value || e.blocked()) throw new De("readonly");
|
|
2235
|
+
const z = Lt($);
|
|
2236
|
+
for (const N of k.edits) {
|
|
2237
|
+
const Z = z(N.address);
|
|
2238
|
+
if (!Z?.editable || F.canEdit?.(Z) === !1) throw new De("readonly");
|
|
2239
|
+
if (F.requireSource && !Z.source) throw new De("missing");
|
|
2240
|
+
const H = Dn(Z, F);
|
|
2241
|
+
H && $a(Z, N.value, H);
|
|
2242
|
+
}
|
|
2243
|
+
}
|
|
2244
|
+
async function q($, k, F) {
|
|
2245
|
+
if (k.saveBatch) return k.saveBatch(ve($), F);
|
|
2246
|
+
if (k.save && $.edits.length > 1) throw new De("atomic");
|
|
2247
|
+
if ($.edits[0]) return k.save?.(ve($.edits[0]), F);
|
|
2248
|
+
}
|
|
2249
|
+
async function B($, k, F) {
|
|
2250
|
+
for (const z of $.edits) {
|
|
2251
|
+
const N = await k.validate?.(ve(z), F);
|
|
2252
|
+
if (N) throw new Error(N);
|
|
2253
|
+
if (F.signal.aborted) return;
|
|
2254
|
+
}
|
|
2255
|
+
}
|
|
2256
|
+
function U($, k, F, z, N) {
|
|
2257
|
+
if (e.plan.value = Pa(Sa($, k), k, F), t.value = [...t.value, ...k.edits], N) {
|
|
2258
|
+
const H = new Set(k.edits.map(fn));
|
|
2259
|
+
l.value = l.value.filter((V) => !H.has(fn(V)));
|
|
2260
|
+
} else l.value = dn([...l.value, ...k.edits]);
|
|
2261
|
+
z === "edit" && (a.value = [...a.value, k.edits], n.value = []), o.value = [], v = null;
|
|
2262
|
+
const Z = y;
|
|
2263
|
+
for (const H of k.edits) {
|
|
2264
|
+
if (y !== Z) break;
|
|
2265
|
+
e.onChange(ve(H));
|
|
2266
|
+
}
|
|
2267
|
+
}
|
|
2268
|
+
async function X($, k) {
|
|
2269
|
+
const F = e.plan.value, z = D();
|
|
2270
|
+
if (!F || !z || e.blocked()) return !1;
|
|
2271
|
+
const N = new AbortController(), Z = y;
|
|
2272
|
+
m = N, r.value = !0, s.value = null;
|
|
2273
|
+
const H = () => m === N && !N.signal.aborted && e.plan.value === F && e.options.value !== !1;
|
|
2274
|
+
try {
|
|
2275
|
+
const V = Ca(F, $, Ss());
|
|
2276
|
+
if (L(F, V, z), V.edits = V.edits.filter((K) => !Object.is(K.previousValue, K.value)), !V.edits.length) return !0;
|
|
2277
|
+
const w = JSON.stringify([k, V.edits]);
|
|
2278
|
+
v?.plan === F && v.signature === w ? V.requestId = v.requestId : v = { plan: F, signature: w, requestId: V.requestId }, L(F, V, z);
|
|
2279
|
+
const S = { signal: N.signal, requestId: V.requestId, action: k };
|
|
2280
|
+
if (await B(V, z, S), !H()) return !1;
|
|
2281
|
+
L(F, V, z);
|
|
2282
|
+
const x = await q(V, z, S);
|
|
2283
|
+
if (!H()) return !1;
|
|
2284
|
+
if (x?.conflicts?.length)
|
|
2285
|
+
throw o.value = ve(x.conflicts), new Ps(x.conflicts);
|
|
2286
|
+
return L(F, V, z), U(F, V, x, k, !!(z.save || z.saveBatch)), Z === y;
|
|
2287
|
+
} catch (V) {
|
|
2288
|
+
return H() && (s.value = e.errorMessage?.(V) ?? (V instanceof Error ? V.message : "Cell edit failed"), e.onError(s.value, V)), !1;
|
|
2289
|
+
} finally {
|
|
2290
|
+
m === N && (m = null, r.value = !1);
|
|
2291
|
+
}
|
|
2292
|
+
}
|
|
2293
|
+
async function G($, k = "edit") {
|
|
2294
|
+
if (g) return g;
|
|
2295
|
+
const F = X($, k);
|
|
2296
|
+
g = F;
|
|
2297
|
+
const z = await F;
|
|
2298
|
+
return g === F && (g = null), z;
|
|
2299
|
+
}
|
|
2300
|
+
async function Q() {
|
|
2301
|
+
const $ = y, k = a.value[a.value.length - 1];
|
|
2302
|
+
return !k || r.value || !await G(k.map((F) => ({ address: F.address, value: F.previousValue })), "undo") || $ !== y ? !1 : (a.value = a.value.slice(0, -1), n.value = [...n.value, k], !0);
|
|
2303
|
+
}
|
|
2304
|
+
async function h() {
|
|
2305
|
+
const $ = y, k = n.value[n.value.length - 1];
|
|
2306
|
+
return !k || r.value || !await G(k.map((F) => ({ address: F.address, value: F.value })), "redo") || $ !== y ? !1 : (n.value = n.value.slice(0, -1), a.value = [...a.value, k], !0);
|
|
2307
|
+
}
|
|
2308
|
+
async function M() {
|
|
2309
|
+
const $ = y;
|
|
2310
|
+
return !p.value.length || r.value || !await G(p.value.map((k) => ({ address: k.address, value: k.previousValue })), "restore") || $ !== y ? !1 : (a.value = [], n.value = [], !0);
|
|
2311
|
+
}
|
|
2312
|
+
return { changes: t, differences: p, localDifferences: l, hasLocalDrafts: f, lastError: s, conflicts: o, saving: r, canUndo: u, canRedo: i, apply: G, undo: Q, redo: h, restore: M, cancel: c, reset: T };
|
|
2313
|
+
}
|
|
2314
|
+
let Ms = 0;
|
|
2315
|
+
const Ts = "position:absolute;inset:0;width:100%;height:100%;min-height:20px;box-sizing:border-box;z-index:10;resize:none;margin:0;padding:2px 4px;border:2px solid var(--mrp-btn-active-bg,#2563eb);outline:none;background:var(--mrp-toolbar-bg,#fff);color:var(--mrp-toolbar-fg,#111);font:inherit;line-height:1.25;white-space:pre-wrap;";
|
|
2316
|
+
function Fs(e) {
|
|
2317
|
+
return e.type === "boolean" ? [{ value: !0, label: e.trueLabel ?? "是" }, { value: !1, label: e.falseLabel ?? "否" }] : e.type === "enum" ? e.options.map((t) => ({ value: t.value, label: t.label ?? String(t.value) })) : [];
|
|
2318
|
+
}
|
|
2319
|
+
function Ds(e, t, a) {
|
|
2320
|
+
const n = e.createElement("select"), o = [{ value: null, label: "—" }, ...Fs(t)];
|
|
2321
|
+
if (o.forEach((r, s) => {
|
|
2322
|
+
const l = e.createElement("option");
|
|
2323
|
+
l.value = String(s), l.textContent = r.label, (Object.is(a.value, r.value) || a.value === "" && r.value === null) && (l.selected = !0), n.append(l);
|
|
2324
|
+
}), !o.some((r) => Object.is(a.value, r.value) || a.value === "" && r.value === null)) {
|
|
2325
|
+
const r = e.createElement("option");
|
|
2326
|
+
r.value = "unknown", r.textContent = a.cell.text ?? String(a.value), r.selected = !0, n.append(r);
|
|
2327
|
+
}
|
|
2328
|
+
return { input: n, value: () => n.value === "unknown" ? a.value : o[Number(n.value)]?.value ?? null };
|
|
2329
|
+
}
|
|
2330
|
+
function Os(e, t, a) {
|
|
2331
|
+
const n = t?.type === "number" || t?.type === "date" ? e.createElement("input") : e.createElement("textarea");
|
|
2332
|
+
return n.value = a.value == null ? "" : String(a.value), n instanceof HTMLInputElement && (n.type = t?.type === "date" ? "date" : "text", t?.type === "number" && (n.inputMode = "decimal"), t?.type === "date" && (t.min && (n.min = t.min), t.max && (n.max = t.max))), { input: n, value: () => t?.type === "date" && n instanceof HTMLInputElement && n.validity.badInput ? "invalid-date" : n.value };
|
|
2333
|
+
}
|
|
2334
|
+
function As(e) {
|
|
2335
|
+
if (!e) return "";
|
|
2336
|
+
const t = [e.hint, e.unit];
|
|
2337
|
+
return (e.type === "number" || e.type === "date") && (e.min !== void 0 && t.push(`≥ ${e.min}`), e.max !== void 0 && t.push(`≤ ${e.max}`)), e.type === "number" && e.precision !== void 0 && t.push(`最多 ${e.precision} 位小数`), e.type === "text" && e.maxLength !== void 0 && t.push(`最多 ${e.maxLength} 字符`), t.filter(Boolean).join(" · ");
|
|
2338
|
+
}
|
|
2339
|
+
function Ls(e, t, a, n) {
|
|
2340
|
+
const o = e.ownerDocument, r = n?.type === "boolean" || n?.type === "enum" ? Ds(o, n, a) : Os(o, n, a), s = r.input, l = o.createElement("span");
|
|
2341
|
+
l.className = "mrp-cell-editor-host", l.style.cssText = "position:absolute;inset:0;z-index:10;", s.className = "mrp-cell-editor", s.style.cssText = Ts, s.setAttribute("aria-label", n?.label ?? t), n?.required && s.setAttribute("aria-required", "true");
|
|
2342
|
+
const f = o.createElement("span");
|
|
2343
|
+
f.id = `mrp-cell-hint-${++Ms}`, f.className = "mrp-cell-editor-hint", f.style.cssText = "position:absolute;top:100%;left:0;min-width:100%;width:max-content;max-width:320px;box-sizing:border-box;padding:4px 8px;white-space:normal;border:1px solid var(--mrp-toolbar-border,#ddd);background:var(--mrp-toolbar-bg,#fff);color:var(--mrp-toolbar-fg,#111);font-size:12px;line-height:1.4;box-shadow:0 3px 10px #0002;z-index:11;";
|
|
2344
|
+
const p = As(n);
|
|
2345
|
+
return f.textContent = p, f.hidden = !p, s.setAttribute("aria-describedby", f.id), l.append(s, f), e.append(l), {
|
|
2346
|
+
input: s,
|
|
2347
|
+
root: l,
|
|
2348
|
+
initialInput: s.value,
|
|
2349
|
+
value: r.value,
|
|
2350
|
+
focus: () => {
|
|
2351
|
+
s.focus(), (s instanceof HTMLTextAreaElement || s instanceof HTMLInputElement && s.type !== "date") && s.select();
|
|
2352
|
+
},
|
|
2353
|
+
feedback: (u) => {
|
|
2354
|
+
f.textContent = u ?? p, f.hidden = !f.textContent, s.setAttribute("aria-invalid", u ? "true" : "false");
|
|
2355
|
+
}
|
|
2356
|
+
};
|
|
2357
|
+
}
|
|
2358
|
+
function Bt(e) {
|
|
2359
|
+
const t = e.closest(".mrp-page-holder"), a = e.closest("[data-mr-component-index]");
|
|
2360
|
+
if (!t || !a) return null;
|
|
2361
|
+
const n = {
|
|
2362
|
+
pageIndex: Number(t.dataset.page) - 1,
|
|
2363
|
+
componentIndex: Number(a.dataset.mrComponentIndex),
|
|
2364
|
+
rowIndex: Number(e.dataset.mrRowIndex),
|
|
2365
|
+
columnIndex: Number(e.dataset.mrColumnIndex)
|
|
2366
|
+
};
|
|
2367
|
+
return Object.values(n).every((o) => Number.isInteger(o) && o >= 0) ? n : null;
|
|
2368
|
+
}
|
|
2369
|
+
function zs(e) {
|
|
2370
|
+
const t = ae(null), a = Rs(e), { saving: n, changes: o } = a, r = ae(!1), s = A(() => r.value || a.hasLocalDrafts.value);
|
|
2371
|
+
let l = null;
|
|
2372
|
+
function f() {
|
|
2373
|
+
const c = t.value;
|
|
2374
|
+
t.value = null, r.value = !1, a.cancel(), l = null, c?.editor.root.remove();
|
|
2375
|
+
}
|
|
2376
|
+
function p() {
|
|
2377
|
+
f(), a.reset();
|
|
2378
|
+
}
|
|
2379
|
+
function u(c) {
|
|
2380
|
+
return t.value === c && e.plan.value === c.plan;
|
|
2381
|
+
}
|
|
2382
|
+
async function i(c) {
|
|
2383
|
+
return await a.apply([{ address: c.address, value: c.editor.value() }]) ? (t.value = null, r.value = !1, c.editor.root.remove(), !0) : (t.value === c && (c.editor.input.disabled = !1, c.editor.feedback(a.lastError.value ?? void 0), c.editor.input.focus()), !1);
|
|
2384
|
+
}
|
|
2385
|
+
async function m() {
|
|
2386
|
+
if (l) return l;
|
|
2387
|
+
const c = t.value;
|
|
2388
|
+
if (!c) return !0;
|
|
2389
|
+
if (!u(c))
|
|
2390
|
+
return f(), !1;
|
|
2391
|
+
r.value = c.editor.input.value !== c.editor.initialInput, c.editor.input.disabled = !0;
|
|
2392
|
+
const T = i(c);
|
|
2393
|
+
l = T;
|
|
2394
|
+
const D = await T;
|
|
2395
|
+
return l === T && (l = null), D;
|
|
2396
|
+
}
|
|
2397
|
+
function g(c) {
|
|
2398
|
+
if (c.stopPropagation(), !c.isComposing && (c.key === "Escape" && (c.preventDefault(), f()), c.key === "Enter" && !c.shiftKey || c.key === "Tab")) {
|
|
2399
|
+
c.preventDefault();
|
|
2400
|
+
const T = t.value?.address;
|
|
2401
|
+
m().then((D) => {
|
|
2402
|
+
D && T && e.onNavigate?.(T, c.key, c.shiftKey);
|
|
2403
|
+
});
|
|
2404
|
+
}
|
|
2405
|
+
}
|
|
2406
|
+
async function y(c) {
|
|
2407
|
+
if (!e.options.value || e.blocked() || !await m() || !c.isConnected) return;
|
|
2408
|
+
const T = e.plan.value, D = Bt(c);
|
|
2409
|
+
if (!T || !D || !e.options.value || e.blocked()) return;
|
|
2410
|
+
const L = typeof e.options.value == "object" ? e.options.value : {};
|
|
2411
|
+
try {
|
|
2412
|
+
const q = ot(T, D);
|
|
2413
|
+
if (!q?.editable || L.canEdit?.(q) === !1) return;
|
|
2414
|
+
const B = Dn(q, L);
|
|
2415
|
+
B && Ra(q, B);
|
|
2416
|
+
const U = Ls(c, e.label(), q, B), X = U.input;
|
|
2417
|
+
t.value = { plan: T, address: D, editor: U }, r.value = !1, X.addEventListener("keydown", (G) => g(G)), X.addEventListener("input", () => {
|
|
2418
|
+
r.value = X.value !== U.initialInput, U.feedback();
|
|
2419
|
+
}), X.addEventListener("change", () => {
|
|
2420
|
+
r.value = X.value !== U.initialInput;
|
|
2421
|
+
}), X.addEventListener("blur", () => {
|
|
2422
|
+
!n.value && !e.suspendBlur?.() && m();
|
|
2423
|
+
}), U.focus();
|
|
2424
|
+
} catch (q) {
|
|
2425
|
+
e.onError(q instanceof Error ? q.message : "无法编辑单元格", q);
|
|
2426
|
+
}
|
|
2427
|
+
}
|
|
2428
|
+
async function v(c) {
|
|
2429
|
+
const T = c.target;
|
|
2430
|
+
if (!(T instanceof Element) || T.closest(".mrp-cell-editor")) return;
|
|
2431
|
+
const D = T.closest("td[data-mr-row-index]");
|
|
2432
|
+
D && await y(D);
|
|
2433
|
+
}
|
|
2434
|
+
return le(e.options, (c, T) => {
|
|
2435
|
+
(!c || c !== T) && f();
|
|
2436
|
+
}, { flush: "sync" }), le(e.plan, () => {
|
|
2437
|
+
t.value && e.plan.value !== t.value.plan && (t.value.editor.root.remove(), t.value = null, r.value = !1);
|
|
2438
|
+
}, { flush: "sync" }), Oe(p), {
|
|
2439
|
+
...a,
|
|
2440
|
+
active: t,
|
|
2441
|
+
saving: n,
|
|
2442
|
+
changes: o,
|
|
2443
|
+
pendingLocalChanges: s,
|
|
2444
|
+
cancel: f,
|
|
2445
|
+
reset: p,
|
|
2446
|
+
commit: m,
|
|
2447
|
+
onDoubleClick: v,
|
|
2448
|
+
editCell: y,
|
|
2449
|
+
getChanges: () => ve(o.value)
|
|
2450
|
+
};
|
|
2451
|
+
}
|
|
2452
|
+
const jt = ["html", "pdf", "xlsx", "png", "word"], yn = ["search", "thumbnails", "zoom", ...jt, "print", "pdfWindow", "editing", "import"];
|
|
2453
|
+
function $l(e) {
|
|
2454
|
+
return {
|
|
2455
|
+
load: (t) => JSON.parse(e.getItem(t) ?? "null"),
|
|
2456
|
+
save: (t, a) => e.setItem(t, JSON.stringify(a)),
|
|
2457
|
+
remove: (t) => e.removeItem(t)
|
|
2458
|
+
};
|
|
2459
|
+
}
|
|
2460
|
+
function qs(e, t, a, n) {
|
|
2461
|
+
const o = J({});
|
|
2462
|
+
let r = 0, s = 0, l = Promise.resolve();
|
|
2463
|
+
const f = A(() => Object.fromEntries(yn.map((m) => [
|
|
2464
|
+
m,
|
|
2465
|
+
e.value[m] && (o.value[m] ?? t.value[m] ?? !0)
|
|
2466
|
+
])));
|
|
2467
|
+
function p(m, g) {
|
|
2468
|
+
e.value[m] && (s++, o.value = { ...o.value, [m]: g }, u());
|
|
2469
|
+
}
|
|
2470
|
+
function u() {
|
|
2471
|
+
const m = a?.value;
|
|
2472
|
+
if (!m) return;
|
|
2473
|
+
const g = { ...o.value };
|
|
2474
|
+
l = l.then(() => m.adapter.save(m.key, g)).catch((y) => {
|
|
2475
|
+
n?.(y);
|
|
2476
|
+
});
|
|
2477
|
+
}
|
|
2478
|
+
function i() {
|
|
2479
|
+
s++, o.value = {}, u();
|
|
2480
|
+
}
|
|
2481
|
+
return a && le(a, async (m) => {
|
|
2482
|
+
const g = ++r, y = s;
|
|
2483
|
+
if (o.value = {}, !!m)
|
|
2484
|
+
try {
|
|
2485
|
+
const v = await m.adapter.load(m.key);
|
|
2486
|
+
if (g !== r || y !== s || !v || typeof v != "object") return;
|
|
2487
|
+
o.value = Object.fromEntries(yn.flatMap((c) => typeof v[c] == "boolean" ? [[c, v[c]]] : []));
|
|
2488
|
+
} catch (v) {
|
|
2489
|
+
g === r && n?.(v);
|
|
2490
|
+
}
|
|
2491
|
+
}, { immediate: !0 }), Oe(() => {
|
|
2492
|
+
r++;
|
|
2493
|
+
}), { enabled: f, setEnabled: p, reset: i };
|
|
2494
|
+
}
|
|
2495
|
+
function Bs(e, t, a) {
|
|
2496
|
+
const n = J({}), o = $s(), r = A(() => Es(o.value, e.preset)), s = A(() => ({
|
|
2497
|
+
...r.value.messages,
|
|
2498
|
+
...e.messages
|
|
2499
|
+
})), l = A(() => e.showExport ?? r.value.showExport), f = A(() => e.showPrint ?? r.value.showPrint), p = A(() => e.showPdfWindow ?? r.value.showPdfWindow), u = A(() => e.showSettings ?? r.value.showSettings), i = A(() => e.guardChanges ?? r.value.guardChanges), m = A(() => ({ ...r.value.output, ...e.output })), g = A(() => ({ ...r.value.toolbar, ...e.toolbar })), y = A(() => ({ ...r.value.interaction, ...e.interaction, ...n.value })), v = A(() => e.preferences ?? r.value.preferences), c = A(() => e.assets ?? r.value.assets), T = A(() => e.gapPx ?? (t.value ? 0 : r.value.gapPx)), D = A(() => e.showParams ?? r.value.showParams), L = A(() => e.editable ?? r.value.editable), q = A(() => e.excelImport ?? r.value.excelImport), B = A(() => ({
|
|
2500
|
+
search: g.value.search !== !1,
|
|
2501
|
+
thumbnails: g.value.thumbnails !== !1,
|
|
2502
|
+
zoom: g.value.zoom !== !1,
|
|
2503
|
+
...Object.fromEntries(jt.map((k) => [
|
|
2504
|
+
k,
|
|
2505
|
+
l.value && (g.value.exportFormats?.includes(k) ?? !0)
|
|
2506
|
+
])),
|
|
2507
|
+
print: f.value,
|
|
2508
|
+
pdfWindow: p.value,
|
|
2509
|
+
editing: !!L.value,
|
|
2510
|
+
import: !!q.value
|
|
2511
|
+
})), U = qs(B, A(() => ({
|
|
2512
|
+
editing: g.value.editing,
|
|
2513
|
+
import: g.value.excelImport
|
|
2514
|
+
})), v, () => a(s.value.preferencesError ?? "Preferences storage unavailable")), X = U.enabled, G = A(() => jt.filter((k) => X.value[k])), Q = A(() => X.value.editing ? L.value : !1), h = A(() => X.value.import ? q.value : !1), M = A(() => typeof L.value == "object" && (typeof L.value.save == "function" || typeof L.value.saveBatch == "function")), $ = A(() => typeof e.emptyState == "object" ? e.emptyState : {});
|
|
2515
|
+
return { resolved: r, resolvedMessages: s, effectiveShowExport: l, effectiveShowPrint: f, effectiveShowPdfWindow: p, effectiveShowSettings: u, effectiveGuardChanges: i, effectiveOutput: m, effectiveInteraction: y, effectiveAssets: c, effectiveGapPx: T, effectiveShowParams: D, availableTools: B, tools: U, toolState: X, visibleExportFormats: G, effectiveEditable: Q, effectiveExcelImport: h, persistedEditing: M, emptyStateContent: $, sessionInteraction: n };
|
|
2516
|
+
}
|
|
2517
|
+
function On(e) {
|
|
2518
|
+
return e.table.role === "header" ? -Math.max(1, e.grid?.cells.length ?? 1) : e.table.rowIndex;
|
|
2519
|
+
}
|
|
2520
|
+
function $e(e, t, a = t) {
|
|
2521
|
+
const n = e.pages[t.pageIndex]?.components[t.componentIndex], o = n?.table, r = e.pages[a.pageIndex]?.components[a.componentIndex]?.table;
|
|
2522
|
+
return o && r && o.id === r.id ? {
|
|
2523
|
+
grid: o.id,
|
|
2524
|
+
row: On(n) + t.rowIndex,
|
|
2525
|
+
column: r.columnKeys.indexOf(o.columnKeys[t.columnIndex] ?? "")
|
|
2526
|
+
} : { grid: `${t.pageIndex}:${t.componentIndex}`, row: t.rowIndex, column: t.columnIndex };
|
|
2527
|
+
}
|
|
2528
|
+
function wn(e, t) {
|
|
2529
|
+
const a = e.pages[t.pageIndex]?.components[t.componentIndex]?.table;
|
|
2530
|
+
if (!a) return (o, r) => ({ ...t, rowIndex: o, columnIndex: r });
|
|
2531
|
+
const n = /* @__PURE__ */ new Map();
|
|
2532
|
+
return e.pages.forEach((o, r) => o.components.forEach((s, l) => {
|
|
2533
|
+
s.table?.id !== a.id || !s.grid || s.grid.cells.forEach((f, p) => {
|
|
2534
|
+
const u = On(s) + p;
|
|
2535
|
+
n.set(u, [...n.get(u) ?? [], { address: { pageIndex: r, componentIndex: l, rowIndex: p, columnIndex: 0 }, keys: s.table.columnKeys }]);
|
|
2536
|
+
});
|
|
2537
|
+
})), (o, r) => {
|
|
2538
|
+
const s = a.columnKeys[r];
|
|
2539
|
+
if (s === void 0) return null;
|
|
2540
|
+
const l = n.get(o)?.find((f) => f.keys.includes(s));
|
|
2541
|
+
return l ? { ...l.address, columnIndex: l.keys.indexOf(s) } : null;
|
|
2542
|
+
};
|
|
2543
|
+
}
|
|
2544
|
+
function js(e, t) {
|
|
2545
|
+
const a = [...e.ownerDocument.querySelectorAll("a[href],button,input,textarea,select,[tabindex]:not([tabindex='-1'])")].filter((r) => r.tabIndex >= 0 && !r.matches(":disabled,[hidden],input[type='hidden']") && !r.closest("[inert],[aria-hidden='true']") && r.getClientRects().length > 0).map((r, s) => ({ element: r, order: s })).sort((r, s) => (r.element.tabIndex || 1 / 0) - (s.element.tabIndex || 1 / 0) || r.order - s.order), n = a.findIndex(({ element: r }) => r === e);
|
|
2546
|
+
if (n < 0) return !1;
|
|
2547
|
+
const o = a[n + (t ? -1 : 1)]?.element;
|
|
2548
|
+
return o ? (o.focus(), e.ownerDocument.activeElement === o) : !1;
|
|
2549
|
+
}
|
|
2550
|
+
function Ns(e, t) {
|
|
2551
|
+
const a = e?.source;
|
|
2552
|
+
return !Ws(e, t.field) || t.tableId !== void 0 && e?.table?.id !== t.tableId || t.datasetId !== void 0 && (a?.datasetId ?? e?.component.table?.source?.datasetId) !== t.datasetId ? !1 : t.rowKey === void 0 || a?.rowKey === t.rowKey;
|
|
2553
|
+
}
|
|
2554
|
+
function Ws(e, t) {
|
|
2555
|
+
if ((e?.source?.field ?? e?.table?.columnKey) === t) return !0;
|
|
2556
|
+
if (!e || e.table?.role !== "header") return !1;
|
|
2557
|
+
const a = e.address.columnIndex;
|
|
2558
|
+
return e.component.table?.columnKeys.slice(a, a + (e.cell.colSpan ?? 1)).includes(t) ?? !1;
|
|
2559
|
+
}
|
|
2560
|
+
function Hs(e, t) {
|
|
2561
|
+
return e.pageIndex === t.pageIndex && e.componentIndex === t.componentIndex;
|
|
2562
|
+
}
|
|
2563
|
+
function Ks(e, t) {
|
|
2564
|
+
return Hs(e, t) && e.rowIndex === t.rowIndex && e.columnIndex === t.columnIndex;
|
|
2565
|
+
}
|
|
2566
|
+
function Rt(e) {
|
|
2567
|
+
return `[data-page="${e.pageIndex + 1}"] [data-mr-component-index="${e.componentIndex}"] td[data-mr-row-index="${e.rowIndex}"][data-mr-column-index="${e.columnIndex}"]`;
|
|
2568
|
+
}
|
|
2569
|
+
function Nt(e) {
|
|
2570
|
+
return `${e.pageIndex}:${e.componentIndex}:${e.rowIndex}:${e.columnIndex}`;
|
|
2571
|
+
}
|
|
2572
|
+
function Us(e, t) {
|
|
2573
|
+
const a = $e(e, t.anchor), n = $e(e, t.focus, t.anchor);
|
|
2574
|
+
return { grid: a.grid, minRow: Math.min(a.row, n.row), maxRow: Math.max(a.row, n.row), minColumn: Math.min(a.column, n.column), maxColumn: Math.max(a.column, n.column), focusKey: Nt(t.focus), origin: e.pages[t.anchor.pageIndex]?.components[t.anchor.componentIndex]?.table };
|
|
2575
|
+
}
|
|
2576
|
+
function Vs(e, t, a) {
|
|
2577
|
+
const n = t?.table;
|
|
2578
|
+
if (!n || !a.origin || n.id !== a.origin.id) return { grid: `${e.pageIndex}:${e.componentIndex}`, rowOffset: 0, missingColumn: -1 };
|
|
2579
|
+
const o = /* @__PURE__ */ new Map();
|
|
2580
|
+
return a.origin.columnKeys.forEach((r, s) => {
|
|
2581
|
+
o.has(r) || o.set(r, s);
|
|
2582
|
+
}), { grid: n.id, rowOffset: n.role === "header" ? -Math.max(1, t.grid?.cells.length ?? 1) : n.rowIndex, columns: n.columnKeys.map((r) => o.get(r) ?? -1), missingColumn: o.get("") ?? -1 };
|
|
2583
|
+
}
|
|
2584
|
+
function Gs(e, t, a) {
|
|
2585
|
+
if (!a || !t || t.grid !== a.grid) return !1;
|
|
2586
|
+
const n = t.rowOffset + e.row, o = t.columns ? t.columns[e.column] ?? t.missingColumn : e.column;
|
|
2587
|
+
return n >= a.minRow && n <= a.maxRow && o >= a.minColumn && o <= a.maxColumn;
|
|
2588
|
+
}
|
|
2589
|
+
function it(e, t, a) {
|
|
2590
|
+
e.getAttribute(t) !== a && e.setAttribute(t, a);
|
|
2591
|
+
}
|
|
2592
|
+
function Mt(e, t, a) {
|
|
2593
|
+
e.classList.contains(t) !== a && e.classList.toggle(t, a);
|
|
2594
|
+
}
|
|
2595
|
+
function Js(e, t, a, n, o, r) {
|
|
2596
|
+
t.role !== a && (it(e, "role", a), t.role = a), t.selected !== n && (Mt(e, "mrp-cell-selected", n), it(e, "aria-selected", String(n)), t.selected = n), t.focused !== o && (Mt(e, "mrp-cell-focus", o), it(e, "tabindex", o ? "0" : "-1"), t.focused = o), t.modified !== r && (Mt(e, "mrp-cell-modified", r), t.modified = r);
|
|
2597
|
+
}
|
|
2598
|
+
function Zs(e) {
|
|
2599
|
+
const t = ae(null), a = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap();
|
|
2600
|
+
let o = null, r = /* @__PURE__ */ new Set();
|
|
2601
|
+
function s(h = e.root.value ?? void 0) {
|
|
2602
|
+
if (!h) return;
|
|
2603
|
+
const M = t.value, $ = e.plan.value, k = e.differences();
|
|
2604
|
+
k !== o && (o = k, r = new Set(k.map((z) => Nt(z.address))));
|
|
2605
|
+
const F = M && $ ? Us($, M) : null;
|
|
2606
|
+
h instanceof HTMLTableElement && p(h, $, F);
|
|
2607
|
+
for (const z of h.querySelectorAll("table")) p(z, $, F);
|
|
2608
|
+
}
|
|
2609
|
+
function l(h) {
|
|
2610
|
+
const M = a.get(h);
|
|
2611
|
+
if (M) return M;
|
|
2612
|
+
const $ = h.closest("[data-mr-component-index]"), k = $?.closest(".mrp-page-holder"), F = { pageIndex: Number(k?.dataset.page) - 1, componentIndex: Number($?.dataset.mrComponentIndex) };
|
|
2613
|
+
return Object.values(F).every((z) => Number.isInteger(z) && z >= 0) ? (a.set(h, F), F) : null;
|
|
2614
|
+
}
|
|
2615
|
+
function f(h, M) {
|
|
2616
|
+
const $ = n.get(h);
|
|
2617
|
+
if ($) return $;
|
|
2618
|
+
const k = Number(h.dataset.mrRowIndex), F = Number(h.dataset.mrColumnIndex);
|
|
2619
|
+
if (![k, F].every((N) => Number.isInteger(N) && N >= 0)) return null;
|
|
2620
|
+
const z = { row: k, column: F, key: Nt({ ...M, rowIndex: k, columnIndex: F }) };
|
|
2621
|
+
return n.set(h, z), z;
|
|
2622
|
+
}
|
|
2623
|
+
function p(h, M, $) {
|
|
2624
|
+
const k = l(h);
|
|
2625
|
+
if (!k) return;
|
|
2626
|
+
const F = M?.pages[k.pageIndex]?.components[k.componentIndex], z = F?.table?.role === "header" ? "columnheader" : "gridcell", N = $ ? Vs(k, F, $) : null;
|
|
2627
|
+
it(h, "role", "grid");
|
|
2628
|
+
for (const Z of h.rows) for (const H of Z.cells) {
|
|
2629
|
+
const V = f(H, k);
|
|
2630
|
+
V && Js(H, V, z, Gs(V, N, $), $?.focusKey === V.key, r.size > 0 && r.has(V.key));
|
|
2631
|
+
}
|
|
2632
|
+
}
|
|
2633
|
+
async function u(h, M = !1) {
|
|
2634
|
+
if (!e.plan.value || !ot(e.plan.value, h)) return !1;
|
|
2635
|
+
const $ = t.value, k = M && $ && $e(e.plan.value, $.anchor).grid === $e(e.plan.value, h, $.anchor).grid;
|
|
2636
|
+
t.value = { anchor: k ? $.anchor : { ...h }, focus: { ...h } }, e.root.value?.querySelector(Rt(h)) || e.gotoPage(h.pageIndex + 1), await Qe(), s();
|
|
2637
|
+
const F = e.root.value?.querySelector(Rt(h));
|
|
2638
|
+
return F?.focus({ preventScroll: !0 }), F?.scrollIntoView?.({ block: "nearest", inline: "nearest" }), !!F;
|
|
2639
|
+
}
|
|
2640
|
+
function i(h) {
|
|
2641
|
+
const M = h.target;
|
|
2642
|
+
if (!(M instanceof Element) || M.closest("textarea,input,button,select")) return;
|
|
2643
|
+
const $ = M.closest("td[data-mr-row-index]"), k = $ && Bt($);
|
|
2644
|
+
if (!k || e.busy() || !e.plan.value || !ot(e.plan.value, k)) return;
|
|
2645
|
+
const F = t.value, z = h.shiftKey && F && $e(e.plan.value, F.anchor).grid === $e(e.plan.value, k, F.anchor).grid;
|
|
2646
|
+
t.value = { anchor: z ? F.anchor : { ...k }, focus: { ...k } }, s(), $.focus({ preventScroll: !0 });
|
|
2647
|
+
}
|
|
2648
|
+
function m(h) {
|
|
2649
|
+
const M = e.plan.value?.pages[h.pageIndex]?.components[h.componentIndex];
|
|
2650
|
+
return M?.grid ? Sn(M.grid, M.widthMm, M.heightMm).cells.map(($) => ({ ...h, rowIndex: $.ri, columnIndex: $.ci })) : [];
|
|
2651
|
+
}
|
|
2652
|
+
function g(h, M, $) {
|
|
2653
|
+
const k = m(h), F = $ ? -1 : 1;
|
|
2654
|
+
if (M === "Tab") return k[k.findIndex((Z) => Ks(Z, h)) + F];
|
|
2655
|
+
const z = M === "ArrowUp" || M === "ArrowDown" || M === "Enter", N = M === "ArrowUp" || M === "ArrowLeft" ? -1 : F;
|
|
2656
|
+
return k.filter((Z) => z ? Z.columnIndex === h.columnIndex && (Z.rowIndex - h.rowIndex) * N > 0 : Z.rowIndex === h.rowIndex && (Z.columnIndex - h.columnIndex) * N > 0).sort((Z, H) => z ? (Z.rowIndex - H.rowIndex) * N : (Z.columnIndex - H.columnIndex) * N)[0];
|
|
2657
|
+
}
|
|
2658
|
+
function y(h, M, $) {
|
|
2659
|
+
if (M === "ArrowLeft" || M === "ArrowRight") return;
|
|
2660
|
+
const k = e.plan.value;
|
|
2661
|
+
if (!k.pages[h.pageIndex]?.components[h.componentIndex]?.table) return;
|
|
2662
|
+
const z = M === "ArrowUp" || $ ? -1 : 1;
|
|
2663
|
+
for (let N = h.pageIndex; N >= 0 && N < k.pages.length; N += z) {
|
|
2664
|
+
const Z = k.pages[N].components, H = N === h.pageIndex ? h.componentIndex + z : z === 1 ? 0 : Z.length - 1;
|
|
2665
|
+
for (let V = H; V >= 0 && V < Z.length; V += z) {
|
|
2666
|
+
const w = v(h, { ...h, pageIndex: N, componentIndex: V }, M, z);
|
|
2667
|
+
if (w) return w;
|
|
2668
|
+
}
|
|
2669
|
+
}
|
|
2670
|
+
}
|
|
2671
|
+
function v(h, M, $, k) {
|
|
2672
|
+
const F = e.plan.value, z = F.pages[h.pageIndex].components[h.componentIndex].table, N = F.pages[M.pageIndex].components[M.componentIndex]?.table;
|
|
2673
|
+
if (N?.id !== z.id || N.role === "header" && z.role !== "header" && (k > 0 || z.rowIndex + h.rowIndex > 0)) return;
|
|
2674
|
+
const Z = m(M), H = $ === "Tab" ? Z : Z.filter((V) => V.columnIndex === h.columnIndex);
|
|
2675
|
+
return k === 1 ? H[0] : H[H.length - 1];
|
|
2676
|
+
}
|
|
2677
|
+
function c(h, M, $ = !1, k = !1, F = !1) {
|
|
2678
|
+
const z = g(h, M, $) ?? y(h, M, $);
|
|
2679
|
+
return z ? (u(z, k), !0) : ((M !== "Tab" || !F) && u(h), !1);
|
|
2680
|
+
}
|
|
2681
|
+
function T(h) {
|
|
2682
|
+
const M = t.value;
|
|
2683
|
+
if (e.busy() || h.target instanceof Element && h.target.closest("textarea,input,select")) return !1;
|
|
2684
|
+
if (!M) return L(h);
|
|
2685
|
+
const $ = h.key, k = h.ctrlKey || h.metaKey;
|
|
2686
|
+
if (k && $.toLowerCase() === "z")
|
|
2687
|
+
return h.preventDefault(), h.shiftKey ? e.redo() : e.undo(), !0;
|
|
2688
|
+
if (k && $.toLowerCase() === "y")
|
|
2689
|
+
return h.preventDefault(), e.redo(), !0;
|
|
2690
|
+
if (D(h, M.focus)) return !0;
|
|
2691
|
+
if (!["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight", "Tab", "Enter"].includes($)) return !1;
|
|
2692
|
+
const F = c(M.focus, $, $ === "Tab" && h.shiftKey, h.shiftKey && $ !== "Tab", !0);
|
|
2693
|
+
if ($ === "Tab" && !F) {
|
|
2694
|
+
const z = e.root.value?.ownerDocument.activeElement;
|
|
2695
|
+
if (!(z instanceof HTMLElement) || !js(z, h.shiftKey)) return !1;
|
|
2696
|
+
}
|
|
2697
|
+
return h.preventDefault(), !0;
|
|
2698
|
+
}
|
|
2699
|
+
function D(h, M) {
|
|
2700
|
+
if (!e.enabled() || !e.plan.value || h.key !== "F2" && !(h.key === "Enter" && ot(e.plan.value, M)?.editable)) return !1;
|
|
2701
|
+
const $ = e.root.value?.querySelector(Rt(M));
|
|
2702
|
+
return $ && (h.preventDefault(), e.edit($)), !0;
|
|
2703
|
+
}
|
|
2704
|
+
function L(h) {
|
|
2705
|
+
if (!["ArrowDown", "ArrowRight", "ArrowUp", "ArrowLeft", "Enter"].includes(h.key)) return !1;
|
|
2706
|
+
const M = e.root.value?.querySelector("td[data-mr-row-index]"), $ = M && Bt(M);
|
|
2707
|
+
return $ ? (h.preventDefault(), u($), !0) : !1;
|
|
2708
|
+
}
|
|
2709
|
+
function q() {
|
|
2710
|
+
const h = t.value, M = e.plan.value;
|
|
2711
|
+
if (!h || !M) return "";
|
|
2712
|
+
const $ = [], k = $e(M, h.anchor), F = $e(M, h.focus, h.anchor), z = wn(M, h.anchor), N = Lt(M), Z = Math.min(k.column, F.column), H = Math.max(k.column, F.column);
|
|
2713
|
+
if ((Math.abs(k.row - F.row) + 1) * (H - Z + 1) > 1e4)
|
|
2714
|
+
return e.error(new De("limit")), "";
|
|
2715
|
+
for (let V = Math.min(k.row, F.row); V <= Math.max(k.row, F.row); V++) {
|
|
2716
|
+
const w = [];
|
|
2717
|
+
for (let S = Z; S <= H; S++) {
|
|
2718
|
+
const x = z(V, S);
|
|
2719
|
+
w.push(x ? N(x)?.cell.text ?? "" : "");
|
|
2720
|
+
}
|
|
2721
|
+
$.push(w);
|
|
2722
|
+
}
|
|
2723
|
+
return Ta($);
|
|
2724
|
+
}
|
|
2725
|
+
function B(h) {
|
|
2726
|
+
!t.value || h.target instanceof Element && h.target.closest("textarea,input,select") || (h.clipboardData?.setData("text/plain", q()), h.preventDefault());
|
|
2727
|
+
}
|
|
2728
|
+
async function U(h) {
|
|
2729
|
+
const M = t.value;
|
|
2730
|
+
if (!M || !e.enabled() || e.busy()) return !1;
|
|
2731
|
+
try {
|
|
2732
|
+
let $;
|
|
2733
|
+
try {
|
|
2734
|
+
$ = Ma(h);
|
|
2735
|
+
} catch (H) {
|
|
2736
|
+
throw new De(H instanceof Error && H.message.includes("limit") ? "limit" : "clipboard");
|
|
2737
|
+
}
|
|
2738
|
+
const k = e.plan.value, F = $e(k, M.anchor), z = $e(k, M.focus, M.anchor), N = wn(k, M.anchor), Z = $.flatMap((H, V) => H.map((w, S) => {
|
|
2739
|
+
const x = N(Math.min(F.row, z.row) + V, Math.min(F.column, z.column) + S);
|
|
2740
|
+
if (!x) throw new De("missing");
|
|
2741
|
+
return { address: x, value: w };
|
|
2742
|
+
}));
|
|
2743
|
+
return await e.apply(Z);
|
|
2744
|
+
} catch ($) {
|
|
2745
|
+
return e.error($), !1;
|
|
2746
|
+
}
|
|
2747
|
+
}
|
|
2748
|
+
function X(h) {
|
|
2749
|
+
if (!t.value || !e.enabled() || h.target instanceof Element && h.target.closest("textarea,input,select") || !h.clipboardData?.types.includes("text/plain")) return;
|
|
2750
|
+
const M = h.clipboardData?.getData("text/plain");
|
|
2751
|
+
M && (h.preventDefault(), U(M));
|
|
2752
|
+
}
|
|
2753
|
+
async function G(h) {
|
|
2754
|
+
const M = e.plan.value;
|
|
2755
|
+
if (!M) return !1;
|
|
2756
|
+
const $ = Lt(M);
|
|
2757
|
+
for (let k = 0; k < M.pages.length; k++) {
|
|
2758
|
+
const F = M.pages[k];
|
|
2759
|
+
for (let z = 0; z < F.components.length; z++)
|
|
2760
|
+
for (const N of m({ pageIndex: k, componentIndex: z, rowIndex: 0, columnIndex: 0 })) {
|
|
2761
|
+
const Z = $(N);
|
|
2762
|
+
if (Ns(Z, h))
|
|
2763
|
+
return u(N);
|
|
2764
|
+
}
|
|
2765
|
+
}
|
|
2766
|
+
return !1;
|
|
2767
|
+
}
|
|
2768
|
+
function Q() {
|
|
2769
|
+
t.value = null, s();
|
|
2770
|
+
}
|
|
2771
|
+
return { selection: t, refresh: s, reset: Q, focusCell: u, focusField: G, navigate: c, onClick: i, onKeydown: T, onCopy: B, onPaste: X, copySelection: q, pasteSelection: U };
|
|
2772
|
+
}
|
|
2773
|
+
function Ys(e) {
|
|
2774
|
+
let t = 0, a = !1;
|
|
2775
|
+
function n() {
|
|
2776
|
+
const r = e.viewport.value, s = e.root.value, l = e.plan.value;
|
|
2777
|
+
if (!r || !s || !l) return;
|
|
2778
|
+
const f = e.options(), p = Math.max(0, Math.min(20, Math.floor(f.frozenColumns ?? 0)));
|
|
2779
|
+
if (!f.freezeHeaders && p === 0 && !a) return;
|
|
2780
|
+
const u = e.zoom.value || 1, i = r.getBoundingClientRect();
|
|
2781
|
+
s.querySelectorAll("[data-mr-component-index]").forEach((m) => {
|
|
2782
|
+
const g = m.closest("[data-page]"), y = Number(g?.dataset.page) - 1, v = l.pages[y]?.components[Number(m.dataset.mrComponentIndex)];
|
|
2783
|
+
if (!v?.grid || !g) return;
|
|
2784
|
+
m.style.transform = "", m.style.zIndex = "";
|
|
2785
|
+
const c = m.getBoundingClientRect(), T = g.getBoundingClientRect().bottom, D = Math.max(0, (i.left - c.left) / u), L = f.freezeHeaders ? Math.max(0, Math.min((i.top - c.top) / u, (T - c.bottom) / u)) : 0;
|
|
2786
|
+
D > 0 && p > 0 && (m.style.zIndex = "1"), v.table?.role === "header" && L > 0 && (m.style.transform = `translateY(${L}px)`, m.style.zIndex = "5"), m.querySelectorAll(".mrp-cell-frozen").forEach((B) => {
|
|
2787
|
+
B.style.transform = "", B.style.zIndex = "", B.classList.remove("mrp-cell-frozen");
|
|
2788
|
+
});
|
|
2789
|
+
const q = Array.from({ length: p }, (B, U) => `td[data-mr-column-index="${U}"]`);
|
|
2790
|
+
!v.table && f.freezeHeaders && q.push('td[data-mr-row-index="0"]'), q.length && m.querySelectorAll(q.join(",")).forEach((B) => {
|
|
2791
|
+
const U = Number(B.dataset.mrColumnIndex) < p, X = !v.table && Number(B.dataset.mrRowIndex) === 0 && !!f.freezeHeaders, G = U ? D : 0, Q = X ? L : 0;
|
|
2792
|
+
B.style.transform = G || Q ? `translate(${G}px, ${Q}px)` : "", B.classList.toggle("mrp-cell-frozen", !!(G || Q)), B.style.zIndex = G || Q ? X ? "7" : "6" : "";
|
|
2793
|
+
});
|
|
2794
|
+
}), a = !!f.freezeHeaders || p > 0;
|
|
2795
|
+
}
|
|
2796
|
+
function o() {
|
|
2797
|
+
t || (t = requestAnimationFrame(() => {
|
|
2798
|
+
t = 0, n();
|
|
2799
|
+
}));
|
|
2800
|
+
}
|
|
2801
|
+
return Oe(() => {
|
|
2802
|
+
t && cancelAnimationFrame(t);
|
|
2803
|
+
}), { refresh: n, schedule: o };
|
|
2804
|
+
}
|
|
2805
|
+
async function An(e, t, a, n) {
|
|
2806
|
+
if (!t?.assetRenderers || !Object.keys(t.assetRenderers).length) return e;
|
|
2807
|
+
try {
|
|
2808
|
+
return (await Fa(e, { ...t, signal: a, format: "dom", onDiagnostic: (r) => {
|
|
2809
|
+
a.aborted || (t.onDiagnostic?.(r), n(r.message));
|
|
2810
|
+
} })).plan;
|
|
2811
|
+
} catch (o) {
|
|
2812
|
+
throw a.aborted ? o : new ge("render", o instanceof Error ? o.message : "Report asset preparation failed", o);
|
|
2813
|
+
}
|
|
2814
|
+
}
|
|
2815
|
+
function Ln(e, t) {
|
|
2816
|
+
const a = Oa(e);
|
|
2817
|
+
if (!a.ok) throw new ge("validate", `渲染计划校验失败(${a.errors.length} 处): ${a.errors.slice(0, 3).map((n) => `${n.path}: ${n.message}`).join("; ")}`);
|
|
2818
|
+
a.warnings.forEach((n) => t(`${n.path}: ${n.message}`));
|
|
2819
|
+
}
|
|
2820
|
+
async function Xs(e, t, a, n) {
|
|
2821
|
+
const o = await Ke(e(t), t.signal);
|
|
2822
|
+
return Me(t.signal), n("validate"), Ln(o, t.onWarning ?? (() => {
|
|
2823
|
+
})), Me(t.signal), n("assets"), An(o, a, t.signal, t.onWarning ?? (() => {
|
|
2824
|
+
}));
|
|
2825
|
+
}
|
|
2826
|
+
async function Qs(e, t, a, n, o, r) {
|
|
2827
|
+
const { importExcelTemplate: s } = await import("@agile-team/mach-report/xlsx");
|
|
2828
|
+
Me(n);
|
|
2829
|
+
const l = await Ke(s(e, { ...t, signal: n }), n);
|
|
2830
|
+
r("layout");
|
|
2831
|
+
const f = Da(ve(l.template), {}).plan;
|
|
2832
|
+
Ln(f, o), Me(n), r("assets");
|
|
2833
|
+
const p = await An(f, a, n, o);
|
|
2834
|
+
return { result: l, plan: p };
|
|
2835
|
+
}
|
|
2836
|
+
const _s = {
|
|
2837
|
+
key: 7,
|
|
2838
|
+
class: "mrp-edit-hint",
|
|
2839
|
+
role: "status"
|
|
2840
|
+
}, el = {
|
|
2841
|
+
key: 9,
|
|
2842
|
+
class: "mrp-export-notice mrp-export-warning",
|
|
2843
|
+
role: "status"
|
|
2844
|
+
}, tl = { class: "mrp-main" }, nl = {
|
|
2845
|
+
key: 0,
|
|
2846
|
+
class: "mrp-state"
|
|
2847
|
+
}, al = {
|
|
2848
|
+
key: 1,
|
|
2849
|
+
class: "mrp-state mrp-error"
|
|
2850
|
+
}, rl = ["data-page"], ol = ["aria-label", "aria-current", "onClick"], sl = ["data-thumb"], ll = { class: "mrp-thumb-no" }, il = { class: "mrp-overlay" }, ul = {
|
|
2851
|
+
key: 10,
|
|
2852
|
+
class: "mrp-debug",
|
|
2853
|
+
"aria-hidden": "true"
|
|
2854
|
+
}, Tt = 96 / 25.4, Ft = "mach-report:ui", Dt = "mach-report:ui:wide", cl = /* @__PURE__ */ xe({
|
|
2855
|
+
__name: "ReportPreview",
|
|
2856
|
+
props: {
|
|
2857
|
+
reportId: {
|
|
2858
|
+
type: [String, Array],
|
|
2859
|
+
default: null
|
|
2860
|
+
},
|
|
2861
|
+
params: {
|
|
2862
|
+
type: Object,
|
|
2863
|
+
default: () => ({})
|
|
2864
|
+
},
|
|
2865
|
+
height: { type: String, default: "100vh" },
|
|
2866
|
+
autoLoad: { type: Boolean, default: !0 },
|
|
2867
|
+
/** 以下显隐/间距不传时走配置中心(preset > defaults > 内置缺省) */
|
|
2868
|
+
showExport: { type: Boolean, default: void 0 },
|
|
2869
|
+
showPrint: { type: Boolean, default: void 0 },
|
|
2870
|
+
showPdfWindow: { type: Boolean, default: void 0 },
|
|
2871
|
+
showSettings: { type: Boolean, default: void 0 },
|
|
2872
|
+
toolbar: { type: Object, default: void 0 },
|
|
2873
|
+
interaction: { type: Object, default: void 0 },
|
|
2874
|
+
preferences: { type: Object, default: void 0 },
|
|
2875
|
+
guardChanges: { type: Boolean, default: void 0 },
|
|
2876
|
+
beforeDiscard: { type: Function, default: void 0 },
|
|
2877
|
+
output: { type: Object, default: void 0 },
|
|
2878
|
+
assets: { type: Object, default: void 0 },
|
|
2879
|
+
/** 保留表头的零行业务结果;不改变计划和导出内容。 */
|
|
2880
|
+
emptyState: { type: [Boolean, Object], default: !1 },
|
|
2881
|
+
/** 页间距(px);不传走配置中心 */
|
|
2882
|
+
gapPx: { type: Number, default: void 0 },
|
|
2883
|
+
/** 工具栏/状态文案覆写(不传走配置中心 messages) */
|
|
2884
|
+
messages: { type: Object, default: void 0 },
|
|
2885
|
+
/** 启用的 preset 名(不传用配置中心 defaultPreset) */
|
|
2886
|
+
preset: { type: String, default: void 0 },
|
|
2887
|
+
/** 调试面板(也可用 URL ?mrp-debug=1 开启) */
|
|
2888
|
+
debug: { type: Boolean, default: !1 },
|
|
2889
|
+
/** 参数定义(优先级:prop > 模板 params;有定义且未关闭时显示查询面板) */
|
|
2890
|
+
paramDefs: {
|
|
2891
|
+
type: Array,
|
|
2892
|
+
default: void 0
|
|
2893
|
+
},
|
|
2894
|
+
/** 参数面板显隐(不传走配置中心,缺省 true;有参数定义才渲染) */
|
|
2895
|
+
showParams: { type: Boolean, default: void 0 },
|
|
2896
|
+
editable: { type: [Boolean, Object], default: void 0 },
|
|
2897
|
+
excelImport: { type: [Boolean, Object], default: void 0 },
|
|
2898
|
+
fetcher: {
|
|
2899
|
+
type: Function,
|
|
2900
|
+
default: null
|
|
2901
|
+
}
|
|
2902
|
+
},
|
|
2903
|
+
emits: ["loaded", "task", "diagnostic", "error", "warning", "cell-edit", "template-import", "preferences-change"],
|
|
2904
|
+
setup(e, { expose: t, emit: a }) {
|
|
2905
|
+
const n = e, o = a, r = ae(null), s = J(!1), l = J(""), f = ae(null), p = J(null), u = J(!1), i = J(null), m = J(1), g = J(null), y = J(null), v = J(null), c = J(!1), T = J(!1), D = J(!1), L = ae(null), q = J(null), B = J(null), U = or();
|
|
2906
|
+
let X = null, G = !1;
|
|
2907
|
+
const Q = xo((d) => o("task", d)), h = ko((d) => o("diagnostic", d)), M = ae(null), $ = A(() => !!r.value?.pages.length && r.value.pages.every((d) => d.layout === "wide"));
|
|
2908
|
+
let k = Ft;
|
|
2909
|
+
const F = ct(Ba, null), z = ct(ja, null), N = A(() => Rn(n.reportId)), Z = A(() => n.fetcher ?? F), H = A(() => r.value?.pages.length ?? 0), V = A(() => Object.freeze({
|
|
2910
|
+
loading: s.value,
|
|
2911
|
+
hasPlan: H.value > 0,
|
|
2912
|
+
pageCount: H.value,
|
|
2913
|
+
currentPage: m.value,
|
|
2914
|
+
exporting: p.value,
|
|
2915
|
+
printing: u.value,
|
|
2916
|
+
canExport: !s.value && !T.value && !W.saving.value && H.value > 0 && p.value === null,
|
|
2917
|
+
canPrint: !s.value && !T.value && !W.saving.value && H.value > 0 && !u.value,
|
|
2918
|
+
error: f.value,
|
|
2919
|
+
pdfFont: Gt.value,
|
|
2920
|
+
editing: W.active.value !== null,
|
|
2921
|
+
saving: W.saving.value,
|
|
2922
|
+
importing: T.value,
|
|
2923
|
+
dirty: W.differences.value.length > 0,
|
|
2924
|
+
pendingLocalChanges: W.pendingLocalChanges.value,
|
|
2925
|
+
task: Q.state.value,
|
|
2926
|
+
diagnostics: h.entries.value,
|
|
2927
|
+
reportIds: M.value?.reportIds ?? [],
|
|
2928
|
+
params: M.value?.params ?? {},
|
|
2929
|
+
canUndo: W.canUndo.value,
|
|
2930
|
+
canRedo: W.canRedo.value,
|
|
2931
|
+
changeCount: W.differences.value.length,
|
|
2932
|
+
selection: ne.selection.value ? ve(ne.selection.value) : null
|
|
2933
|
+
}));
|
|
2934
|
+
function w(d, E, O) {
|
|
2935
|
+
f.value = Object.freeze({ message: d, code: E, cause: O }), o("error", d, { code: E, cause: O });
|
|
2936
|
+
}
|
|
2937
|
+
const {
|
|
2938
|
+
resolved: S,
|
|
2939
|
+
resolvedMessages: x,
|
|
2940
|
+
effectiveShowExport: K,
|
|
2941
|
+
effectiveShowSettings: Y,
|
|
2942
|
+
effectiveGuardChanges: _,
|
|
2943
|
+
effectiveOutput: ie,
|
|
2944
|
+
effectiveInteraction: ce,
|
|
2945
|
+
effectiveAssets: Pe,
|
|
2946
|
+
effectiveGapPx: _e,
|
|
2947
|
+
effectiveShowParams: zn,
|
|
2948
|
+
availableTools: qn,
|
|
2949
|
+
tools: Kt,
|
|
2950
|
+
toolState: ue,
|
|
2951
|
+
visibleExportFormats: Bn,
|
|
2952
|
+
effectiveEditable: et,
|
|
2953
|
+
effectiveExcelImport: tt,
|
|
2954
|
+
persistedEditing: Ut,
|
|
2955
|
+
emptyStateContent: pt,
|
|
2956
|
+
sessionInteraction: gt
|
|
2957
|
+
} = Bs(n, $, (d) => o("warning", d)), Vt = A(() => ue.value.pdf || ue.value.pdfWindow), { pdfFont: Gt, getPdfExporter: jn, checkPdfFont: Nn, retryPdfFont: Jt, cancelFontCheck: Wn } = bo({
|
|
2958
|
+
plan: r,
|
|
2959
|
+
fontUrl: () => S.value.pdfFontUrl,
|
|
2960
|
+
enabled: () => Vt.value,
|
|
2961
|
+
injectedExporter: z,
|
|
2962
|
+
destroyed: () => G
|
|
2963
|
+
});
|
|
2964
|
+
async function Hn(d, E) {
|
|
2965
|
+
d === "editing" && !E && !await W.commit() || (Kt.setEnabled(d, E), o("preferences-change", Object.freeze({ ...ue.value })));
|
|
2966
|
+
}
|
|
2967
|
+
async function Kn() {
|
|
2968
|
+
await W.commit() && (Kt.reset(), gt.value = {}, o("preferences-change", Object.freeze({ ...ue.value })));
|
|
2969
|
+
}
|
|
2970
|
+
async function Un() {
|
|
2971
|
+
if (D.value) {
|
|
2972
|
+
D.value = !1;
|
|
2973
|
+
return;
|
|
2974
|
+
}
|
|
2975
|
+
!await W.commit() || G || !Y.value || (D.value = !0);
|
|
2976
|
+
}
|
|
2977
|
+
function Zt(d) {
|
|
2978
|
+
return d instanceof De ? {
|
|
2979
|
+
number: x.value.editInvalidNumber,
|
|
2980
|
+
boolean: x.value.editInvalidBoolean,
|
|
2981
|
+
conflict: x.value.editConflict,
|
|
2982
|
+
atomic: x.value.editAtomicRequired,
|
|
2983
|
+
limit: x.value.clipboardLimit,
|
|
2984
|
+
readonly: x.value.editReadOnly,
|
|
2985
|
+
missing: x.value.editMissing,
|
|
2986
|
+
duplicate: x.value.editDuplicate,
|
|
2987
|
+
clipboard: x.value.clipboardInvalid
|
|
2988
|
+
}[d.code] ?? d.message : d instanceof Error ? d.message : "单元格保存失败";
|
|
2989
|
+
}
|
|
2990
|
+
const W = zs({
|
|
2991
|
+
plan: r,
|
|
2992
|
+
options: et,
|
|
2993
|
+
blocked: () => s.value || T.value || p.value !== null || u.value || Ie.pending.value,
|
|
2994
|
+
label: () => x.value.editCell ?? "编辑单元格",
|
|
2995
|
+
errorMessage: Zt,
|
|
2996
|
+
suspendBlur: () => Ie.request.value !== null,
|
|
2997
|
+
onChange: (d) => {
|
|
2998
|
+
f.value = null, i.value = null, o("cell-edit", d);
|
|
2999
|
+
},
|
|
3000
|
+
onError: (d, E) => {
|
|
3001
|
+
i.value = { kind: "error", message: d }, w(d, "edit", E);
|
|
3002
|
+
},
|
|
3003
|
+
onNavigate: (d, E, O) => ne.navigate(d, E, O)
|
|
3004
|
+
}), ne = Zs({
|
|
3005
|
+
plan: r,
|
|
3006
|
+
root: g,
|
|
3007
|
+
enabled: () => !!et.value,
|
|
3008
|
+
busy: () => s.value || T.value || W.saving.value || !!p.value || u.value || Ie.pending.value,
|
|
3009
|
+
differences: () => W.differences.value,
|
|
3010
|
+
gotoPage: he,
|
|
3011
|
+
edit: W.editCell,
|
|
3012
|
+
apply: W.apply,
|
|
3013
|
+
undo: W.undo,
|
|
3014
|
+
redo: W.redo,
|
|
3015
|
+
error: (d) => {
|
|
3016
|
+
const E = Zt(d);
|
|
3017
|
+
i.value = { kind: "error", message: E }, w(E, "edit", d);
|
|
3018
|
+
}
|
|
3019
|
+
}), Ie = yo({
|
|
3020
|
+
pending: () => W.pendingLocalChanges.value,
|
|
3021
|
+
reportIds: () => M.value?.reportIds ?? N.value,
|
|
3022
|
+
hook: () => n.beforeDiscard ?? S.value.beforeDiscard,
|
|
3023
|
+
enabled: () => _.value,
|
|
3024
|
+
snapshot: () => [r.value, W.active.value?.editor.input.value],
|
|
3025
|
+
error: (d) => w(d instanceof Error ? d.message : "修改保护回调失败", "config", d)
|
|
3026
|
+
});
|
|
3027
|
+
async function Vn(d = "leave") {
|
|
3028
|
+
return Ie.check(d);
|
|
3029
|
+
}
|
|
3030
|
+
function Yt(d) {
|
|
3031
|
+
!_.value || !W.pendingLocalChanges.value || (d.preventDefault(), d.returnValue = "");
|
|
3032
|
+
}
|
|
3033
|
+
function Xt() {
|
|
3034
|
+
Q.cancel();
|
|
3035
|
+
}
|
|
3036
|
+
async function Gn(d) {
|
|
3037
|
+
await ne.focusField(d) || (i.value = { kind: "warning", message: x.value.locateFieldMissing ?? "Field not found" });
|
|
3038
|
+
}
|
|
3039
|
+
function Jn(d) {
|
|
3040
|
+
if (d.pageIndex === void 0) return;
|
|
3041
|
+
he(d.pageIndex + 1);
|
|
3042
|
+
const E = d.componentPath;
|
|
3043
|
+
d.componentIndex !== void 0 && E && E.length === 2 && ne.focusCell({ pageIndex: d.pageIndex, componentIndex: d.componentIndex, rowIndex: E[0], columnIndex: E[1] });
|
|
3044
|
+
}
|
|
3045
|
+
function vt(d) {
|
|
3046
|
+
const E = r.value;
|
|
3047
|
+
if (!E) return !1;
|
|
3048
|
+
const O = { excel: "xlsx", image: "png", doc: "word" }[d] ?? d, re = O === "pdf" ? "pdf" : O === "xlsx" ? "xlsx" : O === "png" ? "canvas" : "dom", ee = h.inspect(E, re);
|
|
3049
|
+
return r.value !== E ? !1 : ee.length && ie.value.fidelity === "strict" ? (i.value = { kind: "error", message: x.value.diagnosticsStrict ?? "输出存在已知降级" }, w(i.value.message, "export", { diagnostics: ee }), !1) : !0;
|
|
3050
|
+
}
|
|
3051
|
+
function Zn(d) {
|
|
3052
|
+
return r.value ? h.inspect(r.value, d) : [];
|
|
3053
|
+
}
|
|
3054
|
+
const Yn = A(() => {
|
|
3055
|
+
if (L.value) return L.value.sheets.map((E) => ({ label: E.name, pageIndex: E.pageStart }));
|
|
3056
|
+
const d = /* @__PURE__ */ new Set();
|
|
3057
|
+
return r.value?.pages.flatMap((E, O) => E.components.flatMap((re) => {
|
|
3058
|
+
const ee = re.table;
|
|
3059
|
+
return !ee?.title || d.has(ee.id) ? [] : (d.add(ee.id), [{ label: ee.title, pageIndex: O }]);
|
|
3060
|
+
})) ?? [];
|
|
3061
|
+
});
|
|
3062
|
+
async function Xn(d) {
|
|
3063
|
+
d && !await ne.focusField({ field: d }) && (i.value = { kind: "warning", message: x.value.locateFieldMissing ?? "Field not found" });
|
|
3064
|
+
}
|
|
3065
|
+
const ht = A(() => {
|
|
3066
|
+
try {
|
|
3067
|
+
return { defs: n.paramDefs ?? Z.value?.getParamDefs?.(N.value) ?? [], error: null };
|
|
3068
|
+
} catch (d) {
|
|
3069
|
+
return { defs: [], error: new ge("config", d instanceof Error ? d.message : "查询参数配置无效", d) };
|
|
3070
|
+
}
|
|
3071
|
+
}), bt = A(() => ht.value.defs), Ue = Co({ defs: bt, reportIds: N, params: () => n.params, messages: () => x.value }), { values: Ve, attempted: nt, pendingRequired: Qt } = Ue, _t = J(null);
|
|
3072
|
+
function Qn() {
|
|
3073
|
+
nt.value = !0, Ue.validation.value.ok || Qe(() => _t.value?.focusInvalid()), ze();
|
|
3074
|
+
}
|
|
3075
|
+
function _n() {
|
|
3076
|
+
Ue.reset(), l.value = "", f.value = null;
|
|
3077
|
+
}
|
|
3078
|
+
const ea = A(() => ({
|
|
3079
|
+
height: n.height,
|
|
3080
|
+
"--mrp-page-gap": `${Math.max(0, _e.value)}px`,
|
|
3081
|
+
...Cs(S.value.theme)
|
|
3082
|
+
})), { zoom: de, zoomMode: Ge, applyFitZoom: en, setZoom: Je } = Ka(() => ({
|
|
3083
|
+
viewport: y.value,
|
|
3084
|
+
pageWidthPx: yt.contentSize.value.w || 210 * Tt
|
|
3085
|
+
})), yt = Wa(r, de, {
|
|
3086
|
+
pxPerMm: Tt,
|
|
3087
|
+
gapPx: _e,
|
|
3088
|
+
overscan: A(() => S.value.preview.overscanPages)
|
|
3089
|
+
}), { contentSize: wt, windowRange: Ze, visiblePages: tn, makeScrollHandler: ta, refreshViewport: xt } = yt, na = ta(m, H), kt = Ys({ root: g, viewport: y, plan: r, zoom: de, options: () => ce.value });
|
|
3090
|
+
le([ce, de], () => kt.schedule(), { flush: "post" });
|
|
3091
|
+
function It(d) {
|
|
3092
|
+
Je(d * 100);
|
|
3093
|
+
}
|
|
3094
|
+
function Le() {
|
|
3095
|
+
T.value = !1, W.reset(), ne.reset(), L.value = null, an(), r.value = null, M.value = null, h.reset(), m.value = 1, te.reset();
|
|
3096
|
+
}
|
|
3097
|
+
let oe = 0, se = null;
|
|
3098
|
+
function at(d, E) {
|
|
3099
|
+
return d === oe && !E.signal.aborted && !G;
|
|
3100
|
+
}
|
|
3101
|
+
function nn() {
|
|
3102
|
+
y.value && (y.value.scrollTop = 0, y.value.scrollLeft = 0);
|
|
3103
|
+
}
|
|
3104
|
+
function aa(d, E) {
|
|
3105
|
+
for (const O of d) {
|
|
3106
|
+
if (E !== oe) return !1;
|
|
3107
|
+
o("warning", O);
|
|
3108
|
+
}
|
|
3109
|
+
return E === oe;
|
|
3110
|
+
}
|
|
3111
|
+
function ra() {
|
|
3112
|
+
if (ht.value.error) {
|
|
3113
|
+
const E = ht.value.error;
|
|
3114
|
+
return Le(), l.value = E.message, w(E.message, E.code, E.cause), null;
|
|
3115
|
+
}
|
|
3116
|
+
const d = Ue.query();
|
|
3117
|
+
return d.params ? d.params : (Le(), l.value = d.quiet ? "" : d.error.message, d.quiet || (nt.value = !0, w(d.error.message, d.error.code, d.error.cause)), null);
|
|
3118
|
+
}
|
|
3119
|
+
async function ze() {
|
|
3120
|
+
if (G || _.value && W.pendingLocalChanges.value && !await Ie.check("reload") || G) return;
|
|
3121
|
+
const d = ++oe;
|
|
3122
|
+
T.value = !1, se?.abort(), se = null;
|
|
3123
|
+
const E = Z.value;
|
|
3124
|
+
if (s.value = !1, f.value = null, N.value.length === 0) {
|
|
3125
|
+
l.value = "缺少报表 ID", Le(), w(l.value, "param");
|
|
3126
|
+
return;
|
|
3127
|
+
}
|
|
3128
|
+
if (!E) {
|
|
3129
|
+
l.value = "未提供渲染数据源 fetcher", Le(), w(l.value, "config");
|
|
3130
|
+
return;
|
|
3131
|
+
}
|
|
3132
|
+
const O = ra();
|
|
3133
|
+
if (!O) return;
|
|
3134
|
+
s.value = !0, l.value = "", i.value = null, Le();
|
|
3135
|
+
const re = U.start(), ee = new AbortController();
|
|
3136
|
+
se = ee;
|
|
3137
|
+
const Ce = Q.start("query", "query", () => {
|
|
3138
|
+
se === ee && (ee.abort(), oe++, se = null, s.value = !1);
|
|
3139
|
+
}), rt = [...N.value], be = Object.freeze({ ...O }), Se = /* @__PURE__ */ new Set();
|
|
3140
|
+
function je(me) {
|
|
3141
|
+
d !== oe || ee.signal.aborted || Se.has(me) || (Se.add(me), S.value.logger.warn("[mach-report] 报表告警:", me), h.add({ code: "layout", severity: "warning", message: me }), o("warning", me));
|
|
3142
|
+
}
|
|
3143
|
+
try {
|
|
3144
|
+
const me = await Xs(E, {
|
|
3145
|
+
reportIds: rt,
|
|
3146
|
+
params: O,
|
|
3147
|
+
taskId: Ce.taskId,
|
|
3148
|
+
onEvent: (Ae) => {
|
|
3149
|
+
d === oe && !ee.signal.aborted && Ce.update(Ae.stage, Ae.completed, Ae.total);
|
|
3150
|
+
},
|
|
3151
|
+
onQueryResult: (Ae, va) => {
|
|
3152
|
+
d === oe && !ee.signal.aborted && h.addMany(va.diagnostics ?? []);
|
|
3153
|
+
},
|
|
3154
|
+
signal: ee.signal,
|
|
3155
|
+
onWarning: je
|
|
3156
|
+
}, Pe.value, Ce.update);
|
|
3157
|
+
if (!at(d, ee) || (r.value = me, M.value = Object.freeze({ reportIds: Object.freeze(rt), params: be }), h.inspect(me, "dom"), !at(d, ee))) return;
|
|
3158
|
+
Ce.finish(), m.value = 1, U.end(re), nn();
|
|
3159
|
+
const Ne = $.value ? Dt : Ft;
|
|
3160
|
+
Ne !== k && (k = Ne, $t()), Ge.value === "fit" && en(), o("loaded", me.pages.length);
|
|
3161
|
+
} catch (me) {
|
|
3162
|
+
if (d !== oe) return;
|
|
3163
|
+
if (ee.signal.aborted) {
|
|
3164
|
+
Ce.finish("cancelled");
|
|
3165
|
+
return;
|
|
3166
|
+
}
|
|
3167
|
+
Ce.finish("failed");
|
|
3168
|
+
const Ne = mo(me);
|
|
3169
|
+
l.value = Ne.message;
|
|
3170
|
+
const Ae = fo(Ne);
|
|
3171
|
+
w(Ne.message, Ae.code, Ae.cause);
|
|
3172
|
+
} finally {
|
|
3173
|
+
d === oe && (s.value = !1), se === ee && (se = null);
|
|
3174
|
+
}
|
|
3175
|
+
}
|
|
3176
|
+
function he(d) {
|
|
3177
|
+
if (G || H.value <= 0) return;
|
|
3178
|
+
const E = Math.max(1, Math.min(H.value, d));
|
|
3179
|
+
m.value = E;
|
|
3180
|
+
const O = y.value;
|
|
3181
|
+
O && (O.scrollTop = yt.pageOffsetPx(E - 1) * de.value, xt(O), pa.prioritize(E - 1));
|
|
3182
|
+
}
|
|
3183
|
+
const qe = Ga(r, {
|
|
3184
|
+
getPdfExporter: jn,
|
|
3185
|
+
onTask: (d) => Q.receive(d, () => qe.cancel()),
|
|
3186
|
+
onDiagnostic: h.add,
|
|
3187
|
+
getXlsxOptions: () => S.value.xlsx,
|
|
3188
|
+
onError: (d, E) => {
|
|
3189
|
+
i.value = { kind: "error", message: d }, w(d, E ?? "print");
|
|
3190
|
+
},
|
|
3191
|
+
onWarning: (d) => {
|
|
3192
|
+
i.value = { kind: "warning", message: d }, h.add({ code: "output", severity: "warning", message: d }), o("warning", d);
|
|
3193
|
+
},
|
|
3194
|
+
onBusy: (d) => {
|
|
3195
|
+
p.value = d, d ? i.value = {
|
|
3196
|
+
kind: "progress",
|
|
3197
|
+
message: x.value.exporting.replace("{format}", d)
|
|
3198
|
+
} : i.value?.kind === "progress" && (i.value = null);
|
|
3199
|
+
},
|
|
3200
|
+
onPrinting: (d) => {
|
|
3201
|
+
u.value = d;
|
|
3202
|
+
}
|
|
3203
|
+
}), { releasePrintFrame: an, dispose: oa } = qe;
|
|
3204
|
+
async function rn() {
|
|
3205
|
+
s.value || T.value || W.active.value && !await W.commit() || (f.value = null, vt("html") && await qe.print());
|
|
3206
|
+
}
|
|
3207
|
+
async function on(d) {
|
|
3208
|
+
s.value || T.value || W.active.value && !await W.commit() || (f.value = null, vt(d) && await qe.exportAs(d));
|
|
3209
|
+
}
|
|
3210
|
+
function sn() {
|
|
3211
|
+
if (s.value || T.value || W.active.value) {
|
|
3212
|
+
i.value = { kind: "warning", message: x.value.editingHint ?? "请先确认单元格修改" };
|
|
3213
|
+
return;
|
|
3214
|
+
}
|
|
3215
|
+
f.value = null, vt("pdf") && qe.openPdfWindow();
|
|
3216
|
+
}
|
|
3217
|
+
async function sa(d, E = {}) {
|
|
3218
|
+
G || (Ve.value = { ...Ve.value, ...d }, E.reload !== !1 && (nt.value = !0, await ze()));
|
|
3219
|
+
}
|
|
3220
|
+
const ln = {
|
|
3221
|
+
reload: ze,
|
|
3222
|
+
print: rn,
|
|
3223
|
+
exportAs: on,
|
|
3224
|
+
openPdfWindow: sn,
|
|
3225
|
+
gotoPage: he,
|
|
3226
|
+
setParams: sa,
|
|
3227
|
+
checkPdfFont: Nn,
|
|
3228
|
+
importExcel: un,
|
|
3229
|
+
getPlan: la,
|
|
3230
|
+
cancelTask: Xt,
|
|
3231
|
+
confirmDiscard: Vn,
|
|
3232
|
+
getOutputDiagnostics: Zn,
|
|
3233
|
+
getChanges: W.getChanges,
|
|
3234
|
+
undo: W.undo,
|
|
3235
|
+
redo: W.redo,
|
|
3236
|
+
restoreChanges: W.restore,
|
|
3237
|
+
getDifferences: () => ve(W.differences.value),
|
|
3238
|
+
getSelection: () => ne.selection.value ? ve(ne.selection.value) : null,
|
|
3239
|
+
focusCell: ne.focusCell,
|
|
3240
|
+
focusField: ne.focusField,
|
|
3241
|
+
copySelection: ne.copySelection,
|
|
3242
|
+
pasteSelection: ne.pasteSelection,
|
|
3243
|
+
get state() {
|
|
3244
|
+
return V.value;
|
|
3245
|
+
}
|
|
3246
|
+
};
|
|
3247
|
+
En(Na, ln);
|
|
3248
|
+
function la() {
|
|
3249
|
+
return r.value ? ve(r.value) : null;
|
|
3250
|
+
}
|
|
3251
|
+
function ia(d) {
|
|
3252
|
+
const E = typeof tt.value == "object" ? tt.value : {};
|
|
3253
|
+
return { ...E, ...d, limits: { ...E.limits, ...d?.limits } };
|
|
3254
|
+
}
|
|
3255
|
+
function ua(d, E) {
|
|
3256
|
+
W.reset(), ne.reset(), an(), te.reset(), r.value = d, M.value = null, h.reset(), L.value = { sheets: ve(E.sheets), warnings: [...E.warnings] }, m.value = 1, l.value = "", i.value = E.warnings.length ? { kind: "warning", message: E.warnings.join(";") } : null, nn(), k = $.value ? Dt : Ft, $t(), h.addMany(E.warnings.map((O) => ({ code: "excel-import", severity: "warning", message: O }))), r.value === d && h.inspect(d, "dom");
|
|
3257
|
+
}
|
|
3258
|
+
async function un(d, E) {
|
|
3259
|
+
if (G) throw new ge("config", "报表预览已卸载");
|
|
3260
|
+
if (_.value && W.pendingLocalChanges.value && !await Ie.check("import") || G) return null;
|
|
3261
|
+
const O = ++oe;
|
|
3262
|
+
se?.abort(), se = null, s.value = !1, W.cancel(), qe.invalidatePending(), T.value = !0;
|
|
3263
|
+
const re = new AbortController();
|
|
3264
|
+
se = re, f.value = null, i.value = { kind: "progress", message: x.value.importing ?? "正在导入 Excel…" };
|
|
3265
|
+
const ee = Q.start("import", "import", () => {
|
|
3266
|
+
se === re && (re.abort(), oe++, se = null, T.value = !1, i.value = null);
|
|
3267
|
+
}), Ce = ia(E), rt = La(Ce.signal, re);
|
|
3268
|
+
try {
|
|
3269
|
+
const { result: be, plan: Se } = await Qs(d, {
|
|
3270
|
+
...Ce,
|
|
3271
|
+
onProgress: (je, me) => {
|
|
3272
|
+
ee.update("import", je, me), Ce.onProgress?.(je, me);
|
|
3273
|
+
}
|
|
3274
|
+
}, Pe.value, re.signal, (je) => {
|
|
3275
|
+
O === oe && o("warning", je);
|
|
3276
|
+
}, ee.update);
|
|
3277
|
+
return !at(O, re) || !aa(be.warnings, O) || (ua(Se, be), !at(O, re)) ? null : (ee.finish(), o("template-import", be), O === oe && o("loaded", Se.pages.length), be);
|
|
3278
|
+
} catch (be) {
|
|
3279
|
+
if (O !== oe) return null;
|
|
3280
|
+
if (re.signal.aborted)
|
|
3281
|
+
return ee.finish("cancelled"), null;
|
|
3282
|
+
ee.finish("failed");
|
|
3283
|
+
const Se = new ge("import", be instanceof Error ? be.message : "Excel 模板导入失败", be);
|
|
3284
|
+
throw i.value = { kind: "error", message: Se.message }, w(Se.message, "import", be), Se;
|
|
3285
|
+
} finally {
|
|
3286
|
+
rt(), O === oe && (T.value = !1), se === re && (se = null);
|
|
3287
|
+
}
|
|
3288
|
+
}
|
|
3289
|
+
function ca(d) {
|
|
3290
|
+
const E = d.target, O = E.files?.[0];
|
|
3291
|
+
E.value = "", O && un(O).catch(() => {
|
|
3292
|
+
});
|
|
3293
|
+
}
|
|
3294
|
+
const te = nr({
|
|
3295
|
+
plan: r,
|
|
3296
|
+
gotoPage: he,
|
|
3297
|
+
debounceMs: A(() => S.value.preview.searchDebounceMs),
|
|
3298
|
+
highlight: Za,
|
|
3299
|
+
clearHighlights: Ja
|
|
3300
|
+
});
|
|
3301
|
+
le(() => ue.value.search, (d) => {
|
|
3302
|
+
d || (te.reset(), te.visible.value = !1);
|
|
3303
|
+
});
|
|
3304
|
+
function da(d) {
|
|
3305
|
+
!d.ctrlKey || !ue.value.zoom || (d.preventDefault(), It(de.value * (d.deltaY < 0 ? 1.1 : 1 / 1.1)));
|
|
3306
|
+
}
|
|
3307
|
+
function fa(d) {
|
|
3308
|
+
if (!ne.onKeydown(d) && !(d.target instanceof Element && d.target.closest("input,textarea,select,[contenteditable='true']"))) {
|
|
3309
|
+
if (ue.value.search && (d.ctrlKey || d.metaKey) && d.key.toLowerCase() === "f") {
|
|
3310
|
+
d.preventDefault(), te.visible.value || te.toggle(), Qe(() => B.value?.focusSearch());
|
|
3311
|
+
return;
|
|
3312
|
+
}
|
|
3313
|
+
switch (d.key) {
|
|
3314
|
+
case "PageDown":
|
|
3315
|
+
d.preventDefault(), he(m.value + 1);
|
|
3316
|
+
break;
|
|
3317
|
+
case "PageUp":
|
|
3318
|
+
d.preventDefault(), he(m.value - 1);
|
|
3319
|
+
break;
|
|
3320
|
+
case "Home":
|
|
3321
|
+
d.preventDefault(), he(1);
|
|
3322
|
+
break;
|
|
3323
|
+
case "End":
|
|
3324
|
+
d.preventDefault(), he(H.value);
|
|
3325
|
+
break;
|
|
3326
|
+
case "+":
|
|
3327
|
+
case "=":
|
|
3328
|
+
d.preventDefault(), ue.value.zoom && It(de.value * 1.1);
|
|
3329
|
+
break;
|
|
3330
|
+
case "-":
|
|
3331
|
+
d.preventDefault(), ue.value.zoom && It(de.value / 1.1);
|
|
3332
|
+
break;
|
|
3333
|
+
}
|
|
3334
|
+
}
|
|
3335
|
+
}
|
|
3336
|
+
function ma() {
|
|
3337
|
+
try {
|
|
3338
|
+
localStorage.setItem(
|
|
3339
|
+
k,
|
|
3340
|
+
JSON.stringify({ zoomMode: Ge.value === "fit" ? "fit" : Math.round(de.value * 100) })
|
|
3341
|
+
);
|
|
3342
|
+
} catch {
|
|
3343
|
+
}
|
|
3344
|
+
}
|
|
3345
|
+
le([Ge, de], ma);
|
|
3346
|
+
let Et = "";
|
|
3347
|
+
function cn(d = !1) {
|
|
3348
|
+
const E = te.activeMatch.value;
|
|
3349
|
+
if (!$.value || !E) return;
|
|
3350
|
+
const O = `${te.query.value}:${te.matchIndex.value}:${E.pageIndex}`;
|
|
3351
|
+
if (!d && O === Et) return;
|
|
3352
|
+
const ee = g.value?.querySelector(`[data-page="${E.pageIndex + 1}"]`)?.querySelectorAll("mark.mrp-hit")[E.occurrence];
|
|
3353
|
+
ee && (ee.scrollIntoView?.({ block: "nearest", inline: "nearest" }), Et = O);
|
|
3354
|
+
}
|
|
3355
|
+
const pa = Ha({
|
|
3356
|
+
plan: r,
|
|
3357
|
+
root: g,
|
|
3358
|
+
pages: () => tn.value,
|
|
3359
|
+
priority: () => te.activeMatch.value?.pageIndex ?? m.value - 1,
|
|
3360
|
+
focusToken: () => te.activeMatch.value,
|
|
3361
|
+
query: () => te.query.value,
|
|
3362
|
+
zoom: () => de.value,
|
|
3363
|
+
loading: () => x.value.loading,
|
|
3364
|
+
clear: te.clear,
|
|
3365
|
+
highlight: te.apply,
|
|
3366
|
+
mounted: (d) => {
|
|
3367
|
+
ne.refresh(d), kt.schedule();
|
|
3368
|
+
},
|
|
3369
|
+
ready: () => {
|
|
3370
|
+
te.activeMatch.value || (Et = ""), cn();
|
|
3371
|
+
},
|
|
3372
|
+
error: (d) => {
|
|
3373
|
+
l.value = d instanceof Error ? d.message : String(d), w(l.value, "render", d);
|
|
3374
|
+
}
|
|
3375
|
+
});
|
|
3376
|
+
le(() => ne.selection.value, () => {
|
|
3377
|
+
ne.refresh();
|
|
3378
|
+
}, { flush: "post" }), le(() => te.query.value, (d) => {
|
|
3379
|
+
d || g.value?.querySelectorAll(".mrp-page-holder").forEach((E) => {
|
|
3380
|
+
te.clear(E);
|
|
3381
|
+
});
|
|
3382
|
+
});
|
|
3383
|
+
const Ee = rr(r, {
|
|
3384
|
+
thumbsRoot: v,
|
|
3385
|
+
visible: c,
|
|
3386
|
+
renderThumbCanvas: (d) => {
|
|
3387
|
+
try {
|
|
3388
|
+
const E = r.value.pages[d], O = Math.min(0.2, 116 / Math.max(1, E.pageWidthMm * Tt)), { canvases: re } = Aa(r.value, { start: d, end: d, dpr: O });
|
|
3389
|
+
return re[0] ?? null;
|
|
3390
|
+
} catch {
|
|
3391
|
+
return null;
|
|
3392
|
+
}
|
|
3393
|
+
}
|
|
3394
|
+
});
|
|
3395
|
+
ba(() => {
|
|
3396
|
+
Ee.schedule();
|
|
3397
|
+
}, { flush: "post" });
|
|
3398
|
+
const ga = A(() => n.debug), { debugStats: Be } = ar(ga, {
|
|
3399
|
+
plan: r,
|
|
3400
|
+
pageCount: H,
|
|
3401
|
+
windowRange: Ze,
|
|
3402
|
+
zoom: de,
|
|
3403
|
+
loadMs: U.loadMs
|
|
3404
|
+
});
|
|
3405
|
+
function Ct() {
|
|
3406
|
+
xt(y.value), Ee.schedule(), Ge.value === "fit" && en(), cn(!0);
|
|
3407
|
+
}
|
|
3408
|
+
function $t() {
|
|
3409
|
+
Je(k === Dt ? 100 : "fit");
|
|
3410
|
+
try {
|
|
3411
|
+
const d = JSON.parse(localStorage.getItem(k) ?? "{}");
|
|
3412
|
+
d.zoomMode === "fit" ? Je("fit") : typeof d.zoomMode == "number" && Je(d.zoomMode);
|
|
3413
|
+
} catch {
|
|
3414
|
+
}
|
|
3415
|
+
}
|
|
3416
|
+
return Wt(() => {
|
|
3417
|
+
window.addEventListener("resize", Ct), window.addEventListener("beforeunload", Yt), typeof ResizeObserver < "u" && y.value && (X = new ResizeObserver(Ct), X.observe(y.value)), xt(y.value), $t(), n.autoLoad && ze();
|
|
3418
|
+
}), Ht(() => {
|
|
3419
|
+
G = !0, Ie.cancel(), Q.cancel(), W.reset(), T.value = !1, Wn(), oe++, se?.abort(), se = null, window.removeEventListener("resize", Ct), window.removeEventListener("beforeunload", Yt), X?.disconnect(), X = null, Ee.destroy(), te.reset(), oa();
|
|
3420
|
+
}), le(
|
|
3421
|
+
() => [JSON.stringify(N.value), JSON.stringify(n.params), Z.value],
|
|
3422
|
+
async () => {
|
|
3423
|
+
if (n.autoLoad) {
|
|
3424
|
+
ze();
|
|
3425
|
+
return;
|
|
3426
|
+
}
|
|
3427
|
+
!await Ie.check("replace") || G || (oe++, se?.abort(), se = null, s.value = !1, l.value = "", f.value = null, i.value = null, Le());
|
|
3428
|
+
}
|
|
3429
|
+
), t({ ...ln, state: V }), (d, E) => (I(), P("div", {
|
|
3430
|
+
class: ye(["mach-report-preview", { "mrp-wide-report": $.value }]),
|
|
3431
|
+
style: Re(ea.value)
|
|
3432
|
+
}, [
|
|
3433
|
+
b(zn) && bt.value.length > 0 ? (I(), Te(zo, {
|
|
3434
|
+
key: 0,
|
|
3435
|
+
ref_key: "paramPanelRef",
|
|
3436
|
+
ref: _t,
|
|
3437
|
+
defs: bt.value,
|
|
3438
|
+
modelValue: b(Ve),
|
|
3439
|
+
"onUpdate:modelValue": E[0] || (E[0] = (O) => ya(Ve) ? Ve.value = O : null),
|
|
3440
|
+
messages: b(x),
|
|
3441
|
+
attempted: b(nt),
|
|
3442
|
+
issues: b(Ue).validation.value.issues,
|
|
3443
|
+
onQuery: Qn,
|
|
3444
|
+
onReset: _n
|
|
3445
|
+
}, null, 8, ["defs", "modelValue", "messages", "attempted", "issues"])) : j("", !0),
|
|
3446
|
+
Pt(Mr, {
|
|
3447
|
+
ref_key: "toolbarRef",
|
|
3448
|
+
ref: B,
|
|
3449
|
+
"page-count": H.value,
|
|
3450
|
+
"current-page": m.value,
|
|
3451
|
+
"zoom-mode": b(Ge),
|
|
3452
|
+
zoom: b(de),
|
|
3453
|
+
"show-export": b(K),
|
|
3454
|
+
"show-print": b(ue).print,
|
|
3455
|
+
"show-pdf-window": b(ue).pdfWindow,
|
|
3456
|
+
"show-search": b(ue).search,
|
|
3457
|
+
"show-thumbnails": b(ue).thumbnails,
|
|
3458
|
+
"show-zoom": b(ue).zoom,
|
|
3459
|
+
"export-formats": b(Bn),
|
|
3460
|
+
"show-settings": b(Y),
|
|
3461
|
+
"settings-open": D.value,
|
|
3462
|
+
messages: b(x),
|
|
3463
|
+
search: { visible: b(te).visible.value, query: b(te).query.value, matchIndex: b(te).matchIndex.value, matchCount: b(te).matchCount.value, searching: b(te).searching.value },
|
|
3464
|
+
"thumbs-visible": c.value,
|
|
3465
|
+
"show-import": !!b(tt),
|
|
3466
|
+
busy: s.value || T.value || b(W).saving.value,
|
|
3467
|
+
onGoto: he,
|
|
3468
|
+
onZoom: b(Je),
|
|
3469
|
+
onExport: E[1] || (E[1] = (O) => on(O)),
|
|
3470
|
+
onPrint: rn,
|
|
3471
|
+
onPdfWindow: sn,
|
|
3472
|
+
onSearchInput: b(te).onInput,
|
|
3473
|
+
onSearchNav: b(te).onNav,
|
|
3474
|
+
onSearchToggle: b(te).toggle,
|
|
3475
|
+
onThumbsToggle: E[2] || (E[2] = (O) => c.value = !c.value),
|
|
3476
|
+
onImportExcel: E[3] || (E[3] = (O) => q.value?.click()),
|
|
3477
|
+
onSettingsToggle: Un
|
|
3478
|
+
}, null, 8, ["page-count", "current-page", "zoom-mode", "zoom", "show-export", "show-print", "show-pdf-window", "show-search", "show-thumbnails", "show-zoom", "export-formats", "show-settings", "settings-open", "messages", "search", "thumbs-visible", "show-import", "busy", "onZoom", "onSearchInput", "onSearchNav", "onSearchToggle"]),
|
|
3479
|
+
b(Ie).request.value ? (I(), Te(Qr, {
|
|
3480
|
+
key: 1,
|
|
3481
|
+
messages: b(x),
|
|
3482
|
+
onAnswer: b(Ie).settle
|
|
3483
|
+
}, null, 8, ["messages", "onAnswer"])) : j("", !0),
|
|
3484
|
+
Pt(ao, {
|
|
3485
|
+
task: b(Q).state.value,
|
|
3486
|
+
messages: b(x),
|
|
3487
|
+
onCancel: Xt
|
|
3488
|
+
}, null, 8, ["task", "messages"]),
|
|
3489
|
+
Pt(co, {
|
|
3490
|
+
entries: b(h).entries.value,
|
|
3491
|
+
messages: b(x),
|
|
3492
|
+
onLocate: Jn
|
|
3493
|
+
}, null, 8, ["entries", "messages"]),
|
|
3494
|
+
D.value && b(Y) ? (I(), Te(Vr, {
|
|
3495
|
+
key: 2,
|
|
3496
|
+
available: b(qn),
|
|
3497
|
+
enabled: b(ue),
|
|
3498
|
+
messages: b(x),
|
|
3499
|
+
"persisted-editing": b(Ut),
|
|
3500
|
+
interaction: b(ce),
|
|
3501
|
+
busy: s.value || T.value || b(W).saving.value || !!p.value || u.value,
|
|
3502
|
+
onInteraction: E[4] || (E[4] = (O) => gt.value = { ...b(gt), ...O }),
|
|
3503
|
+
onChange: Hn,
|
|
3504
|
+
onReset: Kn,
|
|
3505
|
+
onClose: E[5] || (E[5] = (O) => D.value = !1)
|
|
3506
|
+
}, {
|
|
3507
|
+
default: wa(() => [
|
|
3508
|
+
Ot(d.$slots, "settings", {}, void 0, !0)
|
|
3509
|
+
]),
|
|
3510
|
+
_: 3
|
|
3511
|
+
}, 8, ["available", "enabled", "messages", "persisted-editing", "interaction", "busy"])) : j("", !0),
|
|
3512
|
+
H.value > 0 && b(ce).navigation !== !1 ? (I(), Te(ps, {
|
|
3513
|
+
key: 3,
|
|
3514
|
+
plan: r.value,
|
|
3515
|
+
onLocateTarget: Gn,
|
|
3516
|
+
sections: Yn.value,
|
|
3517
|
+
"current-page": m.value,
|
|
3518
|
+
messages: b(x),
|
|
3519
|
+
busy: s.value || T.value || b(W).saving.value,
|
|
3520
|
+
onGoto: he,
|
|
3521
|
+
onLocate: Xn
|
|
3522
|
+
}, null, 8, ["plan", "sections", "current-page", "messages", "busy"])) : j("", !0),
|
|
3523
|
+
L.value ? (I(), Te(ys, {
|
|
3524
|
+
key: 4,
|
|
3525
|
+
result: L.value,
|
|
3526
|
+
messages: b(x)
|
|
3527
|
+
}, null, 8, ["result", "messages"])) : j("", !0),
|
|
3528
|
+
b(et) && H.value > 0 ? (I(), Te(_o, {
|
|
3529
|
+
key: 5,
|
|
3530
|
+
differences: b(W).differences.value,
|
|
3531
|
+
conflicts: b(W).conflicts.value,
|
|
3532
|
+
messages: b(x),
|
|
3533
|
+
saving: b(W).saving.value,
|
|
3534
|
+
"can-undo": b(W).canUndo.value,
|
|
3535
|
+
"can-redo": b(W).canRedo.value,
|
|
3536
|
+
persisted: b(Ut),
|
|
3537
|
+
busy: !!p.value || u.value,
|
|
3538
|
+
onUndo: b(W).undo,
|
|
3539
|
+
onRedo: b(W).redo,
|
|
3540
|
+
onRestore: b(W).restore,
|
|
3541
|
+
onLocate: E[6] || (E[6] = (O) => b(ne).focusCell(O.address))
|
|
3542
|
+
}, null, 8, ["differences", "conflicts", "messages", "saving", "can-undo", "can-redo", "persisted", "busy", "onUndo", "onRedo", "onRestore"])) : j("", !0),
|
|
3543
|
+
b(tt) ? (I(), P("input", {
|
|
3544
|
+
key: 6,
|
|
3545
|
+
ref_key: "importInputRef",
|
|
3546
|
+
ref: q,
|
|
3547
|
+
class: "mrp-import-input",
|
|
3548
|
+
type: "file",
|
|
3549
|
+
accept: ".xlsx,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
3550
|
+
hidden: "",
|
|
3551
|
+
onChange: ca
|
|
3552
|
+
}, null, 544)) : j("", !0),
|
|
3553
|
+
b(et) && H.value > 0 ? (I(), P("div", _s, C(b(W).saving.value ? b(x).saving : b(x).editingHint), 1)) : j("", !0),
|
|
3554
|
+
i.value ? (I(), P("div", {
|
|
3555
|
+
key: 8,
|
|
3556
|
+
class: ye(["mrp-export-notice", `mrp-export-${i.value.kind}`]),
|
|
3557
|
+
role: "alert"
|
|
3558
|
+
}, C(i.value.message), 3)) : j("", !0),
|
|
3559
|
+
b(Gt).status === "error" && Vt.value ? (I(), P("div", el, [
|
|
3560
|
+
we(C(b(x).pdfFontUnavailable) + " ", 1),
|
|
3561
|
+
R("button", {
|
|
3562
|
+
type: "button",
|
|
3563
|
+
onClick: E[7] || (E[7] = //@ts-ignore
|
|
3564
|
+
(...O) => b(Jt) && b(Jt)(...O))
|
|
3565
|
+
}, C(b(x).retry), 1)
|
|
3566
|
+
])) : j("", !0),
|
|
3567
|
+
R("div", tl, [
|
|
3568
|
+
R("div", {
|
|
3569
|
+
ref_key: "viewportRef",
|
|
3570
|
+
ref: y,
|
|
3571
|
+
class: "mrp-body",
|
|
3572
|
+
tabindex: "0",
|
|
3573
|
+
onWheel: da,
|
|
3574
|
+
onKeydown: fa,
|
|
3575
|
+
onDblclick: E[8] || (E[8] = //@ts-ignore
|
|
3576
|
+
(...O) => b(W).onDoubleClick && b(W).onDoubleClick(...O)),
|
|
3577
|
+
onClick: E[9] || (E[9] = //@ts-ignore
|
|
3578
|
+
(...O) => b(ne).onClick && b(ne).onClick(...O)),
|
|
3579
|
+
onCopy: E[10] || (E[10] = //@ts-ignore
|
|
3580
|
+
(...O) => b(ne).onCopy && b(ne).onCopy(...O)),
|
|
3581
|
+
onPaste: E[11] || (E[11] = //@ts-ignore
|
|
3582
|
+
(...O) => b(ne).onPaste && b(ne).onPaste(...O)),
|
|
3583
|
+
onScrollPassive: E[12] || (E[12] = (O) => {
|
|
3584
|
+
b(na)(O.target), b(kt).schedule();
|
|
3585
|
+
})
|
|
3586
|
+
}, [
|
|
3587
|
+
s.value ? (I(), P("div", nl, C(b(x).loading), 1)) : l.value ? (I(), P("div", al, [
|
|
3588
|
+
we(C(l.value) + " ", 1),
|
|
3589
|
+
R("button", {
|
|
3590
|
+
class: "mrp-retry",
|
|
3591
|
+
type: "button",
|
|
3592
|
+
onClick: ze
|
|
3593
|
+
}, C(b(x).retry), 1)
|
|
3594
|
+
])) : !r.value || H.value === 0 ? (I(), Te(vn, {
|
|
3595
|
+
key: 2,
|
|
3596
|
+
title: b(Qt) ? b(x).paramPrompt ?? b(x).paramsTitle : b(x).empty,
|
|
3597
|
+
description: b(Qt) ? b(x).paramPromptDescription : b(pt).description ?? b(x).emptyDescription
|
|
3598
|
+
}, null, 8, ["title", "description"])) : (I(), P("div", {
|
|
3599
|
+
key: 3,
|
|
3600
|
+
class: "mrp-scale",
|
|
3601
|
+
style: Re({ width: `${b(wt).w * b(de)}px`, height: `${b(wt).h * b(de)}px` })
|
|
3602
|
+
}, [
|
|
3603
|
+
R("div", {
|
|
3604
|
+
ref_key: "containerRef",
|
|
3605
|
+
ref: g,
|
|
3606
|
+
class: "mrp-scale-inner",
|
|
3607
|
+
style: Re({ transform: `scale(${b(de)})`, transformOrigin: "top left", width: `${b(wt).w}px` })
|
|
3608
|
+
}, [
|
|
3609
|
+
b(Ze).padTopPx > 0 ? (I(), P("div", {
|
|
3610
|
+
key: 0,
|
|
3611
|
+
class: "mrp-spacer-top",
|
|
3612
|
+
style: Re({ height: `${b(Ze).padTopPx}px` }),
|
|
3613
|
+
"aria-hidden": "true"
|
|
3614
|
+
}, null, 4)) : j("", !0),
|
|
3615
|
+
(I(!0), P(fe, null, pe(b(tn), (O) => (I(), P("div", {
|
|
3616
|
+
key: O.index,
|
|
3617
|
+
class: "mrp-page-holder",
|
|
3618
|
+
"data-page": O.index + 1
|
|
3619
|
+
}, null, 8, rl))), 128)),
|
|
3620
|
+
b(Ze).padBottomPx > 0 ? (I(), P("div", {
|
|
3621
|
+
key: 1,
|
|
3622
|
+
class: "mrp-spacer-bottom",
|
|
3623
|
+
style: Re({ height: `${b(Ze).padBottomPx}px` }),
|
|
3624
|
+
"aria-hidden": "true"
|
|
3625
|
+
}, null, 4)) : j("", !0)
|
|
3626
|
+
], 4)
|
|
3627
|
+
], 4)),
|
|
3628
|
+
!s.value && !l.value && r.value && H.value > 0 && e.emptyState ? (I(), Te(vn, {
|
|
3629
|
+
key: 4,
|
|
3630
|
+
title: b(pt).title ?? b(x).empty,
|
|
3631
|
+
description: b(pt).description ?? b(x).emptyDescription
|
|
3632
|
+
}, null, 8, ["title", "description"])) : j("", !0)
|
|
3633
|
+
], 544),
|
|
3634
|
+
b(ue).thumbnails && c.value && H.value > 0 ? (I(), P("aside", {
|
|
3635
|
+
key: 0,
|
|
3636
|
+
ref_key: "thumbsRef",
|
|
3637
|
+
ref: v,
|
|
3638
|
+
class: "mrp-thumbs",
|
|
3639
|
+
onScrollPassive: E[13] || (E[13] = //@ts-ignore
|
|
3640
|
+
(...O) => b(Ee).onScroll && b(Ee).onScroll(...O))
|
|
3641
|
+
}, [
|
|
3642
|
+
b(Ee).windowRange.value.padTopPx > 0 ? (I(), P("div", {
|
|
3643
|
+
key: 0,
|
|
3644
|
+
class: "mrp-thumb-spacer",
|
|
3645
|
+
style: Re({ height: `${b(Ee).windowRange.value.padTopPx}px` }),
|
|
3646
|
+
"aria-hidden": "true"
|
|
3647
|
+
}, null, 4)) : j("", !0),
|
|
3648
|
+
(I(!0), P(fe, null, pe(b(Ee).visibleThumbs.value, (O) => (I(), P("button", {
|
|
3649
|
+
key: O.index,
|
|
3650
|
+
class: ye(["mrp-thumb", { "mrp-thumb-active": O.index + 1 === m.value }]),
|
|
3651
|
+
type: "button",
|
|
3652
|
+
"aria-label": `${b(x).thumbnails} · ${b(x).pageInfo.replace("{cur}", String(O.index + 1)).replace("{total}", String(H.value))}`,
|
|
3653
|
+
"aria-current": O.index + 1 === m.value ? "page" : void 0,
|
|
3654
|
+
style: Re({ height: `${O.height + 20}px` }),
|
|
3655
|
+
onClick: (re) => he(O.index + 1)
|
|
3656
|
+
}, [
|
|
3657
|
+
R("span", {
|
|
3658
|
+
class: "mrp-thumb-box",
|
|
3659
|
+
"data-thumb": O.index + 1,
|
|
3660
|
+
style: Re({ height: `${O.height}px` })
|
|
3661
|
+
}, null, 12, sl),
|
|
3662
|
+
R("span", ll, C(O.index + 1), 1)
|
|
3663
|
+
], 14, ol))), 128)),
|
|
3664
|
+
b(Ee).windowRange.value.padBottomPx > 0 ? (I(), P("div", {
|
|
3665
|
+
key: 1,
|
|
3666
|
+
class: "mrp-thumb-spacer",
|
|
3667
|
+
style: Re({ height: `${b(Ee).windowRange.value.padBottomPx}px` }),
|
|
3668
|
+
"aria-hidden": "true"
|
|
3669
|
+
}, null, 4)) : j("", !0)
|
|
3670
|
+
], 544)) : j("", !0)
|
|
3671
|
+
]),
|
|
3672
|
+
R("div", il, [
|
|
3673
|
+
Ot(d.$slots, "default", {}, void 0, !0)
|
|
3674
|
+
]),
|
|
3675
|
+
b(Be) ? (I(), P("div", ul, [
|
|
3676
|
+
E[14] || (E[14] = R("div", null, "mach-report debug", -1)),
|
|
3677
|
+
R("div", null, "pages: " + C(b(Be).pages) + " | window: [" + C(b(Be).window) + "]", 1),
|
|
3678
|
+
R("div", null, "zoom: " + C(b(Be).zoom) + " | load: " + C(b(Be).loadMs), 1),
|
|
3679
|
+
R("div", null, "plan: " + C(b(Be).planKB) + "KB", 1)
|
|
3680
|
+
])) : j("", !0)
|
|
3681
|
+
], 6));
|
|
3682
|
+
}
|
|
3683
|
+
}), dl = /* @__PURE__ */ ke(cl, [["__scopeId", "data-v-f0801c0a"]]), Pl = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
3684
|
+
__proto__: null,
|
|
3685
|
+
default: dl
|
|
3686
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
3687
|
+
export {
|
|
3688
|
+
ws as D,
|
|
3689
|
+
ge as M,
|
|
3690
|
+
St as P,
|
|
3691
|
+
jt as R,
|
|
3692
|
+
El as S,
|
|
3693
|
+
xs as a,
|
|
3694
|
+
yn as b,
|
|
3695
|
+
ve as c,
|
|
3696
|
+
zo as d,
|
|
3697
|
+
dl as e,
|
|
3698
|
+
Mr as f,
|
|
3699
|
+
Va as g,
|
|
3700
|
+
kl as h,
|
|
3701
|
+
ho as i,
|
|
3702
|
+
wl as j,
|
|
3703
|
+
$l as k,
|
|
3704
|
+
ks as l,
|
|
3705
|
+
Il as m,
|
|
3706
|
+
yl as n,
|
|
3707
|
+
Rn as o,
|
|
3708
|
+
mo as p,
|
|
3709
|
+
xl as q,
|
|
3710
|
+
Cl as r,
|
|
3711
|
+
Es as s,
|
|
3712
|
+
Cs as t,
|
|
3713
|
+
fo as u,
|
|
3714
|
+
$s as v,
|
|
3715
|
+
Wa as w,
|
|
3716
|
+
Ga as x,
|
|
3717
|
+
Ka as y,
|
|
3718
|
+
Pl as z
|
|
3719
|
+
};
|