@veltra/sheet 2.1.1 → 2.2.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 +76 -0
- package/dist/components/report/designer/cell-coords.js +46 -0
- package/dist/components/report/designer/col-widths.js +15 -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 +385 -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 +269 -0
- package/dist/components/report/designer/rules-dialog.js +135 -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/report-designer.js +343 -0
- package/dist/components/report/report-viewer.js +111 -0
- package/dist/components/report/style.d.ts +17 -0
- package/dist/components/report/style.js +18 -0
- package/dist/components/report/style2.css +869 -0
- package/dist/components/report/use-report-designer.js +360 -0
- package/dist/components/report/use-report-viewer.js +50 -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 +1 -1
- 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 +1 -1
- package/dist/{vue → components/sheet}/popups/find-popup.js +1 -1
- package/dist/{vue → components/sheet}/popups/font-color-popup.js +1 -1
- package/dist/{vue → components/sheet}/popups/font-size-popup.js +1 -1
- 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 +1 -1
- 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 +8 -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 +10 -2
- package/dist/{vue → components/sheet}/use-sheet-state.js +3 -3
- 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 +45 -0
- package/dist/report/binding.js +175 -0
- package/dist/report/connector.d.ts +66 -0
- package/dist/report/connector.js +159 -0
- package/dist/report/export-xlsx.d.ts +19 -0
- package/dist/report/export-xlsx.js +95 -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 +157 -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 +59 -0
- package/dist/report/template.js +80 -0
- package/dist/report/types.d.ts +85 -0
- package/dist/tools/context.d.ts +1 -1
- package/dist/types/index.d.ts +3 -2
- package/dist/types/report-designer.d.ts +36 -0
- package/dist/types/report-viewer.d.ts +38 -0
- package/dist/types/sheet.d.ts +17 -1
- package/package.json +3 -5
- package/src/components/report/__test__/conditional-rules-helpers.test.ts +87 -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__/report-designer.test.ts +388 -0
- package/src/components/report/__test__/report-viewer.test.ts +334 -0
- package/src/components/report/__test__/topology.test.ts +143 -0
- package/src/components/report/__test__/use-report-designer.test.ts +565 -0
- package/src/components/report/binding-badge.ts +73 -0
- package/src/components/report/designer/cell-coords.ts +94 -0
- package/src/components/report/designer/col-widths.ts +33 -0
- package/src/components/report/designer/conditional-rules/helpers.ts +186 -0
- package/src/components/report/designer/drop-highlight-overlay.vue +74 -0
- package/src/components/report/designer/float-panel.vue +387 -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 +126 -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/report-designer.vue +356 -0
- package/src/components/report/report-viewer.vue +128 -0
- package/src/components/report/style-designer.scss +583 -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 +547 -0
- package/src/components/report/use-report-viewer.ts +79 -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 +40 -3
- package/src/{vue → components/sheet}/__test__/sheet-context-menu.test.ts +1 -1
- 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 +1 -1
- package/src/{vue → components/sheet}/popups/export-popup.vue +2 -2
- package/src/{vue → components/sheet}/popups/fill-color-popup.vue +1 -1
- package/src/{vue → components/sheet}/popups/find-popup.vue +1 -1
- package/src/{vue → components/sheet}/popups/font-color-popup.vue +1 -1
- package/src/{vue → components/sheet}/popups/font-size-popup.vue +1 -1
- package/src/{vue → components/sheet}/popups/insert-image-popup.vue +1 -1
- package/src/{vue → components/sheet}/sheet-context-menu.ts +2 -2
- package/src/{vue → components/sheet}/sheet-toolbar.vue +2 -2
- package/src/{vue → components/sheet}/sheet.vue +4 -3
- package/src/{vue → components/sheet}/use-find-replace.ts +1 -1
- package/src/{vue → components/sheet}/use-sheet-grid.ts +7 -3
- package/src/{vue → components/sheet}/use-sheet-state.ts +3 -3
- 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 +218 -0
- package/src/report/__test__/connector.test.ts +218 -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 +728 -0
- package/src/report/__test__/rules.test.ts +131 -0
- package/src/report/__test__/template.test.ts +355 -0
- package/src/report/binding.ts +243 -0
- package/src/report/connector.ts +205 -0
- package/src/report/export-xlsx.ts +118 -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 +240 -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 +141 -0
- package/src/report/types.ts +96 -0
- package/src/tools/builtin.ts +2 -2
- package/src/types/index.ts +2 -6
- package/src/types/report-designer.ts +36 -0
- package/src/types/report-viewer.ts +37 -0
- package/src/types/sheet.ts +22 -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,387 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
v-if="binding && cell"
|
|
4
|
+
v-show="visible"
|
|
5
|
+
ref="panelRef"
|
|
6
|
+
:class="[cls.b, cls.m(placement), expanded ? cls.m('expanded') : '']"
|
|
7
|
+
:style="panelStyle"
|
|
8
|
+
@mousedown.stop
|
|
9
|
+
@pointerdown.stop
|
|
10
|
+
>
|
|
11
|
+
<div :class="cls.e('bar')">
|
|
12
|
+
<div :class="cls.e('summary')" :title="summaryText">
|
|
13
|
+
{{ summaryText }}
|
|
14
|
+
</div>
|
|
15
|
+
<div :class="cls.e('toolbar')">
|
|
16
|
+
<u-select
|
|
17
|
+
size="small"
|
|
18
|
+
:class="[cls.e('select'), cls.em('select', 'role')]"
|
|
19
|
+
:model-value="currentPresetValue"
|
|
20
|
+
:options="presetOptions"
|
|
21
|
+
@update:model-value="onPreset"
|
|
22
|
+
/>
|
|
23
|
+
<u-select
|
|
24
|
+
size="small"
|
|
25
|
+
:class="[cls.e('select'), cls.em('select', 'aggregate')]"
|
|
26
|
+
:model-value="binding.aggregate"
|
|
27
|
+
:options="aggregateOptions"
|
|
28
|
+
@update:model-value="onAggregate"
|
|
29
|
+
/>
|
|
30
|
+
<u-select
|
|
31
|
+
size="small"
|
|
32
|
+
:class="[cls.e('select'), cls.em('select', 'expand')]"
|
|
33
|
+
:model-value="binding.expand"
|
|
34
|
+
:options="expandOptions"
|
|
35
|
+
@update:model-value="onExpand"
|
|
36
|
+
/>
|
|
37
|
+
<u-button size="small" plain @click="emit('open-rules')">条件样式</u-button>
|
|
38
|
+
<u-button
|
|
39
|
+
size="small"
|
|
40
|
+
text
|
|
41
|
+
:class="cls.e('expand')"
|
|
42
|
+
:title="expanded ? '收起' : '展开更多'"
|
|
43
|
+
@click="expanded = !expanded"
|
|
44
|
+
>
|
|
45
|
+
{{ expanded ? '收起' : '展开' }}
|
|
46
|
+
</u-button>
|
|
47
|
+
</div>
|
|
48
|
+
</div>
|
|
49
|
+
|
|
50
|
+
<div v-if="expanded" :class="cls.e('body')">
|
|
51
|
+
<section :class="cls.e('section')">
|
|
52
|
+
<div :class="cls.e('section-label')">数据集</div>
|
|
53
|
+
<p :class="cls.e('hint')">{{ binding.dataset }}</p>
|
|
54
|
+
</section>
|
|
55
|
+
|
|
56
|
+
<section :class="cls.e('section')">
|
|
57
|
+
<div :class="cls.e('section-label')">排序</div>
|
|
58
|
+
<u-radio-group
|
|
59
|
+
size="small"
|
|
60
|
+
:items="sortOptions"
|
|
61
|
+
:model-value="binding.sort ?? 'none'"
|
|
62
|
+
@update:model-value="onSort"
|
|
63
|
+
/>
|
|
64
|
+
</section>
|
|
65
|
+
|
|
66
|
+
<section :class="cls.e('section')">
|
|
67
|
+
<div :class="cls.e('section-label')">扩展实例合并单元格</div>
|
|
68
|
+
<u-switch
|
|
69
|
+
size="small"
|
|
70
|
+
:model-value="binding.mergeSpan !== false"
|
|
71
|
+
@update:model-value="onMergeSpan"
|
|
72
|
+
/>
|
|
73
|
+
</section>
|
|
74
|
+
|
|
75
|
+
<section :class="cls.e('section')">
|
|
76
|
+
<div :class="cls.e('section-label')">行方向父格</div>
|
|
77
|
+
<p :class="cls.e('hint')">当前:{{ resolvedRowParentLabel }}</p>
|
|
78
|
+
<div :class="cls.e('parent-actions')">
|
|
79
|
+
<u-button
|
|
80
|
+
size="small"
|
|
81
|
+
plain
|
|
82
|
+
:type="parentPickMode === 'row' ? 'primary' : undefined"
|
|
83
|
+
@click="emit('start-parent-pick', 'row')"
|
|
84
|
+
>
|
|
85
|
+
{{ parentPickMode === 'row' ? '点选目标格…' : '设置行方向父格' }}
|
|
86
|
+
</u-button>
|
|
87
|
+
<u-select
|
|
88
|
+
v-if="rowParentOptions.length > 0"
|
|
89
|
+
size="small"
|
|
90
|
+
:class="cls.e('parent-select')"
|
|
91
|
+
placeholder="候选格"
|
|
92
|
+
:model-value="rowParentSelectValue"
|
|
93
|
+
:options="rowParentOptions"
|
|
94
|
+
@update:model-value="onRowParentSelect"
|
|
95
|
+
/>
|
|
96
|
+
<u-button
|
|
97
|
+
v-if="binding.rowParent"
|
|
98
|
+
size="small"
|
|
99
|
+
text
|
|
100
|
+
type="danger"
|
|
101
|
+
@click="emit('clear-parent', 'row')"
|
|
102
|
+
>
|
|
103
|
+
清除
|
|
104
|
+
</u-button>
|
|
105
|
+
</div>
|
|
106
|
+
</section>
|
|
107
|
+
|
|
108
|
+
<section :class="cls.e('section')">
|
|
109
|
+
<div :class="cls.e('section-label')">列方向父格</div>
|
|
110
|
+
<p :class="cls.e('hint')">当前:{{ resolvedColParentLabel }}</p>
|
|
111
|
+
<div :class="cls.e('parent-actions')">
|
|
112
|
+
<u-button
|
|
113
|
+
size="small"
|
|
114
|
+
plain
|
|
115
|
+
:type="parentPickMode === 'col' ? 'primary' : undefined"
|
|
116
|
+
@click="emit('start-parent-pick', 'col')"
|
|
117
|
+
>
|
|
118
|
+
{{ parentPickMode === 'col' ? '点选目标格…' : '设置列方向父格' }}
|
|
119
|
+
</u-button>
|
|
120
|
+
<u-select
|
|
121
|
+
v-if="colParentOptions.length > 0"
|
|
122
|
+
size="small"
|
|
123
|
+
:class="cls.e('parent-select')"
|
|
124
|
+
placeholder="候选格"
|
|
125
|
+
:model-value="colParentSelectValue"
|
|
126
|
+
:options="colParentOptions"
|
|
127
|
+
@update:model-value="onColParentSelect"
|
|
128
|
+
/>
|
|
129
|
+
<u-button
|
|
130
|
+
v-if="binding.colParent"
|
|
131
|
+
size="small"
|
|
132
|
+
text
|
|
133
|
+
type="danger"
|
|
134
|
+
@click="emit('clear-parent', 'col')"
|
|
135
|
+
>
|
|
136
|
+
清除
|
|
137
|
+
</u-button>
|
|
138
|
+
</div>
|
|
139
|
+
</section>
|
|
140
|
+
|
|
141
|
+
<footer :class="cls.e('footer')">
|
|
142
|
+
<u-button v-if="parentPickMode" size="small" plain @click="emit('cancel-parent-pick')">
|
|
143
|
+
取消点选
|
|
144
|
+
</u-button>
|
|
145
|
+
<u-button size="small" type="danger" plain @click="emit('remove')">删除绑定</u-button>
|
|
146
|
+
</footer>
|
|
147
|
+
</div>
|
|
148
|
+
</div>
|
|
149
|
+
</template>
|
|
150
|
+
|
|
151
|
+
<script lang="ts" setup>
|
|
152
|
+
import { UButton, URadioGroup, USelect, USwitch } from '@veltra/desktop'
|
|
153
|
+
import type { CellAddress, SheetGrid } from '@veltra/sheet-core'
|
|
154
|
+
import { bem } from '@veltra/utils'
|
|
155
|
+
import { computed, nextTick, ref, toRef, watch } from 'vue'
|
|
156
|
+
|
|
157
|
+
import {
|
|
158
|
+
formatBindingPlaceholder,
|
|
159
|
+
formatCellAddress,
|
|
160
|
+
inferReportPreset
|
|
161
|
+
} from '../../../report/binding'
|
|
162
|
+
import type {
|
|
163
|
+
ReportAggregate,
|
|
164
|
+
ReportBinding,
|
|
165
|
+
ReportExpand,
|
|
166
|
+
ReportPreset,
|
|
167
|
+
ReportSort
|
|
168
|
+
} from '../../../report/types'
|
|
169
|
+
import type { ParentPickMode } from '../use-report-designer'
|
|
170
|
+
import { resolveGridOverlayLayout } from './cell-coords'
|
|
171
|
+
import { REPORT_PRESET_OPTIONS, presetBindingDefaults } from './role'
|
|
172
|
+
import {
|
|
173
|
+
readCellOverlayRect,
|
|
174
|
+
resolveBindingFloatPanelPosition,
|
|
175
|
+
useGridOverlaySync
|
|
176
|
+
} from './use-grid-overlay'
|
|
177
|
+
|
|
178
|
+
defineOptions({ name: 'UReportFloatPanel' })
|
|
179
|
+
|
|
180
|
+
const CUSTOM_PRESET_VALUE = '__custom__'
|
|
181
|
+
|
|
182
|
+
const props = defineProps<{
|
|
183
|
+
cell: CellAddress | null
|
|
184
|
+
binding: ReportBinding | null
|
|
185
|
+
resolvedRowParentLabel: string
|
|
186
|
+
resolvedColParentLabel: string
|
|
187
|
+
parentPickMode: ParentPickMode | null
|
|
188
|
+
rowParentCandidates: CellAddress[]
|
|
189
|
+
colParentCandidates: CellAddress[]
|
|
190
|
+
resolveFieldLabel?: (datasetId: string, fieldName: string) => string
|
|
191
|
+
hostEl: HTMLElement | null
|
|
192
|
+
getGrid: () => SheetGrid | undefined
|
|
193
|
+
}>()
|
|
194
|
+
|
|
195
|
+
const emit = defineEmits<{
|
|
196
|
+
patch: [patch: Partial<ReportBinding>]
|
|
197
|
+
remove: []
|
|
198
|
+
'open-rules': []
|
|
199
|
+
'start-parent-pick': [mode: ParentPickMode]
|
|
200
|
+
'cancel-parent-pick': []
|
|
201
|
+
'clear-parent': [mode: ParentPickMode]
|
|
202
|
+
}>()
|
|
203
|
+
|
|
204
|
+
const cls = bem('report-float-panel')
|
|
205
|
+
|
|
206
|
+
const hostEl = toRef(props, 'hostEl')
|
|
207
|
+
const panelRef = ref<HTMLElement | null>(null)
|
|
208
|
+
const expanded = ref(false)
|
|
209
|
+
const placement = ref<'above' | 'below'>('above')
|
|
210
|
+
|
|
211
|
+
const presetOptions = computed(() => {
|
|
212
|
+
const options = REPORT_PRESET_OPTIONS.map((item) => ({ ...item }))
|
|
213
|
+
if (props.binding && inferReportPreset(props.binding) === null) {
|
|
214
|
+
options.unshift({ value: CUSTOM_PRESET_VALUE as ReportPreset, label: '自定义' })
|
|
215
|
+
}
|
|
216
|
+
return options
|
|
217
|
+
})
|
|
218
|
+
|
|
219
|
+
const aggregateOptions = [
|
|
220
|
+
{ value: 'list' as const, label: '明细' },
|
|
221
|
+
{ value: 'group' as const, label: '分组' },
|
|
222
|
+
{ value: 'sum' as const, label: '求和' },
|
|
223
|
+
{ value: 'avg' as const, label: '平均' },
|
|
224
|
+
{ value: 'count' as const, label: '计数' },
|
|
225
|
+
{ value: 'max' as const, label: '最大' },
|
|
226
|
+
{ value: 'min' as const, label: '最小' }
|
|
227
|
+
]
|
|
228
|
+
|
|
229
|
+
const expandOptions = [
|
|
230
|
+
{ value: 'down' as const, label: '向下' },
|
|
231
|
+
{ value: 'right' as const, label: '向右' },
|
|
232
|
+
{ value: 'none' as const, label: '不展开' }
|
|
233
|
+
]
|
|
234
|
+
|
|
235
|
+
const sortOptions = [
|
|
236
|
+
{ value: 'none' as const, label: '无' },
|
|
237
|
+
{ value: 'asc' as const, label: '升序' },
|
|
238
|
+
{ value: 'desc' as const, label: '降序' }
|
|
239
|
+
]
|
|
240
|
+
|
|
241
|
+
const panelLeft = ref(0)
|
|
242
|
+
const panelTop = ref(0)
|
|
243
|
+
const inView = ref(false)
|
|
244
|
+
|
|
245
|
+
const currentPresetValue = computed(() => {
|
|
246
|
+
if (!props.binding) return 'detail'
|
|
247
|
+
return inferReportPreset(props.binding) ?? CUSTOM_PRESET_VALUE
|
|
248
|
+
})
|
|
249
|
+
|
|
250
|
+
const summaryText = computed(() => {
|
|
251
|
+
if (!props.binding) return ''
|
|
252
|
+
return formatBindingPlaceholder(props.binding, props.resolveFieldLabel)
|
|
253
|
+
})
|
|
254
|
+
|
|
255
|
+
const rowParentOptions = computed(() =>
|
|
256
|
+
props.rowParentCandidates.map((addr) => ({
|
|
257
|
+
value: formatCellAddress(addr),
|
|
258
|
+
label: formatCellAddress(addr)
|
|
259
|
+
}))
|
|
260
|
+
)
|
|
261
|
+
|
|
262
|
+
const colParentOptions = computed(() =>
|
|
263
|
+
props.colParentCandidates.map((addr) => ({
|
|
264
|
+
value: formatCellAddress(addr),
|
|
265
|
+
label: formatCellAddress(addr)
|
|
266
|
+
}))
|
|
267
|
+
)
|
|
268
|
+
|
|
269
|
+
const rowParentSelectValue = computed(() =>
|
|
270
|
+
props.binding?.rowParent ? formatCellAddress(props.binding.rowParent) : undefined
|
|
271
|
+
)
|
|
272
|
+
|
|
273
|
+
const colParentSelectValue = computed(() =>
|
|
274
|
+
props.binding?.colParent ? formatCellAddress(props.binding.colParent) : undefined
|
|
275
|
+
)
|
|
276
|
+
|
|
277
|
+
const visible = computed(() => !!props.binding && !!props.cell && inView.value)
|
|
278
|
+
|
|
279
|
+
const panelStyle = computed(() => ({ left: `${panelLeft.value}px`, top: `${panelTop.value}px` }))
|
|
280
|
+
|
|
281
|
+
watch(
|
|
282
|
+
() => [props.cell?.row, props.cell?.col] as const,
|
|
283
|
+
() => {
|
|
284
|
+
expanded.value = false
|
|
285
|
+
}
|
|
286
|
+
)
|
|
287
|
+
|
|
288
|
+
watch(expanded, () => {
|
|
289
|
+
nextTick(() => updatePosition())
|
|
290
|
+
})
|
|
291
|
+
|
|
292
|
+
watch(visible, (show) => {
|
|
293
|
+
if (!show) return
|
|
294
|
+
nextTick(() => updatePosition())
|
|
295
|
+
})
|
|
296
|
+
|
|
297
|
+
function onPreset(preset: ReportPreset | typeof CUSTOM_PRESET_VALUE): void {
|
|
298
|
+
if (preset === CUSTOM_PRESET_VALUE) return
|
|
299
|
+
emit('patch', presetBindingDefaults(preset))
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
function aggregateDefaultExpand(aggregate: ReportAggregate): ReportExpand {
|
|
303
|
+
return aggregate === 'sum' ||
|
|
304
|
+
aggregate === 'avg' ||
|
|
305
|
+
aggregate === 'count' ||
|
|
306
|
+
aggregate === 'max' ||
|
|
307
|
+
aggregate === 'min'
|
|
308
|
+
? 'none'
|
|
309
|
+
: 'down'
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
function onAggregate(aggregate: ReportAggregate): void {
|
|
313
|
+
emit('patch', { aggregate, expand: aggregateDefaultExpand(aggregate) })
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
function onExpand(expand: ReportExpand): void {
|
|
317
|
+
emit('patch', { expand })
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
function onSort(value: ReportSort): void {
|
|
321
|
+
emit('patch', { sort: value })
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
function onMergeSpan(merged: boolean): void {
|
|
325
|
+
emit('patch', { mergeSpan: merged })
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
function onRowParentSelect(label: string): void {
|
|
329
|
+
const addr = props.rowParentCandidates.find((item) => formatCellAddress(item) === label)
|
|
330
|
+
if (!addr) return
|
|
331
|
+
emit('patch', { rowParent: { ...addr } })
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
function onColParentSelect(label: string): void {
|
|
335
|
+
const addr = props.colParentCandidates.find((item) => formatCellAddress(item) === label)
|
|
336
|
+
if (!addr) return
|
|
337
|
+
emit('patch', { colParent: { ...addr } })
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
function updatePosition(): void {
|
|
341
|
+
const cell = props.cell
|
|
342
|
+
const host = props.hostEl
|
|
343
|
+
if (!cell || !host) {
|
|
344
|
+
inView.value = false
|
|
345
|
+
return
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
const layoutResolved = resolveGridOverlayLayout(host)
|
|
349
|
+
const rect = readCellOverlayRect(cell, host, props.getGrid)
|
|
350
|
+
if (!rect || !layoutResolved) {
|
|
351
|
+
inView.value = false
|
|
352
|
+
return
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
inView.value = true
|
|
356
|
+
|
|
357
|
+
const panelEl = panelRef.value
|
|
358
|
+
const panelWidth = panelEl?.offsetWidth ?? 340
|
|
359
|
+
const panelHeight = panelEl?.offsetHeight ?? (expanded.value ? 360 : 68)
|
|
360
|
+
const position = resolveBindingFloatPanelPosition(
|
|
361
|
+
rect,
|
|
362
|
+
layoutResolved.layout,
|
|
363
|
+
panelWidth,
|
|
364
|
+
panelHeight,
|
|
365
|
+
host.clientWidth
|
|
366
|
+
)
|
|
367
|
+
|
|
368
|
+
placement.value = position.placement
|
|
369
|
+
panelLeft.value = position.left
|
|
370
|
+
panelTop.value = position.top
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
useGridOverlaySync({
|
|
374
|
+
hostEl,
|
|
375
|
+
getGrid: () => props.getGrid(),
|
|
376
|
+
watchSources: () =>
|
|
377
|
+
[
|
|
378
|
+
props.cell?.row,
|
|
379
|
+
props.cell?.col,
|
|
380
|
+
props.binding,
|
|
381
|
+
props.hostEl,
|
|
382
|
+
expanded.value,
|
|
383
|
+
props.parentPickMode
|
|
384
|
+
] as const,
|
|
385
|
+
update: updatePosition
|
|
386
|
+
})
|
|
387
|
+
</script>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { presetBindingPatch } from '../../../report/binding'
|
|
2
|
+
import type { ReportBinding, ReportPreset } from '../../../report/types'
|
|
3
|
+
|
|
4
|
+
const PRESET_LABELS: Record<ReportPreset, string> = {
|
|
5
|
+
groupHeader: '分组头',
|
|
6
|
+
detail: '明细行',
|
|
7
|
+
subtotal: '小计行',
|
|
8
|
+
grandTotal: '总计行',
|
|
9
|
+
cross: '交叉格'
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const REPORT_PRESET_OPTIONS = (
|
|
13
|
+
Object.entries(PRESET_LABELS) as Array<[ReportPreset, string]>
|
|
14
|
+
).map(([value, label]) => ({ value, label }))
|
|
15
|
+
|
|
16
|
+
/** @deprecated 05 将更名;暂保留别名供 float-panel 消费 */
|
|
17
|
+
export const REPORT_ROLE_OPTIONS = REPORT_PRESET_OPTIONS
|
|
18
|
+
|
|
19
|
+
export function presetLabel(preset: ReportPreset): string {
|
|
20
|
+
return PRESET_LABELS[preset]
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** @deprecated 05 将更名 */
|
|
24
|
+
export const roleLabel = presetLabel
|
|
25
|
+
|
|
26
|
+
/** 切换预设时写入 expand / aggregate / 父格组合(父格除 grandTotal 外保留既有值) */
|
|
27
|
+
export function presetBindingDefaults(preset: ReportPreset): Partial<ReportBinding> {
|
|
28
|
+
return presetBindingPatch(preset)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** @deprecated 05 将更名 */
|
|
32
|
+
export const roleBindingDefaults = presetBindingDefaults
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<span
|
|
3
|
+
:class="[cls.b, rule.scope === 'row' && cls.m('row')]"
|
|
4
|
+
:style="previewStyle"
|
|
5
|
+
:title="previewTitle"
|
|
6
|
+
>
|
|
7
|
+
{{ previewLabel }}
|
|
8
|
+
</span>
|
|
9
|
+
</template>
|
|
10
|
+
|
|
11
|
+
<script lang="ts" setup>
|
|
12
|
+
import { bem } from '@veltra/utils'
|
|
13
|
+
import { computed } from 'vue'
|
|
14
|
+
|
|
15
|
+
import type { ConditionalRule } from '../../../report/types'
|
|
16
|
+
|
|
17
|
+
defineOptions({ name: 'UReportRulePreview' })
|
|
18
|
+
|
|
19
|
+
const props = defineProps<{ rule: ConditionalRule }>()
|
|
20
|
+
|
|
21
|
+
const cls = bem('report-rule-preview')
|
|
22
|
+
|
|
23
|
+
const previewStyle = computed(() => {
|
|
24
|
+
const { fill, font } = props.rule.style
|
|
25
|
+
return {
|
|
26
|
+
backgroundColor: fill?.color || 'transparent',
|
|
27
|
+
color: font?.color || 'inherit',
|
|
28
|
+
fontWeight: font?.bold ? '700' : '400',
|
|
29
|
+
fontStyle: font?.italic ? 'italic' : 'normal'
|
|
30
|
+
}
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
const previewLabel = computed(() => (props.rule.scope === 'row' ? '整行' : 'Aa'))
|
|
34
|
+
|
|
35
|
+
const previewTitle = computed(() =>
|
|
36
|
+
props.rule.scope === 'row'
|
|
37
|
+
? '整行作用范围:命中后染满物理输出行(交叉表会染满整行,明细行报表更合适)'
|
|
38
|
+
: '本格作用范围'
|
|
39
|
+
)
|
|
40
|
+
</script>
|