@gct-paas/word 0.1.32 → 0.1.33

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 (41) hide show
  1. package/dist/base/input/src/input.vue.d.ts +1 -1
  2. package/dist/base/input/src/text-area.vue.d.ts +1 -1
  3. package/dist/base/table/src/table.vue.d.ts +1 -1
  4. package/dist/core/command/commands/InsertField.d.ts +22 -2
  5. package/dist/core/data/DataManager.d.ts +24 -8
  6. package/dist/core/layout/handlers/fields/FieldBaseHandler.d.ts +1 -0
  7. package/dist/core/layout/linkSubTableLayout.d.ts +22 -0
  8. package/dist/core/layout/providers/TableInfoProvider.d.ts +2 -3
  9. package/dist/core/model/document/Wtbl/RegionManager.d.ts +47 -10
  10. package/dist/core/model/document/Wtc.d.ts +20 -15
  11. package/dist/core/model/document/wtcRegionRef.d.ts +20 -0
  12. package/dist/core/model/logic/{Region.d.ts → base/Region.d.ts} +2 -5
  13. package/dist/core/model/logic/{SubTableHeaderRegion.d.ts → header/SubTableHeaderRegion.d.ts} +3 -6
  14. package/dist/core/model/logic/{TableHeaderRegion.d.ts → header/TableHeaderRegion.d.ts} +3 -3
  15. package/dist/core/model/logic/index.d.ts +18 -22
  16. package/dist/core/model/logic/{BoundedItemRegion.d.ts → subtable/bounded/BoundedItemRegion.d.ts} +1 -1
  17. package/dist/core/model/logic/{BoundedRegion.d.ts → subtable/bounded/BoundedRegion.d.ts} +3 -9
  18. package/dist/core/model/logic/subtable/link/CheckTableRegion.d.ts +11 -0
  19. package/dist/core/model/logic/subtable/link/DataGroup2DRegion.d.ts +11 -0
  20. package/dist/core/model/logic/subtable/link/LinkSubTableRegion.d.ts +48 -0
  21. package/dist/core/model/logic/subtable/link/_2DTableRegion.d.ts +11 -0
  22. package/dist/core/model/logic/{RepeatingRegion.d.ts → subtable/repeating/RepeatingRegion.d.ts} +3 -9
  23. package/dist/core/model/logic/subtable/shared/itemRegionOps.d.ts +11 -0
  24. package/dist/core/model/logic/types.d.ts +10 -0
  25. package/dist/core/utils/expand.d.ts +49 -18
  26. package/dist/core/view/TableCell.d.ts +3 -7
  27. package/dist/index.es.js +1611 -1238
  28. package/dist/runtime/canvas/table/utils/index.d.ts +10 -2
  29. package/dist/runtime/factories/createDesignWidgetFactory.d.ts +17 -0
  30. package/dist/runtime/factories/{useRenderData.d.ts → useWidgetRenderData.d.ts} +18 -6
  31. package/dist/runtime/renderer/dropdowns/components/tables/rdo-table-dropdown.vue.d.ts +3 -3
  32. package/dist/runtime/renderer/dropdowns/components/tables/table-dropdown.vue.d.ts +3 -3
  33. package/dist/utils/func/core.d.ts +70 -20
  34. package/dist/word.css +128 -128
  35. package/package.json +3 -3
  36. package/dist/core/model/logic/CheckTableRegion.d.ts +0 -44
  37. package/dist/core/model/logic/DataGroup2DRegion.d.ts +0 -12
  38. package/dist/core/model/logic/_2DTableRegion.d.ts +0 -44
  39. package/dist/runtime/factories/createFieldToWidgetFactory.d.ts +0 -13
  40. package/dist/runtime/factories/createPaperWidgetToWidgetFactory.d.ts +0 -13
  41. package/dist/runtime/factories/usePwRenderData.d.ts +0 -13
package/dist/index.es.js CHANGED
@@ -15580,7 +15580,7 @@ function isArrayBufferView(val) {
15580
15580
  }
15581
15581
  const isString = typeOfTest("string");
15582
15582
  const isFunction$2 = typeOfTest("function");
15583
- const isNumber = typeOfTest("number");
15583
+ const isNumber$1 = typeOfTest("number");
15584
15584
  const isObject$1 = (thing) => thing !== null && typeof thing === "object";
15585
15585
  const isBoolean = (thing) => thing === true || thing === false;
15586
15586
  const isPlainObject$1 = (val) => {
@@ -15738,7 +15738,7 @@ const toArray = (thing) => {
15738
15738
  if (!thing) return null;
15739
15739
  if (isArray$1(thing)) return thing;
15740
15740
  let i = thing.length;
15741
- if (!isNumber(i)) return null;
15741
+ if (!isNumber$1(i)) return null;
15742
15742
  const arr = new Array(i);
15743
15743
  while (i-- > 0) {
15744
15744
  arr[i] = thing[i];
@@ -15881,7 +15881,7 @@ const utils$1 = {
15881
15881
  isFormData,
15882
15882
  isArrayBufferView,
15883
15883
  isString,
15884
- isNumber,
15884
+ isNumber: isNumber$1,
15885
15885
  isBoolean,
15886
15886
  isObject: isObject$1,
15887
15887
  isPlainObject: isPlainObject$1,
@@ -19121,11 +19121,11 @@ var moduleExports$2 = freeModule$2 && freeModule$2.exports === freeExports$2;
19121
19121
  var Buffer$2 = moduleExports$2 ? root.Buffer : void 0;
19122
19122
  var nativeIsBuffer = Buffer$2 ? Buffer$2.isBuffer : void 0;
19123
19123
  var isBuffer = nativeIsBuffer || stubFalse;
19124
- var argsTag$2 = "[object Arguments]", arrayTag$2 = "[object Array]", boolTag$3 = "[object Boolean]", dateTag$3 = "[object Date]", errorTag$2 = "[object Error]", funcTag$1 = "[object Function]", mapTag$6 = "[object Map]", numberTag$3 = "[object Number]", objectTag$4 = "[object Object]", regexpTag$3 = "[object RegExp]", setTag$6 = "[object Set]", stringTag$3 = "[object String]", weakMapTag$2 = "[object WeakMap]";
19124
+ var argsTag$2 = "[object Arguments]", arrayTag$2 = "[object Array]", boolTag$3 = "[object Boolean]", dateTag$3 = "[object Date]", errorTag$2 = "[object Error]", funcTag$1 = "[object Function]", mapTag$6 = "[object Map]", numberTag$4 = "[object Number]", objectTag$4 = "[object Object]", regexpTag$3 = "[object RegExp]", setTag$6 = "[object Set]", stringTag$3 = "[object String]", weakMapTag$2 = "[object WeakMap]";
19125
19125
  var arrayBufferTag$3 = "[object ArrayBuffer]", dataViewTag$4 = "[object DataView]", float32Tag$2 = "[object Float32Array]", float64Tag$2 = "[object Float64Array]", int8Tag$2 = "[object Int8Array]", int16Tag$2 = "[object Int16Array]", int32Tag$2 = "[object Int32Array]", uint8Tag$2 = "[object Uint8Array]", uint8ClampedTag$2 = "[object Uint8ClampedArray]", uint16Tag$2 = "[object Uint16Array]", uint32Tag$2 = "[object Uint32Array]";
19126
19126
  var typedArrayTags = {};
19127
19127
  typedArrayTags[float32Tag$2] = typedArrayTags[float64Tag$2] = typedArrayTags[int8Tag$2] = typedArrayTags[int16Tag$2] = typedArrayTags[int32Tag$2] = typedArrayTags[uint8Tag$2] = typedArrayTags[uint8ClampedTag$2] = typedArrayTags[uint16Tag$2] = typedArrayTags[uint32Tag$2] = true;
19128
- typedArrayTags[argsTag$2] = typedArrayTags[arrayTag$2] = typedArrayTags[arrayBufferTag$3] = typedArrayTags[boolTag$3] = typedArrayTags[dataViewTag$4] = typedArrayTags[dateTag$3] = typedArrayTags[errorTag$2] = typedArrayTags[funcTag$1] = typedArrayTags[mapTag$6] = typedArrayTags[numberTag$3] = typedArrayTags[objectTag$4] = typedArrayTags[regexpTag$3] = typedArrayTags[setTag$6] = typedArrayTags[stringTag$3] = typedArrayTags[weakMapTag$2] = false;
19128
+ typedArrayTags[argsTag$2] = typedArrayTags[arrayTag$2] = typedArrayTags[arrayBufferTag$3] = typedArrayTags[boolTag$3] = typedArrayTags[dataViewTag$4] = typedArrayTags[dateTag$3] = typedArrayTags[errorTag$2] = typedArrayTags[funcTag$1] = typedArrayTags[mapTag$6] = typedArrayTags[numberTag$4] = typedArrayTags[objectTag$4] = typedArrayTags[regexpTag$3] = typedArrayTags[setTag$6] = typedArrayTags[stringTag$3] = typedArrayTags[weakMapTag$2] = false;
19129
19129
  function baseIsTypedArray(value) {
19130
19130
  return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
19131
19131
  }
@@ -19684,7 +19684,7 @@ function cloneTypedArray(typedArray, isDeep) {
19684
19684
  var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
19685
19685
  return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
19686
19686
  }
19687
- var boolTag$2 = "[object Boolean]", dateTag$2 = "[object Date]", mapTag$4 = "[object Map]", numberTag$2 = "[object Number]", regexpTag$2 = "[object RegExp]", setTag$4 = "[object Set]", stringTag$2 = "[object String]", symbolTag$2 = "[object Symbol]";
19687
+ var boolTag$2 = "[object Boolean]", dateTag$2 = "[object Date]", mapTag$4 = "[object Map]", numberTag$3 = "[object Number]", regexpTag$2 = "[object RegExp]", setTag$4 = "[object Set]", stringTag$2 = "[object String]", symbolTag$2 = "[object Symbol]";
19688
19688
  var arrayBufferTag$2 = "[object ArrayBuffer]", dataViewTag$2 = "[object DataView]", float32Tag$1 = "[object Float32Array]", float64Tag$1 = "[object Float64Array]", int8Tag$1 = "[object Int8Array]", int16Tag$1 = "[object Int16Array]", int32Tag$1 = "[object Int32Array]", uint8Tag$1 = "[object Uint8Array]", uint8ClampedTag$1 = "[object Uint8ClampedArray]", uint16Tag$1 = "[object Uint16Array]", uint32Tag$1 = "[object Uint32Array]";
19689
19689
  function initCloneByTag(object4, tag, isDeep) {
19690
19690
  var Ctor = object4.constructor;
@@ -19708,7 +19708,7 @@ function initCloneByTag(object4, tag, isDeep) {
19708
19708
  return cloneTypedArray(object4, isDeep);
19709
19709
  case mapTag$4:
19710
19710
  return new Ctor();
19711
- case numberTag$2:
19711
+ case numberTag$3:
19712
19712
  case stringTag$2:
19713
19713
  return new Ctor(object4);
19714
19714
  case regexpTag$2:
@@ -19735,10 +19735,10 @@ function baseIsSet(value) {
19735
19735
  var nodeIsSet = nodeUtil && nodeUtil.isSet;
19736
19736
  var isSet = nodeIsSet ? baseUnary(nodeIsSet) : baseIsSet;
19737
19737
  var CLONE_DEEP_FLAG$2 = 1, CLONE_FLAT_FLAG$1 = 2, CLONE_SYMBOLS_FLAG$2 = 4;
19738
- var argsTag$1 = "[object Arguments]", arrayTag$1 = "[object Array]", boolTag$1 = "[object Boolean]", dateTag$1 = "[object Date]", errorTag$1 = "[object Error]", funcTag = "[object Function]", genTag = "[object GeneratorFunction]", mapTag$2 = "[object Map]", numberTag$1 = "[object Number]", objectTag$1 = "[object Object]", regexpTag$1 = "[object RegExp]", setTag$2 = "[object Set]", stringTag$1 = "[object String]", symbolTag$1 = "[object Symbol]", weakMapTag = "[object WeakMap]";
19738
+ var argsTag$1 = "[object Arguments]", arrayTag$1 = "[object Array]", boolTag$1 = "[object Boolean]", dateTag$1 = "[object Date]", errorTag$1 = "[object Error]", funcTag = "[object Function]", genTag = "[object GeneratorFunction]", mapTag$2 = "[object Map]", numberTag$2 = "[object Number]", objectTag$1 = "[object Object]", regexpTag$1 = "[object RegExp]", setTag$2 = "[object Set]", stringTag$1 = "[object String]", symbolTag$1 = "[object Symbol]", weakMapTag = "[object WeakMap]";
19739
19739
  var arrayBufferTag$1 = "[object ArrayBuffer]", dataViewTag$1 = "[object DataView]", float32Tag = "[object Float32Array]", float64Tag = "[object Float64Array]", int8Tag = "[object Int8Array]", int16Tag = "[object Int16Array]", int32Tag = "[object Int32Array]", uint8Tag = "[object Uint8Array]", uint8ClampedTag = "[object Uint8ClampedArray]", uint16Tag = "[object Uint16Array]", uint32Tag = "[object Uint32Array]";
19740
19740
  var cloneableTags = {};
19741
- cloneableTags[argsTag$1] = cloneableTags[arrayTag$1] = cloneableTags[arrayBufferTag$1] = cloneableTags[dataViewTag$1] = cloneableTags[boolTag$1] = cloneableTags[dateTag$1] = cloneableTags[float32Tag] = cloneableTags[float64Tag] = cloneableTags[int8Tag] = cloneableTags[int16Tag] = cloneableTags[int32Tag] = cloneableTags[mapTag$2] = cloneableTags[numberTag$1] = cloneableTags[objectTag$1] = cloneableTags[regexpTag$1] = cloneableTags[setTag$2] = cloneableTags[stringTag$1] = cloneableTags[symbolTag$1] = cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] = cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
19741
+ cloneableTags[argsTag$1] = cloneableTags[arrayTag$1] = cloneableTags[arrayBufferTag$1] = cloneableTags[dataViewTag$1] = cloneableTags[boolTag$1] = cloneableTags[dateTag$1] = cloneableTags[float32Tag] = cloneableTags[float64Tag] = cloneableTags[int8Tag] = cloneableTags[int16Tag] = cloneableTags[int32Tag] = cloneableTags[mapTag$2] = cloneableTags[numberTag$2] = cloneableTags[objectTag$1] = cloneableTags[regexpTag$1] = cloneableTags[setTag$2] = cloneableTags[stringTag$1] = cloneableTags[symbolTag$1] = cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] = cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true;
19742
19742
  cloneableTags[errorTag$1] = cloneableTags[funcTag] = cloneableTags[weakMapTag] = false;
19743
19743
  function baseClone(value, bitmask, customizer, key, object4, stack) {
19744
19744
  var result, isDeep = bitmask & CLONE_DEEP_FLAG$2, isFlat = bitmask & CLONE_FLAT_FLAG$1, isFull = bitmask & CLONE_SYMBOLS_FLAG$2;
@@ -19892,7 +19892,7 @@ function setToArray(set2) {
19892
19892
  return result;
19893
19893
  }
19894
19894
  var COMPARE_PARTIAL_FLAG$4 = 1, COMPARE_UNORDERED_FLAG$2 = 2;
19895
- var boolTag = "[object Boolean]", dateTag = "[object Date]", errorTag = "[object Error]", mapTag$1 = "[object Map]", numberTag = "[object Number]", regexpTag = "[object RegExp]", setTag$1 = "[object Set]", stringTag = "[object String]", symbolTag = "[object Symbol]";
19895
+ var boolTag = "[object Boolean]", dateTag = "[object Date]", errorTag = "[object Error]", mapTag$1 = "[object Map]", numberTag$1 = "[object Number]", regexpTag = "[object RegExp]", setTag$1 = "[object Set]", stringTag = "[object String]", symbolTag = "[object Symbol]";
19896
19896
  var arrayBufferTag = "[object ArrayBuffer]", dataViewTag = "[object DataView]";
19897
19897
  var symbolProto = Symbol$1 ? Symbol$1.prototype : void 0, symbolValueOf = symbolProto ? symbolProto.valueOf : void 0;
19898
19898
  function equalByTag(object4, other, tag, bitmask, customizer, equalFunc, stack) {
@@ -19910,7 +19910,7 @@ function equalByTag(object4, other, tag, bitmask, customizer, equalFunc, stack)
19910
19910
  return true;
19911
19911
  case boolTag:
19912
19912
  case dateTag:
19913
- case numberTag:
19913
+ case numberTag$1:
19914
19914
  return eq(+object4, +other);
19915
19915
  case errorTag:
19916
19916
  return object4.name == other.name && object4.message == other.message;
@@ -20430,6 +20430,10 @@ function isEmpty(value) {
20430
20430
  function isEqual(value, other) {
20431
20431
  return baseIsEqual(value, other);
20432
20432
  }
20433
+ var numberTag = "[object Number]";
20434
+ function isNumber(value) {
20435
+ return typeof value == "number" || isObjectLike(value) && baseGetTag(value) == numberTag;
20436
+ }
20433
20437
  function isNil(value) {
20434
20438
  return value == null;
20435
20439
  }
@@ -20594,13 +20598,21 @@ function safeParseJson(data, fallback = null, validator2) {
20594
20598
  }
20595
20599
  function generateValuePath(fieldLink, subFieldKey) {
20596
20600
  if (subFieldKey) {
20597
- const connector = subFieldKey.includes(":") ? "" : "[n]";
20601
+ const connector = subFieldKey.includes(":") ? "[n_y][n_x]" : "[n]";
20598
20602
  return `$.${subFieldKey}${connector}.${fieldLink}`;
20599
20603
  } else {
20600
20604
  return `$.${fieldLink}`;
20601
20605
  }
20602
20606
  }
20603
- function replacePathIndexPlaceholder(refPath, templatePath) {
20607
+ function replacePathIndexPlaceholders(params) {
20608
+ const { x: x2, y: y2, templatePath } = params;
20609
+ let path2 = templatePath;
20610
+ path2 = replacePathIndexPlaceholder(y2, path2, "n_y");
20611
+ path2 = replacePathIndexPlaceholder(x2, path2, "n_x");
20612
+ path2 = replacePathIndexPlaceholder(x2, path2);
20613
+ return path2;
20614
+ }
20615
+ function replacePathIndexPlaceholder(refPath, templatePath, placeholder = "n") {
20604
20616
  let index2;
20605
20617
  if (refPath === void 0) {
20606
20618
  return templatePath;
@@ -20609,32 +20621,64 @@ function replacePathIndexPlaceholder(refPath, templatePath) {
20609
20621
  index2 = refPath.toString();
20610
20622
  } else {
20611
20623
  const indexMatch = refPath.match(/\[(\d+)\]/);
20612
- index2 = indexMatch ? indexMatch[1] : "n";
20624
+ index2 = indexMatch ? indexMatch[1] : placeholder;
20613
20625
  }
20614
- return templatePath.replace(/\[n\]/g, `[${index2}]`);
20626
+ return templatePath.replaceAll(`[${placeholder}]`, `[${index2}]`);
20615
20627
  }
20616
20628
  function getLastSegment(str, separator = ".") {
20617
20629
  if (!str) return "";
20618
20630
  const index2 = str.lastIndexOf(separator);
20619
20631
  return index2 === -1 ? str : str.slice(index2 + 1);
20620
20632
  }
20621
- function parseLinkFieldExpression(str) {
20622
- if (!str) {
20633
+ function parseValuePath(valuePath) {
20634
+ if (!valuePath) {
20623
20635
  return {
20624
- subFieldKey: "",
20625
- linkFieldKey: ""
20626
- };
20636
+ raw: "",
20637
+ normalized: "",
20638
+ fieldKey: "",
20639
+ isRoot: false,
20640
+ isSubTable: false,
20641
+ isLink: false,
20642
+ hasIndex: false,
20643
+ segments: []
20644
+ };
20645
+ }
20646
+ const normalized = valuePath.replace(/^\$\./, "");
20647
+ const segments = normalized.split(".").filter(Boolean);
20648
+ const only = segments[0] || "";
20649
+ const parentRaw = segments.length > 1 ? only : only.includes(":") ? only : "";
20650
+ const fieldKey = segments.length > 1 ? segments.at(-1) || "" : only.includes(":") ? "" : only;
20651
+ const hasIndex = /\[[^\]]+\]/.test(valuePath);
20652
+ const isLink = parentRaw.includes(":");
20653
+ let parentFieldKey = "";
20654
+ let linkFieldKey = "";
20655
+ if (isLink) {
20656
+ const colonIdx = parentRaw.indexOf(":");
20657
+ const subFieldKey = colonIdx >= 0 ? parentRaw.slice(0, colonIdx) : parentRaw;
20658
+ const linkKey = colonIdx >= 0 ? parentRaw.slice(colonIdx + 1) : "";
20659
+ parentFieldKey = (subFieldKey || "").replace(/\[[^\]]*\]/g, "");
20660
+ linkFieldKey = (linkKey || "").replace(/\[[^\]]*\]/g, "");
20661
+ } else {
20662
+ parentFieldKey = parentRaw.replace(/\[.*?\]/g, "");
20627
20663
  }
20628
- const normalized = str.replace(/^\$\./, "");
20629
- const [subFieldKey = "", linkFieldKey = ""] = normalized.split(":");
20630
20664
  return {
20631
- subFieldKey,
20632
- linkFieldKey
20665
+ raw: valuePath,
20666
+ normalized,
20667
+ fieldKey,
20668
+ parentFieldKey,
20669
+ isRoot: segments.length === 1,
20670
+ isSubTable: segments.length > 1,
20671
+ isLink,
20672
+ linkFieldKey,
20673
+ hasIndex,
20674
+ segments
20633
20675
  };
20634
20676
  }
20635
20677
  function getBeforeBracket(str) {
20636
- const reg = /\$\.[a-z_]+\[[^\]]+\]/i;
20637
- return str.match(reg)?.[0] || "";
20678
+ const reg = /\$\.[a-z0-9_$:]+(?:\[[^\]]+\])+/i;
20679
+ const m = str.match(reg)?.[0];
20680
+ if (m) return m;
20681
+ return str.match(/\$\.[a-z_]+\[[^\]]+\]/i)?.[0] || "";
20638
20682
  }
20639
20683
  function createRafOnce() {
20640
20684
  let rafId = null;
@@ -22626,16 +22670,7 @@ const TABLE_CELL_TEMPLATE = {
22626
22670
  }
22627
22671
  ]
22628
22672
  };
22629
- const WTC_REF_KEYS = [
22630
- "mergeId",
22631
- "repeatingId",
22632
- "_2DTableId",
22633
- "boundedId",
22634
- "boundedItemId",
22635
- "checkTableId",
22636
- "dataGroup2DId",
22637
- "headerId"
22638
- ];
22673
+ const WTC_REF_KEYS = ["mergeId", "subTable", "subTableItem", "header"];
22639
22674
  class Wtc extends ModelGroup {
22640
22675
  name = "w:tc";
22641
22676
  type = "element";
@@ -22652,19 +22687,12 @@ class Wtc extends ModelGroup {
22652
22687
  // 被合并单元格指向源头单元格的 ID
22653
22688
  mergeId;
22654
22689
  // 属于哪个合并区域的 ID(所有属于同一合并区域的单元格都有相同值)
22655
- repeatingId;
22656
- // 属于哪个重复区域的 ID
22657
- _2DTableId;
22658
- // 二维表
22659
- boundedId;
22660
- // 属于哪个有界区域的 ID
22661
- boundedItemId;
22662
- // 有界区域内的项目 ID
22663
- checkTableId;
22664
- // 属于哪个检验表的 ID
22665
- dataGroup2DId;
22666
- // 属于哪个数据关联项目 ID
22667
- headerId;
22690
+ /** 子表主体(动态表 / 固定表 / 二维表 / 检验表) */
22691
+ subTable;
22692
+ /** 子表内数据分组或数据关联 */
22693
+ subTableItem;
22694
+ /** 表头 / 子表表头 */
22695
+ header;
22668
22696
  vMergeType;
22669
22697
  // 临时字段,用于 fromXmlJson 时追踪垂直合并
22670
22698
  tempMergeId;
@@ -22677,13 +22705,9 @@ class Wtc extends ModelGroup {
22677
22705
  this.mergeId = options.mergeId;
22678
22706
  this.mergeFromId = options.mergeFromId;
22679
22707
  this.vMergeType = options.vMergeType;
22680
- this.repeatingId = options.repeatingId;
22681
- this._2DTableId = options._2DTableId;
22682
- this.boundedId = options.boundedId;
22683
- this.boundedItemId = options.boundedItemId;
22684
- this.checkTableId = options.checkTableId;
22685
- this.dataGroup2DId = options.dataGroup2DId;
22686
- this.headerId = options.headerId;
22708
+ this.subTable = options.subTable;
22709
+ this.subTableItem = options.subTableItem;
22710
+ this.header = options.header;
22687
22711
  this.backgroundColor = options.backgroundColor;
22688
22712
  this.tempMergeId = options.tempMergeId;
22689
22713
  }
@@ -22760,6 +22784,36 @@ class Wtc extends ModelGroup {
22760
22784
  });
22761
22785
  return result;
22762
22786
  }
22787
+ setSubTable(type4, regionId) {
22788
+ this.subTable = { type: type4, regionId };
22789
+ }
22790
+ clearSubTable() {
22791
+ this.subTable = void 0;
22792
+ }
22793
+ setSubTableItem(type4, regionId) {
22794
+ this.subTableItem = { type: type4, regionId };
22795
+ }
22796
+ clearSubTableItem() {
22797
+ this.subTableItem = void 0;
22798
+ }
22799
+ setHeaderRef(type4, regionId) {
22800
+ this.header = { type: type4, regionId };
22801
+ }
22802
+ clearHeaderRef() {
22803
+ this.header = void 0;
22804
+ }
22805
+ /** 按 regionId 清除单元格上的子表 / 表头引用 */
22806
+ clearRegionRef(regionId) {
22807
+ if (this.subTable?.regionId === regionId) {
22808
+ this.subTable = void 0;
22809
+ }
22810
+ if (this.subTableItem?.regionId === regionId) {
22811
+ this.subTableItem = void 0;
22812
+ }
22813
+ if (this.header?.regionId === regionId) {
22814
+ this.header = void 0;
22815
+ }
22816
+ }
22763
22817
  /**
22764
22818
  * 查找当前单元格对应的区域
22765
22819
  * @returns
@@ -23457,9 +23511,6 @@ class Region {
23457
23511
  }
23458
23512
  /**
23459
23513
  * 检查指定的行列位置是否在当前区域内
23460
- * @param row 行号
23461
- * @param col 列号
23462
- * @returns 是否在区域内
23463
23514
  */
23464
23515
  contains(row, col) {
23465
23516
  return row >= this.start.row && row <= this.end.row && col >= this.start.col && col <= this.end.col;
@@ -23479,84 +23530,81 @@ class Region {
23479
23530
  };
23480
23531
  }
23481
23532
  }
23482
- class RepeatingRegion extends Region {
23483
- type = "repeating";
23484
- name;
23485
- valuePath;
23486
- widgetMeta;
23533
+ class TableHeaderRegion extends Region {
23534
+ type = "table-header";
23535
+ name = "";
23487
23536
  constructor(options) {
23488
23537
  super(options);
23489
- this.valuePath = options.valuePath;
23490
23538
  this.name = options.name;
23491
- this.widgetMeta = options.widgetMeta || {
23492
- props: {
23493
- quickFill: false
23494
- }
23539
+ }
23540
+ toJSON() {
23541
+ return {
23542
+ ...super.toJSON(),
23543
+ name: this.name
23495
23544
  };
23496
23545
  }
23497
- /**
23498
- * 序列化为 JSON 对象
23499
- */
23546
+ static fromJSON(json, table) {
23547
+ return new TableHeaderRegion({
23548
+ table,
23549
+ id: json.id,
23550
+ start: json.start,
23551
+ end: json.end,
23552
+ name: json.name
23553
+ });
23554
+ }
23555
+ }
23556
+ class SubTableHeaderRegion extends Region {
23557
+ type = "sub-table-header";
23558
+ name = "";
23559
+ subTableId;
23560
+ constructor(options) {
23561
+ super(options);
23562
+ this.name = options.name;
23563
+ this.subTableId = options.subTableId;
23564
+ }
23500
23565
  toJSON() {
23501
23566
  return {
23502
23567
  ...super.toJSON(),
23503
23568
  name: this.name,
23504
- valuePath: this.valuePath,
23505
- widgetMeta: this.widgetMeta
23569
+ subTableId: this.subTableId
23506
23570
  };
23507
23571
  }
23508
- /**
23509
- * 从 JSON 对象还原
23510
- */
23511
23572
  static fromJSON(json, table) {
23512
- const region = new RepeatingRegion({
23573
+ return new SubTableHeaderRegion({
23513
23574
  table,
23514
23575
  id: json.id,
23515
23576
  start: json.start,
23516
23577
  end: json.end,
23517
23578
  name: json.name,
23518
- valuePath: json.valuePath,
23519
- widgetMeta: json.widgetMeta
23579
+ subTableId: json.subTableId
23520
23580
  });
23521
- return region;
23522
23581
  }
23523
23582
  }
23524
- class CheckTableRegion extends Region {
23525
- type = "check-table";
23583
+ class RepeatingRegion extends Region {
23584
+ type = "repeating";
23526
23585
  name;
23527
23586
  valuePath;
23528
23587
  widgetMeta;
23529
- itemRegion;
23530
23588
  constructor(options) {
23531
23589
  super(options);
23532
- this.name = options.name;
23533
23590
  this.valuePath = options.valuePath;
23591
+ this.name = options.name;
23534
23592
  this.widgetMeta = options.widgetMeta || {
23535
23593
  props: {
23536
- autoFill: true,
23537
- refColField: void 0,
23538
- refRowField: void 0
23594
+ quickFill: false
23539
23595
  }
23540
23596
  };
23541
- this.itemRegion = options.itemRegion;
23542
23597
  }
23543
- /**
23544
- * 序列化为 JSON 对象
23545
- */
23546
23598
  toJSON() {
23547
23599
  return {
23548
23600
  ...super.toJSON(),
23549
23601
  name: this.name,
23550
23602
  valuePath: this.valuePath,
23551
- widgetMeta: this.widgetMeta,
23552
- itemRegion: this.itemRegion ? this.itemRegion.toJSON() : void 0
23603
+ widgetMeta: this.widgetMeta
23553
23604
  };
23554
23605
  }
23555
- /**
23556
- * 从 JSON 对象还原
23557
- */
23558
23606
  static fromJSON(json, table) {
23559
- const region = new CheckTableRegion({
23607
+ return new RepeatingRegion({
23560
23608
  table,
23561
23609
  id: json.id,
23562
23610
  start: json.start,
@@ -23565,52 +23613,10 @@ class CheckTableRegion extends Region {
23565
23613
  valuePath: json.valuePath,
23566
23614
  widgetMeta: json.widgetMeta
23567
23615
  });
23568
- if (json.itemRegion) {
23569
- region.itemRegion = new DataGroup2DRegion({
23570
- table,
23571
- start: json.itemRegion?.start,
23572
- end: json.itemRegion?.end,
23573
- parent: region
23574
- });
23575
- }
23576
- return region;
23577
- }
23578
- setItemRegion(options) {
23579
- const region = new DataGroup2DRegion({
23580
- table: this.table,
23581
- parent: this,
23582
- ...options
23583
- });
23584
- this.itemRegion = region;
23585
- this.table.forEachCell({
23586
- startRowIdx: options.start.row,
23587
- startColIdx: options.start.col,
23588
- endRowIdx: options.end.row,
23589
- endColIdx: options.end.col,
23590
- callback: (cell) => {
23591
- cell.dataGroup2DId = region.id;
23592
- }
23593
- });
23594
- return region;
23595
- }
23596
- removeItemRegion() {
23597
- if (this.itemRegion) {
23598
- this.table.forEachCell({
23599
- startRowIdx: this.itemRegion.start.row,
23600
- startColIdx: this.itemRegion.start.col,
23601
- endRowIdx: this.itemRegion.end.row,
23602
- endColIdx: this.itemRegion.end.col,
23603
- callback: (cell) => {
23604
- cell.clearFieldRuns();
23605
- cell.dataGroup2DId = void 0;
23606
- }
23607
- });
23608
- }
23609
- this.itemRegion = void 0;
23610
23616
  }
23611
23617
  }
23612
- class DataGroup2DRegion extends Region {
23613
- type = "dataGroup2D";
23618
+ class BoundedItemRegion extends Region {
23619
+ type = "boundedItem";
23614
23620
  parent;
23615
23621
  constructor(options) {
23616
23622
  super(options);
@@ -23622,8 +23628,31 @@ class DataGroup2DRegion extends Region {
23622
23628
  this.parent.removeItemRegion();
23623
23629
  }
23624
23630
  }
23625
- class _2DTableRegion extends Region {
23626
- type = "2d-table";
23631
+ function markSubTableItemCells(table, bounds, itemType, regionId) {
23632
+ table.forEachCell({
23633
+ startRowIdx: bounds.start.row,
23634
+ startColIdx: bounds.start.col,
23635
+ endRowIdx: bounds.end.row,
23636
+ endColIdx: bounds.end.col,
23637
+ callback: (cell) => {
23638
+ cell.setSubTableItem(itemType, regionId);
23639
+ }
23640
+ });
23641
+ }
23642
+ function clearSubTableItemCells(table, itemRegion) {
23643
+ table.forEachCell({
23644
+ startRowIdx: itemRegion.start.row,
23645
+ startColIdx: itemRegion.start.col,
23646
+ endRowIdx: itemRegion.end.row,
23647
+ endColIdx: itemRegion.end.col,
23648
+ callback: (cell) => {
23649
+ cell.clearFieldRuns();
23650
+ cell.clearSubTableItem();
23651
+ }
23652
+ });
23653
+ }
23654
+ class BoundedRegion extends Region {
23655
+ type = "bounded";
23627
23656
  name;
23628
23657
  valuePath;
23629
23658
  widgetMeta;
@@ -23635,15 +23664,11 @@ class _2DTableRegion extends Region {
23635
23664
  this.widgetMeta = options.widgetMeta || {
23636
23665
  props: {
23637
23666
  autoFill: true,
23638
- refColField: void 0,
23639
- refRowField: void 0
23667
+ fillDirection: "x"
23640
23668
  }
23641
23669
  };
23642
23670
  this.itemRegion = options.itemRegion;
23643
23671
  }
23644
- /**
23645
- * 序列化为 JSON 对象
23646
- */
23647
23672
  toJSON() {
23648
23673
  return {
23649
23674
  ...super.toJSON(),
@@ -23653,11 +23678,8 @@ class _2DTableRegion extends Region {
23653
23678
  itemRegion: this.itemRegion ? this.itemRegion.toJSON() : void 0
23654
23679
  };
23655
23680
  }
23656
- /**
23657
- * 从 JSON 对象还原
23658
- */
23659
23681
  static fromJSON(json, table) {
23660
- const region = new _2DTableRegion({
23682
+ const region = new BoundedRegion({
23661
23683
  table,
23662
23684
  id: json.id,
23663
23685
  start: json.start,
@@ -23667,7 +23689,7 @@ class _2DTableRegion extends Region {
23667
23689
  widgetMeta: json.widgetMeta
23668
23690
  });
23669
23691
  if (json.itemRegion) {
23670
- region.itemRegion = new DataGroup2DRegion({
23692
+ region.itemRegion = new BoundedItemRegion({
23671
23693
  table,
23672
23694
  start: json.itemRegion?.start,
23673
23695
  end: json.itemRegion?.end,
@@ -23677,41 +23699,24 @@ class _2DTableRegion extends Region {
23677
23699
  return region;
23678
23700
  }
23679
23701
  setItemRegion(options) {
23680
- const region = new DataGroup2DRegion({
23702
+ const region = new BoundedItemRegion({
23681
23703
  table: this.table,
23682
23704
  parent: this,
23683
23705
  ...options
23684
23706
  });
23685
23707
  this.itemRegion = region;
23686
- this.table.forEachCell({
23687
- startRowIdx: options.start.row,
23688
- startColIdx: options.start.col,
23689
- endRowIdx: options.end.row,
23690
- endColIdx: options.end.col,
23691
- callback: (cell) => {
23692
- cell.dataGroup2DId = region.id;
23693
- }
23694
- });
23708
+ markSubTableItemCells(this.table, options, "bounded-item", region.id);
23695
23709
  return region;
23696
23710
  }
23697
23711
  removeItemRegion() {
23698
23712
  if (this.itemRegion) {
23699
- this.table.forEachCell({
23700
- startRowIdx: this.itemRegion.start.row,
23701
- startColIdx: this.itemRegion.start.col,
23702
- endRowIdx: this.itemRegion.end.row,
23703
- endColIdx: this.itemRegion.end.col,
23704
- callback: (cell) => {
23705
- cell.clearFieldRuns();
23706
- cell.dataGroup2DId = void 0;
23707
- }
23708
- });
23713
+ clearSubTableItemCells(this.table, this.itemRegion);
23709
23714
  }
23710
23715
  this.itemRegion = void 0;
23711
23716
  }
23712
23717
  }
23713
- class BoundedItemRegion extends Region {
23714
- type = "boundedItem";
23718
+ class DataGroup2DRegion extends Region {
23719
+ type = "dataGroup2D";
23715
23720
  parent;
23716
23721
  constructor(options) {
23717
23722
  super(options);
@@ -23723,8 +23728,7 @@ class BoundedItemRegion extends Region {
23723
23728
  this.parent.removeItemRegion();
23724
23729
  }
23725
23730
  }
23726
- class BoundedRegion extends Region {
23727
- type = "bounded";
23731
+ class LinkSubTableRegion extends Region {
23728
23732
  name;
23729
23733
  valuePath;
23730
23734
  widgetMeta;
@@ -23736,15 +23740,26 @@ class BoundedRegion extends Region {
23736
23740
  this.widgetMeta = options.widgetMeta || {
23737
23741
  props: {
23738
23742
  autoFill: true,
23739
- fillDirection: "x"
23743
+ refColField: void 0,
23744
+ refRowField: void 0
23740
23745
  }
23741
23746
  };
23742
23747
  this.itemRegion = options.itemRegion;
23743
23748
  }
23744
- /**
23745
- * 序列化为 JSON 对象
23746
- */
23747
- toJSON() {
23749
+ get subFieldKey() {
23750
+ const parsed = parseValuePath(this.valuePath);
23751
+ return parsed.isLink ? parsed.parentFieldKey ?? "" : parsed.fieldKey;
23752
+ }
23753
+ get linkFieldKey() {
23754
+ return parseValuePath(this.valuePath).linkFieldKey ?? "";
23755
+ }
23756
+ get subValuePath() {
23757
+ return this.subFieldKey ? `$.${this.subFieldKey}` : "";
23758
+ }
23759
+ get linkValuePath() {
23760
+ return this.linkFieldKey ? `$.${this.linkFieldKey}` : "";
23761
+ }
23762
+ toLinkSubTableJSON() {
23748
23763
  return {
23749
23764
  ...super.toJSON(),
23750
23765
  name: this.name,
@@ -23753,11 +23768,19 @@ class BoundedRegion extends Region {
23753
23768
  itemRegion: this.itemRegion ? this.itemRegion.toJSON() : void 0
23754
23769
  };
23755
23770
  }
23756
- /**
23757
- * JSON 对象还原
23758
- */
23759
- static fromJSON(json, table) {
23760
- const region = new BoundedRegion({
23771
+ static restoreItemRegion(region, json, table) {
23772
+ if (json.itemRegion) {
23773
+ region.itemRegion = new DataGroup2DRegion({
23774
+ table,
23775
+ start: json.itemRegion?.start,
23776
+ end: json.itemRegion?.end,
23777
+ parent: region
23778
+ });
23779
+ }
23780
+ }
23781
+ /** 从 JSON 还原关联子表(二维表 / 检验表子类共用) */
23782
+ static fromLinkSubTableJSON(Ctor, json, table) {
23783
+ const region = new Ctor({
23761
23784
  table,
23762
23785
  id: json.id,
23763
23786
  start: json.start,
@@ -23766,103 +23789,42 @@ class BoundedRegion extends Region {
23766
23789
  valuePath: json.valuePath,
23767
23790
  widgetMeta: json.widgetMeta
23768
23791
  });
23769
- if (json.itemRegion) {
23770
- region.itemRegion = new BoundedItemRegion({
23771
- table,
23772
- start: json.itemRegion?.start,
23773
- end: json.itemRegion?.end,
23774
- parent: region
23775
- });
23776
- }
23792
+ LinkSubTableRegion.restoreItemRegion(region, json, table);
23777
23793
  return region;
23778
23794
  }
23779
23795
  setItemRegion(options) {
23780
- const region = new BoundedItemRegion({
23796
+ const region = new DataGroup2DRegion({
23781
23797
  table: this.table,
23782
23798
  parent: this,
23783
23799
  ...options
23784
23800
  });
23785
23801
  this.itemRegion = region;
23786
- this.table.forEachCell({
23787
- startRowIdx: options.start.row,
23788
- startColIdx: options.start.col,
23789
- endRowIdx: options.end.row,
23790
- endColIdx: options.end.col,
23791
- callback: (cell) => {
23792
- cell.boundedItemId = region.id;
23793
- }
23794
- });
23802
+ markSubTableItemCells(this.table, options, "data-group-2d", region.id);
23795
23803
  return region;
23796
23804
  }
23797
23805
  removeItemRegion() {
23798
23806
  if (this.itemRegion) {
23799
- this.table.forEachCell({
23800
- startRowIdx: this.itemRegion.start.row,
23801
- startColIdx: this.itemRegion.start.col,
23802
- endRowIdx: this.itemRegion.end.row,
23803
- endColIdx: this.itemRegion.end.col,
23804
- callback: (cell) => {
23805
- cell.clearFieldRuns();
23806
- cell.boundedItemId = void 0;
23807
- }
23808
- });
23807
+ clearSubTableItemCells(this.table, this.itemRegion);
23809
23808
  }
23810
23809
  this.itemRegion = void 0;
23811
23810
  }
23812
23811
  }
23813
- class TableHeaderRegion extends Region {
23814
- type = "table-header";
23815
- name = "";
23816
- constructor(options) {
23817
- super(options);
23818
- this.name = options.name;
23819
- }
23812
+ class _2DTableRegion extends LinkSubTableRegion {
23813
+ type = "2d-table";
23820
23814
  toJSON() {
23821
- return {
23822
- ...super.toJSON(),
23823
- name: this.name
23824
- };
23815
+ return this.toLinkSubTableJSON();
23825
23816
  }
23826
23817
  static fromJSON(json, table) {
23827
- const region = new TableHeaderRegion({
23828
- table,
23829
- id: json.id,
23830
- start: json.start,
23831
- end: json.end,
23832
- name: json.name
23833
- });
23834
- return region;
23818
+ return LinkSubTableRegion.fromLinkSubTableJSON(_2DTableRegion, json, table);
23835
23819
  }
23836
23820
  }
23837
- class SubTableHeaderRegion extends Region {
23838
- type = "sub-table-header";
23839
- name = "";
23840
- subTableId;
23841
- constructor(options) {
23842
- super(options);
23843
- this.name = options.name;
23844
- this.subTableId = options.subTableId;
23845
- }
23846
- /**
23847
- * 序列化为 JSON 对象
23848
- */
23821
+ class CheckTableRegion extends LinkSubTableRegion {
23822
+ type = "check-table";
23849
23823
  toJSON() {
23850
- return {
23851
- ...super.toJSON(),
23852
- name: this.name,
23853
- subTableId: this.subTableId
23854
- };
23824
+ return this.toLinkSubTableJSON();
23855
23825
  }
23856
23826
  static fromJSON(json, table) {
23857
- const region = new SubTableHeaderRegion({
23858
- table,
23859
- id: json.id,
23860
- start: json.start,
23861
- end: json.end,
23862
- name: json.name,
23863
- subTableId: json.subTableId
23864
- });
23865
- return region;
23827
+ return LinkSubTableRegion.fromLinkSubTableJSON(CheckTableRegion, json, table);
23866
23828
  }
23867
23829
  }
23868
23830
  const TABLE_TEMPLATE = {
@@ -24269,7 +24231,7 @@ class WtblRowColumnOps {
24269
24231
  WTC_REF_KEYS.forEach((key) => {
24270
24232
  const refValue = refCell[key];
24271
24233
  if (!refValue) return;
24272
- if (nextRefCell && nextRefCell[key] !== refValue) return;
24234
+ if (nextRefCell && JSON.stringify(nextRefCell[key]) !== JSON.stringify(refValue)) return;
24273
24235
  newCell[key] = refValue;
24274
24236
  });
24275
24237
  }
@@ -24531,27 +24493,25 @@ class WtblCellIterator {
24531
24493
  }
24532
24494
  class WtblRegionManager {
24533
24495
  /**
24534
- * 根据 region id 查找对应的 region
24496
+ * id 查找 region
24535
24497
  */
24536
24498
  static findRegionById(table, regionId) {
24537
24499
  return table.regions.find((r) => r.id === regionId);
24538
24500
  }
24539
- static findCrossRegion(table, options) {
24540
- const { start, end } = options;
24541
- const crossRegion = table.regions.find((r) => {
24542
- return !(r.end.row < start.row || r.start.row > end.row || r.end.col < start.col || r.start.col > end.col);
24543
- });
24544
- return crossRegion;
24501
+ /**
24502
+ * 查找与给定矩形范围相交的第一个 region(含边界接触)
24503
+ */
24504
+ static findCrossRegion(table, bounds) {
24505
+ return table.regions.find((r) => this.regionsIntersect(r, bounds));
24545
24506
  }
24546
- static findCrossRegions(table, options) {
24547
- const { start, end } = options;
24548
- const crossRegions = table.regions.filter((r) => {
24549
- return !(r.end.row < start.row || r.start.row > end.row || r.end.col < start.col || r.start.col > end.col);
24550
- });
24551
- return crossRegions;
24507
+ /**
24508
+ * 查找与给定矩形范围相交的全部 region
24509
+ */
24510
+ static findCrossRegions(table, bounds) {
24511
+ return table.regions.filter((r) => this.regionsIntersect(r, bounds));
24552
24512
  }
24553
24513
  /**
24554
- * 根据 region id 删除对应的 region
24514
+ * id 删除 region,并清除其覆盖范围内单元格上的关联标记
24555
24515
  */
24556
24516
  static deleteRegionById(table, regionId) {
24557
24517
  const regionIndex = table.regions.findIndex((r) => r.id === regionId);
@@ -24559,154 +24519,348 @@ class WtblRegionManager {
24559
24519
  const region = table.regions[regionIndex];
24560
24520
  if (!region) return;
24561
24521
  table.regions.splice(regionIndex, 1);
24562
- const { type: regionType, start, end } = region;
24563
- const isRepeating = regionType === "repeating";
24564
- const is2DTable = regionType === "2d-table";
24565
- const isBounded = regionType === "bounded";
24566
- const isCheckTable = regionType === "check-table";
24567
- const isThead = ["table-header", "sub-table-header"].includes(regionType);
24568
- WtblCellIterator.forEachCell(table, {
24569
- startRowIdx: start.row,
24570
- startColIdx: start.col,
24571
- endRowIdx: end.row,
24572
- endColIdx: end.col,
24573
- callback: (cell) => {
24574
- if (isRepeating) {
24575
- cell.clearFieldRuns();
24576
- cell.repeatingId = void 0;
24577
- cell.dataGroup2DId = void 0;
24578
- } else if (is2DTable) {
24579
- cell.clearFieldRuns();
24580
- cell._2DTableId = void 0;
24581
- cell.dataGroup2DId = void 0;
24582
- } else if (isBounded) {
24583
- cell.clearFieldRuns();
24584
- cell.boundedId = void 0;
24585
- cell.boundedItemId = void 0;
24586
- } else if (isCheckTable) {
24587
- cell.clearFieldRuns();
24588
- cell.checkTableId = void 0;
24589
- cell.dataGroup2DId = void 0;
24590
- } else if (isThead) {
24591
- cell.headerId = void 0;
24592
- }
24593
- }
24522
+ this.forEachCellInRegion(table, region, (cell) => {
24523
+ this.clearCellRegionMarks(cell, region);
24594
24524
  });
24595
24525
  }
24596
24526
  /**
24597
- * 设置重复区域
24527
+ * 设置重复区域(子表体)
24598
24528
  */
24599
24529
  static setRepeating(table, options) {
24600
- const region = new RepeatingRegion({
24601
- ...options,
24602
- table
24603
- });
24604
- table.regions.push(region);
24605
- WtblCellIterator.forEachCell(table, {
24606
- startRowIdx: options.start.row,
24607
- startColIdx: options.start.col,
24608
- endRowIdx: options.end.row,
24609
- endColIdx: options.end.col,
24610
- callback: (cell) => {
24611
- cell.repeatingId = region.id;
24612
- }
24530
+ const region = new RepeatingRegion({ ...options, table });
24531
+ return this.registerRegion(table, region, options, (cell) => {
24532
+ cell.setSubTable("repeating", region.id);
24613
24533
  });
24614
- return region;
24615
24534
  }
24616
24535
  /**
24617
- * 设置二维表
24536
+ * 设置二维表区域
24618
24537
  */
24619
24538
  static set2DTable(table, options) {
24620
- const region = new _2DTableRegion({
24621
- ...options,
24622
- table
24623
- });
24624
- table.regions.push(region);
24625
- WtblCellIterator.forEachCell(table, {
24626
- startRowIdx: options.start.row,
24627
- startColIdx: options.start.col,
24628
- endRowIdx: options.end.row,
24629
- endColIdx: options.end.col,
24630
- callback: (cell) => {
24631
- cell._2DTableId = region.id;
24632
- }
24539
+ const region = new _2DTableRegion({ ...options, table });
24540
+ return this.registerRegion(table, region, options, (cell) => {
24541
+ cell.setSubTable("2d-table", region.id);
24633
24542
  });
24634
- return region;
24635
24543
  }
24636
24544
  /**
24637
- * 设置有界区域
24545
+ * 设置有界区域(子表体)
24638
24546
  */
24639
24547
  static setBounded(table, options) {
24640
- const region = new BoundedRegion({
24641
- ...options,
24642
- table
24548
+ const region = new BoundedRegion({ ...options, table });
24549
+ return this.registerRegion(table, region, options, (cell) => {
24550
+ cell.setSubTable("bounded", region.id);
24643
24551
  });
24644
- table.regions.push(region);
24645
- WtblCellIterator.forEachCell(table, {
24646
- startRowIdx: options.start.row,
24647
- startColIdx: options.start.col,
24648
- endRowIdx: options.end.row,
24649
- endColIdx: options.end.col,
24650
- callback: (cell) => {
24651
- cell.boundedId = region.id;
24652
- }
24653
- });
24654
- return region;
24655
24552
  }
24656
24553
  /**
24657
- * 设置检验表
24554
+ * 设置检验表区域
24658
24555
  */
24659
24556
  static setCheckTable(table, options) {
24660
- const region = new CheckTableRegion({
24661
- ...options,
24662
- table
24663
- });
24664
- table.regions.push(region);
24665
- WtblCellIterator.forEachCell(table, {
24666
- startRowIdx: options.start.row,
24667
- startColIdx: options.start.col,
24668
- endRowIdx: options.end.row,
24669
- endColIdx: options.end.col,
24670
- callback: (cell) => {
24671
- cell.checkTableId = region.id;
24672
- }
24557
+ const region = new CheckTableRegion({ ...options, table });
24558
+ return this.registerRegion(table, region, options, (cell) => {
24559
+ cell.setSubTable("check-table", region.id);
24673
24560
  });
24674
- return region;
24675
24561
  }
24562
+ /**
24563
+ * 设置表头区域(主表表头)
24564
+ */
24676
24565
  static setTableHeader(table, options) {
24677
- const region = new TableHeaderRegion({
24678
- ...options,
24679
- table
24566
+ const region = new TableHeaderRegion({ ...options, table });
24567
+ return this.registerRegion(table, region, options, (cell) => {
24568
+ cell.setHeaderRef("table-header", region.id);
24680
24569
  });
24681
- table.regions.push(region);
24682
- WtblCellIterator.forEachCell(table, {
24683
- startRowIdx: options.start.row,
24684
- startColIdx: options.start.col,
24685
- endRowIdx: options.end.row,
24686
- endColIdx: options.end.col,
24687
- callback: (cell) => {
24688
- cell.headerId = region.id;
24689
- }
24690
- });
24691
- return region;
24692
24570
  }
24571
+ /**
24572
+ * 设置子表表头区域
24573
+ */
24693
24574
  static setSubTableHeader(table, options) {
24694
- const region = new SubTableHeaderRegion({
24695
- ...options,
24696
- table
24575
+ const region = new SubTableHeaderRegion({ ...options, table });
24576
+ return this.registerRegion(table, region, options, (cell) => {
24577
+ cell.setHeaderRef("sub-table-header", region.id);
24697
24578
  });
24698
- table.regions.push(region);
24579
+ }
24580
+ /**
24581
+ * 判断两个矩形区域是否相交(含边界恰好相贴的情况)
24582
+ */
24583
+ static regionsIntersect(a, b2) {
24584
+ return !(a.end.row < b2.start.row || a.start.row > b2.end.row || a.end.col < b2.start.col || a.start.col > b2.end.col);
24585
+ }
24586
+ /**
24587
+ * 遍历 region 覆盖范围内的所有单元格
24588
+ */
24589
+ static forEachCellInRegion(table, bounds, callback) {
24590
+ const { start, end } = bounds;
24699
24591
  WtblCellIterator.forEachCell(table, {
24700
- startRowIdx: options.start.row,
24701
- startColIdx: options.start.col,
24702
- endRowIdx: options.end.row,
24703
- endColIdx: options.end.col,
24704
- callback: (cell) => {
24705
- cell.headerId = region.id;
24706
- }
24592
+ startRowIdx: start.row,
24593
+ startColIdx: start.col,
24594
+ endRowIdx: end.row,
24595
+ endColIdx: end.col,
24596
+ callback: (cell) => callback(cell)
24707
24597
  });
24598
+ }
24599
+ /**
24600
+ * 将 region 加入 table.regions,并同步标记覆盖范围内的单元格
24601
+ */
24602
+ static registerRegion(table, region, bounds, markCell) {
24603
+ table.regions.push(region);
24604
+ this.forEachCellInRegion(table, bounds, markCell);
24708
24605
  return region;
24709
24606
  }
24607
+ /**
24608
+ * 删除 region 时,按类型清除单元格上的关联数据
24609
+ *
24610
+ * - 子表类:清除字段 runs + 子表 / 子表项引用
24611
+ * - 表头类:清除字段 runs + 表头引用
24612
+ * - 其他:仅清除对应 region 的引用
24613
+ */
24614
+ static clearCellRegionMarks(cell, region) {
24615
+ const regionId = region.id;
24616
+ switch (region.type) {
24617
+ case "repeating":
24618
+ case "2d-table":
24619
+ case "bounded":
24620
+ case "check-table":
24621
+ cell.clearFieldRuns();
24622
+ cell.clearSubTable();
24623
+ cell.clearSubTableItem();
24624
+ break;
24625
+ case "table-header":
24626
+ case "sub-table-header":
24627
+ cell.clearFieldRuns();
24628
+ cell.clearHeaderRef();
24629
+ break;
24630
+ default:
24631
+ cell.clearRegionRef(regionId);
24632
+ }
24633
+ }
24634
+ }
24635
+ const OUTLINE_BORDER_INSET = 1;
24636
+ const borderConfig = {
24637
+ outer: {
24638
+ color: "rgb(128, 128, 128)",
24639
+ width: 1
24640
+ },
24641
+ inner: {
24642
+ color: "rgb(128, 128, 128)",
24643
+ width: 1
24644
+ },
24645
+ guide: {
24646
+ color: "#026AC8",
24647
+ width: 2
24648
+ }
24649
+ };
24650
+ const subThemeConfig = {
24651
+ "fixed-table": {
24652
+ label: "固定表",
24653
+ color: "#309C41",
24654
+ background: "rgba(48,156,65,0.1)",
24655
+ labelBjColor: "rgba(48,156,65,0.8)"
24656
+ },
24657
+ "check-table": {
24658
+ label: "检验表",
24659
+ color: "#309C41",
24660
+ background: "rgba(48,156,65,0.1)",
24661
+ labelBjColor: "rgba(48,156,65,0.8)"
24662
+ },
24663
+ "dynamic-table": {
24664
+ label: "动态表",
24665
+ color: "#026AC8",
24666
+ background: "rgba(2,106,200,0.1)",
24667
+ labelBjColor: "rgba(2,106,200,0.8)"
24668
+ },
24669
+ "2d-table": {
24670
+ label: "二维表",
24671
+ color: "#026AC8",
24672
+ background: "rgba(2,106,200,0.1)",
24673
+ labelBjColor: "rgba(2,106,200,0.8)"
24674
+ },
24675
+ "table-header": {
24676
+ label: "表头",
24677
+ color: "rgba(245, 69, 71, 1)",
24678
+ background: "rgba(245, 69, 71, 0.1)",
24679
+ labelBjColor: "rgba(245, 69, 71, 0.8)"
24680
+ },
24681
+ "data-group": {
24682
+ label: "数据分组",
24683
+ color: "#F77E4A",
24684
+ background: "rgba(247,126,74,0.1)",
24685
+ labelBjColor: "rgba(247,126,74,0.8)"
24686
+ },
24687
+ "data-group-2d": {
24688
+ label: "动态关联",
24689
+ color: "#F77E4A",
24690
+ background: "rgba(247,126,74,0.1)",
24691
+ labelBjColor: "rgba(247,126,74,0.8)"
24692
+ }
24693
+ };
24694
+ const getStyleByType = (type4) => {
24695
+ const config = subThemeConfig[type4];
24696
+ return {
24697
+ strokeColor: config?.color || "#000",
24698
+ backgroundColor: config?.background || "transparent",
24699
+ label: config?.label || "",
24700
+ labelBjColor: config?.labelBjColor || "#666"
24701
+ };
24702
+ };
24703
+ const EPS = 1e-3;
24704
+ function clipHLineByMerges(line, merges) {
24705
+ let segments = [line];
24706
+ merges.forEach((rect) => {
24707
+ segments = segments.flatMap((seg) => {
24708
+ const insideY = seg.y > rect.y + EPS && seg.y < rect.y + rect.height - EPS;
24709
+ if (!insideY) return [seg];
24710
+ if (seg.x2 <= rect.x + EPS || seg.x1 >= rect.x + rect.width - EPS) return [seg];
24711
+ if (rect.x <= seg.x1 + EPS && rect.x + rect.width >= seg.x2 - EPS) return [];
24712
+ const res = [];
24713
+ if (seg.x1 < rect.x - EPS) res.push({ ...seg, x2: rect.x });
24714
+ if (seg.x2 > rect.x + rect.width + EPS) res.push({ ...seg, x1: rect.x + rect.width });
24715
+ return res;
24716
+ });
24717
+ });
24718
+ return segments;
24719
+ }
24720
+ function clipVLineByMerges(line, merges) {
24721
+ let segments = [line];
24722
+ merges.forEach((rect) => {
24723
+ segments = segments.flatMap((seg) => {
24724
+ const insideX = seg.x > rect.x + EPS && seg.x < rect.x + rect.width - EPS;
24725
+ if (!insideX) return [seg];
24726
+ if (seg.y2 <= rect.y + EPS || seg.y1 >= rect.y + rect.height - EPS) return [seg];
24727
+ if (rect.y <= seg.y1 + EPS && rect.y + rect.height >= seg.y2 - EPS) return [];
24728
+ const res = [];
24729
+ if (seg.y1 < rect.y - EPS) res.push({ ...seg, y2: rect.y });
24730
+ if (seg.y2 > rect.y + rect.height + EPS) res.push({ ...seg, y1: rect.y + rect.height });
24731
+ return res;
24732
+ });
24733
+ });
24734
+ return segments;
24735
+ }
24736
+ function createTableOutlineLayer(options) {
24737
+ const { cells, inset = 1 } = options;
24738
+ if (!cells.length) return { backgroundRect: null, hLines: [], vLines: [], labelPos: void 0 };
24739
+ const minX = Math.min(...cells.map((c2) => c2.x));
24740
+ const minY = Math.min(...cells.map((c2) => c2.y));
24741
+ const maxX = Math.max(...cells.map((c2) => c2.x + c2.width));
24742
+ const maxY = Math.max(...cells.map((c2) => c2.y + c2.height));
24743
+ const minLY = Math.min(...cells.map((c2) => c2.layoutY));
24744
+ const maxLX = Math.max(...cells.map((c2) => c2.layoutX + c2.width));
24745
+ const maxLY = Math.max(...cells.map((c2) => c2.layoutY + c2.height));
24746
+ const backgroundRect = {
24747
+ x: minX + inset,
24748
+ y: minY + inset,
24749
+ width: maxX - minX - inset * 2,
24750
+ height: maxY - minY - inset * 2
24751
+ };
24752
+ const hLines = [
24753
+ { x1: minX + inset, x2: maxX - inset, y: minY + inset },
24754
+ // top
24755
+ { x1: minX + inset, x2: maxX - inset, y: maxY - inset }
24756
+ // bottom
24757
+ ];
24758
+ const vLines = [
24759
+ { x: minX + inset, y1: minY + inset, y2: maxY - inset },
24760
+ // left
24761
+ { x: maxX - inset, y1: minY + inset, y2: maxY - inset }
24762
+ // right
24763
+ ];
24764
+ const labelPos = { x: maxLX - inset, y1: minLY + inset, y2: maxLY - inset };
24765
+ return { backgroundRect, hLines, vLines, labelPos };
24766
+ }
24767
+ const accumulate = (list) => {
24768
+ const result = [0];
24769
+ let acc = 0;
24770
+ for (const n of list) {
24771
+ acc += n;
24772
+ result.push(acc);
24773
+ }
24774
+ return result;
24775
+ };
24776
+ const inRange = (n, min, max) => n > min && n < max;
24777
+ function mapCellsToOutlineCells(cells) {
24778
+ return cells.map((c2) => ({
24779
+ x: c2.x,
24780
+ y: c2.rowY,
24781
+ layoutX: c2.layoutX,
24782
+ layoutY: c2.layoutY,
24783
+ width: c2.width,
24784
+ height: c2.height
24785
+ }));
24786
+ }
24787
+ function groupBy(list, getKey) {
24788
+ return list.reduce((acc, item) => {
24789
+ const key = getKey(item);
24790
+ (acc[key] ||= []).push(item);
24791
+ return acc;
24792
+ }, {});
24793
+ }
24794
+ function buildPosMap(layers, getRect, toDom) {
24795
+ const res = {};
24796
+ for (const [id, layer] of Object.entries(layers)) {
24797
+ const rect = getRect(layer);
24798
+ if (!rect) continue;
24799
+ const pos = toDom(rect);
24800
+ if (pos) res[id] = pos;
24801
+ }
24802
+ return res;
24803
+ }
24804
+ const getIsDataGroup2DTable = (type4) => {
24805
+ if (!type4) return false;
24806
+ return ["2d-table", "check-table"].includes(type4);
24807
+ };
24808
+ const getIs2DCellInSubTable = (cellZone) => {
24809
+ if (!cellZone) return false;
24810
+ return ["cross", "horizontal"].includes(cellZone);
24811
+ };
24812
+ function getDataIndexLayersMap({
24813
+ type: type4,
24814
+ cells,
24815
+ isDesign,
24816
+ convertExtraProps
24817
+ }) {
24818
+ const getDataIndex = (cell) => {
24819
+ return getIsDataGroup2DTable(type4) && isDesign ? cell.subRenderer?.xDataIndex : cell.subRenderer?.dataIndex;
24820
+ };
24821
+ const getAllDataIndex = (cell) => {
24822
+ const { dataIndex, xDataIndex, yDataIndex } = cell?.subRenderer || {};
24823
+ return dataIndex ?? xDataIndex ?? yDataIndex;
24824
+ };
24825
+ const _cells = cells.filter(
24826
+ (cell) => isNumber(getAllDataIndex(cell)) && cell?.subRenderer?.type === type4
24827
+ );
24828
+ if (!_cells.length) return {};
24829
+ const grouped = groupBy(
24830
+ _cells,
24831
+ (cell) => `${cell.subRenderer.id}_dataIndex${getDataIndex(cell)}`
24832
+ );
24833
+ const layersMapEntries = Object.entries(grouped).map(([id, __cells]) => {
24834
+ const firstCell = __cells[0];
24835
+ const isFirstGroup = getDataIndex(firstCell) === 0;
24836
+ const lastCell = __cells.filter((c2) => {
24837
+ if (isDesign) {
24838
+ return true;
24839
+ } else {
24840
+ const { type: type22, cellZone } = c2.subRenderer || {};
24841
+ return getIsDataGroup2DTable(type22) ? getIs2DCellInSubTable(cellZone) : true;
24842
+ }
24843
+ }).at(-1);
24844
+ const bgLayer = createTableOutlineLayer({
24845
+ cells: mapCellsToOutlineCells(__cells),
24846
+ inset: 4
24847
+ });
24848
+ const borderLayer = isFirstGroup ? createTableOutlineLayer({
24849
+ cells: mapCellsToOutlineCells(__cells),
24850
+ inset: OUTLINE_BORDER_INSET
24851
+ }) : { hLines: [], vLines: [], backgroundRect: null, labelPos: void 0 };
24852
+ return [
24853
+ id,
24854
+ {
24855
+ ...borderLayer,
24856
+ ...convertExtraProps(firstCell),
24857
+ showBorder: isFirstGroup,
24858
+ placeholderBjRect: bgLayer.backgroundRect,
24859
+ lastCell
24860
+ }
24861
+ ];
24862
+ });
24863
+ return Object.fromEntries(layersMapEntries);
24710
24864
  }
24711
24865
  class CellCollector {
24712
24866
  constructor(table) {
@@ -24744,41 +24898,21 @@ class CellCollector {
24744
24898
  }
24745
24899
  this.mergeGroups.get(cell.mergeId).push(position);
24746
24900
  }
24747
- if (cell.repeatingId) {
24748
- if (!this.repeatingGroups.has(cell.repeatingId)) {
24749
- this.repeatingGroups.set(cell.repeatingId, []);
24750
- }
24751
- this.repeatingGroups.get(cell.repeatingId).push(position);
24752
- }
24753
- if (cell._2DTableId) {
24754
- if (!this._2DTableGroups.has(cell._2DTableId)) {
24755
- this._2DTableGroups.set(cell._2DTableId, []);
24756
- }
24757
- this._2DTableGroups.get(cell._2DTableId).push(position);
24758
- }
24759
- if (cell.boundedId) {
24760
- if (!this.boundedGroups.has(cell.boundedId)) {
24761
- this.boundedGroups.set(cell.boundedId, []);
24762
- }
24763
- this.boundedGroups.get(cell.boundedId).push(position);
24764
- }
24765
- if (cell.boundedItemId) {
24766
- if (!this.boundedItemGroups.has(cell.boundedItemId)) {
24767
- this.boundedItemGroups.set(cell.boundedItemId, []);
24901
+ const body = cell.subTable;
24902
+ if (body) {
24903
+ const map2 = body.type === "repeating" ? this.repeatingGroups : body.type === "2d-table" ? this._2DTableGroups : body.type === "bounded" ? this.boundedGroups : this.checkTableGroups;
24904
+ if (!map2.has(body.regionId)) {
24905
+ map2.set(body.regionId, []);
24768
24906
  }
24769
- this.boundedItemGroups.get(cell.boundedItemId).push(position);
24907
+ map2.get(body.regionId).push(position);
24770
24908
  }
24771
- if (cell.checkTableId) {
24772
- if (!this.checkTableGroups.has(cell.checkTableId)) {
24773
- this.checkTableGroups.set(cell.checkTableId, []);
24909
+ const item = cell.subTableItem;
24910
+ if (item) {
24911
+ const map2 = item.type === "bounded-item" ? this.boundedItemGroups : this.dataGroup2DGroups;
24912
+ if (!map2.has(item.regionId)) {
24913
+ map2.set(item.regionId, []);
24774
24914
  }
24775
- this.checkTableGroups.get(cell.checkTableId).push(position);
24776
- }
24777
- if (cell.dataGroup2DId) {
24778
- if (!this.dataGroup2DGroups.has(cell.dataGroup2DId)) {
24779
- this.dataGroup2DGroups.set(cell.dataGroup2DId, []);
24780
- }
24781
- this.dataGroup2DGroups.get(cell.dataGroup2DId).push(position);
24915
+ map2.get(item.regionId).push(position);
24782
24916
  }
24783
24917
  }
24784
24918
  }
@@ -24956,7 +25090,7 @@ class WtblCalculation {
24956
25090
  if (positions.length === 0) continue;
24957
25091
  const { minRow, maxRow, minCol, maxCol } = calculateGroupBounds(positions);
24958
25092
  const region = table.findRegionById(groupId);
24959
- if (region && ["check-table", "2d-table"].includes(region.type)) {
25093
+ if (region && getIsDataGroup2DTable(region.type)) {
24960
25094
  region.start.row = minRow;
24961
25095
  region.end.row = maxRow;
24962
25096
  region.start.col = minCol;
@@ -31782,7 +31916,7 @@ class DeleteDataGroup2D extends CommandBase {
31782
31916
  return null;
31783
31917
  }
31784
31918
  const subTable = table.findRegionById(regionId);
31785
- if (!subTable || subTable?.type && !["check-table", "2d-table"].includes(subTable.type)) {
31919
+ if (!subTable || !getIsDataGroup2DTable(subTable.type)) {
31786
31920
  console.error(
31787
31921
  `deleteDataGroup2D: region not found with id ${regionId} or region type is not support`
31788
31922
  );
@@ -38092,6 +38226,82 @@ function canSwitchImageFieldToAdaptive(cell, fieldRunId) {
38092
38226
  }
38093
38227
  return !fieldRunId || run.id === fieldRunId;
38094
38228
  }
38229
+ function getLinkSubTableCrossRange(region) {
38230
+ const { itemRegion } = region;
38231
+ if (!itemRegion) return void 0;
38232
+ return {
38233
+ start: {
38234
+ row: Math.max(region.start.row, itemRegion.start.row),
38235
+ col: Math.max(region.start.col, itemRegion.start.col)
38236
+ },
38237
+ end: {
38238
+ row: Math.min(region.end.row, itemRegion.end.row),
38239
+ col: Math.min(region.end.col, itemRegion.end.col)
38240
+ }
38241
+ };
38242
+ }
38243
+ function getDataGroup2DFillEndCol(region, cellDataIndexMap) {
38244
+ const { itemRegion } = region;
38245
+ if (!itemRegion) return region.end.col;
38246
+ let maxCol = itemRegion.end.col;
38247
+ cellDataIndexMap.forEach((meta, key) => {
38248
+ const [rowStr, colStr] = key.split(",");
38249
+ const row = Number(rowStr);
38250
+ const col = Number(colStr);
38251
+ if (row >= itemRegion.start.row && row <= itemRegion.end.row && meta.dataIndex !== void 0) {
38252
+ maxCol = Math.max(maxCol, col);
38253
+ }
38254
+ });
38255
+ return maxCol;
38256
+ }
38257
+ function resolveLinkSubTableCellZone(row, col, region, options = {}) {
38258
+ const { itemRegion } = region;
38259
+ if (!itemRegion) {
38260
+ return region.contains(row, col) ? "horizontal" : void 0;
38261
+ }
38262
+ const cross = getLinkSubTableCrossRange(region);
38263
+ const fillEndCol = options.fillEndCol ?? itemRegion.end.col;
38264
+ const inCrossRows = row >= cross.start.row && row <= cross.end.row;
38265
+ const inItemRows = row >= itemRegion.start.row && row <= itemRegion.end.row;
38266
+ if (inCrossRows && col >= itemRegion.start.col && col <= fillEndCol) {
38267
+ return "cross";
38268
+ }
38269
+ if (!inCrossRows && inItemRows && col >= itemRegion.start.col && col <= fillEndCol) {
38270
+ return "vertical";
38271
+ }
38272
+ if (region.contains(row, col)) {
38273
+ if (col < itemRegion.start.col) {
38274
+ return "horizontal";
38275
+ }
38276
+ if (inCrossRows && col > fillEndCol) {
38277
+ return "horizontal";
38278
+ }
38279
+ }
38280
+ return void 0;
38281
+ }
38282
+ function resolveLinkSubTableValuePath(region, cellZone) {
38283
+ switch (cellZone) {
38284
+ case "cross":
38285
+ return region.valuePath;
38286
+ case "vertical":
38287
+ return region.linkValuePath;
38288
+ case "horizontal":
38289
+ return region.subValuePath;
38290
+ }
38291
+ }
38292
+ function isInLinkSubTableLayoutScope(row, col, region, options = {}) {
38293
+ return resolveLinkSubTableCellZone(row, col, region, options) !== void 0;
38294
+ }
38295
+ const INSERT_FIELD_MSG = {
38296
+ NOT_IN_CELL: "子表字段只能插入表格单元格中",
38297
+ PATH_INCOMPATIBLE: "字段路径与当前区域不兼容,无法插入",
38298
+ NOT_IN_SUBTABLE_REGION: "当前位置不在子表区域内,无法插入该字段",
38299
+ LINK_IN_CROSS: "二维表/检验表关联字段不能拖入交叉区域",
38300
+ SUB_IN_CROSS_PATH: "该字段不能拖入交叉区域",
38301
+ LINK_ONLY_VERTICAL: "请使用动态关联字段拖入纵向关联区域",
38302
+ SUB_ONLY_HORIZONTAL: "请使用子表主体字段拖入横向区域",
38303
+ SUB_IN_2D_EXPANSION: "二维表字段不能拖入交叉区域上方或下方的扩展区域"
38304
+ };
38095
38305
  class InsertField extends CommandBase {
38096
38306
  constructor(doc, payload) {
38097
38307
  super(doc, payload);
@@ -38110,17 +38320,20 @@ class InsertField extends CommandBase {
38110
38320
  handleCollapseText() {
38111
38321
  const cursor = this.doc.cursorManager;
38112
38322
  const { nodeId, offset: offset2, side } = cursor.getCursor();
38113
- const {
38114
- valuePath,
38115
- widgetMeta
38116
- } = this.payload;
38323
+ const { valuePath: draggedValuePath, widgetMeta } = this.payload;
38117
38324
  const mapper = this.doc.layoutMapper;
38118
38325
  const node = mapper.getBaseMetaNodeById(nodeId);
38119
38326
  const run = node.raw;
38120
38327
  const wp = mapper.getModelNodeById(run.parent.modelRef.id);
38121
- const wr = new WrField({ text: valuePath, valuePath, widgetMeta });
38122
- if (!this.validateFieldPath(valuePath, wp)) {
38123
- console.warn("字段路径不合法,无法插入字段", valuePath);
38328
+ const { valuePath, widgetMeta: resolvedMeta } = this.resolveInsertFieldPayload(
38329
+ draggedValuePath,
38330
+ widgetMeta
38331
+ );
38332
+ const wr = new WrField({ text: valuePath, valuePath, widgetMeta: resolvedMeta });
38333
+ const validateError = this.validateFieldPath(valuePath, wp, widgetMeta);
38334
+ if (validateError) {
38335
+ GctMessage.warning(validateError);
38336
+ this.isTerminated = true;
38124
38337
  return null;
38125
38338
  }
38126
38339
  const cell = getAncestorCell(wp);
@@ -38171,8 +38384,17 @@ class InsertField extends CommandBase {
38171
38384
  if (models.length === 0) return null;
38172
38385
  if (mode !== SelectionMode.PP) return null;
38173
38386
  this.clearSelectionContent(models);
38174
- const { valuePath, widgetMeta } = this.payload;
38175
- const wr = new WrField({ text: "*", valuePath, widgetMeta });
38387
+ const { valuePath: draggedValuePath, widgetMeta } = this.payload;
38388
+ const { valuePath, widgetMeta: resolvedMeta } = this.resolveInsertFieldPayload(
38389
+ draggedValuePath,
38390
+ widgetMeta
38391
+ );
38392
+ const validateError = this.validateFieldPath(valuePath, blockFirst, widgetMeta);
38393
+ if (validateError) {
38394
+ GctMessage.warning(validateError);
38395
+ return null;
38396
+ }
38397
+ const wr = new WrField({ text: "*", valuePath, widgetMeta: resolvedMeta });
38176
38398
  const cell = getAncestorCell(blockFirst);
38177
38399
  if (isCellLockedByAdaptiveImage(cell)) {
38178
38400
  GctMessage.warning(ADAPTIVE_IMAGE_CELL_MSG);
@@ -38194,16 +38416,7 @@ class InsertField extends CommandBase {
38194
38416
  };
38195
38417
  }
38196
38418
  isRootField(valuePath) {
38197
- if (valuePath && valuePath.indexOf("[n]") === -1) {
38198
- return true;
38199
- }
38200
- return false;
38201
- }
38202
- isNestedTableField(valuePath) {
38203
- if (valuePath && valuePath.indexOf("[n]") !== -1) {
38204
- return true;
38205
- }
38206
- return false;
38419
+ return parseValuePath(valuePath).isRoot;
38207
38420
  }
38208
38421
  /**
38209
38422
  * 判断两个 valuePath 是否连续(父子关系)
@@ -38220,15 +38433,17 @@ class InsertField extends CommandBase {
38220
38433
  */
38221
38434
  isConsecutivePath(parentPath, childPath) {
38222
38435
  if (!parentPath || !childPath) return false;
38223
- const _parentPath = parentPath.includes(":") ? parentPath.split(":")[0] : parentPath;
38224
- if (!childPath.startsWith(_parentPath)) {
38436
+ if (!childPath.startsWith(parentPath)) {
38225
38437
  return false;
38226
38438
  }
38227
- const remainder = childPath.slice(_parentPath.length);
38439
+ const remainder = childPath.slice(parentPath.length);
38228
38440
  if (remainder === "") {
38229
38441
  return false;
38230
38442
  }
38231
- return remainder.startsWith(".") || remainder.startsWith("[n].");
38443
+ if (remainder.startsWith(":")) {
38444
+ return false;
38445
+ }
38446
+ return remainder.startsWith(".") || remainder.startsWith("[n].") || remainder.startsWith("[");
38232
38447
  }
38233
38448
  /**
38234
38449
  * 判断 childPath 是否可以在 parentPath 的循环区域中使用
@@ -38254,22 +38469,168 @@ class InsertField extends CommandBase {
38254
38469
  const hasLoops = (relativePath.match(/\[n\]/g) || []).length > 0;
38255
38470
  return !!(relativePath && relativePath !== "." && !hasLoops);
38256
38471
  }
38257
- // 获取所在单元格 的 row col
38258
- // 获取所在表格的 子表
38259
- validateFieldPath(valuePath = "", node) {
38260
- if (this.isRootField(valuePath)) return true;
38472
+ getLayoutTableCellFromCursor() {
38473
+ const cursor = this.doc.cursorManager.getCursor();
38474
+ if (!cursor?.nodeId) return void 0;
38475
+ const meta = this.doc.layoutMapper.getBaseMetaNodeById(cursor.nodeId);
38476
+ const tableCellId = meta?.line?.tableCellId;
38477
+ if (!tableCellId) return void 0;
38478
+ return this.doc.layoutMapper.getLayoutNodeById(tableCellId);
38479
+ }
38480
+ getModelCellFromCursor() {
38481
+ const cursor = this.doc.cursorManager.getCursor();
38482
+ if (!cursor?.nodeId) return null;
38483
+ const meta = this.doc.layoutMapper.getBaseMetaNodeById(cursor.nodeId);
38484
+ const run = meta?.raw;
38485
+ const wpId = run?.parent?.modelRef?.id;
38486
+ if (!wpId) return null;
38487
+ const wp = this.doc.layoutMapper.getModelNodeById(wpId);
38488
+ return wp ? getAncestorCell(wp) : null;
38489
+ }
38490
+ /** 二维表/检验表:用当前单元格 subRenderer 分区 valuePath 作为父路径 */
38491
+ getSubTableZoneParentPath() {
38492
+ const sub = this.getLayoutTableCellFromCursor()?.subRenderer;
38493
+ if (sub && getIsDataGroup2DTable(sub.type)) {
38494
+ return sub.valuePath;
38495
+ }
38496
+ return void 0;
38497
+ }
38498
+ resolveInsertFieldPayload(draggedValuePath, widgetMeta) {
38499
+ const layoutSub = this.getLayoutTableCellFromCursor()?.subRenderer;
38500
+ const zoneParentPath = this.getSubTableZoneParentPath();
38501
+ if (!zoneParentPath || !widgetMeta.field) {
38502
+ return { valuePath: draggedValuePath, widgetMeta };
38503
+ }
38504
+ if (layoutSub?.type === "2d-table" || layoutSub?.type === "check-table") {
38505
+ const cell = this.getModelCellFromCursor();
38506
+ const region = cell ? this.getLinkSubTableRegionFromLayout(cell, layoutSub) : void 0;
38507
+ if (region && !this.getDraggedFieldSide(widgetMeta.field, region)) {
38508
+ return { valuePath: draggedValuePath, widgetMeta };
38509
+ }
38510
+ }
38511
+ const fieldLink = widgetMeta.field.fieldLink || getLastSegment(draggedValuePath);
38512
+ const parentKey = getLastSegment(zoneParentPath);
38513
+ const valuePath = generateValuePath(fieldLink, parentKey);
38514
+ return {
38515
+ valuePath,
38516
+ widgetMeta: {
38517
+ ...widgetMeta,
38518
+ field: {
38519
+ ...widgetMeta.field,
38520
+ valuePath,
38521
+ subFieldKey: parentKey
38522
+ }
38523
+ }
38524
+ };
38525
+ }
38526
+ /**
38527
+ * 根据拖拽时 palette 传入的 subFieldKey 判断字段属于关联侧还是二维表/检验表主体侧。
38528
+ * - 仅 linkFieldKey:动态关联 palette(f_ewblink)
38529
+ * - 仅 subFieldKey:横向区 palette(f_ewb)
38530
+ * - sub:link:交叉区 palette 拖入的主体字段(f_ewb:f_ewblink)
38531
+ */
38532
+ getDraggedFieldSide(field, region) {
38533
+ const raw = field?.subFieldKey;
38534
+ if (!raw) return void 0;
38535
+ const parsed = parseValuePath(raw);
38536
+ const subFieldKey = parsed.isLink ? parsed.parentFieldKey ?? "" : parsed.fieldKey;
38537
+ const linkFieldKey = parsed.linkFieldKey ?? "";
38538
+ if (subFieldKey === region.subFieldKey && linkFieldKey === region.linkFieldKey) {
38539
+ return "sub";
38540
+ }
38541
+ if (!linkFieldKey && subFieldKey === region.linkFieldKey) {
38542
+ return "link";
38543
+ }
38544
+ if (!linkFieldKey && subFieldKey === region.subFieldKey) {
38545
+ return "sub";
38546
+ }
38547
+ return void 0;
38548
+ }
38549
+ validateLinkSubTableFieldPath(valuePath, region, field, cell, cellZone) {
38550
+ const fieldSide = this.getDraggedFieldSide(field, region);
38551
+ if (!fieldSide) {
38552
+ return INSERT_FIELD_MSG.PATH_INCOMPATIBLE;
38553
+ }
38554
+ const zoneParentPath = cellZone ? resolveLinkSubTableValuePath(region, cellZone) : fieldSide === "link" ? region.linkValuePath : region.subValuePath;
38555
+ if (!this.isFieldPathCompatible(zoneParentPath, valuePath)) {
38556
+ return INSERT_FIELD_MSG.PATH_INCOMPATIBLE;
38557
+ }
38558
+ const parsed = parseValuePath(valuePath);
38559
+ if (cellZone === "cross") {
38560
+ if (fieldSide === "link") return INSERT_FIELD_MSG.LINK_IN_CROSS;
38561
+ if (!parsed.isLink) return INSERT_FIELD_MSG.SUB_IN_CROSS_PATH;
38562
+ return null;
38563
+ }
38564
+ if (cellZone === "vertical" && fieldSide !== "link") {
38565
+ return INSERT_FIELD_MSG.LINK_ONLY_VERTICAL;
38566
+ }
38567
+ if (cellZone === "horizontal" && fieldSide !== "sub") {
38568
+ return INSERT_FIELD_MSG.SUB_ONLY_HORIZONTAL;
38569
+ }
38570
+ if (region.type === "2d-table" && fieldSide === "sub" && this.isDataGroup2DExpansionCell(cell, region)) {
38571
+ return INSERT_FIELD_MSG.SUB_IN_2D_EXPANSION;
38572
+ }
38573
+ return null;
38574
+ }
38575
+ /** 数据关联区向上/下扩充、超出子表主体行范围的模板行 */
38576
+ isDataGroup2DExpansionCell(cell, region) {
38577
+ const item = region.itemRegion;
38578
+ if (!item) return false;
38579
+ const rowIndex = cell.parent.getCurrentIndex();
38580
+ const inItemRows = rowIndex >= item.start.row && rowIndex <= item.end.row;
38581
+ const inBodyRows = rowIndex >= region.start.row && rowIndex <= region.end.row;
38582
+ return inItemRows && !inBodyRows;
38583
+ }
38584
+ getLinkSubTableRegionFromLayout(cell, sub) {
38585
+ const table = cell.table;
38586
+ if (sub.type === "2d-table") {
38587
+ return table.get2DTableById(sub.id);
38588
+ }
38589
+ if (sub.type === "check-table") {
38590
+ return table.getCheckTableById(sub.id);
38591
+ }
38592
+ return void 0;
38593
+ }
38594
+ /**
38595
+ * 校验字段是否可插入当前位置
38596
+ * @returns 校验通过返回 null,失败返回提示文案
38597
+ */
38598
+ validateFieldPath(valuePath = "", node, widgetMeta) {
38599
+ if (this.isRootField(valuePath)) return null;
38261
38600
  const cell = getAncestorCell(node);
38262
- if (!cell) return false;
38601
+ if (!cell) return INSERT_FIELD_MSG.NOT_IN_CELL;
38602
+ const layoutSub = this.getLayoutTableCellFromCursor()?.subRenderer;
38603
+ if (layoutSub?.type === "2d-table" || layoutSub?.type === "check-table") {
38604
+ const region = this.getLinkSubTableRegionFromLayout(cell, layoutSub);
38605
+ if (!region) return INSERT_FIELD_MSG.NOT_IN_SUBTABLE_REGION;
38606
+ return this.validateLinkSubTableFieldPath(
38607
+ valuePath,
38608
+ region,
38609
+ widgetMeta?.field,
38610
+ cell,
38611
+ layoutSub.cellZone
38612
+ );
38613
+ }
38263
38614
  const table = cell.table;
38264
38615
  const row = cell.parent;
38265
38616
  const regions = table.regions;
38266
38617
  const colIndex = cell.getCurrentIndex();
38267
38618
  const rowIndex = row.getCurrentIndex();
38268
- const targetRegion = regions.find((r) => {
38269
- return r.contains(rowIndex, colIndex);
38270
- });
38271
- if (!targetRegion) return false;
38272
- return this.isFieldPathCompatible(targetRegion.valuePath, valuePath);
38619
+ const targetRegion = regions.find((r) => r.contains(rowIndex, colIndex));
38620
+ if (targetRegion?.type === "2d-table" || targetRegion?.type === "check-table") {
38621
+ return this.validateLinkSubTableFieldPath(
38622
+ valuePath,
38623
+ targetRegion,
38624
+ widgetMeta?.field,
38625
+ cell
38626
+ );
38627
+ }
38628
+ const zoneParentPath = this.getSubTableZoneParentPath();
38629
+ if (zoneParentPath) {
38630
+ return this.isFieldPathCompatible(zoneParentPath, valuePath) ? null : INSERT_FIELD_MSG.PATH_INCOMPATIBLE;
38631
+ }
38632
+ if (!targetRegion) return INSERT_FIELD_MSG.NOT_IN_SUBTABLE_REGION;
38633
+ return this.isFieldPathCompatible(targetRegion.valuePath, valuePath) ? null : INSERT_FIELD_MSG.PATH_INCOMPATIBLE;
38273
38634
  }
38274
38635
  }
38275
38636
  const __vite_glob_0_15$2 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
@@ -39567,7 +39928,7 @@ class SetDataGroup2D extends CommandBase {
39567
39928
  let region;
39568
39929
  cellList.some((cell) => {
39569
39930
  const r = cell.getRegion();
39570
- if (r && ["check-table", "2d-table"].includes(r.type)) {
39931
+ if (r && getIsDataGroup2DTable(r.type)) {
39571
39932
  region = r;
39572
39933
  return true;
39573
39934
  }
@@ -40600,35 +40961,50 @@ class LayoutContext {
40600
40961
  */
40601
40962
  getValuePath(path2) {
40602
40963
  if (!path2) return void 0;
40964
+ const { type: type4, dataIndex, xDataIndex, yDataIndex, cellZone } = this.cell?.subRenderer || {};
40965
+ if (getIsDataGroup2DTable(type4) && cellZone === "cross") {
40966
+ return replacePathIndexPlaceholders({ x: xDataIndex, y: yDataIndex, templatePath: path2 });
40967
+ }
40603
40968
  if (!path2.includes("[n]")) {
40604
40969
  return path2;
40605
40970
  }
40606
- const {
40607
- type: type4,
40608
- dataIndex,
40609
- xDataIndex
40610
- } = this.cell?.subRenderer || {};
40611
40971
  let n = dataIndex;
40612
- if (type4 === "2d-table") {
40613
- n = xDataIndex;
40972
+ if (getIsDataGroup2DTable(type4)) {
40973
+ n = cellZone === "horizontal" ? yDataIndex : xDataIndex;
40614
40974
  }
40615
40975
  if (n === void 0) return path2;
40616
- return path2.replace(/\[n\]/g, `[${n}]`);
40976
+ return replacePathIndexPlaceholder(n, path2);
40617
40977
  }
40618
40978
  }
40619
40979
  class TextHandler {
40620
40980
  static getId(context, wr) {
40621
- let id = wr.id;
40622
- if (typeof context.cell?.subRenderer?.dataIndex === "number") {
40623
- id = `${wr.id}@${context.cell.subRenderer.dataIndex}`;
40624
- } else if (context.type === "header" || context.type === "footer") {
40625
- id = `${wr.id}$p${Math.max(0, context.page?.pageIndex)}`;
40981
+ const baseId = wr.id;
40982
+ const sub = context.cell?.subRenderer;
40983
+ if (sub && getIsDataGroup2DTable(sub.type) && sub.cellZone === "cross" && typeof sub.yDataIndex === "number" && typeof sub.xDataIndex === "number") {
40984
+ return `${baseId}@${sub.yDataIndex}_${sub.xDataIndex}`;
40985
+ }
40986
+ let runIndex;
40987
+ if (sub) {
40988
+ if (getIsDataGroup2DTable(sub.type)) {
40989
+ runIndex = sub.cellZone === "horizontal" ? sub.yDataIndex : sub.xDataIndex;
40990
+ } else {
40991
+ runIndex = sub.dataIndex;
40992
+ }
40626
40993
  }
40627
- return id;
40994
+ if (typeof runIndex === "number") {
40995
+ return `${baseId}@${runIndex}`;
40996
+ }
40997
+ if (context.type === "header" || context.type === "footer") {
40998
+ return `${baseId}$p${Math.max(0, context.page?.pageIndex ?? 0)}`;
40999
+ }
41000
+ return baseId;
40628
41001
  }
40629
41002
  static get2DInfo(context) {
40630
- const { xDataIndex, yDataIndex } = context.cell?.subRenderer || {};
40631
- return { xDataIndex, yDataIndex };
41003
+ const { xDataIndex, yDataIndex, cellZone } = context.cell?.subRenderer || {};
41004
+ return {
41005
+ xDataIndex: cellZone === "horizontal" ? void 0 : xDataIndex,
41006
+ yDataIndex
41007
+ };
40632
41008
  }
40633
41009
  /**
40634
41010
  * 合并部分run
@@ -40707,7 +41083,9 @@ class TextHandler {
40707
41083
  const chars = text.split("");
40708
41084
  let doc = context.doc;
40709
41085
  chars.forEach((char, charIndex) => {
40710
- const { width, height, ascent, descent } = TextRun.measureText(TextRun.measurePayload(char, layoutStyle));
41086
+ const { width, height, ascent, descent } = TextRun.measureText(
41087
+ TextRun.measurePayload(char, layoutStyle)
41088
+ );
40711
41089
  const run = new TextRun({
40712
41090
  doc,
40713
41091
  width,
@@ -40823,18 +41201,41 @@ class FieldBaseHandler {
40823
41201
  static hasValue(value) {
40824
41202
  return value !== void 0 && value !== null;
40825
41203
  }
41204
+ static getSubTableRunIndex(context) {
41205
+ const sub = context.cell?.subRenderer;
41206
+ if (!sub) return void 0;
41207
+ if (getIsDataGroup2DTable(sub.type)) {
41208
+ if (sub.cellZone === "horizontal") {
41209
+ return sub.yDataIndex;
41210
+ }
41211
+ return sub.xDataIndex;
41212
+ }
41213
+ if (typeof sub.dataIndex === "number") {
41214
+ return sub.dataIndex;
41215
+ }
41216
+ return void 0;
41217
+ }
40826
41218
  static getId(context, wr) {
40827
- let id = wr.id;
40828
- if (typeof context.cell?.subRenderer?.dataIndex === "number") {
40829
- id = `${wr.id}@${context.cell.subRenderer.dataIndex}`;
40830
- } else if (context.type === "header" || context.type === "footer") {
40831
- id = `${wr.id}$p${Math.max(0, context.page?.pageIndex)}`;
41219
+ const baseId = wr.id;
41220
+ const sub = context.cell?.subRenderer;
41221
+ if (sub && getIsDataGroup2DTable(sub.type) && sub.cellZone === "cross" && typeof sub.yDataIndex === "number" && typeof sub.xDataIndex === "number") {
41222
+ return `${baseId}@${sub.yDataIndex}_${sub.xDataIndex}`;
40832
41223
  }
40833
- return id;
41224
+ const runIndex = this.getSubTableRunIndex(context);
41225
+ if (typeof runIndex === "number") {
41226
+ return `${baseId}@${runIndex}`;
41227
+ }
41228
+ if (context.type === "header" || context.type === "footer") {
41229
+ return `${baseId}$p${Math.max(0, context.page?.pageIndex ?? 0)}`;
41230
+ }
41231
+ return baseId;
40834
41232
  }
40835
41233
  static get2DInfo(context) {
40836
- const { xDataIndex, yDataIndex } = context.cell?.subRenderer || {};
40837
- return { xDataIndex, yDataIndex };
41234
+ const { xDataIndex, yDataIndex, cellZone } = context.cell?.subRenderer || {};
41235
+ return {
41236
+ xDataIndex: cellZone === "horizontal" ? void 0 : xDataIndex,
41237
+ yDataIndex
41238
+ };
40838
41239
  }
40839
41240
  static getValue(ctx, valuePath) {
40840
41241
  const { context } = ctx;
@@ -40917,7 +41318,9 @@ class FieldBaseHandler {
40917
41318
  position: "left"
40918
41319
  });
40919
41320
  chars.forEach((char, charIndex) => {
40920
- const { width, height, ascent, descent } = TextRun.measureText(TextRun.measurePayload(char, layoutStyle));
41321
+ const { width, height, ascent, descent } = TextRun.measureText(
41322
+ TextRun.measurePayload(char, layoutStyle)
41323
+ );
40921
41324
  const run = new TextWidget({
40922
41325
  doc,
40923
41326
  width,
@@ -40962,7 +41365,9 @@ class FieldBaseHandler {
40962
41365
  position: "left"
40963
41366
  });
40964
41367
  chars.forEach((char, charIndex) => {
40965
- const { width, height, ascent, descent } = TextRun.measureText(TextRun.measurePayload(char, measureStyle));
41368
+ const { width, height, ascent, descent } = TextRun.measureText(
41369
+ TextRun.measurePayload(char, measureStyle)
41370
+ );
40966
41371
  const run = new TextWidget({
40967
41372
  doc,
40968
41373
  width,
@@ -41036,7 +41441,9 @@ class FieldBaseHandler {
41036
41441
  } = payload;
41037
41442
  const style = { ...layoutStyle, fontSize };
41038
41443
  label.split("").forEach((char, charIndex) => {
41039
- const { width, height, ascent, descent } = TextRun.measureText(TextRun.measurePayload(char, style));
41444
+ const { width, height, ascent, descent } = TextRun.measureText(
41445
+ TextRun.measurePayload(char, style)
41446
+ );
41040
41447
  const run = new TextWidget({
41041
41448
  doc: context.doc,
41042
41449
  width,
@@ -41114,7 +41521,9 @@ class FieldBaseHandler {
41114
41521
  } : {
41115
41522
  widgetFieldRightMarker: true
41116
41523
  };
41117
- const { width, height, ascent, descent } = TextRun.measureText(TextRun.measurePayload(label, measureStyle));
41524
+ const { width, height, ascent, descent } = TextRun.measureText(
41525
+ TextRun.measurePayload(label, measureStyle)
41526
+ );
41118
41527
  const _width = position === "left" ? width + 2 : width + 3;
41119
41528
  const run = new TextWidget({
41120
41529
  doc: context.doc,
@@ -41568,8 +41977,14 @@ class WidgetBaseHandler {
41568
41977
  */
41569
41978
  getDataIndex(init2 = null) {
41570
41979
  const { context } = this;
41571
- const { type: type4, dataIndex, xDataIndex } = context.cell?.subRenderer || {};
41572
- return (type4 === "2d-table" ? xDataIndex : dataIndex) ?? init2;
41980
+ const { type: type4, dataIndex, xDataIndex, yDataIndex, cellZone } = context.cell?.subRenderer || {};
41981
+ if (getIsDataGroup2DTable(type4)) {
41982
+ if (cellZone === "horizontal") {
41983
+ return yDataIndex ?? init2;
41984
+ }
41985
+ return xDataIndex ?? init2;
41986
+ }
41987
+ return dataIndex ?? init2;
41573
41988
  }
41574
41989
  getPaperIndex() {
41575
41990
  const { context } = this;
@@ -41579,21 +41994,28 @@ class WidgetBaseHandler {
41579
41994
  return null;
41580
41995
  }
41581
41996
  getId() {
41582
- const { wr } = this;
41583
- let id = wr.id;
41997
+ const baseId = this.wr.id;
41998
+ const sub = this.context.cell?.subRenderer;
41999
+ if (sub && getIsDataGroup2DTable(sub.type) && sub.cellZone === "cross" && typeof sub.yDataIndex === "number" && typeof sub.xDataIndex === "number") {
42000
+ return `${baseId}@${sub.yDataIndex}_${sub.xDataIndex}`;
42001
+ }
41584
42002
  const dataIndex = this.getDataIndex();
41585
- const pageIndex = this.getPaperIndex();
41586
42003
  if (typeof dataIndex === "number") {
41587
- id = `${wr.id}@${dataIndex}`;
41588
- } else if (typeof pageIndex === "number") {
41589
- id = `${wr.id}$p${pageIndex}`;
42004
+ return `${baseId}@${dataIndex}`;
41590
42005
  }
41591
- return id;
42006
+ const pageIndex = this.getPaperIndex();
42007
+ if (typeof pageIndex === "number") {
42008
+ return `${baseId}$p${pageIndex}`;
42009
+ }
42010
+ return baseId;
41592
42011
  }
41593
42012
  get2DInfo() {
41594
42013
  const { context } = this;
41595
- const { xDataIndex, yDataIndex } = context.cell?.subRenderer || {};
41596
- return { xDataIndex, yDataIndex };
42014
+ const { xDataIndex, yDataIndex, cellZone } = context.cell?.subRenderer || {};
42015
+ return {
42016
+ xDataIndex: cellZone === "horizontal" ? void 0 : xDataIndex,
42017
+ yDataIndex
42018
+ };
41597
42019
  }
41598
42020
  getLayoutStyle() {
41599
42021
  const { wr, context } = this;
@@ -41738,7 +42160,7 @@ class BarcodeHandler extends WidgetBaseHandler {
41738
42160
  layout() {
41739
42161
  const { wr, context } = this;
41740
42162
  const computedMap = wr.pageWidgetMeta?.props?.newSpecificConfig;
41741
- const id = wr.id + "@" + this.getDataIndex(0);
42163
+ const id = this.getId();
41742
42164
  const config = computedMap?.[id];
41743
42165
  const width = config?.relWidth ?? wr.pageWidgetMeta?.layout?.width ?? 120;
41744
42166
  const height = wr.pageWidgetMeta?.layout?.height ?? 40;
@@ -42518,12 +42940,16 @@ function splitTableByHeight(table, maxHeight) {
42518
42940
  console.timeEnd(key);
42519
42941
  return result;
42520
42942
  }
42943
+ const cellKey = (row, col) => `${row},${col}`;
42521
42944
  class TableExpander {
42522
42945
  table;
42523
42946
  doc;
42524
42947
  data;
42948
+ /** 模板节点 id → Wtr / Wtc */
42525
42949
  modelMapper = /* @__PURE__ */ new Map();
42950
+ /** 展开实例 id → RowFragment / CellFragment */
42526
42951
  instanceMapper = /* @__PURE__ */ new Map();
42952
+ /** 模板行索引 → 各类逻辑区域(用于按行分发展开策略) */
42527
42953
  rowIndexRepeatingMapper = /* @__PURE__ */ new Map();
42528
42954
  rowIndex2DTableMapper = /* @__PURE__ */ new Map();
42529
42955
  rowIndexBoundedMapper = /* @__PURE__ */ new Map();
@@ -42531,11 +42957,13 @@ class TableExpander {
42531
42957
  rowIndexTableHeaderMapper = /* @__PURE__ */ new Map();
42532
42958
  rowIdTableHeaderMapper = /* @__PURE__ */ new Map();
42533
42959
  rowIdSubTableMapper = /* @__PURE__ */ new Map();
42960
+ /** 固定表 / 检验表 / 二维表:数据关联铺砖后的单元格数据索引 */
42534
42961
  boundedCellDataIndexMap = /* @__PURE__ */ new Map();
42535
42962
  checkTableCellDataIndexMap = /* @__PURE__ */ new Map();
42536
42963
  _2DTableCellDataIndexMap = /* @__PURE__ */ new Map();
42964
+ /** 展开后的行列表(按文档顺序) */
42537
42965
  rows = [];
42538
- // tableHeaders: string[][] = [];
42966
+ /** 表头区域 id 该区域包含的模板行 id 列表 */
42539
42967
  regionIdTableHeaderMetaMap = /* @__PURE__ */ new Map();
42540
42968
  constructor(table, doc) {
42541
42969
  this.table = table;
@@ -42546,373 +42974,371 @@ class TableExpander {
42546
42974
  getModelById(id) {
42547
42975
  return this.modelMapper.get(id);
42548
42976
  }
42977
+ // ─── 初始化入口 ─────────────────────────────────────────────
42549
42978
  initialize() {
42550
42979
  this.initializeModelMapper();
42551
- this.initializeRepeatingMapper();
42552
- this.initialize2DTableMapper();
42553
- this.initializeBoundedMapper();
42554
- this.initializeCheckTableMapper();
42555
- this.initializeTableHeaderMapper();
42980
+ this.initializeRegionMappers();
42556
42981
  this.initializeBoundedItemDataIndex();
42557
42982
  this.initializeDataGroup2DDataIndex();
42558
42983
  this.initializeRows();
42559
42984
  this.transformMergeRelations();
42560
42985
  }
42561
42986
  initializeModelMapper() {
42562
- this.table.rows.forEach((wtr) => {
42987
+ for (const wtr of this.table.rows) {
42563
42988
  this.modelMapper.set(wtr.id, wtr);
42564
- wtr.cells.forEach((wtc) => {
42989
+ for (const wtc of wtr.cells) {
42565
42990
  this.modelMapper.set(wtc.id, wtc);
42566
- });
42567
- });
42568
- }
42569
- initializeRepeatingMapper() {
42570
- this.table.repeating.forEach((region) => {
42571
- for (let r = region.start.row; r <= region.end.row; r++) {
42572
- this.rowIndexRepeatingMapper.set(r, region);
42573
- this.rowIdSubTableMapper.set(this.table.rows[r]?.id, region);
42574
- }
42575
- });
42576
- }
42577
- initialize2DTableMapper() {
42578
- this.table._2DTable.forEach((region) => {
42579
- for (let r = region.start.row; r <= region.end.row; r++) {
42580
- this.rowIndex2DTableMapper.set(r, region);
42581
- this.rowIdSubTableMapper.set(this.table.rows[r]?.id, region);
42582
42991
  }
42583
- });
42992
+ }
42584
42993
  }
42585
- initializeBoundedMapper() {
42586
- this.table.bounded.forEach((region) => {
42587
- for (let r = region.start.row; r <= region.end.row; r++) {
42588
- this.rowIndexBoundedMapper.set(r, region);
42589
- this.rowIdSubTableMapper.set(this.table.rows[r]?.id, region);
42590
- }
42591
- });
42994
+ /** 建立模板行索引 / 行 id 与各类子表、表头区域的映射 */
42995
+ initializeRegionMappers() {
42996
+ this.registerRowsForRegions(this.table.repeating, this.rowIndexRepeatingMapper);
42997
+ this.registerRowsForRegions(this.table._2DTable, this.rowIndex2DTableMapper);
42998
+ this.registerRowsForRegions(this.table.bounded, this.rowIndexBoundedMapper);
42999
+ this.registerRowsForRegions(this.table.checkTable, this.rowIndexCheckTableMapper);
43000
+ this.initializeTableHeaderMapper();
42592
43001
  }
42593
- initializeCheckTableMapper() {
42594
- this.table.checkTable.forEach((region) => {
43002
+ registerRowsForRegions(regions, rowIndexMapper) {
43003
+ for (const region of regions) {
42595
43004
  for (let r = region.start.row; r <= region.end.row; r++) {
42596
- this.rowIndexCheckTableMapper.set(r, region);
42597
- this.rowIdSubTableMapper.set(this.table.rows[r]?.id, region);
43005
+ rowIndexMapper.set(r, region);
43006
+ const rowId = this.table.rows[r]?.id;
43007
+ if (rowId) this.rowIdSubTableMapper.set(rowId, region);
42598
43008
  }
42599
- });
43009
+ }
42600
43010
  }
42601
43011
  initializeTableHeaderMapper() {
42602
- this.table.tableHeader.forEach((region) => {
43012
+ for (const region of this.table.tableHeader) {
42603
43013
  const tableHeaderRowIds = [];
42604
43014
  for (let r = region.start.row; r <= region.end.row; r++) {
42605
43015
  this.rowIndexTableHeaderMapper.set(r, region);
42606
- this.rowIdTableHeaderMapper.set(this.table.getChildAt(r).id, region);
42607
43016
  const wtr = this.table.rows[r];
43017
+ this.rowIdTableHeaderMapper.set(wtr.id, region);
42608
43018
  tableHeaderRowIds.push(wtr.id);
42609
43019
  }
42610
- this.regionIdTableHeaderMetaMap.set(region.id, {
42611
- rowIds: tableHeaderRowIds
42612
- });
42613
- });
43020
+ this.regionIdTableHeaderMetaMap.set(region.id, { rowIds: tableHeaderRowIds });
43021
+ }
42614
43022
  }
42615
43023
  initializeBoundedItemDataIndex() {
42616
- this.table.bounded.forEach((region) => {
42617
- if (region.itemRegion) {
42618
- const fillDirection = region.widgetMeta?.props?.fillDirection ?? "x";
42619
- const map2 = this.computeDataIndexMap(region, region.itemRegion, fillDirection);
42620
- map2.forEach((obj, key) => {
42621
- this.boundedCellDataIndexMap.set(key, {
42622
- dataIndex: obj.dataIndex,
42623
- refCellId: obj.refCellId
42624
- });
42625
- });
42626
- }
42627
- });
43024
+ for (const region of this.table.bounded) {
43025
+ if (!region.itemRegion) continue;
43026
+ const fillDirection = region.widgetMeta?.props?.fillDirection ?? "x";
43027
+ this.mergeIndexMap(
43028
+ this.boundedCellDataIndexMap,
43029
+ this.computeDataIndexMap(region, region.itemRegion, fillDirection)
43030
+ );
43031
+ }
42628
43032
  }
42629
- // [数据关联]上、下超出子表范围的部分需要撑开
43033
+ /**
43034
+ * 检验表 / 二维表的数据关联区:itemRegion 可能超出子表行范围(向上/下扩充),
43035
+ * 展开铺砖时需用扩充后的行范围。
43036
+ */
42630
43037
  getDataGroup2DItemRange(range3, itemRange) {
42631
- const {
42632
- start: { row: startRow },
42633
- end: { row: endRow }
42634
- } = itemRange;
42635
43038
  const expandedRange = cloneDeep(pick(range3, "start", "end"));
42636
- expandedRange.start.row = startRow;
42637
- expandedRange.end.row = endRow;
43039
+ expandedRange.start.row = itemRange.start.row;
43040
+ expandedRange.end.row = itemRange.end.row;
42638
43041
  return expandedRange;
42639
43042
  }
42640
43043
  initializeDataGroup2DDataIndex() {
42641
- this.table.checkTable.forEach((region) => {
42642
- if (region.itemRegion) {
42643
- const expandedRange = this.getDataGroup2DItemRange(region, region.itemRegion);
42644
- const map2 = this.computeDataIndexMap(expandedRange, region.itemRegion);
42645
- map2.forEach((obj, key) => {
42646
- this.checkTableCellDataIndexMap.set(key, {
42647
- dataIndex: obj.dataIndex,
42648
- refCellId: obj.refCellId
42649
- });
42650
- });
42651
- }
42652
- });
42653
- this.table._2DTable.forEach((region) => {
42654
- if (region.itemRegion) {
42655
- const expandedRange = this.getDataGroup2DItemRange(region, region.itemRegion);
42656
- const map2 = this.computeDataIndexMap(expandedRange, region.itemRegion);
42657
- map2.forEach((obj, key) => {
42658
- this._2DTableCellDataIndexMap.set(key, {
42659
- dataIndex: obj.dataIndex,
42660
- refCellId: obj.refCellId
42661
- });
42662
- });
42663
- }
43044
+ this.initLinkSubTableCellIndexMaps(this.table.checkTable, this.checkTableCellDataIndexMap);
43045
+ this.initLinkSubTableCellIndexMaps(this.table._2DTable, this._2DTableCellDataIndexMap);
43046
+ }
43047
+ initLinkSubTableCellIndexMaps(regions, target) {
43048
+ for (const region of regions) {
43049
+ if (!region.itemRegion) continue;
43050
+ const expandedRange = this.getDataGroup2DItemRange(region, region.itemRegion);
43051
+ this.mergeIndexMap(target, this.computeDataIndexMap(expandedRange, region.itemRegion));
43052
+ }
43053
+ }
43054
+ mergeIndexMap(target, source) {
43055
+ source.forEach((meta, key) => {
43056
+ target.set(key, {
43057
+ dataIndex: meta.dataIndex,
43058
+ refCellId: meta.refCellId
43059
+ });
42664
43060
  });
42665
43061
  }
43062
+ // ─── 按行展开 ───────────────────────────────────────────────
42666
43063
  initializeRows() {
42667
- for (let wtrIndex = 0; wtrIndex < this.table.rows.length; wtrIndex++) {
42668
- const wtr = this.table.rows[wtrIndex];
42669
- if (this.rowIndexRepeatingMapper.has(wtrIndex)) {
42670
- const region = this.rowIndexRepeatingMapper.get(wtrIndex);
42671
- if (wtrIndex === region.start.row) {
43064
+ for (let rowIndex = 0; rowIndex < this.table.rows.length; rowIndex++) {
43065
+ const wtr = this.table.rows[rowIndex];
43066
+ if (this.rowIndexRepeatingMapper.has(rowIndex)) {
43067
+ const region = this.rowIndexRepeatingMapper.get(rowIndex);
43068
+ if (rowIndex === region.start.row) {
42672
43069
  this.initializeRepeatingRowsInRange(region);
42673
43070
  }
42674
- } else if (this.rowIndex2DTableMapper.has(wtrIndex)) {
42675
- const region = this.rowIndex2DTableMapper.get(wtrIndex);
42676
- if (wtrIndex === region.start.row) {
42677
- this.initialize2DTableRowsInRange(wtrIndex, region);
43071
+ } else if (this.rowIndex2DTableMapper.has(rowIndex)) {
43072
+ const region = this.rowIndex2DTableMapper.get(rowIndex);
43073
+ if (rowIndex === region.start.row) {
43074
+ this.initialize2DTableRowsInRange(rowIndex, region);
42678
43075
  }
42679
- } else if (this.rowIndexBoundedMapper.has(wtrIndex)) {
42680
- const region = this.rowIndexBoundedMapper.get(wtrIndex);
42681
- this.initializeBoundedRowInRange(wtr, wtrIndex, region);
42682
- } else if (this.rowIndexCheckTableMapper.has(wtrIndex)) {
42683
- const region = this.rowIndexCheckTableMapper.get(wtrIndex);
42684
- this.initializeCheckTableRowInRange(wtr, wtrIndex, region);
42685
- } else if (this.rowIndexTableHeaderMapper.has(wtrIndex)) {
42686
- const region = this.rowIndexTableHeaderMapper.get(wtrIndex);
42687
- this.initializeTableHeaderRowInRange(wtr, region);
43076
+ } else if (this.rowIndexBoundedMapper.has(rowIndex)) {
43077
+ this.initializeBoundedRowInRange(wtr, rowIndex, this.rowIndexBoundedMapper.get(rowIndex));
43078
+ } else if (this.rowIndexCheckTableMapper.has(rowIndex)) {
43079
+ this.initializeCheckTableRowInRange(
43080
+ wtr,
43081
+ rowIndex,
43082
+ this.rowIndexCheckTableMapper.get(rowIndex)
43083
+ );
43084
+ } else if (this.rowIndexTableHeaderMapper.has(rowIndex)) {
43085
+ this.initializeTableHeaderRowInRange(wtr, this.rowIndexTableHeaderMapper.get(rowIndex));
42688
43086
  } else {
42689
- this.initializeNormalRowInRange(wtr, wtrIndex);
43087
+ this.initializeNormalRowInRange(wtr, rowIndex);
42690
43088
  }
42691
43089
  }
42692
43090
  }
43091
+ /** 编辑模式只展开一份;预览/填报模式按数据路径长度重复 */
42693
43092
  getRepeatCount(region) {
42694
- if (this.doc.mode === DocModeTypeConst.Edit) {
42695
- return 1;
42696
- }
42697
- return this.data.get(region.valuePath)?.length || 1;
43093
+ if (this.doc.mode === DocModeTypeConst.Edit) return 1;
43094
+ return this.data.get(region.subValuePath || region.valuePath)?.length || 1;
42698
43095
  }
43096
+ // ─── 循环子表 / 二维子表(纵向重复)────────────────────────
42699
43097
  initializeRepeatingRowsInRange(region) {
42700
- const repeatCount = this.getRepeatCount(region);
42701
- const repeatRows = this.table.children.slice(region.start.row, region.end.row + 1);
42702
- const repeatRowsCount = repeatRows.length;
42703
- repeat(repeatCount, (dataIndex) => {
42704
- repeatRows.forEach((_wtr, _wtrIndex) => {
42705
- const row = {
42706
- id: `${_wtr.id}@${dataIndex}`,
42707
- expandFromId: _wtr.id,
42708
- cells: _wtr.children.map((wtc, wtcIndex) => {
42709
- if (dataIndex === 0 && _wtrIndex === repeatRowsCount - 1 && (wtcIndex < region.start.col || wtcIndex > region.end.col)) {
42710
- if (!wtc.mergeFromId) {
42711
- const cell2 = {
42712
- id: `${wtc.id}@${dataIndex}`,
42713
- expandFromId: wtc.id,
42714
- rowspan: (wtc.rowspan ?? 1) + repeatRowsCount * (repeatCount - 1),
42715
- colspan: wtc.colspan ?? 1
42716
- };
42717
- this.instanceMapper.set(cell2.id, cell2);
42718
- return cell2;
42719
- } else {
42720
- const instanceCell = this.instanceMapper.get(`${wtc.mergeFromId}@0`) ?? this.instanceMapper.get(wtc.mergeFromId);
42721
- instanceCell.rowspan = (instanceCell.rowspan ?? 1) + repeatRowsCount * (repeatCount - 1);
42722
- }
42723
- }
42724
- const cell = {
42725
- id: `${wtc.id}@${dataIndex}`,
42726
- expandFromId: wtc.id,
42727
- rowspan: wtc.rowspan ?? 1,
42728
- colspan: wtc.colspan ?? 1
42729
- };
42730
- if (region.contains(region.start.row + _wtrIndex, wtcIndex)) {
42731
- cell.dataIndex = this.doc.mode === DocModeTypeConst.Edit ? void 0 : dataIndex;
42732
- cell.repeatingId = region.id;
42733
- }
42734
- this.instanceMapper.set(cell.id, cell);
42735
- return cell;
42736
- })
42737
- };
42738
- this.instanceMapper.set(row.id, row);
42739
- this.rows.push(row);
42740
- });
43098
+ this.initializeRepeatableSubTableRows(region, (templateRow, col, dataIndex) => {
43099
+ const cell = {
43100
+ id: "",
43101
+ expandFromId: "",
43102
+ rowspan: 1,
43103
+ colspan: 1
43104
+ };
43105
+ if (region.contains(templateRow, col)) {
43106
+ cell.dataIndex = this.doc.mode === DocModeTypeConst.Edit ? void 0 : dataIndex;
43107
+ cell.repeatingId = region.id;
43108
+ }
43109
+ return cell;
42741
43110
  });
42742
43111
  }
42743
- initialize2DTableRowsInRange(r, region) {
43112
+ initialize2DTableRowsInRange(regionStartRow, region) {
43113
+ this.initializeRepeatableSubTableRows(
43114
+ region,
43115
+ (templateRow, col, yDataIndex, wtc) => {
43116
+ const dataIndexMeta = this._2DTableCellDataIndexMap.get(cellKey(templateRow, col));
43117
+ const linkMeta = this.resolveLinkSubTableCellMeta(templateRow, col, region, dataIndexMeta);
43118
+ const cell = {
43119
+ id: "",
43120
+ expandFromId: linkMeta.expandFromId || wtc.id,
43121
+ rowspan: wtc.rowspan ?? 1,
43122
+ colspan: wtc.colspan ?? 1,
43123
+ xDataIndex: linkMeta.xDataIndex,
43124
+ cellZone: linkMeta.cellZone
43125
+ };
43126
+ if (region.contains(templateRow, col)) {
43127
+ cell.yDataIndex = this.doc.mode === DocModeTypeConst.Edit ? void 0 : yDataIndex;
43128
+ }
43129
+ if (linkMeta.cellZone) {
43130
+ cell._2DTableId = region.id;
43131
+ }
43132
+ return cell;
43133
+ },
43134
+ regionStartRow
43135
+ );
43136
+ }
43137
+ /**
43138
+ * 循环子表与二维子表共用的纵向展开逻辑:
43139
+ * 按数据条数复制行块,区域外最后一行单元格需合并 rowspan 以覆盖重复产生的额外行。
43140
+ */
43141
+ initializeRepeatableSubTableRows(region, enrichCell, regionStartRow = region.start.row) {
42744
43142
  const repeatCount = this.getRepeatCount(region);
42745
- const repeatRows = this.table.children.slice(region.start.row, region.end.row + 1);
42746
- const repeatRowsCount = repeatRows.length;
42747
- repeat(repeatCount, (yDataIndex) => {
42748
- repeatRows.forEach((_wtr, _wtrIndex) => {
43143
+ const templateRows = this.table.children.slice(region.start.row, region.end.row + 1);
43144
+ const templateRowCount = templateRows.length;
43145
+ const extraRowspan = templateRowCount * (repeatCount - 1);
43146
+ repeat(repeatCount, (dataIndex) => {
43147
+ templateRows.forEach((wtr, rowOffset) => {
43148
+ const templateRow = regionStartRow + rowOffset;
43149
+ const isLastTemplateRow = rowOffset === templateRowCount - 1;
42749
43150
  const row = {
42750
- id: `${_wtr.id}@${yDataIndex}`,
42751
- expandFromId: _wtr.id,
42752
- cells: _wtr.children.map((wtc, wtcIndex) => {
42753
- const dataIndexMeta = this._2DTableCellDataIndexMap.get(`${r + _wtrIndex},${wtcIndex}`);
42754
- const xDataIndex = dataIndexMeta?.dataIndex;
42755
- if (yDataIndex === 0 && _wtrIndex === repeatRowsCount - 1 && (wtcIndex < region.start.col || wtcIndex > region.end.col)) {
42756
- if (!wtc.mergeFromId) {
42757
- const cell2 = {
42758
- id: `${wtc.id}@${yDataIndex}`,
42759
- expandFromId: wtc.id,
42760
- rowspan: (wtc.rowspan ?? 1) + repeatRowsCount * (repeatCount - 1),
42761
- colspan: wtc.colspan ?? 1
42762
- };
42763
- this.instanceMapper.set(cell2.id, cell2);
42764
- return cell2;
42765
- } else {
42766
- const instanceCell = this.instanceMapper.get(`${wtc.mergeFromId}@0`) ?? this.instanceMapper.get(wtc.mergeFromId);
42767
- instanceCell.rowspan = (instanceCell.rowspan ?? 1) + repeatRowsCount * (repeatCount - 1);
42768
- }
42769
- }
42770
- const cell = {
42771
- id: `${wtc.id}@${yDataIndex}`,
42772
- expandFromId: dataIndexMeta?.refCellId || wtc.id,
42773
- rowspan: wtc.rowspan ?? 1,
42774
- colspan: wtc.colspan ?? 1,
42775
- xDataIndex
42776
- };
42777
- if (region.contains(region.start.row + _wtrIndex, wtcIndex)) {
42778
- cell.dataIndex = yDataIndex;
42779
- cell.yDataIndex = yDataIndex;
42780
- cell._2DTableId = region.id;
42781
- }
43151
+ id: `${wtr.id}@${dataIndex}`,
43152
+ expandFromId: wtr.id,
43153
+ cells: wtr.children.map((wtc, col) => {
43154
+ const outsideRegion = dataIndex === 0 && isLastTemplateRow && (col < region.start.col || col > region.end.col);
43155
+ const extended = this.tryCreateExtendedRowspanCell(
43156
+ wtc,
43157
+ dataIndex,
43158
+ outsideRegion,
43159
+ extraRowspan
43160
+ );
43161
+ if (extended) return extended;
43162
+ const cell = enrichCell(templateRow, col, dataIndex, wtc);
43163
+ cell.id = `${wtc.id}@${dataIndex}`;
43164
+ if (!cell.expandFromId) cell.expandFromId = wtc.id;
43165
+ cell.rowspan = wtc.rowspan ?? 1;
43166
+ cell.colspan = wtc.colspan ?? 1;
42782
43167
  this.instanceMapper.set(cell.id, cell);
42783
43168
  return cell;
42784
43169
  })
42785
43170
  };
42786
- this.instanceMapper.set(row.id, row);
42787
- this.rows.push(row);
43171
+ this.pushRow(row);
42788
43172
  });
42789
43173
  });
42790
43174
  }
42791
- initializeBoundedRowInRange(wtr, wtrIndex, region) {
42792
- const row = {
42793
- id: wtr.id,
42794
- expandFromId: wtr.id,
42795
- cells: wtr.children.map((wtc, wtcIndex) => {
42796
- const dataIndexMeta = this.boundedCellDataIndexMap.get(`${wtrIndex},${wtcIndex}`);
42797
- const cell = {
42798
- id: wtc.id,
42799
- expandFromId: dataIndexMeta?.refCellId ?? wtc.id,
42800
- // 这里的id需要复用
42801
- rowspan: wtc.rowspan ?? 1,
42802
- colspan: wtc.colspan ?? 1
42803
- };
42804
- if (region.start.col <= wtcIndex && wtcIndex <= region.end.col) {
43175
+ /**
43176
+ * 循环区域外、首条数据最后一行:将 rowspan 拉长以吞并后续重复行,
43177
+ * 避免区域外单元格被拆成多行。
43178
+ */
43179
+ tryCreateExtendedRowspanCell(wtc, dataIndex, shouldExtend, extraRowspan) {
43180
+ if (!shouldExtend) return void 0;
43181
+ if (!wtc.mergeFromId) {
43182
+ const cell = {
43183
+ id: `${wtc.id}@${dataIndex}`,
43184
+ expandFromId: wtc.id,
43185
+ rowspan: (wtc.rowspan ?? 1) + extraRowspan,
43186
+ colspan: wtc.colspan ?? 1
43187
+ };
43188
+ this.instanceMapper.set(cell.id, cell);
43189
+ return cell;
43190
+ }
43191
+ const anchor = this.instanceMapper.get(`${wtc.mergeFromId}@0`) ?? this.instanceMapper.get(wtc.mergeFromId);
43192
+ if (anchor) {
43193
+ anchor.rowspan = (anchor.rowspan ?? 1) + extraRowspan;
43194
+ }
43195
+ return void 0;
43196
+ }
43197
+ // ─── 单行区域(固定表 / 检验表 / 表头 / 普通行)────────────
43198
+ initializeBoundedRowInRange(wtr, rowIndex, region) {
43199
+ this.pushRow(
43200
+ this.buildSingleTemplateRow(wtr, (wtc, col) => {
43201
+ const dataIndexMeta = this.boundedCellDataIndexMap.get(cellKey(rowIndex, col));
43202
+ const cell = this.createTemplateCell(wtc, dataIndexMeta?.refCellId);
43203
+ if (region.start.col <= col && col <= region.end.col) {
42805
43204
  cell.boundedId = region.id;
42806
43205
  }
42807
43206
  if (dataIndexMeta?.dataIndex !== void 0) {
42808
43207
  cell.dataIndex = dataIndexMeta.dataIndex;
42809
43208
  }
42810
- this.instanceMapper.set(cell.id, cell);
42811
43209
  return cell;
42812
43210
  })
42813
- };
42814
- this.instanceMapper.set(row.id, row);
42815
- this.rows.push(row);
43211
+ );
42816
43212
  }
42817
- initializeCheckTableRowInRange(wtr, wtrIndex, region) {
42818
- const row = {
42819
- id: wtr.id,
42820
- expandFromId: wtr.id,
42821
- cells: wtr.children.map((wtc, wtcIndex) => {
42822
- const dataIndexMeta = this.checkTableCellDataIndexMap.get(`${wtrIndex},${wtcIndex}`);
42823
- const cell = {
42824
- id: wtc.id,
42825
- expandFromId: dataIndexMeta?.refCellId ?? wtc.id,
42826
- // 这里的id需要复用
42827
- rowspan: wtc.rowspan ?? 1,
42828
- colspan: wtc.colspan ?? 1
42829
- };
42830
- if (region.start.col <= wtcIndex && wtcIndex <= region.end.col) {
42831
- cell.checkTableId = region.id;
42832
- }
42833
- if (dataIndexMeta?.dataIndex !== void 0) {
42834
- cell.dataIndex = dataIndexMeta.dataIndex;
42835
- }
42836
- this.instanceMapper.set(cell.id, cell);
43213
+ initializeCheckTableRowInRange(wtr, rowIndex, region) {
43214
+ this.pushRow(
43215
+ this.buildSingleTemplateRow(wtr, (wtc, col) => {
43216
+ const dataIndexMeta = this.checkTableCellDataIndexMap.get(cellKey(rowIndex, col));
43217
+ const linkMeta = this.resolveLinkSubTableCellMeta(rowIndex, col, region, dataIndexMeta);
43218
+ const cell = this.createTemplateCell(
43219
+ wtc,
43220
+ linkMeta.expandFromId,
43221
+ linkMeta.xDataIndex,
43222
+ linkMeta.cellZone
43223
+ );
43224
+ if (linkMeta.cellZone) cell.checkTableId = region.id;
42837
43225
  return cell;
42838
43226
  })
42839
- };
42840
- this.instanceMapper.set(row.id, row);
42841
- this.rows.push(row);
43227
+ );
42842
43228
  }
42843
43229
  initializeTableHeaderRowInRange(wtr, region) {
42844
- const row = {
42845
- id: wtr.id,
42846
- expandFromId: wtr.id,
42847
- cells: wtr.children.map((wtc, wtcIndex) => {
42848
- const cell = {
42849
- id: wtc.id,
42850
- expandFromId: wtc.id,
42851
- rowspan: wtc.rowspan ?? 1,
42852
- colspan: wtc.colspan ?? 1
42853
- };
42854
- if (region.start.col <= wtcIndex && wtcIndex <= region.end.col) {
43230
+ this.pushRow(
43231
+ this.buildSingleTemplateRow(wtr, (wtc, col) => {
43232
+ const cell = this.createTemplateCell(wtc);
43233
+ if (region.start.col <= col && col <= region.end.col) {
42855
43234
  cell.headerId = region.id;
42856
43235
  }
42857
- this.instanceMapper.set(cell.id, cell);
42858
43236
  return cell;
42859
43237
  })
42860
- };
42861
- this.instanceMapper.set(row.id, row);
42862
- this.rows.push(row);
43238
+ );
42863
43239
  }
42864
- initializeNormalRowInRange(wtr, wtrIndex) {
42865
- const row = {
43240
+ initializeNormalRowInRange(wtr, rowIndex) {
43241
+ this.pushRow(
43242
+ this.buildSingleTemplateRow(wtr, (wtc, col) => {
43243
+ const dataIndexMeta = this.checkTableCellDataIndexMap.get(cellKey(rowIndex, col)) ?? this._2DTableCellDataIndexMap.get(cellKey(rowIndex, col));
43244
+ const linkRegion = this.findLinkSubTableRegionForCell(rowIndex, col);
43245
+ const cell = this.createTemplateCell(wtc, dataIndexMeta?.refCellId);
43246
+ if (linkRegion) {
43247
+ const linkMeta = this.resolveLinkSubTableCellMeta(
43248
+ rowIndex,
43249
+ col,
43250
+ linkRegion,
43251
+ dataIndexMeta
43252
+ );
43253
+ cell.expandFromId = linkMeta.expandFromId || wtc.id;
43254
+ cell.xDataIndex = linkMeta.xDataIndex;
43255
+ cell.cellZone = linkMeta.cellZone;
43256
+ if (linkRegion.type === "check-table") {
43257
+ cell.checkTableId = linkRegion.id;
43258
+ } else {
43259
+ cell._2DTableId = linkRegion.id;
43260
+ }
43261
+ }
43262
+ return cell;
43263
+ })
43264
+ );
43265
+ }
43266
+ buildSingleTemplateRow(wtr, buildCell) {
43267
+ return {
42866
43268
  id: wtr.id,
42867
43269
  expandFromId: wtr.id,
42868
- cells: wtr.children.map((wtc, wtcIndex) => {
42869
- const checkMeta = this.checkTableCellDataIndexMap.get(`${wtrIndex},${wtcIndex}`);
42870
- const _2DMeta = this._2DTableCellDataIndexMap.get(`${wtrIndex},${wtcIndex}`);
42871
- const dataGroup2DRefCellId = checkMeta?.refCellId || _2DMeta?.refCellId;
42872
- const cell = {
42873
- id: wtc.id,
42874
- expandFromId: dataGroup2DRefCellId || wtc.id,
42875
- rowspan: wtc.rowspan ?? 1,
42876
- colspan: wtc.colspan ?? 1
42877
- };
43270
+ cells: wtr.children.map((wtc, col) => {
43271
+ const cell = buildCell(wtc, col);
42878
43272
  this.instanceMapper.set(cell.id, cell);
42879
43273
  return cell;
42880
43274
  })
42881
43275
  };
43276
+ }
43277
+ createTemplateCell(wtc, expandFromId, xDataIndex, cellZone) {
43278
+ return {
43279
+ id: wtc.id,
43280
+ expandFromId: expandFromId ?? wtc.id,
43281
+ rowspan: wtc.rowspan ?? 1,
43282
+ colspan: wtc.colspan ?? 1,
43283
+ ...xDataIndex !== void 0 && { xDataIndex },
43284
+ ...cellZone !== void 0 && { cellZone }
43285
+ };
43286
+ }
43287
+ pushRow(row) {
42882
43288
  this.instanceMapper.set(row.id, row);
42883
43289
  this.rows.push(row);
42884
43290
  }
43291
+ // ─── 数据关联子表(检验表 / 二维表)元信息 ─────────────────
43292
+ getLinkSubTableCellIndexMap(region) {
43293
+ return region.type === "2d-table" ? this._2DTableCellDataIndexMap : this.checkTableCellDataIndexMap;
43294
+ }
43295
+ getFillEndColForRegion(region) {
43296
+ return getDataGroup2DFillEndCol(region, this.getLinkSubTableCellIndexMap(region));
43297
+ }
43298
+ findLinkSubTableRegionForCell(row, col) {
43299
+ const candidates = [...this.table.checkTable, ...this.table._2DTable];
43300
+ for (const region of candidates) {
43301
+ const fillEndCol = this.getFillEndColForRegion(region);
43302
+ if (isInLinkSubTableLayoutScope(row, col, region, { fillEndCol })) {
43303
+ return region;
43304
+ }
43305
+ }
43306
+ return void 0;
43307
+ }
43308
+ resolveLinkSubTableCellMeta(row, col, region, dataIndexMeta) {
43309
+ const fillEndCol = this.getFillEndColForRegion(region);
43310
+ return {
43311
+ cellZone: resolveLinkSubTableCellZone(row, col, region, { fillEndCol }),
43312
+ xDataIndex: dataIndexMeta?.dataIndex,
43313
+ expandFromId: dataIndexMeta?.refCellId
43314
+ };
43315
+ }
43316
+ // ─── 合并单元格关系 ─────────────────────────────────────────
43317
+ /** 根据主单元格的 rowspan/colspan,为被覆盖的从属单元格设置 mergeFromId */
42885
43318
  transformMergeRelations() {
42886
- this.rows.forEach((row, rowIndex) => {
42887
- row.cells.forEach((cell, colIndex) => {
42888
- if (cell.colspan > 1 || cell.rowspan > 1) {
42889
- this.rows.slice(rowIndex, rowIndex + cell.rowspan).forEach((r, ri) => {
42890
- r.cells.slice(colIndex, colIndex + cell.colspan).forEach((c2, ci) => {
42891
- if (ri === 0 && ci === 0) {
42892
- return;
42893
- }
42894
- c2.mergeFromId = cell.id;
42895
- });
42896
- });
43319
+ for (let rowIndex = 0; rowIndex < this.rows.length; rowIndex++) {
43320
+ const row = this.rows[rowIndex];
43321
+ for (let colIndex = 0; colIndex < row.cells.length; colIndex++) {
43322
+ const cell = row.cells[colIndex];
43323
+ if (cell.colspan <= 1 && cell.rowspan <= 1) continue;
43324
+ for (let dr = 0; dr < cell.rowspan; dr++) {
43325
+ for (let dc = 0; dc < cell.colspan; dc++) {
43326
+ if (dr === 0 && dc === 0) continue;
43327
+ const covered = this.rows[rowIndex + dr]?.cells[colIndex + dc];
43328
+ if (covered) covered.mergeFromId = cell.id;
43329
+ }
42897
43330
  }
42898
- });
42899
- });
43331
+ }
43332
+ }
42900
43333
  }
43334
+ // ─── 数据铺砖索引计算 ─────────────────────────────────────
42901
43335
  /**
42902
- * 计算单元格对应的数据索引(用于范围扩展)
43336
+ * 计算单元格对应的数据索引(用于范围扩展 / 数据关联铺砖)。
42903
43337
  *
42904
- * @param range - 整体范围 {start:{row,col} end:{row,col}},表示需要分配数据项的总区域
42905
- * @param itemRange - 局部范围 {start:{row,col} end:{row,col}},表示一个数据项的模板大小
42906
- * @param fillDirection - `x`:先横向扩展再换行;`y`:先纵向扩展再换列(与 `x` 的行列外层循环互为镜像)
42907
- * @returns Map,key 为字符串 "row,col",值为对应的数据索引
42908
- *
42909
- * 横向(x)算法:
42910
- * 1. 局部范围内的单元格数据索引为 0
42911
- * 2. 从局部范围右侧开始,按 itemWidth 宽度逐个扩展数据项
42912
- * 3. 当同一行带内无法再放置更多数据项时,换到下一个 itemHeight 行带
42913
- * 4. 换行后从整体范围的最左侧列开始继续扩展
42914
- *
42915
- * 纵向(y)算法:与 x 对称——先在模板列宽内从模板下方按 itemHeight 向下铺,再换到下一组列(列宽对齐 itemWidth),新一组列从整体范围最顶行重新起铺。
43338
+ * @param range - 需要分配数据项的总区域
43339
+ * @param itemRange - 单个数据项的模板大小(局部范围索引均为 0)
43340
+ * @param fillDirection - `x`:先横向铺砖再换行;`y`:先纵向铺砖再换列
43341
+ * @returns key "row,col",含 dataIndex 及引用模板单元格 id
42916
43342
  */
42917
43343
  computeDataIndexMap(range3, itemRange, fillDirection = "x") {
42918
43344
  const indexMap = /* @__PURE__ */ new Map();
@@ -42920,34 +43346,32 @@ class TableExpander {
42920
43346
  const itemHeight = itemRange.end.row - itemRange.start.row + 1;
42921
43347
  for (let r = itemRange.start.row; r <= itemRange.end.row; r++) {
42922
43348
  for (let c2 = itemRange.start.col; c2 <= itemRange.end.col; c2++) {
42923
- indexMap.set(`${r},${c2}`, {
42924
- dataIndex: 0
42925
- });
43349
+ indexMap.set(cellKey(r, c2), { dataIndex: 0 });
42926
43350
  }
42927
43351
  }
42928
- const tlr = itemRange.start.row;
42929
- const tlc = itemRange.start.col;
42930
- const stampBlock = (blockTopRow, blockLeftCol, di) => {
43352
+ const templateTopRow = itemRange.start.row;
43353
+ const templateLeftCol = itemRange.start.col;
43354
+ const stampBlock = (blockTopRow, blockLeftCol, dataIndex) => {
42931
43355
  for (let r = blockTopRow; r < blockTopRow + itemHeight; r++) {
42932
43356
  for (let c2 = blockLeftCol; c2 < blockLeftCol + itemWidth; c2++) {
42933
- const refR = tlr + r - blockTopRow;
42934
- const refC = tlc + c2 - blockLeftCol;
42935
- const refCell = this.table.getChildAt(refR).getChildAt(refC);
42936
- indexMap.set(`${r},${c2}`, {
42937
- dataIndex: di,
42938
- refPos: `${refR},${refC}`,
43357
+ const refRow = templateTopRow + r - blockTopRow;
43358
+ const refCol = templateLeftCol + c2 - blockLeftCol;
43359
+ const refCell = this.table.getChildAt(refRow).getChildAt(refCol);
43360
+ indexMap.set(cellKey(r, c2), {
43361
+ dataIndex,
43362
+ refPos: cellKey(refRow, refCol),
42939
43363
  refCellId: refCell.id
42940
43364
  });
42941
43365
  }
42942
43366
  }
42943
43367
  };
42944
- let dataIndex = 1;
43368
+ let nextDataIndex = 1;
42945
43369
  if (fillDirection === "x") {
42946
43370
  let currentRow = itemRange.start.row;
42947
43371
  let currentCol = itemRange.end.col + 1;
42948
43372
  while (currentRow + itemHeight - 1 <= range3.end.row) {
42949
43373
  while (currentCol + itemWidth - 1 <= range3.end.col) {
42950
- stampBlock(currentRow, currentCol, dataIndex++);
43374
+ stampBlock(currentRow, currentCol, nextDataIndex++);
42951
43375
  currentCol += itemWidth;
42952
43376
  }
42953
43377
  currentRow += itemHeight;
@@ -42958,7 +43382,7 @@ class TableExpander {
42958
43382
  let currentRow = itemRange.end.row + 1;
42959
43383
  while (currentCol + itemWidth - 1 <= range3.end.col) {
42960
43384
  while (currentRow + itemHeight - 1 <= range3.end.row) {
42961
- stampBlock(currentRow, currentCol, dataIndex++);
43385
+ stampBlock(currentRow, currentCol, nextDataIndex++);
42962
43386
  currentRow += itemHeight;
42963
43387
  }
42964
43388
  currentCol += itemWidth;
@@ -42993,32 +43417,18 @@ class TableInfoProvider {
42993
43417
  getCellModelRef(cell) {
42994
43418
  return { id: cell.expandFromId };
42995
43419
  }
42996
- // 获取检验表、二维表超出子表范围的数据关联的单元格范围
42997
- getDataGroup2DAreaRange(region) {
42998
- const { itemRegion, end: { col: endCol } } = region;
42999
- if (!itemRegion) {
43000
- return void 0;
43001
- }
43002
- const {
43003
- start: {
43004
- row: startRow,
43005
- col: startCol
43006
- },
43007
- end: {
43008
- row: endRow
43009
- }
43010
- } = itemRegion;
43011
- const range3 = {
43012
- start: {
43013
- row: startRow,
43014
- col: startCol
43015
- },
43016
- end: {
43017
- row: endRow,
43018
- col: endCol
43019
- }
43420
+ buildLinkSubTableSubRenderer(regionId, type4, region, cell) {
43421
+ const cellZone = cell.cellZone;
43422
+ const valuePath = cellZone ? resolveLinkSubTableValuePath(region, cellZone) : region.valuePath;
43423
+ return {
43424
+ id: regionId,
43425
+ type: type4,
43426
+ valuePath,
43427
+ widgetMeta: region.widgetMeta,
43428
+ cellZone,
43429
+ xDataIndex: cellZone === "horizontal" ? void 0 : cell.xDataIndex,
43430
+ yDataIndex: cellZone === "horizontal" || cellZone === "cross" ? cell.yDataIndex : void 0
43020
43431
  };
43021
- return range3;
43022
43432
  }
43023
43433
  getCellSubRenderer(cell) {
43024
43434
  if (cell.repeatingId) {
@@ -43032,17 +43442,8 @@ class TableInfoProvider {
43032
43442
  };
43033
43443
  } else if (cell._2DTableId) {
43034
43444
  const region = this.wtbl.get2DTableById(cell._2DTableId);
43035
- return {
43036
- id: cell._2DTableId,
43037
- type: "2d-table",
43038
- // 二维表使用 cell 的扩展字段
43039
- dataIndex: cell.dataIndex,
43040
- xDataIndex: cell.xDataIndex,
43041
- yDataIndex: cell.yDataIndex,
43042
- valuePath: region?.valuePath,
43043
- widgetMeta: region?.widgetMeta,
43044
- dataGroup2DAreaRange: this.getDataGroup2DAreaRange(region)
43045
- };
43445
+ if (!region || !cell.cellZone) return void 0;
43446
+ return this.buildLinkSubTableSubRenderer(cell._2DTableId, "2d-table", region, cell);
43046
43447
  } else if (cell.boundedId) {
43047
43448
  const region = this.wtbl.getBoundedById(cell.boundedId);
43048
43449
  return {
@@ -43054,21 +43455,13 @@ class TableInfoProvider {
43054
43455
  };
43055
43456
  } else if (cell.checkTableId) {
43056
43457
  const region = this.wtbl.getCheckTableById(cell.checkTableId);
43057
- return {
43058
- id: cell.checkTableId,
43059
- type: "check-table",
43060
- dataIndex: cell.dataIndex,
43061
- valuePath: region?.valuePath,
43062
- widgetMeta: region?.widgetMeta,
43063
- dataGroup2DAreaRange: this.getDataGroup2DAreaRange(region)
43064
- };
43458
+ if (!region || !cell.cellZone) return void 0;
43459
+ return this.buildLinkSubTableSubRenderer(cell.checkTableId, "check-table", region, cell);
43065
43460
  } else if (cell.headerId) {
43066
43461
  return {
43067
43462
  id: cell.headerId,
43068
43463
  type: "table-header",
43069
43464
  dataIndex: cell.dataIndex,
43070
- // valuePath: region?.valuePath!,
43071
- // widgetMeta: region?.widgetMeta,
43072
43465
  valuePath: "",
43073
43466
  widgetMeta: void 0
43074
43467
  };
@@ -45694,6 +46087,13 @@ class DataManager {
45694
46087
  * @returns 指定路径的值,不存在返回 undefined
45695
46088
  */
45696
46089
  get(path2) {
46090
+ const inferred = this.infer2DPathAndCoords(path2);
46091
+ if (inferred) {
46092
+ const value2D = this.get2DByCoords(inferred.logicalPath, inferred.coords);
46093
+ if (value2D !== void 0) {
46094
+ return value2D;
46095
+ }
46096
+ }
45697
46097
  let value = this.getByPath(this.rawData, path2);
45698
46098
  if (value === void 0) {
45699
46099
  value = this.getDefault(path2);
@@ -45710,16 +46110,26 @@ class DataManager {
45710
46110
  getLabel(path2) {
45711
46111
  return this.get(this.getLabelPath(path2)) || this.get(path2);
45712
46112
  }
46113
+ assignField(target, fieldPath, value) {
46114
+ if (!fieldPath.includes(".") && !fieldPath.includes("[")) {
46115
+ target[fieldPath] = value;
46116
+ return;
46117
+ }
46118
+ this.setByPath(target, `$.${fieldPath}`, value);
46119
+ }
45713
46120
  /**
45714
46121
  * 根据 jsonpath 设置数据
45715
46122
  * @param path jsonpath 路径
45716
46123
  * @param value 要设置的值
45717
- * @param x
45718
- * @param y
45719
46124
  * @returns 是否设置成功
45720
46125
  */
45721
- set2D(path2, value, x2, y2, source = "user") {
46126
+ set(path2, value, source = "user") {
45722
46127
  try {
46128
+ const inferred = this.infer2DPathAndCoords(path2);
46129
+ if (inferred) {
46130
+ const updated = this.set2DByCoords(inferred.logicalPath, value, inferred.coords, source);
46131
+ if (updated) return true;
46132
+ }
45723
46133
  const oldValue = this.getByPath(this.rawData, path2);
45724
46134
  this.setByPath(this.rawData, path2, value);
45725
46135
  this.emit(path2, value, oldValue, source);
@@ -45730,21 +46140,202 @@ class DataManager {
45730
46140
  }
45731
46141
  }
45732
46142
  /**
45733
- * 根据 jsonpath 设置数据
45734
- * @param path jsonpath 路径
45735
- * @param value 要设置的值
45736
- * @returns 是否设置成功
46143
+ * 从带数字下标的 path 推断二维坐标(供 setMultiple / patch / 业务回填等无 modelRef 的场景)
46144
+ * - 单轴:$.f_ewb[0].f_name y=0;$.f_ewblink[1].x → x=1(需能从 rawData 的交叉 key 识别轴,或命中 link 命名启发)
46145
+ * - 交叉:$.f_ewb:f_ewblink[0][1].f_value → y=0,x=1
46146
+ * 不会处理 [n] 通配符;普通子表(如 $.b[0].c)不推断,避免破坏原有语义。
45737
46147
  */
45738
- set(path2, value, source = "user") {
45739
- try {
45740
- const oldValue = this.getByPath(this.rawData, path2);
45741
- this.setByPath(this.rawData, path2, value);
45742
- this.emit(path2, value, oldValue, source);
46148
+ infer2DPathAndCoords(path2) {
46149
+ if (!path2 || path2.includes("[n]")) return null;
46150
+ const segments = this.parsePath(path2);
46151
+ if (segments.length < 3) return null;
46152
+ const head = segments[0];
46153
+ if (head?.type !== "property") return null;
46154
+ const tableKey = head.value;
46155
+ const restToFieldPath = (startIdx) => {
46156
+ let s = "";
46157
+ for (let i = startIdx; i < segments.length; i++) {
46158
+ const seg = segments[i];
46159
+ if (!seg) continue;
46160
+ if (seg.type === "property") {
46161
+ s += (s ? "." : "") + seg.value;
46162
+ } else {
46163
+ s += `[${seg.value}]`;
46164
+ }
46165
+ }
46166
+ return s;
46167
+ };
46168
+ if (tableKey.includes(":")) {
46169
+ let i = 1;
46170
+ if (segments[i]?.type !== "index") return null;
46171
+ const y2 = parseInt(segments[i].value, 10);
46172
+ i++;
46173
+ if (segments[i]?.type !== "index") return null;
46174
+ const x2 = parseInt(segments[i].value, 10);
46175
+ i++;
46176
+ const fieldPath2 = restToFieldPath(i);
46177
+ if (!fieldPath2) return null;
46178
+ return { logicalPath: `$.${tableKey}.${fieldPath2}`, coords: { x: x2, y: y2 } };
46179
+ }
46180
+ if (segments[1]?.type !== "index") return null;
46181
+ const idx = parseInt(segments[1].value, 10);
46182
+ if (!Number.isFinite(idx)) return null;
46183
+ const axisResolved = this.resolveAxisByTableKey(tableKey);
46184
+ const axisGuess = this.guessLinkSubTableAxis(tableKey);
46185
+ const axis = axisResolved?.axis ?? axisGuess;
46186
+ if (!axis) return null;
46187
+ const fieldPath = restToFieldPath(2);
46188
+ if (!fieldPath) return null;
46189
+ const coords = axis === "y" ? { y: idx } : { x: idx };
46190
+ return { logicalPath: `$.${tableKey}.${fieldPath}`, coords };
46191
+ }
46192
+ /**
46193
+ * rawData 尚无交叉 key 时,用命名约定推测轴(避免误判普通子表 $.b[0])
46194
+ * 须先于「f_ewb 主体」判断:f_ewblink 也以 f_ewb 开头。
46195
+ */
46196
+ guessLinkSubTableAxis(tableKey) {
46197
+ const lower = tableKey.toLowerCase();
46198
+ if (lower.includes("ewblink") || /link$/i.test(lower)) return "x";
46199
+ if (lower.startsWith("f_ewb")) return "y";
46200
+ return null;
46201
+ }
46202
+ parse2DPath(path2) {
46203
+ const normalized = path2.replace(/^\$\./, "");
46204
+ const firstDot = normalized.indexOf(".");
46205
+ if (firstDot === -1) return null;
46206
+ const tableKey = normalized.slice(0, firstDot).replace(/\[[^\]]+\]/g, "");
46207
+ const fieldPath = normalized.slice(firstDot + 1);
46208
+ if (!tableKey || !fieldPath) return null;
46209
+ return { tableKey, fieldPath };
46210
+ }
46211
+ getCrossKeys() {
46212
+ return Object.keys(this.rawData).filter((key) => key.includes(":"));
46213
+ }
46214
+ resolveAxisByTableKey(tableKey) {
46215
+ const crossKeys = this.getCrossKeys();
46216
+ const matched = crossKeys.filter((key) => {
46217
+ const [yKey2, xKey] = key.split(":");
46218
+ return yKey2 === tableKey || xKey === tableKey;
46219
+ });
46220
+ if (matched.length === 0) return null;
46221
+ const first = matched[0];
46222
+ const [yKey] = first.split(":");
46223
+ return { axis: yKey === tableKey ? "y" : "x", crossKeys: matched };
46224
+ }
46225
+ ensureAxisRowAndUid(tableKey, index2, axis) {
46226
+ const path2 = `$.${tableKey}`;
46227
+ let rows = this.getByPath(this.rawData, path2);
46228
+ if (!Array.isArray(rows)) {
46229
+ rows = [];
46230
+ this.setByPath(this.rawData, path2, rows);
46231
+ }
46232
+ while (rows.length <= index2) {
46233
+ rows.push({});
46234
+ }
46235
+ const row = rows[index2] ?? {};
46236
+ rows[index2] = row;
46237
+ const uidField = axis === "y" ? "__gw_y_uid" : "__gw_x_uid";
46238
+ if (!row[uidField]) {
46239
+ row[uidField] = row.id || `${axis}_${uuid()}`;
46240
+ }
46241
+ return row;
46242
+ }
46243
+ getFieldFromRow(row, fieldPath) {
46244
+ if (!fieldPath.includes(".") && !fieldPath.includes("[")) {
46245
+ return row[fieldPath];
46246
+ }
46247
+ return this.getByPath(row, `$.${fieldPath}`);
46248
+ }
46249
+ /**
46250
+ * 按 y/x 坐标读取二维表数据(与 set2DByCoords 对称)
46251
+ * 交叉区在 rawData 中按 __gw_y_uid / __gw_x_uid 稀疏存储,不能直接用 [y][x] 下标 getByPath。
46252
+ */
46253
+ get2DByCoords(path2, coords) {
46254
+ const parsed = this.parse2DPath(path2);
46255
+ if (!parsed) return void 0;
46256
+ const { tableKey, fieldPath } = parsed;
46257
+ if (tableKey.includes(":")) {
46258
+ const [yTableKey = "", xTableKey = ""] = tableKey.split(":");
46259
+ if (!yTableKey || !xTableKey) return void 0;
46260
+ if (typeof coords.y !== "number" || typeof coords.x !== "number") return void 0;
46261
+ const yRows = this.getByPath(this.rawData, `$.${yTableKey}`);
46262
+ const xRows = this.getByPath(this.rawData, `$.${xTableKey}`);
46263
+ const yUid = yRows?.[coords.y]?.__gw_y_uid;
46264
+ const xUid = xRows?.[coords.x]?.__gw_x_uid;
46265
+ if (!yUid || !xUid) return void 0;
46266
+ const crossRows = this.getByPath(this.rawData, `$.${tableKey}`);
46267
+ if (!Array.isArray(crossRows)) return void 0;
46268
+ const row = crossRows.find(
46269
+ (item) => item?.__gw_y_uid === yUid && item?.__gw_x_uid === xUid
46270
+ );
46271
+ if (!row) return void 0;
46272
+ return this.getFieldFromRow(row, fieldPath);
46273
+ }
46274
+ const axisInfo = this.resolveAxisByTableKey(tableKey);
46275
+ const axis = axisInfo?.axis ?? (typeof coords.y === "number" ? "y" : typeof coords.x === "number" ? "x" : null);
46276
+ if (!axis) return void 0;
46277
+ const index2 = axis === "y" ? coords.y : coords.x;
46278
+ if (typeof index2 !== "number") return void 0;
46279
+ const rows = this.getByPath(this.rawData, `$.${tableKey}`);
46280
+ if (!Array.isArray(rows) || !rows[index2]) return void 0;
46281
+ return this.getFieldFromRow(rows[index2], fieldPath);
46282
+ }
46283
+ set2DByCoords(path2, value, coords, source) {
46284
+ const parsed = this.parse2DPath(path2);
46285
+ if (!parsed) return false;
46286
+ const { tableKey, fieldPath } = parsed;
46287
+ if (tableKey.includes(":")) {
46288
+ const [yTableKey = "", xTableKey = ""] = tableKey.split(":");
46289
+ if (!yTableKey || !xTableKey) return false;
46290
+ if (typeof coords.y !== "number" || typeof coords.x !== "number") return false;
46291
+ const yRow = this.ensureAxisRowAndUid(yTableKey, coords.y, "y");
46292
+ const xRow = this.ensureAxisRowAndUid(xTableKey, coords.x, "x");
46293
+ const yUid = yRow.__gw_y_uid;
46294
+ const xUid = xRow.__gw_x_uid;
46295
+ if (!yUid || !xUid) return false;
46296
+ const crossPath = `$.${tableKey}`;
46297
+ const oldValue2 = this.deepClone(this.getByPath(this.rawData, crossPath));
46298
+ let rows = this.getByPath(this.rawData, crossPath);
46299
+ if (!Array.isArray(rows)) {
46300
+ rows = [];
46301
+ this.setByPath(this.rawData, crossPath, rows);
46302
+ }
46303
+ let row2 = rows.find((item) => item?.__gw_y_uid === yUid && item?.__gw_x_uid === xUid);
46304
+ if (!row2) {
46305
+ row2 = { __gw_y_uid: yUid, __gw_x_uid: xUid };
46306
+ rows.push(row2);
46307
+ }
46308
+ this.assignField(row2, fieldPath, value);
46309
+ this.emit(crossPath, this.getByPath(this.rawData, crossPath), oldValue2, source);
45743
46310
  return true;
45744
- } catch (error) {
45745
- console.error(`Failed to set value at path "${path2}":`, error);
45746
- return false;
45747
46311
  }
46312
+ const axisInfo = this.resolveAxisByTableKey(tableKey);
46313
+ const axis = axisInfo?.axis ?? (typeof coords.y === "number" ? "y" : typeof coords.x === "number" ? "x" : null);
46314
+ if (!axis) return false;
46315
+ const index2 = axis === "y" ? coords.y : coords.x;
46316
+ if (typeof index2 !== "number") return false;
46317
+ const tablePath = `$.${tableKey}`;
46318
+ const oldValue = this.deepClone(this.getByPath(this.rawData, tablePath));
46319
+ const row = this.ensureAxisRowAndUid(tableKey, index2, axis);
46320
+ this.assignField(row, fieldPath, value);
46321
+ this.emit(tablePath, this.getByPath(this.rawData, tablePath), oldValue, source);
46322
+ return true;
46323
+ }
46324
+ cleanupCrossByAxisUid(tableKey, axis, uid) {
46325
+ if (!uid) return;
46326
+ const uidField = axis === "y" ? "__gw_y_uid" : "__gw_x_uid";
46327
+ this.getCrossKeys().forEach((crossKey) => {
46328
+ const [yKey, xKey] = crossKey.split(":");
46329
+ const matched = (axis === "y" ? yKey : xKey) === tableKey;
46330
+ if (!matched) return;
46331
+ const path2 = `$.${crossKey}`;
46332
+ const rows = this.getByPath(this.rawData, path2);
46333
+ if (!Array.isArray(rows)) return;
46334
+ const oldValue = this.deepClone(rows);
46335
+ const next = rows.filter((item) => item?.[uidField] !== uid);
46336
+ this.setByPath(this.rawData, path2, next);
46337
+ this.emit(path2, next, oldValue);
46338
+ });
45748
46339
  }
45749
46340
  /**
45750
46341
  * 将一个部分值对象合进整体
@@ -45812,8 +46403,15 @@ class DataManager {
45812
46403
  this.set(path2, arr);
45813
46404
  }
45814
46405
  const oldValue = [...arr];
46406
+ const tableKey = path2.replace(/^\$\./, "").replace(/\[(n|\d+)\]/g, "");
46407
+ const axisInfo = this.resolveAxisByTableKey(tableKey);
45815
46408
  values.forEach((value) => {
45816
- arr.push(this.deepClone(value));
46409
+ const cloned = this.deepClone(value);
46410
+ arr.push(cloned);
46411
+ if (axisInfo) {
46412
+ const index2 = arr.length - 1;
46413
+ this.ensureAxisRowAndUid(tableKey, index2, axisInfo.axis);
46414
+ }
45817
46415
  });
45818
46416
  this.emit(path2, arr, oldValue);
45819
46417
  return true;
@@ -45836,6 +46434,12 @@ class DataManager {
45836
46434
  const oldValue = [...arr];
45837
46435
  const poppedValue = arr.pop();
45838
46436
  this.emit(path2, arr, oldValue);
46437
+ const tableKey = path2.replace(/^\$\./, "").replace(/\[(n|\d+)\]/g, "");
46438
+ const axisInfo = this.resolveAxisByTableKey(tableKey);
46439
+ if (axisInfo) {
46440
+ const uidField = axisInfo.axis === "y" ? "__gw_y_uid" : "__gw_x_uid";
46441
+ this.cleanupCrossByAxisUid(tableKey, axisInfo.axis, poppedValue?.[uidField]);
46442
+ }
45839
46443
  return poppedValue;
45840
46444
  } catch (error) {
45841
46445
  console.error(`Failed to pop value at path "${path2}":`, error);
@@ -45865,6 +46469,13 @@ class DataManager {
45865
46469
  const oldValue = [...arr];
45866
46470
  const clonedValues = values.map((value) => this.deepClone(value));
45867
46471
  arr.splice(index2, 0, ...clonedValues);
46472
+ const tableKey = path2.replace(/^\$\./, "").replace(/\[(n|\d+)\]/g, "");
46473
+ const axisInfo = this.resolveAxisByTableKey(tableKey);
46474
+ if (axisInfo) {
46475
+ for (let i = index2; i < arr.length; i++) {
46476
+ this.ensureAxisRowAndUid(tableKey, i, axisInfo.axis);
46477
+ }
46478
+ }
45868
46479
  this.emit(path2, arr, oldValue);
45869
46480
  return true;
45870
46481
  } catch (error) {
@@ -45890,6 +46501,12 @@ class DataManager {
45890
46501
  const oldValue = [...arr];
45891
46502
  const removedValue = arr.splice(index2, 1)[0];
45892
46503
  this.emit(path2, arr, oldValue);
46504
+ const tableKey = path2.replace(/^\$\./, "").replace(/\[(n|\d+)\]/g, "");
46505
+ const axisInfo = this.resolveAxisByTableKey(tableKey);
46506
+ if (axisInfo) {
46507
+ const uidField = axisInfo.axis === "y" ? "__gw_y_uid" : "__gw_x_uid";
46508
+ this.cleanupCrossByAxisUid(tableKey, axisInfo.axis, removedValue?.[uidField]);
46509
+ }
45893
46510
  return removedValue;
45894
46511
  } catch (error) {
45895
46512
  console.error(`Failed to remove value at path "${path2}":`, error);
@@ -45947,7 +46564,9 @@ class DataManager {
45947
46564
  const existing = this.getByPath(this.rawData, path2);
45948
46565
  if (existing === void 0 || existing === null) {
45949
46566
  try {
45950
- this.setByPath(this.rawData, path2, value);
46567
+ if (!this.set(path2, value, "user")) {
46568
+ console.warn(`applyInitData: set returned false for path "${path2}"`);
46569
+ }
45951
46570
  } catch (e) {
45952
46571
  console.warn(`applyInitData: failed to set path "${path2}"`, e);
45953
46572
  }
@@ -45968,7 +46587,9 @@ class DataManager {
45968
46587
  const existing = this.getByPath(this.rawData, realPath);
45969
46588
  if (existing === void 0 || existing === null) {
45970
46589
  try {
45971
- this.setByPath(this.rawData, realPath, value);
46590
+ if (!this.set(realPath, value, "user")) {
46591
+ console.warn(`applyInitData: set returned false for path "${realPath}"`);
46592
+ }
45972
46593
  } catch (e) {
45973
46594
  console.warn(`applyInitData: failed to set path "${realPath}"`, e);
45974
46595
  }
@@ -46095,7 +46716,7 @@ class DataManager {
46095
46716
  if (current.startsWith(".")) {
46096
46717
  current = current.substring(1);
46097
46718
  }
46098
- const regex = /([a-zA-Z_$][a-zA-Z0-9_$]*)|\.([a-zA-Z_$][a-zA-Z0-9_$]*)|\.?(\[(\d+)\])/g;
46719
+ const regex = /([a-zA-Z_$][a-zA-Z0-9_$:]*)|\.([a-zA-Z_$][a-zA-Z0-9_$:]*)|\.?(\[(\d+)\])/g;
46099
46720
  let match;
46100
46721
  while ((match = regex.exec(current)) !== null) {
46101
46722
  if (match[1]) {
@@ -48441,19 +49062,21 @@ class DocModel {
48441
49062
  };
48442
49063
  });
48443
49064
  const table2DRegions = tables.filter((w2) => w2.has2DTable).flatMap((w2) => w2._2DTable).map((item) => {
48444
- const region = parseLinkFieldExpression(item.valuePath);
49065
+ const parsed = parseValuePath(item.valuePath);
49066
+ const subFieldKey = parsed.isLink ? parsed.parentFieldKey ?? "" : parsed.fieldKey;
49067
+ const linkFieldKey = parsed.linkFieldKey ?? "";
48445
49068
  const result = [];
48446
- if (region.subFieldKey) {
49069
+ if (subFieldKey) {
48447
49070
  result.push({
48448
- field: region.subFieldKey,
49071
+ field: subFieldKey,
48449
49072
  key: "dyn",
48450
49073
  name: "二维表",
48451
49074
  subType: "sub-table-2d"
48452
49075
  });
48453
49076
  }
48454
- if (region.linkFieldKey) {
49077
+ if (linkFieldKey) {
48455
49078
  result.push({
48456
- field: region.linkFieldKey,
49079
+ field: linkFieldKey,
48457
49080
  key: "newfixed",
48458
49081
  name: "二维表-关联",
48459
49082
  subType: "sub-table-2d-link"
@@ -48462,19 +49085,21 @@ class DocModel {
48462
49085
  return result;
48463
49086
  }).flat();
48464
49087
  const checkTableRegions = tables.filter((w2) => w2.hasCheckTable).flatMap((w2) => w2.checkTable).map((item) => {
48465
- const region = parseLinkFieldExpression(item.valuePath);
49088
+ const parsed = parseValuePath(item.valuePath);
49089
+ const subFieldKey = parsed.isLink ? parsed.parentFieldKey ?? "" : parsed.fieldKey;
49090
+ const linkFieldKey = parsed.linkFieldKey ?? "";
48466
49091
  const result = [];
48467
- if (region.subFieldKey) {
49092
+ if (subFieldKey) {
48468
49093
  result.push({
48469
- field: region.subFieldKey,
49094
+ field: subFieldKey,
48470
49095
  key: "newfixed",
48471
49096
  name: "检验表-动态",
48472
49097
  subType: "check-table-2d"
48473
49098
  });
48474
49099
  }
48475
- if (region.linkFieldKey) {
49100
+ if (linkFieldKey) {
48476
49101
  result.push({
48477
- field: region.linkFieldKey,
49102
+ field: linkFieldKey,
48478
49103
  key: "newfixed",
48479
49104
  name: "检验表-关联",
48480
49105
  subType: "check-table-2d-link"
@@ -52496,12 +53121,20 @@ const DROPDOWN_TYPES = /* @__PURE__ */ new Set([
52496
53121
  "fw:rdo-table-select"
52497
53122
  ]);
52498
53123
  const DIALOG_TYPES = /* @__PURE__ */ new Set(["fw:signature", "fw:image", "fw:file"]);
53124
+ function useMetaFromWidget(widget, metaKey) {
53125
+ const meta = computed(() => widget?.[metaKey] ?? {});
53126
+ const props = computed(() => meta.value.props ?? {});
53127
+ const widgetType = computed(() => meta.value.type);
53128
+ return { meta, props, widgetType };
53129
+ }
52499
53130
  function useWidgetMeta(widget) {
52500
- const widgetMeta = computed(() => widget?.widgetMeta ?? {});
53131
+ const {
53132
+ meta: widgetMeta,
53133
+ props: widgetProps,
53134
+ widgetType
53135
+ } = useMetaFromWidget(widget, "widgetMeta");
52501
53136
  const fieldMeta = computed(() => widgetMeta.value.field);
52502
- const widgetProps = computed(() => widgetMeta.value.props ?? {});
52503
53137
  const runtimeValuePath = computed(() => widget.valuePath || fieldMeta.value?.valuePath || "");
52504
- const widgetType = computed(() => widgetMeta.value.type);
52505
53138
  const isMultiple = computed(() => MULTIPLE_TYPES.has(widgetType.value));
52506
53139
  const isAsync = computed(() => ASYNC_TYPES.has(widgetType.value));
52507
53140
  const isDropdown = computed(() => {
@@ -52523,6 +53156,14 @@ function useWidgetMeta(widget) {
52523
53156
  isDialog
52524
53157
  };
52525
53158
  }
53159
+ function usePaperWidgetMeta(widget) {
53160
+ const {
53161
+ meta: pageWidgetMeta,
53162
+ props: pageWidgetProps,
53163
+ widgetType
53164
+ } = useMetaFromWidget(widget, "pageWidgetMeta");
53165
+ return { pageWidgetMeta, pageWidgetProps, widgetType };
53166
+ }
52526
53167
  function useFieldInfo(fieldMeta) {
52527
53168
  const designCtx = useDesignSuiteContext();
52528
53169
  const field = computed(() => fieldMeta());
@@ -52611,6 +53252,17 @@ function useWidgetStaticAttrs(widget) {
52611
53252
  showDisplayStatus: newDisplayStatus
52612
53253
  };
52613
53254
  }
53255
+ function usePaperWidgetStaticAttrs(widget) {
53256
+ const { docInst, isDesignMode } = useDocPubApiContext();
53257
+ const { pageWidgetMeta, pageWidgetProps, widgetType } = usePaperWidgetMeta(widget);
53258
+ return {
53259
+ docInst,
53260
+ isDesignMode,
53261
+ pageWidgetMeta,
53262
+ pageWidgetProps,
53263
+ widgetType
53264
+ };
53265
+ }
52614
53266
  const _hoisted_1$1U = { class: "dropdown-container" };
52615
53267
  const _sfc_main$2S = /* @__PURE__ */ defineComponent({
52616
53268
  __name: "dropdown-container",
@@ -52666,7 +53318,7 @@ const _sfc_main$2S = /* @__PURE__ */ defineComponent({
52666
53318
  };
52667
53319
  }
52668
53320
  });
52669
- const DropdownContainer = /* @__PURE__ */ _export_sfc(_sfc_main$2S, [["__scopeId", "data-v-730f825e"]]);
53321
+ const DropdownContainer = /* @__PURE__ */ _export_sfc(_sfc_main$2S, [["__scopeId", "data-v-c9c3a05b"]]);
52670
53322
  const _hoisted_1$1T = { class: "dialog-container" };
52671
53323
  const _sfc_main$2R = /* @__PURE__ */ defineComponent({
52672
53324
  __name: "dialog-container",
@@ -54351,7 +55003,7 @@ const _sfc_main$2Q = /* @__PURE__ */ defineComponent({
54351
55003
  };
54352
55004
  }
54353
55005
  });
54354
- const OverlayRender = /* @__PURE__ */ _export_sfc(_sfc_main$2Q, [["__scopeId", "data-v-7e8fe8f4"]]);
55006
+ const OverlayRender = /* @__PURE__ */ _export_sfc(_sfc_main$2Q, [["__scopeId", "data-v-1d10a573"]]);
54355
55007
  let activeHoverId = 0;
54356
55008
  function useHoverDelay(callback, delay = 120) {
54357
55009
  let timer = null;
@@ -55178,217 +55830,6 @@ const builtinComponents = {
55178
55830
  [BuiltinComponentTypeConst.InlineImage]: _sfc_main$2L,
55179
55831
  [BuiltinComponentTypeConst.Text]: _sfc_main$2K
55180
55832
  };
55181
- const OUTLINE_BORDER_INSET = 1;
55182
- const borderConfig = {
55183
- outer: {
55184
- color: "rgb(128, 128, 128)",
55185
- width: 1
55186
- },
55187
- inner: {
55188
- color: "rgb(128, 128, 128)",
55189
- width: 1
55190
- },
55191
- guide: {
55192
- color: "#026AC8",
55193
- width: 2
55194
- }
55195
- };
55196
- const subThemeConfig = {
55197
- "fixed-table": {
55198
- label: "固定表",
55199
- color: "#309C41",
55200
- background: "rgba(48,156,65,0.1)",
55201
- labelBjColor: "rgba(48,156,65,0.8)"
55202
- },
55203
- "check-table": {
55204
- label: "检验表",
55205
- color: "#309C41",
55206
- background: "rgba(48,156,65,0.1)",
55207
- labelBjColor: "rgba(48,156,65,0.8)"
55208
- },
55209
- "dynamic-table": {
55210
- label: "动态表",
55211
- color: "#026AC8",
55212
- background: "rgba(2,106,200,0.1)",
55213
- labelBjColor: "rgba(2,106,200,0.8)"
55214
- },
55215
- "2d-table": {
55216
- label: "二维表",
55217
- color: "#026AC8",
55218
- background: "rgba(2,106,200,0.1)",
55219
- labelBjColor: "rgba(2,106,200,0.8)"
55220
- },
55221
- "table-header": {
55222
- label: "表头",
55223
- color: "rgba(245, 69, 71, 1)",
55224
- background: "rgba(245, 69, 71, 0.1)",
55225
- labelBjColor: "rgba(245, 69, 71, 0.8)"
55226
- },
55227
- "data-group": {
55228
- label: "数据分组",
55229
- color: "#F77E4A",
55230
- background: "rgba(247,126,74,0.1)",
55231
- labelBjColor: "rgba(247,126,74,0.8)"
55232
- },
55233
- "data-group-2d": {
55234
- label: "动态关联",
55235
- color: "#F77E4A",
55236
- background: "rgba(247,126,74,0.1)",
55237
- labelBjColor: "rgba(247,126,74,0.8)"
55238
- }
55239
- };
55240
- const getStyleByType = (type4) => {
55241
- const config = subThemeConfig[type4];
55242
- return {
55243
- strokeColor: config?.color || "#000",
55244
- backgroundColor: config?.background || "transparent",
55245
- label: config?.label || "",
55246
- labelBjColor: config?.labelBjColor || "#666"
55247
- };
55248
- };
55249
- const EPS = 1e-3;
55250
- function clipHLineByMerges(line, merges) {
55251
- let segments = [line];
55252
- merges.forEach((rect) => {
55253
- segments = segments.flatMap((seg) => {
55254
- const insideY = seg.y > rect.y + EPS && seg.y < rect.y + rect.height - EPS;
55255
- if (!insideY) return [seg];
55256
- if (seg.x2 <= rect.x + EPS || seg.x1 >= rect.x + rect.width - EPS) return [seg];
55257
- if (rect.x <= seg.x1 + EPS && rect.x + rect.width >= seg.x2 - EPS) return [];
55258
- const res = [];
55259
- if (seg.x1 < rect.x - EPS) res.push({ ...seg, x2: rect.x });
55260
- if (seg.x2 > rect.x + rect.width + EPS) res.push({ ...seg, x1: rect.x + rect.width });
55261
- return res;
55262
- });
55263
- });
55264
- return segments;
55265
- }
55266
- function clipVLineByMerges(line, merges) {
55267
- let segments = [line];
55268
- merges.forEach((rect) => {
55269
- segments = segments.flatMap((seg) => {
55270
- const insideX = seg.x > rect.x + EPS && seg.x < rect.x + rect.width - EPS;
55271
- if (!insideX) return [seg];
55272
- if (seg.y2 <= rect.y + EPS || seg.y1 >= rect.y + rect.height - EPS) return [seg];
55273
- if (rect.y <= seg.y1 + EPS && rect.y + rect.height >= seg.y2 - EPS) return [];
55274
- const res = [];
55275
- if (seg.y1 < rect.y - EPS) res.push({ ...seg, y2: rect.y });
55276
- if (seg.y2 > rect.y + rect.height + EPS) res.push({ ...seg, y1: rect.y + rect.height });
55277
- return res;
55278
- });
55279
- });
55280
- return segments;
55281
- }
55282
- function createTableOutlineLayer(options) {
55283
- const { cells, inset = 1 } = options;
55284
- if (!cells.length) return { backgroundRect: null, hLines: [], vLines: [], labelPos: void 0 };
55285
- const minX = Math.min(...cells.map((c2) => c2.x));
55286
- const minY = Math.min(...cells.map((c2) => c2.y));
55287
- const maxX = Math.max(...cells.map((c2) => c2.x + c2.width));
55288
- const maxY = Math.max(...cells.map((c2) => c2.y + c2.height));
55289
- const minLY = Math.min(...cells.map((c2) => c2.layoutY));
55290
- const maxLX = Math.max(...cells.map((c2) => c2.layoutX + c2.width));
55291
- const maxLY = Math.max(...cells.map((c2) => c2.layoutY + c2.height));
55292
- const backgroundRect = {
55293
- x: minX + inset,
55294
- y: minY + inset,
55295
- width: maxX - minX - inset * 2,
55296
- height: maxY - minY - inset * 2
55297
- };
55298
- const hLines = [
55299
- { x1: minX + inset, x2: maxX - inset, y: minY + inset },
55300
- // top
55301
- { x1: minX + inset, x2: maxX - inset, y: maxY - inset }
55302
- // bottom
55303
- ];
55304
- const vLines = [
55305
- { x: minX + inset, y1: minY + inset, y2: maxY - inset },
55306
- // left
55307
- { x: maxX - inset, y1: minY + inset, y2: maxY - inset }
55308
- // right
55309
- ];
55310
- const labelPos = { x: maxLX - inset, y1: minLY + inset, y2: maxLY - inset };
55311
- return { backgroundRect, hLines, vLines, labelPos };
55312
- }
55313
- const accumulate = (list) => {
55314
- const result = [0];
55315
- let acc = 0;
55316
- for (const n of list) {
55317
- acc += n;
55318
- result.push(acc);
55319
- }
55320
- return result;
55321
- };
55322
- const inRange = (n, min, max) => n > min && n < max;
55323
- function mapCellsToOutlineCells(cells) {
55324
- return cells.map((c2) => ({
55325
- x: c2.x,
55326
- y: c2.rowY,
55327
- layoutX: c2.layoutX,
55328
- layoutY: c2.layoutY,
55329
- width: c2.width,
55330
- height: c2.height
55331
- }));
55332
- }
55333
- function groupBy(list, getKey) {
55334
- return list.reduce((acc, item) => {
55335
- const key = getKey(item);
55336
- (acc[key] ||= []).push(item);
55337
- return acc;
55338
- }, {});
55339
- }
55340
- function buildPosMap(layers, getRect, toDom) {
55341
- const res = {};
55342
- for (const [id, layer] of Object.entries(layers)) {
55343
- const rect = getRect(layer);
55344
- if (!rect) continue;
55345
- const pos = toDom(rect);
55346
- if (pos) res[id] = pos;
55347
- }
55348
- return res;
55349
- }
55350
- function getDataIndexLayersMap({
55351
- type: type4,
55352
- cells,
55353
- isEdit,
55354
- convertExtraProps
55355
- }) {
55356
- const getDataIndex = (cell) => {
55357
- return type4 === "2d-table" && isEdit ? cell.subRenderer?.xDataIndex : cell.subRenderer?.dataIndex;
55358
- };
55359
- const _cells = cells.filter(
55360
- (cell) => getDataIndex(cell) != null && cell?.subRenderer?.type === type4
55361
- );
55362
- if (!_cells.length) return {};
55363
- const grouped = groupBy(
55364
- _cells,
55365
- (cell) => `${cell.subRenderer.id}_dataIndex${getDataIndex(cell)}`
55366
- );
55367
- const layersMapEntries = Object.entries(grouped).map(([id, __cells]) => {
55368
- const firstCell = __cells[0];
55369
- const lastCell = __cells[__cells.length - 1];
55370
- const isFirstDataGroup = getDataIndex(firstCell) === 0;
55371
- const bgLayer = createTableOutlineLayer({
55372
- cells: mapCellsToOutlineCells(__cells),
55373
- inset: 4
55374
- });
55375
- const borderLayer = isFirstDataGroup ? createTableOutlineLayer({
55376
- cells: mapCellsToOutlineCells(__cells),
55377
- inset: OUTLINE_BORDER_INSET
55378
- }) : { hLines: [], vLines: [], backgroundRect: null, labelPos: void 0 };
55379
- return [
55380
- id,
55381
- {
55382
- ...borderLayer,
55383
- ...convertExtraProps(firstCell),
55384
- showBorder: isFirstDataGroup,
55385
- placeholderBjRect: bgLayer.backgroundRect,
55386
- lastCell
55387
- }
55388
- ];
55389
- });
55390
- return Object.fromEntries(layersMapEntries);
55391
- }
55392
55833
  const baseCanvasAttrs = {
55393
55834
  /** 不参与事件命中检测 */
55394
55835
  listening: false,
@@ -55699,49 +56140,6 @@ const _sfc_main$2D = /* @__PURE__ */ defineComponent({
55699
56140
  }))
55700
56141
  )
55701
56142
  );
55702
- const dataGroup2DCells = computed(() => {
55703
- const dataGroup2DList = [];
55704
- const cells = [];
55705
- props.rows.flatMap((row) => row.cells).filter((cell) => cell?.subRenderer?.id && ["check-table", "2d-table"].includes(cell.subRenderer.type)).forEach((cell) => {
55706
- if (dataGroup2DList.find((o) => o.subTableId === cell.subRenderer.id)) return;
55707
- dataGroup2DList.push({
55708
- subTableId: cell.subRenderer.id,
55709
- subTableType: cell.subRenderer.type,
55710
- subTableValuePath: cell.subRenderer.valuePath,
55711
- dataGroup2DAreaRange: cell.subRenderer?.dataGroup2DAreaRange
55712
- });
55713
- });
55714
- dataGroup2DList.forEach(({ subTableId, subTableType, subTableValuePath, dataGroup2DAreaRange }) => {
55715
- if (!dataGroup2DAreaRange?.start) return;
55716
- const {
55717
- start: { row: startRow, col: startCol },
55718
- end: { row: endRow, col: endCol }
55719
- } = dataGroup2DAreaRange;
55720
- props.rows.forEach((row, rowIndex) => {
55721
- row.cells.forEach((cell, colIndex) => {
55722
- const isInRange = rowIndex >= startRow && rowIndex <= endRow && colIndex >= startCol && colIndex <= endCol;
55723
- if (isInRange) {
55724
- const fakeDataIndex = colIndex - dataGroup2DAreaRange.start.col;
55725
- cells.push({
55726
- ...cell,
55727
- rowY: row.y,
55728
- layoutY: row.layoutY,
55729
- // 伪造动态关联的 subRenderer
55730
- subRenderer: {
55731
- id: subTableId,
55732
- type: subTableType,
55733
- valuePath: subTableValuePath,
55734
- dataIndex: fakeDataIndex,
55735
- xDataIndex: fakeDataIndex
55736
- }
55737
- });
55738
- }
55739
- });
55740
- });
55741
- });
55742
- const uniqueCells = Object.values(groupBy(cells, (c2) => c2.id)).map((cells2) => cells2[0]).filter(Boolean);
55743
- return uniqueCells;
55744
- });
55745
56143
  const pageBaseOffset = computed(() => {
55746
56144
  const node = props.doc.layoutMapper.getBaseMetaNodeById(tableId.value);
55747
56145
  if (!node) return null;
@@ -55753,7 +56151,15 @@ const _sfc_main$2D = /* @__PURE__ */ defineComponent({
55753
56151
  };
55754
56152
  });
55755
56153
  const outlineLayers = computed(() => {
55756
- const grouped = groupBy(subTableCells.value, (cell) => cell.subRenderer.id);
56154
+ const filteredCells = subTableCells.value.filter(({ subRenderer }) => {
56155
+ if (subRenderer) {
56156
+ const { type: type4, cellZone } = subRenderer;
56157
+ return getIsDataGroup2DTable(type4) ? getIs2DCellInSubTable(cellZone) : true;
56158
+ } else {
56159
+ return true;
56160
+ }
56161
+ });
56162
+ const grouped = groupBy(filteredCells, (cell) => cell.subRenderer.id);
55757
56163
  return Object.fromEntries(
55758
56164
  Object.entries(grouped).map(([id, cells]) => {
55759
56165
  const outline = createTableOutlineLayer({
@@ -55775,7 +56181,7 @@ const _sfc_main$2D = /* @__PURE__ */ defineComponent({
55775
56181
  () => getDataIndexLayersMap({
55776
56182
  type: "fixed-table",
55777
56183
  cells: subTableCells.value,
55778
- isEdit: props.doc.mode === DocModeTypeConst.Edit,
56184
+ isDesign: true,
55779
56185
  convertExtraProps: (cell) => ({
55780
56186
  type: "data-group",
55781
56187
  valuePath: cell.subRenderer.valuePath,
@@ -55786,8 +56192,8 @@ const _sfc_main$2D = /* @__PURE__ */ defineComponent({
55786
56192
  const checkTableDataGroup2DLayersMap = computed(
55787
56193
  () => getDataIndexLayersMap({
55788
56194
  type: "check-table",
55789
- cells: dataGroup2DCells.value,
55790
- isEdit: props.doc.mode === DocModeTypeConst.Edit,
56195
+ cells: subTableCells.value,
56196
+ isDesign: true,
55791
56197
  convertExtraProps: (cell) => ({
55792
56198
  type: "data-group-2d",
55793
56199
  valuePath: cell.subRenderer.valuePath,
@@ -55798,8 +56204,8 @@ const _sfc_main$2D = /* @__PURE__ */ defineComponent({
55798
56204
  const _2DTableDataGroup2DLayersMap = computed(
55799
56205
  () => getDataIndexLayersMap({
55800
56206
  type: "2d-table",
55801
- cells: dataGroup2DCells.value,
55802
- isEdit: props.doc.mode === DocModeTypeConst.Edit,
56207
+ cells: subTableCells.value,
56208
+ isDesign: true,
55803
56209
  convertExtraProps: (cell) => ({
55804
56210
  type: "data-group-2d",
55805
56211
  valuePath: cell.subRenderer.valuePath,
@@ -56633,10 +57039,10 @@ const _sfc_main$2y = /* @__PURE__ */ defineComponent({
56633
57039
  downRowNum: 1
56634
57040
  });
56635
57041
  const getCtx = () => {
56636
- const { subRenderer } = props.cell;
57042
+ const { valuePath, dataIndex, yDataIndex } = props.cell.subRenderer;
56637
57043
  return {
56638
- path: subRenderer.valuePath,
56639
- index: subRenderer.dataIndex
57044
+ path: valuePath,
57045
+ index: dataIndex ?? yDataIndex ?? 0
56640
57046
  };
56641
57047
  };
56642
57048
  const readonly2 = computed(() => {
@@ -56800,7 +57206,7 @@ const _sfc_main$2y = /* @__PURE__ */ defineComponent({
56800
57206
  };
56801
57207
  }
56802
57208
  });
56803
- const SubTableAction = /* @__PURE__ */ _export_sfc(_sfc_main$2y, [["__scopeId", "data-v-adc8fb9a"]]);
57209
+ const SubTableAction = /* @__PURE__ */ _export_sfc(_sfc_main$2y, [["__scopeId", "data-v-e2cc91ff"]]);
56804
57210
  const _sfc_main$2x = /* @__PURE__ */ defineComponent({
56805
57211
  __name: "index",
56806
57212
  props: {
@@ -56844,7 +57250,7 @@ const _sfc_main$2x = /* @__PURE__ */ defineComponent({
56844
57250
  return getDataIndexLayersMap({
56845
57251
  type: type4,
56846
57252
  cells: subTableCells.value,
56847
- isEdit: props.doc.mode === DocModeTypeConst.Edit,
57253
+ isDesign: false,
56848
57254
  convertExtraProps: () => ({
56849
57255
  type: type4,
56850
57256
  placeholder: "",
@@ -59215,8 +59621,10 @@ const _sfc_main$2l = /* @__PURE__ */ defineComponent({
59215
59621
  }[type4];
59216
59622
  const usedSubModelKeys = (docInst.value.model?.document.body.children || []).map((w2) => {
59217
59623
  if (w2.name === "w:tbl" && (w2.hasBounded || w2.hasCheckTable || w2.hasRepeating || w2.has2DTable)) {
59218
- const subInfoList = [...w2.bounded, ...w2.checkTable, ...w2.repeating, ...w2._2DTable];
59219
- return subInfoList.map((info) => info.valuePath.replace("$.", ""));
59624
+ const subTableRegions = [...w2.bounded, ...w2.checkTable, ...w2.repeating, ...w2._2DTable];
59625
+ return subTableRegions.flatMap((region) => {
59626
+ return region.valuePath.replace("$.", "").split(":");
59627
+ });
59220
59628
  } else {
59221
59629
  return [];
59222
59630
  }
@@ -59545,7 +59953,7 @@ const _sfc_main$2l = /* @__PURE__ */ defineComponent({
59545
59953
  };
59546
59954
  }
59547
59955
  });
59548
- const WordTable = /* @__PURE__ */ _export_sfc(_sfc_main$2l, [["__scopeId", "data-v-880a7ed3"]]);
59956
+ const WordTable = /* @__PURE__ */ _export_sfc(_sfc_main$2l, [["__scopeId", "data-v-77cd5ff0"]]);
59549
59957
  const _hoisted_1$1F = { class: "ribbon" };
59550
59958
  const _hoisted_2$14 = { class: "ribbon-content-wrapper" };
59551
59959
  const _sfc_main$2k = /* @__PURE__ */ defineComponent({
@@ -59735,17 +60143,24 @@ function useHighlightSearch() {
59735
60143
  highlightName
59736
60144
  };
59737
60145
  }
59738
- function createDesignFieldToWidgetFactory(getFieldManifest) {
60146
+ function buildPaletteExtra(manifest2, label, opts) {
60147
+ return {
60148
+ extensions: manifest2.extensions,
60149
+ biz: {
60150
+ fromField: true,
60151
+ source: opts.source ?? "palette",
60152
+ fieldIdentity: { label }
60153
+ }
60154
+ };
60155
+ }
60156
+ function createDesignFieldToWidgetFactory(getManifest) {
59739
60157
  return function createWidgetFromField(field, opts = {}) {
59740
- const manifest2 = getFieldManifest(field.type);
60158
+ const manifest2 = getManifest(field.type);
59741
60159
  const valuePath = generateValuePath(field.key, opts.parentFieldKey || "");
59742
60160
  return {
59743
60161
  id: uuid(),
59744
60162
  type: manifest2.component,
59745
- layout: {
59746
- width: 70,
59747
- height: 18
59748
- },
60163
+ layout: { width: 70, height: 18 },
59749
60164
  props: {
59750
60165
  ...manifest2.defaultProps ?? {},
59751
60166
  ...opts.overrideProps ?? {}
@@ -59766,16 +60181,31 @@ function createDesignFieldToWidgetFactory(getFieldManifest) {
59766
60181
  valuePath,
59767
60182
  ...opts.parentFieldKey ? { subFieldKey: opts.parentFieldKey } : void 0
59768
60183
  },
59769
- extra: {
59770
- extensions: manifest2.extensions,
59771
- biz: {
59772
- fromField: true,
59773
- source: opts.source ?? "palette",
59774
- fieldIdentity: {
59775
- label: field.name
59776
- }
59777
- }
59778
- }
60184
+ extra: buildPaletteExtra(manifest2, field.name, opts)
60185
+ };
60186
+ };
60187
+ }
60188
+ function createDesignPaperWidgetToWidgetFactory(getManifest) {
60189
+ return function createWidgetFromPaperWidget(widget, opts = {}) {
60190
+ const manifest2 = getManifest(widget.type);
60191
+ return {
60192
+ id: uuid(),
60193
+ type: manifest2.component,
60194
+ layout: manifest2.defaultLayout || {},
60195
+ props: {
60196
+ ...manifest2.defaultProps ?? {},
60197
+ ...opts.overrideProps ?? {}
60198
+ },
60199
+ behavior: {
60200
+ draggable: manifest2.allowDrag,
60201
+ resizable: false,
60202
+ copyable: false,
60203
+ removable: false,
60204
+ droppable: false,
60205
+ outOfFlow: !!manifest2.outOfFlow
60206
+ },
60207
+ widget: { widgetType: widget.type },
60208
+ extra: buildPaletteExtra(manifest2, widget.name, opts)
59779
60209
  };
59780
60210
  };
59781
60211
  }
@@ -59802,19 +60232,18 @@ const _sfc_main$2i = /* @__PURE__ */ defineComponent({
59802
60232
  const { keyword, highlightName } = useHighlightSearch();
59803
60233
  const createFieldToWidget = createDesignFieldToWidgetFactory(designCtx.getFieldManifest);
59804
60234
  const subFieldKey = computed(() => {
59805
- if (!interCtx.panelData) return "";
60235
+ if (!interCtx.panelData?.context?.subFieldKey) return "";
59806
60236
  return getLastSegment(interCtx.panelData.context.subFieldKey);
59807
60237
  });
59808
60238
  const modelKey = computed(() => {
59809
60239
  if (!interCtx.panelData) return "";
59810
- const mainModelKey = interCtx.panelData.context.mainModelKey;
60240
+ const { mainModelKey, isDataGroup2DClicked } = interCtx.panelData.context;
59811
60241
  if (!mainModelKey) return "";
59812
60242
  const fullSubKey = subFieldKey.value;
59813
60243
  if (fullSubKey) {
59814
60244
  let singleSubKey = fullSubKey;
59815
60245
  if (fullSubKey.includes(":")) {
59816
- const keyIndex = interCtx.panelData.context.isDataGroup2DClicked ? 1 : 0;
59817
- singleSubKey = fullSubKey.split(":")[keyIndex];
60246
+ singleSubKey = fullSubKey.split(":")[isDataGroup2DClicked ? 1 : 0];
59818
60247
  }
59819
60248
  const field = designCtx.runtime.getFieldList(mainModelKey)?.find((f) => f.key === singleSubKey);
59820
60249
  return field?.bindInfo ?? "";
@@ -59929,42 +60358,7 @@ const _sfc_main$2i = /* @__PURE__ */ defineComponent({
59929
60358
  };
59930
60359
  }
59931
60360
  });
59932
- const ToolkitContentFields = /* @__PURE__ */ _export_sfc(_sfc_main$2i, [["__scopeId", "data-v-3fbe453b"]]);
59933
- function createDesignPaperWidgetToWidgetFactory(getPaperWidgetManifest) {
59934
- return function(widget, opts = {}) {
59935
- const manifest2 = getPaperWidgetManifest(widget.type);
59936
- return {
59937
- id: uuid(),
59938
- type: manifest2.component,
59939
- layout: manifest2.defaultLayout || {},
59940
- props: {
59941
- ...manifest2.defaultProps ?? {},
59942
- ...opts.overrideProps ?? {}
59943
- },
59944
- behavior: {
59945
- draggable: manifest2.allowDrag,
59946
- resizable: false,
59947
- copyable: false,
59948
- removable: false,
59949
- droppable: false,
59950
- outOfFlow: !!manifest2.outOfFlow
59951
- },
59952
- widget: {
59953
- widgetType: widget.type
59954
- },
59955
- extra: {
59956
- extensions: manifest2.extensions,
59957
- biz: {
59958
- fromField: true,
59959
- source: opts.source ?? "palette",
59960
- fieldIdentity: {
59961
- label: widget.name
59962
- }
59963
- }
59964
- }
59965
- };
59966
- };
59967
- }
60361
+ const ToolkitContentFields = /* @__PURE__ */ _export_sfc(_sfc_main$2i, [["__scopeId", "data-v-2e5d2168"]]);
59968
60362
  const _hoisted_1$1C = { class: "toolkit-content-widgets" };
59969
60363
  const _hoisted_2$11 = { key: 0 };
59970
60364
  const _hoisted_3$M = ["data-type", "draggable", "onDragstart"];
@@ -60014,7 +60408,7 @@ const _sfc_main$2h = /* @__PURE__ */ defineComponent({
60014
60408
  };
60015
60409
  }
60016
60410
  });
60017
- const ToolkitContentWidgets = /* @__PURE__ */ _export_sfc(_sfc_main$2h, [["__scopeId", "data-v-1e28101c"]]);
60411
+ const ToolkitContentWidgets = /* @__PURE__ */ _export_sfc(_sfc_main$2h, [["__scopeId", "data-v-393cb2aa"]]);
60018
60412
  const _hoisted_1$1B = { class: "designer_toolkit-wrapper" };
60019
60413
  const _sfc_main$2g = /* @__PURE__ */ defineComponent({
60020
60414
  __name: "toolkit",
@@ -61121,7 +61515,7 @@ const _sfc_main$27 = /* @__PURE__ */ defineComponent({
61121
61515
  };
61122
61516
  }
61123
61517
  });
61124
- const ValidationCommentItem = /* @__PURE__ */ _export_sfc(_sfc_main$27, [["__scopeId", "data-v-a4657686"]]);
61518
+ const ValidationCommentItem = /* @__PURE__ */ _export_sfc(_sfc_main$27, [["__scopeId", "data-v-553b2a25"]]);
61125
61519
  const _hoisted_1$1x = {
61126
61520
  key: 0,
61127
61521
  class: "validation-comment-layer"
@@ -65081,27 +65475,6 @@ const __vite_glob_0_7$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.d
65081
65475
  __proto__: null,
65082
65476
  default: _sfc_main$1Q
65083
65477
  }, Symbol.toStringTag, { value: "Module" }));
65084
- function usePaperWidgetMeta(widget) {
65085
- const pageWidgetMeta = computed(() => widget?.pageWidgetMeta ?? {});
65086
- const pageWidgetProps = computed(() => pageWidgetMeta.value.props ?? {});
65087
- const widgetType = computed(() => pageWidgetMeta.value.type);
65088
- return {
65089
- pageWidgetMeta,
65090
- pageWidgetProps,
65091
- widgetType
65092
- };
65093
- }
65094
- function usePaperWidgetStaticAttrs(widget) {
65095
- const { docInst, isDesignMode } = useDocPubApiContext();
65096
- const { pageWidgetMeta, pageWidgetProps, widgetType } = usePaperWidgetMeta(widget);
65097
- return {
65098
- docInst,
65099
- isDesignMode,
65100
- pageWidgetMeta,
65101
- pageWidgetProps,
65102
- widgetType
65103
- };
65104
- }
65105
65478
  const UNIT_WIDTH = 1;
65106
65479
  const _sfc_main$1P = /* @__PURE__ */ defineComponent({
65107
65480
  __name: "pw-barcode-render",
@@ -66723,7 +67096,7 @@ const _sfc_main$1E = /* @__PURE__ */ defineComponent({
66723
67096
  };
66724
67097
  }
66725
67098
  });
66726
- const PaperPanel = /* @__PURE__ */ _export_sfc(_sfc_main$1E, [["__scopeId", "data-v-22c28a0f"]]);
67099
+ const PaperPanel = /* @__PURE__ */ _export_sfc(_sfc_main$1E, [["__scopeId", "data-v-3cf8e3a5"]]);
66727
67100
  const schema$c = {
66728
67101
  key: "paper.basic",
66729
67102
  title: "表单属性",
@@ -66974,7 +67347,7 @@ const _sfc_main$1C = /* @__PURE__ */ defineComponent({
66974
67347
  });
66975
67348
  const isBindDataGroup = withLayoutComputed(() => !!regionRef.value?.itemRegion);
66976
67349
  const modelKey = computed(() => getLastSegment(props.active.context.mainModelKey));
66977
- const fieldKey = computed(() => getLastSegment(regionRef.value?.valuePath));
67350
+ const fieldKey = computed(() => getLastSegment(regionRef.value?.subFieldKey));
66978
67351
  const fieldInfo = computed(() => {
66979
67352
  if (!modelKey.value || !fieldKey.value) return null;
66980
67353
  const list = designCtx.runtime.getFieldList(modelKey.value);
@@ -67080,7 +67453,7 @@ const _sfc_main$1C = /* @__PURE__ */ defineComponent({
67080
67453
  };
67081
67454
  }
67082
67455
  });
67083
- const _2DTablePanel = /* @__PURE__ */ _export_sfc(_sfc_main$1C, [["__scopeId", "data-v-654c8531"]]);
67456
+ const _2DTablePanel = /* @__PURE__ */ _export_sfc(_sfc_main$1C, [["__scopeId", "data-v-7d2be0ce"]]);
67084
67457
  const schema$a = {
67085
67458
  key: "2d-table.basic",
67086
67459
  title: [
@@ -67246,7 +67619,7 @@ const _sfc_main$1A = /* @__PURE__ */ defineComponent({
67246
67619
  });
67247
67620
  const isBindDataGroup = withLayoutComputed(() => !!regionRef.value?.itemRegion);
67248
67621
  const modelKey = computed(() => getLastSegment(props.active.context.mainModelKey));
67249
- const fieldKey = computed(() => getLastSegment(regionRef.value?.valuePath));
67622
+ const fieldKey = computed(() => getLastSegment(regionRef.value?.subFieldKey));
67250
67623
  const fieldInfo = computed(() => {
67251
67624
  if (!modelKey.value || !fieldKey.value) return null;
67252
67625
  const list = designCtx.runtime.getFieldList(modelKey.value);
@@ -67352,7 +67725,7 @@ const _sfc_main$1A = /* @__PURE__ */ defineComponent({
67352
67725
  };
67353
67726
  }
67354
67727
  });
67355
- const CheckTablePanel = /* @__PURE__ */ _export_sfc(_sfc_main$1A, [["__scopeId", "data-v-acfe3e02"]]);
67728
+ const CheckTablePanel = /* @__PURE__ */ _export_sfc(_sfc_main$1A, [["__scopeId", "data-v-5792e4ce"]]);
67356
67729
  const schema$8 = {
67357
67730
  key: "check-table.basic",
67358
67731
  title: [
@@ -75904,7 +76277,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
75904
76277
  };
75905
76278
  }
75906
76279
  });
75907
- const optionDropdown = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["__scopeId", "data-v-acc41a8a"]]);
76280
+ const optionDropdown = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["__scopeId", "data-v-d81082a4"]]);
75908
76281
  const optionDropdown$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
75909
76282
  __proto__: null,
75910
76283
  default: optionDropdown
@@ -76125,7 +76498,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
76125
76498
  };
76126
76499
  }
76127
76500
  });
76128
- const treeDropdown = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["__scopeId", "data-v-2eb67208"]]);
76501
+ const treeDropdown = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["__scopeId", "data-v-4a40a7ac"]]);
76129
76502
  const treeDropdown$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
76130
76503
  __proto__: null,
76131
76504
  default: treeDropdown
@@ -76161,7 +76534,7 @@ const _sfc_main$b = /* @__PURE__ */ defineComponent({
76161
76534
  };
76162
76535
  }
76163
76536
  });
76164
- const datetimeDropdown = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["__scopeId", "data-v-aab79189"]]);
76537
+ const datetimeDropdown = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["__scopeId", "data-v-a395aede"]]);
76165
76538
  const datetimeDropdown$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
76166
76539
  __proto__: null,
76167
76540
  default: datetimeDropdown
@@ -76193,7 +76566,7 @@ const _sfc_main$a = /* @__PURE__ */ defineComponent({
76193
76566
  };
76194
76567
  }
76195
76568
  });
76196
- const timeDropdown = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["__scopeId", "data-v-0875dd7d"]]);
76569
+ const timeDropdown = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["__scopeId", "data-v-b2862e2a"]]);
76197
76570
  const timeDropdown$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
76198
76571
  __proto__: null,
76199
76572
  default: timeDropdown
@@ -77718,7 +78091,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
77718
78091
  };
77719
78092
  }
77720
78093
  });
77721
- const uploadFileDialog = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-e1c998a1"]]);
78094
+ const uploadFileDialog = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-8f81c7bf"]]);
77722
78095
  const uploadFileDialog$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
77723
78096
  __proto__: null,
77724
78097
  default: uploadFileDialog
@@ -78017,7 +78390,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
78017
78390
  };
78018
78391
  }
78019
78392
  });
78020
- const uploadImageDialog = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-65b78b04"]]);
78393
+ const uploadImageDialog = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-a4f2d7a5"]]);
78021
78394
  const uploadImageDialog$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
78022
78395
  __proto__: null,
78023
78396
  default: uploadImageDialog
@@ -78204,7 +78577,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
78204
78577
  };
78205
78578
  }
78206
78579
  });
78207
- const signatureDialog = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-f0714089"]]);
78580
+ const signatureDialog = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-41124487"]]);
78208
78581
  const signatureDialog$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
78209
78582
  __proto__: null,
78210
78583
  default: signatureDialog