@gct-paas/word 0.1.24 → 0.1.26
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/core/constants/index.d.ts +0 -1
- package/dist/core/layout/handlers/fields/FieldBaseHandler.d.ts +2 -0
- package/dist/core/view/Doc.d.ts +5 -1
- package/dist/core/view/runs/TextRun.d.ts +6 -0
- package/dist/core/view/utils/TextUtil.d.ts +12 -28
- package/dist/index.es.js +304 -324
- package/dist/runtime/interface/render.d.ts +0 -6
- package/dist/sdk/doc-runtime/composables/useDocOperations.d.ts +8 -1
- package/dist/sdk/doc-runtime/factories/useDocumentFactory.d.ts +5 -0
- package/dist/sdk/engine/index.d.ts +2 -1
- package/dist/sdk/types/index.d.ts +17 -7
- package/dist/utils/func/form.d.ts +2 -0
- package/package.json +1 -1
|
@@ -60,7 +60,6 @@ export declare const DEFAULT_PAGE_SIZE: {
|
|
|
60
60
|
export declare const DEFAULT_PAGE_PADDING: [number, number, number, number];
|
|
61
61
|
export declare const DEFAULT_CELL_PADDING: [number, number, number, number];
|
|
62
62
|
export declare const DEFAULT_FONT_SIZE = 16;
|
|
63
|
-
/** 回退链在不同 OS 上可能命中不同实体字体;跨平台一致布局请配合 Web 字体加载与 TextUtil.awaitDocumentFonts() */
|
|
64
63
|
export declare const DEFAULT_FONT_FAMILY = "Roboto,RobotoDraft,Helvetica,Arial,sans-serif";
|
|
65
64
|
export declare const DEFAULT_TEXT_COLOR = "black";
|
|
66
65
|
export declare const ZERO_WIDTH_SPACE = "\u200B";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { WrText } from '../../../model/document';
|
|
2
2
|
import { LayoutContext } from '../../LayoutContext';
|
|
3
|
+
import { TextRun } from '../../../view/runs/TextRun';
|
|
3
4
|
import { TextWidget } from '../../../view/runs/TextWidget';
|
|
4
5
|
import { HandlerContext } from '../../types';
|
|
5
6
|
type ValueType = string | number | undefined | null;
|
|
@@ -50,6 +51,7 @@ export declare class FieldBaseHandler {
|
|
|
50
51
|
ctx: HandlerContext;
|
|
51
52
|
fontSize: number;
|
|
52
53
|
label: string;
|
|
54
|
+
layoutStyle?: Partial<TextRun>;
|
|
53
55
|
extra?: Partial<TextWidget>;
|
|
54
56
|
}): void;
|
|
55
57
|
/**
|
package/dist/core/view/Doc.d.ts
CHANGED
|
@@ -18,6 +18,8 @@ export interface DocInitOptions {
|
|
|
18
18
|
mainModelKey: ModelKey;
|
|
19
19
|
/** 文档运行时元信息(接口数据 + 业务数据) */
|
|
20
20
|
docRuntimeMeta: DocRuntimeMeta;
|
|
21
|
+
/** 按钮区渲染模式 */
|
|
22
|
+
btnRenderModeType: DocModeType;
|
|
21
23
|
formType: string;
|
|
22
24
|
paramsConfig: Record<string, any>;
|
|
23
25
|
pageSize?: {
|
|
@@ -37,6 +39,8 @@ export declare class Doc {
|
|
|
37
39
|
id: string;
|
|
38
40
|
/** 渲染模式 */
|
|
39
41
|
mode: DocModeType;
|
|
42
|
+
/** 按钮区渲染模式 */
|
|
43
|
+
btnRenderModeType: DocModeType;
|
|
40
44
|
/** 是否是设计器预览模式 */
|
|
41
45
|
preview: boolean;
|
|
42
46
|
model?: DocModel;
|
|
@@ -92,7 +96,7 @@ export declare class Doc {
|
|
|
92
96
|
getFirstPage(): Page | null;
|
|
93
97
|
getLastPage(): Page | null;
|
|
94
98
|
setModel(model: DocModel): void;
|
|
95
|
-
setMode(modeType: DocModeType): void;
|
|
99
|
+
setMode(modeType: DocModeType, updateButton?: boolean): void;
|
|
96
100
|
/** 触发布局计算 */
|
|
97
101
|
layout(): void;
|
|
98
102
|
/** 渲染文档 */
|
|
@@ -97,6 +97,12 @@ export declare class TextRun extends LayoutNode implements ITextRun {
|
|
|
97
97
|
descent: number;
|
|
98
98
|
style?: TextStyle;
|
|
99
99
|
constructor(options: TextRunOptions);
|
|
100
|
+
/**
|
|
101
|
+
* 构建与 Konva 渲染一致的度量参数。
|
|
102
|
+
* 须与段落 layout 使用的 TextRun 样式一致;若只传 fontSize 会按默认字体度量,
|
|
103
|
+
* 加粗/自定义字体后 advance 偏窄,易出现字母叠画。
|
|
104
|
+
*/
|
|
105
|
+
static measurePayload(text: string, layoutStyle?: Partial<TextRun>): Konva.TextConfig;
|
|
100
106
|
/**
|
|
101
107
|
* 计算文字大小 度量
|
|
102
108
|
* 优化版本
|
|
@@ -18,14 +18,14 @@ export declare class TextUtil {
|
|
|
18
18
|
* - kg·m²
|
|
19
19
|
* 等符号贴太近的问题
|
|
20
20
|
*/
|
|
21
|
+
/**
|
|
22
|
+
* 中间点类:CoreText / DirectWrite 下 advance 常偏窄,仅靠较小 ratio 仍可能与字母叠画;
|
|
23
|
+
* 在 getVisualSpacing 内另有 em 下限(与平台无关)。
|
|
24
|
+
*/
|
|
25
|
+
private static readonly MIDDLE_DOT_EXTRA_FLOOR_EM;
|
|
21
26
|
private static readonly VISUAL_SPACING_MAP;
|
|
22
27
|
private static fontMetricsCache;
|
|
23
28
|
private static layoutSizeCache;
|
|
24
|
-
/**
|
|
25
|
-
* 等待文档字体就绪后再做 Canvas 度量,可减轻 Mac/Windows 因 Web 字体未加载导致的度量差异。
|
|
26
|
-
* 无 Font Loading API 时立即 resolve。
|
|
27
|
-
*/
|
|
28
|
-
static awaitDocumentFonts(): Promise<void>;
|
|
29
29
|
/**
|
|
30
30
|
* 验证中文字符
|
|
31
31
|
* @param char
|
|
@@ -56,32 +56,16 @@ export declare class TextUtil {
|
|
|
56
56
|
* @param fontSize
|
|
57
57
|
* @returns
|
|
58
58
|
*/
|
|
59
|
+
/** 数学/单位中间的点号(不含列表圆点 •) */
|
|
60
|
+
private static isMiddleDotSpacingChar;
|
|
59
61
|
static getVisualSpacing(char: string, fontSize: number): number;
|
|
60
|
-
/** 与度量路径一致:lineHeight 固定为 1 的样式副本 */
|
|
61
|
-
private static measureBase;
|
|
62
62
|
/**
|
|
63
|
-
*
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
* 布局缓存键:样式签名 + 编码后的文本
|
|
68
|
-
*/
|
|
69
|
-
private static layoutCacheKey;
|
|
70
|
-
private static touchLru;
|
|
71
|
-
private static evictOldestIfFull;
|
|
72
|
-
/**
|
|
73
|
-
* 单次 Konva.Text 计算 width / height(advance width 含视觉间距)
|
|
74
|
-
*/
|
|
75
|
-
private static computeLayoutSizeUncached;
|
|
76
|
-
/**
|
|
77
|
-
* 一次度量:布局宽高 + 字体 ascent/descent(双缓存均未命中时只创建一个 Konva.Text)
|
|
63
|
+
* 生成文本度量缓存键
|
|
64
|
+
* @param payload
|
|
65
|
+
* @param includeText
|
|
66
|
+
* @returns
|
|
78
67
|
*/
|
|
79
|
-
static
|
|
80
|
-
width: number;
|
|
81
|
-
height: number;
|
|
82
|
-
ascent: number;
|
|
83
|
-
descent: number;
|
|
84
|
-
};
|
|
68
|
+
private static getMeasureCacheKey;
|
|
85
69
|
/**
|
|
86
70
|
* 计算字体度量
|
|
87
71
|
* ascent / descent
|
package/dist/index.es.js
CHANGED
|
@@ -26693,31 +26693,28 @@ class TextUtil {
|
|
|
26693
26693
|
* - kg·m²
|
|
26694
26694
|
* 等符号贴太近的问题
|
|
26695
26695
|
*/
|
|
26696
|
+
/**
|
|
26697
|
+
* 中间点类:CoreText / DirectWrite 下 advance 常偏窄,仅靠较小 ratio 仍可能与字母叠画;
|
|
26698
|
+
* 在 getVisualSpacing 内另有 em 下限(与平台无关)。
|
|
26699
|
+
*/
|
|
26700
|
+
static MIDDLE_DOT_EXTRA_FLOOR_EM = 0.24;
|
|
26696
26701
|
static VISUAL_SPACING_MAP = {
|
|
26697
26702
|
"·": 0.24,
|
|
26698
26703
|
"•": 0.24,
|
|
26699
|
-
"
|
|
26700
|
-
|
|
26701
|
-
"
|
|
26702
|
-
|
|
26703
|
-
"
|
|
26704
|
+
"⋅": 0.24,
|
|
26705
|
+
// ⋅ DOT OPERATOR(常见于 N⋅m 等)
|
|
26706
|
+
"∙": 0.24,
|
|
26707
|
+
// ∙ BULLET OPERATOR
|
|
26708
|
+
"·": 0.24,
|
|
26709
|
+
// · GREEK ANO TELEIA,易与 · 混用
|
|
26710
|
+
"/": 0.2,
|
|
26711
|
+
"/": 0.2,
|
|
26712
|
+
"|": 0.16,
|
|
26713
|
+
":": 0.12,
|
|
26714
|
+
":": 0.12
|
|
26704
26715
|
};
|
|
26705
26716
|
static fontMetricsCache = /* @__PURE__ */ new Map();
|
|
26706
26717
|
static layoutSizeCache = /* @__PURE__ */ new Map();
|
|
26707
|
-
/**
|
|
26708
|
-
* 等待文档字体就绪后再做 Canvas 度量,可减轻 Mac/Windows 因 Web 字体未加载导致的度量差异。
|
|
26709
|
-
* 无 Font Loading API 时立即 resolve。
|
|
26710
|
-
*/
|
|
26711
|
-
static awaitDocumentFonts() {
|
|
26712
|
-
if (typeof document === "undefined") {
|
|
26713
|
-
return Promise.resolve();
|
|
26714
|
-
}
|
|
26715
|
-
const fonts = document.fonts;
|
|
26716
|
-
if (!fonts || typeof fonts.ready?.then !== "function") {
|
|
26717
|
-
return Promise.resolve();
|
|
26718
|
-
}
|
|
26719
|
-
return fonts.ready;
|
|
26720
|
-
}
|
|
26721
26718
|
/**
|
|
26722
26719
|
* 验证中文字符
|
|
26723
26720
|
* @param char
|
|
@@ -26755,119 +26752,41 @@ class TextUtil {
|
|
|
26755
26752
|
* @param fontSize
|
|
26756
26753
|
* @returns
|
|
26757
26754
|
*/
|
|
26755
|
+
/** 数学/单位中间的点号(不含列表圆点 •) */
|
|
26756
|
+
static isMiddleDotSpacingChar(char) {
|
|
26757
|
+
return char === "·" || // · MIDDLE DOT
|
|
26758
|
+
char === "⋅" || // ⋅ DOT OPERATOR
|
|
26759
|
+
char === "∙" || // ∙ BULLET OPERATOR
|
|
26760
|
+
char === "·";
|
|
26761
|
+
}
|
|
26758
26762
|
static getVisualSpacing(char, fontSize2) {
|
|
26759
26763
|
const ratio = this.VISUAL_SPACING_MAP[char];
|
|
26760
26764
|
if (!ratio) {
|
|
26761
26765
|
return 0;
|
|
26762
26766
|
}
|
|
26763
|
-
|
|
26764
|
-
|
|
26765
|
-
|
|
26766
|
-
static measureBase(payload) {
|
|
26767
|
-
return Object.assign({}, payload, { lineHeight: 1 });
|
|
26768
|
-
}
|
|
26769
|
-
/**
|
|
26770
|
-
* 字体级缓存键(不含 text),与 getFontMetrics 语义一致
|
|
26771
|
-
*/
|
|
26772
|
-
static measureStyleKey(payload) {
|
|
26773
|
-
const c2 = this.measureBase(payload);
|
|
26774
|
-
return [
|
|
26775
|
-
c2.fontSize ?? "",
|
|
26776
|
-
c2.fontFamily ?? "",
|
|
26777
|
-
c2.fontStyle ?? "",
|
|
26778
|
-
c2.fontVariant ?? "",
|
|
26779
|
-
c2.lineHeight ?? "",
|
|
26780
|
-
c2.padding ?? "",
|
|
26781
|
-
c2.letterSpacing ?? ""
|
|
26782
|
-
].join("");
|
|
26783
|
-
}
|
|
26784
|
-
/**
|
|
26785
|
-
* 布局缓存键:样式签名 + 编码后的文本
|
|
26786
|
-
*/
|
|
26787
|
-
static layoutCacheKey(payload) {
|
|
26788
|
-
const c2 = this.measureBase(payload);
|
|
26789
|
-
return `${this.measureStyleKey(payload)}${encodeURIComponent(c2.text ?? "")}`;
|
|
26790
|
-
}
|
|
26791
|
-
static touchLru(map2, key, value) {
|
|
26792
|
-
map2.delete(key);
|
|
26793
|
-
map2.set(key, value);
|
|
26794
|
-
}
|
|
26795
|
-
static evictOldestIfFull(map2, limit) {
|
|
26796
|
-
if (map2.size >= limit) {
|
|
26797
|
-
const firstKey = map2.keys().next().value;
|
|
26798
|
-
map2.delete(firstKey);
|
|
26767
|
+
let space = fontSize2 * ratio;
|
|
26768
|
+
if (this.isMiddleDotSpacingChar(char)) {
|
|
26769
|
+
space = Math.max(space, fontSize2 * this.MIDDLE_DOT_EXTRA_FLOOR_EM);
|
|
26799
26770
|
}
|
|
26771
|
+
return space;
|
|
26800
26772
|
}
|
|
26801
26773
|
/**
|
|
26802
|
-
*
|
|
26803
|
-
|
|
26804
|
-
|
|
26805
|
-
|
|
26806
|
-
const text = new Konva.Text(config);
|
|
26807
|
-
const char = payload.text ?? "";
|
|
26808
|
-
const fontSize2 = payload.fontSize ?? 0;
|
|
26809
|
-
const width = this.isFullWidthChar(char) ? fontSize2 : text.width() + this.getVisualSpacing(char, fontSize2);
|
|
26810
|
-
return {
|
|
26811
|
-
width,
|
|
26812
|
-
height: text.height()
|
|
26813
|
-
};
|
|
26814
|
-
}
|
|
26815
|
-
/**
|
|
26816
|
-
* 一次度量:布局宽高 + 字体 ascent/descent(双缓存均未命中时只创建一个 Konva.Text)
|
|
26774
|
+
* 生成文本度量缓存键
|
|
26775
|
+
* @param payload
|
|
26776
|
+
* @param includeText
|
|
26777
|
+
* @returns
|
|
26817
26778
|
*/
|
|
26818
|
-
static
|
|
26819
|
-
|
|
26820
|
-
|
|
26821
|
-
|
|
26822
|
-
|
|
26823
|
-
|
|
26824
|
-
|
|
26825
|
-
|
|
26826
|
-
|
|
26827
|
-
|
|
26828
|
-
|
|
26829
|
-
ascent: fontCached.ascent,
|
|
26830
|
-
descent: fontCached.descent
|
|
26831
|
-
};
|
|
26832
|
-
}
|
|
26833
|
-
if (layoutCached && !fontCached) {
|
|
26834
|
-
this.touchLru(this.layoutSizeCache, layoutKey, layoutCached);
|
|
26835
|
-
const { ascent: ascent2, descent: descent2 } = this.getFontMetrics(payload);
|
|
26836
|
-
return {
|
|
26837
|
-
width: layoutCached.width,
|
|
26838
|
-
height: layoutCached.height,
|
|
26839
|
-
ascent: ascent2,
|
|
26840
|
-
descent: descent2
|
|
26841
|
-
};
|
|
26842
|
-
}
|
|
26843
|
-
if (!layoutCached && fontCached) {
|
|
26844
|
-
const layout2 = this.computeLayoutSizeUncached(payload);
|
|
26845
|
-
this.evictOldestIfFull(this.layoutSizeCache, this.LAYOUT_SIZE_CACHE_LIMIT);
|
|
26846
|
-
this.layoutSizeCache.set(layoutKey, layout2);
|
|
26847
|
-
this.touchLru(this.fontMetricsCache, fontKey, fontCached);
|
|
26848
|
-
return {
|
|
26849
|
-
width: layout2.width,
|
|
26850
|
-
height: layout2.height,
|
|
26851
|
-
ascent: fontCached.ascent,
|
|
26852
|
-
descent: fontCached.descent
|
|
26853
|
-
};
|
|
26854
|
-
}
|
|
26855
|
-
const config = this.measureBase(payload);
|
|
26856
|
-
const text = new Konva.Text(config);
|
|
26857
|
-
const char = payload.text ?? "";
|
|
26858
|
-
const fontSize2 = payload.fontSize ?? 0;
|
|
26859
|
-
const width = this.isFullWidthChar(char) ? fontSize2 : text.width() + this.getVisualSpacing(char, fontSize2);
|
|
26860
|
-
const height = text.height();
|
|
26861
|
-
const sizeHg = text.measureSize("Hg");
|
|
26862
|
-
const ascent = sizeHg.actualBoundingBoxAscent;
|
|
26863
|
-
const descent = sizeHg.actualBoundingBoxDescent;
|
|
26864
|
-
const layout = { width, height };
|
|
26865
|
-
const font = { ascent, descent };
|
|
26866
|
-
this.evictOldestIfFull(this.layoutSizeCache, this.LAYOUT_SIZE_CACHE_LIMIT);
|
|
26867
|
-
this.evictOldestIfFull(this.fontMetricsCache, this.FONT_METRICS_CACHE_LIMIT);
|
|
26868
|
-
this.layoutSizeCache.set(layoutKey, layout);
|
|
26869
|
-
this.fontMetricsCache.set(fontKey, font);
|
|
26870
|
-
return { width, height, ascent, descent };
|
|
26779
|
+
static getMeasureCacheKey(payload, includeText = true) {
|
|
26780
|
+
return JSON.stringify({
|
|
26781
|
+
text: includeText ? payload.text ?? "" : "",
|
|
26782
|
+
fontSize: payload.fontSize ?? "",
|
|
26783
|
+
fontFamily: payload.fontFamily ?? "",
|
|
26784
|
+
fontStyle: payload.fontStyle ?? "",
|
|
26785
|
+
fontVariant: payload.fontVariant ?? "",
|
|
26786
|
+
lineHeight: payload.lineHeight ?? "",
|
|
26787
|
+
padding: payload.padding ?? "",
|
|
26788
|
+
letterSpacing: payload.letterSpacing ?? ""
|
|
26789
|
+
});
|
|
26871
26790
|
}
|
|
26872
26791
|
/**
|
|
26873
26792
|
* 计算字体度量
|
|
@@ -26882,10 +26801,11 @@ class TextUtil {
|
|
|
26882
26801
|
text: targetText,
|
|
26883
26802
|
lineHeight: 1
|
|
26884
26803
|
});
|
|
26885
|
-
const cacheKey = this.
|
|
26804
|
+
const cacheKey = this.getMeasureCacheKey(config, false);
|
|
26886
26805
|
if (this.fontMetricsCache.has(cacheKey)) {
|
|
26887
26806
|
const result2 = this.fontMetricsCache.get(cacheKey);
|
|
26888
|
-
this.
|
|
26807
|
+
this.fontMetricsCache.delete(cacheKey);
|
|
26808
|
+
this.fontMetricsCache.set(cacheKey, result2);
|
|
26889
26809
|
return result2;
|
|
26890
26810
|
}
|
|
26891
26811
|
const text = new Konva.Text(config);
|
|
@@ -26894,7 +26814,10 @@ class TextUtil {
|
|
|
26894
26814
|
ascent: size.actualBoundingBoxAscent,
|
|
26895
26815
|
descent: size.actualBoundingBoxDescent
|
|
26896
26816
|
};
|
|
26897
|
-
|
|
26817
|
+
if (this.fontMetricsCache.size >= this.FONT_METRICS_CACHE_LIMIT) {
|
|
26818
|
+
const firstKey = this.fontMetricsCache.keys().next().value;
|
|
26819
|
+
this.fontMetricsCache.delete(firstKey);
|
|
26820
|
+
}
|
|
26898
26821
|
this.fontMetricsCache.set(cacheKey, result);
|
|
26899
26822
|
return result;
|
|
26900
26823
|
}
|
|
@@ -26923,7 +26846,13 @@ class TextUtil {
|
|
|
26923
26846
|
if (this.isFullWidthChar(char)) {
|
|
26924
26847
|
return fontSize2;
|
|
26925
26848
|
}
|
|
26926
|
-
|
|
26849
|
+
const config = Object.assign({}, payload, {
|
|
26850
|
+
lineHeight: 1
|
|
26851
|
+
});
|
|
26852
|
+
const text = new Konva.Text(config);
|
|
26853
|
+
const glyphWidth = text.width();
|
|
26854
|
+
const visualSpacing = this.getVisualSpacing(char, fontSize2);
|
|
26855
|
+
return glyphWidth + visualSpacing;
|
|
26927
26856
|
}
|
|
26928
26857
|
/**
|
|
26929
26858
|
* 计算单字符布局大小
|
|
@@ -26935,16 +26864,27 @@ class TextUtil {
|
|
|
26935
26864
|
* @returns
|
|
26936
26865
|
*/
|
|
26937
26866
|
static getLayoutSize(payload) {
|
|
26938
|
-
const
|
|
26867
|
+
const config = Object.assign({}, payload, {
|
|
26868
|
+
lineHeight: 1
|
|
26869
|
+
});
|
|
26870
|
+
const cacheKey = this.getMeasureCacheKey(config);
|
|
26939
26871
|
if (this.layoutSizeCache.has(cacheKey)) {
|
|
26940
26872
|
const result2 = this.layoutSizeCache.get(cacheKey);
|
|
26941
|
-
this.
|
|
26942
|
-
|
|
26873
|
+
this.layoutSizeCache.delete(cacheKey);
|
|
26874
|
+
this.layoutSizeCache.set(cacheKey, result2);
|
|
26875
|
+
return result2;
|
|
26876
|
+
}
|
|
26877
|
+
const text = new Konva.Text(config);
|
|
26878
|
+
const result = {
|
|
26879
|
+
width: this.getAdvanceWidth(payload),
|
|
26880
|
+
height: text.height()
|
|
26881
|
+
};
|
|
26882
|
+
if (this.layoutSizeCache.size >= this.LAYOUT_SIZE_CACHE_LIMIT) {
|
|
26883
|
+
const firstKey = this.layoutSizeCache.keys().next().value;
|
|
26884
|
+
this.layoutSizeCache.delete(firstKey);
|
|
26943
26885
|
}
|
|
26944
|
-
const result = this.computeLayoutSizeUncached(payload);
|
|
26945
|
-
this.evictOldestIfFull(this.layoutSizeCache, this.LAYOUT_SIZE_CACHE_LIMIT);
|
|
26946
26886
|
this.layoutSizeCache.set(cacheKey, result);
|
|
26947
|
-
return
|
|
26887
|
+
return result;
|
|
26948
26888
|
}
|
|
26949
26889
|
/**
|
|
26950
26890
|
* 清除度量缓存
|
|
@@ -27017,6 +26957,37 @@ class TextRun extends LayoutNode {
|
|
|
27017
26957
|
Object.assign(this, options.style);
|
|
27018
26958
|
}
|
|
27019
26959
|
}
|
|
26960
|
+
/**
|
|
26961
|
+
* 构建与 Konva 渲染一致的度量参数。
|
|
26962
|
+
* 须与段落 layout 使用的 TextRun 样式一致;若只传 fontSize 会按默认字体度量,
|
|
26963
|
+
* 加粗/自定义字体后 advance 偏窄,易出现字母叠画。
|
|
26964
|
+
*/
|
|
26965
|
+
static measurePayload(text, layoutStyle) {
|
|
26966
|
+
const ls = layoutStyle ?? {};
|
|
26967
|
+
const fontSize2 = ls.fontSize ?? DEFAULT_FONT_SIZE;
|
|
26968
|
+
const fontFamily = ls.fontFamily ?? DEFAULT_FONT_FAMILY;
|
|
26969
|
+
let fontStyle;
|
|
26970
|
+
if (ls.bold && ls.italic) {
|
|
26971
|
+
fontStyle = "bold italic";
|
|
26972
|
+
} else if (ls.bold) {
|
|
26973
|
+
fontStyle = "bold";
|
|
26974
|
+
} else if (ls.italic) {
|
|
26975
|
+
fontStyle = "italic";
|
|
26976
|
+
}
|
|
26977
|
+
const payload = {
|
|
26978
|
+
text,
|
|
26979
|
+
fontSize: fontSize2,
|
|
26980
|
+
fontFamily,
|
|
26981
|
+
lineHeight: 1
|
|
26982
|
+
};
|
|
26983
|
+
if (fontStyle) {
|
|
26984
|
+
payload.fontStyle = fontStyle;
|
|
26985
|
+
}
|
|
26986
|
+
if (ls.letterSpacing !== void 0 && ls.letterSpacing !== null) {
|
|
26987
|
+
payload.letterSpacing = ls.letterSpacing;
|
|
26988
|
+
}
|
|
26989
|
+
return payload;
|
|
26990
|
+
}
|
|
27020
26991
|
/**
|
|
27021
26992
|
* 计算文字大小 度量
|
|
27022
26993
|
* 优化版本
|
|
@@ -27024,7 +26995,14 @@ class TextRun extends LayoutNode {
|
|
|
27024
26995
|
* @returns
|
|
27025
26996
|
*/
|
|
27026
26997
|
static measureText(payload) {
|
|
27027
|
-
|
|
26998
|
+
const { width, height } = TextUtil.getLayoutSize(payload);
|
|
26999
|
+
const { ascent, descent } = TextUtil.getFontMetrics(payload);
|
|
27000
|
+
return {
|
|
27001
|
+
width,
|
|
27002
|
+
height,
|
|
27003
|
+
ascent,
|
|
27004
|
+
descent
|
|
27005
|
+
};
|
|
27028
27006
|
}
|
|
27029
27007
|
/**
|
|
27030
27008
|
* 计算文字大小 度量
|
|
@@ -27048,10 +27026,7 @@ class TextRun extends LayoutNode {
|
|
|
27048
27026
|
}
|
|
27049
27027
|
static createEmptyRun(doc) {
|
|
27050
27028
|
const fontSize2 = DEFAULT_FONT_SIZE;
|
|
27051
|
-
const { height, ascent, descent } = TextRun.measureText({
|
|
27052
|
-
text: "0",
|
|
27053
|
-
fontSize: fontSize2
|
|
27054
|
-
});
|
|
27029
|
+
const { height, ascent, descent } = TextRun.measureText(TextRun.measurePayload("0", { fontSize: fontSize2 }));
|
|
27055
27030
|
const run = new TextRun({
|
|
27056
27031
|
doc,
|
|
27057
27032
|
width: 6,
|
|
@@ -30893,6 +30868,81 @@ const DiagonalDirectionTypeConst = {
|
|
|
30893
30868
|
/** 从右上到左下 / */
|
|
30894
30869
|
Backward: "backward"
|
|
30895
30870
|
};
|
|
30871
|
+
var FIELD_TYPE = /* @__PURE__ */ ((FIELD_TYPE2) => {
|
|
30872
|
+
FIELD_TYPE2["PRIMARY_KEY"] = "primary_key";
|
|
30873
|
+
FIELD_TYPE2["ASSOCIATED_PRIMARY_KEY"] = "associated_primary_key";
|
|
30874
|
+
FIELD_TYPE2["TEXT"] = "text";
|
|
30875
|
+
FIELD_TYPE2["LONG_TEXT"] = "long_text";
|
|
30876
|
+
FIELD_TYPE2["INTEGER"] = "integer";
|
|
30877
|
+
FIELD_TYPE2["LONG"] = "long";
|
|
30878
|
+
FIELD_TYPE2["DOUBLE"] = "double";
|
|
30879
|
+
FIELD_TYPE2["DECIMAL"] = "decimal";
|
|
30880
|
+
FIELD_TYPE2["BOOLEAN"] = "boolean";
|
|
30881
|
+
FIELD_TYPE2["DATE"] = "date";
|
|
30882
|
+
FIELD_TYPE2["TIME"] = "time";
|
|
30883
|
+
FIELD_TYPE2["DATE_TIME"] = "date_time";
|
|
30884
|
+
FIELD_TYPE2["IMAGE"] = "image";
|
|
30885
|
+
FIELD_TYPE2["ATTACHMENT"] = "attachment";
|
|
30886
|
+
FIELD_TYPE2["SERIAL"] = "serial_number";
|
|
30887
|
+
FIELD_TYPE2["MASTERSLAVE"] = "master_slave";
|
|
30888
|
+
FIELD_TYPE2["USER"] = "user";
|
|
30889
|
+
FIELD_TYPE2["USER_MULTI"] = "user_multi";
|
|
30890
|
+
FIELD_TYPE2["ORG"] = "org";
|
|
30891
|
+
FIELD_TYPE2["ORG_MULTI"] = "org_multi";
|
|
30892
|
+
FIELD_TYPE2["ENUM"] = "enum";
|
|
30893
|
+
FIELD_TYPE2["ENUM_MULTI"] = "enum_multi";
|
|
30894
|
+
FIELD_TYPE2["OPTION"] = "option";
|
|
30895
|
+
FIELD_TYPE2["OPTION_MULTI"] = "option_multi";
|
|
30896
|
+
FIELD_TYPE2["REF"] = "ref";
|
|
30897
|
+
FIELD_TYPE2["REF_MULTI"] = "ref_multi";
|
|
30898
|
+
FIELD_TYPE2["RDO_REF"] = "rdo_ref";
|
|
30899
|
+
FIELD_TYPE2["EXPRESSION"] = "expression";
|
|
30900
|
+
FIELD_TYPE2["EXPRESSION_CONDITION"] = "expression_condition";
|
|
30901
|
+
FIELD_TYPE2["FUNCTION"] = "function";
|
|
30902
|
+
FIELD_TYPE2["AGG"] = "agg";
|
|
30903
|
+
FIELD_TYPE2["ESOP"] = "esop";
|
|
30904
|
+
FIELD_TYPE2["TRANSACTION"] = "transaction";
|
|
30905
|
+
FIELD_TYPE2["LABEL_TEMPLATE"] = "label_template";
|
|
30906
|
+
FIELD_TYPE2["LABEL_TEMPLATE_REF"] = "label_template_ref";
|
|
30907
|
+
FIELD_TYPE2["SERIALRULE"] = "serial_number_rule";
|
|
30908
|
+
FIELD_TYPE2["PRINTER"] = "printer";
|
|
30909
|
+
FIELD_TYPE2["MESSAGE_TMPL"] = "message_tmpl";
|
|
30910
|
+
FIELD_TYPE2["RANGE_USER"] = "range_user";
|
|
30911
|
+
FIELD_TYPE2["SIGNATURE"] = "electronic_signature";
|
|
30912
|
+
FIELD_TYPE2["ONLINE_FORM_TEMPLATE"] = "online_form_tmpl";
|
|
30913
|
+
FIELD_TYPE2["E_DHR_TEMPLATE"] = "edhr_tmpl";
|
|
30914
|
+
FIELD_TYPE2["DATA_TABLE_FORMULA"] = "data_table_formula";
|
|
30915
|
+
FIELD_TYPE2["READONLYCMP"] = "readonlycmp";
|
|
30916
|
+
FIELD_TYPE2["MATERIAL_NO"] = "material_no";
|
|
30917
|
+
FIELD_TYPE2["PRODUCT"] = "product";
|
|
30918
|
+
FIELD_TYPE2["DEVICE"] = "device";
|
|
30919
|
+
FIELD_TYPE2["Biz_Process"] = "biz_process";
|
|
30920
|
+
FIELD_TYPE2["Approval_Process"] = "approval_process";
|
|
30921
|
+
FIELD_TYPE2["MFG_ORDER"] = "mfg_order";
|
|
30922
|
+
FIELD_TYPE2["RECORD_NO"] = "record_no";
|
|
30923
|
+
FIELD_TYPE2["TRACE_DATE"] = "trace_date";
|
|
30924
|
+
FIELD_TYPE2["ROUTING_OPERATION"] = "routing_operation";
|
|
30925
|
+
FIELD_TYPE2["GOOD_QTY"] = "good_qty";
|
|
30926
|
+
FIELD_TYPE2["NOT_GOOD_QTY"] = "not_good_qty";
|
|
30927
|
+
FIELD_TYPE2["REPORT_START_TIME"] = "report_start_time";
|
|
30928
|
+
FIELD_TYPE2["REPORT_END_TIME"] = "report_end_time";
|
|
30929
|
+
FIELD_TYPE2["WORK_HOURS"] = "work_hours";
|
|
30930
|
+
FIELD_TYPE2["PRODUCTION_DATE"] = "production_date";
|
|
30931
|
+
FIELD_TYPE2["REPORTER"] = "reporter";
|
|
30932
|
+
FIELD_TYPE2["NOT_GOOD_REASON"] = "not_good_reason";
|
|
30933
|
+
FIELD_TYPE2["NOT_GOOD_GROUP"] = "not_good_group";
|
|
30934
|
+
FIELD_TYPE2["SCRAP_REASON"] = "scrap_reason";
|
|
30935
|
+
FIELD_TYPE2["SCRAP_GROUP"] = "scrap_group";
|
|
30936
|
+
FIELD_TYPE2["SCRAP_QTY"] = "scrap_qty";
|
|
30937
|
+
FIELD_TYPE2["SCRAP_MATERIAL"] = "scrap_material";
|
|
30938
|
+
FIELD_TYPE2["SCRAP_MATERIAL_NO"] = "scrap_material_no";
|
|
30939
|
+
FIELD_TYPE2["DESTRUCTIVE_TEST_QTY"] = "destructive_test_qty";
|
|
30940
|
+
FIELD_TYPE2["PRODUCT_CHECK_QTY"] = "product_check_qty";
|
|
30941
|
+
FIELD_TYPE2["MATERIAL_CHECK_QTY"] = "material_check_qty";
|
|
30942
|
+
FIELD_TYPE2["DEVICE_REF"] = "device_ref";
|
|
30943
|
+
FIELD_TYPE2["DEVICE_REF_MULTI"] = "device_ref_multi";
|
|
30944
|
+
return FIELD_TYPE2;
|
|
30945
|
+
})(FIELD_TYPE || {});
|
|
30896
30946
|
function getValue$1(value, multiple) {
|
|
30897
30947
|
if (multiple) {
|
|
30898
30948
|
return Array.isArray(value) ? value : value?.split(",").filter((i) => !isNil(i)) ?? [];
|
|
@@ -30941,6 +30991,18 @@ function toBoolean(value) {
|
|
|
30941
30991
|
}
|
|
30942
30992
|
return Boolean(parseInt(value));
|
|
30943
30993
|
}
|
|
30994
|
+
function toFormatValue(fieldType, value) {
|
|
30995
|
+
if ([FIELD_TYPE.INTEGER, FIELD_TYPE.LONG].includes(fieldType)) {
|
|
30996
|
+
const _val_ = parseInt(value);
|
|
30997
|
+
return isNaN(_val_) ? null : _val_;
|
|
30998
|
+
} else if (fieldType === FIELD_TYPE.DECIMAL) {
|
|
30999
|
+
const _val_ = parseFloat(value);
|
|
31000
|
+
return isNaN(_val_) ? null : _val_;
|
|
31001
|
+
} else if (fieldType === FIELD_TYPE.BOOLEAN) {
|
|
31002
|
+
return toBoolean(value);
|
|
31003
|
+
}
|
|
31004
|
+
return value;
|
|
31005
|
+
}
|
|
30944
31006
|
function toDictValue(field, value, row) {
|
|
30945
31007
|
const dictValue = row?._DICT?.[field]?.[value];
|
|
30946
31008
|
if (Array.isArray(dictValue)) {
|
|
@@ -40374,14 +40436,11 @@ class TextHandler {
|
|
|
40374
40436
|
let text = wr.text;
|
|
40375
40437
|
const textStyle = TextStyleResolver.resolve(wr.rPr, context.doc.model?.styles);
|
|
40376
40438
|
const layoutStyle = TextRun.textStyle2LayoutStyle(textStyle);
|
|
40377
|
-
const fontSize2 = layoutStyle.fontSize ?? DEFAULT_FONT_SIZE;
|
|
40378
40439
|
const chars = text.split("");
|
|
40379
40440
|
let doc = context.doc;
|
|
40380
40441
|
let charMetrics = [];
|
|
40381
40442
|
let remainingWidth = context.getParagraphRemainingSize();
|
|
40382
|
-
const { ascent, descent } = TextUtil.getFontMetrics(
|
|
40383
|
-
fontSize: fontSize2
|
|
40384
|
-
});
|
|
40443
|
+
const { ascent, descent } = TextUtil.getFontMetrics(TextRun.measurePayload("M", layoutStyle));
|
|
40385
40444
|
const complete = () => {
|
|
40386
40445
|
if (!charMetrics.length) return;
|
|
40387
40446
|
const width = charMetrics.reduce((total, item) => total + item.width, 0);
|
|
@@ -40408,10 +40467,7 @@ class TextHandler {
|
|
|
40408
40467
|
context.addRun(run);
|
|
40409
40468
|
};
|
|
40410
40469
|
chars.forEach((char, charIndex) => {
|
|
40411
|
-
const { width, height } = TextRun.measureText(
|
|
40412
|
-
text: char,
|
|
40413
|
-
fontSize: fontSize2
|
|
40414
|
-
});
|
|
40470
|
+
const { width, height } = TextRun.measureText(TextRun.measurePayload(char, layoutStyle));
|
|
40415
40471
|
if (width <= remainingWidth) {
|
|
40416
40472
|
charMetrics.push({
|
|
40417
40473
|
char,
|
|
@@ -40445,14 +40501,10 @@ class TextHandler {
|
|
|
40445
40501
|
let text = wr.text;
|
|
40446
40502
|
const textStyle = TextStyleResolver.resolve(wr.rPr, context.doc.model?.styles);
|
|
40447
40503
|
const layoutStyle = TextRun.textStyle2LayoutStyle(textStyle);
|
|
40448
|
-
const fontSize2 = layoutStyle.fontSize ?? DEFAULT_FONT_SIZE;
|
|
40449
40504
|
const chars = text.split("");
|
|
40450
40505
|
let doc = context.doc;
|
|
40451
40506
|
chars.forEach((char, charIndex) => {
|
|
40452
|
-
const { width, height, ascent, descent } = TextRun.measureText(
|
|
40453
|
-
text: char,
|
|
40454
|
-
fontSize: fontSize2
|
|
40455
|
-
});
|
|
40507
|
+
const { width, height, ascent, descent } = TextRun.measureText(TextRun.measurePayload(char, layoutStyle));
|
|
40456
40508
|
const run = new TextRun({
|
|
40457
40509
|
doc,
|
|
40458
40510
|
width,
|
|
@@ -40656,10 +40708,7 @@ class FieldBaseHandler {
|
|
|
40656
40708
|
position: "left"
|
|
40657
40709
|
});
|
|
40658
40710
|
chars.forEach((char, charIndex) => {
|
|
40659
|
-
const { width, height, ascent, descent } = TextRun.measureText(
|
|
40660
|
-
text: char,
|
|
40661
|
-
fontSize: fontSize2
|
|
40662
|
-
});
|
|
40711
|
+
const { width, height, ascent, descent } = TextRun.measureText(TextRun.measurePayload(char, layoutStyle));
|
|
40663
40712
|
const run = new TextWidget({
|
|
40664
40713
|
doc,
|
|
40665
40714
|
width,
|
|
@@ -40693,6 +40742,9 @@ class FieldBaseHandler {
|
|
|
40693
40742
|
static layoutNoValueLabel(ctx) {
|
|
40694
40743
|
const { context, wr } = ctx;
|
|
40695
40744
|
let doc = context.doc;
|
|
40745
|
+
const textStyle = TextStyleResolver.resolve(wr.rPr, context.doc.model?.styles);
|
|
40746
|
+
const layoutStyle = TextRun.textStyle2LayoutStyle(textStyle);
|
|
40747
|
+
const measureStyle = { ...layoutStyle, fontSize: 16 };
|
|
40696
40748
|
const { label, type: type4 } = this.getNoValueLabel(ctx);
|
|
40697
40749
|
const chars = label.split("");
|
|
40698
40750
|
this.addFieldMarker({
|
|
@@ -40701,10 +40753,7 @@ class FieldBaseHandler {
|
|
|
40701
40753
|
position: "left"
|
|
40702
40754
|
});
|
|
40703
40755
|
chars.forEach((char, charIndex) => {
|
|
40704
|
-
const { width, height, ascent, descent } = TextRun.measureText(
|
|
40705
|
-
text: char,
|
|
40706
|
-
fontSize: 16
|
|
40707
|
-
});
|
|
40756
|
+
const { width, height, ascent, descent } = TextRun.measureText(TextRun.measurePayload(char, measureStyle));
|
|
40708
40757
|
const run = new TextWidget({
|
|
40709
40758
|
doc,
|
|
40710
40759
|
width,
|
|
@@ -40773,13 +40822,12 @@ class FieldBaseHandler {
|
|
|
40773
40822
|
ctx: { context, wr },
|
|
40774
40823
|
fontSize: fontSize2,
|
|
40775
40824
|
extra,
|
|
40776
|
-
label
|
|
40825
|
+
label,
|
|
40826
|
+
layoutStyle
|
|
40777
40827
|
} = payload;
|
|
40828
|
+
const style = { ...layoutStyle, fontSize: fontSize2 };
|
|
40778
40829
|
label.split("").forEach((char, charIndex) => {
|
|
40779
|
-
const { width, height, ascent, descent } = TextRun.measureText(
|
|
40780
|
-
text: char,
|
|
40781
|
-
fontSize: fontSize2
|
|
40782
|
-
});
|
|
40830
|
+
const { width, height, ascent, descent } = TextRun.measureText(TextRun.measurePayload(char, style));
|
|
40783
40831
|
const run = new TextWidget({
|
|
40784
40832
|
doc: context.doc,
|
|
40785
40833
|
width,
|
|
@@ -40848,16 +40896,16 @@ class FieldBaseHandler {
|
|
|
40848
40896
|
if (context.doc.mode === DocModeTypeConst.Print) {
|
|
40849
40897
|
return;
|
|
40850
40898
|
}
|
|
40899
|
+
const textStyle = TextStyleResolver.resolve(wr.rPr, context.doc.model?.styles);
|
|
40900
|
+
const layoutStyle = TextRun.textStyle2LayoutStyle(textStyle);
|
|
40901
|
+
const measureStyle = { ...layoutStyle, fontSize: fontSize2 };
|
|
40851
40902
|
const label = position === "left" ? "[" : "]";
|
|
40852
40903
|
const options = position === "left" ? {
|
|
40853
40904
|
widgetFieldLeftMarker: true
|
|
40854
40905
|
} : {
|
|
40855
40906
|
widgetFieldRightMarker: true
|
|
40856
40907
|
};
|
|
40857
|
-
const { width, height, ascent, descent } = TextRun.measureText(
|
|
40858
|
-
text: label,
|
|
40859
|
-
fontSize: fontSize2
|
|
40860
|
-
});
|
|
40908
|
+
const { width, height, ascent, descent } = TextRun.measureText(TextRun.measurePayload(label, measureStyle));
|
|
40861
40909
|
const _width = position === "left" ? width + 2 : width + 3;
|
|
40862
40910
|
const run = new TextWidget({
|
|
40863
40911
|
doc: context.doc,
|
|
@@ -40924,10 +40972,9 @@ class OptionHandler extends FieldBaseHandler {
|
|
|
40924
40972
|
});
|
|
40925
40973
|
}
|
|
40926
40974
|
static layoutOptionItem(context, wr, option, optionIndex, layoutStyle) {
|
|
40927
|
-
const { width, height, ascent, descent } = TextRun.measureText(
|
|
40928
|
-
|
|
40929
|
-
|
|
40930
|
-
});
|
|
40975
|
+
const { width, height, ascent, descent } = TextRun.measureText(
|
|
40976
|
+
TextRun.measurePayload("0", { ...layoutStyle, fontSize: 16 })
|
|
40977
|
+
);
|
|
40931
40978
|
const fontSize2 = layoutStyle.fontSize ?? DEFAULT_FONT_SIZE;
|
|
40932
40979
|
const { iconLabelSpace, labelPosition, controlEnumSpace } = wr.widgetMeta?.props;
|
|
40933
40980
|
const isVertical = this.isVerticalLayout(wr);
|
|
@@ -40948,6 +40995,7 @@ class OptionHandler extends FieldBaseHandler {
|
|
|
40948
40995
|
ctx: { context, wr },
|
|
40949
40996
|
fontSize: fontSize2,
|
|
40950
40997
|
label: option.label,
|
|
40998
|
+
layoutStyle,
|
|
40951
40999
|
extra: {
|
|
40952
41000
|
widgetOption
|
|
40953
41001
|
}
|
|
@@ -41059,10 +41107,12 @@ class SignatureHandler extends FieldBaseHandler {
|
|
|
41059
41107
|
const format2 = signatureType === SignatureTypeConst.SIGNATURE_DATETIME ? "YYYY-MM-DD HH:mm" : "YYYY-MM-DD";
|
|
41060
41108
|
const timeStr = dayjs(time).format(format2);
|
|
41061
41109
|
let position = signDisplayStyle === SignDisplayTypeConst.VERTICAL ? "bottom" : "right";
|
|
41062
|
-
const
|
|
41063
|
-
|
|
41064
|
-
|
|
41065
|
-
}
|
|
41110
|
+
const textStyle = TextStyleResolver.resolve(wr.rPr, ctx.context.doc.model?.styles);
|
|
41111
|
+
const layoutStyle = TextRun.textStyle2LayoutStyle(textStyle);
|
|
41112
|
+
const fontSize2 = layoutStyle.fontSize ?? DEFAULT_FONT_SIZE;
|
|
41113
|
+
const { width: textWidth, height: textHeight } = TextRun.measureText(
|
|
41114
|
+
TextRun.measurePayload(timeStr, { ...layoutStyle, fontSize: fontSize2 })
|
|
41115
|
+
);
|
|
41066
41116
|
return {
|
|
41067
41117
|
render: render2,
|
|
41068
41118
|
rectWidth: width + (position === "right" ? textWidth : 0),
|
|
@@ -41070,7 +41120,7 @@ class SignatureHandler extends FieldBaseHandler {
|
|
|
41070
41120
|
decorations: [
|
|
41071
41121
|
{
|
|
41072
41122
|
text: timeStr,
|
|
41073
|
-
fontSize:
|
|
41123
|
+
fontSize: fontSize2,
|
|
41074
41124
|
x: position === "right" ? width : 0,
|
|
41075
41125
|
y: position === "right" ? (height - textHeight) / 2 : height,
|
|
41076
41126
|
position,
|
|
@@ -41154,10 +41204,7 @@ class InputHandler extends FieldBaseHandler {
|
|
|
41154
41204
|
position: "left"
|
|
41155
41205
|
});
|
|
41156
41206
|
chars.forEach((char, charIndex) => {
|
|
41157
|
-
const { width, height, ascent, descent } = TextRun.measureText(
|
|
41158
|
-
text: char,
|
|
41159
|
-
fontSize: fontSize2
|
|
41160
|
-
});
|
|
41207
|
+
const { width, height, ascent, descent } = TextRun.measureText(TextRun.measurePayload(char, layoutStyle));
|
|
41161
41208
|
const run = new TextWidget({
|
|
41162
41209
|
doc,
|
|
41163
41210
|
width,
|
|
@@ -41225,10 +41272,9 @@ class AttachmentHandler extends FieldBaseHandler {
|
|
|
41225
41272
|
const { ctx, item, itemIndex, layoutStyle, itemIsLast } = payload;
|
|
41226
41273
|
const name = getFileName(item);
|
|
41227
41274
|
const fontSize2 = layoutStyle.fontSize ?? DEFAULT_FONT_SIZE;
|
|
41228
|
-
const { width, height, ascent, descent } = TextRun.measureText(
|
|
41229
|
-
|
|
41230
|
-
|
|
41231
|
-
});
|
|
41275
|
+
const { width, height, ascent, descent } = TextRun.measureText(
|
|
41276
|
+
TextRun.measurePayload("0", { ...layoutStyle, fontSize: 16 })
|
|
41277
|
+
);
|
|
41232
41278
|
const widgetFileItem = {
|
|
41233
41279
|
index: itemIndex,
|
|
41234
41280
|
value: item
|
|
@@ -41251,6 +41297,7 @@ class AttachmentHandler extends FieldBaseHandler {
|
|
|
41251
41297
|
ctx,
|
|
41252
41298
|
fontSize: fontSize2,
|
|
41253
41299
|
label: name,
|
|
41300
|
+
layoutStyle,
|
|
41254
41301
|
extra: {
|
|
41255
41302
|
style: layoutStyle,
|
|
41256
41303
|
widgetFileItem
|
|
@@ -41345,10 +41392,9 @@ class SerialNumberHandler extends WidgetBaseHandler {
|
|
|
41345
41392
|
const layoutStyle = this.getLayoutStyle();
|
|
41346
41393
|
const label = (context.cell?.subRenderer?.dataIndex ?? 0) + 1 + "";
|
|
41347
41394
|
label.split("").forEach((char, charIndex) => {
|
|
41348
|
-
const { width, height, ascent, descent } = TextRun.measureText(
|
|
41349
|
-
|
|
41350
|
-
|
|
41351
|
-
});
|
|
41395
|
+
const { width, height, ascent, descent } = TextRun.measureText(
|
|
41396
|
+
TextRun.measurePayload(char, layoutStyle)
|
|
41397
|
+
);
|
|
41352
41398
|
const run = new TextWidget({
|
|
41353
41399
|
doc: context.doc,
|
|
41354
41400
|
width,
|
|
@@ -41384,10 +41430,9 @@ class DefaultHandler extends WidgetBaseHandler {
|
|
|
41384
41430
|
const layoutStyle = this.getLayoutStyle();
|
|
41385
41431
|
const label = wr.pageWidgetMeta?.type ?? "default";
|
|
41386
41432
|
label.split("").forEach((char, charIndex) => {
|
|
41387
|
-
const { width, height, ascent, descent } = TextRun.measureText(
|
|
41388
|
-
|
|
41389
|
-
|
|
41390
|
-
});
|
|
41433
|
+
const { width, height, ascent, descent } = TextRun.measureText(
|
|
41434
|
+
TextRun.measurePayload(char, layoutStyle)
|
|
41435
|
+
);
|
|
41391
41436
|
const run = new TextWidget({
|
|
41392
41437
|
doc: context.doc,
|
|
41393
41438
|
width,
|
|
@@ -41446,11 +41491,11 @@ class BarcodeHandler extends WidgetBaseHandler {
|
|
|
41446
41491
|
const render2 = showValue;
|
|
41447
41492
|
if (render2) {
|
|
41448
41493
|
let codeLabel = label ?? "";
|
|
41449
|
-
|
|
41450
|
-
const
|
|
41451
|
-
|
|
41452
|
-
|
|
41453
|
-
|
|
41494
|
+
const layoutStyle = this.getLayoutStyle();
|
|
41495
|
+
const fontSize2 = layoutStyle.fontSize ?? DEFAULT_FONT_SIZE;
|
|
41496
|
+
const { width: textWidth, height: textHeight } = TextRun.measureText(
|
|
41497
|
+
TextRun.measurePayload(codeLabel, layoutStyle)
|
|
41498
|
+
);
|
|
41454
41499
|
return {
|
|
41455
41500
|
render: render2,
|
|
41456
41501
|
rectWidth: width,
|
|
@@ -41573,10 +41618,9 @@ class PaginationHandler extends WidgetBaseHandler {
|
|
|
41573
41618
|
total: context.doc.pages.length
|
|
41574
41619
|
});
|
|
41575
41620
|
label.split("").forEach((char, charIndex) => {
|
|
41576
|
-
const { width, height, ascent, descent } = TextRun.measureText(
|
|
41577
|
-
|
|
41578
|
-
|
|
41579
|
-
});
|
|
41621
|
+
const { width, height, ascent, descent } = TextRun.measureText(
|
|
41622
|
+
TextRun.measurePayload(char, layoutStyle)
|
|
41623
|
+
);
|
|
41580
41624
|
const run = new TextWidget({
|
|
41581
41625
|
doc: context.doc,
|
|
41582
41626
|
width,
|
|
@@ -46125,6 +46169,8 @@ class Doc {
|
|
|
46125
46169
|
id;
|
|
46126
46170
|
/** 渲染模式 */
|
|
46127
46171
|
mode;
|
|
46172
|
+
/** 按钮区渲染模式 */
|
|
46173
|
+
btnRenderModeType;
|
|
46128
46174
|
/** 是否是设计器预览模式 */
|
|
46129
46175
|
preview;
|
|
46130
46176
|
model;
|
|
@@ -46170,6 +46216,7 @@ class Doc {
|
|
|
46170
46216
|
constructor(options) {
|
|
46171
46217
|
this.id = uuid();
|
|
46172
46218
|
this.mode = options.mode ?? DocModeTypeConst.Edit;
|
|
46219
|
+
this.btnRenderModeType = options.btnRenderModeType;
|
|
46173
46220
|
this.preview = options.preview ?? false;
|
|
46174
46221
|
this.model = options.model;
|
|
46175
46222
|
this.mainModelKey = options.mainModelKey;
|
|
@@ -46218,8 +46265,11 @@ class Doc {
|
|
|
46218
46265
|
this.model = model;
|
|
46219
46266
|
this.layout();
|
|
46220
46267
|
}
|
|
46221
|
-
setMode(modeType) {
|
|
46268
|
+
setMode(modeType, updateButton = false) {
|
|
46222
46269
|
this.mode = modeType;
|
|
46270
|
+
if (updateButton) {
|
|
46271
|
+
this.btnRenderModeType = modeType;
|
|
46272
|
+
}
|
|
46223
46273
|
this.layout();
|
|
46224
46274
|
}
|
|
46225
46275
|
/** 触发布局计算 */
|
|
@@ -49259,81 +49309,6 @@ async function processDocumentRequest(props, payload, id) {
|
|
|
49259
49309
|
} finally {
|
|
49260
49310
|
}
|
|
49261
49311
|
}
|
|
49262
|
-
var FIELD_TYPE = /* @__PURE__ */ ((FIELD_TYPE2) => {
|
|
49263
|
-
FIELD_TYPE2["PRIMARY_KEY"] = "primary_key";
|
|
49264
|
-
FIELD_TYPE2["ASSOCIATED_PRIMARY_KEY"] = "associated_primary_key";
|
|
49265
|
-
FIELD_TYPE2["TEXT"] = "text";
|
|
49266
|
-
FIELD_TYPE2["LONG_TEXT"] = "long_text";
|
|
49267
|
-
FIELD_TYPE2["INTEGER"] = "integer";
|
|
49268
|
-
FIELD_TYPE2["LONG"] = "long";
|
|
49269
|
-
FIELD_TYPE2["DOUBLE"] = "double";
|
|
49270
|
-
FIELD_TYPE2["DECIMAL"] = "decimal";
|
|
49271
|
-
FIELD_TYPE2["BOOLEAN"] = "boolean";
|
|
49272
|
-
FIELD_TYPE2["DATE"] = "date";
|
|
49273
|
-
FIELD_TYPE2["TIME"] = "time";
|
|
49274
|
-
FIELD_TYPE2["DATE_TIME"] = "date_time";
|
|
49275
|
-
FIELD_TYPE2["IMAGE"] = "image";
|
|
49276
|
-
FIELD_TYPE2["ATTACHMENT"] = "attachment";
|
|
49277
|
-
FIELD_TYPE2["SERIAL"] = "serial_number";
|
|
49278
|
-
FIELD_TYPE2["MASTERSLAVE"] = "master_slave";
|
|
49279
|
-
FIELD_TYPE2["USER"] = "user";
|
|
49280
|
-
FIELD_TYPE2["USER_MULTI"] = "user_multi";
|
|
49281
|
-
FIELD_TYPE2["ORG"] = "org";
|
|
49282
|
-
FIELD_TYPE2["ORG_MULTI"] = "org_multi";
|
|
49283
|
-
FIELD_TYPE2["ENUM"] = "enum";
|
|
49284
|
-
FIELD_TYPE2["ENUM_MULTI"] = "enum_multi";
|
|
49285
|
-
FIELD_TYPE2["OPTION"] = "option";
|
|
49286
|
-
FIELD_TYPE2["OPTION_MULTI"] = "option_multi";
|
|
49287
|
-
FIELD_TYPE2["REF"] = "ref";
|
|
49288
|
-
FIELD_TYPE2["REF_MULTI"] = "ref_multi";
|
|
49289
|
-
FIELD_TYPE2["RDO_REF"] = "rdo_ref";
|
|
49290
|
-
FIELD_TYPE2["EXPRESSION"] = "expression";
|
|
49291
|
-
FIELD_TYPE2["EXPRESSION_CONDITION"] = "expression_condition";
|
|
49292
|
-
FIELD_TYPE2["FUNCTION"] = "function";
|
|
49293
|
-
FIELD_TYPE2["AGG"] = "agg";
|
|
49294
|
-
FIELD_TYPE2["ESOP"] = "esop";
|
|
49295
|
-
FIELD_TYPE2["TRANSACTION"] = "transaction";
|
|
49296
|
-
FIELD_TYPE2["LABEL_TEMPLATE"] = "label_template";
|
|
49297
|
-
FIELD_TYPE2["LABEL_TEMPLATE_REF"] = "label_template_ref";
|
|
49298
|
-
FIELD_TYPE2["SERIALRULE"] = "serial_number_rule";
|
|
49299
|
-
FIELD_TYPE2["PRINTER"] = "printer";
|
|
49300
|
-
FIELD_TYPE2["MESSAGE_TMPL"] = "message_tmpl";
|
|
49301
|
-
FIELD_TYPE2["RANGE_USER"] = "range_user";
|
|
49302
|
-
FIELD_TYPE2["SIGNATURE"] = "electronic_signature";
|
|
49303
|
-
FIELD_TYPE2["ONLINE_FORM_TEMPLATE"] = "online_form_tmpl";
|
|
49304
|
-
FIELD_TYPE2["E_DHR_TEMPLATE"] = "edhr_tmpl";
|
|
49305
|
-
FIELD_TYPE2["DATA_TABLE_FORMULA"] = "data_table_formula";
|
|
49306
|
-
FIELD_TYPE2["READONLYCMP"] = "readonlycmp";
|
|
49307
|
-
FIELD_TYPE2["MATERIAL_NO"] = "material_no";
|
|
49308
|
-
FIELD_TYPE2["PRODUCT"] = "product";
|
|
49309
|
-
FIELD_TYPE2["DEVICE"] = "device";
|
|
49310
|
-
FIELD_TYPE2["Biz_Process"] = "biz_process";
|
|
49311
|
-
FIELD_TYPE2["Approval_Process"] = "approval_process";
|
|
49312
|
-
FIELD_TYPE2["MFG_ORDER"] = "mfg_order";
|
|
49313
|
-
FIELD_TYPE2["RECORD_NO"] = "record_no";
|
|
49314
|
-
FIELD_TYPE2["TRACE_DATE"] = "trace_date";
|
|
49315
|
-
FIELD_TYPE2["ROUTING_OPERATION"] = "routing_operation";
|
|
49316
|
-
FIELD_TYPE2["GOOD_QTY"] = "good_qty";
|
|
49317
|
-
FIELD_TYPE2["NOT_GOOD_QTY"] = "not_good_qty";
|
|
49318
|
-
FIELD_TYPE2["REPORT_START_TIME"] = "report_start_time";
|
|
49319
|
-
FIELD_TYPE2["REPORT_END_TIME"] = "report_end_time";
|
|
49320
|
-
FIELD_TYPE2["WORK_HOURS"] = "work_hours";
|
|
49321
|
-
FIELD_TYPE2["PRODUCTION_DATE"] = "production_date";
|
|
49322
|
-
FIELD_TYPE2["REPORTER"] = "reporter";
|
|
49323
|
-
FIELD_TYPE2["NOT_GOOD_REASON"] = "not_good_reason";
|
|
49324
|
-
FIELD_TYPE2["NOT_GOOD_GROUP"] = "not_good_group";
|
|
49325
|
-
FIELD_TYPE2["SCRAP_REASON"] = "scrap_reason";
|
|
49326
|
-
FIELD_TYPE2["SCRAP_GROUP"] = "scrap_group";
|
|
49327
|
-
FIELD_TYPE2["SCRAP_QTY"] = "scrap_qty";
|
|
49328
|
-
FIELD_TYPE2["SCRAP_MATERIAL"] = "scrap_material";
|
|
49329
|
-
FIELD_TYPE2["SCRAP_MATERIAL_NO"] = "scrap_material_no";
|
|
49330
|
-
FIELD_TYPE2["DESTRUCTIVE_TEST_QTY"] = "destructive_test_qty";
|
|
49331
|
-
FIELD_TYPE2["PRODUCT_CHECK_QTY"] = "product_check_qty";
|
|
49332
|
-
FIELD_TYPE2["MATERIAL_CHECK_QTY"] = "material_check_qty";
|
|
49333
|
-
FIELD_TYPE2["DEVICE_REF"] = "device_ref";
|
|
49334
|
-
FIELD_TYPE2["DEVICE_REF_MULTI"] = "device_ref_multi";
|
|
49335
|
-
return FIELD_TYPE2;
|
|
49336
|
-
})(FIELD_TYPE || {});
|
|
49337
49312
|
class RequestCache {
|
|
49338
49313
|
pendingMap = /* @__PURE__ */ new Map();
|
|
49339
49314
|
cacheMap = /* @__PURE__ */ new Map();
|
|
@@ -50745,32 +50720,6 @@ const DEFAULT_FROM_STATE = {
|
|
|
50745
50720
|
_MCTABLE: {}
|
|
50746
50721
|
// 物料消耗表业务数据
|
|
50747
50722
|
};
|
|
50748
|
-
const renderUtils = {
|
|
50749
|
-
getBoolValue: (value) => {
|
|
50750
|
-
if (isNil(value)) {
|
|
50751
|
-
return null;
|
|
50752
|
-
}
|
|
50753
|
-
if (value === "true" || value === "false") {
|
|
50754
|
-
return JSON.parse(value);
|
|
50755
|
-
}
|
|
50756
|
-
if (isNaN(parseInt(value))) {
|
|
50757
|
-
return Boolean(value);
|
|
50758
|
-
}
|
|
50759
|
-
return Boolean(parseInt(value));
|
|
50760
|
-
},
|
|
50761
|
-
formatValue: (fieldType, value) => {
|
|
50762
|
-
if ([FIELD_TYPE.INTEGER, FIELD_TYPE.LONG].includes(fieldType)) {
|
|
50763
|
-
const _val_ = parseInt(value);
|
|
50764
|
-
return isNaN(_val_) ? void 0 : _val_;
|
|
50765
|
-
} else if (fieldType === FIELD_TYPE.DECIMAL) {
|
|
50766
|
-
const _val_ = parseFloat(value);
|
|
50767
|
-
return isNaN(_val_) ? void 0 : _val_;
|
|
50768
|
-
} else if (fieldType === FIELD_TYPE.BOOLEAN) {
|
|
50769
|
-
return renderUtils.getBoolValue(value);
|
|
50770
|
-
}
|
|
50771
|
-
return value;
|
|
50772
|
-
}
|
|
50773
|
-
};
|
|
50774
50723
|
function getDefaultQueryIdsByFieldType(payload) {
|
|
50775
50724
|
const defaultQueryIds = {
|
|
50776
50725
|
[FIELD_TYPE.MATERIAL_NO]: payload.materialNumber,
|
|
@@ -50858,7 +50807,7 @@ const handleParameterMapping = (parameterMapping, paramsConfig, subTableInfo, fi
|
|
|
50858
50807
|
const processParamItem = (item) => {
|
|
50859
50808
|
if (!referenceMap.has(item.formKey)) return;
|
|
50860
50809
|
const value = referenceMap.get(item.formKey);
|
|
50861
|
-
const formattedValue =
|
|
50810
|
+
const formattedValue = toFormatValue(item.fieldType, value);
|
|
50862
50811
|
const target = item?.subModel ? (subMappedFields[item.subFieldKey] ??= {}, subMappedFields[item.subFieldKey]) : paramMap;
|
|
50863
50812
|
merge(target, { [item.field]: formattedValue });
|
|
50864
50813
|
};
|
|
@@ -50908,10 +50857,13 @@ const getFormDataItem = (onFieldMap, subTableInfo, result) => {
|
|
|
50908
50857
|
} else if (item.subModel === 1) {
|
|
50909
50858
|
const sInfo = subTableInfo.find((aa2) => aa2.field === item.subFieldKey) || {};
|
|
50910
50859
|
const fieldList = result.data.map(
|
|
50911
|
-
(data) => item.fields.reduce(
|
|
50912
|
-
prev
|
|
50913
|
-
|
|
50914
|
-
|
|
50860
|
+
(data) => item.fields.reduce(
|
|
50861
|
+
(prev, { isFieldModel, leftFieldKey, fieldLink, rightFieldKey }) => {
|
|
50862
|
+
prev[leftFieldKey] = isFieldModel ? data?.__FOREIGN__?.[fieldLink] : data[rightFieldKey];
|
|
50863
|
+
return prev;
|
|
50864
|
+
},
|
|
50865
|
+
{}
|
|
50866
|
+
)
|
|
50915
50867
|
);
|
|
50916
50868
|
let fieldList2d;
|
|
50917
50869
|
if (sInfo.subTable2d && sInfo.key === "dyn" || sInfo.checkTable2d && sInfo.key === "newfixed") {
|
|
@@ -51106,12 +51058,19 @@ const handleCustomDataSource = async (customDataSource, paramsConfig, subTableIn
|
|
|
51106
51058
|
const loadDataInitValues = async (runtimeJson, paramsConfig, subTableInfo, fieldPermission, instanceId) => {
|
|
51107
51059
|
const { document: document2 } = JSON.parse(runtimeJson || "{}");
|
|
51108
51060
|
if (!document2?.config?.dataInit) return {};
|
|
51109
|
-
const {
|
|
51110
|
-
|
|
51111
|
-
|
|
51112
|
-
|
|
51113
|
-
|
|
51114
|
-
|
|
51061
|
+
const { parameterMapping = [], customDataSource = [] } = document2.config.dataInit;
|
|
51062
|
+
const paramMap = handleParameterMapping(
|
|
51063
|
+
parameterMapping,
|
|
51064
|
+
paramsConfig,
|
|
51065
|
+
subTableInfo,
|
|
51066
|
+
fieldPermission
|
|
51067
|
+
);
|
|
51068
|
+
const dsMap = await handleCustomDataSource(
|
|
51069
|
+
customDataSource,
|
|
51070
|
+
paramsConfig,
|
|
51071
|
+
subTableInfo,
|
|
51072
|
+
instanceId
|
|
51073
|
+
);
|
|
51115
51074
|
return {
|
|
51116
51075
|
...mainData2WordData(paramMap),
|
|
51117
51076
|
...mainData2WordData(dsMap)
|
|
@@ -51326,17 +51285,15 @@ async function initializeDocumentEngine(props, payload, result) {
|
|
|
51326
51285
|
const docRuntimeMeta = {
|
|
51327
51286
|
...requestInfo,
|
|
51328
51287
|
handleInfo: {
|
|
51329
|
-
btnRenderModeType: result.btnModelType,
|
|
51330
51288
|
bpmnType: result.bpmnType,
|
|
51331
51289
|
bpmnFieldAuthMap: result.bpmnFieldAuthMap,
|
|
51332
51290
|
initDocModelJson: JSON.stringify(docModel.toXmlJson())
|
|
51333
51291
|
}
|
|
51334
51292
|
};
|
|
51335
|
-
console.log("rawData", rawData);
|
|
51336
|
-
await TextUtil.awaitDocumentFonts();
|
|
51337
51293
|
const doc = new Doc({
|
|
51338
51294
|
model: docModel,
|
|
51339
51295
|
mode: fillModeType,
|
|
51296
|
+
btnRenderModeType: result.btnModelType,
|
|
51340
51297
|
mainModelKey,
|
|
51341
51298
|
formType: requestInfo.formType || FormTypeConst.BASE,
|
|
51342
51299
|
preview: payload.isPreview,
|
|
@@ -51348,6 +51305,7 @@ async function initializeDocumentEngine(props, payload, result) {
|
|
|
51348
51305
|
...defaultDataMap,
|
|
51349
51306
|
...dataInitMap
|
|
51350
51307
|
});
|
|
51308
|
+
doc.docRuntimeMeta.handleInfo.initRawDataSnapshot = cloneDeep(doc.dataManager.getRawData());
|
|
51351
51309
|
const docInfo = snapshotDocInfo(doc);
|
|
51352
51310
|
return {
|
|
51353
51311
|
doc,
|
|
@@ -51407,6 +51365,7 @@ function useDocumentFactory(props, payload) {
|
|
|
51407
51365
|
docInfo.value = snapshotDocInfo(ins);
|
|
51408
51366
|
};
|
|
51409
51367
|
docInfo.value = initialized.docInfo;
|
|
51368
|
+
payload.onDocumentLoadSuccess?.(result);
|
|
51410
51369
|
}
|
|
51411
51370
|
const hasData = computed(() => docIns.value !== null);
|
|
51412
51371
|
function clear() {
|
|
@@ -57003,7 +56962,7 @@ function useDocOperations(docRef) {
|
|
|
57003
56962
|
focus: ids.length ? `root::${firstPage.id}` : null
|
|
57004
56963
|
});
|
|
57005
56964
|
}
|
|
57006
|
-
function getUnsavedChanges() {
|
|
56965
|
+
function getUnsavedChanges(options) {
|
|
57007
56966
|
const currentCheckpoint = buildSaveCheckpoint();
|
|
57008
56967
|
if (!currentCheckpoint) {
|
|
57009
56968
|
return { dirty: false };
|
|
@@ -57012,10 +56971,26 @@ function useDocOperations(docRef) {
|
|
|
57012
56971
|
if (!isEqual(currentCheckpoint.currentModel, currentCheckpoint.interfaceModel)) {
|
|
57013
56972
|
changedScopes.push("model");
|
|
57014
56973
|
}
|
|
56974
|
+
if (options?.includeRawData) {
|
|
56975
|
+
const doc = getDoc();
|
|
56976
|
+
const baselineRaw = doc?.docRuntimeMeta.handleInfo.initRawDataSnapshot;
|
|
56977
|
+
if (baselineRaw !== void 0 && doc) {
|
|
56978
|
+
const currentRaw = doc.dataManager.getRawData();
|
|
56979
|
+
if (!isEqual(currentRaw, baselineRaw)) {
|
|
56980
|
+
changedScopes.push("rawData");
|
|
56981
|
+
}
|
|
56982
|
+
}
|
|
56983
|
+
}
|
|
57015
56984
|
return {
|
|
57016
56985
|
dirty: changedScopes.length > 0
|
|
57017
56986
|
};
|
|
57018
56987
|
}
|
|
56988
|
+
function markAsSaved() {
|
|
56989
|
+
const doc = getDoc();
|
|
56990
|
+
if (!doc) return;
|
|
56991
|
+
doc.docRuntimeMeta.handleInfo.initDocModelJson = JSON.stringify(exportModel());
|
|
56992
|
+
doc.docRuntimeMeta.handleInfo.initRawDataSnapshot = cloneDeep(doc.dataManager.getRawData());
|
|
56993
|
+
}
|
|
57019
56994
|
return {
|
|
57020
56995
|
validate,
|
|
57021
56996
|
exportModel,
|
|
@@ -57023,7 +56998,8 @@ function useDocOperations(docRef) {
|
|
|
57023
56998
|
enterBaseline,
|
|
57024
56999
|
computeBaselineChanges,
|
|
57025
57000
|
setAnnotation,
|
|
57026
|
-
getUnsavedChanges
|
|
57001
|
+
getUnsavedChanges,
|
|
57002
|
+
markAsSaved
|
|
57027
57003
|
};
|
|
57028
57004
|
}
|
|
57029
57005
|
function useDocController(factory2, ops) {
|
|
@@ -57050,6 +57026,7 @@ function useDocController(factory2, ops) {
|
|
|
57050
57026
|
docRuntimeMeta: doc.docRuntimeMeta,
|
|
57051
57027
|
mode: computed(() => doc.mode),
|
|
57052
57028
|
modeLabel: computed(() => doc.modeLabel),
|
|
57029
|
+
btnRenderModeType: computed(() => doc.btnRenderModeType),
|
|
57053
57030
|
updateTick: computed(() => doc.updateTick),
|
|
57054
57031
|
pages: computed(() => doc.pages),
|
|
57055
57032
|
// Doc 内置命令系统
|
|
@@ -57062,8 +57039,8 @@ function useDocController(factory2, ops) {
|
|
|
57062
57039
|
redo() {
|
|
57063
57040
|
doc.redo();
|
|
57064
57041
|
},
|
|
57065
|
-
setMode(mode) {
|
|
57066
|
-
doc.setMode(mode);
|
|
57042
|
+
setMode(mode, updateButton = false) {
|
|
57043
|
+
doc.setMode(mode, updateButton);
|
|
57067
57044
|
},
|
|
57068
57045
|
setModel(model) {
|
|
57069
57046
|
doc.setModel(model);
|
|
@@ -57099,8 +57076,11 @@ function useDocController(factory2, ops) {
|
|
|
57099
57076
|
computeBaselineChanges(ctx) {
|
|
57100
57077
|
return ops.computeBaselineChanges(ctx);
|
|
57101
57078
|
},
|
|
57102
|
-
getUnsavedChanges() {
|
|
57103
|
-
return ops.getUnsavedChanges();
|
|
57079
|
+
getUnsavedChanges(options) {
|
|
57080
|
+
return ops.getUnsavedChanges(options);
|
|
57081
|
+
},
|
|
57082
|
+
markAsSaved() {
|
|
57083
|
+
ops.markAsSaved();
|
|
57104
57084
|
},
|
|
57105
57085
|
setAnnotation(ids, list) {
|
|
57106
57086
|
ops.setAnnotation(ids, list);
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
import { FIELD_TYPE } from '../../domain/field/field-type';
|
|
2
1
|
import { DesignSuiteContext } from '../_register_/context/DesignSuiteContext';
|
|
3
2
|
import { FieldMeta } from '../../capabilities/model-field-runtime';
|
|
4
|
-
/** 渲染端公共类(目前只迁移了部分使用到的方法 ) */
|
|
5
|
-
export declare const renderUtils: {
|
|
6
|
-
getBoolValue: (value: any) => any;
|
|
7
|
-
formatValue: (fieldType: FIELD_TYPE, value: any) => any;
|
|
8
|
-
};
|
|
9
3
|
/**
|
|
10
4
|
* 根据字段类型获取默认的查询ID值
|
|
11
5
|
* 用于根据不同类型的ID请求实验室(Lab)相关数据
|
|
@@ -10,6 +10,11 @@ export interface DocUnsavedChanges {
|
|
|
10
10
|
/** 是否存在未保存改动 */
|
|
11
11
|
dirty: boolean;
|
|
12
12
|
}
|
|
13
|
+
/** getUnsavedChanges 可选参数 */
|
|
14
|
+
export interface DocGetUnsavedChangesOptions {
|
|
15
|
+
/** 为 true 时除文档模型外,同时与初始化时的 rawData 快照比对 */
|
|
16
|
+
includeRawData?: boolean;
|
|
17
|
+
}
|
|
13
18
|
export interface DocOperations {
|
|
14
19
|
/** 校验所有字段,返回错误映射或 null(通过) */
|
|
15
20
|
validate(): Promise<Record<string, string[]> | null>;
|
|
@@ -27,7 +32,9 @@ export interface DocOperations {
|
|
|
27
32
|
/** 设置变更批注 */
|
|
28
33
|
setAnnotation(ids: string[], list: any[]): void;
|
|
29
34
|
/** 获取当前未保存改动状态,供外部在退出前做拦截 */
|
|
30
|
-
getUnsavedChanges(): DocUnsavedChanges;
|
|
35
|
+
getUnsavedChanges(options?: DocGetUnsavedChangesOptions): DocUnsavedChanges;
|
|
36
|
+
/** 标记当前文档为已保存 */
|
|
37
|
+
markAsSaved(): void;
|
|
31
38
|
}
|
|
32
39
|
/**
|
|
33
40
|
* 文档操作组合式函数
|
|
@@ -43,6 +43,11 @@ export interface IDocPayload extends IDocTemplatePayload, IDocInstancePayload {
|
|
|
43
43
|
/** 是否是预览模式 */
|
|
44
44
|
isPreview: boolean;
|
|
45
45
|
ctx: DesignSuiteContext;
|
|
46
|
+
/**
|
|
47
|
+
* 文档接口请求成功且引擎挂载完成后的回调(每轮成功加载触发一次)。
|
|
48
|
+
* 不会在 requestId 为空、请求被丢弃、或初始化抛错时调用。
|
|
49
|
+
*/
|
|
50
|
+
onDocumentLoadSuccess?: (result: Execute) => void;
|
|
46
51
|
}
|
|
47
52
|
/** 文档加载工厂 — 只负责响应式加载与生命周期,不包含业务操作 */
|
|
48
53
|
export interface DocumentFactory {
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
export { DocModeTypeConst, PageSizeEnumConst, BuiltinComponentTypeConst } from '../../core';
|
|
6
6
|
export type { DocModeType, CompleteComponentType, BuiltinComponentType } from '../../core';
|
|
7
|
-
export type { DocController, DocQueryAPI, WordRuntime, DocInfo, DocRuntimeMeta, DocRuntimeMetaHandleInfo, DocUnsavedChanges, UseWordProps, UseWordOptions, FieldModelQuery, } from '../types';
|
|
7
|
+
export type { DocController, DocQueryAPI, WordRuntime, DocInfo, DocRuntimeMeta, DocRuntimeMetaHandleInfo, DocUnsavedChanges, DocGetUnsavedChangesOptions, UseWordProps, UseWordOptions, FieldModelQuery, } from '../types';
|
|
8
|
+
export type { Execute } from '../doc-runtime/factories/useDocumentFactory';
|
|
8
9
|
export { useWord } from '../doc-runtime/useWord';
|
|
9
10
|
export { useDocSuite } from '../doc-runtime/composables/useDocSuite';
|
|
10
11
|
export { useDocumentFactory } from '../doc-runtime/factories/useDocumentFactory';
|
|
@@ -2,11 +2,12 @@ import { ComputedRef, Ref, ShallowRef } from 'vue';
|
|
|
2
2
|
import { DocModeType } from '../../core/constants';
|
|
3
3
|
import { DocModel } from '../../core/model';
|
|
4
4
|
import { Page } from '../../core';
|
|
5
|
-
import { DocBaselineContext, DocUnsavedChanges, DocOperations } from '../doc-runtime/composables/useDocOperations';
|
|
5
|
+
import { DocBaselineContext, DocUnsavedChanges, DocOperations, DocGetUnsavedChangesOptions } from '../doc-runtime/composables/useDocOperations';
|
|
6
6
|
import { OnlineFormInstanceResponse, OnlineFormTmplResponse } from '@gct-paas/api/apaas';
|
|
7
7
|
import { FieldChangeItem } from '../../runtime/interface/change-diff';
|
|
8
8
|
import { FormTmplConfigController } from '../../suites/edhr/panel-schema/data-load/hooks/form-tmpl-config';
|
|
9
|
-
|
|
9
|
+
import { Execute } from '../doc-runtime/factories/useDocumentFactory';
|
|
10
|
+
export type { DocUnsavedChanges, DocGetUnsavedChangesOptions, } from '../doc-runtime/composables/useDocOperations';
|
|
10
11
|
export type { FieldModelQuery } from './field-model-query';
|
|
11
12
|
/** 字段权限信息 */
|
|
12
13
|
export interface FieldPermissionInfo {
|
|
@@ -49,7 +50,7 @@ export interface DocControllerMethods extends DocOperations {
|
|
|
49
50
|
/** 重做上一步被撤销的操作 */
|
|
50
51
|
redo(): void;
|
|
51
52
|
/** 设置渲染模式 */
|
|
52
|
-
setMode(mode: DocModeType): void;
|
|
53
|
+
setMode(mode: DocModeType, updateBtn?: boolean): void;
|
|
53
54
|
/** 用新的文档模型替换当前文档 */
|
|
54
55
|
setModel(model: DocModel): void;
|
|
55
56
|
/** 获取当前文档原始填报数据快照 */
|
|
@@ -78,8 +79,10 @@ export interface DocControllerMethods extends DocOperations {
|
|
|
78
79
|
enterBaseline(uniqueId: string): DocBaselineContext | null;
|
|
79
80
|
/** 与基线做差异计算,返回字段变更列表 */
|
|
80
81
|
computeBaselineChanges(ctx: DocBaselineContext): Promise<FieldChangeItem[]>;
|
|
81
|
-
/**
|
|
82
|
-
getUnsavedChanges(): DocUnsavedChanges;
|
|
82
|
+
/** 获取当前未保存改动状态,适合外部在退出前做校验;特定场景可传入 includeRawData 同时比对填报数据 */
|
|
83
|
+
getUnsavedChanges(options?: DocGetUnsavedChangesOptions): DocUnsavedChanges;
|
|
84
|
+
/** 标记当前文档为已保存 */
|
|
85
|
+
markAsSaved(): void;
|
|
83
86
|
/** 向指定字段/组件设置批注信息 */
|
|
84
87
|
setAnnotation(ids: string[], list: any[]): void;
|
|
85
88
|
}
|
|
@@ -91,6 +94,8 @@ export interface DocControllerState {
|
|
|
91
94
|
mode: ComputedRef<DocModeType | null>;
|
|
92
95
|
/** 当前渲染模式中文文案(响应式) */
|
|
93
96
|
modeLabel: ComputedRef<string>;
|
|
97
|
+
/** 按钮区渲染模式(响应式) */
|
|
98
|
+
btnRenderModeType: ComputedRef<DocModeType | null>;
|
|
94
99
|
/** 布局刷新次数(响应式) */
|
|
95
100
|
updateTick: ComputedRef<number>;
|
|
96
101
|
/** 当前页面数组(响应式) */
|
|
@@ -115,14 +120,14 @@ export interface DocController extends DocControllerState, DocControllerMethods
|
|
|
115
120
|
}
|
|
116
121
|
/** docRuntimeMeta 中业务拼接的运行时处理信息 */
|
|
117
122
|
export interface DocRuntimeMetaHandleInfo {
|
|
118
|
-
/** 按钮区渲染模式 */
|
|
119
|
-
btnRenderModeType: DocModeType;
|
|
120
123
|
/** bpmn 流程类型 */
|
|
121
124
|
bpmnType?: string;
|
|
122
125
|
/** bpmn 字段权限映射 */
|
|
123
126
|
bpmnFieldAuthMap?: Record<string, any>;
|
|
124
127
|
/** 初始化的doc model 用来比对用 */
|
|
125
128
|
initDocModelJson: string;
|
|
129
|
+
/** 初始化后的填报原始数据快照,供 getUnsavedChanges({ includeRawData: true }) 比对 */
|
|
130
|
+
initRawDataSnapshot?: Record<string, any>;
|
|
126
131
|
}
|
|
127
132
|
/** 文档运行时元信息(接口返回字段 + 业务拼接字段) */
|
|
128
133
|
export interface DocRuntimeMeta extends OnlineFormInstanceResponse, OnlineFormTmplResponse {
|
|
@@ -178,6 +183,11 @@ export interface UseWordOptions {
|
|
|
178
183
|
isDetailPage?: boolean | (() => boolean);
|
|
179
184
|
/** 指定渲染模式 */
|
|
180
185
|
renderModeType?: DocModeType;
|
|
186
|
+
/**
|
|
187
|
+
* 文档接口请求成功且引擎挂载完成后的回调(每轮成功加载触发一次)。
|
|
188
|
+
* 不会在 requestId 为空、请求被丢弃、或初始化抛错时调用。
|
|
189
|
+
*/
|
|
190
|
+
onDocumentLoadSuccess?: (result: Execute) => void;
|
|
181
191
|
/** 扩展字段 - 兼容其他未明确定义的负载参数 */
|
|
182
192
|
[key: string]: any;
|
|
183
193
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DecimalDisplayModeType } from '../../domain/constants/enum';
|
|
2
|
+
import { FIELD_TYPE } from '../../domain/field/field-type';
|
|
2
3
|
export declare function getValue(value: any, multiple: boolean): any;
|
|
3
4
|
export declare function setValue(value: any, valuePath: string, payload?: {
|
|
4
5
|
multiple?: boolean;
|
|
@@ -11,6 +12,7 @@ export declare function setValue(value: any, valuePath: string, payload?: {
|
|
|
11
12
|
[x: string]: any;
|
|
12
13
|
};
|
|
13
14
|
export declare function toBoolean(value: any): boolean | null;
|
|
15
|
+
export declare function toFormatValue(fieldType: FIELD_TYPE, value: any): any;
|
|
14
16
|
export declare function toDictValue(field: string, value: any, row: any): any;
|
|
15
17
|
export declare function getSelectOptions(payload: any): {
|
|
16
18
|
selectOptions: any;
|