@veltra/sheet 2.4.0 → 2.5.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.
Files changed (142) hide show
  1. package/dist/index.d.ts +2 -19
  2. package/dist/index.js +2 -15
  3. package/dist/types/index.d.ts +1 -3
  4. package/package.json +2 -3
  5. package/src/index.ts +1 -27
  6. package/src/types/index.ts +0 -2
  7. package/dist/components/report/binding-badge.js +0 -118
  8. package/dist/components/report/designer/cell-coords.js +0 -46
  9. package/dist/components/report/designer/col-widths.js +0 -29
  10. package/dist/components/report/designer/conditional-rules/helpers.js +0 -139
  11. package/dist/components/report/designer/drill-dialog.js +0 -258
  12. package/dist/components/report/designer/drop-highlight-overlay.js +0 -76
  13. package/dist/components/report/designer/float-panel.js +0 -434
  14. package/dist/components/report/designer/role.js +0 -17
  15. package/dist/components/report/designer/rule-preview.js +0 -33
  16. package/dist/components/report/designer/rule-row.js +0 -253
  17. package/dist/components/report/designer/rules-dialog.js +0 -118
  18. package/dist/components/report/designer/topology-overlay.js +0 -122
  19. package/dist/components/report/designer/topology.js +0 -64
  20. package/dist/components/report/designer/use-grid-overlay.js +0 -75
  21. package/dist/components/report/designer-hub.js +0 -177
  22. package/dist/components/report/field-panel-helpers.js +0 -33
  23. package/dist/components/report/field-panel.js +0 -132
  24. package/dist/components/report/filter-bar.js +0 -74
  25. package/dist/components/report/hub-connection-form.js +0 -145
  26. package/dist/components/report/hub-dataset-editor.js +0 -409
  27. package/dist/components/report/preview-grid-size.js +0 -32
  28. package/dist/components/report/print.js +0 -39
  29. package/dist/components/report/report-designer.js +0 -428
  30. package/dist/components/report/report-viewer.js +0 -253
  31. package/dist/components/report/style.d.ts +0 -17
  32. package/dist/components/report/style.js +0 -18
  33. package/dist/components/report/style2.css +0 -965
  34. package/dist/components/report/use-report-designer.js +0 -387
  35. package/dist/components/report/use-report-viewer.js +0 -140
  36. package/dist/report/binding.d.ts +0 -83
  37. package/dist/report/binding.js +0 -334
  38. package/dist/report/connector.d.ts +0 -66
  39. package/dist/report/connector.js +0 -159
  40. package/dist/report/drill.d.ts +0 -48
  41. package/dist/report/drill.js +0 -78
  42. package/dist/report/export-xlsx.d.ts +0 -13
  43. package/dist/report/export-xlsx.js +0 -13
  44. package/dist/report/filter-bar.d.ts +0 -10
  45. package/dist/report/filter-bar.js +0 -31
  46. package/dist/report/index.d.ts +0 -14
  47. package/dist/report/params.d.ts +0 -13
  48. package/dist/report/params.js +0 -61
  49. package/dist/report/print.d.ts +0 -23
  50. package/dist/report/print.js +0 -197
  51. package/dist/report/render/aggregate.js +0 -193
  52. package/dist/report/render/builder.d.ts +0 -12
  53. package/dist/report/render/builder.js +0 -139
  54. package/dist/report/render/coordinate.d.ts +0 -25
  55. package/dist/report/render/coordinate.js +0 -733
  56. package/dist/report/render/index.d.ts +0 -14
  57. package/dist/report/render/index.js +0 -21
  58. package/dist/report/render/style-resolver.js +0 -50
  59. package/dist/report/render/template-index.d.ts +0 -24
  60. package/dist/report/render/template-index.js +0 -137
  61. package/dist/report/rules/evaluate.d.ts +0 -25
  62. package/dist/report/rules/evaluate.js +0 -82
  63. package/dist/report/rules/index.d.ts +0 -2
  64. package/dist/report/template.d.ts +0 -63
  65. package/dist/report/template.js +0 -83
  66. package/dist/report/types.d.ts +0 -103
  67. package/dist/types/report-designer.d.ts +0 -51
  68. package/dist/types/report-viewer.d.ts +0 -57
  69. package/src/components/report/__test__/binding-badge.test.ts +0 -92
  70. package/src/components/report/__test__/conditional-rules-helpers.test.ts +0 -88
  71. package/src/components/report/__test__/field-panel-helpers.test.ts +0 -65
  72. package/src/components/report/__test__/float-panel-position.test.ts +0 -45
  73. package/src/components/report/__test__/preview-grid-size.test.ts +0 -63
  74. package/src/components/report/__test__/report-designer.test.ts +0 -559
  75. package/src/components/report/__test__/report-drill.test.ts +0 -692
  76. package/src/components/report/__test__/report-viewer.test.ts +0 -400
  77. package/src/components/report/__test__/topology.test.ts +0 -143
  78. package/src/components/report/__test__/use-report-designer.test.ts +0 -804
  79. package/src/components/report/binding-badge.ts +0 -122
  80. package/src/components/report/designer/cell-coords.ts +0 -95
  81. package/src/components/report/designer/col-widths.ts +0 -56
  82. package/src/components/report/designer/conditional-rules/helpers.ts +0 -189
  83. package/src/components/report/designer/drill-dialog.vue +0 -245
  84. package/src/components/report/designer/drop-highlight-overlay.vue +0 -75
  85. package/src/components/report/designer/float-panel.vue +0 -444
  86. package/src/components/report/designer/role.ts +0 -32
  87. package/src/components/report/designer/rule-preview.vue +0 -40
  88. package/src/components/report/designer/rule-row.vue +0 -252
  89. package/src/components/report/designer/rules-dialog.vue +0 -110
  90. package/src/components/report/designer/topology-overlay.vue +0 -128
  91. package/src/components/report/designer/topology.ts +0 -124
  92. package/src/components/report/designer/use-grid-overlay.ts +0 -114
  93. package/src/components/report/designer-hub.vue +0 -198
  94. package/src/components/report/field-panel-helpers.ts +0 -44
  95. package/src/components/report/field-panel.vue +0 -136
  96. package/src/components/report/filter-bar.vue +0 -77
  97. package/src/components/report/hub-connection-form.vue +0 -124
  98. package/src/components/report/hub-dataset-editor.vue +0 -387
  99. package/src/components/report/index.ts +0 -2
  100. package/src/components/report/preview-grid-size.ts +0 -33
  101. package/src/components/report/print.ts +0 -44
  102. package/src/components/report/report-designer.vue +0 -454
  103. package/src/components/report/report-viewer.vue +0 -289
  104. package/src/components/report/style-designer.scss +0 -653
  105. package/src/components/report/style-hub.scss +0 -292
  106. package/src/components/report/style-viewer.scss +0 -144
  107. package/src/components/report/style.scss +0 -3
  108. package/src/components/report/style.ts +0 -20
  109. package/src/components/report/use-report-designer.ts +0 -603
  110. package/src/components/report/use-report-viewer.ts +0 -227
  111. package/src/report/__test__/binding.test.ts +0 -320
  112. package/src/report/__test__/connector.test.ts +0 -239
  113. package/src/report/__test__/drill.test.ts +0 -194
  114. package/src/report/__test__/export-xlsx.test.ts +0 -96
  115. package/src/report/__test__/filter-bar.test.ts +0 -58
  116. package/src/report/__test__/params.test.ts +0 -156
  117. package/src/report/__test__/print.test.ts +0 -170
  118. package/src/report/__test__/render.test.ts +0 -856
  119. package/src/report/__test__/rules.test.ts +0 -131
  120. package/src/report/__test__/template.test.ts +0 -366
  121. package/src/report/binding.ts +0 -474
  122. package/src/report/connector.ts +0 -206
  123. package/src/report/drill.ts +0 -112
  124. package/src/report/export-xlsx.ts +0 -15
  125. package/src/report/filter-bar.ts +0 -36
  126. package/src/report/index.ts +0 -16
  127. package/src/report/params.ts +0 -96
  128. package/src/report/print.ts +0 -234
  129. package/src/report/render/__test__/aggregate.test.ts +0 -16
  130. package/src/report/render/__test__/coordinate.test.ts +0 -405
  131. package/src/report/render/aggregate.ts +0 -289
  132. package/src/report/render/builder.ts +0 -211
  133. package/src/report/render/coordinate.ts +0 -1239
  134. package/src/report/render/index.ts +0 -30
  135. package/src/report/render/style-resolver.ts +0 -68
  136. package/src/report/render/template-index.ts +0 -200
  137. package/src/report/rules/evaluate.ts +0 -113
  138. package/src/report/rules/index.ts +0 -7
  139. package/src/report/template.ts +0 -145
  140. package/src/report/types.ts +0 -116
  141. package/src/types/report-designer.ts +0 -55
  142. package/src/types/report-viewer.ts +0 -54
@@ -1,409 +0,0 @@
1
- import { buildParamDefs } from "../../report/params.js";
2
- import { computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, normalizeClass, onBeforeUnmount, openBlock, ref, shallowRef, toDisplayString, unref, watch, withCtx } from "vue";
3
- import { UButton, UCodeEditor, UInput, UPopConfirm, USelect, UTable, UTabs, UTag, defineTableColumns } from "@veltra/desktop";
4
- import { bem } from "@veltra/utils";
5
- //#region src/components/report/hub-dataset-editor.vue
6
- const _sfc_main = /*@__PURE__*/ defineComponent({
7
- name: "UReportHubDatasetEditor",
8
- __name: "hub-dataset-editor",
9
- props: {
10
- hub: {},
11
- datasetId: {}
12
- },
13
- emits: ["remove"],
14
- setup(__props, { emit: __emit }) {
15
- const props = __props;
16
- const emit = __emit;
17
- const cls = bem("report-hub-dataset-editor");
18
- const detailTab = ref("schema");
19
- const detailTabItems = [{
20
- key: "schema",
21
- name: "字段 Schema"
22
- }, {
23
- key: "preview",
24
- name: "数据预览"
25
- }];
26
- const paramTypeOptions = [
27
- {
28
- label: "文本",
29
- value: "text"
30
- },
31
- {
32
- label: "数字",
33
- value: "number"
34
- },
35
- {
36
- label: "日期",
37
- value: "date"
38
- },
39
- {
40
- label: "日期范围",
41
- value: "date-range"
42
- },
43
- {
44
- label: "下拉",
45
- value: "select"
46
- }
47
- ];
48
- const dataset = computed(() => props.hub.datasets.value.find((item) => item.id === props.datasetId));
49
- const describing = ref(false);
50
- const describeError = shallowRef("");
51
- let describeSeq = 0;
52
- const previewing = ref(false);
53
- const previewError = shallowRef("");
54
- const previewRows = shallowRef([]);
55
- const previewFields = shallowRef([]);
56
- function resetPreview() {
57
- previewing.value = false;
58
- previewError.value = "";
59
- previewRows.value = [];
60
- previewFields.value = [];
61
- }
62
- const sqlDraft = ref("");
63
- let sqlTimer;
64
- watch(() => props.datasetId, () => {
65
- sqlDraft.value = dataset.value?.sql ?? "";
66
- resetPreview();
67
- runDescribe();
68
- }, { immediate: true });
69
- /** 立即把草稿 SQL 落入数据集(v-model 实时、change 失焦才发且提交有 debounce),供预览同步拿到最新 SQL */
70
- function flushSqlDraft(datasetId) {
71
- if (sqlTimer) {
72
- clearTimeout(sqlTimer);
73
- sqlTimer = void 0;
74
- }
75
- const current = dataset.value;
76
- if (!current || current.sql === sqlDraft.value) return;
77
- props.hub.updateDataset(datasetId, { sql: sqlDraft.value });
78
- runDescribe();
79
- }
80
- function onSqlChange(value) {
81
- sqlDraft.value = value;
82
- const datasetId = props.datasetId;
83
- if (sqlTimer) clearTimeout(sqlTimer);
84
- sqlTimer = setTimeout(() => {
85
- sqlTimer = void 0;
86
- if (props.datasetId !== datasetId) return;
87
- props.hub.updateDataset(datasetId, { sql: value });
88
- runDescribe();
89
- }, 280);
90
- }
91
- onBeforeUnmount(() => {
92
- if (sqlTimer) clearTimeout(sqlTimer);
93
- });
94
- async function runDescribe() {
95
- const seq = ++describeSeq;
96
- if (!sqlDraft.value.trim()) {
97
- describeError.value = "";
98
- props.hub.updateDataset(props.datasetId, { fields: void 0 });
99
- return;
100
- }
101
- describing.value = true;
102
- const result = await props.hub.describeDataset(props.datasetId);
103
- if (seq !== describeSeq) return;
104
- describing.value = false;
105
- describeError.value = result.ok ? "" : result.error.message;
106
- }
107
- const paramRows = computed(() => {
108
- const current = dataset.value;
109
- if (!current || !current.sql.trim()) return [];
110
- return buildParamDefs(current.sql, current.paramOverrides);
111
- });
112
- const schemaRows = computed(() => {
113
- const current = dataset.value;
114
- if (!current) return [];
115
- return (current.fields ?? []).map((field) => ({
116
- ...field,
117
- label: current.fieldOverrides?.[field.name]?.label ?? field.label
118
- }));
119
- });
120
- async function runPreview() {
121
- flushSqlDraft(props.datasetId);
122
- previewing.value = true;
123
- previewError.value = "";
124
- const result = await props.hub.previewDataset(props.datasetId);
125
- previewing.value = false;
126
- if (result.ok) {
127
- previewRows.value = result.data.rows;
128
- previewFields.value = result.data.fields;
129
- } else {
130
- previewRows.value = [];
131
- previewError.value = result.error.message;
132
- }
133
- }
134
- watch(detailTab, (tab) => {
135
- if (tab === "preview") runPreview();
136
- });
137
- const paramColumns = defineTableColumns([
138
- {
139
- key: "id",
140
- name: "参数名",
141
- minWidth: 100
142
- },
143
- {
144
- key: "label",
145
- name: "显示名",
146
- minWidth: 120
147
- },
148
- {
149
- key: "type",
150
- name: "类型",
151
- width: 120
152
- },
153
- {
154
- key: "defaultValue",
155
- name: "默认值",
156
- minWidth: 140
157
- },
158
- {
159
- key: "options",
160
- name: "选项(select)",
161
- minWidth: 160
162
- }
163
- ]);
164
- const schemaColumns = defineTableColumns([
165
- {
166
- key: "name",
167
- name: "字段名(name)",
168
- minWidth: 140
169
- },
170
- {
171
- key: "label",
172
- name: "中文描述(label)",
173
- minWidth: 160
174
- },
175
- {
176
- key: "type",
177
- name: "类型",
178
- width: 88
179
- }
180
- ]);
181
- const previewColumns = computed(() => defineTableColumns(previewFields.value.map((field) => ({
182
- key: field.name,
183
- name: field.label,
184
- minWidth: field.type === "number" ? 88 : 112
185
- }))));
186
- function fieldTypeColor(type) {
187
- if (type === "number") return "success";
188
- if (type === "date") return "warning";
189
- return "info";
190
- }
191
- function formatDefaultValue(value) {
192
- if (Array.isArray(value)) return value.join(", ");
193
- return String(value ?? "");
194
- }
195
- function formatOptions(options) {
196
- if (!options?.length) return "";
197
- return options.map((item) => `${item.label}|${item.value}`).join(",");
198
- }
199
- function parseOptions(raw) {
200
- return raw.split(",").map((part) => part.trim()).filter(Boolean).map((part) => {
201
- const [label, value] = part.split("|");
202
- const text = (label ?? "").trim();
203
- return {
204
- label: text,
205
- value: (value ?? text).trim()
206
- };
207
- });
208
- }
209
- function patchDataset(patch) {
210
- props.hub.updateDataset(props.datasetId, patch);
211
- }
212
- function patchParam(paramId, patch) {
213
- const current = dataset.value;
214
- if (!current) return;
215
- patchDataset({ paramOverrides: {
216
- ...current.paramOverrides,
217
- [paramId]: {
218
- ...current.paramOverrides?.[paramId],
219
- ...patch
220
- }
221
- } });
222
- }
223
- function patchFieldLabel(fieldName, label) {
224
- const current = dataset.value;
225
- if (!current) return;
226
- patchDataset({ fieldOverrides: {
227
- ...current.fieldOverrides,
228
- [fieldName]: {
229
- ...current.fieldOverrides?.[fieldName],
230
- label
231
- }
232
- } });
233
- }
234
- return (_ctx, _cache) => {
235
- return dataset.value ? (openBlock(), createElementBlock("section", {
236
- key: 0,
237
- class: normalizeClass(unref(cls).b)
238
- }, [
239
- createElementVNode("div", { class: normalizeClass(unref(cls).e("head")) }, [createElementVNode("div", { class: normalizeClass(unref(cls).e("rename")) }, [createElementVNode("span", { class: normalizeClass(unref(cls).e("label")) }, "数据集名称", 2), createVNode(unref(UInput), {
240
- "model-value": dataset.value.label,
241
- size: "small",
242
- "onUpdate:modelValue": _cache[0] || (_cache[0] = (v) => patchDataset({ label: String(v ?? "") }))
243
- }, null, 8, ["model-value"])], 2), createVNode(unref(UPopConfirm), {
244
- title: "确定删除该数据集?",
245
- onConfirm: _cache[1] || (_cache[1] = ($event) => emit("remove"))
246
- }, {
247
- reference: withCtx(() => [createVNode(unref(UButton), {
248
- size: "small",
249
- type: "danger",
250
- plain: ""
251
- }, {
252
- default: withCtx(() => [..._cache[4] || (_cache[4] = [createTextVNode("删除数据集", -1)])]),
253
- _: 1
254
- })]),
255
- _: 1
256
- })], 2),
257
- createElementVNode("div", { class: normalizeClass(unref(cls).e("sql")) }, [
258
- createElementVNode("p", { class: normalizeClass(unref(cls).e("section-title")) }, "SQL 查询", 2),
259
- createVNode(unref(UCodeEditor), {
260
- modelValue: sqlDraft.value,
261
- "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => sqlDraft.value = $event),
262
- lang: "sql",
263
- langs: ["sql"],
264
- "default-lines": 6,
265
- onChange: onSqlChange
266
- }, null, 8, ["modelValue"]),
267
- describeError.value ? (openBlock(), createElementBlock("p", {
268
- key: 0,
269
- class: normalizeClass(unref(cls).e("sql-error")),
270
- role: "alert"
271
- }, toDisplayString(describeError.value), 3)) : createCommentVNode("v-if", true)
272
- ], 2),
273
- paramRows.value.length ? (openBlock(), createElementBlock("div", {
274
- key: 0,
275
- class: normalizeClass(unref(cls).e("params"))
276
- }, [createElementVNode("p", { class: normalizeClass(unref(cls).e("section-title")) }, "查询参数(从 SQL 自动提取)", 2), createVNode(unref(UTable), {
277
- class: normalizeClass(unref(cls).e("param-table")),
278
- data: paramRows.value,
279
- columns: unref(paramColumns),
280
- border: "",
281
- "text-ellipsis": ""
282
- }, {
283
- "column:label": withCtx(({ rowData }) => [createVNode(unref(UInput), {
284
- "model-value": rowData.label,
285
- size: "small",
286
- "onUpdate:modelValue": (v) => patchParam(rowData.id, { label: String(v ?? "") })
287
- }, null, 8, ["model-value", "onUpdate:modelValue"])]),
288
- "column:type": withCtx(({ rowData }) => [createVNode(unref(USelect), {
289
- "model-value": rowData.type,
290
- size: "small",
291
- options: paramTypeOptions,
292
- "onUpdate:modelValue": (v) => patchParam(rowData.id, { type: v })
293
- }, null, 8, ["model-value", "onUpdate:modelValue"])]),
294
- "column:defaultValue": withCtx(({ rowData }) => [rowData.type === "number" ? (openBlock(), createBlock(unref(UInput), {
295
- key: 0,
296
- "model-value": String(rowData.defaultValue ?? ""),
297
- size: "small",
298
- type: "number",
299
- "onUpdate:modelValue": (v) => patchParam(rowData.id, { defaultValue: Number(v) })
300
- }, null, 8, ["model-value", "onUpdate:modelValue"])) : rowData.type === "date" ? (openBlock(), createBlock(unref(UInput), {
301
- key: 1,
302
- "model-value": String(rowData.defaultValue ?? ""),
303
- size: "small",
304
- type: "date",
305
- "onUpdate:modelValue": (v) => patchParam(rowData.id, { defaultValue: v })
306
- }, null, 8, ["model-value", "onUpdate:modelValue"])) : rowData.type === "select" ? (openBlock(), createBlock(unref(USelect), {
307
- key: 2,
308
- "model-value": String(rowData.defaultValue ?? ""),
309
- size: "small",
310
- options: rowData.options ?? [],
311
- "onUpdate:modelValue": (v) => patchParam(rowData.id, { defaultValue: v })
312
- }, null, 8, [
313
- "model-value",
314
- "options",
315
- "onUpdate:modelValue"
316
- ])) : (openBlock(), createBlock(unref(UInput), {
317
- key: 3,
318
- "model-value": formatDefaultValue(rowData.defaultValue),
319
- size: "small",
320
- "onUpdate:modelValue": (v) => patchParam(rowData.id, { defaultValue: v })
321
- }, null, 8, ["model-value", "onUpdate:modelValue"]))]),
322
- "column:options": withCtx(({ rowData }) => [rowData.type === "select" ? (openBlock(), createBlock(unref(UInput), {
323
- key: 0,
324
- "model-value": formatOptions(rowData.options),
325
- size: "small",
326
- placeholder: "华东|华东,华南|华南",
327
- "onUpdate:modelValue": (v) => patchParam(rowData.id, { options: parseOptions(String(v ?? "")) })
328
- }, null, 8, ["model-value", "onUpdate:modelValue"])) : (openBlock(), createElementBlock("span", {
329
- key: 1,
330
- class: normalizeClass(unref(cls).e("muted"))
331
- }, "—", 2))]),
332
- _: 1
333
- }, 8, [
334
- "class",
335
- "data",
336
- "columns"
337
- ])], 2)) : createCommentVNode("v-if", true),
338
- createVNode(unref(UTabs), {
339
- modelValue: detailTab.value,
340
- "onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => detailTab.value = $event),
341
- items: detailTabItems,
342
- class: normalizeClass(unref(cls).e("tabs"))
343
- }, {
344
- schema: withCtx(() => [describing.value ? (openBlock(), createElementBlock("p", {
345
- key: 0,
346
- class: normalizeClass(unref(cls).e("muted"))
347
- }, "正在解析字段…", 2)) : (openBlock(), createBlock(unref(UTable), {
348
- key: 1,
349
- class: normalizeClass(unref(cls).e("schema-table")),
350
- data: schemaRows.value,
351
- columns: unref(schemaColumns),
352
- border: "",
353
- "text-ellipsis": ""
354
- }, {
355
- "column:label": withCtx(({ rowData }) => [createVNode(unref(UInput), {
356
- "model-value": rowData.label,
357
- size: "small",
358
- placeholder: "中文显示名",
359
- "onUpdate:modelValue": (v) => patchFieldLabel(rowData.name, String(v ?? ""))
360
- }, null, 8, ["model-value", "onUpdate:modelValue"])]),
361
- "column:type": withCtx(({ rowData }) => [createVNode(unref(UTag), {
362
- size: "small",
363
- type: fieldTypeColor(rowData.type)
364
- }, {
365
- default: withCtx(() => [createTextVNode(toDisplayString(rowData.type), 1)]),
366
- _: 2
367
- }, 1032, ["type"])]),
368
- _: 1
369
- }, 8, [
370
- "class",
371
- "data",
372
- "columns"
373
- ]))]),
374
- preview: withCtx(() => [
375
- createElementVNode("div", { class: normalizeClass(unref(cls).e("preview-actions")) }, [createVNode(unref(UButton), {
376
- size: "small",
377
- plain: "",
378
- loading: previewing.value,
379
- onClick: runPreview
380
- }, {
381
- default: withCtx(() => [..._cache[5] || (_cache[5] = [createTextVNode(" 刷新预览(按参数默认值取数) ", -1)])]),
382
- _: 1
383
- }, 8, ["loading"])], 2),
384
- createVNode(unref(UTable), {
385
- class: normalizeClass(unref(cls).e("preview-table")),
386
- data: previewRows.value,
387
- columns: previewColumns.value,
388
- "show-index": "",
389
- border: "",
390
- "text-ellipsis": ""
391
- }, null, 8, [
392
- "class",
393
- "data",
394
- "columns"
395
- ]),
396
- previewError.value ? (openBlock(), createElementBlock("p", {
397
- key: 0,
398
- class: normalizeClass(unref(cls).e("preview-error")),
399
- role: "alert"
400
- }, toDisplayString(previewError.value), 3)) : createCommentVNode("v-if", true)
401
- ]),
402
- _: 1
403
- }, 8, ["modelValue", "class"])
404
- ], 2)) : createCommentVNode("v-if", true);
405
- };
406
- }
407
- });
408
- //#endregion
409
- export { _sfc_main as default };
@@ -1,32 +0,0 @@
1
- //#region src/components/report/preview-grid-size.ts
2
- /**
3
- * 报表预览网格尺寸:只铺到实际内容,不用设计态 canvas / 50×10 下限。
4
- *
5
- * - `template`:取数前的静态结构,按 cells/merges/meta 包围盒(忽略 snapshot.rows/cols,
6
- * 那是设计网格声明尺寸,会带出空白格)
7
- * - `filled`:行保留展开布局的 `snapshot.rows`(可能含无存值的空扩展行);列按包围盒收敛
8
- * (Filled Report 的 `cols` 常被 `max(layout, template.cols)` 撑到设计态列数)
9
- */
10
- function previewGridSize(snapshot, mode) {
11
- let maxRow = -1;
12
- let maxCol = -1;
13
- const grow = (row, col) => {
14
- if (row > maxRow) maxRow = row;
15
- if (col > maxCol) maxCol = col;
16
- };
17
- for (const cell of snapshot.cells) grow(cell.row, cell.col);
18
- for (const merge of snapshot.merges) grow(merge.end.row, merge.end.col);
19
- for (const item of snapshot.meta ?? []) grow(item.row, item.col);
20
- const boundRows = maxRow + 1;
21
- const boundCols = maxCol + 1;
22
- if (mode === "filled") return {
23
- rows: Math.max(boundRows, snapshot.rows, 1),
24
- cols: Math.max(boundCols, 1)
25
- };
26
- return {
27
- rows: Math.max(boundRows, 1),
28
- cols: Math.max(boundCols, 1)
29
- };
30
- }
31
- //#endregion
32
- export { previewGridSize };
@@ -1,39 +0,0 @@
1
- //#region src/components/report/print.ts
2
- /**
3
- * 打印 HTML 文档:隐藏 iframe 装载后调起浏览器打印,结束(或兜底超时)销毁。
4
- *
5
- * 路线取舍:相对 `window.open` 不被弹窗拦截;相对 `@media print` 直打宿主页,
6
- * 不侵入应用布局,也不受网格 canvas 虚拟滚动(只绘制视口)限制。
7
- * iframe 用 0×0 定位隐藏而非 `display:none`(部分浏览器不打印 none 的 iframe)。
8
- */
9
- function printHtmlDocument(html) {
10
- const iframe = document.createElement("iframe");
11
- iframe.setAttribute("aria-hidden", "true");
12
- iframe.style.cssText = "position:fixed;right:0;bottom:0;width:0;height:0;border:0;";
13
- document.body.appendChild(iframe);
14
- const win = iframe.contentWindow;
15
- const doc = iframe.contentDocument;
16
- if (!win || !doc || typeof win.print !== "function") {
17
- iframe.remove();
18
- throw new Error("当前环境不支持打印");
19
- }
20
- let cleaned = false;
21
- const cleanup = () => {
22
- if (cleaned) return;
23
- cleaned = true;
24
- iframe.remove();
25
- };
26
- win.addEventListener("afterprint", cleanup);
27
- doc.open();
28
- doc.write(html);
29
- doc.close();
30
- const decoding = Array.from(doc.images).map((img) => typeof img.decode === "function" ? img.decode().catch(() => void 0) : Promise.resolve());
31
- Promise.all(decoding).then(() => {
32
- if (cleaned) return;
33
- win.focus();
34
- win.print();
35
- setTimeout(cleanup, 6e4);
36
- });
37
- }
38
- //#endregion
39
- export { printHtmlDocument };