@gct-paas/word 0.2.18-beta.0 → 0.2.19-beta.1

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.
@@ -40,6 +40,13 @@ export declare class DataManager {
40
40
  * value: 默认值
41
41
  */
42
42
  private defaults;
43
+ /** 表结构/检验项元数据,不属于用户输入初值,重开和打印时仍需读取。 */
44
+ private configurationDefaults;
45
+ /** 参数映射的行模板;保存过的文档只允许对新增行使用。 */
46
+ private rowInitData;
47
+ /** 按对象身份追踪本次新增行,插入/删除导致下标变化时不会误初始化旧行。 */
48
+ private initializedRows;
49
+ private documentInitializationEnabled;
43
50
  constructor(options?: {
44
51
  doc?: Doc;
45
52
  data?: Data;
@@ -104,11 +111,14 @@ export declare class DataManager {
104
111
  flushDependenciesNow(): Promise<JsonPath[]>;
105
112
  private trackDependencyFieldChange;
106
113
  /**
107
- * 根据 jsonpath 获取原始数据(仅返回 rawData 中的值)
114
+ * 根据 jsonpath 读取字段。首次填报和本次新增行允许 undefined 回落到输入初值;
115
+ * null / '' 保留。结构配置独立读取,不受输入初值生命周期限制。
108
116
  * @param path jsonpath 路径 (例如: "document.body.children[0].text" 或 "user.name")
109
117
  * @returns 指定路径的值,不存在返回 undefined
110
118
  */
111
119
  get<T = any>(path: JsonPath): T | undefined;
120
+ /** 仅读取实际数据,不回落到默认值。初始化写入据此保护已有值与主动清空。 */
121
+ getStoredValue<T = any>(path: JsonPath): T | undefined;
112
122
  /**
113
123
  * 根据 jsonpath 获取标签数据
114
124
  * 优先获取带 LABEL_SUFFIX 的值,如果不存在则返回原值
@@ -229,11 +239,15 @@ export declare class DataManager {
229
239
  /**
230
240
  * 设置整个原始数据
231
241
  * @param data 新的 JSON 数据
232
- * @param defaultsMap 默认值, 字段值为 undefined 时才懒填充,不覆盖接口数据
242
+ * @param defaultsMap 默认值:首次填报仅为 undefined 懒填充,保存过的实例仅供新增行使用
233
243
  */
234
- setRawData(data: Data, defaultsMap?: Record<string, any>): void;
244
+ setRawData(data: Data, defaultsMap?: Record<string, any>, options?: {
245
+ configurationDefaults?: Record<string, any>;
246
+ initializeValues?: boolean;
247
+ }): void;
235
248
  /**
236
- * 将初始化数据直接写入 rawData(仅填充空值,不覆盖接口数据)
249
+ * 首次填报时将初始化数据写入 rawData,仅填 undefined;null / '' 是已赋值,必须保留。
250
+ * 保存过的数据重新打开时不再赋初值,行模板仅保留给后续新增行使用。
237
251
  * 与 defaults(懒填充)不同,此方法在初始化阶段一次性写入
238
252
  *
239
253
  * 支持两种子表路径形式:
@@ -241,9 +255,14 @@ export declare class DataManager {
241
255
  * - 真实下标:直接写入指定行,如 `$.sub[0].field`
242
256
  *
243
257
  * 处理顺序:先展开 `[n]` 通配符,再写入真实下标路径。
244
- * 这样可以保证:参数映射(`[n]`)先铺好默认值,自定义数据源(真实下标)再精确覆盖。
258
+ * 参数映射(`[n]`)先填未赋值字段,自定义数据源(真实下标)再填剩余未赋值字段。
245
259
  */
246
260
  applyInitData(initDataMap: Record<string, any>): void;
261
+ /**
262
+ * 只初始化刚新增的行。参数写入实际数据,组件默认值继续懒读并在提交前物化。
263
+ * 不提前物化默认值,避免其挡住当前主表选择的数据填充;复制行/null/'' 均保留。
264
+ */
265
+ applyRowInitData(subFieldKey: string, rowIndex: number): void;
247
266
  /**
248
267
  * 按版面铺砖槽位补齐子表行数:
249
268
  * - 固定表:按槽位补齐自身子表行
@@ -346,6 +365,13 @@ export declare class DataManager {
346
365
  * @returns 默认值,不存在返回 undefined
347
366
  */
348
367
  getDefault<T = any>(path: JsonPath): T | undefined;
368
+ private allDefaults;
369
+ /** 设计/未保存模板打印仍可展示默认值;重开或整表换数后不再隐式填充旧行。 */
370
+ private canApplyDocumentDefaults;
371
+ private canApplyDefaultAt;
372
+ private getApplicableDefault;
373
+ /** 快照的交叉区保持 UID 稀疏结构,不能按 [y][x] 写成嵌套数组。 */
374
+ private setSnapshotDefault;
349
375
  /**
350
376
  * 将路径中的具体数组索引转换为默认值通配符
351
377
  * - 普通子表: items[0].name -> items[n].name
@@ -0,0 +1,26 @@
1
+ /**
2
+ * 初始化值语义:
3
+ * - undefined:尚未赋值,首次填报或新增行时可以带入初值。
4
+ * - null:用户主动清空;'':已写入的空字符串。二者都必须保留。
5
+ * - 0、false 及其他已定义的值同样不能被初值覆盖。
6
+ * isBlank/isPresent 用于业务校验,不能用于判断是否允许初始化。
7
+ */
8
+ export declare function isUninitialized(value: unknown): value is undefined;
9
+ interface DocumentInitializationContext {
10
+ mode?: string;
11
+ docRuntimeMeta?: {
12
+ dataId?: string;
13
+ dataStatus?: string;
14
+ instanceStatus?: string;
15
+ };
16
+ }
17
+ /** 是否已有填报记录;与编辑/打印等展示模式无关。 */
18
+ export declare function hasPersistedDocumentData(context: DocumentInitializationContext): boolean;
19
+ /**
20
+ * 文档初值只在首次填报时带入。暂存、提交或已有填报数据的实例重开时,
21
+ * 即使接口未返回某个字段,也不能重新初始化;新增行另走行初始化入口。
22
+ * 没有实例状态的模板模拟填报仍可初始化;设计/打印不执行填报初始化,
23
+ * 模板预览展示默认值由 DataManager 单独处理。
24
+ */
25
+ export declare function shouldInitializeDocumentData(context: DocumentInitializationContext): boolean;
26
+ export {};
@@ -2,6 +2,17 @@ import { Wtbl } from '../Wtbl';
2
2
  /**
3
3
  * 表格行列操作功能类
4
4
  * 提供插入和删除行列的功能
5
+ *
6
+ * 边框规则说明:
7
+ * 1. 边框操作作用于当前单元格或选中区域。“外侧边框”只设置外围,内部保持原设置;
8
+ * 如需只保留外框,应先设置“无边框”,再设置“外侧边框”。
9
+ * 2. 相邻单元格共用一条边,设置或清除时会同步两侧。例如第二行的下边框,
10
+ * 同时也是第三行的上边框,画面上只显示一条线。
11
+ * 3. 当前删除行或列时,保留剩余单元格已有的边框设置。因此删除第二行后,
12
+ * 原第三行的上边框仍会保留并上移,交界处可能继续显示横线。
13
+ * 4. 新增行或列沿用邻近单元格的边框设置;合并单元格时隐藏内部边框,保留设置供拆分后恢复。
14
+ * 5. 编辑时的浅灰虚线用于识别单元格范围,预览、打印和 PDF 输出时不显示。
15
+ * 如需删除行后同步清除交界线,应统一首行、末行及连续多行删除等场景的产品规则和验收预期。
5
16
  */
6
17
  export declare class WtblRowColumnOps {
7
18
  /** 外表删除前,显式移除受影响单元格中的嵌套表,避免孤儿节点残留 */
@@ -6,6 +6,10 @@ export interface DocumentValidationDecision {
6
6
  skipValidation: boolean;
7
7
  reason?: string;
8
8
  }
9
+ export interface DocumentRuntimeInitOptions {
10
+ /** 刷新/整表换数时只恢复运行时状态,禁止重跑首次填报的初值赋值。 */
11
+ initializeValues?: boolean;
12
+ }
9
13
  /**
10
14
  * 文档级运行时扩展。
11
15
  *
@@ -13,7 +17,7 @@ export interface DocumentValidationDecision {
13
17
  * composable / DataManager / 校验入口中。
14
18
  */
15
19
  export interface DocumentRuntimeExtension {
16
- onInit?(): void | Promise<void>;
20
+ onInit?(options?: DocumentRuntimeInitOptions): void | Promise<void>;
17
21
  onHydrate?(): void | Promise<void>;
18
22
  onFieldChanges?(changedMap: FieldChangeMap, options: {
19
23
  batchSource: EmitSource;
@@ -24,7 +28,7 @@ export interface DocumentRuntimeExtension {
24
28
  export declare class DocumentRuntimeManager {
25
29
  private readonly extensions;
26
30
  register(extension: DocumentRuntimeExtension): void;
27
- onInit(): Promise<void>;
31
+ onInit(options?: DocumentRuntimeInitOptions): Promise<void>;
28
32
  onHydrate(): Promise<void>;
29
33
  onFieldChanges(changedMap: FieldChangeMap, options: {
30
34
  batchSource: EmitSource;
@@ -5,6 +5,7 @@ export declare function resolveSealDisplay(doc: Doc, widget: ImageWidget): {
5
5
  visible: boolean;
6
6
  hasError: boolean;
7
7
  emptySymbol: string;
8
+ readonlyEmpty: boolean;
8
9
  showEmptySymbol: boolean;
9
10
  placeholder: string;
10
11
  requiredBorder: boolean | undefined;
@@ -17,6 +18,7 @@ export declare function resolveSealDisplay(doc: Doc, widget: ImageWidget): {
17
18
  visible: boolean;
18
19
  hasError: boolean;
19
20
  emptySymbol: string;
21
+ readonlyEmpty: boolean;
20
22
  showEmptySymbol: boolean;
21
23
  placeholder: string;
22
24
  requiredBorder: boolean | undefined;
@@ -1,8 +1,9 @@
1
1
  import { CheckTableItemInfosPayload, CheckTableRegionRef } from '../types';
2
2
  /**
3
3
  * 将接口返回的检验项配置写入 defaults(展开为 $.f_jianyan1[0].type_ 等字段路径)。
4
- * 仅配置字段;不写入 rawData,避免覆盖 fetchRenderData 的业务数据。
4
+ * 行配置与交叉区填报初值分别输出:配置重开时仍有效,填报初值仅首次使用。
5
+ * 两者都不直接写 rawData,已有业务值由 DataManager 保留。
5
6
  */
6
- export declare function mergeCheckTableItemInfosIntoDefaults(defaultsMap: Record<string, unknown>, region: CheckTableRegionRef, infos: CheckTableItemInfosPayload, layoutColumnCount?: number): void;
7
+ export declare function mergeCheckTableItemInfosIntoDefaults(defaultsMap: Record<string, unknown>, region: CheckTableRegionRef, infos: CheckTableItemInfosPayload, layoutColumnCount?: number, configurationDefaultsMap?: Record<string, unknown>): void;
7
8
  /** 从字段级 defaults 组装检验项行配置(供 readRowMeta) */
8
9
  export declare function readCheckTableRowConfigFromDefaults(getDefault: (path: string) => unknown, rowMetaPath: string): Record<string, unknown>;
@@ -19,4 +19,4 @@ export declare function prepareCheckTableRuntimeJson<T extends Record<string, un
19
19
  * 文档初始化中:将检验项配置写入 defaultsMap(字段路径展开)。
20
20
  * 优先使用 prepare 返回的 regions,避免再次扫描 runtimeJson。
21
21
  */
22
- export declare function applyCheckTableItemInfosToDefaults(defaultsMap: Record<string, unknown>, regions: CheckTableRegionRef[], infosMap: Record<string, CheckTableItemInfosPayload>, getLayoutSlotCount: (linkFieldKey: string) => number): void;
22
+ export declare function applyCheckTableItemInfosToDefaults(defaultsMap: Record<string, unknown>, regions: CheckTableRegionRef[], infosMap: Record<string, CheckTableItemInfosPayload>, getLayoutSlotCount: (linkFieldKey: string) => number, configurationDefaultsMap?: Record<string, unknown>): void;
@@ -1,7 +1,8 @@
1
1
  import { BusinessScanHandler } from '../../../shared/scan-action';
2
2
  /**
3
3
  * 库存调拨表:扫码后入行
4
- * - 连续扫码每次新增一行
4
+ * - 优先填充未选择库存物料的占位行,忽略默认数量、目标仓库等字段
5
+ * - 已有物料后连续扫码每次新增一行
5
6
  * - 重复扫同一码不合并
6
7
  */
7
8
  export declare const handleWarehouseAllocateScan: BusinessScanHandler;
@@ -13,5 +13,6 @@ export declare class InitLoadEngine {
13
13
  */
14
14
  private shouldSkip;
15
15
  private readExistingRows;
16
- private hasNonemptyRow;
16
+ /** null / '' 也是已赋值;只允许替换尚未填写业务字段的占位行。 */
17
+ private hasInitializedRow;
17
18
  }
@@ -6,9 +6,9 @@ export declare class RowRuntimeEngine {
6
6
  constructor(doc: Doc);
7
7
  hasRowInit(ctx: TableRuntimeContext): boolean;
8
8
  /** 对单行执行行初始化 */
9
- applyRowInit(ctx: TableRuntimeContext, rowIndex: number, rowSource?: string): void;
9
+ applyRowInit(ctx: TableRuntimeContext, rowIndex: number, rowSource?: string, initializeValues?: boolean): void;
10
10
  /** 初始化时对所有未软删行执行行初始化 */
11
- applyRowInitForAllRows(ctx: TableRuntimeContext): void;
11
+ applyRowInitForAllRows(ctx: TableRuntimeContext, initializeValues?: boolean): void;
12
12
  /** 字段变更时执行 when=onFieldChange 的行处理器(按 watch 过滤) */
13
13
  applyRowHandlersOnFieldChange(ctx: TableRuntimeContext, change: SubtableFieldPath, fieldChange?: FieldChangeDetail): void;
14
14
  /** 主表字段变更时,执行 when=onMainFieldChange 的上下文赋值,补填全部子表行 */
@@ -41,7 +41,9 @@ export declare class TableRuntime {
41
41
  /** 文档是否包含业务子表 */
42
42
  get hasBusinessTables(): boolean;
43
43
  /** 文档初始化时执行全套运行时逻辑 */
44
- onInit(): Promise<void>;
44
+ onInit(options?: {
45
+ initializeValues?: boolean;
46
+ }): Promise<void>;
45
47
  /**
46
48
  * 子表新增行初始化:rowInit → 字段态规则 → 级联 → 数据填充。
47
49
  */
@@ -239,7 +239,7 @@ export interface RemoteSyncDef {
239
239
  export interface ContextAssignmentDef {
240
240
  /**
241
241
  * context → 行字段赋值的触发时机
242
- * @property onRowInit - 插行 / 文档初始化逐行时
242
+ * @property onRowInit - 新增行 / 首次填报逐行时,已保存文档重开不执行
243
243
  * @property onMainFieldChange - 指定主表字段变更时,补填全部行(需配 mainFieldKey)
244
244
  * @property onInitLoad - initLoad 批量加载映射后,逐行补填
245
245
  */
@@ -250,7 +250,7 @@ export interface ContextAssignmentDef {
250
250
  paramKey: string;
251
251
  /** 写入的行字段 key */
252
252
  fieldKey: string;
253
- /** 仅当目标字段为空时写入 */
253
+ /** 历史配置兼容;初始化统一仅填 undefined,null / '' 和其他已定义值均保留。 */
254
254
  onlyIfEmpty?: boolean;
255
255
  }
256
256
  /** 行级处理器声明:按时机调用注册于 runtime-handlers 的具名处理器 */