@gct-paas/excel 0.1.40-beta.11 → 0.1.40-beta.12

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.
@@ -1062,7 +1062,8 @@ class FormTmplBomController {
1062
1062
  async function prepareObjectProductDefaults({
1063
1063
  enabled,
1064
1064
  fields,
1065
- objectInitialValues = []
1065
+ objectInitialValues = [],
1066
+ onWarning
1066
1067
  }) {
1067
1068
  const defaults2 = /* @__PURE__ */ new WeakMap();
1068
1069
  if (!enabled) return defaults2;
@@ -1083,7 +1084,7 @@ async function prepareObjectProductDefaults({
1083
1084
  );
1084
1085
  const product = result?.data;
1085
1086
  if (!product || typeof product !== "object" || Array.isArray(product) || Object.keys(product).length === 0) {
1086
- throw new Error(`未找到默认物料详情:${productId}`);
1087
+ return void 0;
1087
1088
  }
1088
1089
  return { ...product, _DICT: result?.dict ?? product._DICT };
1089
1090
  })();
@@ -1112,6 +1113,13 @@ async function prepareObjectProductDefaults({
1112
1113
  tasks.push(
1113
1114
  fetchProduct(productId).then(
1114
1115
  (sourceData) => {
1116
+ if (!sourceData) {
1117
+ const objectName = configured.objectFieldName || field.belongingObject;
1118
+ onWarning?.(
1119
+ `「数据 → 对象初始化 → ${objectName} → 配置」中的默认物料未查到详情(字段 ${field.fieldId},物料 ${productId}),已跳过自动填充。`
1120
+ );
1121
+ return;
1122
+ }
1115
1123
  productDefault.sourceData = sourceData;
1116
1124
  },
1117
1125
  (error) => {
@@ -1524,7 +1532,10 @@ function createRuntimeInstanceInitializer(props, payload, getConsumeData) {
1524
1532
  const objectProductDefaults = await prepareObjectProductDefaults({
1525
1533
  enabled: fillModeType === RenderModeEnum.FormMode && selfInfo.dataStatus !== "STASH" && selfInfo.dataStatus !== "SUBMIT",
1526
1534
  fields: fieldInfoMap.useDefaultValueFields,
1527
- objectInitialValues: runtimeContext.formConfig.objectInitialValues
1535
+ objectInitialValues: runtimeContext.formConfig.objectInitialValues,
1536
+ onWarning: (content) => {
1537
+ window.NocodeAdapter.openUtil?.message({ type: "warning", content, duration: 8 });
1538
+ }
1528
1539
  });
1529
1540
  const defaultDataMap = renderUtils.getDefaultValueMapByField({
1530
1541
  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.40-beta.11",
3
+ "version": "0.1.40-beta.12",
4
4
  "description": "GCT Excel online form rendering",
5
5
  "license": "MIT",
6
6
  "type": "module",