@gct-paas/excel 0.1.39-beta.28 → 0.1.39-beta.29

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.
@@ -1006,7 +1006,8 @@ class FormTmplBomController {
1006
1006
  async function prepareObjectProductDefaults({
1007
1007
  enabled,
1008
1008
  fields,
1009
- objectInitialValues = []
1009
+ objectInitialValues = [],
1010
+ onWarning
1010
1011
  }) {
1011
1012
  const defaults2 = /* @__PURE__ */ new WeakMap();
1012
1013
  if (!enabled) return defaults2;
@@ -1027,7 +1028,7 @@ async function prepareObjectProductDefaults({
1027
1028
  );
1028
1029
  const product = result?.data;
1029
1030
  if (!product || typeof product !== "object" || Array.isArray(product) || Object.keys(product).length === 0) {
1030
- throw new Error(`未找到默认物料详情:${productId}`);
1031
+ return void 0;
1031
1032
  }
1032
1033
  return { ...product, _DICT: result?.dict ?? product._DICT };
1033
1034
  })();
@@ -1056,6 +1057,13 @@ async function prepareObjectProductDefaults({
1056
1057
  tasks.push(
1057
1058
  fetchProduct(productId).then(
1058
1059
  (sourceData) => {
1060
+ if (!sourceData) {
1061
+ const objectName = configured.objectFieldName || field.belongingObject;
1062
+ onWarning?.(
1063
+ `「数据 → 对象初始化 → ${objectName} → 配置」中的默认物料未查到详情(字段 ${field.fieldId},物料 ${productId}),已跳过自动填充。`
1064
+ );
1065
+ return;
1066
+ }
1059
1067
  productDefault.sourceData = sourceData;
1060
1068
  },
1061
1069
  (error) => {
@@ -1436,7 +1444,10 @@ function createRuntimeInstanceInitializer(props, payload, getConsumeData) {
1436
1444
  const objectProductDefaults = await prepareObjectProductDefaults({
1437
1445
  enabled: fillModeType === RenderModeEnum.FormMode && selfInfo.dataStatus !== "STASH" && selfInfo.dataStatus !== "SUBMIT",
1438
1446
  fields: fieldInfoMap.useDefaultValueFields,
1439
- objectInitialValues: runtimeContext.formConfig.objectInitialValues
1447
+ objectInitialValues: runtimeContext.formConfig.objectInitialValues,
1448
+ onWarning: (content) => {
1449
+ window.NocodeAdapter.openUtil?.message({ type: "warning", content, duration: 8 });
1450
+ }
1440
1451
  });
1441
1452
  const defaultDataMap = renderUtils.getDefaultValueMapByField({
1442
1453
  objectProductDefaults,
@@ -9,9 +9,11 @@ interface Options {
9
9
  fields: readonly unknown[];
10
10
  objectInitialValues?: readonly {
11
11
  objectField: string;
12
+ objectFieldName?: string;
12
13
  values?: Record<string, any>;
13
14
  }[];
15
+ onWarning?: (message: string) => void;
14
16
  }
15
17
  /** 只解析对象物料默认值、查询对应详情;赋值和填充统一由默认值入口执行。 */
16
- export declare function prepareObjectProductDefaults({ enabled, fields, objectInitialValues, }: Options): Promise<ObjectProductDefaultMap>;
18
+ export declare function prepareObjectProductDefaults({ enabled, fields, objectInitialValues, onWarning, }: Options): Promise<ObjectProductDefaultMap>;
17
19
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gct-paas/excel",
3
- "version": "0.1.39-beta.28",
3
+ "version": "0.1.39-beta.29",
4
4
  "description": "GCT Excel online form rendering",
5
5
  "license": "MIT",
6
6
  "type": "module",