@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,382 @@
|
|
|
1
|
+
import { REPORT_META_NAMESPACE, applyReportPreset, createReportBinding, formatCellAddress, inferDropPreset, inferParentsForPreset, isColGroupBinding, isHorizontalExpandBinding, isRowGroupBinding, isVerticalExpandBinding, listColParentCandidates, listRowParentCandidates, prefersGroupParent, presetStillApplies } from "../../report/binding.js";
|
|
2
|
+
import { buildParamDefs } from "../../report/params.js";
|
|
3
|
+
import { assertCompatibleTemplateVersion, createReportTemplate, getTemplateDatasets, resolveParamDefaults } from "../../report/template.js";
|
|
4
|
+
import { createBindingBadgeRenderer, createBindingBadgeStyleResolver } from "./binding-badge.js";
|
|
5
|
+
import { computed, onScopeDispose, ref, watch } from "vue";
|
|
6
|
+
import { Workbook } from "@veltra/sheet-core";
|
|
7
|
+
//#region src/components/report/use-report-designer.ts
|
|
8
|
+
/**
|
|
9
|
+
* UReportDesigner 的 headless 编排:连接 / 数据集状态、绑定写 Cell Meta、
|
|
10
|
+
* 角色徽章渲染 hook、`getTemplate()` 模板吐出。不持有 DOM / 网格引用。
|
|
11
|
+
*/
|
|
12
|
+
function useReportDesigner(options) {
|
|
13
|
+
const { props, connections } = options;
|
|
14
|
+
/** 设计态工作簿:宿主可注入(USheet / UReportViewer 先例),缺省内部自建 */
|
|
15
|
+
const internalWorkbook = new Workbook();
|
|
16
|
+
const workbook = computed(() => props.workbook ?? internalWorkbook);
|
|
17
|
+
const datasets = ref([]);
|
|
18
|
+
/** meta 变更计数:boundKeys 等派生状态的响应式触发(绑定经命令系统写入后由模型发 meta-change) */
|
|
19
|
+
const metaTick = ref(0);
|
|
20
|
+
const parentPick = ref(null);
|
|
21
|
+
const offMeta = workbook.value.activeSheet.on("meta-change", () => {
|
|
22
|
+
metaTick.value++;
|
|
23
|
+
});
|
|
24
|
+
onScopeDispose(offMeta);
|
|
25
|
+
/** 稳定选区地址引用(值未变时不替换对象,避免触发下游 watcher) */
|
|
26
|
+
const activeCell = ref(null);
|
|
27
|
+
function syncActiveCell() {
|
|
28
|
+
const next = workbook.value.activeSheet.getSelection().activeCell ?? null;
|
|
29
|
+
const prev = activeCell.value;
|
|
30
|
+
if (!next) {
|
|
31
|
+
activeCell.value = null;
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
if (prev && prev.row === next.row && prev.col === next.col) return;
|
|
35
|
+
activeCell.value = {
|
|
36
|
+
row: next.row,
|
|
37
|
+
col: next.col
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
const offSelection = workbook.value.activeSheet.on("selection-change", syncActiveCell);
|
|
41
|
+
onScopeDispose(offSelection);
|
|
42
|
+
syncActiveCell();
|
|
43
|
+
const selectionLabel = computed(() => activeCell.value ? formatCellAddress(activeCell.value) : "—");
|
|
44
|
+
const catalog = computed(() => datasets.value.map((dataset) => ({
|
|
45
|
+
id: dataset.id,
|
|
46
|
+
label: dataset.label,
|
|
47
|
+
fields: (dataset.fields ?? []).map((field) => ({
|
|
48
|
+
...field,
|
|
49
|
+
label: dataset.fieldOverrides?.[field.name]?.label ?? field.label
|
|
50
|
+
}))
|
|
51
|
+
})));
|
|
52
|
+
/** 字段 label 的 O(1) 查找表(徽章 hook 性能契约) */
|
|
53
|
+
const fieldLabelMap = computed(() => {
|
|
54
|
+
const map = /* @__PURE__ */ new Map();
|
|
55
|
+
for (const dataset of catalog.value) for (const field of dataset.fields) map.set(`${dataset.id}:${field.name}`, field.label);
|
|
56
|
+
return map;
|
|
57
|
+
});
|
|
58
|
+
function resolveFieldLabel(datasetId, fieldName) {
|
|
59
|
+
return fieldLabelMap.value.get(`${datasetId}:${fieldName}`) ?? fieldName;
|
|
60
|
+
}
|
|
61
|
+
const boundKeys = computed(() => {
|
|
62
|
+
metaTick.value;
|
|
63
|
+
const keys = /* @__PURE__ */ new Set();
|
|
64
|
+
for (const [, namespace, payload] of workbook.value.activeSheet.entriesCellMeta()) {
|
|
65
|
+
if (namespace !== "report") continue;
|
|
66
|
+
const binding = payload;
|
|
67
|
+
keys.add(`${binding.dataset}:${binding.field}`);
|
|
68
|
+
}
|
|
69
|
+
return keys;
|
|
70
|
+
});
|
|
71
|
+
function getBindingAt(addr) {
|
|
72
|
+
return workbook.value.activeSheet.getCellMeta(addr, REPORT_META_NAMESPACE);
|
|
73
|
+
}
|
|
74
|
+
function bindField(datasetId, fieldName, addr) {
|
|
75
|
+
const dataset = catalog.value.find((item) => item.id === datasetId);
|
|
76
|
+
if (!dataset) return;
|
|
77
|
+
const field = dataset.fields.find((item) => item.name === fieldName);
|
|
78
|
+
const target = addr ?? workbook.value.activeSheet.getSelection().activeCell;
|
|
79
|
+
if (!target) return;
|
|
80
|
+
const preset = inferDropPreset(target, field?.type ?? "string", getBindingAt);
|
|
81
|
+
let binding = createReportBinding(dataset, fieldName);
|
|
82
|
+
binding = applyReportPreset(binding, preset);
|
|
83
|
+
const parents = inferParentsForPreset(target, preset, getBindingAt);
|
|
84
|
+
if (parents.rowParent) binding.rowParent = parents.rowParent;
|
|
85
|
+
if (parents.colParent) binding.colParent = parents.colParent;
|
|
86
|
+
workbook.value.activeSheet.setCellMeta(target, REPORT_META_NAMESPACE, binding);
|
|
87
|
+
}
|
|
88
|
+
const activeBinding = computed(() => {
|
|
89
|
+
metaTick.value;
|
|
90
|
+
const cell = activeCell.value;
|
|
91
|
+
if (!cell) return void 0;
|
|
92
|
+
return getBindingAt(cell);
|
|
93
|
+
});
|
|
94
|
+
const activeFieldType = computed(() => {
|
|
95
|
+
const binding = activeBinding.value;
|
|
96
|
+
if (!binding) return "number";
|
|
97
|
+
return (catalog.value.find((item) => item.id === binding.dataset)?.fields.find((item) => item.name === binding.field))?.type ?? "number";
|
|
98
|
+
});
|
|
99
|
+
const activeDatasetFields = computed(() => {
|
|
100
|
+
const binding = activeBinding.value;
|
|
101
|
+
if (!binding) return [];
|
|
102
|
+
return catalog.value.find((item) => item.id === binding.dataset)?.fields ?? [];
|
|
103
|
+
});
|
|
104
|
+
const resolvedRowParentLabel = computed(() => {
|
|
105
|
+
metaTick.value;
|
|
106
|
+
const binding = activeBinding.value;
|
|
107
|
+
if (!binding?.rowParent) return "—";
|
|
108
|
+
return formatCellAddress(binding.rowParent);
|
|
109
|
+
});
|
|
110
|
+
const resolvedColParentLabel = computed(() => {
|
|
111
|
+
metaTick.value;
|
|
112
|
+
const binding = activeBinding.value;
|
|
113
|
+
if (!binding?.colParent) return "—";
|
|
114
|
+
return formatCellAddress(binding.colParent);
|
|
115
|
+
});
|
|
116
|
+
const rowParentCandidates = computed(() => {
|
|
117
|
+
metaTick.value;
|
|
118
|
+
const binding = activeBinding.value;
|
|
119
|
+
if (!binding) return [];
|
|
120
|
+
return listRowParentCandidates(binding, bindingEntries.value, { preferGroup: prefersGroupParent(binding) });
|
|
121
|
+
});
|
|
122
|
+
const colParentCandidates = computed(() => {
|
|
123
|
+
metaTick.value;
|
|
124
|
+
const binding = activeBinding.value;
|
|
125
|
+
if (!binding) return [];
|
|
126
|
+
return listColParentCandidates(binding, bindingEntries.value, { preferGroup: prefersGroupParent(binding) });
|
|
127
|
+
});
|
|
128
|
+
const bindingEntries = computed(() => {
|
|
129
|
+
metaTick.value;
|
|
130
|
+
const entries = [];
|
|
131
|
+
for (const [addr, namespace, payload] of workbook.value.activeSheet.entriesCellMeta()) {
|
|
132
|
+
if (namespace !== "report") continue;
|
|
133
|
+
entries.push({
|
|
134
|
+
addr,
|
|
135
|
+
binding: payload
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
return entries;
|
|
139
|
+
});
|
|
140
|
+
function parentNeedsCorrection(addr) {
|
|
141
|
+
if (!addr) return true;
|
|
142
|
+
const parent = getBindingAt(addr);
|
|
143
|
+
return !parent || parent.aggregate === "list";
|
|
144
|
+
}
|
|
145
|
+
function patchActiveBinding(patch) {
|
|
146
|
+
const cell = activeCell.value;
|
|
147
|
+
const binding = activeBinding.value;
|
|
148
|
+
if (!cell || !binding) return;
|
|
149
|
+
const next = {
|
|
150
|
+
...binding,
|
|
151
|
+
...patch
|
|
152
|
+
};
|
|
153
|
+
if ("rowParent" in patch && patch.rowParent === void 0) delete next.rowParent;
|
|
154
|
+
if ("colParent" in patch && patch.colParent === void 0) delete next.colParent;
|
|
155
|
+
if (("aggregate" in patch || "expand" in patch) && !("preset" in patch) && !presetStillApplies(next)) delete next.preset;
|
|
156
|
+
if (patch.preset === "subtotal") {
|
|
157
|
+
const inferred = inferParentsForPreset(cell, "subtotal", getBindingAt);
|
|
158
|
+
if (parentNeedsCorrection(next.rowParent)) if (inferred.rowParent) next.rowParent = inferred.rowParent;
|
|
159
|
+
else delete next.rowParent;
|
|
160
|
+
if (parentNeedsCorrection(next.colParent)) if (inferred.colParent) next.colParent = inferred.colParent;
|
|
161
|
+
else delete next.colParent;
|
|
162
|
+
}
|
|
163
|
+
workbook.value.activeSheet.setCellMeta(cell, REPORT_META_NAMESPACE, next);
|
|
164
|
+
}
|
|
165
|
+
function startParentPick(mode) {
|
|
166
|
+
const cell = activeCell.value;
|
|
167
|
+
if (!cell || !activeBinding.value) return;
|
|
168
|
+
parentPick.value = {
|
|
169
|
+
mode,
|
|
170
|
+
source: {
|
|
171
|
+
row: cell.row,
|
|
172
|
+
col: cell.col
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
function cancelParentPick() {
|
|
177
|
+
parentPick.value = null;
|
|
178
|
+
}
|
|
179
|
+
function isValidParentTarget(mode, source, target) {
|
|
180
|
+
if (!target) return false;
|
|
181
|
+
if (target.dataset !== source.dataset) return false;
|
|
182
|
+
const groupOnly = prefersGroupParent(source);
|
|
183
|
+
if (mode === "row") return groupOnly ? isRowGroupBinding(target) : isVerticalExpandBinding(target);
|
|
184
|
+
return groupOnly ? isColGroupBinding(target) : isHorizontalExpandBinding(target);
|
|
185
|
+
}
|
|
186
|
+
function pickParentAt(target) {
|
|
187
|
+
const pick = parentPick.value;
|
|
188
|
+
if (!pick) return;
|
|
189
|
+
if (target.row === pick.source.row && target.col === pick.source.col) return;
|
|
190
|
+
const sourceBinding = getBindingAt(pick.source);
|
|
191
|
+
if (!sourceBinding) {
|
|
192
|
+
parentPick.value = null;
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
const targetBinding = getBindingAt(target);
|
|
196
|
+
if (!isValidParentTarget(pick.mode, sourceBinding, targetBinding)) {
|
|
197
|
+
workbook.value.activeSheet.selectCell(pick.source);
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
const patch = pick.mode === "row" ? { rowParent: { ...target } } : { colParent: { ...target } };
|
|
201
|
+
const next = {
|
|
202
|
+
...sourceBinding,
|
|
203
|
+
...patch
|
|
204
|
+
};
|
|
205
|
+
workbook.value.activeSheet.setCellMeta(pick.source, REPORT_META_NAMESPACE, next);
|
|
206
|
+
parentPick.value = null;
|
|
207
|
+
workbook.value.activeSheet.selectCell(pick.source);
|
|
208
|
+
}
|
|
209
|
+
function clearParent(mode) {
|
|
210
|
+
if (mode === "row") patchActiveBinding({ rowParent: void 0 });
|
|
211
|
+
else patchActiveBinding({ colParent: void 0 });
|
|
212
|
+
}
|
|
213
|
+
function removeActiveBinding() {
|
|
214
|
+
const cell = activeCell.value;
|
|
215
|
+
if (!cell) return;
|
|
216
|
+
workbook.value.activeSheet.clearCellMeta(cell, REPORT_META_NAMESPACE);
|
|
217
|
+
}
|
|
218
|
+
function addConnection(connection) {
|
|
219
|
+
connections.value = [...connections.value, connection];
|
|
220
|
+
}
|
|
221
|
+
function updateConnection(connection) {
|
|
222
|
+
connections.value = connections.value.map((item) => item.id === connection.id ? connection : item);
|
|
223
|
+
}
|
|
224
|
+
function removeConnection(connectionId) {
|
|
225
|
+
connections.value = connections.value.filter((item) => item.id !== connectionId);
|
|
226
|
+
datasets.value = datasets.value.filter((dataset) => dataset.connectionId !== connectionId);
|
|
227
|
+
}
|
|
228
|
+
let datasetSeq = 0;
|
|
229
|
+
function addDataset(connectionId) {
|
|
230
|
+
const dataset = {
|
|
231
|
+
id: `dataset-${Date.now()}-${datasetSeq++}`,
|
|
232
|
+
label: "新数据集",
|
|
233
|
+
connectionId,
|
|
234
|
+
sql: ""
|
|
235
|
+
};
|
|
236
|
+
datasets.value = [...datasets.value, dataset];
|
|
237
|
+
return dataset;
|
|
238
|
+
}
|
|
239
|
+
function updateDataset(datasetId, patch) {
|
|
240
|
+
datasets.value = datasets.value.map((item) => item.id === datasetId ? {
|
|
241
|
+
...item,
|
|
242
|
+
...patch
|
|
243
|
+
} : item);
|
|
244
|
+
}
|
|
245
|
+
function removeDataset(datasetId) {
|
|
246
|
+
datasets.value = datasets.value.filter((item) => item.id !== datasetId);
|
|
247
|
+
}
|
|
248
|
+
function resolveDatasetConnection(dataset) {
|
|
249
|
+
return connections.value.find((item) => item.id === dataset.connectionId);
|
|
250
|
+
}
|
|
251
|
+
function datasetNotFound() {
|
|
252
|
+
return {
|
|
253
|
+
ok: false,
|
|
254
|
+
error: {
|
|
255
|
+
code: "DATASET_NOT_FOUND",
|
|
256
|
+
message: "数据集不存在"
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
function connectionNotFound() {
|
|
261
|
+
return {
|
|
262
|
+
ok: false,
|
|
263
|
+
error: {
|
|
264
|
+
code: "CONNECTION_NOT_FOUND",
|
|
265
|
+
message: "数据集所属连接不存在"
|
|
266
|
+
}
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
function testConnection(connection) {
|
|
270
|
+
return props.connector.test(connection);
|
|
271
|
+
}
|
|
272
|
+
async function describeDataset(datasetId) {
|
|
273
|
+
const dataset = datasets.value.find((item) => item.id === datasetId);
|
|
274
|
+
if (!dataset) return datasetNotFound();
|
|
275
|
+
const connection = resolveDatasetConnection(dataset);
|
|
276
|
+
if (!connection) return connectionNotFound();
|
|
277
|
+
const sql = dataset.sql;
|
|
278
|
+
const result = await props.connector.describe(connection, sql);
|
|
279
|
+
if (result.ok) {
|
|
280
|
+
const current = datasets.value.find((item) => item.id === datasetId);
|
|
281
|
+
if (current && current.sql === sql) updateDataset(datasetId, { fields: result.data });
|
|
282
|
+
}
|
|
283
|
+
return result;
|
|
284
|
+
}
|
|
285
|
+
async function previewDataset(datasetId) {
|
|
286
|
+
const dataset = datasets.value.find((item) => item.id === datasetId);
|
|
287
|
+
if (!dataset) return datasetNotFound();
|
|
288
|
+
const connection = resolveDatasetConnection(dataset);
|
|
289
|
+
if (!connection) return connectionNotFound();
|
|
290
|
+
const values = resolveParamDefaults(buildParamDefs(dataset.sql, dataset.paramOverrides));
|
|
291
|
+
return props.connector.query(connection, dataset.sql, values);
|
|
292
|
+
}
|
|
293
|
+
const resolveCellStyle = createBindingBadgeStyleResolver(getBindingAt);
|
|
294
|
+
const resolveCellRenderer = createBindingBadgeRenderer(getBindingAt, resolveFieldLabel);
|
|
295
|
+
function getTemplate() {
|
|
296
|
+
const resolved = datasets.value.flatMap((dataset) => {
|
|
297
|
+
const connection = resolveDatasetConnection(dataset);
|
|
298
|
+
if (!connection) return [];
|
|
299
|
+
return [{
|
|
300
|
+
id: dataset.id,
|
|
301
|
+
label: dataset.label,
|
|
302
|
+
connection: { ...connection },
|
|
303
|
+
sql: dataset.sql,
|
|
304
|
+
...dataset.paramOverrides ? { paramOverrides: dataset.paramOverrides } : {},
|
|
305
|
+
...dataset.fieldOverrides ? { fieldOverrides: dataset.fieldOverrides } : {}
|
|
306
|
+
}];
|
|
307
|
+
});
|
|
308
|
+
return createReportTemplate(workbook.value.activeSheet.snapshot(), resolved);
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* 载入既有 Report Template 继续设计(`template` prop):
|
|
312
|
+
* 快照恢复网格绑定(restore + restoreContent 与查看器同路径);
|
|
313
|
+
* 内嵌数据集定义还原为设计态(connectionId 引用),内嵌连接按 id 合并进
|
|
314
|
+
* v-model 连接列表(仅缺省追加,宿主列表是单一事实源);
|
|
315
|
+
* describe 恢复字段缓存(字段面板数据源),业务错误忽略(字段留空,可在数据中枢重试)。
|
|
316
|
+
*/
|
|
317
|
+
function loadTemplate(template) {
|
|
318
|
+
assertCompatibleTemplateVersion(template);
|
|
319
|
+
const sheet = workbook.value.activeSheet;
|
|
320
|
+
sheet.restore(template);
|
|
321
|
+
sheet.restoreContent(template);
|
|
322
|
+
sheet.history.clear();
|
|
323
|
+
syncActiveCell();
|
|
324
|
+
const defs = getTemplateDatasets(template);
|
|
325
|
+
datasets.value = defs.map((def) => ({
|
|
326
|
+
id: def.id,
|
|
327
|
+
label: def.label,
|
|
328
|
+
connectionId: def.connection.id,
|
|
329
|
+
sql: def.sql,
|
|
330
|
+
...def.paramOverrides ? { paramOverrides: def.paramOverrides } : {},
|
|
331
|
+
...def.fieldOverrides ? { fieldOverrides: def.fieldOverrides } : {}
|
|
332
|
+
}));
|
|
333
|
+
const missing = defs.map((def) => def.connection).filter((connection) => !connections.value.some((item) => item.id === connection.id));
|
|
334
|
+
if (missing.length > 0) connections.value = [...connections.value, ...missing.map((connection) => ({ ...connection }))];
|
|
335
|
+
for (const dataset of datasets.value) if (dataset.sql.trim()) describeDataset(dataset.id);
|
|
336
|
+
}
|
|
337
|
+
watch(() => props.template, (template) => {
|
|
338
|
+
if (template) loadTemplate(template);
|
|
339
|
+
}, { immediate: true });
|
|
340
|
+
return {
|
|
341
|
+
workbook,
|
|
342
|
+
connections,
|
|
343
|
+
datasets,
|
|
344
|
+
catalog,
|
|
345
|
+
boundKeys,
|
|
346
|
+
activeCell,
|
|
347
|
+
selectionLabel,
|
|
348
|
+
activeBinding,
|
|
349
|
+
activeFieldType,
|
|
350
|
+
activeDatasetFields,
|
|
351
|
+
resolvedRowParentLabel,
|
|
352
|
+
resolvedColParentLabel,
|
|
353
|
+
parentPick,
|
|
354
|
+
rowParentCandidates,
|
|
355
|
+
colParentCandidates,
|
|
356
|
+
bindingEntries,
|
|
357
|
+
metaTick,
|
|
358
|
+
getBindingAt,
|
|
359
|
+
resolveFieldLabel,
|
|
360
|
+
bindField,
|
|
361
|
+
patchActiveBinding,
|
|
362
|
+
startParentPick,
|
|
363
|
+
cancelParentPick,
|
|
364
|
+
pickParentAt,
|
|
365
|
+
clearParent,
|
|
366
|
+
removeActiveBinding,
|
|
367
|
+
resolveCellStyle,
|
|
368
|
+
resolveCellRenderer,
|
|
369
|
+
getTemplate,
|
|
370
|
+
addConnection,
|
|
371
|
+
updateConnection,
|
|
372
|
+
removeConnection,
|
|
373
|
+
addDataset,
|
|
374
|
+
updateDataset,
|
|
375
|
+
removeDataset,
|
|
376
|
+
testConnection,
|
|
377
|
+
describeDataset,
|
|
378
|
+
previewDataset
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
//#endregion
|
|
382
|
+
export { useReportDesigner };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { renderReport, resolveFilledColWidths } from "../../report/render/index.js";
|
|
2
|
+
import { fetchTemplateRecords, resolveParamDefaults, resolveTemplateParams } from "../../report/template.js";
|
|
3
|
+
import { computed, ref, shallowRef, watch } from "vue";
|
|
4
|
+
//#region src/components/report/use-report-viewer.ts
|
|
5
|
+
/**
|
|
6
|
+
* UReportViewer 的 headless 编排:参数提取 → 取数 → renderReport 展开。
|
|
7
|
+
* 不持有 DOM / 网格引用;填充快照经 `filledSnapshot` 交给组件壳应用。
|
|
8
|
+
*/
|
|
9
|
+
function useReportViewer(props) {
|
|
10
|
+
const loading = ref(false);
|
|
11
|
+
const error = shallowRef(null);
|
|
12
|
+
const filledSnapshot = shallowRef(null);
|
|
13
|
+
const filledColWidths = shallowRef(void 0);
|
|
14
|
+
const params = computed(() => resolveTemplateParams(props.template));
|
|
15
|
+
const values = shallowRef({});
|
|
16
|
+
let fetchSeq = 0;
|
|
17
|
+
async function refresh() {
|
|
18
|
+
const current = ++fetchSeq;
|
|
19
|
+
const template = props.template;
|
|
20
|
+
loading.value = true;
|
|
21
|
+
error.value = null;
|
|
22
|
+
const result = await fetchTemplateRecords(props.connector, template, values.value);
|
|
23
|
+
if (current !== fetchSeq) return;
|
|
24
|
+
loading.value = false;
|
|
25
|
+
if (!result.ok) {
|
|
26
|
+
error.value = result.error;
|
|
27
|
+
filledColWidths.value = void 0;
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
filledSnapshot.value = renderReport(template, result.data);
|
|
31
|
+
filledColWidths.value = template.colWidths?.length ? resolveFilledColWidths(template, result.data, template.colWidths) : void 0;
|
|
32
|
+
}
|
|
33
|
+
function setValues(next) {
|
|
34
|
+
values.value = next;
|
|
35
|
+
refresh();
|
|
36
|
+
}
|
|
37
|
+
watch(() => props.template, () => {
|
|
38
|
+
filledSnapshot.value = null;
|
|
39
|
+
filledColWidths.value = void 0;
|
|
40
|
+
values.value = resolveParamDefaults(params.value);
|
|
41
|
+
refresh();
|
|
42
|
+
}, { immediate: true });
|
|
43
|
+
return {
|
|
44
|
+
params,
|
|
45
|
+
values,
|
|
46
|
+
loading,
|
|
47
|
+
error,
|
|
48
|
+
filledSnapshot,
|
|
49
|
+
filledColWidths,
|
|
50
|
+
refresh,
|
|
51
|
+
setValues
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
//#endregion
|
|
55
|
+
export { useReportViewer };
|
|
@@ -5,7 +5,7 @@ import { formatAddress, formatRange, parseRange } from "@veltra/sheet-core/core/
|
|
|
5
5
|
import { computed, createCommentVNode, createElementBlock, createElementVNode, createVNode, defineComponent, nextTick, normalizeClass, onBeforeUnmount, onMounted, openBlock, ref, shallowRef, unref, useTemplateRef, vModelText, watch, withDirectives, withModifiers } from "vue";
|
|
6
6
|
import { message } from "@veltra/desktop";
|
|
7
7
|
import { bem } from "@veltra/utils";
|
|
8
|
-
//#region src/
|
|
8
|
+
//#region src/components/sheet/formula-bar.vue
|
|
9
9
|
const _hoisted_1 = ["disabled", "readonly"];
|
|
10
10
|
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
11
11
|
name: "UFormulaBar",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Fragment, computed, createCommentVNode, createElementBlock, createElementVNode, createVNode, defineComponent, nextTick, normalizeClass, openBlock, renderList, toDisplayString, unref, watch, withCtx, withModifiers } from "vue";
|
|
2
2
|
import { UScroll } from "@veltra/desktop";
|
|
3
3
|
import { bem } from "@veltra/utils";
|
|
4
|
-
//#region src/
|
|
4
|
+
//#region src/components/sheet/formula-suggest-list.vue
|
|
5
5
|
const _hoisted_1 = [
|
|
6
6
|
"aria-selected",
|
|
7
7
|
"onMousedown",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { message, messageConfirm } from "@veltra/desktop";
|
|
2
2
|
import { nextFrame } from "@veltra/utils";
|
|
3
3
|
import { importCsv, importXlsx, replaceWorkbookWithSnapshots } from "@veltra/sheet-core/core/io/import";
|
|
4
|
-
//#region src/
|
|
4
|
+
//#region src/components/sheet/import-file.ts
|
|
5
5
|
/** 导入文件 accept(工具栏直接选文件) */
|
|
6
6
|
const IMPORT_FILE_ACCEPT = ".xlsx,.csv";
|
|
7
7
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createElementBlock, createElementVNode, createVNode, defineComponent, inject, normalizeClass, openBlock, ref, toDisplayString, unref, withKeys, withModifiers } from "vue";
|
|
2
2
|
import { ContextmenuRootDIKey, UNumberInput } from "@veltra/desktop";
|
|
3
3
|
import { bem } from "@veltra/utils";
|
|
4
|
-
//#region src/
|
|
4
|
+
//#region src/components/sheet/insert-count-menu-item.vue
|
|
5
5
|
const _hoisted_1 = ["onKeydownCapture"];
|
|
6
6
|
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
7
7
|
name: "USheetInsertCountMenuItem",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BORDER_STYLE_WIDTH } from "@veltra/sheet-core/core/style/types";
|
|
2
|
-
//#region src/
|
|
2
|
+
//#region src/components/sheet/popup-helpers.ts
|
|
3
3
|
/** 当前选区(ranges[0] 优先;无区域选区时用活动格单格) */
|
|
4
4
|
function currentRange(context) {
|
|
5
5
|
const { activeCell, ranges } = context.getSelection();
|
|
@@ -5,7 +5,7 @@ import { UPalette } from "@veltra/desktop";
|
|
|
5
5
|
import { bem } from "@veltra/utils";
|
|
6
6
|
import { buildBorderPresetItems } from "@veltra/sheet-core/core/style/border-presets";
|
|
7
7
|
import { BORDER_STYLE_WIDTH } from "@veltra/sheet-core/core/style/types";
|
|
8
|
-
//#region src/
|
|
8
|
+
//#region src/components/sheet/popups/border-popup.vue
|
|
9
9
|
const _hoisted_1 = ["title", "onClick"];
|
|
10
10
|
const _hoisted_2 = ["title", "onClick"];
|
|
11
11
|
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
@@ -18,13 +18,36 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
18
18
|
* 预设补丁由 core/style/border-presets 生成(含邻居格共享边同步,对齐
|
|
19
19
|
* Excel「写入时同步、最近设置生效」);面板打开期间的写入由
|
|
20
20
|
* use-tool-popup 事务包裹为一个 undo 单元。
|
|
21
|
+
* 整行/整列选区下,均匀预设(all/none/单侧)走 applyStyle → 行列默认样式。
|
|
21
22
|
*/
|
|
22
23
|
const props = __props;
|
|
23
24
|
const cls = bem("sheet");
|
|
24
25
|
/** 当前线型 / 颜色 */
|
|
25
26
|
const borderLineStyle = ref("thin");
|
|
26
27
|
const borderColor = ref("#000000");
|
|
27
|
-
/**
|
|
28
|
+
/** 均匀边框补丁(可写进行/列默认样式);outer/inner 几何相关 → null */
|
|
29
|
+
function uniformBorderPatch(preset, edge) {
|
|
30
|
+
switch (preset) {
|
|
31
|
+
case "all": return { border: {
|
|
32
|
+
top: edge,
|
|
33
|
+
right: edge,
|
|
34
|
+
bottom: edge,
|
|
35
|
+
left: edge
|
|
36
|
+
} };
|
|
37
|
+
case "none": return { border: {
|
|
38
|
+
top: null,
|
|
39
|
+
right: null,
|
|
40
|
+
bottom: null,
|
|
41
|
+
left: null
|
|
42
|
+
} };
|
|
43
|
+
case "top": return { border: { top: edge } };
|
|
44
|
+
case "bottom": return { border: { bottom: edge } };
|
|
45
|
+
case "left": return { border: { left: edge } };
|
|
46
|
+
case "right": return { border: { right: edge } };
|
|
47
|
+
default: return null;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/** 应用边框预设:整行/整列均匀预设走 applyStyle;其余逐格批量(含邻居同步) */
|
|
28
51
|
function applyBorderPreset(preset) {
|
|
29
52
|
const range = currentRange(props.context);
|
|
30
53
|
if (!range) return;
|
|
@@ -33,7 +56,12 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
33
56
|
width: BORDER_STYLE_WIDTH[borderLineStyle.value],
|
|
34
57
|
color: borderColor.value
|
|
35
58
|
};
|
|
36
|
-
const
|
|
59
|
+
const uniform = props.context.resolveStyleTarget(range) !== "cell" ? uniformBorderPatch(preset, edge) : null;
|
|
60
|
+
if (uniform) {
|
|
61
|
+
props.context.applyStyle(range, uniform);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const items = buildBorderPresetItems(range, preset, edge, (addr) => props.context.getEffectiveStyle(addr)).map(({ addr, patch }) => ({
|
|
37
65
|
addr,
|
|
38
66
|
partial: patch
|
|
39
67
|
}));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { computed, createCommentVNode, createElementBlock, createElementVNode, defineComponent, normalizeClass, openBlock, unref } from "vue";
|
|
2
2
|
import { bem } from "@veltra/utils";
|
|
3
|
-
//#region src/
|
|
3
|
+
//#region src/components/sheet/popups/border-preset-glyph.vue
|
|
4
4
|
const _hoisted_1 = ["stroke"];
|
|
5
5
|
const _hoisted_2 = ["stroke"];
|
|
6
6
|
const _hoisted_3 = ["stroke"];
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { exportSheetCsvFile, exportWorkbookFile } from "
|
|
1
|
+
import { exportSheetCsvFile, exportWorkbookFile } from "../../../tools/download.js";
|
|
2
2
|
import { createElementBlock, createElementVNode, defineComponent, normalizeClass, openBlock, unref } from "vue";
|
|
3
3
|
import { message } from "@veltra/desktop";
|
|
4
4
|
import { bem } from "@veltra/utils";
|
|
5
|
-
//#region src/
|
|
5
|
+
//#region src/components/sheet/popups/export-popup.vue
|
|
6
6
|
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
7
7
|
name: "USheetExportPopup",
|
|
8
8
|
__name: "export-popup",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { currentRange } from "../popup-helpers.js";
|
|
2
2
|
import { createBlock, defineComponent, onMounted, openBlock, ref, unref } from "vue";
|
|
3
3
|
import { UPalette } from "@veltra/desktop";
|
|
4
|
-
//#region src/
|
|
4
|
+
//#region src/components/sheet/popups/fill-color-popup.vue
|
|
5
5
|
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
6
6
|
name: "USheetFillColorPopup",
|
|
7
7
|
__name: "fill-color-popup",
|
|
@@ -16,14 +16,14 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
16
16
|
const fillColor = ref("");
|
|
17
17
|
onMounted(() => {
|
|
18
18
|
const active = props.context.getSelection().activeCell;
|
|
19
|
-
const style = active ? props.context.
|
|
19
|
+
const style = active ? props.context.getEffectiveStyle(active) : void 0;
|
|
20
20
|
fillColor.value = style?.fill?.color ?? "";
|
|
21
21
|
});
|
|
22
22
|
/** 填充颜色变化('' = 无填充:清除 fill 保留边框) */
|
|
23
23
|
function applyFillColor(color) {
|
|
24
24
|
const range = currentRange(props.context);
|
|
25
25
|
if (!range) return;
|
|
26
|
-
props.context.
|
|
26
|
+
props.context.applyStyle(range, color ? { fill: { color } } : { fill: {} });
|
|
27
27
|
}
|
|
28
28
|
return (_ctx, _cache) => {
|
|
29
29
|
return openBlock(), createBlock(unref(UPalette), {
|
|
@@ -2,7 +2,7 @@ import { useFindReplace } from "../use-find-replace.js";
|
|
|
2
2
|
import { Fragment, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, isRef, normalizeClass, openBlock, toDisplayString, unref, vModelCheckbox, vModelSelect, withDirectives } from "vue";
|
|
3
3
|
import { UInput } from "@veltra/desktop";
|
|
4
4
|
import { bem } from "@veltra/utils";
|
|
5
|
-
//#region src/
|
|
5
|
+
//#region src/components/sheet/popups/find-popup.vue
|
|
6
6
|
const _hoisted_1 = ["disabled"];
|
|
7
7
|
const _hoisted_2 = ["disabled"];
|
|
8
8
|
const _hoisted_3 = ["disabled"];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { currentRange } from "../popup-helpers.js";
|
|
2
2
|
import { createBlock, defineComponent, onMounted, openBlock, ref, unref } from "vue";
|
|
3
3
|
import { UPalette } from "@veltra/desktop";
|
|
4
|
-
//#region src/
|
|
4
|
+
//#region src/components/sheet/popups/font-color-popup.vue
|
|
5
5
|
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
6
6
|
name: "USheetFontColorPopup",
|
|
7
7
|
__name: "font-color-popup",
|
|
@@ -16,14 +16,14 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
16
16
|
const fontColor = ref("");
|
|
17
17
|
onMounted(() => {
|
|
18
18
|
const active = props.context.getSelection().activeCell;
|
|
19
|
-
const style = active ? props.context.
|
|
19
|
+
const style = active ? props.context.getEffectiveStyle(active) : void 0;
|
|
20
20
|
fontColor.value = style?.font?.color ?? "";
|
|
21
21
|
});
|
|
22
22
|
/** 字体颜色变化('' = 清除 color) */
|
|
23
23
|
function applyFontColor(color) {
|
|
24
24
|
const range = currentRange(props.context);
|
|
25
25
|
if (!range) return;
|
|
26
|
-
props.context.
|
|
26
|
+
props.context.applyStyle(range, color ? { font: { color } } : { font: { color: null } });
|
|
27
27
|
}
|
|
28
28
|
return (_ctx, _cache) => {
|
|
29
29
|
return openBlock(), createBlock(unref(UPalette), {
|
|
@@ -2,7 +2,7 @@ import { currentRange } from "../popup-helpers.js";
|
|
|
2
2
|
import { Fragment, createCommentVNode, createElementBlock, createElementVNode, createVNode, defineComponent, normalizeClass, onMounted, openBlock, ref, renderList, toDisplayString, unref, withCtx } from "vue";
|
|
3
3
|
import { UScroll } from "@veltra/desktop";
|
|
4
4
|
import { bem } from "@veltra/utils";
|
|
5
|
-
//#region src/
|
|
5
|
+
//#region src/components/sheet/popups/font-size-popup.vue
|
|
6
6
|
const _hoisted_1 = ["onClick"];
|
|
7
7
|
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
8
8
|
name: "USheetFontSizePopup",
|
|
@@ -32,14 +32,14 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
|
32
32
|
const currentSize = ref(void 0);
|
|
33
33
|
onMounted(() => {
|
|
34
34
|
const active = props.context.getSelection().activeCell;
|
|
35
|
-
const style = active ? props.context.
|
|
35
|
+
const style = active ? props.context.getEffectiveStyle(active) : void 0;
|
|
36
36
|
currentSize.value = style?.font?.size;
|
|
37
37
|
});
|
|
38
38
|
function applyFontSize(size) {
|
|
39
39
|
const range = currentRange(props.context);
|
|
40
40
|
if (!range) return;
|
|
41
41
|
currentSize.value = size;
|
|
42
|
-
props.context.
|
|
42
|
+
props.context.applyStyle(range, { font: { size } });
|
|
43
43
|
}
|
|
44
44
|
return (_ctx, _cache) => {
|
|
45
45
|
return openBlock(), createElementBlock(Fragment, null, [createCommentVNode(" 下拉排列:每行一个字号;滚动用 desktop UScroll(自定义滚动条) "), createVNode(unref(UScroll), {
|