@borurio-print/print-designer 1.0.6 → 1.0.7

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.
@@ -1,17 +1,19 @@
1
- import type { BusinessFieldGroup, PrintResult, PrintTemplate } from '@/core/types';
1
+ import type { BusinessFieldGroup, PrintRequest, PrintResult, PrintTemplate, PrintDesignerTheme } from '@/core/types';
2
2
  type __VLS_Props = {
3
3
  /**
4
4
  * 由业务系统提供的可打印字段目录。
5
5
  * 设计器只保存字段路径和用户最终选择的展示类型,不感知 WMS、OMS 业务含义。
6
6
  */
7
7
  fieldGroups?: readonly BusinessFieldGroup[];
8
+ /** 当前设计器实例使用的主色主题。 */
9
+ theme?: PrintDesignerTheme;
8
10
  };
9
11
  declare function getTemplate(): PrintTemplate;
10
12
  declare function loadTemplate(template: PrintTemplate): void;
11
- /** 供业务系统获取 PDF Blob,后续可直接传给本地打印控件。 */
12
- declare function generatePdf(data: unknown): Promise<Blob>;
13
- /** 供业务系统直接在浏览器中打开数据打印预览。 */
14
- declare function previewPdf(data: unknown): Promise<void>;
13
+ /** 供业务系统生成 PDF,结果统一通过 print-result 事件通知。 */
14
+ declare function generatePdf(request: PrintRequest): Promise<void>;
15
+ /** 供业务系统打开 PDF 预览,结果统一通过 print-result 事件通知。 */
16
+ declare function previewPdf(request: PrintRequest): Promise<void>;
15
17
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {
16
18
  getTemplate: typeof getTemplate;
17
19
  loadTemplate: typeof loadTemplate;
@@ -0,0 +1,6 @@
1
+ import { type ComputedRef, type CSSProperties, type InjectionKey } from 'vue';
2
+ import type { PrintDesignerTheme } from './types';
3
+ export type PrintDesignerThemeStyle = CSSProperties & Record<`--bpd-${string}`, string>;
4
+ export declare const printDesignerThemeStyleKey: InjectionKey<ComputedRef<PrintDesignerThemeStyle>>;
5
+ export declare function createPrintDesignerThemeStyle(theme?: PrintDesignerTheme): PrintDesignerThemeStyle;
6
+ export declare function usePrintDesignerThemeStyle(): ComputedRef<PrintDesignerThemeStyle>;
@@ -36,13 +36,25 @@ export interface PrintRenderPage {
36
36
  data?: Record<string, unknown>;
37
37
  tableData: Record<string, TableRuntimeData>;
38
38
  }
39
- /** 设计器完成 PDF 预览或内部测试打印后通知业务系统的结果。 */
39
+ /** 业务系统发起一次 PDF 生成或预览的请求。 */
40
+ export interface PrintRequest<T = unknown> {
41
+ /** 由调用方生成,用于将异步结果与请求一一对应。 */
42
+ requestId: string;
43
+ data: T;
44
+ /** 只有显式需要获取 PDF 文件时才设置为 true。 */
45
+ returnBlob?: boolean;
46
+ }
47
+ /** 设计器完成 PDF 生成或预览后通过 print-result 通知的结果。 */
40
48
  export interface PrintResult {
41
- success: boolean;
42
- action: 'preview' | 'testPrint';
43
- pageCount: number;
44
- blob?: Blob;
45
- error?: unknown;
49
+ requestId: string;
50
+ result: 'success' | 'failed';
51
+ /** 成功固定为 ok,失败时为可展示的错误信息。 */
52
+ message: string;
53
+ data?: {
54
+ pageCount: number;
55
+ /** 只在请求中指定 returnBlob: true 时返回。 */
56
+ blob?: Blob;
57
+ };
46
58
  }
47
59
  /** 业务字段目前允许在标签中使用的三种展示方式。 */
48
60
  export type FieldElementType = 'text' | 'textBox' | 'qrcode' | 'barcode';
@@ -62,6 +74,17 @@ export interface BusinessFieldGroup {
62
74
  label: string;
63
75
  fields: readonly BusinessField[];
64
76
  }
77
+ /** 业务系统可为每个设计器实例单独配置的主色主题。 */
78
+ export interface PrintDesignerTheme {
79
+ /** 主色;未传入衍生色时,设计器会自动生成对应的明暗色阶。 */
80
+ primaryColor?: string;
81
+ primaryLight3?: string;
82
+ primaryLight5?: string;
83
+ primaryLight7?: string;
84
+ primaryLight8?: string;
85
+ primaryLight9?: string;
86
+ primaryDark2?: string;
87
+ }
65
88
  /**
66
89
  * 设计器支持的组件类型。
67
90
  *