@veltra/sheet 2.1.1 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/report/binding-badge.js +100 -0
- package/dist/components/report/designer/cell-coords.js +46 -0
- package/dist/components/report/designer/col-widths.js +29 -0
- package/dist/components/report/designer/conditional-rules/helpers.js +139 -0
- package/dist/components/report/designer/drop-highlight-overlay.js +76 -0
- package/dist/components/report/designer/float-panel.js +422 -0
- package/dist/components/report/designer/role.js +17 -0
- package/dist/components/report/designer/rule-preview.js +33 -0
- package/dist/components/report/designer/rule-row.js +253 -0
- package/dist/components/report/designer/rules-dialog.js +118 -0
- package/dist/components/report/designer/topology-overlay.js +122 -0
- package/dist/components/report/designer/topology.js +64 -0
- package/dist/components/report/designer/use-grid-overlay.js +75 -0
- package/dist/components/report/designer-hub.js +177 -0
- package/dist/components/report/field-panel-helpers.js +33 -0
- package/dist/components/report/field-panel.js +132 -0
- package/dist/components/report/filter-bar.js +74 -0
- package/dist/components/report/hub-connection-form.js +145 -0
- package/dist/components/report/hub-dataset-editor.js +394 -0
- package/dist/components/report/preview-grid-size.js +32 -0
- package/dist/components/report/report-designer.js +393 -0
- package/dist/components/report/report-viewer.js +124 -0
- package/dist/components/report/style.d.ts +17 -0
- package/dist/components/report/style.js +18 -0
- package/dist/components/report/style2.css +874 -0
- package/dist/components/report/use-report-designer.js +382 -0
- package/dist/components/report/use-report-viewer.js +55 -0
- package/dist/{vue → components/sheet}/formula-bar.js +1 -1
- package/dist/{vue → components/sheet}/formula-suggest-list.js +1 -1
- package/dist/{vue → components/sheet}/import-file.js +1 -1
- package/dist/{vue → components/sheet}/insert-count-menu-item.js +1 -1
- package/dist/{vue → components/sheet}/insert-image.js +1 -1
- package/dist/{vue → components/sheet}/popup-helpers.js +1 -1
- package/dist/{vue → components/sheet}/popups/border-popup.js +31 -3
- package/dist/{vue → components/sheet}/popups/border-preset-glyph.js +1 -1
- package/dist/{vue → components/sheet}/popups/export-popup.js +2 -2
- package/dist/{vue → components/sheet}/popups/fill-color-popup.js +3 -3
- package/dist/{vue → components/sheet}/popups/find-popup.js +1 -1
- package/dist/{vue → components/sheet}/popups/font-color-popup.js +3 -3
- package/dist/{vue → components/sheet}/popups/font-size-popup.js +3 -3
- package/dist/{vue → components/sheet}/popups/import.worker.d.ts +1 -1
- package/dist/{vue → components/sheet}/popups/import.worker.js +1 -1
- package/dist/{vue → components/sheet}/popups/insert-image-popup.js +1 -1
- package/dist/{vue → components/sheet}/sheet-context-menu.js +7 -4
- package/dist/{vue → components/sheet}/sheet-tabs.js +1 -1
- package/dist/{vue → components/sheet}/sheet-toolbar.js +1 -1
- package/dist/{vue → components/sheet}/sheet.js +16 -1
- package/dist/{vue → components/sheet}/use-find-replace.js +1 -1
- package/dist/{vue → components/sheet}/use-formula-ref-select.js +1 -1
- package/dist/{vue → components/sheet}/use-sheet-grid.js +22 -4
- package/dist/{vue → components/sheet}/use-sheet-state.js +6 -5
- package/dist/{vue → components/sheet}/use-sheet-tabs-bar.js +1 -1
- package/dist/{vue → components/sheet}/use-tool-groups.js +2 -2
- package/dist/{vue → components/sheet}/use-tool-popup.js +2 -2
- package/dist/{vue → components/sheet}/use-toolbar-scroll.js +1 -1
- package/dist/index.d.ts +17 -3
- package/dist/index.js +13 -3
- package/dist/report/binding.d.ts +83 -0
- package/dist/report/binding.js +332 -0
- package/dist/report/connector.d.ts +66 -0
- package/dist/report/connector.js +159 -0
- package/dist/report/export-xlsx.d.ts +17 -0
- package/dist/report/export-xlsx.js +92 -0
- package/dist/report/filter-bar.d.ts +10 -0
- package/dist/report/filter-bar.js +31 -0
- package/dist/report/index.d.ts +12 -0
- package/dist/report/params.d.ts +13 -0
- package/dist/report/params.js +61 -0
- package/dist/report/render/aggregate.js +169 -0
- package/dist/report/render/builder.d.ts +12 -0
- package/dist/report/render/builder.js +139 -0
- package/dist/report/render/coordinate.d.ts +25 -0
- package/dist/report/render/coordinate.js +733 -0
- package/dist/report/render/index.d.ts +14 -0
- package/dist/report/render/index.js +21 -0
- package/dist/report/render/style-resolver.js +50 -0
- package/dist/report/render/template-index.d.ts +24 -0
- package/dist/report/render/template-index.js +137 -0
- package/dist/report/rules/evaluate.d.ts +25 -0
- package/dist/report/rules/evaluate.js +82 -0
- package/dist/report/rules/index.d.ts +2 -0
- package/dist/report/template.d.ts +63 -0
- package/dist/report/template.js +83 -0
- package/dist/report/types.d.ts +85 -0
- package/dist/tools/apply-style.js +29 -0
- package/dist/tools/builtin.js +17 -17
- package/dist/tools/context.d.ts +39 -6
- package/dist/tools/context.js +38 -1
- package/dist/types/index.d.ts +3 -2
- package/dist/types/report-designer.d.ts +38 -0
- package/dist/types/report-viewer.d.ts +38 -0
- package/dist/types/sheet.d.ts +21 -1
- package/package.json +6 -8
- package/src/components/report/__test__/conditional-rules-helpers.test.ts +88 -0
- package/src/components/report/__test__/field-panel-helpers.test.ts +65 -0
- package/src/components/report/__test__/float-panel-position.test.ts +45 -0
- package/src/components/report/__test__/preview-grid-size.test.ts +63 -0
- package/src/components/report/__test__/report-designer.test.ts +464 -0
- package/src/components/report/__test__/report-viewer.test.ts +357 -0
- package/src/components/report/__test__/topology.test.ts +143 -0
- package/src/components/report/__test__/use-report-designer.test.ts +697 -0
- package/src/components/report/binding-badge.ts +92 -0
- package/src/components/report/designer/cell-coords.ts +94 -0
- package/src/components/report/designer/col-widths.ts +56 -0
- package/src/components/report/designer/conditional-rules/helpers.ts +189 -0
- package/src/components/report/designer/drop-highlight-overlay.vue +74 -0
- package/src/components/report/designer/float-panel.vue +431 -0
- package/src/components/report/designer/role.ts +32 -0
- package/src/components/report/designer/rule-preview.vue +40 -0
- package/src/components/report/designer/rule-row.vue +252 -0
- package/src/components/report/designer/rules-dialog.vue +110 -0
- package/src/components/report/designer/topology-overlay.vue +127 -0
- package/src/components/report/designer/topology.ts +124 -0
- package/src/components/report/designer/use-grid-overlay.ts +113 -0
- package/src/components/report/designer-hub.vue +198 -0
- package/src/components/report/field-panel-helpers.ts +44 -0
- package/src/components/report/field-panel.vue +136 -0
- package/src/components/report/filter-bar.vue +77 -0
- package/src/components/report/hub-connection-form.vue +124 -0
- package/src/components/report/hub-dataset-editor.vue +369 -0
- package/src/components/report/index.ts +2 -0
- package/src/components/report/preview-grid-size.ts +33 -0
- package/src/components/report/report-designer.vue +420 -0
- package/src/components/report/report-viewer.vue +136 -0
- package/src/components/report/style-designer.scss +587 -0
- package/src/components/report/style-hub.scss +292 -0
- package/src/components/report/style-viewer.scss +104 -0
- package/src/components/report/style.scss +3 -0
- package/src/components/report/style.ts +20 -0
- package/src/components/report/use-report-designer.ts +596 -0
- package/src/components/report/use-report-viewer.ts +88 -0
- package/src/{vue → components/sheet}/__test__/formula-bar.test.ts +37 -18
- package/src/{vue → components/sheet}/__test__/insert-image-popup.test.ts +1 -1
- package/src/{vue → components/sheet}/__test__/insert-image.test.ts +1 -1
- package/src/{vue → components/sheet}/__test__/sheet-component.test.ts +77 -3
- package/src/{vue → components/sheet}/__test__/sheet-context-menu.test.ts +4 -3
- package/src/{vue → components/sheet}/formula-bar.vue +1 -1
- package/src/{vue → components/sheet}/insert-image.ts +1 -1
- package/src/{vue → components/sheet}/popup-helpers.ts +1 -1
- package/src/{vue → components/sheet}/popups/border-popup.vue +32 -4
- package/src/{vue → components/sheet}/popups/export-popup.vue +2 -2
- package/src/{vue → components/sheet}/popups/fill-color-popup.vue +3 -3
- package/src/{vue → components/sheet}/popups/find-popup.vue +1 -1
- package/src/{vue → components/sheet}/popups/font-color-popup.vue +3 -3
- package/src/{vue → components/sheet}/popups/font-size-popup.vue +3 -3
- package/src/{vue → components/sheet}/popups/insert-image-popup.vue +1 -1
- package/src/{vue → components/sheet}/sheet-context-menu.ts +10 -4
- package/src/{vue → components/sheet}/sheet-toolbar.vue +2 -2
- package/src/{vue → components/sheet}/sheet.vue +6 -3
- package/src/{vue → components/sheet}/use-find-replace.ts +1 -1
- package/src/{vue → components/sheet}/use-sheet-grid.ts +23 -5
- package/src/{vue → components/sheet}/use-sheet-state.ts +11 -6
- package/src/{vue → components/sheet}/use-tool-groups.ts +2 -2
- package/src/{vue → components/sheet}/use-tool-popup.ts +2 -2
- package/src/index.ts +24 -188
- package/src/report/__test__/binding.test.ts +320 -0
- package/src/report/__test__/connector.test.ts +239 -0
- package/src/report/__test__/export-xlsx.test.ts +118 -0
- package/src/report/__test__/filter-bar.test.ts +58 -0
- package/src/report/__test__/params.test.ts +156 -0
- package/src/report/__test__/render.test.ts +830 -0
- package/src/report/__test__/rules.test.ts +131 -0
- package/src/report/__test__/template.test.ts +366 -0
- package/src/report/binding.ts +474 -0
- package/src/report/connector.ts +206 -0
- package/src/report/export-xlsx.ts +113 -0
- package/src/report/filter-bar.ts +36 -0
- package/src/report/index.ts +13 -0
- package/src/report/params.ts +96 -0
- package/src/report/render/__test__/aggregate.test.ts +16 -0
- package/src/report/render/__test__/coordinate.test.ts +405 -0
- package/src/report/render/aggregate.ts +261 -0
- package/src/report/render/builder.ts +211 -0
- package/src/report/render/coordinate.ts +1239 -0
- package/src/report/render/index.ts +30 -0
- package/src/report/render/style-resolver.ts +68 -0
- package/src/report/render/template-index.ts +200 -0
- package/src/report/rules/evaluate.ts +113 -0
- package/src/report/rules/index.ts +7 -0
- package/src/report/template.ts +145 -0
- package/src/report/types.ts +96 -0
- package/src/tools/__test__/apply-style.test.ts +129 -0
- package/src/tools/apply-style.ts +41 -0
- package/src/tools/builtin.ts +20 -20
- package/src/tools/context.ts +67 -4
- package/src/tools/index.ts +1 -0
- package/src/types/index.ts +2 -6
- package/src/types/report-designer.ts +38 -0
- package/src/types/report-viewer.ts +37 -0
- package/src/types/sheet.ts +26 -1
- /package/dist/{vue → components/sheet}/style.d.ts +0 -0
- /package/dist/{vue → components/sheet}/style.js +0 -0
- /package/dist/{vue → components/sheet}/style2.css +0 -0
- /package/dist/{vue → components/sheet}/use-formula-suggest.js +0 -0
- /package/src/{vue → components/sheet}/__test__/import-file.test.ts +0 -0
- /package/src/{vue → components/sheet}/__test__/insert-count-menu-item.test.ts +0 -0
- /package/src/{vue → components/sheet}/__test__/use-formula-ref-select.test.ts +0 -0
- /package/src/{vue → components/sheet}/__test__/use-formula-suggest.test.ts +0 -0
- /package/src/{vue → components/sheet}/formula-suggest-list.vue +0 -0
- /package/src/{vue → components/sheet}/import-file.ts +0 -0
- /package/src/{vue → components/sheet}/index.ts +0 -0
- /package/src/{vue → components/sheet}/insert-count-menu-item.vue +0 -0
- /package/src/{vue → components/sheet}/parsing.ts +0 -0
- /package/src/{vue → components/sheet}/popups/border-preset-glyph.vue +0 -0
- /package/src/{vue → components/sheet}/popups/import.worker.ts +0 -0
- /package/src/{vue → components/sheet}/sheet-tabs.vue +0 -0
- /package/src/{vue → components/sheet}/style.scss +0 -0
- /package/src/{vue → components/sheet}/style.ts +0 -0
- /package/src/{vue → components/sheet}/use-formula-ref-select.ts +0 -0
- /package/src/{vue → components/sheet}/use-formula-suggest.ts +0 -0
- /package/src/{vue → components/sheet}/use-sheet-tabs-bar.ts +0 -0
- /package/src/{vue → components/sheet}/use-toolbar-scroll.ts +0 -0
|
@@ -0,0 +1,394 @@
|
|
|
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
|
+
function onSqlChange(value) {
|
|
70
|
+
sqlDraft.value = value;
|
|
71
|
+
if (sqlTimer) clearTimeout(sqlTimer);
|
|
72
|
+
sqlTimer = setTimeout(() => {
|
|
73
|
+
props.hub.updateDataset(props.datasetId, { sql: value });
|
|
74
|
+
runDescribe();
|
|
75
|
+
}, 280);
|
|
76
|
+
}
|
|
77
|
+
onBeforeUnmount(() => {
|
|
78
|
+
if (sqlTimer) clearTimeout(sqlTimer);
|
|
79
|
+
});
|
|
80
|
+
async function runDescribe() {
|
|
81
|
+
const seq = ++describeSeq;
|
|
82
|
+
if (!sqlDraft.value.trim()) {
|
|
83
|
+
describeError.value = "";
|
|
84
|
+
props.hub.updateDataset(props.datasetId, { fields: void 0 });
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
describing.value = true;
|
|
88
|
+
const result = await props.hub.describeDataset(props.datasetId);
|
|
89
|
+
if (seq !== describeSeq) return;
|
|
90
|
+
describing.value = false;
|
|
91
|
+
describeError.value = result.ok ? "" : result.error.message;
|
|
92
|
+
}
|
|
93
|
+
const paramRows = computed(() => {
|
|
94
|
+
const current = dataset.value;
|
|
95
|
+
if (!current || !current.sql.trim()) return [];
|
|
96
|
+
return buildParamDefs(current.sql, current.paramOverrides);
|
|
97
|
+
});
|
|
98
|
+
const schemaRows = computed(() => {
|
|
99
|
+
const current = dataset.value;
|
|
100
|
+
if (!current) return [];
|
|
101
|
+
return (current.fields ?? []).map((field) => ({
|
|
102
|
+
...field,
|
|
103
|
+
label: current.fieldOverrides?.[field.name]?.label ?? field.label
|
|
104
|
+
}));
|
|
105
|
+
});
|
|
106
|
+
async function runPreview() {
|
|
107
|
+
previewing.value = true;
|
|
108
|
+
previewError.value = "";
|
|
109
|
+
const result = await props.hub.previewDataset(props.datasetId);
|
|
110
|
+
previewing.value = false;
|
|
111
|
+
if (result.ok) {
|
|
112
|
+
previewRows.value = result.data.rows;
|
|
113
|
+
previewFields.value = result.data.fields;
|
|
114
|
+
} else {
|
|
115
|
+
previewRows.value = [];
|
|
116
|
+
previewError.value = result.error.message;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
watch(detailTab, (tab) => {
|
|
120
|
+
if (tab === "preview") runPreview();
|
|
121
|
+
});
|
|
122
|
+
const paramColumns = defineTableColumns([
|
|
123
|
+
{
|
|
124
|
+
key: "id",
|
|
125
|
+
name: "参数名",
|
|
126
|
+
minWidth: 100
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
key: "label",
|
|
130
|
+
name: "显示名",
|
|
131
|
+
minWidth: 120
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
key: "type",
|
|
135
|
+
name: "类型",
|
|
136
|
+
width: 120
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
key: "defaultValue",
|
|
140
|
+
name: "默认值",
|
|
141
|
+
minWidth: 140
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
key: "options",
|
|
145
|
+
name: "选项(select)",
|
|
146
|
+
minWidth: 160
|
|
147
|
+
}
|
|
148
|
+
]);
|
|
149
|
+
const schemaColumns = defineTableColumns([
|
|
150
|
+
{
|
|
151
|
+
key: "name",
|
|
152
|
+
name: "字段名(name)",
|
|
153
|
+
minWidth: 140
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
key: "label",
|
|
157
|
+
name: "中文描述(label)",
|
|
158
|
+
minWidth: 160
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
key: "type",
|
|
162
|
+
name: "类型",
|
|
163
|
+
width: 88
|
|
164
|
+
}
|
|
165
|
+
]);
|
|
166
|
+
const previewColumns = computed(() => defineTableColumns(previewFields.value.map((field) => ({
|
|
167
|
+
key: field.name,
|
|
168
|
+
name: field.label,
|
|
169
|
+
minWidth: field.type === "number" ? 88 : 112
|
|
170
|
+
}))));
|
|
171
|
+
function fieldTypeColor(type) {
|
|
172
|
+
if (type === "number") return "success";
|
|
173
|
+
if (type === "date") return "warning";
|
|
174
|
+
return "info";
|
|
175
|
+
}
|
|
176
|
+
function formatDefaultValue(value) {
|
|
177
|
+
if (Array.isArray(value)) return value.join(", ");
|
|
178
|
+
return String(value ?? "");
|
|
179
|
+
}
|
|
180
|
+
function formatOptions(options) {
|
|
181
|
+
if (!options?.length) return "";
|
|
182
|
+
return options.map((item) => `${item.label}|${item.value}`).join(",");
|
|
183
|
+
}
|
|
184
|
+
function parseOptions(raw) {
|
|
185
|
+
return raw.split(",").map((part) => part.trim()).filter(Boolean).map((part) => {
|
|
186
|
+
const [label, value] = part.split("|");
|
|
187
|
+
const text = (label ?? "").trim();
|
|
188
|
+
return {
|
|
189
|
+
label: text,
|
|
190
|
+
value: (value ?? text).trim()
|
|
191
|
+
};
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
function patchDataset(patch) {
|
|
195
|
+
props.hub.updateDataset(props.datasetId, patch);
|
|
196
|
+
}
|
|
197
|
+
function patchParam(paramId, patch) {
|
|
198
|
+
const current = dataset.value;
|
|
199
|
+
if (!current) return;
|
|
200
|
+
patchDataset({ paramOverrides: {
|
|
201
|
+
...current.paramOverrides,
|
|
202
|
+
[paramId]: {
|
|
203
|
+
...current.paramOverrides?.[paramId],
|
|
204
|
+
...patch
|
|
205
|
+
}
|
|
206
|
+
} });
|
|
207
|
+
}
|
|
208
|
+
function patchFieldLabel(fieldName, label) {
|
|
209
|
+
const current = dataset.value;
|
|
210
|
+
if (!current) return;
|
|
211
|
+
patchDataset({ fieldOverrides: {
|
|
212
|
+
...current.fieldOverrides,
|
|
213
|
+
[fieldName]: {
|
|
214
|
+
...current.fieldOverrides?.[fieldName],
|
|
215
|
+
label
|
|
216
|
+
}
|
|
217
|
+
} });
|
|
218
|
+
}
|
|
219
|
+
return (_ctx, _cache) => {
|
|
220
|
+
return dataset.value ? (openBlock(), createElementBlock("section", {
|
|
221
|
+
key: 0,
|
|
222
|
+
class: normalizeClass(unref(cls).b)
|
|
223
|
+
}, [
|
|
224
|
+
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), {
|
|
225
|
+
"model-value": dataset.value.label,
|
|
226
|
+
size: "small",
|
|
227
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = (v) => patchDataset({ label: String(v ?? "") }))
|
|
228
|
+
}, null, 8, ["model-value"])], 2), createVNode(unref(UPopConfirm), {
|
|
229
|
+
title: "确定删除该数据集?",
|
|
230
|
+
onConfirm: _cache[1] || (_cache[1] = ($event) => emit("remove"))
|
|
231
|
+
}, {
|
|
232
|
+
reference: withCtx(() => [createVNode(unref(UButton), {
|
|
233
|
+
size: "small",
|
|
234
|
+
type: "danger",
|
|
235
|
+
plain: ""
|
|
236
|
+
}, {
|
|
237
|
+
default: withCtx(() => [..._cache[4] || (_cache[4] = [createTextVNode("删除数据集", -1)])]),
|
|
238
|
+
_: 1
|
|
239
|
+
})]),
|
|
240
|
+
_: 1
|
|
241
|
+
})], 2),
|
|
242
|
+
createElementVNode("div", { class: normalizeClass(unref(cls).e("sql")) }, [
|
|
243
|
+
createElementVNode("p", { class: normalizeClass(unref(cls).e("section-title")) }, "SQL 查询", 2),
|
|
244
|
+
createVNode(unref(UCodeEditor), {
|
|
245
|
+
modelValue: sqlDraft.value,
|
|
246
|
+
"onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => sqlDraft.value = $event),
|
|
247
|
+
lang: "sql",
|
|
248
|
+
langs: ["sql"],
|
|
249
|
+
"default-lines": 6,
|
|
250
|
+
onChange: onSqlChange
|
|
251
|
+
}, null, 8, ["modelValue"]),
|
|
252
|
+
describeError.value ? (openBlock(), createElementBlock("p", {
|
|
253
|
+
key: 0,
|
|
254
|
+
class: normalizeClass(unref(cls).e("sql-error")),
|
|
255
|
+
role: "alert"
|
|
256
|
+
}, toDisplayString(describeError.value), 3)) : createCommentVNode("v-if", true)
|
|
257
|
+
], 2),
|
|
258
|
+
paramRows.value.length ? (openBlock(), createElementBlock("div", {
|
|
259
|
+
key: 0,
|
|
260
|
+
class: normalizeClass(unref(cls).e("params"))
|
|
261
|
+
}, [createElementVNode("p", { class: normalizeClass(unref(cls).e("section-title")) }, "查询参数(从 SQL 自动提取)", 2), createVNode(unref(UTable), {
|
|
262
|
+
class: normalizeClass(unref(cls).e("param-table")),
|
|
263
|
+
data: paramRows.value,
|
|
264
|
+
columns: unref(paramColumns),
|
|
265
|
+
border: "",
|
|
266
|
+
"text-ellipsis": ""
|
|
267
|
+
}, {
|
|
268
|
+
"column:label": withCtx(({ rowData }) => [createVNode(unref(UInput), {
|
|
269
|
+
"model-value": rowData.label,
|
|
270
|
+
size: "small",
|
|
271
|
+
"onUpdate:modelValue": (v) => patchParam(rowData.id, { label: String(v ?? "") })
|
|
272
|
+
}, null, 8, ["model-value", "onUpdate:modelValue"])]),
|
|
273
|
+
"column:type": withCtx(({ rowData }) => [createVNode(unref(USelect), {
|
|
274
|
+
"model-value": rowData.type,
|
|
275
|
+
size: "small",
|
|
276
|
+
options: paramTypeOptions,
|
|
277
|
+
"onUpdate:modelValue": (v) => patchParam(rowData.id, { type: v })
|
|
278
|
+
}, null, 8, ["model-value", "onUpdate:modelValue"])]),
|
|
279
|
+
"column:defaultValue": withCtx(({ rowData }) => [rowData.type === "number" ? (openBlock(), createBlock(unref(UInput), {
|
|
280
|
+
key: 0,
|
|
281
|
+
"model-value": String(rowData.defaultValue ?? ""),
|
|
282
|
+
size: "small",
|
|
283
|
+
type: "number",
|
|
284
|
+
"onUpdate:modelValue": (v) => patchParam(rowData.id, { defaultValue: Number(v) })
|
|
285
|
+
}, null, 8, ["model-value", "onUpdate:modelValue"])) : rowData.type === "date" ? (openBlock(), createBlock(unref(UInput), {
|
|
286
|
+
key: 1,
|
|
287
|
+
"model-value": String(rowData.defaultValue ?? ""),
|
|
288
|
+
size: "small",
|
|
289
|
+
type: "date",
|
|
290
|
+
"onUpdate:modelValue": (v) => patchParam(rowData.id, { defaultValue: v })
|
|
291
|
+
}, null, 8, ["model-value", "onUpdate:modelValue"])) : rowData.type === "select" ? (openBlock(), createBlock(unref(USelect), {
|
|
292
|
+
key: 2,
|
|
293
|
+
"model-value": String(rowData.defaultValue ?? ""),
|
|
294
|
+
size: "small",
|
|
295
|
+
options: rowData.options ?? [],
|
|
296
|
+
"onUpdate:modelValue": (v) => patchParam(rowData.id, { defaultValue: v })
|
|
297
|
+
}, null, 8, [
|
|
298
|
+
"model-value",
|
|
299
|
+
"options",
|
|
300
|
+
"onUpdate:modelValue"
|
|
301
|
+
])) : (openBlock(), createBlock(unref(UInput), {
|
|
302
|
+
key: 3,
|
|
303
|
+
"model-value": formatDefaultValue(rowData.defaultValue),
|
|
304
|
+
size: "small",
|
|
305
|
+
"onUpdate:modelValue": (v) => patchParam(rowData.id, { defaultValue: v })
|
|
306
|
+
}, null, 8, ["model-value", "onUpdate:modelValue"]))]),
|
|
307
|
+
"column:options": withCtx(({ rowData }) => [rowData.type === "select" ? (openBlock(), createBlock(unref(UInput), {
|
|
308
|
+
key: 0,
|
|
309
|
+
"model-value": formatOptions(rowData.options),
|
|
310
|
+
size: "small",
|
|
311
|
+
placeholder: "华东|华东,华南|华南",
|
|
312
|
+
"onUpdate:modelValue": (v) => patchParam(rowData.id, { options: parseOptions(String(v ?? "")) })
|
|
313
|
+
}, null, 8, ["model-value", "onUpdate:modelValue"])) : (openBlock(), createElementBlock("span", {
|
|
314
|
+
key: 1,
|
|
315
|
+
class: normalizeClass(unref(cls).e("muted"))
|
|
316
|
+
}, "—", 2))]),
|
|
317
|
+
_: 1
|
|
318
|
+
}, 8, [
|
|
319
|
+
"class",
|
|
320
|
+
"data",
|
|
321
|
+
"columns"
|
|
322
|
+
])], 2)) : createCommentVNode("v-if", true),
|
|
323
|
+
createVNode(unref(UTabs), {
|
|
324
|
+
modelValue: detailTab.value,
|
|
325
|
+
"onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => detailTab.value = $event),
|
|
326
|
+
items: detailTabItems,
|
|
327
|
+
class: normalizeClass(unref(cls).e("tabs"))
|
|
328
|
+
}, {
|
|
329
|
+
schema: withCtx(() => [describing.value ? (openBlock(), createElementBlock("p", {
|
|
330
|
+
key: 0,
|
|
331
|
+
class: normalizeClass(unref(cls).e("muted"))
|
|
332
|
+
}, "正在解析字段…", 2)) : (openBlock(), createBlock(unref(UTable), {
|
|
333
|
+
key: 1,
|
|
334
|
+
class: normalizeClass(unref(cls).e("schema-table")),
|
|
335
|
+
data: schemaRows.value,
|
|
336
|
+
columns: unref(schemaColumns),
|
|
337
|
+
border: "",
|
|
338
|
+
"text-ellipsis": ""
|
|
339
|
+
}, {
|
|
340
|
+
"column:label": withCtx(({ rowData }) => [createVNode(unref(UInput), {
|
|
341
|
+
"model-value": rowData.label,
|
|
342
|
+
size: "small",
|
|
343
|
+
placeholder: "中文显示名",
|
|
344
|
+
"onUpdate:modelValue": (v) => patchFieldLabel(rowData.name, String(v ?? ""))
|
|
345
|
+
}, null, 8, ["model-value", "onUpdate:modelValue"])]),
|
|
346
|
+
"column:type": withCtx(({ rowData }) => [createVNode(unref(UTag), {
|
|
347
|
+
size: "small",
|
|
348
|
+
type: fieldTypeColor(rowData.type)
|
|
349
|
+
}, {
|
|
350
|
+
default: withCtx(() => [createTextVNode(toDisplayString(rowData.type), 1)]),
|
|
351
|
+
_: 2
|
|
352
|
+
}, 1032, ["type"])]),
|
|
353
|
+
_: 1
|
|
354
|
+
}, 8, [
|
|
355
|
+
"class",
|
|
356
|
+
"data",
|
|
357
|
+
"columns"
|
|
358
|
+
]))]),
|
|
359
|
+
preview: withCtx(() => [
|
|
360
|
+
createElementVNode("div", { class: normalizeClass(unref(cls).e("preview-actions")) }, [createVNode(unref(UButton), {
|
|
361
|
+
size: "small",
|
|
362
|
+
plain: "",
|
|
363
|
+
loading: previewing.value,
|
|
364
|
+
onClick: runPreview
|
|
365
|
+
}, {
|
|
366
|
+
default: withCtx(() => [..._cache[5] || (_cache[5] = [createTextVNode(" 刷新预览(按参数默认值取数) ", -1)])]),
|
|
367
|
+
_: 1
|
|
368
|
+
}, 8, ["loading"])], 2),
|
|
369
|
+
createVNode(unref(UTable), {
|
|
370
|
+
class: normalizeClass(unref(cls).e("preview-table")),
|
|
371
|
+
data: previewRows.value,
|
|
372
|
+
columns: previewColumns.value,
|
|
373
|
+
"show-index": "",
|
|
374
|
+
border: "",
|
|
375
|
+
"text-ellipsis": ""
|
|
376
|
+
}, null, 8, [
|
|
377
|
+
"class",
|
|
378
|
+
"data",
|
|
379
|
+
"columns"
|
|
380
|
+
]),
|
|
381
|
+
previewError.value ? (openBlock(), createElementBlock("p", {
|
|
382
|
+
key: 0,
|
|
383
|
+
class: normalizeClass(unref(cls).e("preview-error")),
|
|
384
|
+
role: "alert"
|
|
385
|
+
}, toDisplayString(previewError.value), 3)) : createCommentVNode("v-if", true)
|
|
386
|
+
]),
|
|
387
|
+
_: 1
|
|
388
|
+
}, 8, ["modelValue", "class"])
|
|
389
|
+
], 2)) : createCommentVNode("v-if", true);
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
});
|
|
393
|
+
//#endregion
|
|
394
|
+
export { _sfc_main as default };
|
|
@@ -0,0 +1,32 @@
|
|
|
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 };
|