@gct-paas/word 0.2.17 → 0.2.18

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;
@@ -99,11 +106,14 @@ export declare class DataManager {
99
106
  flushDependenciesNow(): Promise<JsonPath[]>;
100
107
  private trackDependencyFieldChange;
101
108
  /**
102
- * 根据 jsonpath 获取原始数据(仅返回 rawData 中的值)
109
+ * 根据 jsonpath 读取字段。首次填报和本次新增行允许 undefined 回落到输入初值;
110
+ * null / '' 保留。结构配置独立读取,不受输入初值生命周期限制。
103
111
  * @param path jsonpath 路径 (例如: "document.body.children[0].text" 或 "user.name")
104
112
  * @returns 指定路径的值,不存在返回 undefined
105
113
  */
106
114
  get<T = any>(path: JsonPath): T | undefined;
115
+ /** 仅读取实际数据,不回落到默认值。初始化写入据此保护已有值与主动清空。 */
116
+ getStoredValue<T = any>(path: JsonPath): T | undefined;
107
117
  /**
108
118
  * 根据 jsonpath 获取标签数据
109
119
  * 优先获取带 LABEL_SUFFIX 的值,如果不存在则返回原值
@@ -224,11 +234,15 @@ export declare class DataManager {
224
234
  /**
225
235
  * 设置整个原始数据
226
236
  * @param data 新的 JSON 数据
227
- * @param defaultsMap 默认值, 字段值为 undefined 时才懒填充,不覆盖接口数据
237
+ * @param defaultsMap 默认值:首次填报仅为 undefined 懒填充,保存过的实例仅供新增行使用
228
238
  */
229
- setRawData(data: Data, defaultsMap?: Record<string, any>): void;
239
+ setRawData(data: Data, defaultsMap?: Record<string, any>, options?: {
240
+ configurationDefaults?: Record<string, any>;
241
+ initializeValues?: boolean;
242
+ }): void;
230
243
  /**
231
- * 将初始化数据直接写入 rawData(仅填充空值,不覆盖接口数据)
244
+ * 首次填报时将初始化数据写入 rawData,仅填 undefined;null / '' 是已赋值,必须保留。
245
+ * 保存过的数据重新打开时不再赋初值,行模板仅保留给后续新增行使用。
232
246
  * 与 defaults(懒填充)不同,此方法在初始化阶段一次性写入
233
247
  *
234
248
  * 支持两种子表路径形式:
@@ -236,9 +250,14 @@ export declare class DataManager {
236
250
  * - 真实下标:直接写入指定行,如 `$.sub[0].field`
237
251
  *
238
252
  * 处理顺序:先展开 `[n]` 通配符,再写入真实下标路径。
239
- * 这样可以保证:参数映射(`[n]`)先铺好默认值,自定义数据源(真实下标)再精确覆盖。
253
+ * 参数映射(`[n]`)先填未赋值字段,自定义数据源(真实下标)再填剩余未赋值字段。
240
254
  */
241
255
  applyInitData(initDataMap: Record<string, any>): void;
256
+ /**
257
+ * 只初始化刚新增的行。参数写入实际数据,组件默认值继续懒读并在提交前物化。
258
+ * 不提前物化默认值,避免其挡住当前主表选择的数据填充;复制行/null/'' 均保留。
259
+ */
260
+ applyRowInitData(subFieldKey: string, rowIndex: number): void;
242
261
  /**
243
262
  * 按版面铺砖槽位补齐子表行数:
244
263
  * - 固定表:按槽位补齐自身子表行
@@ -341,6 +360,13 @@ export declare class DataManager {
341
360
  * @returns 默认值,不存在返回 undefined
342
361
  */
343
362
  getDefault<T = any>(path: JsonPath): T | undefined;
363
+ private allDefaults;
364
+ /** 设计/未保存模板打印仍可展示默认值;重开或整表换数后不再隐式填充旧行。 */
365
+ private canApplyDocumentDefaults;
366
+ private canApplyDefaultAt;
367
+ private getApplicableDefault;
368
+ /** 快照的交叉区保持 UID 稀疏结构,不能按 [y][x] 写成嵌套数组。 */
369
+ private setSnapshotDefault;
344
370
  /**
345
371
  * 将路径中的具体数组索引转换为默认值通配符
346
372
  * - 普通子表: 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 {};
@@ -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 的上下文赋值,补填全部子表行 */
@@ -40,7 +40,9 @@ export declare class TableRuntime {
40
40
  /** 文档是否包含业务子表 */
41
41
  get hasBusinessTables(): boolean;
42
42
  /** 文档初始化时执行全套运行时逻辑 */
43
- onInit(): Promise<void>;
43
+ onInit(options?: {
44
+ initializeValues?: boolean;
45
+ }): Promise<void>;
44
46
  /**
45
47
  * 子表新增行初始化:rowInit → 字段态规则 → 级联 → 数据填充。
46
48
  */
@@ -233,7 +233,7 @@ export interface RemoteSyncDef {
233
233
  export interface ContextAssignmentDef {
234
234
  /**
235
235
  * context → 行字段赋值的触发时机
236
- * @property onRowInit - 插行 / 文档初始化逐行时
236
+ * @property onRowInit - 新增行 / 首次填报逐行时,已保存文档重开不执行
237
237
  * @property onMainFieldChange - 指定主表字段变更时,补填全部行(需配 mainFieldKey)
238
238
  * @property onInitLoad - initLoad 批量加载映射后,逐行补填
239
239
  */
@@ -244,7 +244,7 @@ export interface ContextAssignmentDef {
244
244
  paramKey: string;
245
245
  /** 写入的行字段 key */
246
246
  fieldKey: string;
247
- /** 仅当目标字段为空时写入 */
247
+ /** 历史配置兼容;初始化统一仅填 undefined,null / '' 和其他已定义值均保留。 */
248
248
  onlyIfEmpty?: boolean;
249
249
  }
250
250
  /** 行级处理器声明:按时机调用注册于 runtime-handlers 的具名处理器 */
package/dist/index.es.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! @gct-paas/word v0.2.17 */
1
+ /*! @gct-paas/word v0.2.18 */
2
2
  import { Fragment, Suspense, Teleport, Transition, TransitionGroup, cloneVNode, computed, createApp, createBlock, createCommentVNode, createElementBlock, createElementVNode, createSlots, createStaticVNode, createTextVNode, createVNode, defineAsyncComponent, defineComponent, getCurrentInstance, getCurrentScope, guardReactiveProps, h, inject, isRef, isVNode, markRaw, mergeModels, mergeProps, nextTick, normalizeClass, normalizeProps, normalizeStyle, onBeforeMount, onBeforeUnmount, onMounted, onScopeDispose, onUnmounted, openBlock, provide, reactive, readonly, ref, render, renderList, renderSlot, resolveComponent, resolveDynamicComponent, shallowRef, toDisplayString, toHandlers, toRaw, toRef, toValue, unref, useAttrs, useCssVars, useModel, useSlots, vModelRadio, vModelText, vShow, watch, watchEffect, withCtx, withDirectives, withKeys, withModifiers } from "vue";
3
3
  import Gt, { PopperWrapper } from "floating-vue";
4
4
  import VueKonva from "vue-konva";
@@ -96004,7 +96004,7 @@ var init_render = __esmMin((() => {
96004
96004
  }
96005
96005
  return (await Promise.all(promises)).reduce((merged, map) => merge(merged, map), {});
96006
96006
  };
96007
- loadDataInitValues = async (fillModeType, dataInitConfig, paramsConfig, subTableInfo, fieldPermission, instanceId, instances, ctx) => {
96007
+ loadDataInitValues = async (fillModeType, dataInitConfig, paramsConfig, subTableInfo, fieldPermission, instanceId, instances, ctx, initializeDataSources = true) => {
96008
96008
  if (fillModeType === DocModeTypeConst.Edit || !dataInitConfig) return {
96009
96009
  paramMap: {},
96010
96010
  dsRawData: {}
@@ -96012,7 +96012,7 @@ var init_render = __esmMin((() => {
96012
96012
  const { parameterMapping = [], customDataSource = [] } = dataInitConfig || {};
96013
96013
  return {
96014
96014
  paramMap: await handleParameterMapping(parameterMapping, paramsConfig, fieldPermission, instances, ctx),
96015
- dsMap: await handleCustomDataSource(customDataSource, paramsConfig, subTableInfo, instanceId, instances)
96015
+ dsMap: initializeDataSources ? await handleCustomDataSource(customDataSource, paramsConfig, subTableInfo, instanceId, instances) : {}
96016
96016
  };
96017
96017
  };
96018
96018
  collectLinkedModelFields = (instances) => {
@@ -96816,9 +96816,10 @@ var init_field_keys$13 = __esmMin((() => {
96816
96816
  //#region src/domain/table/business/check/check-table/runtime/map-check-table-item-infos.ts
96817
96817
  /**
96818
96818
  * 将接口返回的检验项配置写入 defaults(展开为 $.f_jianyan1[0].type_ 等字段路径)。
96819
- * 仅配置字段;不写入 rawData,避免覆盖 fetchRenderData 的业务数据。
96819
+ * 行配置与交叉区填报初值分别输出:配置重开时仍有效,填报初值仅首次使用。
96820
+ * 两者都不直接写 rawData,已有业务值由 DataManager 保留。
96820
96821
  */
96821
- function mergeCheckTableItemInfosIntoDefaults(defaultsMap, region, infos, layoutColumnCount = 0) {
96822
+ function mergeCheckTableItemInfosIntoDefaults(defaultsMap, region, infos, layoutColumnCount = 0, configurationDefaultsMap = defaultsMap) {
96822
96823
  if (!infos.data.length || !region.subFieldKey) return;
96823
96824
  const subFieldKey = region.subFieldKey;
96824
96825
  const xCount = region.linkFieldKey ? Math.max(layoutColumnCount, 0) : 0;
@@ -96828,7 +96829,7 @@ function mergeCheckTableItemInfosIntoDefaults(defaultsMap, region, infos, layout
96828
96829
  const rowPath = `$.${subFieldKey}[${index}]`;
96829
96830
  for (const [key, value] of Object.entries(item)) {
96830
96831
  if (value === void 0) continue;
96831
- defaultsMap[`${rowPath}.${key}`] = value;
96832
+ configurationDefaultsMap[`${rowPath}.${key}`] = value;
96832
96833
  }
96833
96834
  const defaultValue = item[F$13.defaultValue];
96834
96835
  if (defaultValue == null || defaultValue === "" || !region.linkFieldKey || xCount === 0) return;
@@ -97618,11 +97619,11 @@ async function prepareCheckTableRuntimeJson(instanceId, runtimeJson, options) {
97618
97619
  * 文档初始化中:将检验项配置写入 defaultsMap(字段路径展开)。
97619
97620
  * 优先使用 prepare 返回的 regions,避免再次扫描 runtimeJson。
97620
97621
  */
97621
- function applyCheckTableItemInfosToDefaults(defaultsMap, regions, infosMap, getLayoutSlotCount) {
97622
+ function applyCheckTableItemInfosToDefaults(defaultsMap, regions, infosMap, getLayoutSlotCount, configurationDefaultsMap = defaultsMap) {
97622
97623
  for (const region of regions) {
97623
97624
  const infos = infosMap[region.regionId];
97624
97625
  if (!infos) continue;
97625
- mergeCheckTableItemInfosIntoDefaults(defaultsMap, region, infos, region.linkFieldKey ? getLayoutSlotCount(region.linkFieldKey) : 0);
97626
+ mergeCheckTableItemInfosIntoDefaults(defaultsMap, region, infos, region.linkFieldKey ? getLayoutSlotCount(region.linkFieldKey) : 0, configurationDefaultsMap);
97626
97627
  }
97627
97628
  }
97628
97629
  var init_prepare_check_table_init = __esmMin((() => {
@@ -98873,16 +98874,20 @@ function getColumns(key, displayFields, isTree = false) {
98873
98874
  field: key,
98874
98875
  minWidth: 200
98875
98876
  }));
98876
- return (displayFragments.length ? displayFragments : COLUMN_FRAGMENTS[key]).map((fragment, index) => {
98877
+ const fragments = displayFragments.length ? displayFragments : COLUMN_FRAGMENTS[key];
98878
+ const firstDisplayColumnIndex = fragments.findIndex((fragment) => fragment && !["radio", "checkbox"].includes(fragment.type));
98879
+ return fragments.map((fragment, index) => {
98877
98880
  if (!fragment) return null;
98881
+ const isTreeColumn = isTree && index === firstDisplayColumnIndex;
98878
98882
  return {
98879
98883
  ...BASE_COLUMN_CONFIG,
98880
- treeNode: isTree && index === 0,
98881
98884
  ...fragment,
98882
- slots: fragment.slots ? {
98885
+ treeNode: isTreeColumn,
98886
+ slots: {
98883
98887
  ...BASE_COLUMN_CONFIG.slots,
98884
- ...fragment.slots
98885
- } : BASE_COLUMN_CONFIG.slots
98888
+ ...fragment.slots,
98889
+ ...isTreeColumn ? { default: "rdo_version_render" } : {}
98890
+ }
98886
98891
  };
98887
98892
  }).filter(Boolean);
98888
98893
  }
@@ -99713,7 +99718,8 @@ async function applyAutofillOnSubTableRowInit(doc, subFieldKey, rowIndex, fetchS
99713
99718
  rowIndexes: [rowIndex],
99714
99719
  fetchSource
99715
99720
  });
99716
- if (Object.keys(updates).length) doc.dataManager.setMultiple(updates, "hydrate");
99721
+ const initialUpdates = Object.fromEntries(Object.entries(updates).filter(([path]) => doc.dataManager.getStoredValue(path) === void 0));
99722
+ if (Object.keys(initialUpdates).length) doc.dataManager.setMultiple(initialUpdates, "hydrate");
99717
99723
  }
99718
99724
  var init_autofill_runtime = __esmMin((() => {
99719
99725
  init_core$1();
@@ -101141,6 +101147,34 @@ var init_hydrate_utils = __esmMin((() => {
101141
101147
  init_subtable_path();
101142
101148
  }));
101143
101149
  //#endregion
101150
+ //#region src/core/data/initialization.ts
101151
+ /**
101152
+ * 初始化值语义:
101153
+ * - undefined:尚未赋值,首次填报或新增行时可以带入初值。
101154
+ * - null:用户主动清空;'':已写入的空字符串。二者都必须保留。
101155
+ * - 0、false 及其他已定义的值同样不能被初值覆盖。
101156
+ * isBlank/isPresent 用于业务校验,不能用于判断是否允许初始化。
101157
+ */
101158
+ function isUninitialized(value) {
101159
+ return value === void 0;
101160
+ }
101161
+ /** 是否已有填报记录;与编辑/打印等展示模式无关。 */
101162
+ function hasPersistedDocumentData(context) {
101163
+ const { dataId, dataStatus, instanceStatus } = context.docRuntimeMeta ?? {};
101164
+ return Boolean(dataId || dataStatus === "STASH" || dataStatus === "SUBMIT" || instanceStatus && instanceStatus !== "UNFILLED");
101165
+ }
101166
+ /**
101167
+ * 文档初值只在首次填报时带入。暂存、提交或已有填报数据的实例重开时,
101168
+ * 即使接口未返回某个字段,也不能重新初始化;新增行另走行初始化入口。
101169
+ * 没有实例状态的模板模拟填报仍可初始化;设计/打印不执行填报初始化,
101170
+ * 模板预览展示默认值由 DataManager 单独处理。
101171
+ */
101172
+ function shouldInitializeDocumentData(context) {
101173
+ if (context.mode === "edit" || context.mode === "print") return false;
101174
+ return !hasPersistedDocumentData(context);
101175
+ }
101176
+ var init_initialization = __esmMin((() => {}));
101177
+ //#endregion
101144
101178
  //#region src/core/data/DataManager.ts
101145
101179
  var DEFAULT_EMPTY_ITEM, DataManager;
101146
101180
  var init_DataManager = __esmMin((() => {
@@ -101156,6 +101190,7 @@ var init_DataManager = __esmMin((() => {
101156
101190
  init_hydrate_utils();
101157
101191
  init_path_templates();
101158
101192
  init_subtable_path();
101193
+ init_initialization();
101159
101194
  init_defineProperty();
101160
101195
  DEFAULT_EMPTY_ITEM = Object.freeze({ __gw_default: true });
101161
101196
  DataManager = class {
@@ -101211,6 +101246,25 @@ var init_DataManager = __esmMin((() => {
101211
101246
  "defaults",
101212
101247
  /* @__PURE__ */ new Map()
101213
101248
  );
101249
+ _defineProperty(
101250
+ this,
101251
+ /** 表结构/检验项元数据,不属于用户输入初值,重开和打印时仍需读取。 */
101252
+ "configurationDefaults",
101253
+ /* @__PURE__ */ new Map()
101254
+ );
101255
+ _defineProperty(
101256
+ this,
101257
+ /** 参数映射的行模板;保存过的文档只允许对新增行使用。 */
101258
+ "rowInitData",
101259
+ {}
101260
+ );
101261
+ _defineProperty(
101262
+ this,
101263
+ /** 按对象身份追踪本次新增行,插入/删除导致下标变化时不会误初始化旧行。 */
101264
+ "initializedRows",
101265
+ /* @__PURE__ */ new WeakSet()
101266
+ );
101267
+ _defineProperty(this, "documentInitializationEnabled", true);
101214
101268
  this.doc = options === null || options === void 0 ? void 0 : options.doc;
101215
101269
  this.rawData = this.deepClone((options === null || options === void 0 ? void 0 : options.data) ?? {});
101216
101270
  }
@@ -101263,12 +101317,13 @@ var init_DataManager = __esmMin((() => {
101263
101317
  materializePendingDefaults() {
101264
101318
  const updates = {};
101265
101319
  const materialized = [];
101266
- for (const [path, defaultValue] of this.defaults) {
101320
+ for (const [path, defaultValue] of this.allDefaults()) {
101267
101321
  if (defaultValue === void 0) continue;
101268
101322
  const concretePaths = path.includes("[n") ? expandInitPathTemplates(path, this.rawData) : [path];
101269
101323
  for (const realPath of concretePaths) {
101270
- if (this.getByPath(this.rawData, realPath) !== void 0) continue;
101271
- const value = this.getDefault(realPath);
101324
+ if (!this.canApplyDefaultAt(realPath)) continue;
101325
+ if (this.getStoredValue(realPath) !== void 0) continue;
101326
+ const value = this.getApplicableDefault(realPath);
101272
101327
  if (value === void 0) continue;
101273
101328
  updates[realPath] = value;
101274
101329
  materialized.push(realPath);
@@ -101507,19 +101562,23 @@ var init_DataManager = __esmMin((() => {
101507
101562
  if (this.flushingDependencies && source === "dependency" && !isDerivedDataPath(path)) this.dependencyFlushChangedPaths.add(path);
101508
101563
  }
101509
101564
  /**
101510
- * 根据 jsonpath 获取原始数据(仅返回 rawData 中的值)
101565
+ * 根据 jsonpath 读取字段。首次填报和本次新增行允许 undefined 回落到输入初值;
101566
+ * null / '' 保留。结构配置独立读取,不受输入初值生命周期限制。
101511
101567
  * @param path jsonpath 路径 (例如: "document.body.children[0].text" 或 "user.name")
101512
101568
  * @returns 指定路径的值,不存在返回 undefined
101513
101569
  */
101514
101570
  get(path) {
101571
+ const value = this.getStoredValue(path);
101572
+ return value === void 0 ? this.getApplicableDefault(path) : value;
101573
+ }
101574
+ /** 仅读取实际数据,不回落到默认值。初始化写入据此保护已有值与主动清空。 */
101575
+ getStoredValue(path) {
101515
101576
  const inferred = this.infer2DPathAndCoords(path);
101516
101577
  if (inferred) {
101517
101578
  const value2D = this.get2DByCoords(inferred.logicalPath, inferred.coords);
101518
101579
  if (value2D !== void 0) return value2D;
101519
101580
  }
101520
- let value = this.getByPath(this.rawData, path);
101521
- if (value === void 0) value = this.getDefault(path);
101522
- return value;
101581
+ return this.getByPath(this.rawData, path);
101523
101582
  }
101524
101583
  /**
101525
101584
  * 根据 jsonpath 获取标签数据
@@ -101550,7 +101609,7 @@ var init_DataManager = __esmMin((() => {
101550
101609
  if (!subFieldKey) return 0;
101551
101610
  const prefix = `$.${subFieldKey}[`;
101552
101611
  let maxIndex = -1;
101553
- for (const path of this.defaults.keys()) {
101612
+ for (const path of this.allDefaults().keys()) {
101554
101613
  if (!path.startsWith(prefix)) continue;
101555
101614
  const match = path.slice(prefix.length).match(/^(\d+)\]/);
101556
101615
  if (match) maxIndex = Math.max(maxIndex, Number(match[1]));
@@ -101927,6 +101986,7 @@ var init_DataManager = __esmMin((() => {
101927
101986
  const index = arr.length - 1;
101928
101987
  this.ensureAxisRowAndUid(tableKey, index, axisInfo.axis);
101929
101988
  }
101989
+ this.applyRowInitData(tableKey, arr.length - 1);
101930
101990
  });
101931
101991
  this.emit(path, arr, oldValue);
101932
101992
  return true;
@@ -101987,6 +102047,7 @@ var init_DataManager = __esmMin((() => {
101987
102047
  this.shiftFieldRuntimeConfigAfterRowInsert(path, storageIndex);
101988
102048
  this.shiftDependencyGraphAfterRowInsert(path, storageIndex);
101989
102049
  this.shiftSubFieldConfigAfterRowInsert(path, storageIndex);
102050
+ clonedValues.forEach((_, offset) => this.applyRowInitData(tableKey, storageIndex + offset));
101990
102051
  return true;
101991
102052
  } catch (error) {
101992
102053
  console.error(`Failed to insert value at path "${path}":`, error);
@@ -102046,22 +102107,26 @@ var init_DataManager = __esmMin((() => {
102046
102107
  */
102047
102108
  getRawData() {
102048
102109
  const data = this.deepClone(this.rawData);
102049
- for (const path of this.defaults.keys()) {
102050
- if (this.defaults.get(path) === void 0) continue;
102110
+ for (const [path, value] of this.allDefaults()) {
102111
+ if (value === void 0) continue;
102051
102112
  if (path.includes("[n")) continue;
102052
- if (this.getByPath(data, path) !== void 0) continue;
102053
- this.setByPath(data, path, this.getDefault(path));
102113
+ if (this.getStoredValue(path) !== void 0) continue;
102114
+ const defaultValue = this.getApplicableDefault(path);
102115
+ if (defaultValue !== void 0) this.setSnapshotDefault(data, path, defaultValue);
102054
102116
  }
102055
102117
  return data;
102056
102118
  }
102057
102119
  /**
102058
102120
  * 设置整个原始数据
102059
102121
  * @param data 新的 JSON 数据
102060
- * @param defaultsMap 默认值, 字段值为 undefined 时才懒填充,不覆盖接口数据
102122
+ * @param defaultsMap 默认值:首次填报仅为 undefined 懒填充,保存过的实例仅供新增行使用
102061
102123
  */
102062
- setRawData(data, defaultsMap) {
102124
+ setRawData(data, defaultsMap, options) {
102063
102125
  const oldData = this.rawData;
102064
102126
  this.rawData = this.deepClone(data);
102127
+ this.initializedRows = /* @__PURE__ */ new WeakSet();
102128
+ this.documentInitializationEnabled = (options === null || options === void 0 ? void 0 : options.initializeValues) !== false;
102129
+ if (options === null || options === void 0 ? void 0 : options.configurationDefaults) this.configurationDefaults = new Map(Object.entries(options.configurationDefaults));
102065
102130
  this.fieldRuntimeConfigByPath.clear();
102066
102131
  this.depGraph.clear();
102067
102132
  this.ranImmediateDepKeys.clear();
@@ -102069,7 +102134,8 @@ var init_DataManager = __esmMin((() => {
102069
102134
  if (defaultsMap) this.setDefaults(defaultsMap);
102070
102135
  }
102071
102136
  /**
102072
- * 将初始化数据直接写入 rawData(仅填充空值,不覆盖接口数据)
102137
+ * 首次填报时将初始化数据写入 rawData,仅填 undefined;null / '' 是已赋值,必须保留。
102138
+ * 保存过的数据重新打开时不再赋初值,行模板仅保留给后续新增行使用。
102073
102139
  * 与 defaults(懒填充)不同,此方法在初始化阶段一次性写入
102074
102140
  *
102075
102141
  * 支持两种子表路径形式:
@@ -102077,9 +102143,14 @@ var init_DataManager = __esmMin((() => {
102077
102143
  * - 真实下标:直接写入指定行,如 `$.sub[0].field`
102078
102144
  *
102079
102145
  * 处理顺序:先展开 `[n]` 通配符,再写入真实下标路径。
102080
- * 这样可以保证:参数映射(`[n]`)先铺好默认值,自定义数据源(真实下标)再精确覆盖。
102146
+ * 参数映射(`[n]`)先填未赋值字段,自定义数据源(真实下标)再填剩余未赋值字段。
102081
102147
  */
102082
102148
  applyInitData(initDataMap) {
102149
+ this.rowInitData = Object.fromEntries(Object.entries(initDataMap).filter(([path, value]) => path.includes("[n") && value != null));
102150
+ if (!this.documentInitializationEnabled || this.doc && !shouldInitializeDocumentData(this.doc)) {
102151
+ this.syncSubTableRowsToLayout();
102152
+ return;
102153
+ }
102083
102154
  for (const [path, value] of Object.entries(initDataMap)) {
102084
102155
  if (value === void 0 || value === null) continue;
102085
102156
  const parse = parseValuePath(path);
@@ -102094,8 +102165,7 @@ var init_DataManager = __esmMin((() => {
102094
102165
  if (value === void 0 || value === null) continue;
102095
102166
  const parse = parseValuePath(path);
102096
102167
  if (!(parse.isSubTable || parse.isLink)) {
102097
- const existing = this.getByPath(this.rawData, path);
102098
- if (existing === void 0 || existing === null) try {
102168
+ if (isUninitialized(this.getByPath(this.rawData, path))) try {
102099
102169
  if (!this.set(path, value, "hydrate")) console.warn(`applyInitData: set returned false for path "${path}"`);
102100
102170
  } catch (e) {
102101
102171
  console.warn(`applyInitData: failed to set path "${path}"`, e);
@@ -102105,20 +102175,39 @@ var init_DataManager = __esmMin((() => {
102105
102175
  this.syncSubTableRowsToLayout();
102106
102176
  }
102107
102177
  /**
102178
+ * 只初始化刚新增的行。参数写入实际数据,组件默认值继续懒读并在提交前物化。
102179
+ * 不提前物化默认值,避免其挡住当前主表选择的数据填充;复制行/null/'' 均保留。
102180
+ */
102181
+ applyRowInitData(subFieldKey, rowIndex) {
102182
+ var _this$doc7, _this$doc7$isInEditMo;
102183
+ if ((_this$doc7 = this.doc) === null || _this$doc7 === void 0 || (_this$doc7$isInEditMo = _this$doc7.isInEditMode) === null || _this$doc7$isInEditMo === void 0 ? void 0 : _this$doc7$isInEditMo.call(_this$doc7)) return;
102184
+ const row = this.getByPath(this.rawData, `$.${subFieldKey}[${rowIndex}]`);
102185
+ if (row && typeof row === "object") this.initializedRows.add(row);
102186
+ for (const [templatePath, value] of Object.entries(this.rowInitData)) {
102187
+ if (value == null || !templatePath.includes("[n")) continue;
102188
+ const parsed = parseValuePath(templatePath);
102189
+ if (parsed.parentFieldKey !== subFieldKey && parsed.linkFieldKey !== subFieldKey) continue;
102190
+ const paths = parsed.isLink ? expandInitPathTemplates(templatePath, this.rawData).filter((path) => {
102191
+ return [...path.matchAll(/\[(\d+)\]/g)].map((match) => Number(match[1]))[parsed.parentFieldKey === subFieldKey ? 0 : 1] === rowIndex;
102192
+ }) : [replacePathIndexPlaceholder(rowIndex, templatePath)];
102193
+ for (const path of paths) if (isUninitialized(this.getStoredValue(path))) this.set(path, this.formatRuntimeValue(value), "hydrate");
102194
+ }
102195
+ }
102196
+ /**
102108
102197
  * 按版面铺砖槽位补齐子表行数:
102109
102198
  * - 固定表:按槽位补齐自身子表行
102110
102199
  * - 二维/检验表:仅补齐关联轴(如 f_ewblink / f_jianyan2)
102111
102200
  * 不处理主体轴(如 f_ewb / f_jianyan1),避免覆盖接口行或误扩纵向轴。
102112
102201
  */
102113
102202
  syncSubTableRowsToLayout() {
102114
- var _this$doc7, _this$doc8;
102115
- const listSubTables = (_this$doc7 = this.doc) === null || _this$doc7 === void 0 || (_this$doc7 = _this$doc7.model) === null || _this$doc7 === void 0 ? void 0 : _this$doc7.getSubTableInfoList;
102203
+ var _this$doc8, _this$doc9;
102204
+ const listSubTables = (_this$doc8 = this.doc) === null || _this$doc8 === void 0 || (_this$doc8 = _this$doc8.model) === null || _this$doc8 === void 0 ? void 0 : _this$doc8.getSubTableInfoList;
102116
102205
  if (typeof listSubTables !== "function") return;
102117
- for (const info of listSubTables.call((_this$doc8 = this.doc) === null || _this$doc8 === void 0 ? void 0 : _this$doc8.model)) {
102118
- var _this$doc9;
102206
+ for (const info of listSubTables.call((_this$doc9 = this.doc) === null || _this$doc9 === void 0 ? void 0 : _this$doc9.model)) {
102207
+ var _this$doc10;
102119
102208
  if (!info.field) continue;
102120
102209
  const subTableKey = info.field;
102121
- const layoutRows = ((_this$doc9 = this.doc) === null || _this$doc9 === void 0 || (_this$doc9 = _this$doc9.model) === null || _this$doc9 === void 0 ? void 0 : _this$doc9.getSubTableLayoutSlotCount(subTableKey)) ?? 0;
102210
+ const layoutRows = ((_this$doc10 = this.doc) === null || _this$doc10 === void 0 || (_this$doc10 = _this$doc10.model) === null || _this$doc10 === void 0 ? void 0 : _this$doc10.getSubTableLayoutSlotCount(subTableKey)) ?? 0;
102122
102211
  if (layoutRows <= 0) continue;
102123
102212
  const dataRows = countSubTableDataRows(this.rawData, subTableKey);
102124
102213
  const targetRows = Math.max(dataRows, layoutRows);
@@ -102162,8 +102251,7 @@ var init_DataManager = __esmMin((() => {
102162
102251
  templatePath: path
102163
102252
  });
102164
102253
  const inferred = this.infer2DPathAndCoords(realPath);
102165
- const existing = inferred ? this.get2DByCoords(inferred.logicalPath, inferred.coords) : this.getByPath(this.rawData, realPath);
102166
- if (existing === void 0 || existing === null) try {
102254
+ if (isUninitialized(inferred ? this.get2DByCoords(inferred.logicalPath, inferred.coords) : this.getByPath(this.rawData, realPath))) try {
102167
102255
  if (this.set(realPath, value, "hydrate")) {
102168
102256
  this.clearPlaceholderFlag(yRows[y]);
102169
102257
  this.clearPlaceholderFlag(xRows[x]);
@@ -102199,8 +102287,7 @@ var init_DataManager = __esmMin((() => {
102199
102287
  const subTableArray = this.ensureSubTableRowCount(subTableKey, resolveSubTableRowCount(this.doc, subTableKey, this.rawData), false);
102200
102288
  for (let i = 0; i < subTableArray.length; i++) {
102201
102289
  const realPath = replacePathIndexPlaceholder(i, path);
102202
- const existing = this.getByPath(this.rawData, realPath);
102203
- if (existing === void 0 || existing === null) try {
102290
+ if (isUninitialized(this.getByPath(this.rawData, realPath))) try {
102204
102291
  if (this.set(realPath, value, "hydrate")) this.clearPlaceholderFlag(subTableArray[i]);
102205
102292
  else console.warn(`applyInitData: set returned false for path "${realPath}"`);
102206
102293
  } catch (e) {
@@ -102445,6 +102532,7 @@ var init_DataManager = __esmMin((() => {
102445
102532
  const bindingPaths = this.collectFieldBindingPaths(designValuePath);
102446
102533
  for (const path of bindingPaths) {
102447
102534
  this.defaults.delete(path);
102535
+ this.configurationDefaults.delete(path);
102448
102536
  this.fieldRuntimeConfigByPath.delete(path);
102449
102537
  this.subscriptions.delete(path);
102450
102538
  }
@@ -102463,6 +102551,7 @@ var init_DataManager = __esmMin((() => {
102463
102551
  const result = new Set(bases);
102464
102552
  const scanTargets = [
102465
102553
  ...this.defaults.keys(),
102554
+ ...this.configurationDefaults.keys(),
102466
102555
  ...this.fieldRuntimeConfigByPath.keys(),
102467
102556
  ...this.subscriptions.keys()
102468
102557
  ];
@@ -102527,15 +102616,60 @@ var init_DataManager = __esmMin((() => {
102527
102616
  * @returns 默认值,不存在返回 undefined
102528
102617
  */
102529
102618
  getDefault(path) {
102530
- if (this.defaults.has(path)) {
102531
- const value = this.defaults.get(path);
102532
- return this.formatRuntimeValue(value);
102619
+ for (const defaults of [this.configurationDefaults, this.defaults]) {
102620
+ const key = defaults.has(path) ? path : this.convertPathToWildcard(path);
102621
+ if (defaults.has(key)) return this.formatRuntimeValue(defaults.get(key));
102622
+ }
102623
+ }
102624
+ allDefaults() {
102625
+ return new Map([...this.configurationDefaults, ...[...this.defaults].filter(([path]) => !this.configurationDefaults.has(path))]);
102626
+ }
102627
+ /** 设计/未保存模板打印仍可展示默认值;重开或整表换数后不再隐式填充旧行。 */
102628
+ canApplyDocumentDefaults() {
102629
+ return this.documentInitializationEnabled && (!this.doc || this.doc.mode === "edit" || !hasPersistedDocumentData(this.doc));
102630
+ }
102631
+ canApplyDefaultAt(path) {
102632
+ if (this.configurationDefaults.has(path) || this.configurationDefaults.has(this.convertPathToWildcard(path)) || this.canApplyDocumentDefaults()) return true;
102633
+ const match = path.match(/^\$\.([^.[\]]+)\[(\d+)\](?:\[(\d+)\])?/);
102634
+ if (!match) return false;
102635
+ const [, tableKey = "", y = "", x] = match;
102636
+ return tableKey.split(":").some((key, index) => {
102637
+ const row = this.getByPath(this.rawData, `$.${key}[${index === 0 ? y : x}]`);
102638
+ return row && typeof row === "object" && this.initializedRows.has(row);
102639
+ });
102640
+ }
102641
+ getApplicableDefault(path) {
102642
+ if (!this.canApplyDefaultAt(path)) return void 0;
102643
+ if (path.endsWith("_lb_")) {
102644
+ const valuePath = path.slice(0, -LABEL_SUFFIX.length);
102645
+ const defaultValue = this.getDefault(valuePath);
102646
+ if (defaultValue !== void 0 && !isEqual(this.get(valuePath), defaultValue)) return;
102533
102647
  }
102534
- const pathWithWildcard = this.convertPathToWildcard(path);
102535
- if (pathWithWildcard !== path && this.defaults.has(pathWithWildcard)) {
102536
- const value = this.defaults.get(pathWithWildcard);
102537
- return this.formatRuntimeValue(value);
102648
+ return this.getDefault(path);
102649
+ }
102650
+ /** 快照的交叉区保持 UID 稀疏结构,不能按 [y][x] 写成嵌套数组。 */
102651
+ setSnapshotDefault(data, path, value) {
102652
+ const inferred = this.infer2DPathAndCoords(path);
102653
+ const parsed = inferred && this.parse2DPath(inferred.logicalPath);
102654
+ if (inferred && (parsed === null || parsed === void 0 ? void 0 : parsed.tableKey.includes(":"))) {
102655
+ var _data$yKey, _data$xKey;
102656
+ const [yKey = "", xKey = ""] = parsed.tableKey.split(":");
102657
+ const yUid = (_data$yKey = data[yKey]) === null || _data$yKey === void 0 || (_data$yKey = _data$yKey[inferred.coords.y]) === null || _data$yKey === void 0 ? void 0 : _data$yKey.__gw_y_uid;
102658
+ const xUid = (_data$xKey = data[xKey]) === null || _data$xKey === void 0 || (_data$xKey = _data$xKey[inferred.coords.x]) === null || _data$xKey === void 0 ? void 0 : _data$xKey.__gw_x_uid;
102659
+ if (!yUid || !xUid) return;
102660
+ const rows = data[parsed.tableKey] ??= [];
102661
+ let row = rows.find((item) => (item === null || item === void 0 ? void 0 : item.__gw_y_uid) === yUid && (item === null || item === void 0 ? void 0 : item.__gw_x_uid) === xUid);
102662
+ if (!row) {
102663
+ row = {
102664
+ __gw_y_uid: yUid,
102665
+ __gw_x_uid: xUid
102666
+ };
102667
+ rows.push(row);
102668
+ }
102669
+ if (this.getFieldFromRow(row, parsed.fieldPath) === void 0) this.assignField(row, parsed.fieldPath, this.deepClone(value));
102670
+ return;
102538
102671
  }
102672
+ if (this.getByPath(data, path) === void 0) this.setByPath(data, path, this.deepClone(value));
102539
102673
  }
102540
102674
  /**
102541
102675
  * 将路径中的具体数组索引转换为默认值通配符
@@ -102689,6 +102823,10 @@ var init_DataManager = __esmMin((() => {
102689
102823
  this.emit("$", {}, oldData);
102690
102824
  this.subscriptions.clear();
102691
102825
  this.defaults.clear();
102826
+ this.configurationDefaults.clear();
102827
+ this.rowInitData = {};
102828
+ this.initializedRows = /* @__PURE__ */ new WeakSet();
102829
+ this.documentInitializationEnabled = true;
102692
102830
  this.ranImmediateDepKeys.clear();
102693
102831
  this.fieldRuntimeConfigByPath.clear();
102694
102832
  }
@@ -103063,12 +103201,14 @@ function appendOrFillScanRow(doc, subFieldKey, row, isEmptyRow = (item) => !hasS
103063
103201
  const emptyIndex = rows.findIndex((r) => r && !r.deleted_ && isEmptyRow(r));
103064
103202
  if (emptyIndex >= 0) {
103065
103203
  const existing = rows[emptyIndex];
103204
+ const fillsPlaceholder = !hasSubtableBusinessData(existing);
103066
103205
  const frontKey = ensureFrontRowKey(existing);
103067
103206
  if (frontKey) doc.dataManager.set(`${arrayPath}[${emptyIndex}].${FRONT_ROW_KEY}`, frontKey, "user");
103068
103207
  for (const [key, value] of Object.entries(row)) {
103069
103208
  if (key === "front_row_key_" || key === "id_" || key === "id" || key === "group_") continue;
103070
103209
  doc.dataManager.set(`${arrayPath}[${emptyIndex}].${key}`, value, "user");
103071
103210
  }
103211
+ if (fillsPlaceholder) doc.dataManager.applyRowInitData(subFieldKey, emptyIndex);
103072
103212
  return emptyIndex;
103073
103213
  }
103074
103214
  ensureFrontRowKey(row);
@@ -105732,7 +105872,7 @@ var init_scan$2 = __esmMin((() => {
105732
105872
  }
105733
105873
  const selected = await pickInventoryScanRecord(records);
105734
105874
  if (!selected) return;
105735
- const rowIndex = appendOrFillScanRow(doc, subFieldKey, buildAllocateScanRow(selected, parsed, resolveScanFillData(input)));
105875
+ const rowIndex = appendOrFillScanRow(doc, subFieldKey, buildAllocateScanRow(selected, parsed, resolveScanFillData(input)), (item) => isProductBatchEmptyRow(item) && [F$5.inventory, F$5.batch].every((key) => item[key] == null || item[key] === ""));
105736
105876
  await doc.dataManager.whenEmitSettled();
105737
105877
  await hydrateSubtableRowLabels(doc, subFieldKey, [rowIndex]);
105738
105878
  };
@@ -105863,13 +106003,15 @@ var init_fields$5 = __esmMin((() => {
105863
106003
  match: { fieldKey: F$4.material },
105864
106004
  defaultProps: {
105865
106005
  disabled: true,
105866
- fieldDisabled: true
106006
+ fieldDisabled: true,
106007
+ required: false
105867
106008
  }
105868
106009
  }, {
105869
106010
  match: { fieldKey: F$4.materialBalancePercent },
105870
106011
  defaultProps: {
105871
106012
  disabled: true,
105872
106013
  fieldDisabled: true,
106014
+ required: false,
105873
106015
  keepExceptionHighlight: true
105874
106016
  }
105875
106017
  }];
@@ -106834,7 +106976,8 @@ var init_fields$2 = __esmMin((() => {
106834
106976
  ] },
106835
106977
  defaultProps: {
106836
106978
  disabled: true,
106837
- fieldDisabled: true
106979
+ fieldDisabled: true,
106980
+ required: false
106838
106981
  }
106839
106982
  }];
106840
106983
  }));
@@ -116093,6 +116236,7 @@ var init_row_runtime_engine = __esmMin((() => {
116093
116236
  init_table_runtime_utils();
116094
116237
  init_runtime_handlers();
116095
116238
  init_core$1();
116239
+ init_initialization();
116096
116240
  init_defineProperty();
116097
116241
  RowRuntimeEngine = class {
116098
116242
  constructor(doc) {
@@ -116103,18 +116247,18 @@ var init_row_runtime_engine = __esmMin((() => {
116103
116247
  return Boolean(ctx.profile.rowSourceField) || this.assignmentsFor(ctx, "onRowInit").length > 0 || this.handlersFor(ctx, "onRowInit").length > 0;
116104
116248
  }
116105
116249
  /** 对单行执行行初始化 */
116106
- applyRowInit(ctx, rowIndex, rowSource) {
116250
+ applyRowInit(ctx, rowIndex, rowSource, initializeValues = true) {
116107
116251
  const rowPath = ctx.rowPath(rowIndex);
116108
116252
  const row = ctx.getRow(rowIndex);
116109
116253
  const sourceField = ctx.profile.rowSourceField;
116110
116254
  if (sourceField && !isPresent(row === null || row === void 0 ? void 0 : row[sourceField])) this.doc.dataManager.set(`${rowPath}.${sourceField}`, rowSource ?? "manual", "hydrate");
116111
- for (const assignment of this.assignmentsFor(ctx, "onRowInit")) this.applyContextAssignment(rowPath, assignment);
116255
+ if (initializeValues) for (const assignment of this.assignmentsFor(ctx, "onRowInit")) this.applyContextAssignment(rowPath, assignment);
116112
116256
  for (const handler of this.handlersFor(ctx, "onRowInit")) runRowHandler(ctx.profile.type, handler.handler, this.doc, ctx.subFieldKey, rowIndex);
116113
116257
  }
116114
116258
  /** 初始化时对所有未软删行执行行初始化 */
116115
- applyRowInitForAllRows(ctx) {
116259
+ applyRowInitForAllRows(ctx, initializeValues = shouldInitializeDocumentData(this.doc)) {
116116
116260
  if (!this.hasRowInit(ctx)) return;
116117
- for (const rowIndex of ctx.getActiveRowIndexes()) this.applyRowInit(ctx, rowIndex);
116261
+ for (const rowIndex of ctx.getActiveRowIndexes()) this.applyRowInit(ctx, rowIndex, void 0, initializeValues);
116118
116262
  }
116119
116263
  /** 字段变更时执行 when=onFieldChange 的行处理器(按 watch 过滤) */
116120
116264
  applyRowHandlersOnFieldChange(ctx, change, fieldChange) {
@@ -116141,7 +116285,7 @@ var init_row_runtime_engine = __esmMin((() => {
116141
116285
  const contextValue = readContextParam(this.doc, assignment.paramKey);
116142
116286
  if (contextValue === void 0) return;
116143
116287
  const fieldPath = `${rowPath}.${assignment.fieldKey}`;
116144
- if (assignment.onlyIfEmpty && isPresent(this.doc.dataManager.get(fieldPath))) return;
116288
+ if (!isUninitialized(this.doc.dataManager.get(fieldPath))) return;
116145
116289
  this.doc.dataManager.set(fieldPath, contextValue, "hydrate");
116146
116290
  }
116147
116291
  };
@@ -116408,6 +116552,7 @@ var init_init_load_engine = __esmMin((() => {
116408
116552
  init_runtime_handlers();
116409
116553
  init_table_runtime_utils();
116410
116554
  init_core$1();
116555
+ init_initialization();
116411
116556
  init_defineProperty();
116412
116557
  InitLoadEngine = class {
116413
116558
  constructor(doc) {
@@ -116416,6 +116561,7 @@ var init_init_load_engine = __esmMin((() => {
116416
116561
  }
116417
116562
  async apply(ctx) {
116418
116563
  var _ctx$region$widgetMet;
116564
+ if (!shouldInitializeDocumentData(this.doc)) return;
116419
116565
  const config = ctx.profile.initLoad;
116420
116566
  if (!config) return;
116421
116567
  const regionProps = (_ctx$region$widgetMet = ctx.region.widgetMeta) === null || _ctx$region$widgetMet === void 0 ? void 0 : _ctx$region$widgetMet.props;
@@ -116448,7 +116594,7 @@ var init_init_load_engine = __esmMin((() => {
116448
116594
  for (const fill of fills) {
116449
116595
  const contextValue = readContextParam(this.doc, fill.paramKey);
116450
116596
  if (contextValue === void 0) continue;
116451
- if (fill.onlyIfEmpty && isPresent(next[fill.fieldKey])) continue;
116597
+ if (!isUninitialized(next[fill.fieldKey])) continue;
116452
116598
  next[fill.fieldKey] = contextValue;
116453
116599
  }
116454
116600
  return next;
@@ -116457,6 +116603,7 @@ var init_init_load_engine = __esmMin((() => {
116457
116603
  ...row,
116458
116604
  ...config.rowPatch
116459
116605
  }));
116606
+ if (!shouldInitializeDocumentData(this.doc) || this.shouldSkip(subFieldKey, config)) return;
116460
116607
  const deletedRows = this.readExistingRows(subFieldKey).filter((row) => row.deleted_);
116461
116608
  this.doc.dataManager.set(subFieldKey, [...rows, ...deletedRows], "hydrate");
116462
116609
  }
@@ -116474,7 +116621,7 @@ var init_init_load_engine = __esmMin((() => {
116474
116621
  shouldSkip(subFieldKey, config) {
116475
116622
  const existingRows = this.readExistingRows(subFieldKey).filter((row) => !row.deleted_);
116476
116623
  if (existingRows.length === 0) return false;
116477
- if (config.skipWhenNonemptyRows && this.hasNonemptyRow(existingRows)) return true;
116624
+ if (config.skipWhenNonemptyRows && this.hasInitializedRow(existingRows)) return true;
116478
116625
  const skipIfRowHasAny = config.skipIfRowHasAny;
116479
116626
  if (!(skipIfRowHasAny === null || skipIfRowHasAny === void 0 ? void 0 : skipIfRowHasAny.length)) return false;
116480
116627
  return existingRows.some((row) => skipIfRowHasAny.some((key) => isPresent(row[key])));
@@ -116485,7 +116632,8 @@ var init_init_load_engine = __esmMin((() => {
116485
116632
  if (raw && typeof raw === "object" && Array.isArray(raw.data)) return raw.data;
116486
116633
  return [];
116487
116634
  }
116488
- hasNonemptyRow(rows) {
116635
+ /** null / '' 也是已赋值;只允许替换尚未填写业务字段的占位行。 */
116636
+ hasInitializedRow(rows) {
116489
116637
  const metaKeys = /* @__PURE__ */ new Set([
116490
116638
  "_DICT",
116491
116639
  "_OPCT",
@@ -116497,7 +116645,7 @@ var init_init_load_engine = __esmMin((() => {
116497
116645
  ]);
116498
116646
  return rows.some((row) => Object.entries(row).some(([key, value]) => {
116499
116647
  if (metaKeys.has(key) || key.startsWith("__gw_")) return false;
116500
- return value != null && value !== "";
116648
+ return !isUninitialized(value);
116501
116649
  }));
116502
116650
  }
116503
116651
  };
@@ -116509,6 +116657,7 @@ var init_main_field_bind_engine = __esmMin((() => {
116509
116657
  init_core$1();
116510
116658
  init_field_type();
116511
116659
  init_table_runtime_utils();
116660
+ init_initialization();
116512
116661
  init_defineProperty();
116513
116662
  MainFieldBindEngine = class {
116514
116663
  constructor(doc) {
@@ -116516,6 +116665,7 @@ var init_main_field_bind_engine = __esmMin((() => {
116516
116665
  this.doc = doc;
116517
116666
  }
116518
116667
  apply(bindings) {
116668
+ if (!shouldInitializeDocumentData(this.doc)) return;
116519
116669
  const entries = getWidgetFieldEntries(this.doc);
116520
116670
  const updates = {};
116521
116671
  for (const binding of bindings) {
@@ -116531,6 +116681,7 @@ var init_main_field_bind_engine = __esmMin((() => {
116531
116681
  if ((_binding$excludeField = binding.excludeFieldKeys) === null || _binding$excludeField === void 0 ? void 0 : _binding$excludeField.includes(fieldKey)) continue;
116532
116682
  const fieldInfo = (_this$doc$fieldModelQ = this.doc.fieldModelQuery) === null || _this$doc$fieldModelQ === void 0 ? void 0 : _this$doc$fieldModelQ.getFieldByKeyAsync(this.doc.mainModelKey, fieldKey);
116533
116683
  if (!this.matchesMainFieldBinding(binding, field.fieldType, fieldInfo)) continue;
116684
+ if (!isUninitialized(this.doc.dataManager.getStoredValue(valuePath))) continue;
116534
116685
  updates[valuePath] = contextValue;
116535
116686
  }
116536
116687
  }
@@ -116561,6 +116712,7 @@ var init_table_runtime = __esmMin((() => {
116561
116712
  init_table_runtime_context();
116562
116713
  init_computed();
116563
116714
  init_autofill_runtime();
116715
+ init_initialization();
116564
116716
  init_defineProperty();
116565
116717
  TableRuntime = class {
116566
116718
  constructor(doc) {
@@ -116586,17 +116738,18 @@ var init_table_runtime = __esmMin((() => {
116586
116738
  return this.contexts.length > 0;
116587
116739
  }
116588
116740
  /** 文档初始化时执行全套运行时逻辑 */
116589
- async onInit() {
116741
+ async onInit(options = {}) {
116590
116742
  var _this$doc$isInEditMod, _this$doc;
116591
116743
  if ((_this$doc$isInEditMod = (_this$doc = this.doc).isInEditMode) === null || _this$doc$isInEditMod === void 0 ? void 0 : _this$doc$isInEditMod.call(_this$doc)) return;
116744
+ const initializeValues = options.initializeValues !== false && shouldInitializeDocumentData(this.doc);
116592
116745
  const bindings = this.mergeMainFieldBindings();
116593
- if (bindings.length) this.mainFieldBind.apply(bindings);
116746
+ if (initializeValues && bindings.length) this.mainFieldBind.apply(bindings);
116594
116747
  for (const ctx of this.contexts) {
116595
- await this.initLoad.apply(ctx);
116596
- this.row.applyRowInitForAllRows(ctx);
116748
+ if (initializeValues) await this.initLoad.apply(ctx);
116749
+ this.row.applyRowInitForAllRows(ctx, initializeValues);
116597
116750
  this.linkage.applyForSubTable(ctx);
116598
116751
  this.rule.applyOnInit(ctx);
116599
- this.remoteSync.applyOnInit(ctx);
116752
+ if (initializeValues) this.remoteSync.applyOnInit(ctx);
116600
116753
  }
116601
116754
  }
116602
116755
  /**
@@ -116605,6 +116758,7 @@ var init_table_runtime = __esmMin((() => {
116605
116758
  onRowInit(subFieldKey, rowIndex, rowSource) {
116606
116759
  var _this$doc$isInEditMod2, _this$doc2;
116607
116760
  if ((_this$doc$isInEditMod2 = (_this$doc2 = this.doc).isInEditMode) === null || _this$doc$isInEditMod2 === void 0 ? void 0 : _this$doc$isInEditMod2.call(_this$doc2)) return;
116761
+ this.doc.dataManager.applyRowInitData(subFieldKey, rowIndex);
116608
116762
  const ctx = this.findContext(subFieldKey);
116609
116763
  if (ctx) {
116610
116764
  this.row.applyRowInit(ctx, rowIndex, rowSource);
@@ -127341,6 +127495,7 @@ var init_material_consume_table_controller = __esmMin((() => {
127341
127495
  init_bom_validator$1();
127342
127496
  init_label_parse_rule();
127343
127497
  init_sub_field_config();
127498
+ init_initialization();
127344
127499
  init_base$2();
127345
127500
  init_data();
127346
127501
  init_uom_convert_runtime();
@@ -127895,7 +128050,7 @@ var init_material_consume_table_controller = __esmMin((() => {
127895
128050
  (_this$setupUomUnsubsc = this.setupUomUnsubscribe) === null || _this$setupUomUnsubsc === void 0 || _this$setupUomUnsubsc.call(this);
127896
128051
  this.setupDoc = opts.doc;
127897
128052
  this.unitConversionRules = getUnitConversionRulesFromDoc(opts.doc);
127898
- const initializedRowIndexes = this.initTableData(opts.doc.dataManager, opts.subTableInfo.subFieldKey, opts.defaultRowData);
128053
+ const initializedRowIndexes = shouldInitializeDocumentData(opts.doc) ? this.initTableData(opts.doc.dataManager, opts.subTableInfo.subFieldKey, opts.defaultRowData) : [];
127899
128054
  await hydrateSubtableRowLabels(opts.doc, opts.subTableInfo.subFieldKey, initializedRowIndexes);
127900
128055
  let materialNoNum = this.materialNoNum;
127901
128056
  if (this.dataStatus !== "SUBMIT") this.syncQtyRequiredFromBom(opts.doc);
@@ -128589,6 +128744,7 @@ var init_material_consume_util = __esmMin((() => {
128589
128744
  init_material_consume_table_controller();
128590
128745
  init_types$4();
128591
128746
  init_helpers();
128747
+ init_product_id_query();
128592
128748
  syncMaterialConsumeBomInfo = async (id, docModel) => {
128593
128749
  const allList = await api$1.apaas.onlineFormTmpl.getGetBomByFormTmplId({ id }) || [];
128594
128750
  const formTmplBomList = allList.filter((e) => !!e.table_key_);
@@ -128625,7 +128781,7 @@ var init_material_consume_util = __esmMin((() => {
128625
128781
  const subFieldKey = table_key_.replace("$.", "");
128626
128782
  const rows = doc.dataManager.getRawData()[subFieldKey] || [];
128627
128783
  const activeCount = rows.filter((row) => !(row === null || row === void 0 ? void 0 : row.deleted_)).length;
128628
- if (isBomPattern) {
128784
+ if (isBomPattern || personal_bom_enabled_) {
128629
128785
  const entries = personal_bom_enabled_ ? entries_ : tmplBomC.bomEntries;
128630
128786
  const includedIds = [];
128631
128787
  (entries || []).forEach((e) => {
@@ -128634,11 +128790,11 @@ var init_material_consume_util = __esmMin((() => {
128634
128790
  includedIds.push(_e.product_id_.split(":").pop());
128635
128791
  });
128636
128792
  });
128637
- subConfig[`${table_key_}[n].product_id_`] = { "id_.in": includedIds };
128638
- repeat(activeCount || 1, (index) => {
128639
- MCDataUtil.updateQtyRequiredDisablement(doc.dataManager, `${table_key_}[${index}]`, true);
128640
- });
128793
+ subConfig[`${table_key_}[n].product_id_`] = { "id_.in": includedIds.length ? includedIds : [EMPTY_PRODUCT_VERSION_ID] };
128641
128794
  }
128795
+ if (isBomPattern) repeat(activeCount || 1, (index) => {
128796
+ MCDataUtil.updateQtyRequiredDisablement(doc.dataManager, `${table_key_}[${index}]`, true);
128797
+ });
128642
128798
  rows.forEach((row, rowIndex) => {
128643
128799
  if (row === null || row === void 0 ? void 0 : row.deleted_) return;
128644
128800
  const rowPath = `${table_key_}[${rowIndex}]`;
@@ -128719,18 +128875,11 @@ function findObjectBom(formInstBom, belongingObject) {
128719
128875
  const objectBomList = formInstBom.formTmplObjectBomList;
128720
128876
  return objectBomList === null || objectBomList === void 0 ? void 0 : objectBomList.find((item) => item.object_key_ === belongingObject);
128721
128877
  }
128722
- function normalizeSubFields(subFields) {
128723
- if (!subFields) return [];
128724
- return (Array.isArray(subFields) ? subFields : Object.values(subFields)).filter((f) => Boolean((f === null || f === void 0 ? void 0 : f.used) && (f === null || f === void 0 ? void 0 : f.key)));
128725
- }
128726
- function matchFieldBiz(field, bizType) {
128727
- return (field.bizType || field.type) === bizType;
128728
- }
128729
- /** 在指定消耗对象子字段中,按 belongingObject + bizType/type 定位 product / qty / qty_required */
128730
- function pickObjectFieldKeys(subFields, belongingObject) {
128878
+ /** 从当前模型中定位指定消耗对象的物料、数量和需求数量字段。 */
128879
+ function pickObjectFieldKeys(modelFields, belongingObject) {
128731
128880
  var _byBiz, _byBiz2;
128732
- const list = normalizeSubFields(subFields).filter((field) => !belongingObject || !field.belongingObject || field.belongingObject === belongingObject);
128733
- const byBiz = (bizType) => list.find((field) => matchFieldBiz(field, bizType));
128881
+ const list = modelFields.filter((field) => field.belongingObject === belongingObject);
128882
+ const byBiz = (bizType) => list.find((field) => (field.bizType || field.type) === bizType);
128734
128883
  const qtyField = byBiz(FIELD_TYPE.QTY);
128735
128884
  return {
128736
128885
  productKey: (_byBiz = byBiz(FIELD_TYPE.PRODUCT)) === null || _byBiz === void 0 ? void 0 : _byBiz.key,
@@ -128866,12 +129015,12 @@ function getObjectBomDropdownQuery(fieldType, opts) {
128866
129015
  */
128867
129016
  async function validateObjectBomQtyOnSubmit(opts) {
128868
129017
  var _formInstBom$sequence;
128869
- const { formState, objectFieldList, formInstBom } = opts;
129018
+ const { formState, objectFieldList, modelFields, formInstBom } = opts;
128870
129019
  if (!formInstBom || !(objectFieldList === null || objectFieldList === void 0 ? void 0 : objectFieldList.length)) return null;
128871
129020
  const sequential = !!((_formInstBom$sequence = formInstBom.sequenceEntries) === null || _formInstBom$sequence === void 0 || (_formInstBom$sequence = _formInstBom$sequence[0]) === null || _formInstBom$sequence === void 0 ? void 0 : _formInstBom$sequence.enabled_);
128872
129021
  for (const obj of objectFieldList) {
128873
129022
  if (!(obj === null || obj === void 0 ? void 0 : obj.objectField)) continue;
128874
- const { productKey, qtyKey, qtyRequiredKey, qtyFieldName } = pickObjectFieldKeys(obj.subFields, obj.objectField);
129023
+ const { productKey, qtyKey, qtyRequiredKey, qtyFieldName } = pickObjectFieldKeys(modelFields, obj.objectField);
128875
129024
  if (!qtyKey || !qtyRequiredKey) continue;
128876
129025
  const requiredRaw = formState[qtyRequiredKey];
128877
129026
  if (!hasRequiredQtyValue(requiredRaw)) continue;
@@ -129269,12 +129418,14 @@ async function runValidation(doc, mode, showComments = true, isSessionCurrent =
129269
129418
  let businessResult = null;
129270
129419
  if (mode === "all") {
129271
129420
  var _doc$model, _window$TMPL_BOM_CONT2;
129272
- const materialConsumeObjectKeys = new Set((doc.fieldModelQuery.getFieldList(doc.mainModelKey) ?? []).filter(isMaterialConsumeObjectField).map((field) => field.key));
129421
+ const modelFields = doc.fieldModelQuery.getFieldList(doc.mainModelKey) ?? [];
129422
+ const materialConsumeObjectKeys = new Set(modelFields.filter(isMaterialConsumeObjectField).map((field) => field.key));
129273
129423
  const objectFieldList = (((_doc$model = doc.model) === null || _doc$model === void 0 || (_doc$model = _doc$model.document) === null || _doc$model === void 0 || (_doc$model = _doc$model.config) === null || _doc$model === void 0 || (_doc$model = _doc$model.dataInit) === null || _doc$model === void 0 ? void 0 : _doc$model.objectInitialValues) ?? []).filter((item) => materialConsumeObjectKeys.has(item.objectField));
129274
129424
  const formTmplBomController = (_window$TMPL_BOM_CONT2 = window[TMPL_BOM_CONTROLLER]) === null || _window$TMPL_BOM_CONT2 === void 0 ? void 0 : _window$TMPL_BOM_CONT2.value;
129275
129425
  const objectBomError = await validateObjectBomQtyOnSubmit({
129276
129426
  formState: doc.dataManager.getRawData(),
129277
129427
  objectFieldList,
129428
+ modelFields,
129278
129429
  formInstBom: formTmplBomController === null || formTmplBomController === void 0 ? void 0 : formTmplBomController.formInstBom
129279
129430
  });
129280
129431
  if (objectBomError) {
@@ -137381,7 +137532,8 @@ function applyObjectProductAutofills(doc, pending) {
137381
137532
  rawData: doc.dataManager.getRawData(),
137382
137533
  doc
137383
137534
  });
137384
- if (Object.keys(updates).length) doc.dataManager.setMultiple(updates, "hydrate");
137535
+ const initialUpdates = Object.fromEntries(Object.entries(updates).filter(([path]) => doc.dataManager.getStoredValue(path) === void 0));
137536
+ if (Object.keys(initialUpdates).length) doc.dataManager.setMultiple(initialUpdates, "hydrate");
137385
137537
  }
137386
137538
  }
137387
137539
  //#endregion
@@ -137401,6 +137553,7 @@ init_material_consume();
137401
137553
  init_table$1();
137402
137554
  init_sub_field_config();
137403
137555
  init_core$1();
137556
+ init_initialization();
137404
137557
  /**
137405
137558
  * 兼容历史模板:物料消耗对象工序字段的 operation / routing_operation 曾互相混用。
137406
137559
  * 真实字段元数据优先,避免下拉和 _lb_ 解析走错业务类型。
@@ -137466,7 +137619,7 @@ async function finalizeAfterRawDataReplace(doc, ctx) {
137466
137619
  var _doc$model3;
137467
137620
  await ensureDocumentFontsForUsage((_doc$model3 = doc.model) === null || _doc$model3 === void 0 ? void 0 : _doc$model3.fontUsage);
137468
137621
  await reinitializeDocumentFieldDependencies(doc, ctx);
137469
- await new TableRuntime(doc).onInit();
137622
+ await new TableRuntime(doc).onInit({ initializeValues: false });
137470
137623
  await runDocumentPostLoadEnrichFlush(doc);
137471
137624
  await waitForDataManagerSettle(doc);
137472
137625
  doc.layout();
@@ -137495,7 +137648,7 @@ async function prepareDocumentFieldContext(options) {
137495
137648
  /**
137496
137649
  * 初始化[物料消耗对象]字段默认值
137497
137650
  */
137498
- var initObjectTypeFieldDefaultValue = (rawData, instances, fieldList, runtimeJson) => {
137651
+ var initObjectTypeFieldDefaultValue = (rawData, instances, fieldList, runtimeJson, initializeValues) => {
137499
137652
  var _res$document;
137500
137653
  const usingObjectFieldMap = instances.map((i) => {
137501
137654
  const { belongingObject, fieldLink } = i.widgetMeta.field;
@@ -137520,21 +137673,21 @@ var initObjectTypeFieldDefaultValue = (rawData, instances, fieldList, runtimeJso
137520
137673
  });
137521
137674
  const res = JSON.parse(runtimeJson);
137522
137675
  const { objectInitialValues } = (res === null || res === void 0 || (_res$document = res.document) === null || _res$document === void 0 || (_res$document = _res$document.config) === null || _res$document === void 0 ? void 0 : _res$document.dataInit) || {};
137523
- if (!(objectInitialValues === null || objectInitialValues === void 0 ? void 0 : objectInitialValues.length)) return;
137676
+ if (!initializeValues || !(objectInitialValues === null || objectInitialValues === void 0 ? void 0 : objectInitialValues.length)) return;
137524
137677
  const materialConsumeObjectKeys = new Set(fieldList.filter(isMaterialConsumeObjectField).map((field) => field.key));
137525
137678
  objectInitialValues.forEach(({ objectField, values }) => {
137526
137679
  if (!objectField || !values || !materialConsumeObjectKeys.has(objectField)) return;
137527
137680
  for (const [key, value] of Object.entries(values)) {
137528
137681
  if (value === void 0 || value === null) continue;
137529
137682
  const existing = rawData[key];
137530
- if (existing !== void 0 && existing !== null) continue;
137683
+ if (!isUninitialized(existing)) continue;
137531
137684
  rawData[key] = value;
137532
137685
  }
137533
137686
  });
137534
137687
  };
137535
137688
  async function prepareDocumentRenderData(options) {
137536
137689
  var _payload$ctx;
137537
- const { requestInfo, payload, materialNo, query, instances, subTableInfoList, fieldList, masterSlaveList } = options;
137690
+ const { requestInfo, fillModeType, payload, materialNo, query, instances, subTableInfoList, fieldList, masterSlaveList } = options;
137538
137691
  const rawData = conversionFormState({
137539
137692
  masterSlaveList,
137540
137693
  interfaceData: await fetchRenderData({
@@ -137547,21 +137700,27 @@ async function prepareDocumentRenderData(options) {
137547
137700
  }),
137548
137701
  subTableInfoList
137549
137702
  });
137550
- initObjectTypeFieldDefaultValue(rawData, instances, fieldList, requestInfo.runtimeJson);
137703
+ initObjectTypeFieldDefaultValue(rawData, instances, fieldList, requestInfo.runtimeJson, options.initializeValues !== false && shouldInitializeDocumentData({
137704
+ mode: fillModeType,
137705
+ docRuntimeMeta: requestInfo
137706
+ }));
137551
137707
  return rawData;
137552
137708
  }
137553
137709
  /** 加载参数映射与自定义数据源 */
137554
137710
  async function loadDocumentInitMappings(options) {
137555
137711
  var _runtimeJson$document;
137556
- const { fillModeType, runtimeJson, paramsConfig, processFieldPermission, instanceId, instances, payload, subTableInfoList } = options;
137557
- const { paramMap, dsMap } = await loadDataInitValues(fillModeType, runtimeJson === null || runtimeJson === void 0 || (_runtimeJson$document = runtimeJson.document) === null || _runtimeJson$document === void 0 || (_runtimeJson$document = _runtimeJson$document.config) === null || _runtimeJson$document === void 0 ? void 0 : _runtimeJson$document.dataInit, paramsConfig, subTableInfoList, JSON.parse(processFieldPermission || "[]"), instanceId, instances, payload.ctx);
137712
+ const { fillModeType, runtimeJson, paramsConfig, processFieldPermission, instanceId, instances, payload, subTableInfoList, requestInfo } = options;
137713
+ const { paramMap, dsMap } = await loadDataInitValues(fillModeType, runtimeJson === null || runtimeJson === void 0 || (_runtimeJson$document = runtimeJson.document) === null || _runtimeJson$document === void 0 || (_runtimeJson$document = _runtimeJson$document.config) === null || _runtimeJson$document === void 0 ? void 0 : _runtimeJson$document.dataInit, paramsConfig, subTableInfoList, JSON.parse(processFieldPermission || "[]"), instanceId, instances, payload.ctx, options.initializeValues !== false && shouldInitializeDocumentData({
137714
+ mode: fillModeType,
137715
+ docRuntimeMeta: requestInfo
137716
+ }));
137558
137717
  return {
137559
137718
  ...paramMap,
137560
137719
  ...dsMap
137561
137720
  };
137562
137721
  }
137563
137722
  /**
137564
- * 将参数映射 / 自定义数据源写入 rawData(仅填空 value,source: hydrate)
137723
+ * 首次填报仅填 undefined(source: hydrate);保存过的实例仅保留新增行的参数映射模板。
137565
137724
  */
137566
137725
  function applyDocumentInitMappings(doc, initMap) {
137567
137726
  doc.dataManager.applyInitData(initMap);
@@ -137597,7 +137756,8 @@ async function initializeDocumentEngine(props, payload, result) {
137597
137756
  defaultOrgId: payload === null || payload === void 0 || (_payload$deviceConfig2 = payload.deviceConfig) === null || _payload$deviceConfig2 === void 0 ? void 0 : _payload$deviceConfig2.defaultOrgId
137598
137757
  });
137599
137758
  const defaultDataMap = await loadDefaultValuesByFields(instances, payload.ctx, defaultQueryIds, masterSlaveList);
137600
- if (fillModeType !== DocModeTypeConst.Edit) applyCheckTableItemInfosToDefaults(defaultDataMap, checkTableRegions, infosMap, (linkFieldKey) => docModel.getSubTableLayoutSlotCount(linkFieldKey));
137759
+ const configurationDefaults = {};
137760
+ if (fillModeType !== DocModeTypeConst.Edit) applyCheckTableItemInfosToDefaults(defaultDataMap, checkTableRegions, infosMap, (linkFieldKey) => docModel.getSubTableLayoutSlotCount(linkFieldKey), configurationDefaults);
137601
137761
  const initDataMap = await loadDocumentInitMappings({
137602
137762
  fillModeType,
137603
137763
  runtimeJson: runtimeJsonForModel,
@@ -137606,10 +137766,12 @@ async function initializeDocumentEngine(props, payload, result) {
137606
137766
  instanceId: id,
137607
137767
  instances,
137608
137768
  payload,
137609
- subTableInfoList: docModel.getSubTableInfoList() ?? []
137769
+ subTableInfoList: docModel.getSubTableInfoList() ?? [],
137770
+ requestInfo
137610
137771
  });
137611
137772
  const rawData = await prepareDocumentRenderData({
137612
137773
  requestInfo,
137774
+ fillModeType,
137613
137775
  payload,
137614
137776
  materialNo: props.materialNo || materialNo,
137615
137777
  query: result.query,
@@ -137621,7 +137783,10 @@ async function initializeDocumentEngine(props, payload, result) {
137621
137783
  const materialConsumeObjectKeys = new Set(fieldList.filter(isMaterialConsumeObjectField).map((field) => field.key));
137622
137784
  const materialConsumeInitialValues = (((_docModel$document$co = docModel.document.config) === null || _docModel$document$co === void 0 || (_docModel$document$co = _docModel$document$co.dataInit) === null || _docModel$document$co === void 0 ? void 0 : _docModel$document$co.objectInitialValues) ?? []).filter((item) => materialConsumeObjectKeys.has(item.objectField));
137623
137785
  const pendingObjectAutofills = await prepareObjectProductAutofills({
137624
- enabled: fillModeType === DocModeTypeConst.Fill && requestInfo.instanceStatus === "UNFILLED",
137786
+ enabled: shouldInitializeDocumentData({
137787
+ mode: fillModeType,
137788
+ docRuntimeMeta: requestInfo
137789
+ }),
137625
137790
  instances,
137626
137791
  objectInitialValues: materialConsumeInitialValues,
137627
137792
  rawData,
@@ -137673,7 +137838,7 @@ async function initializeDocumentEngine(props, payload, result) {
137673
137838
  getFieldManifest: (type) => payload.ctx.getFieldManifest(type),
137674
137839
  loadFieldByKey: (modelKey, key) => payload.ctx.runtime.loadFieldByKey(modelKey, key)
137675
137840
  });
137676
- doc.dataManager.setRawData(rawData, enrichedDefaults);
137841
+ doc.dataManager.setRawData(rawData, enrichedDefaults, { configurationDefaults });
137677
137842
  applyDocumentInitMappings(doc, initDataMap);
137678
137843
  const subConfig = {};
137679
137844
  initMaterialConsumeTableConfig(doc, subConfig, tmplBomC);
@@ -137839,6 +138004,8 @@ function useDocumentFactory(props, payload) {
137839
138004
  }
137840
138005
  const rawData = await prepareDocumentRenderData({
137841
138006
  requestInfo,
138007
+ initializeValues: false,
138008
+ fillModeType,
137842
138009
  payload,
137843
138010
  materialNo,
137844
138011
  query,
@@ -137847,7 +138014,7 @@ function useDocumentFactory(props, payload) {
137847
138014
  fieldList,
137848
138015
  masterSlaveList
137849
138016
  });
137850
- doc.dataManager.setRawData(rawData);
138017
+ doc.dataManager.setRawData(rawData, void 0, { initializeValues: false });
137851
138018
  applyDocumentInitMappings(doc, await loadDocumentInitMappings({
137852
138019
  fillModeType,
137853
138020
  runtimeJson: JSON.parse(requestInfo.runtimeJson || "{}"),
@@ -137856,7 +138023,9 @@ function useDocumentFactory(props, payload) {
137856
138023
  instanceId: requestId,
137857
138024
  instances: ((_doc$model3 = doc.model) === null || _doc$model3 === void 0 ? void 0 : _doc$model3.getWidgetInstances()) ?? [],
137858
138025
  payload,
137859
- subTableInfoList: ((_doc$model4 = doc.model) === null || _doc$model4 === void 0 ? void 0 : _doc$model4.getSubTableInfoList()) ?? []
138026
+ subTableInfoList: ((_doc$model4 = doc.model) === null || _doc$model4 === void 0 ? void 0 : _doc$model4.getSubTableInfoList()) ?? [],
138027
+ requestInfo,
138028
+ initializeValues: false
137860
138029
  }));
137861
138030
  doc.paramsConfig[SUB_FIELD_CONFIG_KEY] = subFieldConfigCache;
137862
138031
  doc.dataManager.setRuntimeSpecificConfig(runtimeConfigCache);
@@ -149372,7 +149541,7 @@ var init_repeating_table_action_vue_vue_type_script_setup_true_name_sub_table_ac
149372
149541
  if (!getIsIncreasable()) return;
149373
149542
  const { path, subFieldKey } = getCtx();
149374
149543
  props.doc.dataManager.insertAt(path, index, ...Array.from({ length: count }, () => ({})));
149375
- handleRowIncreased(subFieldKey, index);
149544
+ for (let offset = 0; offset < count; offset++) handleRowIncreased(subFieldKey, index + offset);
149376
149545
  };
149377
149546
  const copyRow = () => {
149378
149547
  if (!getIsIncreasable()) return;
@@ -150873,7 +151042,7 @@ function useDocController(factory, ops) {
150873
151042
  },
150874
151043
  async setRawData(data, defaultDataMap) {
150875
151044
  ops.clearFormChangeRowPreview();
150876
- doc.dataManager.setRawData(data, defaultDataMap);
151045
+ doc.dataManager.setRawData(data, defaultDataMap, { initializeValues: Boolean(defaultDataMap) });
150877
151046
  await finalizeAfterRawDataReplace(doc, factory.ctx);
150878
151047
  },
150879
151048
  setMultiple(updates) {
@@ -159361,7 +159530,7 @@ var manifest$26 = {
159361
159530
  key: "field:object_type",
159362
159531
  type: FIELD_TYPE.OBJECT_TYPE,
159363
159532
  label: "对象字段",
159364
- icon: "icon-duixiang",
159533
+ icon: "icon-duixiang bd-iconfont",
159365
159534
  version: "v1",
159366
159535
  allowDrag: false,
159367
159536
  component: "cascade",
@@ -172561,8 +172730,7 @@ var display_fields_editor_vue_vue_type_script_setup_true_lang_default = /*@__PUR
172561
172730
  inline: false
172562
172731
  }, {
172563
172732
  default: withCtx(() => [createElementVNode("div", { title: selectorInfo.value.displayTitle }, [createVNode(unref(basic_select_default), {
172564
- allowClear: !defaultConfig.value.unremovableKeys.length,
172565
- "multiple-clearable": !defaultConfig.value.unremovableKeys.length,
172733
+ allowClear: "",
172566
172734
  picker: "",
172567
172735
  multipleArrow: "",
172568
172736
  multipleClearOnHover: "",
@@ -172577,8 +172745,6 @@ var display_fields_editor_vue_vue_type_script_setup_true_lang_default = /*@__PUR
172577
172745
  onClick: handleOpenModal,
172578
172746
  onChange: _cache[1] || (_cache[1] = (keys) => handleSelectChange(keys))
172579
172747
  }, null, 8, [
172580
- "allowClear",
172581
- "multiple-clearable",
172582
172748
  "options",
172583
172749
  "unremovable-values",
172584
172750
  "modelValue",
@@ -172592,7 +172758,7 @@ var display_fields_editor_vue_vue_type_script_setup_true_lang_default = /*@__PUR
172592
172758
  //#endregion
172593
172759
  //#region src/suites/shared/panel/config/editor/display-fields-editor/display-fields-editor.vue
172594
172760
  init__plugin_vue_export_helper();
172595
- var display_fields_editor_default = /*#__PURE__*/ _plugin_vue_export_helper_default(display_fields_editor_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-c4b171d3"]]);
172761
+ var display_fields_editor_default = /*#__PURE__*/ _plugin_vue_export_helper_default(display_fields_editor_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-b4c34d10"]]);
172596
172762
  //#endregion
172597
172763
  //#region src/suites/shared/panel/config/editor/quick-search-editor/quick-search-editor.vue?vue&type=script&setup=true&name=quick-search-editor&lang.ts
172598
172764
  init_base$2();
@@ -20,7 +20,9 @@ instanceId: string,
20
20
  /** 组件实例列表(用于查找 widget 的 fieldMeta/props,供 label 派生) */
21
21
  instances: any[],
22
22
  /** 设计套件上下文(用于 getFieldManifest 和 loadFieldByKey) */
23
- ctx: DesignSuiteContext) => Promise<{
23
+ ctx: DesignSuiteContext,
24
+ /** 保存过的实例只准备参数映射的行模板,不再查询首次初始化的数据源。 */
25
+ initializeDataSources?: boolean) => Promise<{
24
26
  paramMap: {};
25
27
  dsRawData: {};
26
28
  dsMap?: undefined;
@@ -28,6 +28,8 @@ export interface DocumentFieldContext {
28
28
  export declare function prepareDocumentFieldContext(options: PrepareFieldContextOptions): Promise<DocumentFieldContext>;
29
29
  export interface PrepareRenderDataOptions {
30
30
  requestInfo: Execute['requestInfo'];
31
+ initializeValues?: boolean;
32
+ fillModeType: DocModeType;
31
33
  payload: IDocPayload;
32
34
  materialNo: string;
33
35
  query: Record<string, any>;
@@ -46,11 +48,13 @@ interface LoadDocumentInitMappingsOptions {
46
48
  instances: any[];
47
49
  payload: IDocPayload;
48
50
  subTableInfoList: any[];
51
+ requestInfo: Execute['requestInfo'];
52
+ initializeValues?: boolean;
49
53
  }
50
54
  /** 加载参数映射与自定义数据源 */
51
55
  export declare function loadDocumentInitMappings(options: LoadDocumentInitMappingsOptions): Promise<Record<string, unknown>>;
52
56
  /**
53
- * 将参数映射 / 自定义数据源写入 rawData(仅填空 value,source: hydrate)
57
+ * 首次填报仅填 undefined(source: hydrate);保存过的实例仅保留新增行的参数映射模板。
54
58
  */
55
59
  export declare function applyDocumentInitMappings(doc: Doc, initMap: Record<string, unknown>): {
56
60
  pathCount: number;
@@ -1,20 +1,15 @@
1
1
  import { FormInstBomResponse } from '@gct-paas/api/apaas';
2
2
  import { IBomEntry } from '../../../../../domain/table/business/material/types';
3
+ import { FieldMeta } from '../../../../../capabilities/model-field-runtime';
3
4
  /** 物料消耗对象字段信息 */
4
5
  export interface IMaterialConsumeObjectInfo {
5
6
  /** 对象字段key */
6
7
  objectField: string;
7
8
  /** 对象字段名称(仅用于展示) */
8
9
  objectFieldName?: string;
9
- /** 子表字段key */
10
- subFields?: Record<string, {
11
- used: boolean;
12
- key: string;
13
- [key: string]: any;
14
- }>;
15
10
  }
16
11
  /** 物料消耗对象中参与提交数量校验的上料数量字段。 */
17
- export declare function getObjectBomQtyFieldKeys(objectFieldList?: IMaterialConsumeObjectInfo[]): string[];
12
+ export declare function getObjectBomQtyFieldKeys(objectFieldList: readonly IMaterialConsumeObjectInfo[], modelFields: readonly FieldMeta[]): string[];
18
13
  export declare function resolveObjectBomEntry(opts: {
19
14
  formInstBom: FormInstBomResponse;
20
15
  belongingObject: string;
@@ -66,6 +61,7 @@ export declare function getObjectBomDropdownQuery(fieldType: string | undefined,
66
61
  export declare function validateObjectBomQtyOnSubmit(opts: {
67
62
  formState: Record<string, any>;
68
63
  objectFieldList?: IMaterialConsumeObjectInfo[];
64
+ modelFields: readonly FieldMeta[];
69
65
  formInstBom?: FormInstBomResponse | null;
70
66
  }): Promise<{
71
67
  field: string;
package/dist/word.css CHANGED
@@ -13676,7 +13676,7 @@ svg.portrait-icon[data-v-8bdb451e] {
13676
13676
  background-color: #026ac8;
13677
13677
  color: #fff;
13678
13678
  }
13679
- .editor-tip[data-v-c4b171d3] {
13679
+ .editor-tip[data-v-b4c34d10] {
13680
13680
  margin-top: 4px;
13681
13681
  color: #a6a6a6;
13682
13682
  font-size: 12px;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gct-paas/word",
3
- "version": "0.2.17",
3
+ "version": "0.2.18",
4
4
  "description": "GCT 在线 word",
5
5
  "keywords": [
6
6
  "vue",