@veltra/sheet 2.2.0 → 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 +45 -21
- package/dist/components/report/designer/col-widths.js +18 -4
- package/dist/components/report/designer/conditional-rules/helpers.js +3 -3
- package/dist/components/report/designer/float-panel.js +73 -36
- package/dist/components/report/designer/rule-row.js +111 -127
- package/dist/components/report/designer/rules-dialog.js +5 -22
- package/dist/components/report/preview-grid-size.js +32 -0
- package/dist/components/report/report-designer.js +75 -25
- package/dist/components/report/report-viewer.js +38 -25
- package/dist/components/report/style2.css +44 -39
- package/dist/components/report/use-report-designer.js +34 -12
- package/dist/components/report/use-report-viewer.js +6 -1
- package/dist/components/sheet/popups/border-popup.js +30 -2
- package/dist/components/sheet/popups/fill-color-popup.js +2 -2
- package/dist/components/sheet/popups/font-color-popup.js +2 -2
- package/dist/components/sheet/popups/font-size-popup.js +2 -2
- package/dist/components/sheet/sheet-context-menu.js +6 -3
- package/dist/components/sheet/sheet.js +8 -0
- package/dist/components/sheet/use-sheet-grid.js +14 -4
- package/dist/components/sheet/use-sheet-state.js +3 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/report/binding.d.ts +49 -11
- package/dist/report/binding.js +186 -29
- package/dist/report/connector.js +1 -1
- package/dist/report/export-xlsx.d.ts +3 -5
- package/dist/report/export-xlsx.js +7 -10
- package/dist/report/index.d.ts +2 -2
- package/dist/report/render/aggregate.js +20 -8
- package/dist/report/template.d.ts +8 -4
- package/dist/report/template.js +5 -2
- package/dist/tools/apply-style.js +29 -0
- package/dist/tools/builtin.js +17 -17
- package/dist/tools/context.d.ts +38 -5
- package/dist/tools/context.js +38 -1
- package/dist/types/report-designer.d.ts +2 -0
- package/dist/types/report-viewer.d.ts +2 -2
- package/dist/types/sheet.d.ts +4 -0
- package/package.json +6 -6
- package/src/components/report/__test__/conditional-rules-helpers.test.ts +1 -0
- package/src/components/report/__test__/preview-grid-size.test.ts +63 -0
- package/src/components/report/__test__/report-designer.test.ts +76 -0
- package/src/components/report/__test__/report-viewer.test.ts +24 -1
- package/src/components/report/__test__/use-report-designer.test.ts +142 -10
- package/src/components/report/binding-badge.ts +39 -20
- package/src/components/report/designer/col-widths.ts +34 -11
- package/src/components/report/designer/conditional-rules/helpers.ts +6 -3
- package/src/components/report/designer/float-panel.vue +71 -27
- package/src/components/report/designer/rule-row.vue +67 -67
- package/src/components/report/designer/rules-dialog.vue +3 -19
- package/src/components/report/preview-grid-size.ts +33 -0
- package/src/components/report/report-designer.vue +79 -15
- package/src/components/report/report-viewer.vue +37 -29
- package/src/components/report/style-designer.scss +45 -41
- package/src/components/report/use-report-designer.ts +63 -14
- package/src/components/report/use-report-viewer.ts +11 -2
- package/src/components/sheet/__test__/sheet-component.test.ts +37 -0
- package/src/components/sheet/__test__/sheet-context-menu.test.ts +3 -2
- package/src/components/sheet/popups/border-popup.vue +31 -3
- package/src/components/sheet/popups/fill-color-popup.vue +2 -2
- package/src/components/sheet/popups/font-color-popup.vue +2 -2
- package/src/components/sheet/popups/font-size-popup.vue +2 -2
- package/src/components/sheet/sheet-context-menu.ts +8 -2
- package/src/components/sheet/sheet.vue +2 -0
- package/src/components/sheet/use-sheet-grid.ts +17 -3
- package/src/components/sheet/use-sheet-state.ts +8 -3
- package/src/report/__test__/binding.test.ts +103 -1
- package/src/report/__test__/connector.test.ts +21 -0
- package/src/report/__test__/export-xlsx.test.ts +4 -4
- package/src/report/__test__/render.test.ts +102 -0
- package/src/report/__test__/template.test.ts +11 -0
- package/src/report/binding.ts +278 -47
- package/src/report/connector.ts +3 -2
- package/src/report/export-xlsx.ts +9 -14
- package/src/report/render/aggregate.ts +29 -8
- package/src/report/template.ts +8 -4
- package/src/tools/__test__/apply-style.test.ts +129 -0
- package/src/tools/apply-style.ts +41 -0
- package/src/tools/builtin.ts +18 -18
- package/src/tools/context.ts +67 -4
- package/src/tools/index.ts +1 -0
- package/src/types/report-designer.ts +2 -0
- package/src/types/report-viewer.ts +2 -2
- package/src/types/sheet.ts +4 -0
package/dist/tools/builtin.js
CHANGED
|
@@ -17,15 +17,15 @@ function selectionRange(ctx) {
|
|
|
17
17
|
function toggleFontFlag(ctx, field) {
|
|
18
18
|
const sel = selectionRange(ctx);
|
|
19
19
|
if (!sel) return;
|
|
20
|
-
const on = ctx.
|
|
21
|
-
ctx.
|
|
20
|
+
const on = ctx.getEffectiveStyle(sel.activeCell)?.font?.[field] === true;
|
|
21
|
+
ctx.applyStyle(sel.range, { font: { [field]: on ? null : true } });
|
|
22
22
|
}
|
|
23
23
|
/** 对齐 toggle:点当前档 = 清除,点其它档 = 切换 */
|
|
24
24
|
function toggleAlign(ctx, axis, value) {
|
|
25
25
|
const sel = selectionRange(ctx);
|
|
26
26
|
if (!sel) return;
|
|
27
|
-
if (ctx.
|
|
28
|
-
else ctx.
|
|
27
|
+
if (ctx.getEffectiveStyle(sel.activeCell)?.align?.[axis] === value) ctx.applyStyle(sel.range, { align: { [axis]: null } });
|
|
28
|
+
else ctx.applyStyle(sel.range, { align: { [axis]: value } });
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
31
31
|
* 内置工具(dogfood 扩展机制)。
|
|
@@ -129,7 +129,7 @@ registerTool({
|
|
|
129
129
|
disabled: (ctx) => !ctx.getSelection().activeCell,
|
|
130
130
|
active: (ctx) => {
|
|
131
131
|
const active = ctx.getSelection().activeCell;
|
|
132
|
-
return !!active && ctx.
|
|
132
|
+
return !!active && ctx.getEffectiveStyle(active)?.font?.bold === true;
|
|
133
133
|
},
|
|
134
134
|
onClick: (ctx) => toggleFontFlag(ctx, "bold")
|
|
135
135
|
});
|
|
@@ -143,7 +143,7 @@ registerTool({
|
|
|
143
143
|
disabled: (ctx) => !ctx.getSelection().activeCell,
|
|
144
144
|
active: (ctx) => {
|
|
145
145
|
const active = ctx.getSelection().activeCell;
|
|
146
|
-
return !!active && ctx.
|
|
146
|
+
return !!active && ctx.getEffectiveStyle(active)?.font?.italic === true;
|
|
147
147
|
},
|
|
148
148
|
onClick: (ctx) => toggleFontFlag(ctx, "italic")
|
|
149
149
|
});
|
|
@@ -157,7 +157,7 @@ registerTool({
|
|
|
157
157
|
disabled: (ctx) => !ctx.getSelection().activeCell,
|
|
158
158
|
active: (ctx) => {
|
|
159
159
|
const active = ctx.getSelection().activeCell;
|
|
160
|
-
return !!active && ctx.
|
|
160
|
+
return !!active && ctx.getEffectiveStyle(active)?.font?.underline === true;
|
|
161
161
|
},
|
|
162
162
|
onClick: (ctx) => toggleFontFlag(ctx, "underline")
|
|
163
163
|
});
|
|
@@ -171,7 +171,7 @@ registerTool({
|
|
|
171
171
|
disabled: (ctx) => !ctx.getSelection().activeCell,
|
|
172
172
|
active: (ctx) => {
|
|
173
173
|
const active = ctx.getSelection().activeCell;
|
|
174
|
-
return !!active && ctx.
|
|
174
|
+
return !!active && ctx.getEffectiveStyle(active)?.font?.strikethrough === true;
|
|
175
175
|
},
|
|
176
176
|
onClick: (ctx) => toggleFontFlag(ctx, "strikethrough")
|
|
177
177
|
});
|
|
@@ -207,7 +207,7 @@ registerTool({
|
|
|
207
207
|
disabled: (ctx) => !ctx.getSelection().activeCell,
|
|
208
208
|
active: (ctx) => {
|
|
209
209
|
const active = ctx.getSelection().activeCell;
|
|
210
|
-
return !!active && ctx.
|
|
210
|
+
return !!active && ctx.getEffectiveStyle(active)?.align?.horizontal === "left";
|
|
211
211
|
},
|
|
212
212
|
onClick: (ctx) => toggleAlign(ctx, "horizontal", "left")
|
|
213
213
|
});
|
|
@@ -221,7 +221,7 @@ registerTool({
|
|
|
221
221
|
disabled: (ctx) => !ctx.getSelection().activeCell,
|
|
222
222
|
active: (ctx) => {
|
|
223
223
|
const active = ctx.getSelection().activeCell;
|
|
224
|
-
return !!active && ctx.
|
|
224
|
+
return !!active && ctx.getEffectiveStyle(active)?.align?.horizontal === "center";
|
|
225
225
|
},
|
|
226
226
|
onClick: (ctx) => toggleAlign(ctx, "horizontal", "center")
|
|
227
227
|
});
|
|
@@ -235,7 +235,7 @@ registerTool({
|
|
|
235
235
|
disabled: (ctx) => !ctx.getSelection().activeCell,
|
|
236
236
|
active: (ctx) => {
|
|
237
237
|
const active = ctx.getSelection().activeCell;
|
|
238
|
-
return !!active && ctx.
|
|
238
|
+
return !!active && ctx.getEffectiveStyle(active)?.align?.horizontal === "right";
|
|
239
239
|
},
|
|
240
240
|
onClick: (ctx) => toggleAlign(ctx, "horizontal", "right")
|
|
241
241
|
});
|
|
@@ -249,7 +249,7 @@ registerTool({
|
|
|
249
249
|
disabled: (ctx) => !ctx.getSelection().activeCell,
|
|
250
250
|
active: (ctx) => {
|
|
251
251
|
const active = ctx.getSelection().activeCell;
|
|
252
|
-
return !!active && ctx.
|
|
252
|
+
return !!active && ctx.getEffectiveStyle(active)?.align?.vertical === "top";
|
|
253
253
|
},
|
|
254
254
|
onClick: (ctx) => toggleAlign(ctx, "vertical", "top")
|
|
255
255
|
});
|
|
@@ -263,7 +263,7 @@ registerTool({
|
|
|
263
263
|
disabled: (ctx) => !ctx.getSelection().activeCell,
|
|
264
264
|
active: (ctx) => {
|
|
265
265
|
const active = ctx.getSelection().activeCell;
|
|
266
|
-
return !!active && ctx.
|
|
266
|
+
return !!active && ctx.getEffectiveStyle(active)?.align?.vertical === "middle";
|
|
267
267
|
},
|
|
268
268
|
onClick: (ctx) => toggleAlign(ctx, "vertical", "middle")
|
|
269
269
|
});
|
|
@@ -277,7 +277,7 @@ registerTool({
|
|
|
277
277
|
disabled: (ctx) => !ctx.getSelection().activeCell,
|
|
278
278
|
active: (ctx) => {
|
|
279
279
|
const active = ctx.getSelection().activeCell;
|
|
280
|
-
return !!active && ctx.
|
|
280
|
+
return !!active && ctx.getEffectiveStyle(active)?.align?.vertical === "bottom";
|
|
281
281
|
},
|
|
282
282
|
onClick: (ctx) => toggleAlign(ctx, "vertical", "bottom")
|
|
283
283
|
});
|
|
@@ -291,13 +291,13 @@ registerTool({
|
|
|
291
291
|
disabled: (ctx) => !ctx.getSelection().activeCell,
|
|
292
292
|
active: (ctx) => {
|
|
293
293
|
const active = ctx.getSelection().activeCell;
|
|
294
|
-
return !!active && ctx.
|
|
294
|
+
return !!active && ctx.getEffectiveStyle(active)?.align?.wrap === true;
|
|
295
295
|
},
|
|
296
296
|
onClick: (ctx) => {
|
|
297
297
|
const sel = selectionRange(ctx);
|
|
298
298
|
if (!sel) return;
|
|
299
|
-
const on = ctx.
|
|
300
|
-
ctx.
|
|
299
|
+
const on = ctx.getEffectiveStyle(sel.activeCell)?.align?.wrap === true;
|
|
300
|
+
ctx.applyStyle(sel.range, { align: { wrap: on ? null : true } });
|
|
301
301
|
}
|
|
302
302
|
});
|
|
303
303
|
registerTool({
|
package/dist/tools/context.d.ts
CHANGED
|
@@ -37,12 +37,33 @@ interface SheetContext {
|
|
|
37
37
|
getDisplayValue(addr: CellAddress): CellValue | undefined;
|
|
38
38
|
/** 合并语义下的单元格信息(普通格 / 合并锚点 / 被覆盖格) */
|
|
39
39
|
getCellInfo(addr: CellAddress): CellInfo;
|
|
40
|
-
/**
|
|
40
|
+
/**
|
|
41
|
+
* 按选区形态写样式(Excel 语义):
|
|
42
|
+
* 整行选区 → rowStyles;整列选区 → colStyles;其余 → 逐格。
|
|
43
|
+
* 判定依赖 createSheetContext 注入的渲染尺寸;未注入时一律走 setCellStyle。
|
|
44
|
+
*/
|
|
45
|
+
applyStyle(range: CellRange, partial: CellStylePatch): void;
|
|
46
|
+
/**
|
|
47
|
+
* 选区样式目标(与 applyStyle 同一判定);未注入渲染尺寸时恒为 'cell'。
|
|
48
|
+
*/
|
|
49
|
+
resolveStyleTarget(range: CellRange): 'row' | 'col' | 'cell';
|
|
50
|
+
/**
|
|
51
|
+
* 按选区形态清除样式:整行/整列清对应默认样式;其余清单元格 s。
|
|
52
|
+
* 未注入渲染尺寸时一律走 clearCellStyle。
|
|
53
|
+
*/
|
|
54
|
+
clearStyle(range: CellRange): void;
|
|
55
|
+
/** 设置区域单元格样式(部分合并语义,见 CellStylePatch);空样式 = 删除 s 字段 */
|
|
41
56
|
setCellStyle(range: CellRange, partial: CellStylePatch): void;
|
|
42
|
-
/**
|
|
57
|
+
/** 清除区域单元格样式(保留值 / 公式) */
|
|
43
58
|
clearCellStyle(range: CellRange): void;
|
|
44
|
-
/**
|
|
59
|
+
/** 设置行默认样式(部分合并,进 undo) */
|
|
60
|
+
setRowStyle(row: number, partial: CellStylePatch): void;
|
|
61
|
+
/** 设置列默认样式(部分合并,进 undo) */
|
|
62
|
+
setColStyle(col: number, partial: CellStylePatch): void;
|
|
63
|
+
/** 读取单元格样式(原始存储语义:被覆盖格 → undefined;不含行列默认) */
|
|
45
64
|
getCellStyle(addr: CellAddress): CellStyle | undefined;
|
|
65
|
+
/** 有效样式:列 → 行 → 格字段级叠加(空格可继承行列默认) */
|
|
66
|
+
getEffectiveStyle(addr: CellAddress): CellStyle | undefined;
|
|
46
67
|
setCellValue(addr: CellAddress, value: CellValue): void;
|
|
47
68
|
setCellFormula(addr: CellAddress, formula: string): void;
|
|
48
69
|
/** 批量写入(一次调用 = 一个 undo 单元) */
|
|
@@ -86,6 +107,17 @@ interface SheetContext {
|
|
|
86
107
|
id?: string;
|
|
87
108
|
}) => void): () => void;
|
|
88
109
|
}
|
|
110
|
+
/** createSheetContext 可选配置 */
|
|
111
|
+
interface SheetContextOptions {
|
|
112
|
+
/**
|
|
113
|
+
* 当前渲染网格尺寸(与 SheetGrid / resolveRenderSize 一致)。
|
|
114
|
+
* applyStyle / clearStyle 用其判定整行/整列;缺省时不走行列默认样式。
|
|
115
|
+
*/
|
|
116
|
+
resolveGridSize?: () => {
|
|
117
|
+
rows: number;
|
|
118
|
+
cols: number;
|
|
119
|
+
};
|
|
120
|
+
}
|
|
89
121
|
/**
|
|
90
122
|
* 创建工具上下文。
|
|
91
123
|
* @param resolveSheet 活动 sheet 解析器(USheet 传 `() => activeSheet`,
|
|
@@ -94,7 +126,8 @@ interface SheetContext {
|
|
|
94
126
|
* 支持传解析函数 `() => Workbook`——USheet 在 props.workbook 动态切换后,
|
|
95
127
|
* 上下文始终解析到**当前**工作簿(#2:旧实现取构造时值快照,宿主切换
|
|
96
128
|
* workbook prop 后导出工具仍导出旧工作簿)
|
|
129
|
+
* @param options.resolveGridSize 渲染尺寸解析器(整行/整列样式路由)
|
|
97
130
|
*/
|
|
98
|
-
declare function createSheetContext(resolveSheet: Sheet | (() => Sheet), workbook?: Workbook | (() => Workbook)): SheetContext;
|
|
131
|
+
declare function createSheetContext(resolveSheet: Sheet | (() => Sheet), workbook?: Workbook | (() => Workbook), options?: SheetContextOptions): SheetContext;
|
|
99
132
|
//#endregion
|
|
100
|
-
export { SheetContext, createSheetContext };
|
|
133
|
+
export { SheetContext, SheetContextOptions, createSheetContext };
|
package/dist/tools/context.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { axisStyleItemsForRange, classifySelectionStyleTarget } from "./apply-style.js";
|
|
1
2
|
//#region src/tools/context.ts
|
|
2
3
|
/**
|
|
3
4
|
* 创建工具上下文。
|
|
@@ -7,10 +8,16 @@
|
|
|
7
8
|
* 支持传解析函数 `() => Workbook`——USheet 在 props.workbook 动态切换后,
|
|
8
9
|
* 上下文始终解析到**当前**工作簿(#2:旧实现取构造时值快照,宿主切换
|
|
9
10
|
* workbook prop 后导出工具仍导出旧工作簿)
|
|
11
|
+
* @param options.resolveGridSize 渲染尺寸解析器(整行/整列样式路由)
|
|
10
12
|
*/
|
|
11
|
-
function createSheetContext(resolveSheet, workbook) {
|
|
13
|
+
function createSheetContext(resolveSheet, workbook, options) {
|
|
12
14
|
const sheet = typeof resolveSheet === "function" ? resolveSheet : () => resolveSheet;
|
|
13
15
|
const resolveWorkbook = typeof workbook === "function" ? workbook : workbook != null ? () => workbook : void 0;
|
|
16
|
+
const resolveGridSize = options?.resolveGridSize;
|
|
17
|
+
const resolveTarget = (range) => {
|
|
18
|
+
const size = resolveGridSize?.();
|
|
19
|
+
return size ? classifySelectionStyleTarget(range, size.rows, size.cols) : "cell";
|
|
20
|
+
};
|
|
14
21
|
return {
|
|
15
22
|
get workbook() {
|
|
16
23
|
return resolveWorkbook?.();
|
|
@@ -29,9 +36,39 @@ function createSheetContext(resolveSheet, workbook) {
|
|
|
29
36
|
setCells: (items) => sheet().setCells(items),
|
|
30
37
|
mergeCells: (range) => sheet().mergeCells(range),
|
|
31
38
|
unmergeCells: (range) => sheet().unmergeCells(range),
|
|
39
|
+
applyStyle: (range, partial) => {
|
|
40
|
+
const target = resolveTarget(range);
|
|
41
|
+
if (target === "row" || target === "col") {
|
|
42
|
+
const items = axisStyleItemsForRange(range, target, { partial });
|
|
43
|
+
if (items.length === 0) return;
|
|
44
|
+
sheet().executeCommand("sheet.command.set-axis-style", {
|
|
45
|
+
axis: target,
|
|
46
|
+
items
|
|
47
|
+
});
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
sheet().setCellStyle(range, partial);
|
|
51
|
+
},
|
|
52
|
+
resolveStyleTarget: (range) => resolveTarget(range),
|
|
53
|
+
clearStyle: (range) => {
|
|
54
|
+
const target = resolveTarget(range);
|
|
55
|
+
if (target === "row" || target === "col") {
|
|
56
|
+
const items = axisStyleItemsForRange(range, target, { clear: true });
|
|
57
|
+
if (items.length === 0) return;
|
|
58
|
+
sheet().executeCommand("sheet.command.set-axis-style", {
|
|
59
|
+
axis: target,
|
|
60
|
+
items
|
|
61
|
+
});
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
sheet().clearCellStyle(range);
|
|
65
|
+
},
|
|
32
66
|
setCellStyle: (range, partial) => sheet().setCellStyle(range, partial),
|
|
33
67
|
clearCellStyle: (range) => sheet().clearCellStyle(range),
|
|
68
|
+
setRowStyle: (row, partial) => sheet().setRowStyle(row, partial),
|
|
69
|
+
setColStyle: (col, partial) => sheet().setColStyle(col, partial),
|
|
34
70
|
getCellStyle: (addr) => sheet().getCellStyle(addr),
|
|
71
|
+
getEffectiveStyle: (addr) => sheet().getEffectiveStyle(addr),
|
|
35
72
|
executeCommand: (commandId, params) => sheet().executeCommand(commandId, params),
|
|
36
73
|
get frozen() {
|
|
37
74
|
return sheet().frozen;
|
|
@@ -24,6 +24,8 @@ interface ReportDesignerProps {
|
|
|
24
24
|
/** 报表设计器组件定义的事件 */
|
|
25
25
|
interface ReportDesignerEmits {
|
|
26
26
|
(e: 'update:connections', value: DataConnection[]): void;
|
|
27
|
+
/** 数据集增删改或数据中枢关闭:宿主可立即持久化工作区 */
|
|
28
|
+
(e: 'datasets-change'): void;
|
|
27
29
|
}
|
|
28
30
|
/** 在组件内部引用 */
|
|
29
31
|
interface _ReportDesignerExposed {
|
|
@@ -17,8 +17,8 @@ interface ReportViewerProps {
|
|
|
17
17
|
/** 承载填充报表的工作簿(USheet 先例:缺省内部自建单 sheet 工作簿) */
|
|
18
18
|
workbook?: Workbook;
|
|
19
19
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
20
|
+
* 列宽显式覆盖(可选):优先于模板 `colWidths` / 展开映射结果写入模型与网格。
|
|
21
|
+
* 列宽已进 `SheetSnapshot.colWidths`,通常无需再传。
|
|
22
22
|
*/
|
|
23
23
|
colWidths?: ReadonlyArray<ReportColWidthEntry>;
|
|
24
24
|
}
|
package/dist/types/sheet.d.ts
CHANGED
|
@@ -33,6 +33,10 @@ interface SheetProps {
|
|
|
33
33
|
showFormulaBar?: boolean;
|
|
34
34
|
/** 是否显示底部 sheet 标签栏,默认 true */
|
|
35
35
|
showTabs?: boolean;
|
|
36
|
+
/** 是否显示行号列,默认 true */
|
|
37
|
+
showRowHeader?: boolean;
|
|
38
|
+
/** 是否显示列字母表头,默认 true */
|
|
39
|
+
showColHeader?: boolean;
|
|
36
40
|
/** 只读预览(关闭编辑回写、填充柄等写入口) */
|
|
37
41
|
readonly?: boolean;
|
|
38
42
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@veltra/sheet",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"files": [
|
|
5
5
|
"dist",
|
|
6
6
|
"src"
|
|
@@ -30,12 +30,12 @@
|
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"@cat-kit/core": ">=1.1.8",
|
|
32
32
|
"@cat-kit/fe": ">=1.1.8",
|
|
33
|
-
"@veltra/compositions": "^1.
|
|
34
|
-
"@veltra/desktop": "^1.
|
|
33
|
+
"@veltra/compositions": "^1.6.0",
|
|
34
|
+
"@veltra/desktop": "^1.6.0",
|
|
35
35
|
"@veltra/icons": "^1.5.0",
|
|
36
|
-
"@veltra/sheet-core": "^2.
|
|
37
|
-
"@veltra/styles": "^1.
|
|
38
|
-
"@veltra/utils": "^1.
|
|
36
|
+
"@veltra/sheet-core": "^2.3.0",
|
|
37
|
+
"@veltra/styles": "^1.6.0",
|
|
38
|
+
"@veltra/utils": "^1.6.0",
|
|
39
39
|
"vue": ">=3.5.41"
|
|
40
40
|
}
|
|
41
41
|
}
|
|
@@ -72,6 +72,7 @@ describe('conditional-rules helpers', () => {
|
|
|
72
72
|
'本格字段',
|
|
73
73
|
'地区'
|
|
74
74
|
])
|
|
75
|
+
expect(ruleEvalFieldOptions('amount', fields).map((item) => item.value)).toEqual(['', 'region'])
|
|
75
76
|
expect(RULE_SCOPE_OPTIONS.map((item) => item.label)).toEqual(['本格', '整行'])
|
|
76
77
|
expect(resolveEvalFieldType({ operator: 'eq', value: '', style: {} }, 'amount', fields)).toBe(
|
|
77
78
|
'number'
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { SheetSnapshot } from '@veltra/sheet-core'
|
|
2
|
+
import { describe, expect, it } from 'vitest'
|
|
3
|
+
|
|
4
|
+
import { previewGridSize } from '../preview-grid-size'
|
|
5
|
+
|
|
6
|
+
function snap(
|
|
7
|
+
partial: Partial<SheetSnapshot> & Pick<SheetSnapshot, 'cells'>
|
|
8
|
+
): Pick<SheetSnapshot, 'cells' | 'merges' | 'meta' | 'rows'> {
|
|
9
|
+
return { merges: [], rows: 0, ...partial }
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
describe('previewGridSize', () => {
|
|
13
|
+
it('template 模式用内容包围盒,忽略设计态 canvas 尺寸', () => {
|
|
14
|
+
expect(
|
|
15
|
+
previewGridSize(
|
|
16
|
+
snap({
|
|
17
|
+
cells: [
|
|
18
|
+
{ row: 0, col: 0, v: '客户' },
|
|
19
|
+
{ row: 0, col: 1, v: '金额' }
|
|
20
|
+
],
|
|
21
|
+
rows: 24,
|
|
22
|
+
cols: 10
|
|
23
|
+
}),
|
|
24
|
+
'template'
|
|
25
|
+
)
|
|
26
|
+
).toEqual({ rows: 1, cols: 2 })
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
it('filled 模式行保留展开布局尺寸,列按包围盒收敛(去掉设计态撑大的列)', () => {
|
|
30
|
+
expect(
|
|
31
|
+
previewGridSize(
|
|
32
|
+
snap({
|
|
33
|
+
cells: [
|
|
34
|
+
{ row: 0, col: 0, v: '客户' },
|
|
35
|
+
{ row: 3, col: 1, v: 300 }
|
|
36
|
+
],
|
|
37
|
+
rows: 4,
|
|
38
|
+
cols: 10
|
|
39
|
+
}),
|
|
40
|
+
'filled'
|
|
41
|
+
)
|
|
42
|
+
).toEqual({ rows: 4, cols: 2 })
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
it('空快照至少 1×1(VTable 需要非零网格)', () => {
|
|
46
|
+
expect(previewGridSize(snap({ cells: [] }), 'template')).toEqual({ rows: 1, cols: 1 })
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
it('包围盒计入合并区终点与 meta 绑定格', () => {
|
|
50
|
+
expect(
|
|
51
|
+
previewGridSize(
|
|
52
|
+
snap({
|
|
53
|
+
cells: [{ row: 0, col: 0, v: '标题' }],
|
|
54
|
+
merges: [{ start: { row: 0, col: 0 }, end: { row: 0, col: 2 } }],
|
|
55
|
+
meta: [{ row: 2, col: 1, namespace: 'report', payload: {} }],
|
|
56
|
+
rows: 24,
|
|
57
|
+
cols: 10
|
|
58
|
+
}),
|
|
59
|
+
'template'
|
|
60
|
+
)
|
|
61
|
+
).toEqual({ rows: 3, cols: 3 })
|
|
62
|
+
})
|
|
63
|
+
})
|
|
@@ -386,3 +386,79 @@ describe('UReportDesigner 全量:template 载入与预览模式(内嵌查看
|
|
|
386
386
|
overlaySpy.mockRestore()
|
|
387
387
|
})
|
|
388
388
|
})
|
|
389
|
+
|
|
390
|
+
describe('UReportDesigner Action Pill', () => {
|
|
391
|
+
const overlayRect = {
|
|
392
|
+
left: 10,
|
|
393
|
+
top: 80,
|
|
394
|
+
right: 90,
|
|
395
|
+
bottom: 104,
|
|
396
|
+
width: 80,
|
|
397
|
+
height: 24,
|
|
398
|
+
centerX: 50,
|
|
399
|
+
centerY: 92
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
function spyOverlay() {
|
|
403
|
+
const layoutSpy = vi
|
|
404
|
+
.spyOn(cellCoords, 'resolveGridOverlayLayout')
|
|
405
|
+
.mockReturnValue({
|
|
406
|
+
gridEl: document.createElement('div'),
|
|
407
|
+
layout: { offsetX: 0, offsetY: 77, viewW: 640, viewH: 400 }
|
|
408
|
+
})
|
|
409
|
+
const overlaySpy = vi.spyOn(gridOverlay, 'readCellOverlayRect').mockReturnValue(overlayRect)
|
|
410
|
+
return () => {
|
|
411
|
+
layoutSpy.mockRestore()
|
|
412
|
+
overlaySpy.mockRestore()
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
it('小计预设默认条显示聚合、隐藏展开方向,并提供删除绑定', async () => {
|
|
417
|
+
const workbook = new Workbook()
|
|
418
|
+
workbook.activeSheet.setCellMeta({ row: 0, col: 0 }, REPORT_META_NAMESPACE, {
|
|
419
|
+
dataset: 'ds',
|
|
420
|
+
field: 'amount',
|
|
421
|
+
aggregate: 'sum',
|
|
422
|
+
expand: 'none',
|
|
423
|
+
preset: 'subtotal'
|
|
424
|
+
} satisfies ReportBinding)
|
|
425
|
+
workbook.activeSheet.selectCell({ row: 0, col: 0 })
|
|
426
|
+
|
|
427
|
+
const restore = spyOverlay()
|
|
428
|
+
const { el } = mountDesigner(workbook)
|
|
429
|
+
await flush()
|
|
430
|
+
|
|
431
|
+
const panel = el.querySelector('.u-report-float-panel')
|
|
432
|
+
expect(panel).toBeTruthy()
|
|
433
|
+
expect(panel!.querySelector('.u-report-float-panel__body')).toBeNull()
|
|
434
|
+
expect(panel!.querySelector('.u-report-float-panel__select--aggregate')).toBeTruthy()
|
|
435
|
+
expect(panel!.querySelector('.u-report-float-panel__select--expand')).toBeNull()
|
|
436
|
+
const deleteBtn = [...panel!.querySelectorAll('button')].find((button) =>
|
|
437
|
+
button.textContent?.includes('删除绑定')
|
|
438
|
+
)
|
|
439
|
+
expect(deleteBtn).toBeTruthy()
|
|
440
|
+
restore()
|
|
441
|
+
})
|
|
442
|
+
|
|
443
|
+
it('明细预设默认条显示展开方向、隐藏聚合', async () => {
|
|
444
|
+
const workbook = new Workbook()
|
|
445
|
+
workbook.activeSheet.setCellMeta({ row: 0, col: 0 }, REPORT_META_NAMESPACE, {
|
|
446
|
+
dataset: 'ds',
|
|
447
|
+
field: 'orderNo',
|
|
448
|
+
aggregate: 'list',
|
|
449
|
+
expand: 'down',
|
|
450
|
+
preset: 'detail'
|
|
451
|
+
} satisfies ReportBinding)
|
|
452
|
+
workbook.activeSheet.selectCell({ row: 0, col: 0 })
|
|
453
|
+
|
|
454
|
+
const restore = spyOverlay()
|
|
455
|
+
const { el } = mountDesigner(workbook)
|
|
456
|
+
await flush()
|
|
457
|
+
|
|
458
|
+
const panel = el.querySelector('.u-report-float-panel')
|
|
459
|
+
expect(panel).toBeTruthy()
|
|
460
|
+
expect(panel!.querySelector('.u-report-float-panel__select--expand')).toBeTruthy()
|
|
461
|
+
expect(panel!.querySelector('.u-report-float-panel__select--aggregate')).toBeNull()
|
|
462
|
+
restore()
|
|
463
|
+
})
|
|
464
|
+
})
|
|
@@ -8,7 +8,7 @@ import type { DataConnection, DataConnector } from '../../../report/connector'
|
|
|
8
8
|
import { createReportTemplate } from '../../../report/template'
|
|
9
9
|
import type { ReportDatasetDef, ReportTemplate } from '../../../report/template'
|
|
10
10
|
import type { ParamValues, ReportBinding } from '../../../report/types'
|
|
11
|
-
import type { ReportViewerExposed } from '../../../types'
|
|
11
|
+
import type { ReportViewerExposed, SheetExposed } from '../../../types'
|
|
12
12
|
|
|
13
13
|
// ---- 内联 fixtures:stub connector(实现 DataConnector 接口的内存测试夹具)----
|
|
14
14
|
|
|
@@ -91,6 +91,8 @@ function createViewerTemplate(datasets: ReportDatasetDef[] = [ORDERS_DATASET]):
|
|
|
91
91
|
}
|
|
92
92
|
sheet.setCellMeta({ row: 1, col: 1 }, REPORT_META_NAMESPACE, amount)
|
|
93
93
|
|
|
94
|
+
// 模拟设计态 canvas(旧预览用 max(50×10, 快照) 会铺出空白格)
|
|
95
|
+
sheet.ensureTableSize(50, 10)
|
|
94
96
|
return createReportTemplate(sheet.snapshot(), datasets)
|
|
95
97
|
}
|
|
96
98
|
|
|
@@ -158,6 +160,14 @@ function mountViewer(props: {
|
|
|
158
160
|
return { app, el, exposedRef }
|
|
159
161
|
}
|
|
160
162
|
|
|
163
|
+
/** 内嵌 USheet 的 SheetGrid(报表预览断言行列头 / 渲染尺寸) */
|
|
164
|
+
function nestedSheetGrid(el: HTMLElement) {
|
|
165
|
+
const sheetEl = el.querySelector('.u-sheet') as
|
|
166
|
+
| (HTMLElement & { __vueParentComponent?: { exposed?: SheetExposed } })
|
|
167
|
+
| null
|
|
168
|
+
return sheetEl?.__vueParentComponent?.exposed?.getGrid()
|
|
169
|
+
}
|
|
170
|
+
|
|
161
171
|
/** 等待取数(宏/微任务)+ 填充快照应用(watch + nextTick)落定 */
|
|
162
172
|
async function flushViewer(): Promise<void> {
|
|
163
173
|
await nextTick()
|
|
@@ -201,6 +211,19 @@ describe('UReportViewer', () => {
|
|
|
201
211
|
expect(sheet.getCellData({ row: 2, col: 1 })?.v).toBe(200)
|
|
202
212
|
expect(sheet.getDisplayValue({ row: 3, col: 0 })).toBe('乙公司')
|
|
203
213
|
expect(sheet.getCellData({ row: 3, col: 1 })?.v).toBe(300)
|
|
214
|
+
|
|
215
|
+
// 网格铺到内容尺寸(表头 + 3 明细行 × 2 列),不再用 50×10 下限
|
|
216
|
+
expect(sheet.rows).toBe(4)
|
|
217
|
+
expect(sheet.cols).toBe(2)
|
|
218
|
+
|
|
219
|
+
const table = nestedSheetGrid(el)!.getTable()
|
|
220
|
+
expect(table.options.showHeader).toBe(false)
|
|
221
|
+
expect(table.options.rowSeriesNumber).toBeUndefined()
|
|
222
|
+
expect(table.columnHeaderLevelCount).toBe(0)
|
|
223
|
+
expect(table.rowCount).toBe(4)
|
|
224
|
+
expect(table.colCount).toBe(2)
|
|
225
|
+
// 无行号/列头偏移:表格 (0,0) 即模型 A1
|
|
226
|
+
expect(table.getCellValue(0, 0)).toBe('客户')
|
|
204
227
|
})
|
|
205
228
|
|
|
206
229
|
it('Filter Bar 改值重新取数,其余参数值保留', async () => {
|