@agile-team/mach-report 0.6.0 → 0.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/dist/vue.js CHANGED
@@ -1,44 +1,53 @@
1
- import { D as m, a as R, R as P, b as g, c as u, d, e as T, p as _, r as C, t as M, u as w, f as F, g as D, h as A } from "./ReportPreview-DWLjYi_p.js";
2
- import { P as t } from "./plugin-DrV67_VW.js";
3
- import { M as H, a as O, b, c as L, d as j, e as v, j as G, m as I, n as K } from "./plugin-DrV67_VW.js";
4
- import { paginateTemplate as i } from "@agile-team/mach-report";
1
+ import { D as g, a as T, M as _, R as M, b as d, c as C, d as w, e as D, p as F, r as O, t as A, f as H, u as L, g as v, h as x, i as b } from "./ReportPreview-DgsOdO4y.js";
2
+ import { P as s, M as c } from "./plugin-Dp3kKWiQ.js";
3
+ import { a as K, b as Y, c as G, d as I, e as S, f as y, g as N, j as U, m as V, n as q } from "./plugin-Dp3kKWiQ.js";
4
+ import { paginateTemplate as p } from "@agile-team/mach-report";
5
+ import { inject as R } from "vue";
5
6
  function h(n) {
6
7
  return async ({ tempIds: a }) => {
7
- if (a.length === 0) throw new t("缺少报表模板 ID");
8
+ if (a.length === 0) throw new s("缺少报表模板 ID");
8
9
  const r = [];
9
10
  for (const o of a) {
10
11
  const e = n[o];
11
- if (!e) throw new t(`本地模板 ${o} 不存在`);
12
- const { plan: c, warnings: s } = i(e.template, e.datasets ?? {});
13
- s.length > 0 && console.warn("[mach-report] 分页告警:", s), r.push(...c.pages);
12
+ if (!e) throw new s(`本地模板 ${o} 不存在`);
13
+ const { plan: i, warnings: t } = p(e.template, e.datasets ?? {});
14
+ t.length > 0 && console.warn("[mach-report] 分页告警:", t), r.push(...i.pages);
14
15
  }
15
16
  return { schemaVersion: "mach-local", pages: r };
16
17
  };
17
18
  }
19
+ function m() {
20
+ return R(c, null);
21
+ }
18
22
  export {
19
- m as DEFAULT_MESSAGES,
20
- R as DEFAULT_THEME,
21
- H as MACH_REPORT_CONFIG_KEY,
22
- O as MACH_REPORT_FETCHER_KEY,
23
- b as MACH_REPORT_PDF_EXPORTER_KEY,
24
- t as PlanLoadError,
25
- P as ReportPreview,
26
- g as ReportToolbar,
27
- u as buildPrintDocument,
28
- L as createDefaultPdfExporter,
29
- j as createFetchRequest,
30
- v as createJh4jGridPlanFetcher,
23
+ g as DEFAULT_MESSAGES,
24
+ T as DEFAULT_THEME,
25
+ K as MACH_REPORT_CONFIG_KEY,
26
+ c as MACH_REPORT_CONTROLLER_KEY,
27
+ Y as MACH_REPORT_FETCHER_KEY,
28
+ G as MACH_REPORT_PDF_EXPORTER_KEY,
29
+ _ as MachReportError,
30
+ I as MachReportPreview,
31
+ s as PlanLoadError,
32
+ M as ReportPreview,
33
+ d as ReportToolbar,
34
+ C as buildPrintDocument,
35
+ S as createDefaultPdfExporter,
36
+ y as createFetchRequest,
37
+ N as createJh4jGridPlanFetcher,
31
38
  h as createLocalFetcher,
32
- d as defineMachReportConfig,
33
- T as defineMachReportPreset,
34
- G as joinTempIds,
35
- I as machReportPlugin,
36
- K as normalizeTempIds,
37
- _ as provideMachReportConfig,
38
- C as resolveConfig,
39
- M as themeToCssVars,
40
- w as useMachReportConfig,
41
- F as usePageWindow,
42
- D as usePrintExport,
43
- A as useZoom
39
+ w as defineMachReportConfig,
40
+ D as defineMachReportPreset,
41
+ U as joinTempIds,
42
+ V as machReportPlugin,
43
+ q as normalizeTempIds,
44
+ F as provideMachReportConfig,
45
+ O as resolveConfig,
46
+ A as themeToCssVars,
47
+ H as toErrorDetail,
48
+ L as useMachReportConfig,
49
+ v as usePageWindow,
50
+ x as usePrintExport,
51
+ m as useReportPreview,
52
+ b as useZoom
44
53
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agile-team/mach-report",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "MachReport 报表引擎单包:RenderPlan 模型 + 分页 + DOM/Canvas/PDF 渲染 + 动态 SQL + 管理端 API + Vue 3 契约组件(零运行时依赖;./vue 为框架子路径,vue 为可选 peer)",
5
5
  "type": "module",
6
6
  "sideEffects": [
@@ -1,527 +0,0 @@
1
- import { ref as C, computed as g, defineComponent as re, openBlock as w, createElementBlock as b, createElementVNode as M, toDisplayString as x, Fragment as ae, createCommentVNode as T, normalizeClass as G, inject as j, provide as Pe, useCssVars as ye, shallowRef as xe, watchEffect as Ee, onMounted as Me, onUnmounted as $e, watch as te, normalizeStyle as H, createVNode as Re, unref as c, createTextVNode as ke, renderList as Ce } from "vue";
2
- import { computePageWindow as Fe, renderPage as se, validateRenderPlan as Be } from "@agile-team/mach-report";
3
- import { M as q, a as Te, b as We, n as ze, c as Se } from "./plugin-DrV67_VW.js";
4
- function He(e, o, n = {}) {
5
- const t = n.pxPerMm ?? 3.7795275590551185, r = n.gapPx ?? 18, s = C(0), u = C(800), f = g(
6
- () => (e.value?.pages ?? []).map((a) => a.pageHeightMm * t)
7
- ), R = g(() => {
8
- const a = e.value?.pages ?? [];
9
- let p = 0, d = 0;
10
- for (const h of a)
11
- p += h.pageHeightMm * t + r, d = Math.max(d, h.pageWidthMm * t);
12
- return { w: d, h: p };
13
- }), i = g(
14
- () => Fe({
15
- pageHeightsPx: f.value,
16
- viewportHeightPx: u.value / o.value,
17
- scrollTopPx: s.value / o.value,
18
- overscan: 1,
19
- gapPx: r
20
- })
21
- ), l = g(() => {
22
- const a = e.value;
23
- if (!a) return [];
24
- const { start: p, end: d } = i.value;
25
- return d < p ? [] : a.pages.slice(p, d + 1).map((h, $) => ({ page: h, index: p + $ }));
26
- });
27
- function v(a, p) {
28
- let d = 0;
29
- return (h) => {
30
- d || (d = requestAnimationFrame(() => {
31
- if (d = 0, s.value = h.scrollTop, u.value = h.clientHeight || 800, p.value <= 0) return;
32
- const $ = h.querySelectorAll(".mrp-page-holder");
33
- if (!$.length) return;
34
- const D = h.getBoundingClientRect().top + 56;
35
- let k = 1;
36
- $.forEach((F) => {
37
- F.getBoundingClientRect().top <= D && (k = Number(F.dataset.page ?? 1));
38
- }), a.value = Math.max(1, Math.min(p.value, k));
39
- }));
40
- };
41
- }
42
- return {
43
- pageHeightsPx: f,
44
- contentSize: R,
45
- windowRange: i,
46
- visiblePages: l,
47
- scrollTop: s,
48
- viewportHeight: u,
49
- makeScrollHandler: v,
50
- refreshViewport(a) {
51
- a && (u.value = a.clientHeight || 800);
52
- }
53
- };
54
- }
55
- function Le(e) {
56
- const o = C(1), n = C("fit");
57
- function t() {
58
- requestAnimationFrame(() => {
59
- const s = e();
60
- !s || !s.viewport || (o.value = Math.min(
61
- 1,
62
- Math.max(0.3, (s.viewport.clientWidth - 48) / Math.max(1, s.pageWidthPx))
63
- ));
64
- });
65
- }
66
- function r(s) {
67
- s === "fit" ? (n.value = "fit", t()) : (n.value = "raw", o.value = s / 100);
68
- }
69
- return { zoom: o, zoomMode: n, applyFitZoom: t, setZoom: r };
70
- }
71
- const oe = 8;
72
- function ne() {
73
- return new Promise((e) => setTimeout(e, 0));
74
- }
75
- function O(e) {
76
- return `p${Math.round(e.pageWidthMm)}x${Math.round(e.pageHeightMm)}`;
77
- }
78
- function Z(e) {
79
- const o = /* @__PURE__ */ new Map();
80
- e.pages.forEach((u) => {
81
- o.has(O(u)) || o.set(O(u), u);
82
- });
83
- const r = `<!doctype html><html><head><meta charset="utf-8"><style>${`.mr-page{margin:0 auto;page-break-after:always;}
84
- .mr-page tr{break-inside:avoid;page-break-inside:avoid;}
85
- .mr-comp{break-inside:avoid;page-break-inside:avoid;}
86
- ${[...o.values()].map(
87
- (u) => `@page ${O(u)}{size:${Math.round(u.pageWidthMm)}mm ${Math.round(u.pageHeightMm)}mm;margin:0;}`
88
- ).join(`
89
- `)}
90
- body{margin:0;background:#fff;}`}</style></head><body>`, s = e.pages.map((u) => {
91
- const f = se(u, 96, {}, document);
92
- return f.style.page = O(u), f.outerHTML;
93
- });
94
- return { head: r, pageChunks: s };
95
- }
96
- function Ae(e, o) {
97
- let n = null;
98
- function t() {
99
- n?.remove(), n = null;
100
- }
101
- function r(i, l) {
102
- const v = URL.createObjectURL(i), a = document.createElement("a");
103
- a.href = v, a.download = l, a.click(), setTimeout(() => URL.revokeObjectURL(v), 1e4);
104
- }
105
- async function s() {
106
- const i = e.value;
107
- if (!i || i.pages.length === 0) return;
108
- t();
109
- const { head: l, pageChunks: v } = Z(i);
110
- n = document.createElement("iframe"), n.style.cssText = "position:fixed;right:0;bottom:0;width:0;height:0;border:0;visibility:hidden;", document.body.appendChild(n);
111
- const a = n;
112
- try {
113
- const p = a.contentDocument;
114
- p.open(), p.write(l);
115
- for (let d = 0; d < v.length; d++)
116
- if (p.write(v[d]), d % oe === oe - 1 && await ne(), a !== n) return;
117
- p.write("</body></html>"), p.close(), await ne(), a.contentWindow?.focus(), a.contentWindow?.print();
118
- } catch {
119
- o.onError("调用打印失败,请改用导出 PDF");
120
- }
121
- }
122
- async function u() {
123
- const i = e.value;
124
- if (!(!i || i.pages.length === 0))
125
- try {
126
- const l = await o.getPdfExporter()(i);
127
- r(new Blob([l], { type: "application/pdf" }), "mach-report.pdf");
128
- } catch (l) {
129
- o.onError(l instanceof Error ? `PDF 导出失败: ${l.message}` : "PDF 导出失败");
130
- }
131
- }
132
- function f(i) {
133
- const l = e.value;
134
- if (!l || l.pages.length === 0) return;
135
- if (i === "pdf") {
136
- u();
137
- return;
138
- }
139
- const { head: v, pageChunks: a } = Z(l), p = `${v}${a.join("")}</body></html>`;
140
- r(new Blob([p], { type: "text/html;charset=utf-8" }), `mach-report.${i === "html" ? "html" : i}`);
141
- }
142
- function R() {
143
- const i = e.value;
144
- if (!i || i.pages.length === 0) return;
145
- const { head: l, pageChunks: v } = Z(i), a = `${l}${v.join("")}</body></html>`, p = new Blob([a], { type: "text/html;charset=utf-8" }), d = URL.createObjectURL(p), h = window.open(d, "_blank");
146
- if (!h) {
147
- o.onError("浏览器拦截了弹窗,请允许弹窗后重试"), URL.revokeObjectURL(d);
148
- return;
149
- }
150
- setTimeout(() => h.print(), 400), setTimeout(() => URL.revokeObjectURL(d), 1e4);
151
- }
152
- return {
153
- print: s,
154
- exportAs: f,
155
- openPdfWindow: R,
156
- releasePrintFrame: t
157
- };
158
- }
159
- const Ie = { class: "mrp-toolbar" }, Oe = { class: "mrp-title" }, Ue = ["disabled"], je = { class: "mrp-pageinfo" }, De = ["disabled"], Ve = /* @__PURE__ */ re({
160
- __name: "ReportToolbar",
161
- props: {
162
- pageCount: {},
163
- currentPage: {},
164
- zoomMode: {},
165
- zoom: {},
166
- showExport: { type: Boolean },
167
- showPrint: { type: Boolean },
168
- showPdfWindow: { type: Boolean },
169
- messages: {}
170
- },
171
- emits: ["goto", "zoom", "export", "print", "pdf-window"],
172
- setup(e) {
173
- function o(n, t, r) {
174
- return n.replace("{cur}", String(t)).replace("{total}", String(r));
175
- }
176
- return (n, t) => (w(), b("div", Ie, [
177
- M("span", Oe, x(e.messages.title), 1),
178
- e.pageCount > 0 ? (w(), b(ae, { key: 0 }, [
179
- M("button", {
180
- class: "mrp-nav",
181
- type: "button",
182
- disabled: e.currentPage <= 1,
183
- onClick: t[0] || (t[0] = (r) => n.$emit("goto", e.currentPage - 1))
184
- }, x(e.messages.prevPage), 9, Ue),
185
- M("span", je, x(o(e.messages.pageInfo, e.currentPage, e.pageCount)), 1),
186
- M("button", {
187
- class: "mrp-nav",
188
- type: "button",
189
- disabled: e.currentPage >= e.pageCount,
190
- onClick: t[1] || (t[1] = (r) => n.$emit("goto", e.currentPage + 1))
191
- }, x(e.messages.nextPage), 9, De)
192
- ], 64)) : T("", !0),
193
- t[9] || (t[9] = M("span", { class: "mrp-spacer" }, null, -1)),
194
- M("button", {
195
- class: G(["mrp-nav", { "mrp-active": e.zoomMode === "fit" }]),
196
- type: "button",
197
- onClick: t[2] || (t[2] = (r) => n.$emit("zoom", "fit"))
198
- }, x(e.messages.fitWidth), 3),
199
- M("button", {
200
- class: G(["mrp-nav", { "mrp-active": e.zoomMode === "raw" && Math.round(e.zoom * 100) === 100 }]),
201
- type: "button",
202
- onClick: t[3] || (t[3] = (r) => n.$emit("zoom", 100))
203
- }, " 100% ", 2),
204
- M("button", {
205
- class: G(["mrp-nav", { "mrp-active": e.zoomMode === "raw" && Math.round(e.zoom * 100) === 150 }]),
206
- type: "button",
207
- onClick: t[4] || (t[4] = (r) => n.$emit("zoom", 150))
208
- }, " 150% ", 2),
209
- e.showExport ? (w(), b("button", {
210
- key: 1,
211
- class: "mrp-nav",
212
- type: "button",
213
- onClick: t[5] || (t[5] = (r) => n.$emit("export", "html"))
214
- }, x(e.messages.exportHtml), 1)) : T("", !0),
215
- e.showExport ? (w(), b("button", {
216
- key: 2,
217
- class: "mrp-nav",
218
- type: "button",
219
- onClick: t[6] || (t[6] = (r) => n.$emit("export", "pdf"))
220
- }, x(e.messages.exportPdf), 1)) : T("", !0),
221
- e.showPrint ? (w(), b("button", {
222
- key: 3,
223
- class: "mrp-nav",
224
- type: "button",
225
- onClick: t[7] || (t[7] = (r) => n.$emit("print"))
226
- }, x(e.messages.print), 1)) : T("", !0),
227
- e.showPdfWindow ? (w(), b("button", {
228
- key: 4,
229
- class: "mrp-nav",
230
- type: "button",
231
- onClick: t[8] || (t[8] = (r) => n.$emit("pdf-window"))
232
- }, x(e.messages.pdfWindow), 1)) : T("", !0)
233
- ]));
234
- }
235
- }), le = (e, o) => {
236
- const n = e.__vccOpts || e;
237
- for (const [t, r] of o)
238
- n[t] = r;
239
- return n;
240
- }, Ne = /* @__PURE__ */ le(Ve, [["__scopeId", "data-v-2bfb2c61"]]), Ge = {
241
- title: "报表预览",
242
- prevPage: "‹ 上一页",
243
- nextPage: "下一页 ›",
244
- pageInfo: "{cur} / {total}",
245
- fitWidth: "适宽",
246
- exportHtml: "导出 HTML",
247
- exportPdf: "导出 PDF",
248
- print: "打印",
249
- pdfWindow: "PDF 窗口",
250
- loading: "报表渲染中…",
251
- empty: "暂无预览数据",
252
- errorPrefix: "",
253
- retry: "重试"
254
- }, Ze = {
255
- shellBg: "#525659",
256
- shellFg: "#e8e8e8",
257
- toolbarBg: "#323639",
258
- toolbarBorder: "#22252a",
259
- toolbarFg: "#e8e8e8",
260
- btnFg: "#cfcfcf",
261
- btnBorder: "#4a4d52",
262
- btnHoverBg: "#414549",
263
- btnHoverFg: "#ffffff",
264
- btnActiveBg: "#2d5fb8"
265
- };
266
- function at(e) {
267
- return e;
268
- }
269
- function st(e) {
270
- return e;
271
- }
272
- const L = {
273
- showExport: !0,
274
- showPrint: !0,
275
- showPdfWindow: !0,
276
- gapPx: 18,
277
- pdfFontUrl: "/simhei.ttf"
278
- };
279
- function qe(e, o) {
280
- const n = o ? e?.presets?.[o] : e?.defaultPreset ? e?.presets?.[e.defaultPreset] : void 0, t = { ...e?.defaults, ...n };
281
- return {
282
- showExport: t.showExport ?? L.showExport,
283
- showPrint: t.showPrint ?? L.showPrint,
284
- showPdfWindow: t.showPdfWindow ?? L.showPdfWindow,
285
- gapPx: t.gapPx ?? L.gapPx,
286
- pdfFontUrl: t.pdfFontUrl ?? L.pdfFontUrl,
287
- theme: { ...Ze, ...t.theme },
288
- messages: { ...Ge, ...t.messages }
289
- };
290
- }
291
- function Ke(e) {
292
- const o = {};
293
- return e.shellBg != null && (o["--mrp-shell-bg"] = e.shellBg), e.shellFg != null && (o["--mrp-shell-fg"] = e.shellFg), e.toolbarBg != null && (o["--mrp-toolbar-bg"] = e.toolbarBg), e.toolbarBorder != null && (o["--mrp-toolbar-border"] = e.toolbarBorder), e.toolbarFg != null && (o["--mrp-toolbar-fg"] = e.toolbarFg), e.btnFg != null && (o["--mrp-btn-fg"] = e.btnFg), e.btnBorder != null && (o["--mrp-btn-border"] = e.btnBorder), e.btnHoverBg != null && (o["--mrp-btn-hover-bg"] = e.btnHoverBg), e.btnHoverFg != null && (o["--mrp-btn-hover-fg"] = e.btnHoverFg), e.btnActiveBg != null && (o["--mrp-btn-active-bg"] = e.btnActiveBg), o;
294
- }
295
- function lt(e) {
296
- const o = j(q, null), n = g(() => {
297
- const t = o?.value ?? null, r = "defaults" in e && "presets" in e ? e : { defaults: e, presets: {} };
298
- return t ? {
299
- defaults: { ...t.defaults, ...r.defaults },
300
- presets: { ...t.presets, ...r.presets },
301
- defaultPreset: r.defaultPreset ?? t.defaultPreset
302
- } : r;
303
- });
304
- Pe(q, n);
305
- }
306
- function Ye() {
307
- return j(q, g(() => null));
308
- }
309
- const Xe = {
310
- key: 0,
311
- class: "mrp-state"
312
- }, Je = {
313
- key: 1,
314
- class: "mrp-state mrp-error"
315
- }, Qe = {
316
- key: 2,
317
- class: "mrp-state"
318
- }, _e = ["data-page"], U = 96 / 25.4, et = /* @__PURE__ */ re({
319
- __name: "ReportPreview",
320
- props: {
321
- tempId: {
322
- type: [String, Array],
323
- default: null
324
- },
325
- furnitureTempId: { type: String, default: "" },
326
- params: {
327
- type: Object,
328
- default: () => ({})
329
- },
330
- height: { type: String, default: "100vh" },
331
- autoLoad: { type: Boolean, default: !0 },
332
- /** 以下显隐/间距不传时走配置中心(preset > defaults > 内置缺省) */
333
- showExport: { type: Boolean, default: void 0 },
334
- showPrint: { type: Boolean, default: void 0 },
335
- showPdfWindow: { type: Boolean, default: void 0 },
336
- /** 页间距(px);不传走配置中心 */
337
- gapPx: { type: Number, default: void 0 },
338
- /** 工具栏/状态文案覆写(不传走配置中心 messages) */
339
- messages: { type: Object, default: void 0 },
340
- /** 启用的 preset 名(不传用配置中心 defaultPreset) */
341
- preset: { type: String, default: void 0 },
342
- fetcher: {
343
- type: Function,
344
- default: null
345
- }
346
- },
347
- emits: ["loaded", "error"],
348
- setup(e, { expose: o, emit: n }) {
349
- ye((E) => ({
350
- v1f6cf76a: v.value + "px"
351
- }));
352
- const t = e, r = n, s = xe(null), u = C(!1), f = C(""), R = C(1), i = C(null), l = C(null), v = g(() => Math.max(0, pe.value)), a = j(Te, null), d = j(We, null) ?? Se({ fontUrl: "/simhei.ttf" }), h = g(() => ze(t.tempId)), $ = g(() => s.value?.pages.length ?? 0), D = Ye(), k = g(() => qe(D.value, t.preset)), F = g(() => ({
353
- ...k.value.messages,
354
- ...t.messages
355
- })), ie = g(() => t.showExport ?? k.value.showExport), ue = g(() => t.showPrint ?? k.value.showPrint), de = g(() => t.showPdfWindow ?? k.value.showPdfWindow), pe = g(() => t.gapPx ?? k.value.gapPx), ce = g(() => ({
356
- height: t.height,
357
- ...Ke(k.value.theme)
358
- })), { zoom: W, zoomMode: fe, applyFitZoom: K, setZoom: me } = Le(() => ({
359
- viewport: l.value,
360
- pageWidthPx: (s.value?.pages[0]?.pageWidthMm ?? 210) * U
361
- })), ge = He(s, W, {
362
- pxPerMm: U,
363
- gapPx: v.value
364
- }), { contentSize: V, windowRange: A, visiblePages: ve, makeScrollHandler: he, refreshViewport: Y } = ge, we = he(R, $);
365
- function N() {
366
- s.value = null, R.value = 1;
367
- }
368
- let I = 0;
369
- async function S() {
370
- const E = ++I, P = t.fetcher ?? a;
371
- if (h.value.length === 0) {
372
- f.value = "缺少报表模板 ID", N(), r("error", f.value);
373
- return;
374
- }
375
- if (!P) {
376
- f.value = "未提供渲染数据源 fetcher", N(), r("error", f.value);
377
- return;
378
- }
379
- u.value = !0, f.value = "", N();
380
- try {
381
- const m = await P({
382
- tempIds: h.value,
383
- furnitureTempId: t.furnitureTempId || void 0,
384
- params: { ...t.params }
385
- });
386
- if (E !== I) return;
387
- const y = Be(m);
388
- if (!y.ok) {
389
- const B = y.errors.slice(0, 3).map((z) => `${z.path}: ${z.message}`).join("; ");
390
- throw new Error(`渲染计划校验失败(${y.errors.length} 处): ${B}`);
391
- }
392
- y.warnings.length > 0 && console.warn("[mach-report] 渲染计划告警:", y.warnings), s.value = m, R.value = 1, l.value && (l.value.scrollTop = 0), K(), r("loaded", m.pages.length);
393
- } catch (m) {
394
- if (E !== I) return;
395
- f.value = m instanceof Error ? m.message : "预览加载失败", r("error", f.value);
396
- } finally {
397
- E === I && (u.value = !1);
398
- }
399
- }
400
- function X(E) {
401
- if ($.value <= 0) return;
402
- const P = Math.max(1, Math.min($.value, E));
403
- R.value = P;
404
- const m = l.value;
405
- if (!m) return;
406
- let y = 0;
407
- for (let B = 0; B < P - 1; B++)
408
- y += (s.value?.pages[B]?.pageHeightMm ?? 0) * U + v.value;
409
- m.scrollTop = y * W.value;
410
- }
411
- const { print: J, exportAs: Q, openPdfWindow: _, releasePrintFrame: be } = Ae(s, {
412
- getPdfExporter: () => d,
413
- onError: (E) => r("error", E)
414
- });
415
- Ee(() => {
416
- const E = s.value;
417
- if (!E) return;
418
- const P = i.value;
419
- if (!P) return;
420
- P.querySelectorAll(".mrp-page-holder").forEach((y) => {
421
- const B = Number(y.dataset.page ?? 0) - 1, z = E.pages[B];
422
- !z || y.childElementCount > 0 || (y.style.width = `${z.pageWidthMm * U}px`, y.appendChild(se(z, 96, {}, document)));
423
- });
424
- }, { flush: "post" });
425
- function ee() {
426
- Y(l.value), K();
427
- }
428
- return Me(() => {
429
- window.addEventListener("resize", ee), Y(l.value), t.autoLoad && S();
430
- }), $e(() => {
431
- window.removeEventListener("resize", ee), be();
432
- }), te(
433
- () => [t.tempId, t.furnitureTempId, JSON.stringify(t.params)],
434
- () => {
435
- t.autoLoad && S();
436
- }
437
- ), te(
438
- () => t.fetcher ?? a,
439
- () => {
440
- t.autoLoad && S();
441
- }
442
- ), o({ reload: S, print: J, exportAs: Q, openPdfWindow: _, gotoPage: X }), (E, P) => (w(), b("div", {
443
- class: "mach-report-preview",
444
- style: H(ce.value)
445
- }, [
446
- Re(Ne, {
447
- "page-count": $.value,
448
- "current-page": R.value,
449
- "zoom-mode": c(fe),
450
- zoom: c(W),
451
- "show-export": ie.value,
452
- "show-print": ue.value,
453
- "show-pdf-window": de.value,
454
- messages: F.value,
455
- onGoto: X,
456
- onZoom: c(me),
457
- onExport: P[0] || (P[0] = (m) => c(Q)(m)),
458
- onPrint: c(J),
459
- onPdfWindow: c(_)
460
- }, null, 8, ["page-count", "current-page", "zoom-mode", "zoom", "show-export", "show-print", "show-pdf-window", "messages", "onZoom", "onPrint", "onPdfWindow"]),
461
- M("div", {
462
- ref_key: "viewportRef",
463
- ref: l,
464
- class: "mrp-body",
465
- onScrollPassive: P[1] || (P[1] = (m) => c(we)(m.target))
466
- }, [
467
- u.value ? (w(), b("div", Xe, x(F.value.loading), 1)) : f.value ? (w(), b("div", Je, [
468
- ke(x(f.value) + " ", 1),
469
- M("button", {
470
- class: "mrp-retry",
471
- type: "button",
472
- onClick: S
473
- }, x(F.value.retry), 1)
474
- ])) : !s.value || $.value === 0 ? (w(), b("div", Qe, x(F.value.empty), 1)) : (w(), b("div", {
475
- key: 3,
476
- class: "mrp-scale",
477
- style: H({ width: `${c(V).w * c(W)}px`, height: `${c(V).h * c(W)}px` })
478
- }, [
479
- M("div", {
480
- ref_key: "containerRef",
481
- ref: i,
482
- class: "mrp-scale-inner",
483
- style: H({ transform: `scale(${c(W)})`, transformOrigin: "top left", width: `${c(V).w}px` })
484
- }, [
485
- c(A).padTopPx > 0 ? (w(), b("div", {
486
- key: 0,
487
- class: "mrp-spacer-top",
488
- style: H({ height: `${c(A).padTopPx}px` }),
489
- "aria-hidden": "true"
490
- }, null, 4)) : T("", !0),
491
- (w(!0), b(ae, null, Ce(c(ve), (m) => (w(), b("div", {
492
- key: m.index,
493
- class: "mrp-page-holder",
494
- "data-page": m.index + 1
495
- }, null, 8, _e))), 128)),
496
- c(A).padBottomPx > 0 ? (w(), b("div", {
497
- key: 1,
498
- class: "mrp-spacer-bottom",
499
- style: H({ height: `${c(A).padBottomPx}px` }),
500
- "aria-hidden": "true"
501
- }, null, 4)) : T("", !0)
502
- ], 4)
503
- ], 4))
504
- ], 544)
505
- ], 4));
506
- }
507
- }), tt = /* @__PURE__ */ le(et, [["__scopeId", "data-v-a3e8e93b"]]), it = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
508
- __proto__: null,
509
- default: tt
510
- }, Symbol.toStringTag, { value: "Module" }));
511
- export {
512
- Ge as D,
513
- tt as R,
514
- Ze as a,
515
- Ne as b,
516
- Z as c,
517
- at as d,
518
- st as e,
519
- He as f,
520
- Ae as g,
521
- Le as h,
522
- it as i,
523
- lt as p,
524
- qe as r,
525
- Ke as t,
526
- Ye as u
527
- };
@@ -1,6 +0,0 @@
1
- "use strict";const e=require("vue"),H=require("@agile-team/mach-report"),B=require("./plugin-BIJxGHZX.cjs");function Z(t,n,r={}){const o=r.pxPerMm??3.7795275590551185,a=r.gapPx??18,s=e.ref(0),c=e.ref(800),f=e.computed(()=>(t.value?.pages??[]).map(l=>l.pageHeightMm*o)),y=e.computed(()=>{const l=t.value?.pages??[];let p=0,d=0;for(const v of l)p+=v.pageHeightMm*o+a,d=Math.max(d,v.pageWidthMm*o);return{w:d,h:p}}),u=e.computed(()=>H.computePageWindow({pageHeightsPx:f.value,viewportHeightPx:c.value/n.value,scrollTopPx:s.value/n.value,overscan:1,gapPx:a})),i=e.computed(()=>{const l=t.value;if(!l)return[];const{start:p,end:d}=u.value;return d<p?[]:l.pages.slice(p,d+1).map((v,b)=>({page:v,index:p+b}))});function g(l,p){let d=0;return v=>{d||(d=requestAnimationFrame(()=>{if(d=0,s.value=v.scrollTop,c.value=v.clientHeight||800,p.value<=0)return;const b=v.querySelectorAll(".mrp-page-holder");if(!b.length)return;const D=v.getBoundingClientRect().top+56;let E=1;b.forEach(x=>{x.getBoundingClientRect().top<=D&&(E=Number(x.dataset.page??1))}),l.value=Math.max(1,Math.min(p.value,E))}))}}return{pageHeightsPx:f,contentSize:y,windowRange:u,visiblePages:i,scrollTop:s,viewportHeight:c,makeScrollHandler:g,refreshViewport(l){l&&(c.value=l.clientHeight||800)}}}function Y(t){const n=e.ref(1),r=e.ref("fit");function o(){requestAnimationFrame(()=>{const s=t();!s||!s.viewport||(n.value=Math.min(1,Math.max(.3,(s.viewport.clientWidth-48)/Math.max(1,s.pageWidthPx))))})}function a(s){s==="fit"?(r.value="fit",o()):(r.value="raw",n.value=s/100)}return{zoom:n,zoomMode:r,applyFitZoom:o,setZoom:a}}const q=8;function K(){return new Promise(t=>setTimeout(t,0))}function T(t){return`p${Math.round(t.pageWidthMm)}x${Math.round(t.pageHeightMm)}`}function W(t){const n=new Map;t.pages.forEach(c=>{n.has(T(c))||n.set(T(c),c)});const a=`<!doctype html><html><head><meta charset="utf-8"><style>${`.mr-page{margin:0 auto;page-break-after:always;}
2
- .mr-page tr{break-inside:avoid;page-break-inside:avoid;}
3
- .mr-comp{break-inside:avoid;page-break-inside:avoid;}
4
- ${[...n.values()].map(c=>`@page ${T(c)}{size:${Math.round(c.pageWidthMm)}mm ${Math.round(c.pageHeightMm)}mm;margin:0;}`).join(`
5
- `)}
6
- body{margin:0;background:#fff;}`}</style></head><body>`,s=t.pages.map(c=>{const f=H.renderPage(c,96,{},document);return f.style.page=T(c),f.outerHTML});return{head:a,pageChunks:s}}function X(t,n){let r=null;function o(){r?.remove(),r=null}function a(u,i){const g=URL.createObjectURL(u),l=document.createElement("a");l.href=g,l.download=i,l.click(),setTimeout(()=>URL.revokeObjectURL(g),1e4)}async function s(){const u=t.value;if(!u||u.pages.length===0)return;o();const{head:i,pageChunks:g}=W(u);r=document.createElement("iframe"),r.style.cssText="position:fixed;right:0;bottom:0;width:0;height:0;border:0;visibility:hidden;",document.body.appendChild(r);const l=r;try{const p=l.contentDocument;p.open(),p.write(i);for(let d=0;d<g.length;d++)if(p.write(g[d]),d%q===q-1&&await K(),l!==r)return;p.write("</body></html>"),p.close(),await K(),l.contentWindow?.focus(),l.contentWindow?.print()}catch{n.onError("调用打印失败,请改用导出 PDF")}}async function c(){const u=t.value;if(!(!u||u.pages.length===0))try{const i=await n.getPdfExporter()(u);a(new Blob([i],{type:"application/pdf"}),"mach-report.pdf")}catch(i){n.onError(i instanceof Error?`PDF 导出失败: ${i.message}`:"PDF 导出失败")}}function f(u){const i=t.value;if(!i||i.pages.length===0)return;if(u==="pdf"){c();return}const{head:g,pageChunks:l}=W(i),p=`${g}${l.join("")}</body></html>`;a(new Blob([p],{type:"text/html;charset=utf-8"}),`mach-report.${u==="html"?"html":u}`)}function y(){const u=t.value;if(!u||u.pages.length===0)return;const{head:i,pageChunks:g}=W(u),l=`${i}${g.join("")}</body></html>`,p=new Blob([l],{type:"text/html;charset=utf-8"}),d=URL.createObjectURL(p),v=window.open(d,"_blank");if(!v){n.onError("浏览器拦截了弹窗,请允许弹窗后重试"),URL.revokeObjectURL(d);return}setTimeout(()=>v.print(),400),setTimeout(()=>URL.revokeObjectURL(d),1e4)}return{print:s,exportAs:f,openPdfWindow:y,releasePrintFrame:o}}const he={class:"mrp-toolbar"},we={class:"mrp-title"},Pe=["disabled"],be={class:"mrp-pageinfo"},ye=["disabled"],Ee=e.defineComponent({__name:"ReportToolbar",props:{pageCount:{},currentPage:{},zoomMode:{},zoom:{},showExport:{type:Boolean},showPrint:{type:Boolean},showPdfWindow:{type:Boolean},messages:{}},emits:["goto","zoom","export","print","pdf-window"],setup(t){function n(r,o,a){return r.replace("{cur}",String(o)).replace("{total}",String(a))}return(r,o)=>(e.openBlock(),e.createElementBlock("div",he,[e.createElementVNode("span",we,e.toDisplayString(t.messages.title),1),t.pageCount>0?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createElementVNode("button",{class:"mrp-nav",type:"button",disabled:t.currentPage<=1,onClick:o[0]||(o[0]=a=>r.$emit("goto",t.currentPage-1))},e.toDisplayString(t.messages.prevPage),9,Pe),e.createElementVNode("span",be,e.toDisplayString(n(t.messages.pageInfo,t.currentPage,t.pageCount)),1),e.createElementVNode("button",{class:"mrp-nav",type:"button",disabled:t.currentPage>=t.pageCount,onClick:o[1]||(o[1]=a=>r.$emit("goto",t.currentPage+1))},e.toDisplayString(t.messages.nextPage),9,ye)],64)):e.createCommentVNode("",!0),o[9]||(o[9]=e.createElementVNode("span",{class:"mrp-spacer"},null,-1)),e.createElementVNode("button",{class:e.normalizeClass(["mrp-nav",{"mrp-active":t.zoomMode==="fit"}]),type:"button",onClick:o[2]||(o[2]=a=>r.$emit("zoom","fit"))},e.toDisplayString(t.messages.fitWidth),3),e.createElementVNode("button",{class:e.normalizeClass(["mrp-nav",{"mrp-active":t.zoomMode==="raw"&&Math.round(t.zoom*100)===100}]),type:"button",onClick:o[3]||(o[3]=a=>r.$emit("zoom",100))}," 100% ",2),e.createElementVNode("button",{class:e.normalizeClass(["mrp-nav",{"mrp-active":t.zoomMode==="raw"&&Math.round(t.zoom*100)===150}]),type:"button",onClick:o[4]||(o[4]=a=>r.$emit("zoom",150))}," 150% ",2),t.showExport?(e.openBlock(),e.createElementBlock("button",{key:1,class:"mrp-nav",type:"button",onClick:o[5]||(o[5]=a=>r.$emit("export","html"))},e.toDisplayString(t.messages.exportHtml),1)):e.createCommentVNode("",!0),t.showExport?(e.openBlock(),e.createElementBlock("button",{key:2,class:"mrp-nav",type:"button",onClick:o[6]||(o[6]=a=>r.$emit("export","pdf"))},e.toDisplayString(t.messages.exportPdf),1)):e.createCommentVNode("",!0),t.showPrint?(e.openBlock(),e.createElementBlock("button",{key:3,class:"mrp-nav",type:"button",onClick:o[7]||(o[7]=a=>r.$emit("print"))},e.toDisplayString(t.messages.print),1)):e.createCommentVNode("",!0),t.showPdfWindow?(e.openBlock(),e.createElementBlock("button",{key:4,class:"mrp-nav",type:"button",onClick:o[8]||(o[8]=a=>r.$emit("pdf-window"))},e.toDisplayString(t.messages.pdfWindow),1)):e.createCommentVNode("",!0)]))}}),J=(t,n)=>{const r=t.__vccOpts||t;for(const[o,a]of n)r[o]=a;return r},Q=J(Ee,[["__scopeId","data-v-2bfb2c61"]]),_={title:"报表预览",prevPage:"‹ 上一页",nextPage:"下一页 ›",pageInfo:"{cur} / {total}",fitWidth:"适宽",exportHtml:"导出 HTML",exportPdf:"导出 PDF",print:"打印",pdfWindow:"PDF 窗口",loading:"报表渲染中…",empty:"暂无预览数据",errorPrefix:"",retry:"重试"},ee={shellBg:"#525659",shellFg:"#e8e8e8",toolbarBg:"#323639",toolbarBorder:"#22252a",toolbarFg:"#e8e8e8",btnFg:"#cfcfcf",btnBorder:"#4a4d52",btnHoverBg:"#414549",btnHoverFg:"#ffffff",btnActiveBg:"#2d5fb8"};function xe(t){return t}function ke(t){return t}const $={showExport:!0,showPrint:!0,showPdfWindow:!0,gapPx:18,pdfFontUrl:"/simhei.ttf"};function te(t,n){const r=n?t?.presets?.[n]:t?.defaultPreset?t?.presets?.[t.defaultPreset]:void 0,o={...t?.defaults,...r};return{showExport:o.showExport??$.showExport,showPrint:o.showPrint??$.showPrint,showPdfWindow:o.showPdfWindow??$.showPdfWindow,gapPx:o.gapPx??$.gapPx,pdfFontUrl:o.pdfFontUrl??$.pdfFontUrl,theme:{...ee,...o.theme},messages:{..._,...o.messages}}}function oe(t){const n={};return t.shellBg!=null&&(n["--mrp-shell-bg"]=t.shellBg),t.shellFg!=null&&(n["--mrp-shell-fg"]=t.shellFg),t.toolbarBg!=null&&(n["--mrp-toolbar-bg"]=t.toolbarBg),t.toolbarBorder!=null&&(n["--mrp-toolbar-border"]=t.toolbarBorder),t.toolbarFg!=null&&(n["--mrp-toolbar-fg"]=t.toolbarFg),t.btnFg!=null&&(n["--mrp-btn-fg"]=t.btnFg),t.btnBorder!=null&&(n["--mrp-btn-border"]=t.btnBorder),t.btnHoverBg!=null&&(n["--mrp-btn-hover-bg"]=t.btnHoverBg),t.btnHoverFg!=null&&(n["--mrp-btn-hover-fg"]=t.btnHoverFg),t.btnActiveBg!=null&&(n["--mrp-btn-active-bg"]=t.btnActiveBg),n}function Be(t){const n=e.inject(B.MACH_REPORT_CONFIG_KEY,null),r=e.computed(()=>{const o=n?.value??null,a="defaults"in t&&"presets"in t?t:{defaults:t,presets:{}};return o?{defaults:{...o.defaults,...a.defaults},presets:{...o.presets,...a.presets},defaultPreset:a.defaultPreset??o.defaultPreset}:a});e.provide(B.MACH_REPORT_CONFIG_KEY,r)}function ne(){return e.inject(B.MACH_REPORT_CONFIG_KEY,e.computed(()=>null))}const Me={key:0,class:"mrp-state"},Ce={key:1,class:"mrp-state mrp-error"},Re={key:2,class:"mrp-state"},$e=["data-page"],z=96/25.4,Se=e.defineComponent({__name:"ReportPreview",props:{tempId:{type:[String,Array],default:null},furnitureTempId:{type:String,default:""},params:{type:Object,default:()=>({})},height:{type:String,default:"100vh"},autoLoad:{type:Boolean,default:!0},showExport:{type:Boolean,default:void 0},showPrint:{type:Boolean,default:void 0},showPdfWindow:{type:Boolean,default:void 0},gapPx:{type:Number,default:void 0},messages:{type:Object,default:void 0},preset:{type:String,default:void 0},fetcher:{type:Function,default:null}},emits:["loaded","error"],setup(t,{expose:n,emit:r}){e.useCssVars(P=>({v1f6cf76a:g.value+"px"}));const o=t,a=r,s=e.shallowRef(null),c=e.ref(!1),f=e.ref(""),y=e.ref(1),u=e.ref(null),i=e.ref(null),g=e.computed(()=>Math.max(0,ie.value)),l=e.inject(B.MACH_REPORT_FETCHER_KEY,null),d=e.inject(B.MACH_REPORT_PDF_EXPORTER_KEY,null)??B.createDefaultPdfExporter({fontUrl:"/simhei.ttf"}),v=e.computed(()=>B.normalizeTempIds(o.tempId)),b=e.computed(()=>s.value?.pages.length??0),D=ne(),E=e.computed(()=>te(D.value,o.preset)),x=e.computed(()=>({...E.value.messages,...o.messages})),ae=e.computed(()=>o.showExport??E.value.showExport),le=e.computed(()=>o.showPrint??E.value.showPrint),se=e.computed(()=>o.showPdfWindow??E.value.showPdfWindow),ie=e.computed(()=>o.gapPx??E.value.gapPx),ue=e.computed(()=>({height:o.height,...oe(E.value.theme)})),{zoom:M,zoomMode:ce,applyFitZoom:A,setZoom:de}=Y(()=>({viewport:i.value,pageWidthPx:(s.value?.pages[0]?.pageWidthMm??210)*z})),pe=Z(s,M,{pxPerMm:z,gapPx:g.value}),{contentSize:N,windowRange:S,visiblePages:fe,makeScrollHandler:me,refreshViewport:L}=pe,ge=me(y,b);function V(){s.value=null,y.value=1}let F=0;async function R(){const P=++F,h=o.fetcher??l;if(v.value.length===0){f.value="缺少报表模板 ID",V(),a("error",f.value);return}if(!h){f.value="未提供渲染数据源 fetcher",V(),a("error",f.value);return}c.value=!0,f.value="",V();try{const m=await h({tempIds:v.value,furnitureTempId:o.furnitureTempId||void 0,params:{...o.params}});if(P!==F)return;const w=H.validateRenderPlan(m);if(!w.ok){const k=w.errors.slice(0,3).map(C=>`${C.path}: ${C.message}`).join("; ");throw new Error(`渲染计划校验失败(${w.errors.length} 处): ${k}`)}w.warnings.length>0&&console.warn("[mach-report] 渲染计划告警:",w.warnings),s.value=m,y.value=1,i.value&&(i.value.scrollTop=0),A(),a("loaded",m.pages.length)}catch(m){if(P!==F)return;f.value=m instanceof Error?m.message:"预览加载失败",a("error",f.value)}finally{P===F&&(c.value=!1)}}function O(P){if(b.value<=0)return;const h=Math.max(1,Math.min(b.value,P));y.value=h;const m=i.value;if(!m)return;let w=0;for(let k=0;k<h-1;k++)w+=(s.value?.pages[k]?.pageHeightMm??0)*z+g.value;m.scrollTop=w*M.value}const{print:I,exportAs:j,openPdfWindow:U,releasePrintFrame:ve}=X(s,{getPdfExporter:()=>d,onError:P=>a("error",P)});e.watchEffect(()=>{const P=s.value;if(!P)return;const h=u.value;if(!h)return;h.querySelectorAll(".mrp-page-holder").forEach(w=>{const k=Number(w.dataset.page??0)-1,C=P.pages[k];!C||w.childElementCount>0||(w.style.width=`${C.pageWidthMm*z}px`,w.appendChild(H.renderPage(C,96,{},document)))})},{flush:"post"});function G(){L(i.value),A()}return e.onMounted(()=>{window.addEventListener("resize",G),L(i.value),o.autoLoad&&R()}),e.onUnmounted(()=>{window.removeEventListener("resize",G),ve()}),e.watch(()=>[o.tempId,o.furnitureTempId,JSON.stringify(o.params)],()=>{o.autoLoad&&R()}),e.watch(()=>o.fetcher??l,()=>{o.autoLoad&&R()}),n({reload:R,print:I,exportAs:j,openPdfWindow:U,gotoPage:O}),(P,h)=>(e.openBlock(),e.createElementBlock("div",{class:"mach-report-preview",style:e.normalizeStyle(ue.value)},[e.createVNode(Q,{"page-count":b.value,"current-page":y.value,"zoom-mode":e.unref(ce),zoom:e.unref(M),"show-export":ae.value,"show-print":le.value,"show-pdf-window":se.value,messages:x.value,onGoto:O,onZoom:e.unref(de),onExport:h[0]||(h[0]=m=>e.unref(j)(m)),onPrint:e.unref(I),onPdfWindow:e.unref(U)},null,8,["page-count","current-page","zoom-mode","zoom","show-export","show-print","show-pdf-window","messages","onZoom","onPrint","onPdfWindow"]),e.createElementVNode("div",{ref_key:"viewportRef",ref:i,class:"mrp-body",onScrollPassive:h[1]||(h[1]=m=>e.unref(ge)(m.target))},[c.value?(e.openBlock(),e.createElementBlock("div",Me,e.toDisplayString(x.value.loading),1)):f.value?(e.openBlock(),e.createElementBlock("div",Ce,[e.createTextVNode(e.toDisplayString(f.value)+" ",1),e.createElementVNode("button",{class:"mrp-retry",type:"button",onClick:R},e.toDisplayString(x.value.retry),1)])):!s.value||b.value===0?(e.openBlock(),e.createElementBlock("div",Re,e.toDisplayString(x.value.empty),1)):(e.openBlock(),e.createElementBlock("div",{key:3,class:"mrp-scale",style:e.normalizeStyle({width:`${e.unref(N).w*e.unref(M)}px`,height:`${e.unref(N).h*e.unref(M)}px`})},[e.createElementVNode("div",{ref_key:"containerRef",ref:u,class:"mrp-scale-inner",style:e.normalizeStyle({transform:`scale(${e.unref(M)})`,transformOrigin:"top left",width:`${e.unref(N).w}px`})},[e.unref(S).padTopPx>0?(e.openBlock(),e.createElementBlock("div",{key:0,class:"mrp-spacer-top",style:e.normalizeStyle({height:`${e.unref(S).padTopPx}px`}),"aria-hidden":"true"},null,4)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(fe),m=>(e.openBlock(),e.createElementBlock("div",{key:m.index,class:"mrp-page-holder","data-page":m.index+1},null,8,$e))),128)),e.unref(S).padBottomPx>0?(e.openBlock(),e.createElementBlock("div",{key:1,class:"mrp-spacer-bottom",style:e.normalizeStyle({height:`${e.unref(S).padBottomPx}px`}),"aria-hidden":"true"},null,4)):e.createCommentVNode("",!0)],4)],4))],544)],4))}}),re=J(Se,[["__scopeId","data-v-a3e8e93b"]]),Fe=Object.freeze(Object.defineProperty({__proto__:null,default:re},Symbol.toStringTag,{value:"Module"}));exports.DEFAULT_MESSAGES=_;exports.DEFAULT_THEME=ee;exports.ReportPreview=re;exports.ReportPreview$1=Fe;exports.ReportToolbar=Q;exports.buildPrintDocument=W;exports.defineMachReportConfig=xe;exports.defineMachReportPreset=ke;exports.provideMachReportConfig=Be;exports.resolveConfig=te;exports.themeToCssVars=oe;exports.useMachReportConfig=ne;exports.usePageWindow=Z;exports.usePrintExport=X;exports.useZoom=Y;
@@ -1 +0,0 @@
1
- "use strict";var g=Object.create;var d=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var U=Object.getPrototypeOf,w=Object.prototype.hasOwnProperty;var y=(r,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of F(e))!w.call(r,t)&&t!==n&&d(r,t,{get:()=>e[t],enumerable:!(o=T(e,t))||o.enumerable});return r};var j=(r,e,n)=>(n=r!=null?g(U(r)):{},y(e||!r||!r.__esModule?d(n,"default",{value:r,enumerable:!0}):n,r));const C=require("vue");function h(r){return r==null?[]:Array.isArray(r)?r.map(String).filter(e=>e!==""):String(r).split(",").map(e=>e.trim()).filter(e=>e!=="")}function O(r){return h(r).join(",")}class l extends Error{constructor(e){super(e),this.name="PlanLoadError"}}function E(r={}){const{baseUrl:e="",headers:n,credentials:o}=r;return async({url:t,method:f,params:a})=>{const c=a&&Object.keys(a).length>0?`?${new URLSearchParams(a)}`:"";let s;try{s=await fetch(`${e}${t}${c}`,{method:f.toUpperCase(),headers:{Accept:"application/json",...n},credentials:o})}catch(i){throw new l(`请求失败(${t}): ${i instanceof Error?i.message:String(i)}`)}if(!s.ok)throw new l(`HTTP ${s.status} ${t}`);return s.json()}}function P(r){const{request:e,baseUrl:n=""}=r;return async({tempIds:o,furnitureTempId:t,params:f})=>{if(o.length===0)throw new l("缺少报表模板 ID");const a={tempId:o.join(",")};t&&(a.furnitureTempId=t);for(const[i,u]of Object.entries(f||{}))i&&u!=null&&u!==""&&(a[i]=String(u));const c=await e({url:`${n}/report/codePrintReport/gridPlan`,method:"get",params:a});if(c&&c.code!=null&&c.code!==200)throw new l(String(c.message||"预览加载失败"));const s=c?.data?.pages;return{schemaVersion:"jh4j-compatible",pages:Array.isArray(s)?s:[]}}}function R(r={fontUrl:"/simhei.ttf"}){let e=null;return async n=>{e||(e=await import("@agile-team/mach-report/pdf"));const o=r.fontUrl?await e.loadFontWithCache(r.fontUrl):null,{bytes:t}=await e.renderPlanToPdf(n,o?{customFontBytes:o}:{});return t}}const m="mach-report/fetcher",p="mach-report/pdf-exporter",_="mach-report/config",b={install(r,e={}){const n=e.fetcher??P({request:e.request??E({baseUrl:e.baseUrl}),baseUrl:e.baseUrl});r.provide(m,n);const o=e.pdfFontUrl??e.config?.defaults?.pdfFontUrl??"/simhei.ttf";r.provide(p,e.pdfExporter??R({fontUrl:o})),r.provide(_,C.computed(()=>e.config??null))}};exports.MACH_REPORT_CONFIG_KEY=_;exports.MACH_REPORT_FETCHER_KEY=m;exports.MACH_REPORT_PDF_EXPORTER_KEY=p;exports.PlanLoadError=l;exports.createDefaultPdfExporter=R;exports.createFetchRequest=E;exports.createJh4jGridPlanFetcher=P;exports.joinTempIds=O;exports.machReportPlugin=b;exports.normalizeTempIds=h;