@gct-paas/word 0.1.63-beta.7 → 0.1.63-beta.8

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.
@@ -1,6 +1,11 @@
1
1
  import { Doc } from '../../view/Doc';
2
2
  import { WidgetMeta } from '../../widget';
3
3
  import { DataEnricherRegistration } from '../types';
4
+ /**
5
+ * 用批次号调用 biz_judge_jump,判断是否可超链接。
6
+ * 不可链时返回 null;可链时返回非空字符串(供弹框/跳转使用)。
7
+ */
8
+ export declare function resolveHyperlinkHrefByMaterialNo(materialNo: unknown): Promise<string | null>;
4
9
  type HyperlinkEnricherOptions = Omit<DataEnricherRegistration, 'enrich'> & {
5
10
  doc: Doc;
6
11
  widgetMeta: WidgetMeta;
package/dist/index.es.js CHANGED
@@ -84440,8 +84440,8 @@ function createCompanionEnricher(reg, config) {
84440
84440
  }
84441
84441
  };
84442
84442
  }
84443
- async function resolveHyperlinkHref(_path, value) {
84444
- if (value == null || value === "") return null;
84443
+ async function resolveHyperlinkHrefByMaterialNo(materialNo) {
84444
+ if (!isPresent(materialNo)) return null;
84445
84445
  try {
84446
84446
  const bool = await api.apaas.modelComprehensive.postBizServiceModelCategoryModelKeyBsKey(
84447
84447
  {
@@ -84449,10 +84449,10 @@ async function resolveHyperlinkHref(_path, value) {
84449
84449
  modelKey: "gct_edhr_instance",
84450
84450
  modelCategory: "entity"
84451
84451
  },
84452
- { materialNo: value },
84452
+ { materialNo },
84453
84453
  {}
84454
84454
  );
84455
- return bool ? String(value) : null;
84455
+ return bool ? String(materialNo) : null;
84456
84456
  } catch {
84457
84457
  return null;
84458
84458
  }
@@ -84463,7 +84463,7 @@ function createHyperlinkEnricher(reg) {
84463
84463
  defaultIdPrefix: "hyperlink:",
84464
84464
  getCompanionPath: getHrefPath,
84465
84465
  buildCacheKey: (path, value) => ({ path, value }),
84466
- resolveCompanion: (path, value) => resolveHyperlinkHref(path, value)
84466
+ resolveCompanion: (_path, value) => resolveHyperlinkHrefByMaterialNo(value)
84467
84467
  });
84468
84468
  }
84469
84469
  function resolveProductId(doc, path) {
@@ -89396,24 +89396,6 @@ const profile$1 = {
89396
89396
  }
89397
89397
  };
89398
89398
  const PRODUCTION_CONTAINER_FIELD_KEY = "production_container_id_";
89399
- async function resolveHrefByLabel(path, doc) {
89400
- const materialNo = doc.dataManager.get(getLabelPath(path));
89401
- if (!isPresent(materialNo)) return null;
89402
- try {
89403
- const bool = await api.apaas.modelComprehensive.postBizServiceModelCategoryModelKeyBsKey(
89404
- {
89405
- bsKey: "biz_judge_jump",
89406
- modelKey: "gct_edhr_instance",
89407
- modelCategory: "entity"
89408
- },
89409
- { materialNo },
89410
- {}
89411
- );
89412
- return bool ? String(materialNo) : null;
89413
- } catch {
89414
- return null;
89415
- }
89416
- }
89417
89399
  function createProductionContainerHyperlinkEnricher(doc, tableType) {
89418
89400
  const subFieldKeys = new Set(
89419
89401
  TableRuntimeContext.collectAll(doc).filter((ctx) => ctx.profile.type === tableType).map((ctx) => ctx.subFieldKey)
@@ -89436,9 +89418,11 @@ function createProductionContainerHyperlinkEnricher(doc, tableType) {
89436
89418
  buildCacheKey: (path, value, currentDoc) => ({
89437
89419
  path,
89438
89420
  value,
89421
+ // 生产批次号存的是 id,biz_judge_jump 需用展示批次号(_lb_)
89422
+ // 注意:不要用 dataManager.getLabel(无 _lb_ 时会回落到 id)
89439
89423
  materialNo: currentDoc.dataManager.get(getLabelPath(path))
89440
89424
  }),
89441
- resolveCompanion: (path, _value, currentDoc) => resolveHrefByLabel(path, currentDoc)
89425
+ resolveCompanion: (path, _value, currentDoc) => resolveHyperlinkHrefByMaterialNo(currentDoc.dataManager.get(getLabelPath(path)))
89442
89426
  }
89443
89427
  );
89444
89428
  }
@@ -91760,6 +91744,7 @@ class WsecPr extends ModelNode {
91760
91744
  * 从原始 XML JSON 转换为 WsecPr 实例
91761
91745
  */
91762
91746
  static fromXmlJson(json) {
91747
+ const { paperSize } = json;
91763
91748
  const pgSzRaw = pickElement(json, "w:pgSz");
91764
91749
  const pageSize = pgSzRaw ? {
91765
91750
  width: pgSzRaw["@attrs"]?.["w:w"] ? parseInt(pgSzRaw["@attrs"]["w:w"]) : void 0,
@@ -91788,6 +91773,7 @@ class WsecPr extends ModelNode {
91788
91773
  const titlePg = pickElement(json, "w:titlePg");
91789
91774
  return new WsecPr({
91790
91775
  attrs: json["@attrs"],
91776
+ paperSize,
91791
91777
  pageSize,
91792
91778
  margins,
91793
91779
  columns: columns2,
@@ -102466,9 +102452,9 @@ class Section {
102466
102452
  return { ...res, paperSize };
102467
102453
  }
102468
102454
  getPaperSize() {
102469
- const ps = this.wsecPr?.pageSize;
102470
- const mmWidth = UnitConverter.twipToMm(ps.width);
102471
- const mmHeight = UnitConverter.twipToMm(ps.height);
102455
+ const twipPageSize = this.wsecPr?.pageSize;
102456
+ const mmWidth = UnitConverter.twipToMm(twipPageSize.width);
102457
+ const mmHeight = UnitConverter.twipToMm(twipPageSize.height);
102472
102458
  const w2 = Math.min(mmWidth, mmHeight);
102473
102459
  const h2 = Math.max(mmWidth, mmHeight);
102474
102460
  const tolerance = 3;
@@ -109696,19 +109682,25 @@ class SingleTemplateStrategy extends DocRequestStrategy {
109696
109682
  requestInfo.runtimeJson = JSON.stringify(json);
109697
109683
  } else {
109698
109684
  const jsonObj = JSON.parse(requestInfo.runtimeJson);
109699
- const pgSzEl = jsonObj.document.elements[0].elements.find((el) => el.name === "w:sectPr")?.elements.find((el) => el.name === "w:pgSz");
109700
- if (pgSzEl) {
109701
- updatePgSzElInfo(
109702
- pgSzEl,
109703
- requestInfo.paperSize || PaperSizeConst.A4,
109704
- {
109705
- width: requestInfo.width,
109706
- height: requestInfo.height,
109707
- direction: requestInfo.direction
109708
- }
109709
- );
109685
+ const wSec = jsonObj.document.elements[0]?.elements?.find((el) => el.name === "w:sectPr");
109686
+ if (wSec) {
109687
+ wSec.paperSize = requestInfo.paperSize;
109688
+ const pgSzEl = wSec.elements?.find((el) => el.name === "w:pgSz");
109689
+ if (pgSzEl) {
109690
+ const { paperSize, width: w2, height: h2, direction } = requestInfo;
109691
+ const [width, height] = [w2, h2].sort();
109692
+ updatePgSzElInfo(
109693
+ pgSzEl,
109694
+ paperSize,
109695
+ {
109696
+ width,
109697
+ height,
109698
+ direction
109699
+ }
109700
+ );
109701
+ }
109702
+ requestInfo.runtimeJson = JSON.stringify(jsonObj);
109710
109703
  }
109711
- requestInfo.runtimeJson = JSON.stringify(jsonObj);
109712
109704
  }
109713
109705
  return {
109714
109706
  id,
@@ -114107,6 +114099,43 @@ async function openESopViewModal(doc, widgetMeta, runtimeValuePath) {
114107
114099
  if (!options) return;
114108
114100
  await triggerUtil.handle("OPEN_E_SOP_VIEW_MODAL", options);
114109
114101
  }
114102
+ function resolveFieldKey(widgetMeta, runtimeValuePath) {
114103
+ const sub = parseSubtableFieldPath(runtimeValuePath);
114104
+ if (sub?.fieldKey) return sub.fieldKey;
114105
+ const fromPath = parseValuePath(runtimeValuePath).fieldKey;
114106
+ if (fromPath) return fromPath;
114107
+ return getLastSegment(widgetMeta.field?.fieldLink) || "";
114108
+ }
114109
+ function resolveOpenFieldHyperlinkModalOptions(doc, widgetMeta, runtimeValuePath) {
114110
+ const raw = doc.dataManager.getLabel(runtimeValuePath);
114111
+ const sub = parseSubtableFieldPath(runtimeValuePath);
114112
+ const subFieldKey = sub?.subFieldKey || widgetMeta.field?.subFieldKey;
114113
+ const tableType = subFieldKey ? TableRuntimeContext.find(doc, subFieldKey)?.profile.type : void 0;
114114
+ console.log("TJ::", {
114115
+ materialNo: getValue$1(raw, false),
114116
+ fieldType: widgetMeta.field?.fieldType,
114117
+ href: doc.dataManager.getHref(runtimeValuePath) ?? void 0,
114118
+ fieldKey: resolveFieldKey(widgetMeta, runtimeValuePath) || void 0,
114119
+ tableType,
114120
+ subFieldKey: subFieldKey || void 0,
114121
+ rowIndex: sub?.rowIndex,
114122
+ valuePath: runtimeValuePath
114123
+ });
114124
+ return {
114125
+ materialNo: getValue$1(raw, false),
114126
+ fieldType: widgetMeta.field?.fieldType,
114127
+ href: doc.dataManager.getHref(runtimeValuePath) ?? void 0,
114128
+ fieldKey: resolveFieldKey(widgetMeta, runtimeValuePath) || void 0,
114129
+ tableType,
114130
+ subFieldKey: subFieldKey || void 0,
114131
+ rowIndex: sub?.rowIndex,
114132
+ valuePath: runtimeValuePath
114133
+ };
114134
+ }
114135
+ async function openFieldHyperlinkModal(doc, widgetMeta, runtimeValuePath) {
114136
+ const options = resolveOpenFieldHyperlinkModalOptions(doc, widgetMeta, runtimeValuePath);
114137
+ await triggerUtil.handle("OPEN_FIELD_HYPERLINK_MODAL", options);
114138
+ }
114110
114139
  const _sfc_main$38 = /* @__PURE__ */ defineComponent({
114111
114140
  __name: "index",
114112
114141
  props: {
@@ -114245,11 +114274,7 @@ const _sfc_main$38 = /* @__PURE__ */ defineComponent({
114245
114274
  void openESopViewModal(props.doc, w2.widgetMeta, runtimeValuePath);
114246
114275
  return;
114247
114276
  }
114248
- const raw = props.doc.dataManager.getLabel(runtimeValuePath);
114249
- void triggerUtil.handle("OPEN_FIELD_HYPERLINK_MODAL", {
114250
- materialNo: getValue$1(raw, false),
114251
- fieldType: w2.widgetMeta?.field?.fieldType
114252
- });
114277
+ void openFieldHyperlinkModal(props.doc, w2.widgetMeta, runtimeValuePath);
114253
114278
  return;
114254
114279
  }
114255
114280
  const isShowMark = interCtx.annotationIds && interCtx.annotationIds.length !== 0 && interCtx.annotationIds.includes(runtimeValuePath);
@@ -132542,9 +132567,7 @@ function resolveParamFieldTree(doc) {
132542
132567
  const modelKey = sub.bindInfo;
132543
132568
  const modelName = doc.fieldModelQuery.getModel(modelKey)?.modelName ?? sub.name;
132544
132569
  const fields2 = doc.fieldModelQuery.getFieldList(modelKey).filter(
132545
- (field) => field.createType !== "SYSTEM" && [FIELD_TYPE.TEXT, FIELD_TYPE.DOUBLE, FIELD_TYPE.INTEGER, FIELD_TYPE.DECIMAL].includes(
132546
- field.type
132547
- )
132570
+ (field) => field.createType !== "SYSTEM" && [FIELD_TYPE.DOUBLE, FIELD_TYPE.INTEGER, FIELD_TYPE.DECIMAL].includes(field.type)
132548
132571
  );
132549
132572
  if (!fields2.length) continue;
132550
132573
  nodes.push({
@@ -0,0 +1,24 @@
1
+ import { Doc, WidgetMeta } from '../../../../core';
2
+ import { BusinessSubTableType } from '../../../../domain/table/types';
3
+ /** 填报只读超链接字段点击 → 宿主打开追溯弹框 */
4
+ interface OpenFieldHyperlinkModalOptions {
5
+ /** 展示值(批次号等) */
6
+ materialNo?: string;
7
+ /** 字段 manifest 类型(如 material_no);同类型可能对应不同业务弹框,需配合 fieldKey/tableType */
8
+ fieldType?: string;
9
+ /** enrich 写入的 _href_(可能为空,如 newHrefSuffix 静态链) */
10
+ href?: string | null;
11
+ /** 业务字段 key,如 production_container_id_ / material_container_no_ */
12
+ fieldKey?: string;
13
+ /** 业务表类型,如 pretreatment-list;主表字段为空 */
14
+ tableType?: BusinessSubTableType;
15
+ /** 子表字段 key(子模型挂载点) */
16
+ subFieldKey?: string;
17
+ /** 子表行号 */
18
+ rowIndex?: number;
19
+ /** 运行时 valuePath */
20
+ valuePath?: string;
21
+ }
22
+ export declare function resolveOpenFieldHyperlinkModalOptions(doc: Doc, widgetMeta: WidgetMeta, runtimeValuePath: string): OpenFieldHyperlinkModalOptions;
23
+ export declare function openFieldHyperlinkModal(doc: Doc, widgetMeta: WidgetMeta, runtimeValuePath: string): Promise<void>;
24
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gct-paas/word",
3
- "version": "0.1.63-beta.7",
3
+ "version": "0.1.63-beta.8",
4
4
  "description": "GCT 在线 word",
5
5
  "keywords": [
6
6
  "vue",