@gct-paas/word 0.1.5 → 0.1.6

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.
Files changed (2) hide show
  1. package/dist/index.es.js +3 -79
  2. package/package.json +1 -1
package/dist/index.es.js CHANGED
@@ -50373,54 +50373,6 @@ function applyDefaultValue(props, payload) {
50373
50373
  }
50374
50374
  return defaults2;
50375
50375
  }
50376
- async function fetchLabelAndFill(defaults2, valuePath, id, fetcher, props, fallback) {
50377
- defaults2 ??= {};
50378
- defaults2[valuePath] = id;
50379
- try {
50380
- const result = await apiFetchers[fetcher].getOptionById(id, props);
50381
- if (result) {
50382
- defaults2[`${valuePath}_lb_`] = result.label;
50383
- }
50384
- } catch (error) {
50385
- console.error(`Failed to fetch label for ${valuePath}:`, error);
50386
- if (fallback) {
50387
- defaults2[`${valuePath}_lb_`] = fallback;
50388
- }
50389
- }
50390
- return defaults2;
50391
- }
50392
- async function enrichApiDefaultValues(defaults2, rule, fieldMeta, context, ctx) {
50393
- if (!rule || !("fetcher" in rule)) {
50394
- return defaults2;
50395
- }
50396
- const valuePath = fieldMeta.valuePath;
50397
- const id = context?.[fieldMeta.fieldType];
50398
- if (!id) {
50399
- return defaults2;
50400
- }
50401
- if (rule.type === "resolve") {
50402
- if (!rule.isRenderSideRequest) {
50403
- return defaults2;
50404
- }
50405
- return fetchLabelAndFill(defaults2, valuePath, id, rule.fetcher, {}, rule.fallback);
50406
- }
50407
- if (rule.type !== "api") {
50408
- return defaults2;
50409
- }
50410
- const apiRule = rule;
50411
- if (apiRule.onlyMainModelFieldsCanRequest && fieldMeta.subFieldKey) {
50412
- return defaults2;
50413
- }
50414
- const modelKey = getLastSegment(fieldMeta.modelLink);
50415
- const fieldKey = getLastSegment(fieldMeta.fieldLink);
50416
- const fieldInfo = await ctx.runtime.loadFieldByKey(modelKey, fieldKey);
50417
- const params = {
50418
- modelKey: fieldInfo?.modelKey || modelKey,
50419
- fieldKey: fieldInfo?.key || fieldKey,
50420
- refModelKey: fieldInfo?.bindInfo
50421
- };
50422
- return fetchLabelAndFill(defaults2, valuePath, id, apiRule.fetcher, params, apiRule.fallback);
50423
- }
50424
50376
  let snapshotScheduled = false;
50425
50377
  function scheduleSnapshot(doc, defaults2) {
50426
50378
  if (snapshotScheduled) return;
@@ -56593,31 +56545,6 @@ function getDefaultQueryIdsByFieldType(payload) {
56593
56545
  };
56594
56546
  return defaultQueryIds;
56595
56547
  }
56596
- async function loadDefaultValuesByFields(instances, ctx, context) {
56597
- const defaultDataMap = {};
56598
- const promises = instances.map(async (instance2) => {
56599
- const { field, props } = instance2.widgetMeta;
56600
- if (!field || !props) return;
56601
- const manifest2 = ctx.getFieldManifest(field.fieldType);
56602
- if (!manifest2?.computed) return;
56603
- const { defaultValueRule } = manifest2.computed;
56604
- let defaults2 = applyDefaultValue(props, {
56605
- rule: defaultValueRule,
56606
- valuePath: field.valuePath
56607
- });
56608
- if (defaultValueRule?.type === "api" || defaultValueRule?.type === "resolve" && defaultValueRule.isRenderSideRequest) {
56609
- defaults2 = await enrichApiDefaultValues(defaults2, defaultValueRule, field, context, ctx);
56610
- }
56611
- if (!defaults2) return;
56612
- for (const [key, value] of Object.entries(defaults2)) {
56613
- if (value != null) {
56614
- defaultDataMap[key] = value;
56615
- }
56616
- }
56617
- });
56618
- await Promise.all(promises);
56619
- return defaultDataMap;
56620
- }
56621
56548
  class DocRequestStrategy {
56622
56549
  props;
56623
56550
  payload;
@@ -56730,7 +56657,10 @@ function useDocumentFactory(props, payload) {
56730
56657
  console.log("tangjian 初始化单个文档", result, payload);
56731
56658
  const { id, requestInfo, fillModeType, paramsConfig } = result;
56732
56659
  const cloneRuntimeJson = cloneDeep(JSON.parse(requestInfo.runtimeJson || "{}"));
56660
+ await addSubModelsToFieldScope(requestInfo.modelKey || payload.modelKey, payload.ctx);
56733
56661
  const docModel = ModelConverter.toModel(cloneRuntimeJson);
56662
+ const instances = docModel.getWidgetInstances();
56663
+ console.log("instances", instances);
56734
56664
  const defaultQueryIds = getDefaultQueryIdsByFieldType({
56735
56665
  materialNumber: paramsConfig?.materialNo || requestInfo.materialNo,
56736
56666
  productId: paramsConfig?.productId,
@@ -56740,11 +56670,6 @@ function useDocumentFactory(props, payload) {
56740
56670
  defaultOrgId: payload?.deviceConfig?.defaultOrgId
56741
56671
  });
56742
56672
  console.log("tangjian11111111", defaultQueryIds);
56743
- const instances = docModel.getWidgetInstances();
56744
- console.log("instances", instances);
56745
- await addSubModelsToFieldScope(requestInfo.modelKey || payload.modelKey, payload.ctx);
56746
- const defaultDataMap = await loadDefaultValuesByFields(instances, payload.ctx, defaultQueryIds);
56747
- console.log("tangjian11111111 defaultDataMap", defaultDataMap);
56748
56673
  docEngine.value = createDoc({
56749
56674
  model: docModel,
56750
56675
  mode: fillModeType,
@@ -56757,7 +56682,6 @@ function useDocumentFactory(props, payload) {
56757
56682
  console.log(`Document [${id}] selection changed`);
56758
56683
  }
56759
56684
  });
56760
- docEngine.value.docInstance.dataManager.setDefaults(defaultDataMap);
56761
56685
  docInfo.value = createDocInfo(docEngine.value?.docInstance);
56762
56686
  selfInfo.value = requestInfo;
56763
56687
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gct-paas/word",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "GCT 在线 word",
5
5
  "keywords": [
6
6
  "vue",