@gct-paas/word 0.1.41 → 0.1.43

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.
@@ -175,8 +175,10 @@ export declare class DataManager {
175
175
  */
176
176
  applyInitData(initDataMap: Record<string, any>): void;
177
177
  /**
178
- * 补齐二维/检验表的关联轴子表(如 f_ewblink / f_jianyan2)到动态关联铺砖槽位数。
179
- * 不处理主体轴(如 f_ewb / f_jianyan1),避免覆盖接口行或误扩纵向轴。
178
+ * 按版面铺砖槽位补齐子表行数:
179
+ * - 固定表:按槽位补齐自身子表行
180
+ * - 二维/检验表:仅补齐关联轴(如 f_ewblink / f_jianyan2)
181
+ * 不处理主体轴(如 f_ewb / f_jianyan1),避免覆盖接口行或误扩纵向轴。
180
182
  */
181
183
  private syncSubTableRowsToLayout;
182
184
  /** 子表在 rawData 中的行数(支持尚未转成数组的 { data: [] } 接口形态,此时返回 0 且不在此阶段强转) */
package/dist/index.es.js CHANGED
@@ -32089,11 +32089,20 @@ class Enter extends CommandBase {
32089
32089
  const { nodeId, offset: offset2, side } = cursor.getCursor();
32090
32090
  const mapper = this.doc.layoutMapper;
32091
32091
  const run = mapper.getLayoutNodeById(nodeId);
32092
+ const wpId = run?.parent?.modelRef?.id;
32093
+ if (!run || !wpId) {
32094
+ this.isTerminated = true;
32095
+ return null;
32096
+ }
32092
32097
  if (!this.doc.eventManager.policy.canInput(run)) {
32093
32098
  this.isTerminated = true;
32094
32099
  return null;
32095
32100
  }
32096
- const wp = mapper.getModelNodeById(run.parent.modelRef.id);
32101
+ const wp = mapper.getModelNodeById(wpId);
32102
+ if (!wp) {
32103
+ this.isTerminated = true;
32104
+ return null;
32105
+ }
32097
32106
  let targetModelIndex = 0;
32098
32107
  if (!run.isPlaceholderRun) {
32099
32108
  if (run.isWidgetRun || run.isPageWidgetRun) {
@@ -40350,6 +40359,7 @@ class CommandManager {
40350
40359
  compositionUpdate(text) {
40351
40360
  }
40352
40361
  compositionEnd(text) {
40362
+ if (!text) return;
40353
40363
  this.doc.commandManager.execute(CommandType.insertText, {
40354
40364
  text
40355
40365
  });
@@ -41252,22 +41262,29 @@ class FieldBaseHandler {
41252
41262
  }
41253
41263
  static getNoValueLabel(ctx) {
41254
41264
  const { context, wr } = ctx;
41265
+ const widgetMeta = wr.widgetMeta;
41255
41266
  if (context.doc.mode === DocModeTypeConst.Print) {
41256
- return { label: wr.widgetMeta?.props.emptySymbol ?? "", type: "noneLabel" };
41257
- } else {
41258
- if (wr.widgetMeta?.props?.placeholder) {
41259
- return {
41260
- label: wr.widgetMeta.props.placeholder,
41261
- type: "placeholder"
41262
- };
41263
- } else if (wr.widgetMeta?.extra?.biz?.fieldIdentity?.label) {
41264
- return {
41265
- label: wr.widgetMeta.extra.biz.fieldIdentity.label,
41266
- type: "fieldName"
41267
- };
41268
- }
41267
+ return {
41268
+ label: widgetMeta?.props.emptySymbol ?? "",
41269
+ type: "noneLabel"
41270
+ };
41269
41271
  }
41270
- return {
41272
+ const candidates = [
41273
+ {
41274
+ label: widgetMeta?.props?.newSpecificConfig?.newPlaceholder,
41275
+ type: "placeholder"
41276
+ },
41277
+ {
41278
+ label: widgetMeta?.props?.placeholder,
41279
+ type: "placeholder"
41280
+ },
41281
+ {
41282
+ label: widgetMeta?.extra?.biz?.fieldIdentity?.label,
41283
+ type: "fieldName"
41284
+ }
41285
+ ];
41286
+ const matched = candidates.find((item) => item.label);
41287
+ return matched ?? {
41271
41288
  label: "--",
41272
41289
  type: "default"
41273
41290
  };
@@ -42524,7 +42541,7 @@ const FIELD_TYPE_TO_FW = {
42524
42541
  [FIELD_TYPE.INTEGER]: "fw:number",
42525
42542
  [FIELD_TYPE.LONG]: "fw:number",
42526
42543
  [FIELD_TYPE.DOUBLE]: "fw:double",
42527
- [FIELD_TYPE.DECIMAL]: "fw:double",
42544
+ [FIELD_TYPE.DECIMAL]: "fw:number",
42528
42545
  [FIELD_TYPE.BOOLEAN]: "fw:enum",
42529
42546
  [FIELD_TYPE.DATE]: "fw:date",
42530
42547
  [FIELD_TYPE.DATE_TIME]: "fw:date-time",
@@ -46540,10 +46557,11 @@ class IMEHandler {
46540
46557
  this.eventManager.doc.commandManager.compositionUpdate(data);
46541
46558
  }
46542
46559
  handleCompositionEnd(payload) {
46543
- const data = payload?.data ?? this.lastComposedText ?? "";
46560
+ const data = payload?.data !== null && payload?.data !== void 0 ? payload.data : this.lastComposedText ?? "";
46544
46561
  this.lastComposedText = null;
46545
46562
  this.isComposing = false;
46546
46563
  this.lastCompositionCommitTime = performance.now();
46564
+ if (!data) return;
46547
46565
  this.eventManager.doc.commandManager.compositionEnd(data);
46548
46566
  }
46549
46567
  handleInput(payload) {
@@ -46572,6 +46590,7 @@ class IMEHandler {
46572
46590
  case "delete":
46573
46591
  break;
46574
46592
  case "enter":
46593
+ if (this.isComposing) return;
46575
46594
  doc.commandManager.execute(CommandType.enter);
46576
46595
  break;
46577
46596
  case "tab":
@@ -47621,23 +47640,31 @@ class DataManager {
47621
47640
  this.syncSubTableRowsToLayout();
47622
47641
  }
47623
47642
  /**
47624
- * 补齐二维/检验表的关联轴子表(如 f_ewblink / f_jianyan2)到动态关联铺砖槽位数。
47625
- * 不处理主体轴(如 f_ewb / f_jianyan1),避免覆盖接口行或误扩纵向轴。
47643
+ * 按版面铺砖槽位补齐子表行数:
47644
+ * - 固定表:按槽位补齐自身子表行
47645
+ * - 二维/检验表:仅补齐关联轴(如 f_ewblink / f_jianyan2)
47646
+ * 不处理主体轴(如 f_ewb / f_jianyan1),避免覆盖接口行或误扩纵向轴。
47626
47647
  */
47627
47648
  syncSubTableRowsToLayout() {
47628
47649
  const listSubTables = this.doc?.model?.getSubTableInfoList;
47629
47650
  if (typeof listSubTables !== "function") return;
47630
47651
  for (const info of listSubTables.call(this.doc?.model)) {
47631
- if (!info.field || !["check-table-2d-link", "sub-table-2d-link"].includes(info.subType)) {
47652
+ if (!info.field) {
47632
47653
  continue;
47633
47654
  }
47634
- const linkFieldKey = info.field;
47635
- const layoutRows = this.doc?.model?.getSubTableLayoutSlotCount(linkFieldKey) ?? 0;
47655
+ const subTableKey = info.field;
47656
+ const layoutRows = this.doc?.model?.getSubTableLayoutSlotCount(subTableKey) ?? 0;
47636
47657
  if (layoutRows <= 0) continue;
47637
- const dataRows = this.countSubTableDataRows(linkFieldKey);
47658
+ const dataRows = this.countSubTableDataRows(subTableKey);
47638
47659
  const targetRows = Math.max(dataRows, layoutRows);
47639
47660
  if (targetRows <= dataRows) continue;
47640
- this.ensureCheckTableLinkLayoutRows(linkFieldKey, targetRows);
47661
+ if (["check-table-2d-link", "sub-table-2d-link"].includes(info.subType)) {
47662
+ this.ensureCheckTableLinkLayoutRows(subTableKey, targetRows);
47663
+ continue;
47664
+ }
47665
+ if (info.subType === "fixed-table") {
47666
+ this.ensureSubTableRowCount(subTableKey, targetRows, true);
47667
+ }
47641
47668
  }
47642
47669
  }
47643
47670
  /** 子表在 rawData 中的行数(支持尚未转成数组的 { data: [] } 接口形态,此时返回 0 且不在此阶段强转) */
@@ -48242,9 +48269,6 @@ class InteractionManager {
48242
48269
  this.batcher = new Transaction((q2) => {
48243
48270
  this.broadcastChange(q2.type, q2.prev, q2.reason);
48244
48271
  });
48245
- setTimeout(() => {
48246
- this.emitChange("panelData", null);
48247
- });
48248
48272
  }
48249
48273
  /** 获取 interaction */
48250
48274
  get(type4) {
@@ -48588,10 +48612,14 @@ function useInteraction(docRef) {
48588
48612
  "focusAnnotationId",
48589
48613
  "annotationList"
48590
48614
  ];
48615
+ const setState = (type4, value) => {
48616
+ state[type4] = value;
48617
+ };
48591
48618
  interactionTypes.forEach((type4) => {
48592
48619
  try {
48620
+ setState(type4, doc.interactionManager.get(type4));
48593
48621
  const off2 = doc.eventManager.eventBus.on(`${type4}:change`, (payload) => {
48594
- state[type4] = payload?.value ?? null;
48622
+ setState(type4, payload?.value);
48595
48623
  });
48596
48624
  unsubscribes.push(off2);
48597
48625
  } catch {
@@ -51102,8 +51130,18 @@ const _sfc_main$2X = /* @__PURE__ */ defineComponent({
51102
51130
  lastComposedText.value = data;
51103
51131
  dispatch("ime:compositionupdate", { data });
51104
51132
  }
51133
+ function resolveCompositionEndData(e) {
51134
+ if (e.data !== null && e.data !== void 0) {
51135
+ return e.data;
51136
+ }
51137
+ const fromTextarea = ta2.value?.value ?? "";
51138
+ if (fromTextarea !== lastComposedText.value) {
51139
+ lastComposedText.value = fromTextarea;
51140
+ }
51141
+ return lastComposedText.value ?? "";
51142
+ }
51105
51143
  function onCompositionEnd(e) {
51106
- const data = e.data ?? lastComposedText.value ?? "";
51144
+ const data = resolveCompositionEndData(e);
51107
51145
  isComposing.value = false;
51108
51146
  pos.opacity = props.idleOpacity;
51109
51147
  lastComposedText.value = "";
@@ -51132,6 +51170,7 @@ const _sfc_main$2X = /* @__PURE__ */ defineComponent({
51132
51170
  }
51133
51171
  break;
51134
51172
  case "Enter":
51173
+ if (isComposing.value) return;
51135
51174
  e.preventDefault();
51136
51175
  dispatch("ime:keydown", { type: "enter" });
51137
51176
  break;
@@ -51179,9 +51218,10 @@ const _sfc_main$2X = /* @__PURE__ */ defineComponent({
51179
51218
  function onBlur(e) {
51180
51219
  if (isComposing.value) {
51181
51220
  isComposing.value = false;
51182
- dispatch("ime:compositionend", { data: lastComposedText.value });
51221
+ const data = ta2.value?.value ?? lastComposedText.value ?? "";
51183
51222
  lastComposedText.value = "";
51184
51223
  lastCompositionCommitTime.value = performance.now();
51224
+ dispatch("ime:compositionend", { data });
51185
51225
  }
51186
51226
  dispatch("ime:blur", {});
51187
51227
  }
@@ -51280,7 +51320,7 @@ const _sfc_main$2X = /* @__PURE__ */ defineComponent({
51280
51320
  };
51281
51321
  }
51282
51322
  });
51283
- const HiddenInput = /* @__PURE__ */ _export_sfc(_sfc_main$2X, [["__scopeId", "data-v-58dae928"]]);
51323
+ const HiddenInput = /* @__PURE__ */ _export_sfc(_sfc_main$2X, [["__scopeId", "data-v-72d0b6f5"]]);
51284
51324
  function useLatestRequest(execFn) {
51285
51325
  let lastReqId = 0;
51286
51326
  const loading = ref(false);
@@ -100137,6 +100177,63 @@ async function waitForDataManagerSettle() {
100137
100177
  function syncInitRawDataSnapshot(doc) {
100138
100178
  doc.docRuntimeMeta.handleInfo.initRawDataSnapshot = cloneDeep(doc.dataManager.getRawData());
100139
100179
  }
100180
+ function useSpecificConfig(options) {
100181
+ const { widget, fieldInfo } = options;
100182
+ const resolvedFieldInfo = fieldInfo?.value ?? fieldInfo;
100183
+ const specificFieldConfig = resolvedFieldInfo?.specificConfig;
100184
+ const specificConfig = widget.widgetMeta?.props.newSpecificConfig;
100185
+ if (!specificConfig) return;
100186
+ const widgetMeta = widget.widgetMeta;
100187
+ const widgetType = widgetMeta?.type;
100188
+ switch (widgetType) {
100189
+ case "fw:input": {
100190
+ const fieldType = widgetMeta?.field?.fieldType;
100191
+ if (fieldType === FIELD_TYPE.RECORD_NO && specificFieldConfig?.signGenerate === "snRule") {
100192
+ Object.assign(specificConfig, {
100193
+ newDisabled: true,
100194
+ newPlaceholder: "记录单号自动生成,无需填写"
100195
+ });
100196
+ }
100197
+ break;
100198
+ }
100199
+ case "fw:number": {
100200
+ const { digits, rulesForRounding } = specificFieldConfig ?? {};
100201
+ if (digits !== void 0) {
100202
+ specificConfig.digits = digits;
100203
+ }
100204
+ specificConfig.rulesForRounding = rulesForRounding ?? 6;
100205
+ break;
100206
+ }
100207
+ }
100208
+ }
100209
+ function resolveFieldInfo(options) {
100210
+ if (options.fieldInfo) return options.fieldInfo;
100211
+ const runtime = options.ctx?.runtime;
100212
+ const field = options.widget?.widgetMeta?.field;
100213
+ const modelKey = getLastSegment(field?.modelLink);
100214
+ const fieldKey = getLastSegment(field?.fieldLink);
100215
+ if (!runtime || !modelKey || !fieldKey) return void 0;
100216
+ const list = runtime.getFieldList(modelKey) ?? [];
100217
+ return list.find((item) => item.key === fieldKey);
100218
+ }
100219
+ function applyWidgetRuntimeInitializer(options) {
100220
+ const fieldInfo = resolveFieldInfo(options);
100221
+ useSpecificConfig({
100222
+ ...options,
100223
+ fieldInfo
100224
+ });
100225
+ }
100226
+ function useWidgetInitializer(options) {
100227
+ const init2 = (isSupport) => {
100228
+ if (!isSupport) {
100229
+ return;
100230
+ }
100231
+ applyWidgetRuntimeInitializer(options);
100232
+ };
100233
+ return {
100234
+ init: init2
100235
+ };
100236
+ }
100140
100237
  function snapshotDocInfo(docInst) {
100141
100238
  return {
100142
100239
  pages: docInst?.pages ?? [],
@@ -100162,8 +100259,18 @@ async function initializeDocumentEngine(props, payload, result) {
100162
100259
  const runtimeJsonForModel = expandCheckTableRuntimeJson(cloneRuntimeJson, {
100163
100260
  itemCountByRegionId
100164
100261
  });
100262
+ const checkTableRegions = listCheckTableRegionsInRuntimeJson(runtimeJsonForModel);
100263
+ const linkFieldKey = checkTableRegions[0]?.linkFieldKey;
100165
100264
  const docModel = ModelConverter.toModel(runtimeJsonForModel);
100166
100265
  const instances = docModel.getWidgetInstances();
100266
+ if (fillModeType !== DocModeTypeConst.Edit) {
100267
+ instances.forEach((instance2) => {
100268
+ applyWidgetRuntimeInitializer({
100269
+ widget: instance2,
100270
+ ctx: payload.ctx
100271
+ });
100272
+ });
100273
+ }
100167
100274
  const defaultQueryIds = getDefaultQueryIdsByFieldType({
100168
100275
  materialNumber: paramsConfig?.materialNo || requestInfo.materialNo,
100169
100276
  productId: paramsConfig?.productId,
@@ -100178,8 +100285,6 @@ async function initializeDocumentEngine(props, payload, result) {
100178
100285
  defaultQueryIds,
100179
100286
  masterSlaveList
100180
100287
  );
100181
- const checkTableRegions = listCheckTableRegionsInRuntimeJson(runtimeJsonForModel);
100182
- const linkFieldKey = checkTableRegions[0]?.linkFieldKey;
100183
100288
  mergeCheckTableItemInfosIntoDefaults(defaultDataMap, runtimeJsonForModel, checkTableItemInfos, {
100184
100289
  layoutColumnCount: linkFieldKey ? docModel.getSubTableLayoutSlotCount(linkFieldKey) : 0
100185
100290
  });
@@ -102804,30 +102909,6 @@ function useDependency(doc, widget, ctx) {
102804
102909
  initDependency
102805
102910
  };
102806
102911
  }
102807
- function useSpecificConfig(options) {
102808
- const { widget, fieldInfo } = options;
102809
- const widgetType = widget.widgetMeta?.type;
102810
- if (widgetType !== "fw:number") {
102811
- return;
102812
- }
102813
- const specificConfig = widget.widgetMeta.props.newSpecificConfig;
102814
- const digits = fieldInfo?.value?.specificConfig?.digits;
102815
- if (digits !== void 0) {
102816
- specificConfig.digits = digits;
102817
- }
102818
- specificConfig.rulesForRounding = fieldInfo?.value?.specificConfig?.rulesForRounding ?? 6;
102819
- }
102820
- function useWidgetInitializer(options) {
102821
- const init2 = (isSupport) => {
102822
- if (!isSupport) {
102823
- return;
102824
- }
102825
- useSpecificConfig(options);
102826
- };
102827
- return {
102828
- init: init2
102829
- };
102830
- }
102831
102912
  const _sfc_main$2Q = /* @__PURE__ */ defineComponent({
102832
102913
  __name: "overlay-render",
102833
102914
  props: {
@@ -102864,7 +102945,8 @@ const _sfc_main$2Q = /* @__PURE__ */ defineComponent({
102864
102945
  const { init: init2 } = useWidgetInitializer({
102865
102946
  doc: props.doc,
102866
102947
  widget: props.widget,
102867
- fieldInfo
102948
+ fieldInfo,
102949
+ ctx: designCtx
102868
102950
  });
102869
102951
  init2(props.isLastWidgetId);
102870
102952
  const { validateField } = createFormValidator();
@@ -113089,7 +113171,8 @@ const _sfc_main$1X = /* @__PURE__ */ defineComponent({
113089
113171
  showDisabled,
113090
113172
  showReadonly,
113091
113173
  widgetProps,
113092
- widgetType
113174
+ widgetType,
113175
+ fieldMeta
113093
113176
  } = useWidgetStaticAttrs(props.widget);
113094
113177
  const CurrentComp = computed(() => {
113095
113178
  if (widgetType.value === "fw:file") {
@@ -113108,12 +113191,16 @@ const _sfc_main$1X = /* @__PURE__ */ defineComponent({
113108
113191
  const optionValue = computed(() => props.widget?.widgetOption?.value);
113109
113192
  const modelValue = computed({
113110
113193
  get() {
113194
+ let value;
113111
113195
  if (docInst.value.isInEditMode()) {
113112
- const value2 = docInst.value?.dataManager?.getDefault(runtimeValuePath.value);
113113
- return toBoolean(getValue$1(value2, isMultiple.value));
113196
+ value = docInst.value?.dataManager?.getDefault(runtimeValuePath.value);
113197
+ } else {
113198
+ value = docInst.value?.dataManager?.get(runtimeValuePath.value);
113114
113199
  }
113115
- const value = docInst.value?.dataManager?.get(runtimeValuePath.value);
113116
- return toBoolean(getValue$1(value, isMultiple.value));
113200
+ if (fieldMeta.value?.fieldType === FIELD_TYPE.BOOLEAN) {
113201
+ value = toBoolean(value);
113202
+ }
113203
+ return getValue$1(value, isMultiple.value);
113117
113204
  },
113118
113205
  set(v) {
113119
113206
  const data = setValue(v, runtimeValuePath.value, {
@@ -113301,13 +113388,6 @@ const _sfc_main$1U = /* @__PURE__ */ defineComponent({
113301
113388
  () => props.modelId === interCtx.panelData?.modelId || props.modelId === interCtx.hoverModelId
113302
113389
  );
113303
113390
  const colors = computed(() => {
113304
- if (showRequired.value) {
113305
- return {
113306
- text: "#f26c6c",
113307
- line: "#f26c6c",
113308
- bg: isActive.value ? "rgba(255, 230, 230, 1)" : "rgba(255, 242, 242, 1)"
113309
- };
113310
- }
113311
113391
  if (showDisabled.value) {
113312
113392
  return {
113313
113393
  text: "#c9c9c9",
@@ -113322,6 +113402,13 @@ const _sfc_main$1U = /* @__PURE__ */ defineComponent({
113322
113402
  bg: isActive.value ? "#f5f7fa" : "#fafafa"
113323
113403
  };
113324
113404
  }
113405
+ if (showRequired.value) {
113406
+ return {
113407
+ text: "#f26c6c",
113408
+ line: "#f26c6c",
113409
+ bg: isActive.value ? "rgba(255, 230, 230, 1)" : "rgba(255, 242, 242, 1)"
113410
+ };
113411
+ }
113325
113412
  return {
113326
113413
  text: "#999999",
113327
113414
  line: "#999999",
@@ -1,10 +1,12 @@
1
1
  import { Doc } from '../../core';
2
2
  export interface WidgetInitializerOptions {
3
- doc: Doc;
3
+ doc?: Doc;
4
4
  widget: any;
5
5
  fieldInfo?: any;
6
6
  ctx?: any;
7
7
  }
8
+ /** 运行时执行单个 widget 初始化 */
9
+ export declare function applyWidgetRuntimeInitializer(options: WidgetInitializerOptions): void;
8
10
  /** widget 运行时初始化 */
9
11
  export declare function useWidgetInitializer(options: WidgetInitializerOptions): {
10
12
  init: (isSupport: boolean) => void;
package/dist/word.css CHANGED
@@ -7572,7 +7572,7 @@ textarea[data-v-57fe54a3]::placeholder {
7572
7572
  .avatar--horizontal .avatar__name[data-v-b2773d93] {
7573
7573
  margin-left: 6px;
7574
7574
  }
7575
- .hidden-input[data-v-58dae928] {
7575
+ .hidden-input[data-v-72d0b6f5] {
7576
7576
  position: absolute;
7577
7577
  resize: none;
7578
7578
  border: none;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gct-paas/word",
3
- "version": "0.1.41",
3
+ "version": "0.1.43",
4
4
  "description": "GCT 在线 word",
5
5
  "keywords": [
6
6
  "vue",