@gct-paas/word 0.1.33 → 0.1.35

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.
package/dist/index.es.js CHANGED
@@ -17464,12 +17464,12 @@ const getFetch = (config) => {
17464
17464
  Response,
17465
17465
  fetch2
17466
17466
  ];
17467
- let len = seeds.length, i = len, seed2, target, map2 = seedCache;
17467
+ let len = seeds.length, i = len, seed2, target, map = seedCache;
17468
17468
  while (i--) {
17469
17469
  seed2 = seeds[i];
17470
- target = map2.get(seed2);
17471
- target === void 0 && map2.set(seed2, target = i ? /* @__PURE__ */ new Map() : factory(env));
17472
- map2 = target;
17470
+ target = map.get(seed2);
17471
+ target === void 0 && map.set(seed2, target = i ? /* @__PURE__ */ new Map() : factory(env));
17472
+ map = target;
17473
17473
  }
17474
17474
  return target;
17475
17475
  };
@@ -19033,11 +19033,11 @@ function copyObject(source, props, object4, customizer) {
19033
19033
  }
19034
19034
  return object4;
19035
19035
  }
19036
- var nativeMax$2 = Math.max;
19036
+ var nativeMax$1 = Math.max;
19037
19037
  function overRest(func, start, transform) {
19038
- start = nativeMax$2(start === void 0 ? func.length - 1 : start, 0);
19038
+ start = nativeMax$1(start === void 0 ? func.length - 1 : start, 0);
19039
19039
  return function() {
19040
- var args = arguments, index2 = -1, length = nativeMax$2(args.length - start, 0), array4 = Array(length);
19040
+ var args = arguments, index2 = -1, length = nativeMax$1(args.length - start, 0), array4 = Array(length);
19041
19041
  while (++index2 < length) {
19042
19042
  array4[index2] = args[start + index2];
19043
19043
  }
@@ -19344,8 +19344,8 @@ function isKeyable(value) {
19344
19344
  var type4 = typeof value;
19345
19345
  return type4 == "string" || type4 == "number" || type4 == "symbol" || type4 == "boolean" ? value !== "__proto__" : value === null;
19346
19346
  }
19347
- function getMapData(map2, key) {
19348
- var data = map2.__data__;
19347
+ function getMapData(map, key) {
19348
+ var data = map.__data__;
19349
19349
  return isKeyable(key) ? data[typeof key == "string" ? "string" : "hash"] : data.map;
19350
19350
  }
19351
19351
  function mapCacheDelete(key) {
@@ -19877,9 +19877,9 @@ function equalArrays(array4, other, bitmask, customizer, equalFunc, stack) {
19877
19877
  stack["delete"](other);
19878
19878
  return result;
19879
19879
  }
19880
- function mapToArray(map2) {
19881
- var index2 = -1, result = Array(map2.size);
19882
- map2.forEach(function(value, key) {
19880
+ function mapToArray(map) {
19881
+ var index2 = -1, result = Array(map.size);
19882
+ map.forEach(function(value, key) {
19883
19883
  result[++index2] = [key, value];
19884
19884
  });
19885
19885
  return result;
@@ -20203,7 +20203,7 @@ var now = function() {
20203
20203
  return root.Date.now();
20204
20204
  };
20205
20205
  var FUNC_ERROR_TEXT = "Expected a function";
20206
- var nativeMax$1 = Math.max, nativeMin = Math.min;
20206
+ var nativeMax = Math.max, nativeMin = Math.min;
20207
20207
  function debounce(func, wait, options) {
20208
20208
  var lastArgs, lastThis, maxWait, result, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
20209
20209
  if (typeof func != "function") {
@@ -20213,7 +20213,7 @@ function debounce(func, wait, options) {
20213
20213
  if (isObject(options)) {
20214
20214
  leading = !!options.leading;
20215
20215
  maxing = "maxWait" in options;
20216
- maxWait = maxing ? nativeMax$1(toNumber(options.maxWait) || 0, wait) : maxWait;
20216
+ maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
20217
20217
  trailing = "trailing" in options ? !!options.trailing : trailing;
20218
20218
  }
20219
20219
  function invokeFunc(time) {
@@ -20369,20 +20369,6 @@ function last(array4) {
20369
20369
  var length = array4 == null ? 0 : array4.length;
20370
20370
  return length ? array4[length - 1] : void 0;
20371
20371
  }
20372
- function baseMap(collection, iteratee) {
20373
- var index2 = -1, result = isArrayLike(collection) ? Array(collection.length) : [];
20374
- baseEach(collection, function(value, key, collection2) {
20375
- result[++index2] = iteratee(value, key, collection2);
20376
- });
20377
- return result;
20378
- }
20379
- function map(collection, iteratee) {
20380
- var func = isArray(collection) ? arrayMap : baseMap;
20381
- return func(collection, baseIteratee(iteratee));
20382
- }
20383
- function flatMap(collection, iteratee) {
20384
- return baseFlatten(map(collection, iteratee));
20385
- }
20386
20372
  var objectProto$2 = Object.prototype;
20387
20373
  var hasOwnProperty$2 = objectProto$2.hasOwnProperty;
20388
20374
  var groupBy$1 = createAggregator(function(result, value, key) {
@@ -20506,18 +20492,6 @@ function basePickBy(object4, paths, predicate) {
20506
20492
  }
20507
20493
  return result;
20508
20494
  }
20509
- function pickBy(object4, predicate) {
20510
- if (object4 == null) {
20511
- return {};
20512
- }
20513
- var props = arrayMap(getAllKeysIn(object4), function(prop) {
20514
- return [prop];
20515
- });
20516
- predicate = baseIteratee(predicate);
20517
- return basePickBy(object4, props, function(value, path2) {
20518
- return predicate(value, path2[0]);
20519
- });
20520
- }
20521
20495
  function basePick(object4, paths) {
20522
20496
  return basePickBy(object4, paths, function(value, path2) {
20523
20497
  return hasIn(object4, path2);
@@ -20529,23 +20503,6 @@ var pick = flatRest(function(object4, paths) {
20529
20503
  function set(object4, path2, value) {
20530
20504
  return object4 == null ? object4 : baseSet(object4, path2, value);
20531
20505
  }
20532
- var nativeMax = Math.max;
20533
- function unzip(array4) {
20534
- if (!(array4 && array4.length)) {
20535
- return [];
20536
- }
20537
- var length = 0;
20538
- array4 = arrayFilter(array4, function(group) {
20539
- if (isArrayLikeObject(group)) {
20540
- length = nativeMax(group.length, length);
20541
- return true;
20542
- }
20543
- });
20544
- return baseTimes(length, function(index2) {
20545
- return arrayMap(array4, baseProperty(index2));
20546
- });
20547
- }
20548
- var zip = baseRest(unzip);
20549
20506
  function fallbackUUID() {
20550
20507
  const bytes = new Uint8Array(16);
20551
20508
  crypto?.getRandomValues?.(bytes);
@@ -20604,12 +20561,26 @@ function generateValuePath(fieldLink, subFieldKey) {
20604
20561
  return `$.${fieldLink}`;
20605
20562
  }
20606
20563
  }
20564
+ function getLastSegment(str, separator = ".") {
20565
+ if (!str) return "";
20566
+ const index2 = str.lastIndexOf(separator);
20567
+ return index2 === -1 ? str : str.slice(index2 + 1);
20568
+ }
20607
20569
  function replacePathIndexPlaceholders(params) {
20608
- const { x: x2, y: y2, templatePath } = params;
20570
+ const { refPath, templatePath } = params;
20571
+ let n = params.n;
20572
+ let x2 = params.x;
20573
+ let y2 = params.y;
20574
+ if (refPath) {
20575
+ const indices = [...refPath.matchAll(/\[(\d+)\]/g)].map((m) => Number(m[1]));
20576
+ y2 ??= indices[0];
20577
+ x2 ??= indices[1] ?? indices[0];
20578
+ n ??= indices[0];
20579
+ }
20609
20580
  let path2 = templatePath;
20610
20581
  path2 = replacePathIndexPlaceholder(y2, path2, "n_y");
20611
20582
  path2 = replacePathIndexPlaceholder(x2, path2, "n_x");
20612
- path2 = replacePathIndexPlaceholder(x2, path2);
20583
+ path2 = replacePathIndexPlaceholder(n ?? x2, path2, "n");
20613
20584
  return path2;
20614
20585
  }
20615
20586
  function replacePathIndexPlaceholder(refPath, templatePath, placeholder = "n") {
@@ -20625,17 +20596,13 @@ function replacePathIndexPlaceholder(refPath, templatePath, placeholder = "n") {
20625
20596
  }
20626
20597
  return templatePath.replaceAll(`[${placeholder}]`, `[${index2}]`);
20627
20598
  }
20628
- function getLastSegment(str, separator = ".") {
20629
- if (!str) return "";
20630
- const index2 = str.lastIndexOf(separator);
20631
- return index2 === -1 ? str : str.slice(index2 + 1);
20632
- }
20633
20599
  function parseValuePath(valuePath) {
20634
20600
  if (!valuePath) {
20635
20601
  return {
20636
20602
  raw: "",
20637
20603
  normalized: "",
20638
20604
  fieldKey: "",
20605
+ fieldPath: "",
20639
20606
  isRoot: false,
20640
20607
  isSubTable: false,
20641
20608
  isLink: false,
@@ -20665,11 +20632,14 @@ function parseValuePath(valuePath) {
20665
20632
  raw: valuePath,
20666
20633
  normalized,
20667
20634
  fieldKey,
20635
+ fieldPath: fieldKey ? `$.${fieldKey}` : "",
20668
20636
  parentFieldKey,
20637
+ parentFieldPath: parentFieldKey ? `$.${parentFieldKey}` : "",
20669
20638
  isRoot: segments.length === 1,
20670
20639
  isSubTable: segments.length > 1,
20671
20640
  isLink,
20672
20641
  linkFieldKey,
20642
+ linkFieldPath: linkFieldKey ? `$.${linkFieldKey}` : "",
20673
20643
  hasIndex,
20674
20644
  segments
20675
20645
  };
@@ -20715,10 +20685,10 @@ function createRafOnce() {
20715
20685
  return { schedule, syncSchedule, cancel };
20716
20686
  }
20717
20687
  function listToTree(list, transform = (n) => n) {
20718
- const map2 = /* @__PURE__ */ new Map();
20688
+ const map = /* @__PURE__ */ new Map();
20719
20689
  const roots = [];
20720
20690
  list.forEach((item) => {
20721
- map2.set(item.value, item);
20691
+ map.set(item.value, item);
20722
20692
  item.children = [];
20723
20693
  });
20724
20694
  list.forEach((node) => {
@@ -20726,7 +20696,7 @@ function listToTree(list, transform = (n) => n) {
20726
20696
  if (!parentId || parentId === "ROOT") {
20727
20697
  roots.push(transform(node));
20728
20698
  } else {
20729
- const parent2 = map2.get(parentId);
20699
+ const parent2 = map.get(parentId);
20730
20700
  parent2?.children?.push(transform(node));
20731
20701
  }
20732
20702
  });
@@ -22234,7 +22204,7 @@ class WpPr extends ModelNode {
22234
22204
  while (node.parent) {
22235
22205
  node = node.parent;
22236
22206
  }
22237
- this._cachedWStyles = node.styles;
22207
+ this._cachedWStyles = node.styles ?? node.root?.styles;
22238
22208
  return this._cachedWStyles;
22239
22209
  }
22240
22210
  /**
@@ -22463,6 +22433,13 @@ class Wp extends ModelGroup {
22463
22433
  constructor(options) {
22464
22434
  super(options);
22465
22435
  this.pPr = options.pPr;
22436
+ this.bindPPrParent();
22437
+ }
22438
+ /** 将 pPr 挂到段落节点,供样式解析沿 parent 链查找 styles */
22439
+ bindPPrParent() {
22440
+ if (this.pPr) {
22441
+ this.pPr.parent = this;
22442
+ }
22466
22443
  }
22467
22444
  get styleId() {
22468
22445
  return this.pPr?.styleId;
@@ -22522,6 +22499,7 @@ class Wp extends ModelGroup {
22522
22499
  wp.runs.forEach((run) => {
22523
22500
  run.parent = wp;
22524
22501
  });
22502
+ wp.bindPPrParent();
22525
22503
  return wp;
22526
22504
  }
22527
22505
  toXmlJson() {
@@ -22590,6 +22568,7 @@ class Wp extends ModelGroup {
22590
22568
  ensurePPr() {
22591
22569
  if (!this.pPr) {
22592
22570
  this.pPr = new WpPr({ elements: [] });
22571
+ this.bindPPrParent();
22593
22572
  }
22594
22573
  return this.pPr;
22595
22574
  }
@@ -22725,6 +22704,15 @@ class Wtc extends ModelGroup {
22725
22704
  get contents() {
22726
22705
  return this.children.filter((child) => child instanceof Wp);
22727
22706
  }
22707
+ /** 单元格垂直对齐(w:tcPr/w:vAlign) */
22708
+ get vAlign() {
22709
+ const elem = this.tcPrRaw ? pickElement(this.tcPrRaw, "w:vAlign") : void 0;
22710
+ const val = elem?.["@attrs"]?.["w:val"];
22711
+ if (val === "center" || val === "bottom" || val === "top") {
22712
+ return val;
22713
+ }
22714
+ return void 0;
22715
+ }
22728
22716
  get firstContent() {
22729
22717
  return this.contents[0];
22730
22718
  }
@@ -23580,6 +23568,17 @@ class SubTableHeaderRegion extends Region {
23580
23568
  });
23581
23569
  }
23582
23570
  }
23571
+ function resolveRegionValuePathKeys(valuePath) {
23572
+ const parsed = parseValuePath(valuePath);
23573
+ const subFieldKey = parsed.isLink ? parsed.parentFieldKey ?? "" : parsed.fieldKey;
23574
+ const linkFieldKey = parsed.linkFieldKey ?? "";
23575
+ return {
23576
+ subFieldKey,
23577
+ linkFieldKey,
23578
+ subValuePath: subFieldKey ? `$.${subFieldKey}` : "",
23579
+ linkValuePath: linkFieldKey ? `$.${linkFieldKey}` : ""
23580
+ };
23581
+ }
23583
23582
  class RepeatingRegion extends Region {
23584
23583
  type = "repeating";
23585
23584
  name;
@@ -23595,6 +23594,18 @@ class RepeatingRegion extends Region {
23595
23594
  }
23596
23595
  };
23597
23596
  }
23597
+ get subFieldKey() {
23598
+ return resolveRegionValuePathKeys(this.valuePath).subFieldKey;
23599
+ }
23600
+ get linkFieldKey() {
23601
+ return resolveRegionValuePathKeys(this.valuePath).linkFieldKey;
23602
+ }
23603
+ get subValuePath() {
23604
+ return resolveRegionValuePathKeys(this.valuePath).subValuePath;
23605
+ }
23606
+ get linkValuePath() {
23607
+ return resolveRegionValuePathKeys(this.valuePath).linkValuePath;
23608
+ }
23598
23609
  toJSON() {
23599
23610
  return {
23600
23611
  ...super.toJSON(),
@@ -23624,6 +23635,18 @@ class BoundedItemRegion extends Region {
23624
23635
  this.parent = options.parent;
23625
23636
  }
23626
23637
  }
23638
+ get subFieldKey() {
23639
+ return this.parent?.subFieldKey ?? "";
23640
+ }
23641
+ get linkFieldKey() {
23642
+ return this.parent?.linkFieldKey ?? "";
23643
+ }
23644
+ get subValuePath() {
23645
+ return this.parent?.subValuePath ?? "";
23646
+ }
23647
+ get linkValuePath() {
23648
+ return this.parent?.linkValuePath ?? "";
23649
+ }
23627
23650
  remove() {
23628
23651
  this.parent.removeItemRegion();
23629
23652
  }
@@ -23669,6 +23692,18 @@ class BoundedRegion extends Region {
23669
23692
  };
23670
23693
  this.itemRegion = options.itemRegion;
23671
23694
  }
23695
+ get subFieldKey() {
23696
+ return resolveRegionValuePathKeys(this.valuePath).subFieldKey;
23697
+ }
23698
+ get linkFieldKey() {
23699
+ return resolveRegionValuePathKeys(this.valuePath).linkFieldKey;
23700
+ }
23701
+ get subValuePath() {
23702
+ return resolveRegionValuePathKeys(this.valuePath).subValuePath;
23703
+ }
23704
+ get linkValuePath() {
23705
+ return resolveRegionValuePathKeys(this.valuePath).linkValuePath;
23706
+ }
23672
23707
  toJSON() {
23673
23708
  return {
23674
23709
  ...super.toJSON(),
@@ -23724,6 +23759,18 @@ class DataGroup2DRegion extends Region {
23724
23759
  this.parent = options.parent;
23725
23760
  }
23726
23761
  }
23762
+ get subFieldKey() {
23763
+ return this.parent?.subFieldKey ?? "";
23764
+ }
23765
+ get linkFieldKey() {
23766
+ return this.parent?.linkFieldKey ?? "";
23767
+ }
23768
+ get subValuePath() {
23769
+ return this.parent?.subValuePath ?? "";
23770
+ }
23771
+ get linkValuePath() {
23772
+ return this.parent?.linkValuePath ?? "";
23773
+ }
23727
23774
  remove() {
23728
23775
  this.parent.removeItemRegion();
23729
23776
  }
@@ -23747,17 +23794,16 @@ class LinkSubTableRegion extends Region {
23747
23794
  this.itemRegion = options.itemRegion;
23748
23795
  }
23749
23796
  get subFieldKey() {
23750
- const parsed = parseValuePath(this.valuePath);
23751
- return parsed.isLink ? parsed.parentFieldKey ?? "" : parsed.fieldKey;
23797
+ return resolveRegionValuePathKeys(this.valuePath).subFieldKey;
23752
23798
  }
23753
23799
  get linkFieldKey() {
23754
- return parseValuePath(this.valuePath).linkFieldKey ?? "";
23800
+ return resolveRegionValuePathKeys(this.valuePath).linkFieldKey;
23755
23801
  }
23756
23802
  get subValuePath() {
23757
- return this.subFieldKey ? `$.${this.subFieldKey}` : "";
23803
+ return resolveRegionValuePathKeys(this.valuePath).subValuePath;
23758
23804
  }
23759
23805
  get linkValuePath() {
23760
- return this.linkFieldKey ? `$.${this.linkFieldKey}` : "";
23806
+ return resolveRegionValuePathKeys(this.valuePath).linkValuePath;
23761
23807
  }
23762
23808
  toLinkSubTableJSON() {
23763
23809
  return {
@@ -24632,235 +24678,79 @@ class WtblRegionManager {
24632
24678
  }
24633
24679
  }
24634
24680
  }
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];
24681
+ function isLinkSubTableType(type4) {
24682
+ if (!type4) return false;
24683
+ return type4 === "2d-table" || type4 === "check-table";
24684
+ }
24685
+ function isLinkSubTableSubScopeZone(cellZone) {
24686
+ if (!cellZone) return false;
24687
+ return cellZone === "cross" || cellZone === "horizontal";
24688
+ }
24689
+ function getLinkSubTableCrossRange(region) {
24690
+ const { itemRegion } = region;
24691
+ if (!itemRegion) return void 0;
24696
24692
  return {
24697
- strokeColor: config?.color || "#000",
24698
- backgroundColor: config?.background || "transparent",
24699
- label: config?.label || "",
24700
- labelBjColor: config?.labelBjColor || "#666"
24693
+ start: {
24694
+ row: Math.max(region.start.row, itemRegion.start.row),
24695
+ col: Math.max(region.start.col, itemRegion.start.col)
24696
+ },
24697
+ end: {
24698
+ row: Math.min(region.end.row, itemRegion.end.row),
24699
+ col: Math.min(region.end.col, itemRegion.end.col)
24700
+ }
24701
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
24702
  }
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
- });
24703
+ function getDataGroup2DFillEndCol(region, cellDataIndexMap) {
24704
+ const { itemRegion } = region;
24705
+ if (!itemRegion) return region.end.col;
24706
+ let maxCol = itemRegion.end.col;
24707
+ cellDataIndexMap.forEach((meta, key) => {
24708
+ const [rowStr, colStr] = key.split(",");
24709
+ const row = Number(rowStr);
24710
+ const col = Number(colStr);
24711
+ if (row >= itemRegion.start.row && row <= itemRegion.end.row && meta.dataIndex !== void 0) {
24712
+ maxCol = Math.max(maxCol, col);
24713
+ }
24733
24714
  });
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 };
24715
+ return maxCol;
24766
24716
  }
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);
24717
+ function resolveLinkSubTableCellZone(row, col, region, options = {}) {
24718
+ const { itemRegion } = region;
24719
+ if (!itemRegion) {
24720
+ return region.contains(row, col) ? "horizontal" : void 0;
24773
24721
  }
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
- }, {});
24722
+ const cross = getLinkSubTableCrossRange(region);
24723
+ const fillEndCol = options.fillEndCol ?? itemRegion.end.col;
24724
+ const inCrossRows = row >= cross.start.row && row <= cross.end.row;
24725
+ const inItemRows = row >= itemRegion.start.row && row <= itemRegion.end.row;
24726
+ if (inCrossRows && col >= itemRegion.start.col && col <= fillEndCol) {
24727
+ return "cross";
24728
+ }
24729
+ if (!inCrossRows && inItemRows && col >= itemRegion.start.col && col <= fillEndCol) {
24730
+ return "vertical";
24731
+ }
24732
+ if (region.contains(row, col)) {
24733
+ if (col < itemRegion.start.col) {
24734
+ return "horizontal";
24735
+ }
24736
+ if (inCrossRows && col > fillEndCol) {
24737
+ return "horizontal";
24738
+ }
24739
+ }
24740
+ return void 0;
24793
24741
  }
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;
24742
+ function resolveLinkSubTableValuePath(region, cellZone) {
24743
+ switch (cellZone) {
24744
+ case "cross":
24745
+ return region.valuePath;
24746
+ case "vertical":
24747
+ return region.linkValuePath;
24748
+ case "horizontal":
24749
+ return region.subValuePath;
24801
24750
  }
24802
- return res;
24803
24751
  }
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);
24752
+ function isInLinkSubTableLayoutScope(row, col, region, options = {}) {
24753
+ return resolveLinkSubTableCellZone(row, col, region, options) !== void 0;
24864
24754
  }
24865
24755
  class CellCollector {
24866
24756
  constructor(table) {
@@ -24900,19 +24790,19 @@ class CellCollector {
24900
24790
  }
24901
24791
  const body = cell.subTable;
24902
24792
  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, []);
24793
+ const map = body.type === "repeating" ? this.repeatingGroups : body.type === "2d-table" ? this._2DTableGroups : body.type === "bounded" ? this.boundedGroups : this.checkTableGroups;
24794
+ if (!map.has(body.regionId)) {
24795
+ map.set(body.regionId, []);
24906
24796
  }
24907
- map2.get(body.regionId).push(position);
24797
+ map.get(body.regionId).push(position);
24908
24798
  }
24909
24799
  const item = cell.subTableItem;
24910
24800
  if (item) {
24911
- const map2 = item.type === "bounded-item" ? this.boundedItemGroups : this.dataGroup2DGroups;
24912
- if (!map2.has(item.regionId)) {
24913
- map2.set(item.regionId, []);
24801
+ const map = item.type === "bounded-item" ? this.boundedItemGroups : this.dataGroup2DGroups;
24802
+ if (!map.has(item.regionId)) {
24803
+ map.set(item.regionId, []);
24914
24804
  }
24915
- map2.get(item.regionId).push(position);
24805
+ map.get(item.regionId).push(position);
24916
24806
  }
24917
24807
  }
24918
24808
  }
@@ -25090,7 +24980,7 @@ class WtblCalculation {
25090
24980
  if (positions.length === 0) continue;
25091
24981
  const { minRow, maxRow, minCol, maxCol } = calculateGroupBounds(positions);
25092
24982
  const region = table.findRegionById(groupId);
25093
- if (region && getIsDataGroup2DTable(region.type)) {
24983
+ if (region && isLinkSubTableType(region.type)) {
25094
24984
  region.start.row = minRow;
25095
24985
  region.end.row = maxRow;
25096
24986
  region.start.col = minCol;
@@ -26164,6 +26054,101 @@ class Wdocument extends ModelGroup {
26164
26054
  return result;
26165
26055
  }
26166
26056
  }
26057
+ class ParagraphStyleResolver {
26058
+ /**
26059
+ * 计算段落的有效样式
26060
+ * 优先级:直接属性 > 样式定义 > 文档默认
26061
+ *
26062
+ * @param wpPr - 段落属性节点
26063
+ * @returns 计算后的有效样式
26064
+ *
26065
+ * @example
26066
+ * const style = ParagraphStyleResolver.resolve(wpPr);
26067
+ * console.log(style.alignment); // 可能来自直接属性或样式定义
26068
+ */
26069
+ static resolve(wpPr) {
26070
+ const directStyle = wpPr.directStyle;
26071
+ if (!wpPr.styleId || !wpPr.wStyles) {
26072
+ return directStyle;
26073
+ }
26074
+ const styleDefinition = wpPr.wStyles.resolveStyleDef(wpPr.styleId);
26075
+ if (!styleDefinition) {
26076
+ return directStyle;
26077
+ }
26078
+ const inheritedStyle = this.convertPPrToStyle(styleDefinition.pPr);
26079
+ return this.mergeStyles(inheritedStyle, directStyle);
26080
+ }
26081
+ /**
26082
+ * 从 WparagraphProperties 转换为 ParagraphStyle
26083
+ *
26084
+ * WparagraphProperties 是样式体系内部使用的数值化表示
26085
+ * ParagraphStyle 是对外的字符串化 API 表示
26086
+ *
26087
+ * @param pPr - 段落属性对象(可能为 undefined)
26088
+ * @returns 转换后的段落样式
26089
+ */
26090
+ static convertPPrToStyle(pPr) {
26091
+ if (!pPr) {
26092
+ return {};
26093
+ }
26094
+ const style = {};
26095
+ if (pPr.alignment) {
26096
+ style.alignment = pPr.alignment;
26097
+ }
26098
+ if (pPr.indent && Object.keys(pPr.indent).length > 0) {
26099
+ style.indent = {
26100
+ left: pPr.indent.left?.toString(),
26101
+ right: pPr.indent.right?.toString(),
26102
+ firstLine: pPr.indent.firstLine?.toString()
26103
+ };
26104
+ }
26105
+ if (pPr.spacing && Object.keys(pPr.spacing).length > 0) {
26106
+ style.spacing = {
26107
+ before: pPr.spacing.before?.toString(),
26108
+ after: pPr.spacing.after?.toString(),
26109
+ line: pPr.spacing.line?.toString(),
26110
+ beforeAutospacing: pPr.spacing.beforeAutospacing,
26111
+ afterAutospacing: pPr.spacing.afterAutospacing
26112
+ };
26113
+ }
26114
+ return style;
26115
+ }
26116
+ /**
26117
+ * 深度合并两个样式对象
26118
+ * 后来的值优先覆盖前面的值(override > base)
26119
+ *
26120
+ * @param base - 基础样式(如样式定义)
26121
+ * @param override - 覆盖样式(如直接属性)
26122
+ * @returns 合并后的样式
26123
+ */
26124
+ static mergeStyles(base, override) {
26125
+ const result = {};
26126
+ result.alignment = override.alignment ?? base.alignment;
26127
+ if (base.indent || override.indent) {
26128
+ result.indent = {
26129
+ left: override.indent?.left ?? base.indent?.left,
26130
+ right: override.indent?.right ?? base.indent?.right,
26131
+ firstLine: override.indent?.firstLine ?? base.indent?.firstLine
26132
+ };
26133
+ }
26134
+ if (base.spacing || override.spacing) {
26135
+ result.spacing = {
26136
+ before: override.spacing?.before ?? base.spacing?.before,
26137
+ after: override.spacing?.after ?? base.spacing?.after,
26138
+ line: override.spacing?.line ?? base.spacing?.line,
26139
+ beforeAutospacing: override.spacing?.beforeAutospacing ?? base.spacing?.beforeAutospacing,
26140
+ afterAutospacing: override.spacing?.afterAutospacing ?? base.spacing?.afterAutospacing
26141
+ };
26142
+ }
26143
+ if (base.lang || override.lang) {
26144
+ result.lang = {
26145
+ val: override.lang?.val ?? base.lang?.val,
26146
+ eastAsia: override.lang?.eastAsia ?? base.lang?.eastAsia
26147
+ };
26148
+ }
26149
+ return result;
26150
+ }
26151
+ }
26167
26152
  class TextStyleResolver {
26168
26153
  /**
26169
26154
  * 计算字符的有效样式
@@ -27218,6 +27203,8 @@ class TextWidget extends TextRun {
27218
27203
  widgetFileItem;
27219
27204
  pageWidgetMeta;
27220
27205
  dataIndex;
27206
+ xDataIndex;
27207
+ yDataIndex;
27221
27208
  constructor(options) {
27222
27209
  super(options);
27223
27210
  this.widgetMeta = options.widgetMeta;
@@ -31916,7 +31903,7 @@ class DeleteDataGroup2D extends CommandBase {
31916
31903
  return null;
31917
31904
  }
31918
31905
  const subTable = table.findRegionById(regionId);
31919
- if (!subTable || !getIsDataGroup2DTable(subTable.type)) {
31906
+ if (!subTable || !isLinkSubTableType(subTable.type)) {
31920
31907
  console.error(
31921
31908
  `deleteDataGroup2D: region not found with id ${regionId} or region type is not support`
31922
31909
  );
@@ -38226,72 +38213,6 @@ function canSwitchImageFieldToAdaptive(cell, fieldRunId) {
38226
38213
  }
38227
38214
  return !fieldRunId || run.id === fieldRunId;
38228
38215
  }
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
38216
  const INSERT_FIELD_MSG = {
38296
38217
  NOT_IN_CELL: "子表字段只能插入表格单元格中",
38297
38218
  PATH_INCOMPATIBLE: "字段路径与当前区域不兼容,无法插入",
@@ -38490,7 +38411,7 @@ class InsertField extends CommandBase {
38490
38411
  /** 二维表/检验表:用当前单元格 subRenderer 分区 valuePath 作为父路径 */
38491
38412
  getSubTableZoneParentPath() {
38492
38413
  const sub = this.getLayoutTableCellFromCursor()?.subRenderer;
38493
- if (sub && getIsDataGroup2DTable(sub.type)) {
38414
+ if (sub && isLinkSubTableType(sub.type)) {
38494
38415
  return sub.valuePath;
38495
38416
  }
38496
38417
  return void 0;
@@ -38501,7 +38422,7 @@ class InsertField extends CommandBase {
38501
38422
  if (!zoneParentPath || !widgetMeta.field) {
38502
38423
  return { valuePath: draggedValuePath, widgetMeta };
38503
38424
  }
38504
- if (layoutSub?.type === "2d-table" || layoutSub?.type === "check-table") {
38425
+ if (isLinkSubTableType(layoutSub?.type)) {
38505
38426
  const cell = this.getModelCellFromCursor();
38506
38427
  const region = cell ? this.getLinkSubTableRegionFromLayout(cell, layoutSub) : void 0;
38507
38428
  if (region && !this.getDraggedFieldSide(widgetMeta.field, region)) {
@@ -38509,7 +38430,7 @@ class InsertField extends CommandBase {
38509
38430
  }
38510
38431
  }
38511
38432
  const fieldLink = widgetMeta.field.fieldLink || getLastSegment(draggedValuePath);
38512
- const parentKey = getLastSegment(zoneParentPath);
38433
+ const parentKey = parseValuePath(zoneParentPath).normalized;
38513
38434
  const valuePath = generateValuePath(fieldLink, parentKey);
38514
38435
  return {
38515
38436
  valuePath,
@@ -38583,13 +38504,11 @@ class InsertField extends CommandBase {
38583
38504
  }
38584
38505
  getLinkSubTableRegionFromLayout(cell, sub) {
38585
38506
  const table = cell.table;
38507
+ if (!isLinkSubTableType(sub.type)) return void 0;
38586
38508
  if (sub.type === "2d-table") {
38587
38509
  return table.get2DTableById(sub.id);
38588
38510
  }
38589
- if (sub.type === "check-table") {
38590
- return table.getCheckTableById(sub.id);
38591
- }
38592
- return void 0;
38511
+ return table.getCheckTableById(sub.id);
38593
38512
  }
38594
38513
  /**
38595
38514
  * 校验字段是否可插入当前位置
@@ -38600,7 +38519,7 @@ class InsertField extends CommandBase {
38600
38519
  const cell = getAncestorCell(node);
38601
38520
  if (!cell) return INSERT_FIELD_MSG.NOT_IN_CELL;
38602
38521
  const layoutSub = this.getLayoutTableCellFromCursor()?.subRenderer;
38603
- if (layoutSub?.type === "2d-table" || layoutSub?.type === "check-table") {
38522
+ if (layoutSub && isLinkSubTableType(layoutSub.type)) {
38604
38523
  const region = this.getLinkSubTableRegionFromLayout(cell, layoutSub);
38605
38524
  if (!region) return INSERT_FIELD_MSG.NOT_IN_SUBTABLE_REGION;
38606
38525
  return this.validateLinkSubTableFieldPath(
@@ -38617,7 +38536,7 @@ class InsertField extends CommandBase {
38617
38536
  const colIndex = cell.getCurrentIndex();
38618
38537
  const rowIndex = row.getCurrentIndex();
38619
38538
  const targetRegion = regions.find((r) => r.contains(rowIndex, colIndex));
38620
- if (targetRegion?.type === "2d-table" || targetRegion?.type === "check-table") {
38539
+ if (targetRegion && isLinkSubTableType(targetRegion.type)) {
38621
38540
  return this.validateLinkSubTableFieldPath(
38622
38541
  valuePath,
38623
38542
  targetRegion,
@@ -39928,7 +39847,7 @@ class SetDataGroup2D extends CommandBase {
39928
39847
  let region;
39929
39848
  cellList.some((cell) => {
39930
39849
  const r = cell.getRegion();
39931
- if (r && getIsDataGroup2DTable(r.type)) {
39850
+ if (r && isLinkSubTableType(r.type)) {
39932
39851
  region = r;
39933
39852
  return true;
39934
39853
  }
@@ -40331,16 +40250,16 @@ function getClassNameFromPath(path2) {
40331
40250
  return path2.split("/").pop()?.replace(".ts", "") ?? "";
40332
40251
  }
40333
40252
  function buildCommandMap() {
40334
- const map2 = {};
40253
+ const map = {};
40335
40254
  Object.entries(commandModules).forEach(([path2, module2]) => {
40336
40255
  const expectedClassName = getClassNameFromPath(path2);
40337
40256
  const CommandClass = module2[expectedClassName];
40338
40257
  if (CommandClass && typeof CommandClass === "function") {
40339
40258
  const commandName = toCamelCase(expectedClassName);
40340
- map2[commandName] = CommandClass;
40259
+ map[commandName] = CommandClass;
40341
40260
  }
40342
40261
  });
40343
- return map2;
40262
+ return map;
40344
40263
  }
40345
40264
  class CommandManager {
40346
40265
  registry = /* @__PURE__ */ new Map();
@@ -40445,6 +40364,8 @@ class Paragraph extends LayoutGroup {
40445
40364
  component = BuiltinComponentTypeConst.Paragraph;
40446
40365
  baseline = 0;
40447
40366
  // 基线位置,默认为 0,表示与段落顶部对齐
40367
+ /** 上次 layout 应用的水平对齐偏移,避免重复 layout 时累加 */
40368
+ _alignmentOffset = 0;
40448
40369
  splitFillEvent = new EventUtil();
40449
40370
  // backgroundColor?: string = 'rgba(0,0,0,0.06)';
40450
40371
  // borderTop?: Border = {
@@ -40511,15 +40432,19 @@ class Paragraph extends LayoutGroup {
40511
40432
  }
40512
40433
  applyStyle() {
40513
40434
  const wp = this.doc.layoutMapper.getModelNodeById(this.modelRef.id);
40514
- const style = wp?.pPr?.directStyle ?? {};
40435
+ const style = wp?.pPr ? ParagraphStyleResolver.resolve(wp.pPr) : {};
40515
40436
  let offset2 = 0;
40516
40437
  if (style.alignment === "center") {
40517
40438
  offset2 = (this.width - this.getContextWidth()) / 2;
40518
40439
  } else if (style.alignment === "right") {
40519
40440
  offset2 = this.width - this.getContextWidth();
40520
40441
  }
40442
+ offset2 = Math.max(offset2, 0);
40443
+ const delta = offset2 - this._alignmentOffset;
40444
+ this._alignmentOffset = offset2;
40445
+ if (delta === 0) return;
40521
40446
  this.forEachChild((child) => {
40522
- child.x += Math.max(offset2, 0);
40447
+ child.x += delta;
40523
40448
  });
40524
40449
  }
40525
40450
  /**
@@ -40631,19 +40556,19 @@ class Table extends LayoutGroup {
40631
40556
  });
40632
40557
  }
40633
40558
  updateCellOffsetInfo() {
40634
- const map2 = /* @__PURE__ */ new Map();
40559
+ const map = /* @__PURE__ */ new Map();
40635
40560
  const rows = this.getChildren();
40636
40561
  rows.forEach((row, rowIndex) => {
40637
40562
  row.getChildren().forEach((cell, colIndex) => {
40638
40563
  if (cell.mergeFromId) {
40639
- cell.mergeRefColOffset = colIndex - map2.get(cell.mergeFromId).colIndex;
40640
- cell.mergeRefRowOffset = rowIndex - map2.get(cell.mergeFromId).rowIndex;
40564
+ cell.mergeRefColOffset = colIndex - map.get(cell.mergeFromId).colIndex;
40565
+ cell.mergeRefRowOffset = rowIndex - map.get(cell.mergeFromId).rowIndex;
40641
40566
  } else {
40642
- map2.set(cell.id, { rowIndex, colIndex });
40567
+ map.set(cell.id, { rowIndex, colIndex });
40643
40568
  }
40644
40569
  });
40645
40570
  });
40646
- map2.clear();
40571
+ map.clear();
40647
40572
  }
40648
40573
  forEachCell(options) {
40649
40574
  const { startRowIdx, startColIdx, endRowIdx, endColIdx, callback, filter: filter2 } = options;
@@ -40962,14 +40887,14 @@ class LayoutContext {
40962
40887
  getValuePath(path2) {
40963
40888
  if (!path2) return void 0;
40964
40889
  const { type: type4, dataIndex, xDataIndex, yDataIndex, cellZone } = this.cell?.subRenderer || {};
40965
- if (getIsDataGroup2DTable(type4) && cellZone === "cross") {
40890
+ if (isLinkSubTableType(type4) && cellZone === "cross") {
40966
40891
  return replacePathIndexPlaceholders({ x: xDataIndex, y: yDataIndex, templatePath: path2 });
40967
40892
  }
40968
40893
  if (!path2.includes("[n]")) {
40969
40894
  return path2;
40970
40895
  }
40971
40896
  let n = dataIndex;
40972
- if (getIsDataGroup2DTable(type4)) {
40897
+ if (isLinkSubTableType(type4)) {
40973
40898
  n = cellZone === "horizontal" ? yDataIndex : xDataIndex;
40974
40899
  }
40975
40900
  if (n === void 0) return path2;
@@ -40980,12 +40905,12 @@ class TextHandler {
40980
40905
  static getId(context, wr) {
40981
40906
  const baseId = wr.id;
40982
40907
  const sub = context.cell?.subRenderer;
40983
- if (sub && getIsDataGroup2DTable(sub.type) && sub.cellZone === "cross" && typeof sub.yDataIndex === "number" && typeof sub.xDataIndex === "number") {
40908
+ if (sub && isLinkSubTableType(sub.type) && sub.cellZone === "cross" && typeof sub.yDataIndex === "number" && typeof sub.xDataIndex === "number") {
40984
40909
  return `${baseId}@${sub.yDataIndex}_${sub.xDataIndex}`;
40985
40910
  }
40986
40911
  let runIndex;
40987
40912
  if (sub) {
40988
- if (getIsDataGroup2DTable(sub.type)) {
40913
+ if (isLinkSubTableType(sub.type)) {
40989
40914
  runIndex = sub.cellZone === "horizontal" ? sub.yDataIndex : sub.xDataIndex;
40990
40915
  } else {
40991
40916
  runIndex = sub.dataIndex;
@@ -41204,7 +41129,7 @@ class FieldBaseHandler {
41204
41129
  static getSubTableRunIndex(context) {
41205
41130
  const sub = context.cell?.subRenderer;
41206
41131
  if (!sub) return void 0;
41207
- if (getIsDataGroup2DTable(sub.type)) {
41132
+ if (isLinkSubTableType(sub.type)) {
41208
41133
  if (sub.cellZone === "horizontal") {
41209
41134
  return sub.yDataIndex;
41210
41135
  }
@@ -41218,7 +41143,7 @@ class FieldBaseHandler {
41218
41143
  static getId(context, wr) {
41219
41144
  const baseId = wr.id;
41220
41145
  const sub = context.cell?.subRenderer;
41221
- if (sub && getIsDataGroup2DTable(sub.type) && sub.cellZone === "cross" && typeof sub.yDataIndex === "number" && typeof sub.xDataIndex === "number") {
41146
+ if (sub && isLinkSubTableType(sub.type) && sub.cellZone === "cross" && typeof sub.yDataIndex === "number" && typeof sub.xDataIndex === "number") {
41222
41147
  return `${baseId}@${sub.yDataIndex}_${sub.xDataIndex}`;
41223
41148
  }
41224
41149
  const runIndex = this.getSubTableRunIndex(context);
@@ -41650,6 +41575,8 @@ class ImageWidget extends ImageRun {
41650
41575
  signature;
41651
41576
  pageWidgetMeta;
41652
41577
  dataIndex;
41578
+ xDataIndex;
41579
+ yDataIndex;
41653
41580
  constructor(options) {
41654
41581
  super(options);
41655
41582
  this.src = options.src;
@@ -41658,6 +41585,8 @@ class ImageWidget extends ImageRun {
41658
41585
  this.signature = options.signature;
41659
41586
  this.pageWidgetMeta = options.pageWidgetMeta;
41660
41587
  this.dataIndex = options.dataIndex;
41588
+ this.xDataIndex = options.xDataIndex;
41589
+ this.yDataIndex = options.yDataIndex;
41661
41590
  }
41662
41591
  }
41663
41592
  class FieldImageHandler extends FieldBaseHandler {
@@ -41978,7 +41907,7 @@ class WidgetBaseHandler {
41978
41907
  getDataIndex(init2 = null) {
41979
41908
  const { context } = this;
41980
41909
  const { type: type4, dataIndex, xDataIndex, yDataIndex, cellZone } = context.cell?.subRenderer || {};
41981
- if (getIsDataGroup2DTable(type4)) {
41910
+ if (isLinkSubTableType(type4)) {
41982
41911
  if (cellZone === "horizontal") {
41983
41912
  return yDataIndex ?? init2;
41984
41913
  }
@@ -41996,7 +41925,7 @@ class WidgetBaseHandler {
41996
41925
  getId() {
41997
41926
  const baseId = this.wr.id;
41998
41927
  const sub = this.context.cell?.subRenderer;
41999
- if (sub && getIsDataGroup2DTable(sub.type) && sub.cellZone === "cross" && typeof sub.yDataIndex === "number" && typeof sub.xDataIndex === "number") {
41928
+ if (sub && isLinkSubTableType(sub.type) && sub.cellZone === "cross" && typeof sub.yDataIndex === "number" && typeof sub.xDataIndex === "number") {
42000
41929
  return `${baseId}@${sub.yDataIndex}_${sub.xDataIndex}`;
42001
41930
  }
42002
41931
  const dataIndex = this.getDataIndex();
@@ -42031,7 +41960,7 @@ class SerialNumberHandler extends WidgetBaseHandler {
42031
41960
  layout() {
42032
41961
  const { wr, context } = this;
42033
41962
  const layoutStyle = this.getLayoutStyle();
42034
- const label = (context.cell?.subRenderer?.dataIndex ?? 0) + 1 + "";
41963
+ const label = (this.getDataIndex() ?? 0) + 1 + "";
42035
41964
  label.split("").forEach((char, charIndex) => {
42036
41965
  const { width, height, ascent, descent } = TextRun.measureText(
42037
41966
  TextRun.measurePayload(char, layoutStyle)
@@ -42120,7 +42049,11 @@ class QrCodeHandler extends WidgetBaseHandler {
42120
42049
  start: 0,
42121
42050
  end: 0
42122
42051
  },
42123
- pageWidgetMeta: wr.pageWidgetMeta
42052
+ pageWidgetMeta: wr.pageWidgetMeta,
42053
+ // todo
42054
+ dataIndex: this.getDataIndex() ?? void 0,
42055
+ xDataIndex: context.cell?.subRenderer?.xDataIndex,
42056
+ yDataIndex: context.cell?.subRenderer?.yDataIndex
42124
42057
  });
42125
42058
  context.addRun(run);
42126
42059
  }
@@ -42179,7 +42112,10 @@ class BarcodeHandler extends WidgetBaseHandler {
42179
42112
  end: 0
42180
42113
  },
42181
42114
  pageWidgetMeta: wr.pageWidgetMeta,
42182
- dataIndex: context.cell?.subRenderer?.dataIndex ?? 0
42115
+ // todo
42116
+ dataIndex: this.getDataIndex() ?? void 0,
42117
+ xDataIndex: context.cell?.subRenderer?.xDataIndex,
42118
+ yDataIndex: context.cell?.subRenderer?.yDataIndex
42183
42119
  });
42184
42120
  if (decorationInfo.render) {
42185
42121
  run.decorations = decorationInfo.decorations;
@@ -42227,7 +42163,11 @@ class DiagonalHandler extends WidgetBaseHandler {
42227
42163
  start: 0,
42228
42164
  end: 0
42229
42165
  },
42230
- pageWidgetMeta: wr.pageWidgetMeta
42166
+ pageWidgetMeta: wr.pageWidgetMeta,
42167
+ // todo
42168
+ dataIndex: this.getDataIndex() ?? void 0,
42169
+ xDataIndex: context.cell?.subRenderer?.xDataIndex,
42170
+ yDataIndex: context.cell?.subRenderer?.yDataIndex
42231
42171
  });
42232
42172
  context.addRun(run);
42233
42173
  cell.skipSplitMeasure = true;
@@ -42489,8 +42429,18 @@ class TableCell extends LayoutGroup {
42489
42429
  layout(x2, y2) {
42490
42430
  this.layoutX = x2;
42491
42431
  this.layoutY = y2;
42432
+ const contentHeight = this.getContentHeight();
42433
+ const innerHeight = this.height - this.pt - this.pb;
42434
+ let contentOffsetY = 0;
42435
+ const wtc = this.modelRef ? this.doc.layoutMapper.getModelNodeById(this.modelRef.id) : void 0;
42436
+ const vAlign = wtc?.vAlign;
42437
+ if (vAlign === "center") {
42438
+ contentOffsetY = Math.max(0, (innerHeight - contentHeight) / 2);
42439
+ } else if (vAlign === "bottom") {
42440
+ contentOffsetY = Math.max(0, innerHeight - contentHeight);
42441
+ }
42492
42442
  this.forEachChild((child) => {
42493
- child.layout(this.layoutX + this.pl, this.layoutY + this.pt + child.y);
42443
+ child.layout(this.layoutX + this.pl, this.layoutY + this.pt + contentOffsetY + child.y);
42494
42444
  });
42495
42445
  }
42496
42446
  }
@@ -43914,43 +43864,43 @@ class LayoutManager {
43914
43864
  handler.layout(context, run);
43915
43865
  }
43916
43866
  }
43917
- function generateModelMap(node, map2 = /* @__PURE__ */ new Map()) {
43867
+ function generateModelMap(node, map = /* @__PURE__ */ new Map()) {
43918
43868
  if (!node) return;
43919
- map2.set(node.id, node);
43869
+ map.set(node.id, node);
43920
43870
  const children = node.getChildren?.() ?? node.children ?? null;
43921
43871
  if (Array.isArray(children)) {
43922
43872
  for (let ci = 0; ci < children.length; ci++) {
43923
43873
  const child = children[ci];
43924
- generateModelMap(child, map2);
43874
+ generateModelMap(child, map);
43925
43875
  }
43926
43876
  }
43927
- return map2;
43877
+ return map;
43928
43878
  }
43929
43879
  function generateDocModelMap(doc) {
43930
- const map2 = /* @__PURE__ */ new Map();
43880
+ const map = /* @__PURE__ */ new Map();
43931
43881
  const body = doc.model?.document.body;
43932
43882
  if (body) {
43933
- generateModelMap(body, map2);
43883
+ generateModelMap(body, map);
43934
43884
  }
43935
43885
  const headers2 = doc.model?.headers?.headers;
43936
43886
  if (Array.isArray(headers2)) {
43937
43887
  headers2.forEach((header) => {
43938
- generateModelMap(header, map2);
43888
+ generateModelMap(header, map);
43939
43889
  });
43940
43890
  }
43941
43891
  const footers2 = doc.model?.footers?.footers;
43942
43892
  if (Array.isArray(footers2)) {
43943
43893
  footers2.forEach((footer) => {
43944
- generateModelMap(footer, map2);
43894
+ generateModelMap(footer, map);
43945
43895
  });
43946
43896
  }
43947
43897
  const overlays = doc.model?.overlays.overlays;
43948
43898
  if (Array.isArray(overlays)) {
43949
43899
  overlays.forEach((overlay) => {
43950
- generateModelMap(overlay, map2);
43900
+ generateModelMap(overlay, map);
43951
43901
  });
43952
43902
  }
43953
- return map2;
43903
+ return map;
43954
43904
  }
43955
43905
  class LayoutMapper {
43956
43906
  doc;
@@ -46233,10 +46183,12 @@ class DataManager {
46233
46183
  rows.push({});
46234
46184
  }
46235
46185
  const row = rows[index2] ?? {};
46186
+ const { group_: g_ } = row;
46236
46187
  rows[index2] = row;
46237
- const uidField = axis === "y" ? "__gw_y_uid" : "__gw_x_uid";
46188
+ const isY = axis === "y";
46189
+ const uidField = isY ? "__gw_y_uid" : "__gw_x_uid";
46238
46190
  if (!row[uidField]) {
46239
- row[uidField] = row.id || `${axis}_${uuid()}`;
46191
+ row[uidField] = g_ ? g_.includes(":") ? g_.split(":")[isY ? 0 : 1] : g_ : `${axis}_${uuid()}`;
46240
46192
  }
46241
46193
  return row;
46242
46194
  }
@@ -46337,6 +46289,39 @@ class DataManager {
46337
46289
  this.emit(path2, next, oldValue);
46338
46290
  });
46339
46291
  }
46292
+ /**
46293
+ * 复制轴行插入时:若 uid 与已有行重复,换新 uid 并复制关联交叉区行。
46294
+ */
46295
+ duplicateCrossRowsByAxisUid(crossKeys, axis, oldUid, newUid) {
46296
+ const uidField = axis === "y" ? "__gw_y_uid" : "__gw_x_uid";
46297
+ for (const crossKey of crossKeys) {
46298
+ const path2 = `$.${crossKey}`;
46299
+ const rows = this.getByPath(this.rawData, path2);
46300
+ if (!Array.isArray(rows)) continue;
46301
+ const matched = rows.filter((item) => item?.[uidField] === oldUid);
46302
+ if (matched.length === 0) continue;
46303
+ const oldValue = this.deepClone(rows);
46304
+ const copies = matched.map((item) => {
46305
+ const copy = this.deepClone(item);
46306
+ copy[uidField] = newUid;
46307
+ return copy;
46308
+ });
46309
+ const next = [...rows, ...copies];
46310
+ this.setByPath(this.rawData, path2, next);
46311
+ this.emit(path2, next, oldValue);
46312
+ }
46313
+ }
46314
+ prepareAxisRowForInsert(arr, axisInfo, value) {
46315
+ const cloned = this.deepClone(value);
46316
+ const uidField = axisInfo.axis === "y" ? "__gw_y_uid" : "__gw_x_uid";
46317
+ const oldUid = cloned?.[uidField];
46318
+ if (oldUid && arr.some((row) => row?.[uidField] === oldUid)) {
46319
+ const newUid = `${axisInfo.axis}_${uuid()}`;
46320
+ cloned[uidField] = newUid;
46321
+ this.duplicateCrossRowsByAxisUid(axisInfo.crossKeys, axisInfo.axis, oldUid, newUid);
46322
+ }
46323
+ return cloned;
46324
+ }
46340
46325
  /**
46341
46326
  * 将一个部分值对象合进整体
46342
46327
  */
@@ -46406,7 +46391,7 @@ class DataManager {
46406
46391
  const tableKey = path2.replace(/^\$\./, "").replace(/\[(n|\d+)\]/g, "");
46407
46392
  const axisInfo = this.resolveAxisByTableKey(tableKey);
46408
46393
  values.forEach((value) => {
46409
- const cloned = this.deepClone(value);
46394
+ const cloned = axisInfo ? this.prepareAxisRowForInsert(arr, axisInfo, value) : this.deepClone(value);
46410
46395
  arr.push(cloned);
46411
46396
  if (axisInfo) {
46412
46397
  const index2 = arr.length - 1;
@@ -46467,10 +46452,12 @@ class DataManager {
46467
46452
  throw new Error(`Index ${index2} out of bounds for array of length ${arr.length}`);
46468
46453
  }
46469
46454
  const oldValue = [...arr];
46470
- const clonedValues = values.map((value) => this.deepClone(value));
46471
- arr.splice(index2, 0, ...clonedValues);
46472
46455
  const tableKey = path2.replace(/^\$\./, "").replace(/\[(n|\d+)\]/g, "");
46473
46456
  const axisInfo = this.resolveAxisByTableKey(tableKey);
46457
+ const clonedValues = values.map(
46458
+ (value) => axisInfo ? this.prepareAxisRowForInsert(arr, axisInfo, value) : this.deepClone(value)
46459
+ );
46460
+ arr.splice(index2, 0, ...clonedValues);
46474
46461
  if (axisInfo) {
46475
46462
  for (let i = index2; i < arr.length; i++) {
46476
46463
  this.ensureAxisRowAndUid(tableKey, i, axisInfo.axis);
@@ -46521,6 +46508,7 @@ class DataManager {
46521
46508
  const data = this.deepClone(this.rawData);
46522
46509
  for (let path2 of this.defaults.keys()) {
46523
46510
  if (this.defaults.get(path2) === void 0) continue;
46511
+ if (path2.includes("[n")) continue;
46524
46512
  const value = this.getByPath(data, path2);
46525
46513
  if (value !== void 0) continue;
46526
46514
  this.setByPath(data, path2, this.getDefault(path2));
@@ -46554,13 +46542,22 @@ class DataManager {
46554
46542
  applyInitData(initDataMap) {
46555
46543
  for (const [path2, value] of Object.entries(initDataMap)) {
46556
46544
  if (value === void 0 || value === null) continue;
46557
- if (path2.includes("[n]")) {
46545
+ const parse = parseValuePath(path2);
46546
+ if (parse.isSubTable && !parse.isLink) {
46558
46547
  this.applyInitDataWildcard(path2, value);
46559
46548
  }
46560
46549
  }
46561
46550
  for (const [path2, value] of Object.entries(initDataMap)) {
46562
46551
  if (value === void 0 || value === null) continue;
46563
- if (!path2.includes("[n]")) {
46552
+ const parse = parseValuePath(path2);
46553
+ if (parse.isSubTable && parse.isLink) {
46554
+ this.applyInitDataCrossWildcard(path2, value);
46555
+ }
46556
+ }
46557
+ for (const [path2, value] of Object.entries(initDataMap)) {
46558
+ if (value === void 0 || value === null) continue;
46559
+ const parse = parseValuePath(path2);
46560
+ if (!(parse.isSubTable || parse.isLink)) {
46564
46561
  const existing = this.getByPath(this.rawData, path2);
46565
46562
  if (existing === void 0 || existing === null) {
46566
46563
  try {
@@ -46574,25 +46571,99 @@ class DataManager {
46574
46571
  }
46575
46572
  }
46576
46573
  }
46577
- applyInitDataWildcard(path2, value) {
46578
- const match = path2.match(/^\$\.([^[.]+)\[n\]/);
46579
- if (!match) return;
46580
- const subTableKey = match[1];
46581
- let subTableArray = this.rawData?.[subTableKey];
46582
- if (!Array.isArray(subTableArray) || subTableArray.length === 0) {
46583
- subTableArray = [{ ...DEFAULT_EMPTY_ITEM }];
46574
+ applyInitDataCrossWildcard(path2, value) {
46575
+ const parse = parseValuePath(path2);
46576
+ if (!parse.isLink) return;
46577
+ const yTableKey = parse.parentFieldKey;
46578
+ const xTableKey = parse.linkFieldKey;
46579
+ if (!yTableKey || !xTableKey) return;
46580
+ const yRows = this.ensureSubTableRowCount(
46581
+ yTableKey,
46582
+ this.resolveInitRowCount(yTableKey),
46583
+ false
46584
+ );
46585
+ const xRows = this.ensureSubTableRowCount(
46586
+ xTableKey,
46587
+ this.resolveInitRowCount(xTableKey),
46588
+ false
46589
+ );
46590
+ for (let y2 = 0; y2 < yRows.length; y2++) {
46591
+ for (let x2 = 0; x2 < xRows.length; x2++) {
46592
+ const realPath = replacePathIndexPlaceholders({ y: y2, x: x2, templatePath: path2 });
46593
+ const inferred = this.infer2DPathAndCoords(realPath);
46594
+ const existing = inferred ? this.get2DByCoords(inferred.logicalPath, inferred.coords) : this.getByPath(this.rawData, realPath);
46595
+ if (existing === void 0 || existing === null) {
46596
+ try {
46597
+ if (this.set(realPath, value, "user")) {
46598
+ this.clearPlaceholderFlag(yRows[y2]);
46599
+ this.clearPlaceholderFlag(xRows[x2]);
46600
+ } else {
46601
+ console.warn(`applyInitData: set returned false for path "${realPath}"`);
46602
+ }
46603
+ } catch (e) {
46604
+ console.warn(`applyInitData: failed to set path "${realPath}"`, e);
46605
+ }
46606
+ }
46607
+ }
46608
+ }
46609
+ }
46610
+ /**
46611
+ * 解析子表初始化行数:接口已有行数、版面数据分组槽位。
46612
+ * layoutRows 为 0(如二维表纵向 f_ewb)时不按分组扩行,仅保证至少 1 行可绑定。
46613
+ */
46614
+ resolveInitRowCount(subTableKey) {
46615
+ const existing = this.rawData?.[subTableKey];
46616
+ const dataRows = Array.isArray(existing) ? existing.length : 0;
46617
+ const layoutRows = this.doc?.model?.getSubTableLayoutSlotCount(subTableKey) ?? 1;
46618
+ if (layoutRows > 0) {
46619
+ return Math.max(dataRows, layoutRows);
46620
+ }
46621
+ return Math.max(dataRows, 1);
46622
+ }
46623
+ /**
46624
+ * 将子表数组补齐到指定行数。
46625
+ * @param asPlaceholder true:push/insert 用的系统占位行(带 __gw_default);false:applyInitData 物化行(空对象)
46626
+ */
46627
+ ensureSubTableRowCount(subTableKey, rowCount, asPlaceholder = true) {
46628
+ let arr = this.rawData?.[subTableKey];
46629
+ if (!Array.isArray(arr)) {
46630
+ arr = [];
46631
+ this.rawData[subTableKey] = arr;
46632
+ }
46633
+ while (arr.length < rowCount) {
46634
+ arr.push(asPlaceholder ? { ...DEFAULT_EMPTY_ITEM } : {});
46635
+ }
46636
+ return arr;
46637
+ }
46638
+ /** 行已写入业务数据后去掉占位标记,避免提交/对比时被当成空行 */
46639
+ clearPlaceholderFlag(row) {
46640
+ if (row && row.__gw_default) {
46641
+ delete row.__gw_default;
46584
46642
  }
46643
+ }
46644
+ applyInitDataWildcard(path2, value) {
46645
+ const subTableKey = parseValuePath(path2).parentFieldKey;
46646
+ if (!subTableKey) return;
46647
+ const subTableArray = this.ensureSubTableRowCount(
46648
+ subTableKey,
46649
+ this.resolveInitRowCount(subTableKey),
46650
+ false
46651
+ );
46585
46652
  for (let i = 0; i < subTableArray.length; i++) {
46586
46653
  const realPath = replacePathIndexPlaceholder(i, path2);
46587
46654
  const existing = this.getByPath(this.rawData, realPath);
46588
46655
  if (existing === void 0 || existing === null) {
46589
46656
  try {
46590
- if (!this.set(realPath, value, "user")) {
46657
+ if (this.set(realPath, value, "user")) {
46658
+ this.clearPlaceholderFlag(subTableArray[i]);
46659
+ } else {
46591
46660
  console.warn(`applyInitData: set returned false for path "${realPath}"`);
46592
46661
  }
46593
46662
  } catch (e) {
46594
46663
  console.warn(`applyInitData: failed to set path "${realPath}"`, e);
46595
46664
  }
46665
+ } else {
46666
+ this.clearPlaceholderFlag(subTableArray[i]);
46596
46667
  }
46597
46668
  }
46598
46669
  }
@@ -46874,12 +46945,21 @@ class DataManager {
46874
46945
  return void 0;
46875
46946
  }
46876
46947
  /**
46877
- * 将路径中的具体数组索引转换为通配符
46878
- * 例如: "items[0].name" -> "items[n].name"
46879
- * @param path 原始路径
46880
- * @returns 转换后的路径
46948
+ * 将路径中的具体数组索引转换为默认值通配符
46949
+ * - 普通子表: items[0].name -> items[n].name
46950
+ * - 二维交叉区: $.f_ewb:f_ewblink[0][1].f_value -> $.f_ewb:f_ewblink[n_y][n_x].f_value
46881
46951
  */
46882
46952
  convertPathToWildcard(path2) {
46953
+ const headKey = path2.replace(/^\$\./, "").split(/[\[.]/)[0] ?? "";
46954
+ const isCross = headKey.includes(":");
46955
+ if (isCross) {
46956
+ let index2 = 0;
46957
+ return path2.replace(/\[(\d+)\]/g, () => {
46958
+ const placeholder = index2 === 0 ? "n_y" : index2 === 1 ? "n_x" : "n";
46959
+ index2++;
46960
+ return `[${placeholder}]`;
46961
+ });
46962
+ }
46883
46963
  return path2.replace(/\[(\d+)\]/g, "[n]");
46884
46964
  }
46885
46965
  formatRuntimeValue(value) {
@@ -46931,9 +47011,9 @@ class DataManager {
46931
47011
  if (!this.depGraph.has(realPath)) {
46932
47012
  this.depGraph.set(realPath, /* @__PURE__ */ new Map());
46933
47013
  }
46934
- const map2 = this.depGraph.get(realPath);
46935
- if (!map2.has(depKey)) {
46936
- map2.set(depKey, node);
47014
+ const map = this.depGraph.get(realPath);
47015
+ if (!map.has(depKey)) {
47016
+ map.set(depKey, node);
46937
47017
  }
46938
47018
  });
46939
47019
  }
@@ -46961,9 +47041,9 @@ class DataManager {
46961
47041
  }
46962
47042
  /** 执行依赖 */
46963
47043
  async runDepsByPath(triggerPath, realPath) {
46964
- const map2 = this.depGraph.get(triggerPath);
46965
- if (!map2) return;
46966
- for (const node of map2.values()) {
47044
+ const map = this.depGraph.get(triggerPath);
47045
+ if (!map) return;
47046
+ for (const node of map.values()) {
46967
47047
  await this.runDependency(node, realPath, triggerPath === realPath);
46968
47048
  }
46969
47049
  }
@@ -47280,14 +47360,14 @@ class Doc {
47280
47360
  */
47281
47361
  getWidgetInstances() {
47282
47362
  const instances = [];
47283
- const map2 = /* @__PURE__ */ new Map();
47363
+ const map = /* @__PURE__ */ new Map();
47284
47364
  const collectWidgets = (node) => {
47285
47365
  if (!node) return;
47286
47366
  if (node.widgetMeta && node.valuePath) {
47287
47367
  const refId = node.modelRef?.id;
47288
- if (refId && !map2.has(refId)) {
47368
+ if (refId && !map.has(refId)) {
47289
47369
  instances.push(node);
47290
- map2.set(refId, true);
47370
+ map.set(refId, true);
47291
47371
  }
47292
47372
  }
47293
47373
  if (node.children && Array.isArray(node.children)) {
@@ -48920,6 +49000,41 @@ class Woverlays {
48920
49000
  });
48921
49001
  }
48922
49002
  }
49003
+ function countDataGroupSlots(range3, itemRange, fillDirection = "x") {
49004
+ const itemWidth = itemRange.end.col - itemRange.start.col + 1;
49005
+ const itemHeight = itemRange.end.row - itemRange.start.row + 1;
49006
+ let slotCount = 1;
49007
+ if (fillDirection === "x") {
49008
+ let currentRow = itemRange.start.row;
49009
+ let currentCol = itemRange.end.col + 1;
49010
+ while (currentRow + itemHeight - 1 <= range3.end.row) {
49011
+ while (currentCol + itemWidth - 1 <= range3.end.col) {
49012
+ slotCount++;
49013
+ currentCol += itemWidth;
49014
+ }
49015
+ currentRow += itemHeight;
49016
+ currentCol = range3.start.col;
49017
+ }
49018
+ } else {
49019
+ let currentCol = itemRange.start.col;
49020
+ let currentRow = itemRange.end.row + 1;
49021
+ while (currentCol + itemWidth - 1 <= range3.end.col) {
49022
+ while (currentRow + itemHeight - 1 <= range3.end.row) {
49023
+ slotCount++;
49024
+ currentRow += itemHeight;
49025
+ }
49026
+ currentCol += itemWidth;
49027
+ currentRow = range3.start.row;
49028
+ }
49029
+ }
49030
+ return slotCount;
49031
+ }
49032
+ function expandDataGroupRowRange(parent2, itemRange) {
49033
+ return {
49034
+ start: { row: itemRange.start.row, col: parent2.start.col },
49035
+ end: { row: itemRange.end.row, col: parent2.end.col }
49036
+ };
49037
+ }
48923
49038
  class DocModel {
48924
49039
  document;
48925
49040
  headers;
@@ -49047,7 +49162,7 @@ class DocModel {
49047
49162
  const tables = this.getAllTables();
49048
49163
  const dynamicTableRegions = tables.filter((w2) => w2.hasRepeating).flatMap((w2) => w2.repeating).map((item) => {
49049
49164
  return {
49050
- field: getLastSegment(item.valuePath),
49165
+ field: item.subFieldKey,
49051
49166
  key: "dyn",
49052
49167
  name: "动态表",
49053
49168
  subType: "sub-table"
@@ -49055,28 +49170,25 @@ class DocModel {
49055
49170
  });
49056
49171
  const fixedTableRegions = tables.filter((w2) => w2.hasBounded).flatMap((w2) => w2.bounded).map((item) => {
49057
49172
  return {
49058
- field: getLastSegment(item.valuePath),
49173
+ field: item.subFieldKey,
49059
49174
  key: "newfixed",
49060
49175
  name: "固定表",
49061
49176
  subType: "fixed-table"
49062
49177
  };
49063
49178
  });
49064
49179
  const table2DRegions = tables.filter((w2) => w2.has2DTable).flatMap((w2) => w2._2DTable).map((item) => {
49065
- const parsed = parseValuePath(item.valuePath);
49066
- const subFieldKey = parsed.isLink ? parsed.parentFieldKey ?? "" : parsed.fieldKey;
49067
- const linkFieldKey = parsed.linkFieldKey ?? "";
49068
49180
  const result = [];
49069
- if (subFieldKey) {
49181
+ if (item.subFieldKey) {
49070
49182
  result.push({
49071
- field: subFieldKey,
49183
+ field: item.subFieldKey,
49072
49184
  key: "dyn",
49073
49185
  name: "二维表",
49074
49186
  subType: "sub-table-2d"
49075
49187
  });
49076
49188
  }
49077
- if (linkFieldKey) {
49189
+ if (item.linkFieldKey) {
49078
49190
  result.push({
49079
- field: linkFieldKey,
49191
+ field: item.linkFieldKey,
49080
49192
  key: "newfixed",
49081
49193
  name: "二维表-关联",
49082
49194
  subType: "sub-table-2d-link"
@@ -49085,21 +49197,18 @@ class DocModel {
49085
49197
  return result;
49086
49198
  }).flat();
49087
49199
  const checkTableRegions = tables.filter((w2) => w2.hasCheckTable).flatMap((w2) => w2.checkTable).map((item) => {
49088
- const parsed = parseValuePath(item.valuePath);
49089
- const subFieldKey = parsed.isLink ? parsed.parentFieldKey ?? "" : parsed.fieldKey;
49090
- const linkFieldKey = parsed.linkFieldKey ?? "";
49091
49200
  const result = [];
49092
- if (subFieldKey) {
49201
+ if (item.subFieldKey) {
49093
49202
  result.push({
49094
- field: subFieldKey,
49203
+ field: item.subFieldKey,
49095
49204
  key: "newfixed",
49096
49205
  name: "检验表-动态",
49097
49206
  subType: "check-table-2d"
49098
49207
  });
49099
49208
  }
49100
- if (linkFieldKey) {
49209
+ if (item.linkFieldKey) {
49101
49210
  result.push({
49102
- field: linkFieldKey,
49211
+ field: item.linkFieldKey,
49103
49212
  key: "newfixed",
49104
49213
  name: "检验表-关联",
49105
49214
  subType: "check-table-2d-link"
@@ -49109,6 +49218,42 @@ class DocModel {
49109
49218
  }).flat();
49110
49219
  return [...dynamicTableRegions, ...fixedTableRegions, ...table2DRegions, ...checkTableRegions];
49111
49220
  }
49221
+ /**
49222
+ * 根据版面数据分组 / 动态关联铺砖,计算子表字段在 rawData 中应初始化的行数。
49223
+ *
49224
+ * - 固定表:槽位归 subFieldKey(bounded + itemRegion)
49225
+ * - 二维表 / 检验表:动态分组铺砖在关联轴,槽位归 linkFieldKey(如 f_ewblink);
49226
+ * 纵向 subFieldKey(如 f_ewb)不由 itemRegion 撑行,返回 0
49227
+ * - 其它子表无分组:返回 1
49228
+ */
49229
+ getSubTableLayoutSlotCount(subFieldKey) {
49230
+ if (!subFieldKey) return 1;
49231
+ let max = 0;
49232
+ let isLinkSubTableSubAxisOnly = false;
49233
+ for (const table of this.getAllTables()) {
49234
+ for (const region of table.bounded) {
49235
+ if (region.subFieldKey !== subFieldKey || !region.itemRegion) continue;
49236
+ const fillDirection = region.widgetMeta?.props?.fillDirection ?? "x";
49237
+ max = Math.max(max, countDataGroupSlots(region, region.itemRegion, fillDirection));
49238
+ region.type;
49239
+ }
49240
+ for (const region of [...table.checkTable, ...table._2DTable]) {
49241
+ if (!region.itemRegion) continue;
49242
+ const range3 = expandDataGroupRowRange(region, region.itemRegion);
49243
+ const slots = countDataGroupSlots(range3, region.itemRegion);
49244
+ if (region.linkFieldKey === subFieldKey) {
49245
+ max = Math.max(max, slots);
49246
+ region.type;
49247
+ }
49248
+ if (region.subFieldKey === subFieldKey) {
49249
+ isLinkSubTableSubAxisOnly = true;
49250
+ }
49251
+ }
49252
+ }
49253
+ if (max > 0) return max;
49254
+ if (isLinkSubTableSubAxisOnly) return 0;
49255
+ return 1;
49256
+ }
49112
49257
  /** 根据 pageIndex 获取页眉实例 */
49113
49258
  getHeader(pageIndex, section) {
49114
49259
  const hasEvenOdd = this.settings?.isEvenAndOddEnabled();
@@ -50111,19 +50256,19 @@ function getBpmnFieldAuthMap(list) {
50111
50256
  );
50112
50257
  }
50113
50258
  function deduplicateFields(data) {
50114
- const map2 = /* @__PURE__ */ new Map();
50259
+ const map = /* @__PURE__ */ new Map();
50115
50260
  data.forEach((item) => {
50116
50261
  const key = `${item.modelKey}_${item.field}`;
50117
- if (!map2.has(key)) {
50118
- map2.set(key, item);
50262
+ if (!map.has(key)) {
50263
+ map.set(key, item);
50119
50264
  } else {
50120
- const existing = map2.get(key);
50265
+ const existing = map.get(key);
50121
50266
  if (item.edit && !existing.edit) {
50122
- map2.set(key, item);
50267
+ map.set(key, item);
50123
50268
  }
50124
50269
  }
50125
50270
  });
50126
- return [...map2.values()];
50271
+ return [...map.values()];
50127
50272
  }
50128
50273
  class DocRequestStrategy {
50129
50274
  props;
@@ -50469,13 +50614,23 @@ const withRequestCache = new RequestCache({
50469
50614
  enableLogging: true
50470
50615
  // 启用日志
50471
50616
  });
50617
+ const FILTER_KEYS = [
50618
+ "_DICT",
50619
+ "_OPCT",
50620
+ "__FOREIGN__",
50621
+ "_MCTABLE",
50622
+ "__default_render__",
50623
+ "__gw_default",
50624
+ "__gw_x_uid",
50625
+ "__gw_y_uid"
50626
+ ];
50472
50627
  function transformSourceData(sourceData, i18nData) {
50473
50628
  const clone2 = cloneDeep(sourceData);
50474
50629
  const _DICT = i18nData ? Object.keys(clone2).reduce((acc, key) => {
50475
- const map2 = i18nData[key];
50630
+ const map = i18nData[key];
50476
50631
  const value = clone2[key];
50477
- if (map2 && value) {
50478
- const labels = String(value).split(",").map((k) => map2[k]);
50632
+ if (map && value) {
50633
+ const labels = String(value).split(",").map((k) => map[k]);
50479
50634
  acc[key] = { [value]: labels };
50480
50635
  }
50481
50636
  return acc;
@@ -50495,12 +50650,63 @@ function transformSourceDataList(data, dict = {}) {
50495
50650
  return list || [];
50496
50651
  }
50497
50652
  function conversionFormState(payload) {
50498
- const { interfaceData, masterSlaveList } = payload || {};
50653
+ const { interfaceData, masterSlaveList, instances } = payload || {};
50499
50654
  const formState = {};
50500
50655
  if (interfaceData && interfaceData.data) {
50501
50656
  merge(formState, transformSourceData(interfaceData.data, interfaceData.dict));
50502
50657
  }
50503
- masterSlaveList.map((item) => item.key).forEach((k) => {
50658
+ let _2dKeys = [];
50659
+ if (instances) {
50660
+ const _2DFieldList = instances.map(({ valuePath }) => {
50661
+ if (valuePath.includes(":")) {
50662
+ const { fieldKey, parentFieldKey, linkFieldKey } = parseValuePath(valuePath);
50663
+ const group2DKey = `${parentFieldKey}:${linkFieldKey}`;
50664
+ return {
50665
+ fieldKey,
50666
+ group2DKey
50667
+ };
50668
+ } else {
50669
+ return null;
50670
+ }
50671
+ }).filter(Boolean);
50672
+ Object.entries(groupBy$1(_2DFieldList, "group2DKey")).forEach(([group2DKey, fields]) => {
50673
+ _2dKeys.push(group2DKey);
50674
+ const [parentFieldKey, linkFieldKey] = group2DKey.split(":");
50675
+ const parentState = formState[parentFieldKey];
50676
+ const keys2 = ["group_", ...fields.map((f) => f.fieldKey)];
50677
+ formState[linkFieldKey]?.data.forEach((row) => {
50678
+ row.__gw_x_uid = row.group_;
50679
+ });
50680
+ formState[group2DKey] = {
50681
+ data: parentState?.data.map((row) => {
50682
+ const { group_: g_ } = row;
50683
+ const _row = pick(row, keys2);
50684
+ if (g_) {
50685
+ const [y2, x2] = g_.split(":");
50686
+ _row.__gw_y_uid = y2;
50687
+ _row.__gw_x_uid = x2;
50688
+ }
50689
+ return _row;
50690
+ }) || [],
50691
+ dict: parentState?.dict || []
50692
+ };
50693
+ const addedYUids = [];
50694
+ formState[parentFieldKey] = {
50695
+ data: [],
50696
+ dict: formState[parentFieldKey]?.dict || []
50697
+ };
50698
+ parentState?.data.forEach((row) => {
50699
+ const yUid = row.group_.split(":")[0];
50700
+ if (addedYUids.includes(yUid)) return;
50701
+ addedYUids.push(yUid);
50702
+ formState[parentFieldKey].data.push({
50703
+ ...row,
50704
+ __gw_y_uid: yUid
50705
+ });
50706
+ });
50707
+ });
50708
+ }
50709
+ masterSlaveList.map((item) => item.key).concat(_2dKeys).forEach((k) => {
50504
50710
  const subFormData = formState[k];
50505
50711
  if (subFormData) {
50506
50712
  formState[k] = transformSourceDataList([...subFormData.data], subFormData.dict);
@@ -50509,43 +50715,52 @@ function conversionFormState(payload) {
50509
50715
  return formState;
50510
50716
  }
50511
50717
  function getSubmitFormData(formData) {
50512
- const list2D = [];
50513
- const filterKeys = ["_DICT", "_OPCT", "__FOREIGN__", "_MCTABLE", "__default_render__"];
50514
- const realFormData = Object.keys(formData).reduce((acc, fieldKey) => {
50515
- const info = list2D.find(
50516
- (item) => (item.subTable2d || item.checkTable2d) && item.rowSubFieldKey === fieldKey
50517
- );
50518
- if (info) {
50519
- const colSubTable = formData[info.colSubFieldKey]?.map((item) => ({
50520
- [info.rowRefFieldKey]: item[info.colRefFieldKey]
50521
- }));
50522
- const arr = flatMap(
50523
- formData[fieldKey],
50524
- (row) => zip(row["_2DTABLE_"], colSubTable).map(([obj1, obj2]) => merge({}, obj1, obj2)).map(
50525
- (item) => merge(
50526
- pickBy(omit(row, filterKeys), (v) => !isNil(v)),
50527
- pickBy(omit(item, filterKeys), (v) => !isNil(v))
50528
- )
50529
- )
50530
- ).map((item) => omit(item, "_2DTABLE_"));
50531
- acc[fieldKey] = arr.every((item) => Object.keys(item).length === 1 && has(item, "group_")) ? [] : arr;
50532
- } else if (Array.isArray(formData[fieldKey])) {
50533
- acc[fieldKey] = formData[fieldKey].map(
50534
- (item) => Object.fromEntries(
50535
- Object.entries(item).filter(([key, value]) => {
50536
- if (filterKeys.includes(key)) return false;
50718
+ const _formData = { ...formData };
50719
+ Object.keys(_formData).filter((k) => k.includes(":")).forEach((_2DKey) => {
50720
+ const [subKey] = _2DKey.split(":");
50721
+ const _2DData = _formData[_2DKey];
50722
+ const subData = [..._formData[subKey]];
50723
+ if ([_2DData, subData].every(Array.isArray)) {
50724
+ _formData[subKey] = [];
50725
+ _2DData.forEach((obj) => {
50726
+ const { __gw_y_uid, __gw_x_uid } = obj;
50727
+ const row = subData.find((row2) => row2.__gw_y_uid === __gw_y_uid);
50728
+ if (!row) return;
50729
+ _formData[subKey].push({
50730
+ // 保留动态关联前端键值到 group_
50731
+ group_: `${__gw_y_uid}:${__gw_x_uid}`,
50732
+ ...row,
50733
+ ...omit(obj, FILTER_KEYS)
50734
+ });
50735
+ });
50736
+ }
50737
+ delete _formData[_2DKey];
50738
+ });
50739
+ const realFormData = Object.keys(_formData).reduce((reducedData, fieldKey) => {
50740
+ const fieldValue = _formData[fieldKey];
50741
+ if (Array.isArray(fieldValue)) {
50742
+ fieldValue.forEach((row) => {
50743
+ const { __gw_x_uid } = row;
50744
+ if (__gw_x_uid) {
50745
+ row.group_ = __gw_x_uid;
50746
+ }
50747
+ });
50748
+ reducedData[fieldKey] = _formData[fieldKey].map(
50749
+ (row) => Object.fromEntries(
50750
+ Object.entries(row).filter(([key, value]) => {
50751
+ if (FILTER_KEYS.includes(key)) return false;
50537
50752
  if (key.endsWith("_lb_") && isEmpty(value)) return false;
50538
50753
  return true;
50539
50754
  })
50540
50755
  )
50541
50756
  );
50542
50757
  } else {
50543
- acc[fieldKey] = formData[fieldKey];
50758
+ reducedData[fieldKey] = fieldValue;
50544
50759
  }
50545
- return acc;
50760
+ return reducedData;
50546
50761
  }, {});
50547
- console.log("0506 数据转成真实提交数据(二维表要平铺)", realFormData);
50548
- return omit(realFormData, filterKeys);
50762
+ console.log("数据转成真实提交数据", realFormData);
50763
+ return omit(realFormData, FILTER_KEYS);
50549
50764
  }
50550
50765
  const API_CONFIG = {
50551
50766
  ENTITY_CATEGORY: "entity",
@@ -51249,8 +51464,13 @@ async function applyAutofillRules(record, instances, autofillRules, masterSlaveL
51249
51464
  const targetField = widgetMeta.field;
51250
51465
  if (!targetField) continue;
51251
51466
  let runtimeValuePath = targetField.valuePath;
51467
+ if (parseValuePath(runtimeValuePath).isLink) continue;
51252
51468
  if (opts?.needReplacePathIndexPlaceholder) {
51253
- runtimeValuePath = replacePathIndexPlaceholder(opts.sourceValuePath, runtimeValuePath);
51469
+ if (parseValuePath(opts.sourceValuePath).isLink) continue;
51470
+ runtimeValuePath = replacePathIndexPlaceholders({
51471
+ refPath: opts.sourceValuePath,
51472
+ templatePath: runtimeValuePath
51473
+ });
51254
51474
  }
51255
51475
  const computed2 = await computeFieldDefaultValue({
51256
51476
  fieldType: targetField.fieldType,
@@ -51794,15 +52014,17 @@ const handleParameterMapping = async (parameterMapping, paramsConfig, fieldPermi
51794
52014
  const processParamItem = async (item) => {
51795
52015
  if (!referenceMap.has(item.formKey)) return;
51796
52016
  const value = referenceMap.get(item.formKey);
51797
- const valuePath = generateValuePath(item.field, item?.subModel ? item.subFieldKey : "");
51798
52017
  const widget = instances.find((instance2) => {
51799
52018
  const fieldMeta = instance2.widgetMeta?.field;
51800
52019
  if (item?.subModel) {
51801
- return item.field === getLastSegment(fieldMeta?.fieldLink) && item.subFieldKey === fieldMeta?.subFieldKey;
52020
+ const parsed = parseValuePath(fieldMeta?.subFieldKey);
52021
+ const subFieldKey = parsed.isLink ? parsed.parentFieldKey ?? "" : parsed.fieldKey;
52022
+ return item.field === getLastSegment(fieldMeta?.fieldLink) && item.subFieldKey === subFieldKey;
51802
52023
  }
51803
52024
  return item.field === getLastSegment(fieldMeta?.fieldLink) && !fieldMeta?.subFieldKey;
51804
52025
  });
51805
52026
  if (widget) {
52027
+ const valuePath = widget.valuePath;
51806
52028
  const computed2 = await computeFieldDefaultValue({
51807
52029
  fieldType: item.fieldType,
51808
52030
  fieldMeta: widget.widgetMeta.field,
@@ -51814,8 +52036,6 @@ const handleParameterMapping = async (parameterMapping, paramsConfig, fieldPermi
51814
52036
  allowSubModelRequest: true
51815
52037
  });
51816
52038
  merge(paramMap, computed2);
51817
- } else {
51818
- merge(paramMap, { [valuePath]: toFormatValue(item.fieldType, value) });
51819
52039
  }
51820
52040
  };
51821
52041
  await Promise.all([...builtinParams, ...compParams].map(processParamItem));
@@ -51833,11 +52053,10 @@ const buildPathMapFromApiResult = (onFieldMap, result, subTableInfo) => {
51833
52053
  onFieldMap.forEach((item) => {
51834
52054
  if (item.subModel === 0) {
51835
52055
  const firstRow = data[0];
51836
- item.fields.forEach(({ isFieldModel, leftFieldKey, fieldLink, rightFieldKey }) => {
52056
+ item.fields.forEach(({ isFieldModel, fieldLink, rightFieldKey, valuePath }) => {
51837
52057
  const srcKey = rightFieldKey;
51838
52058
  const value = isFieldModel ? firstRow?.__FOREIGN__?.[fieldLink] : firstRow?.[srcKey];
51839
- if (value != null) {
51840
- const valuePath = generateValuePath(leftFieldKey, "");
52059
+ if (value != null && valuePath) {
51841
52060
  pathMap[valuePath] = value;
51842
52061
  const label = getLabelFromDict(srcKey, value);
51843
52062
  if (label != null) pathMap[`${valuePath}_lb_`] = label;
@@ -51845,12 +52064,15 @@ const buildPathMapFromApiResult = (onFieldMap, result, subTableInfo) => {
51845
52064
  });
51846
52065
  } else if (item.subModel === 1) {
51847
52066
  data.forEach(
51848
- (rowData, index2) => item.fields.forEach(({ isFieldModel, leftFieldKey, fieldLink, rightFieldKey }) => {
52067
+ (rowData, index2) => item.fields.forEach(({ isFieldModel, fieldLink, rightFieldKey, valuePath }) => {
51849
52068
  const srcKey = rightFieldKey;
51850
52069
  const value = isFieldModel ? rowData?.__FOREIGN__?.[fieldLink] : rowData?.[srcKey];
51851
- if (value != null) {
51852
- const valuePath = generateValuePath(leftFieldKey, item.subFieldKey);
51853
- const runtimeValuePath = replacePathIndexPlaceholder(index2, valuePath);
52070
+ if (value != null && valuePath) {
52071
+ const runtimeValuePath = replacePathIndexPlaceholders({
52072
+ y: index2,
52073
+ n: index2,
52074
+ templatePath: valuePath
52075
+ });
51854
52076
  pathMap[runtimeValuePath] = value;
51855
52077
  const label = getLabelFromDict(srcKey, value);
51856
52078
  if (label != null) pathMap[`${runtimeValuePath}_lb_`] = label;
@@ -51861,7 +52083,7 @@ const buildPathMapFromApiResult = (onFieldMap, result, subTableInfo) => {
51861
52083
  });
51862
52084
  return pathMap;
51863
52085
  };
51864
- const handleCustomDataSource = async (customDataSource, paramsConfig, subTableInfo, instanceId) => {
52086
+ const handleCustomDataSource = async (customDataSource, paramsConfig, subTableInfo, instanceId, instances) => {
51865
52087
  if (!customDataSource.length || !paramsConfig) {
51866
52088
  return {};
51867
52089
  }
@@ -51882,7 +52104,26 @@ const handleCustomDataSource = async (customDataSource, paramsConfig, subTableIn
51882
52104
  formKey: ex.formKey
51883
52105
  };
51884
52106
  }),
51885
- onFieldMap: item.onFieldMap
52107
+ onFieldMap: item.onFieldMap.map((k) => {
52108
+ return {
52109
+ ...k,
52110
+ fields: k.fields.map((field) => {
52111
+ const widget = instances.find((instance2) => {
52112
+ const fieldMeta = instance2.widgetMeta?.field;
52113
+ if (k?.subModel === 1) {
52114
+ const parsed = parseValuePath(fieldMeta?.subFieldKey);
52115
+ const subFieldKey = parsed.isLink ? parsed.parentFieldKey ?? "" : parsed.fieldKey;
52116
+ return field.leftFieldKey === getLastSegment(fieldMeta?.fieldLink) && k.subFieldKey === subFieldKey;
52117
+ }
52118
+ return field.leftFieldKey === getLastSegment(fieldMeta?.fieldLink) && !fieldMeta?.subFieldKey;
52119
+ });
52120
+ return {
52121
+ ...field,
52122
+ valuePath: widget ? widget.valuePath : ""
52123
+ };
52124
+ })
52125
+ };
52126
+ })
51886
52127
  };
51887
52128
  });
51888
52129
  for (const info of customDsList) {
@@ -51951,7 +52192,11 @@ const handleCustomDataSource = async (customDataSource, paramsConfig, subTableIn
51951
52192
  Object.entries(rowData).forEach(([key, value]) => {
51952
52193
  if (value != null) {
51953
52194
  const valuePath = generateValuePath(key, item.subFieldKey);
51954
- const runtimeValuePath = replacePathIndexPlaceholder(index2, valuePath);
52195
+ const runtimeValuePath = replacePathIndexPlaceholders({
52196
+ y: index2,
52197
+ n: index2,
52198
+ templatePath: valuePath
52199
+ });
51955
52200
  ipaasPathMap[runtimeValuePath] = value;
51956
52201
  }
51957
52202
  });
@@ -52010,7 +52255,7 @@ const handleCustomDataSource = async (customDataSource, paramsConfig, subTableIn
52010
52255
  }
52011
52256
  }
52012
52257
  const results = await Promise.all(promises);
52013
- return results.reduce((merged, map2) => merge(merged, map2), {});
52258
+ return results.reduce((merged, map) => merge(merged, map), {});
52014
52259
  };
52015
52260
  const loadDataInitValues = async (dataInitConfig, paramsConfig, subTableInfo, fieldPermission, instanceId, instances, ctx) => {
52016
52261
  if (!dataInitConfig) return { paramMap: {}, dsRawData: {} };
@@ -52026,7 +52271,8 @@ const loadDataInitValues = async (dataInitConfig, paramsConfig, subTableInfo, fi
52026
52271
  customDataSource,
52027
52272
  paramsConfig,
52028
52273
  subTableInfo,
52029
- instanceId
52274
+ instanceId,
52275
+ instances
52030
52276
  );
52031
52277
  return { paramMap, dsMap };
52032
52278
  };
@@ -52239,7 +52485,8 @@ async function initializeDocumentEngine(props, payload, result) {
52239
52485
  console.log("接口获取接口数据 ===>", interfaceData);
52240
52486
  const rawData = conversionFormState({
52241
52487
  masterSlaveList,
52242
- interfaceData
52488
+ interfaceData,
52489
+ instances
52243
52490
  });
52244
52491
  const docRuntimeMeta = {
52245
52492
  ...requestInfo,
@@ -52345,7 +52592,11 @@ function useDocumentFactory(props, payload) {
52345
52592
  instances,
52346
52593
  isMockReport: payload.isMockReport || payload.factoryType === "template"
52347
52594
  });
52348
- const rawData = conversionFormState({ masterSlaveList, interfaceData });
52595
+ const rawData = conversionFormState({
52596
+ masterSlaveList,
52597
+ interfaceData,
52598
+ instances
52599
+ });
52349
52600
  doc.dataManager.setRawData(rawData);
52350
52601
  await nextTick();
52351
52602
  doc.docRuntimeMeta.handleInfo.initRawDataSnapshot = cloneDeep(doc.dataManager.getRawData());
@@ -55830,6 +56081,228 @@ const builtinComponents = {
55830
56081
  [BuiltinComponentTypeConst.InlineImage]: _sfc_main$2L,
55831
56082
  [BuiltinComponentTypeConst.Text]: _sfc_main$2K
55832
56083
  };
56084
+ const OUTLINE_BORDER_INSET = 1;
56085
+ const borderConfig = {
56086
+ outer: {
56087
+ color: "rgb(128, 128, 128)",
56088
+ width: 1
56089
+ },
56090
+ inner: {
56091
+ color: "rgb(128, 128, 128)",
56092
+ width: 1
56093
+ },
56094
+ guide: {
56095
+ color: "#026AC8",
56096
+ width: 2
56097
+ }
56098
+ };
56099
+ const subThemeConfig = {
56100
+ "fixed-table": {
56101
+ label: "固定表",
56102
+ color: "#309C41",
56103
+ background: "rgba(48,156,65,0.1)",
56104
+ labelBjColor: "rgba(48,156,65,0.8)"
56105
+ },
56106
+ "check-table": {
56107
+ label: "检验表",
56108
+ color: "#309C41",
56109
+ background: "rgba(48,156,65,0.1)",
56110
+ labelBjColor: "rgba(48,156,65,0.8)"
56111
+ },
56112
+ "dynamic-table": {
56113
+ label: "动态表",
56114
+ color: "#026AC8",
56115
+ background: "rgba(2,106,200,0.1)",
56116
+ labelBjColor: "rgba(2,106,200,0.8)"
56117
+ },
56118
+ "2d-table": {
56119
+ label: "二维表",
56120
+ color: "#026AC8",
56121
+ background: "rgba(2,106,200,0.1)",
56122
+ labelBjColor: "rgba(2,106,200,0.8)"
56123
+ },
56124
+ "table-header": {
56125
+ label: "表头",
56126
+ color: "rgba(245, 69, 71, 1)",
56127
+ background: "rgba(245, 69, 71, 0.1)",
56128
+ labelBjColor: "rgba(245, 69, 71, 0.8)"
56129
+ },
56130
+ "data-group": {
56131
+ label: "数据分组",
56132
+ color: "#F77E4A",
56133
+ background: "rgba(247,126,74,0.1)",
56134
+ labelBjColor: "rgba(247,126,74,0.8)"
56135
+ },
56136
+ "data-group-2d": {
56137
+ label: "动态关联",
56138
+ color: "#F77E4A",
56139
+ background: "rgba(247,126,74,0.1)",
56140
+ labelBjColor: "rgba(247,126,74,0.8)"
56141
+ }
56142
+ };
56143
+ const getStyleByType = (type4) => {
56144
+ const config = subThemeConfig[type4];
56145
+ return {
56146
+ strokeColor: config?.color || "#000",
56147
+ backgroundColor: config?.background || "transparent",
56148
+ label: config?.label || "",
56149
+ labelBjColor: config?.labelBjColor || "#666"
56150
+ };
56151
+ };
56152
+ const EPS = 1e-3;
56153
+ function clipHLineByMerges(line, merges) {
56154
+ let segments = [line];
56155
+ merges.forEach((rect) => {
56156
+ segments = segments.flatMap((seg) => {
56157
+ const insideY = seg.y > rect.y + EPS && seg.y < rect.y + rect.height - EPS;
56158
+ if (!insideY) return [seg];
56159
+ if (seg.x2 <= rect.x + EPS || seg.x1 >= rect.x + rect.width - EPS) return [seg];
56160
+ if (rect.x <= seg.x1 + EPS && rect.x + rect.width >= seg.x2 - EPS) return [];
56161
+ const res = [];
56162
+ if (seg.x1 < rect.x - EPS) res.push({ ...seg, x2: rect.x });
56163
+ if (seg.x2 > rect.x + rect.width + EPS) res.push({ ...seg, x1: rect.x + rect.width });
56164
+ return res;
56165
+ });
56166
+ });
56167
+ return segments;
56168
+ }
56169
+ function clipVLineByMerges(line, merges) {
56170
+ let segments = [line];
56171
+ merges.forEach((rect) => {
56172
+ segments = segments.flatMap((seg) => {
56173
+ const insideX = seg.x > rect.x + EPS && seg.x < rect.x + rect.width - EPS;
56174
+ if (!insideX) return [seg];
56175
+ if (seg.y2 <= rect.y + EPS || seg.y1 >= rect.y + rect.height - EPS) return [seg];
56176
+ if (rect.y <= seg.y1 + EPS && rect.y + rect.height >= seg.y2 - EPS) return [];
56177
+ const res = [];
56178
+ if (seg.y1 < rect.y - EPS) res.push({ ...seg, y2: rect.y });
56179
+ if (seg.y2 > rect.y + rect.height + EPS) res.push({ ...seg, y1: rect.y + rect.height });
56180
+ return res;
56181
+ });
56182
+ });
56183
+ return segments;
56184
+ }
56185
+ function createTableOutlineLayer(options) {
56186
+ const { cells, inset = 1 } = options;
56187
+ if (!cells.length) return { backgroundRect: null, hLines: [], vLines: [], labelPos: void 0 };
56188
+ const minX = Math.min(...cells.map((c2) => c2.x));
56189
+ const minY = Math.min(...cells.map((c2) => c2.y));
56190
+ const maxX = Math.max(...cells.map((c2) => c2.x + c2.width));
56191
+ const maxY = Math.max(...cells.map((c2) => c2.y + c2.height));
56192
+ const minLY = Math.min(...cells.map((c2) => c2.layoutY));
56193
+ const maxLX = Math.max(...cells.map((c2) => c2.layoutX + c2.width));
56194
+ const maxLY = Math.max(...cells.map((c2) => c2.layoutY + c2.height));
56195
+ const backgroundRect = {
56196
+ x: minX + inset,
56197
+ y: minY + inset,
56198
+ width: maxX - minX - inset * 2,
56199
+ height: maxY - minY - inset * 2
56200
+ };
56201
+ const hLines = [
56202
+ { x1: minX + inset, x2: maxX - inset, y: minY + inset },
56203
+ // top
56204
+ { x1: minX + inset, x2: maxX - inset, y: maxY - inset }
56205
+ // bottom
56206
+ ];
56207
+ const vLines = [
56208
+ { x: minX + inset, y1: minY + inset, y2: maxY - inset },
56209
+ // left
56210
+ { x: maxX - inset, y1: minY + inset, y2: maxY - inset }
56211
+ // right
56212
+ ];
56213
+ const labelPos = { x: maxLX - inset, y1: minLY + inset, y2: maxLY - inset };
56214
+ return { backgroundRect, hLines, vLines, labelPos };
56215
+ }
56216
+ const accumulate = (list) => {
56217
+ const result = [0];
56218
+ let acc = 0;
56219
+ for (const n of list) {
56220
+ acc += n;
56221
+ result.push(acc);
56222
+ }
56223
+ return result;
56224
+ };
56225
+ const inRange = (n, min, max) => n > min && n < max;
56226
+ function mapCellsToOutlineCells(cells) {
56227
+ return cells.map((c2) => ({
56228
+ x: c2.x,
56229
+ y: c2.rowY,
56230
+ layoutX: c2.layoutX,
56231
+ layoutY: c2.layoutY,
56232
+ width: c2.width,
56233
+ height: c2.height
56234
+ }));
56235
+ }
56236
+ function groupBy(list, getKey) {
56237
+ return list.reduce((acc, item) => {
56238
+ const key = getKey(item);
56239
+ (acc[key] ||= []).push(item);
56240
+ return acc;
56241
+ }, {});
56242
+ }
56243
+ function buildPosMap(layers, getRect, toDom) {
56244
+ const res = {};
56245
+ for (const [id, layer] of Object.entries(layers)) {
56246
+ const rect = getRect(layer);
56247
+ if (!rect) continue;
56248
+ const pos = toDom(rect);
56249
+ if (pos) res[id] = pos;
56250
+ }
56251
+ return res;
56252
+ }
56253
+ function getDataIndexLayersMap({
56254
+ type: type4,
56255
+ cells,
56256
+ isDesign,
56257
+ convertExtraProps
56258
+ }) {
56259
+ const getDataIndex = (cell) => {
56260
+ return isLinkSubTableType(type4) && isDesign ? cell.subRenderer?.xDataIndex : cell.subRenderer?.yDataIndex;
56261
+ };
56262
+ const getAllDataIndex = (cell) => {
56263
+ const { dataIndex, xDataIndex, yDataIndex } = cell?.subRenderer || {};
56264
+ return dataIndex ?? xDataIndex ?? yDataIndex;
56265
+ };
56266
+ const _cells = cells.filter(
56267
+ (cell) => isNumber(getAllDataIndex(cell)) && cell?.subRenderer?.type === type4
56268
+ );
56269
+ if (!_cells.length) return {};
56270
+ const grouped = groupBy(
56271
+ _cells,
56272
+ (cell) => `${cell.subRenderer.id}_dataIndex${getDataIndex(cell)}`
56273
+ );
56274
+ const layersMapEntries = Object.entries(grouped).map(([id, __cells]) => {
56275
+ const firstCell = __cells[0];
56276
+ const isFirstGroup = getDataIndex(firstCell) === 0;
56277
+ const lastCell = __cells.filter((c2) => {
56278
+ if (isDesign) {
56279
+ return true;
56280
+ } else {
56281
+ const { type: type22, cellZone } = c2.subRenderer || {};
56282
+ return isLinkSubTableType(type22) ? isLinkSubTableSubScopeZone(cellZone) : true;
56283
+ }
56284
+ }).at(-1);
56285
+ const bgLayer = createTableOutlineLayer({
56286
+ cells: mapCellsToOutlineCells(__cells),
56287
+ inset: 4
56288
+ });
56289
+ const borderLayer = isFirstGroup ? createTableOutlineLayer({
56290
+ cells: mapCellsToOutlineCells(__cells),
56291
+ inset: OUTLINE_BORDER_INSET
56292
+ }) : { hLines: [], vLines: [], backgroundRect: null, labelPos: void 0 };
56293
+ return [
56294
+ id,
56295
+ {
56296
+ ...borderLayer,
56297
+ ...convertExtraProps(firstCell),
56298
+ showBorder: isFirstGroup,
56299
+ placeholderBjRect: bgLayer.backgroundRect,
56300
+ lastCell
56301
+ }
56302
+ ];
56303
+ });
56304
+ return Object.fromEntries(layersMapEntries);
56305
+ }
55833
56306
  const baseCanvasAttrs = {
55834
56307
  /** 不参与事件命中检测 */
55835
56308
  listening: false,
@@ -56154,7 +56627,7 @@ const _sfc_main$2D = /* @__PURE__ */ defineComponent({
56154
56627
  const filteredCells = subTableCells.value.filter(({ subRenderer }) => {
56155
56628
  if (subRenderer) {
56156
56629
  const { type: type4, cellZone } = subRenderer;
56157
- return getIsDataGroup2DTable(type4) ? getIs2DCellInSubTable(cellZone) : true;
56630
+ return isLinkSubTableType(type4) ? isLinkSubTableSubScopeZone(cellZone) : true;
56158
56631
  } else {
56159
56632
  return true;
56160
56633
  }
@@ -56197,7 +56670,7 @@ const _sfc_main$2D = /* @__PURE__ */ defineComponent({
56197
56670
  convertExtraProps: (cell) => ({
56198
56671
  type: "data-group-2d",
56199
56672
  valuePath: cell.subRenderer.valuePath,
56200
- placeholder: `${cell.subRenderer.dataIndex}`
56673
+ placeholder: `${cell.subRenderer.xDataIndex}`
56201
56674
  })
56202
56675
  })
56203
56676
  );
@@ -57038,18 +57511,24 @@ const _sfc_main$2y = /* @__PURE__ */ defineComponent({
57038
57511
  upRowNum: 1,
57039
57512
  downRowNum: 1
57040
57513
  });
57514
+ const resolveRowDataPath = (valuePath) => {
57515
+ const parsed = parseValuePath(valuePath);
57516
+ return {
57517
+ path: parsed.isLink ? parsed.parentFieldPath ?? "" : parsed.fieldPath,
57518
+ subFieldKey: parsed.isLink ? parsed.parentFieldKey ?? "" : parsed.fieldKey
57519
+ };
57520
+ };
57041
57521
  const getCtx = () => {
57042
57522
  const { valuePath, dataIndex, yDataIndex } = props.cell.subRenderer;
57043
57523
  return {
57044
- path: valuePath,
57045
- index: dataIndex ?? yDataIndex ?? 0
57524
+ ...resolveRowDataPath(valuePath),
57525
+ index: yDataIndex ?? dataIndex ?? 0
57046
57526
  };
57047
57527
  };
57048
57528
  const readonly2 = computed(() => {
57049
- const subFieldKey = getLastSegment(getCtx().path);
57050
57529
  const state = resolveWidgetState({
57051
57530
  doc: props.doc,
57052
- fieldLink: subFieldKey,
57531
+ fieldLink: getCtx().subFieldKey,
57053
57532
  modelLink: props.doc.mainModelKey
57054
57533
  });
57055
57534
  return state.displayStatus === "readonly-component" || state.displayStatus === "readonly-text";
@@ -57206,7 +57685,7 @@ const _sfc_main$2y = /* @__PURE__ */ defineComponent({
57206
57685
  };
57207
57686
  }
57208
57687
  });
57209
- const SubTableAction = /* @__PURE__ */ _export_sfc(_sfc_main$2y, [["__scopeId", "data-v-e2cc91ff"]]);
57688
+ const SubTableAction = /* @__PURE__ */ _export_sfc(_sfc_main$2y, [["__scopeId", "data-v-a58c6b2e"]]);
57210
57689
  const _sfc_main$2x = /* @__PURE__ */ defineComponent({
57211
57690
  __name: "index",
57212
57691
  props: {
@@ -57643,7 +58122,10 @@ function diffListField(fieldKey, beforeRows, afterRows, metaMap, output) {
57643
58122
  continue;
57644
58123
  }
57645
58124
  const valuePath = generateValuePath(rowFieldKey, fieldKey);
57646
- const runtimeValuePath = replacePathIndexPlaceholder(rowIndex, valuePath);
58125
+ const runtimeValuePath = replacePathIndexPlaceholders({
58126
+ n: rowIndex,
58127
+ templatePath: valuePath
58128
+ });
57647
58129
  const meta = getFieldMeta(metaMap, runtimeValuePath);
57648
58130
  pushChange(output, {
57649
58131
  beforeValue,
@@ -57669,7 +58151,7 @@ function diffMainField(fieldKey, beforeValue, afterValue, beforeData, afterData,
57669
58151
  });
57670
58152
  }
57671
58153
  function buildWidgetFieldMetaMap(instances) {
57672
- const map2 = /* @__PURE__ */ new Map();
58154
+ const map = /* @__PURE__ */ new Map();
57673
58155
  for (const instance2 of instances || []) {
57674
58156
  const widgetMeta = instance2?.widgetMeta;
57675
58157
  const fieldMeta = widgetMeta?.field;
@@ -57682,10 +58164,10 @@ function buildWidgetFieldMetaMap(instances) {
57682
58164
  modelId: instance2.modelRef.id,
57683
58165
  points: instance2?.widgetMeta?.extra?.biz?.[instance2.modelRef.id] || {}
57684
58166
  };
57685
- map2.set(runtimeValuePath, value);
58167
+ map.set(runtimeValuePath, value);
57686
58168
  }
57687
- console.log("map", map2);
57688
- return map2;
58169
+ console.log("map", map);
58170
+ return map;
57689
58171
  }
57690
58172
  function buildFieldChangeList(params) {
57691
58173
  const baseline = normalizeFormData(params.baselineData);
@@ -60233,7 +60715,7 @@ const _sfc_main$2i = /* @__PURE__ */ defineComponent({
60233
60715
  const createFieldToWidget = createDesignFieldToWidgetFactory(designCtx.getFieldManifest);
60234
60716
  const subFieldKey = computed(() => {
60235
60717
  if (!interCtx.panelData?.context?.subFieldKey) return "";
60236
- return getLastSegment(interCtx.panelData.context.subFieldKey);
60718
+ return parseValuePath(interCtx.panelData.context.subFieldKey).normalized;
60237
60719
  });
60238
60720
  const modelKey = computed(() => {
60239
60721
  if (!interCtx.panelData) return "";
@@ -60358,7 +60840,7 @@ const _sfc_main$2i = /* @__PURE__ */ defineComponent({
60358
60840
  };
60359
60841
  }
60360
60842
  });
60361
- const ToolkitContentFields = /* @__PURE__ */ _export_sfc(_sfc_main$2i, [["__scopeId", "data-v-2e5d2168"]]);
60843
+ const ToolkitContentFields = /* @__PURE__ */ _export_sfc(_sfc_main$2i, [["__scopeId", "data-v-9c5fa2ca"]]);
60362
60844
  const _hoisted_1$1C = { class: "toolkit-content-widgets" };
60363
60845
  const _hoisted_2$11 = { key: 0 };
60364
60846
  const _hoisted_3$M = ["data-type", "draggable", "onDragstart"];
@@ -60631,14 +61113,14 @@ const _sfc_main$2e = /* @__PURE__ */ defineComponent({
60631
61113
  bl: { x: x2 + padding.left, y: y2 + height - padding.bottom },
60632
61114
  br: { x: x2 + width - padding.right, y: y2 + height - padding.bottom }
60633
61115
  };
60634
- const map2 = {
61116
+ const map = {
60635
61117
  tl: [-1, -1],
60636
61118
  tr: [1, -1],
60637
61119
  bl: [-1, 1],
60638
61120
  br: [1, 1]
60639
61121
  };
60640
61122
  return Object.keys(corners).map((pos) => {
60641
- const [dx, dy] = map2[pos];
61123
+ const [dx, dy] = map[pos];
60642
61124
  const cx = halfPixel(corners[pos].x);
60643
61125
  const cy = halfPixel(corners[pos].y);
60644
61126
  return {
@@ -64150,16 +64632,16 @@ const __vite_glob_0_42 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.de
64150
64632
  }, Symbol.toStringTag, { value: "Module" }));
64151
64633
  function loadFieldManifestModules() {
64152
64634
  const manifestModules = /* @__PURE__ */ Object.assign({ "./basic/boolean-manifest.ts": __vite_glob_0_0$3, "./basic/date-manifest.ts": __vite_glob_0_1$3, "./basic/date-time-manifest.ts": __vite_glob_0_2$3, "./basic/decimal-manifest.ts": __vite_glob_0_3$3, "./basic/double-manifest.ts": __vite_glob_0_4$3, "./basic/integer-manifest.ts": __vite_glob_0_5$3, "./basic/long-manifest.ts": __vite_glob_0_6$3, "./basic/long-text-manifest.ts": __vite_glob_0_7$2, "./basic/text-manifest.ts": __vite_glob_0_8$2, "./basic/time-manifest.ts": __vite_glob_0_9$2, "./business/destructive-test-qty-manifest.ts": __vite_glob_0_10$2, "./business/good-qty-manifest.ts": __vite_glob_0_11$2, "./business/material-check-qty-manifest.ts": __vite_glob_0_12$2, "./business/not-good-group-manifest.ts": __vite_glob_0_13$2, "./business/not-good-qty-manifest.ts": __vite_glob_0_14$1, "./business/not-good-reason-manifest.ts": __vite_glob_0_15$1, "./business/product-check-qty-manifest.ts": __vite_glob_0_16, "./business/production-date-manifest.ts": __vite_glob_0_17, "./business/report-end-time-manifest.ts": __vite_glob_0_18, "./business/report-start-time-manifest.ts": __vite_glob_0_19, "./business/reporter-manifest.ts": __vite_glob_0_20, "./business/routing-operation-manifest.ts": __vite_glob_0_21, "./business/scrap-group-manifest.ts": __vite_glob_0_22, "./business/scrap-material-manifest.ts": __vite_glob_0_23, "./business/scrap-material-no-manifest.ts": __vite_glob_0_24, "./business/scrap-qty-manifest.ts": __vite_glob_0_25, "./business/scrap-reason-manifest.ts": __vite_glob_0_26, "./business/work-hours-manifest.ts": __vite_glob_0_27, "./logic/attachment-manifest.ts": __vite_glob_0_28, "./logic/image-manifest.ts": __vite_glob_0_29, "./logic/option-manifest.ts": __vite_glob_0_30, "./logic/option-multi-manifest.ts": __vite_glob_0_31, "./logic/org-manifest.ts": __vite_glob_0_32, "./logic/org-multi-manifest.ts": __vite_glob_0_33, "./logic/signature-manifest.ts": __vite_glob_0_34, "./logic/user-manifest.ts": __vite_glob_0_35, "./logic/user-multi-manifest.ts": __vite_glob_0_36, "./trace/device-manifest.ts": __vite_glob_0_37, "./trace/material-no-manifest.ts": __vite_glob_0_38, "./trace/mfg-order-manifest.ts": __vite_glob_0_39, "./trace/product-manifest.ts": __vite_glob_0_40, "./trace/record-no-manifest.ts": __vite_glob_0_41, "./trace/trace-date-manifest.ts": __vite_glob_0_42 });
64153
- const map2 = {};
64635
+ const map = {};
64154
64636
  Object.entries(manifestModules).forEach(([path2, exports$1]) => {
64155
64637
  const { manifest: manifest2 } = exports$1;
64156
64638
  if (!manifest2) {
64157
64639
  console.warn(`模块 ${path2} 缺少必要导出项`);
64158
64640
  return;
64159
64641
  }
64160
- map2[manifest2.type] = manifest2;
64642
+ map[manifest2.type] = manifest2;
64161
64643
  });
64162
- return map2;
64644
+ return map;
64163
64645
  }
64164
64646
  const fieldManifestMap = loadFieldManifestModules();
64165
64647
  const manifest$6 = {
@@ -64456,16 +64938,16 @@ const __vite_glob_0_6$2 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.d
64456
64938
  }, Symbol.toStringTag, { value: "Module" }));
64457
64939
  function loadPaperWidgetManifestModules() {
64458
64940
  const manifestModules = /* @__PURE__ */ Object.assign({ "./basic/barcode-manifest.ts": __vite_glob_0_0$2, "./basic/diagonal-manifest.ts": __vite_glob_0_1$2, "./basic/image-manifest.ts": __vite_glob_0_2$2, "./basic/line-manifest.ts": __vite_glob_0_3$2, "./basic/pagination-manifest.ts": __vite_glob_0_4$2, "./basic/qrcode-manifest.ts": __vite_glob_0_5$2, "./basic/serialnumber-manifest.ts": __vite_glob_0_6$2 });
64459
- const map2 = {};
64941
+ const map = {};
64460
64942
  Object.entries(manifestModules).forEach(([path2, exports$1]) => {
64461
64943
  const { manifest: manifest2 } = exports$1;
64462
64944
  if (!manifest2) {
64463
64945
  console.warn(`模块 ${path2} 缺少必要导出项`);
64464
64946
  return;
64465
64947
  }
64466
- map2[manifest2.type] = manifest2;
64948
+ map[manifest2.type] = manifest2;
64467
64949
  });
64468
- return map2;
64950
+ return map;
64469
64951
  }
64470
64952
  const paperWidgetManifestMap = loadPaperWidgetManifestModules();
64471
64953
  const UploadTypeConst = {
@@ -65491,9 +65973,14 @@ const _sfc_main$1P = /* @__PURE__ */ defineComponent({
65491
65973
  const modelValue = computed(() => {
65492
65974
  let text = pageWidgetProps.value.value;
65493
65975
  if (valueType.value === ValueTypeConst.Field) {
65494
- const path2 = text?.fieldData?.valuePath;
65976
+ const path2 = text?.exp?.fieldData?.valuePath;
65495
65977
  if (path2) {
65496
- const runtimePath = replacePathIndexPlaceholder(props.widget.dataIndex, path2);
65978
+ const runtimePath = replacePathIndexPlaceholders({
65979
+ y: props.widget.yDataIndex,
65980
+ x: props.widget.xDataIndex,
65981
+ n: props.widget.dataIndex,
65982
+ templatePath: path2
65983
+ });
65497
65984
  text = docInst.value?.dataManager?.get(runtimePath);
65498
65985
  }
65499
65986
  }
@@ -65784,7 +66271,12 @@ const _sfc_main$1O = /* @__PURE__ */ defineComponent({
65784
66271
  return fieldInfo?.name ? `\${${fieldInfo.name}}` : path2;
65785
66272
  }
65786
66273
  if (path2) {
65787
- const runtimePath = replacePathIndexPlaceholder(props.widget.dataIndex, path2);
66274
+ const runtimePath = replacePathIndexPlaceholders({
66275
+ y: props.widget.yDataIndex,
66276
+ x: props.widget.xDataIndex,
66277
+ n: props.widget.dataIndex,
66278
+ templatePath: path2
66279
+ });
65788
66280
  return docInst.value?.dataManager?.get(runtimePath);
65789
66281
  }
65790
66282
  }
@@ -66258,9 +66750,14 @@ const _sfc_main$1K = /* @__PURE__ */ defineComponent({
66258
66750
  const modelValue = computed(() => {
66259
66751
  let text = pageWidgetProps.value.value;
66260
66752
  if (valueType.value === ValueTypeConst.Field) {
66261
- const path2 = text?.fieldData?.valuePath;
66753
+ const path2 = text?.exp?.fieldData?.valuePath;
66262
66754
  if (path2) {
66263
- const runtimePath = replacePathIndexPlaceholder(props.widget.dataIndex, path2);
66755
+ const runtimePath = replacePathIndexPlaceholders({
66756
+ y: props.widget.yDataIndex,
66757
+ x: props.widget.xDataIndex,
66758
+ n: props.widget.dataIndex,
66759
+ templatePath: path2
66760
+ });
66264
66761
  text = docInst.value?.dataManager?.get(runtimePath);
66265
66762
  }
66266
66763
  }
@@ -67192,13 +67689,15 @@ const _sfc_main$1D = /* @__PURE__ */ defineComponent({
67192
67689
  const designCtx = useDesignSuiteContext();
67193
67690
  const { docInst } = useDocPubApiContext();
67194
67691
  const props = __props;
67195
- const regionRef = computed(() => props.widget.findRegionById(props.active.context.regionId));
67196
- const modelKey = computed(() => getLastSegment(props.active.context.mainModelKey));
67197
- const fieldKey = computed(() => getLastSegment(regionRef.value?.valuePath));
67692
+ const regionRef = computed(
67693
+ () => props.widget.findRegionById(props.active.context.regionId)
67694
+ );
67695
+ const modelKey = computed(() => props.active.context.mainModelKey);
67696
+ const subFieldKey = computed(() => regionRef.value?.subFieldKey);
67198
67697
  const fieldInfo = computed(() => {
67199
- if (!modelKey.value || !fieldKey.value) return null;
67698
+ if (!modelKey.value || !subFieldKey.value) return null;
67200
67699
  const list = designCtx.runtime.getFieldList(modelKey.value);
67201
- return list?.find((f) => f.key === fieldKey.value) ?? null;
67700
+ return list?.find((f) => f.key === subFieldKey.value) ?? null;
67202
67701
  });
67203
67702
  const regionProps = usePanelProps(regionRef, "widgetMeta.props");
67204
67703
  function onDeleteDynamicTable() {
@@ -67317,7 +67816,7 @@ const _sfc_main$1D = /* @__PURE__ */ defineComponent({
67317
67816
  };
67318
67817
  }
67319
67818
  });
67320
- const DynamicTablePanel = /* @__PURE__ */ _export_sfc(_sfc_main$1D, [["__scopeId", "data-v-ca7aec6b"]]);
67819
+ const DynamicTablePanel = /* @__PURE__ */ _export_sfc(_sfc_main$1D, [["__scopeId", "data-v-09705f9b"]]);
67321
67820
  const schema$b = {
67322
67821
  key: "dynamic-table.basic",
67323
67822
  title: [
@@ -67346,8 +67845,8 @@ const _sfc_main$1C = /* @__PURE__ */ defineComponent({
67346
67845
  return props.widget.findRegionById(id);
67347
67846
  });
67348
67847
  const isBindDataGroup = withLayoutComputed(() => !!regionRef.value?.itemRegion);
67349
- const modelKey = computed(() => getLastSegment(props.active.context.mainModelKey));
67350
- const fieldKey = computed(() => getLastSegment(regionRef.value?.subFieldKey));
67848
+ const modelKey = computed(() => props.active.context.mainModelKey);
67849
+ const fieldKey = computed(() => regionRef.value?.subFieldKey);
67351
67850
  const fieldInfo = computed(() => {
67352
67851
  if (!modelKey.value || !fieldKey.value) return null;
67353
67852
  const list = designCtx.runtime.getFieldList(modelKey.value);
@@ -67453,7 +67952,7 @@ const _sfc_main$1C = /* @__PURE__ */ defineComponent({
67453
67952
  };
67454
67953
  }
67455
67954
  });
67456
- const _2DTablePanel = /* @__PURE__ */ _export_sfc(_sfc_main$1C, [["__scopeId", "data-v-7d2be0ce"]]);
67955
+ const _2DTablePanel = /* @__PURE__ */ _export_sfc(_sfc_main$1C, [["__scopeId", "data-v-8cc7a416"]]);
67457
67956
  const schema$a = {
67458
67957
  key: "2d-table.basic",
67459
67958
  title: [
@@ -67482,8 +67981,8 @@ const _sfc_main$1B = /* @__PURE__ */ defineComponent({
67482
67981
  return props.widget.findRegionById(id);
67483
67982
  });
67484
67983
  const isBindDataGroup = withLayoutComputed(() => !!regionRef.value?.itemRegion);
67485
- const modelKey = computed(() => getLastSegment(props.active.context.mainModelKey));
67486
- const fieldKey = computed(() => getLastSegment(regionRef.value?.valuePath));
67984
+ const modelKey = computed(() => props.active.context.mainModelKey);
67985
+ const fieldKey = computed(() => regionRef.value?.subFieldKey);
67487
67986
  const fieldInfo = computed(() => {
67488
67987
  if (!modelKey.value || !fieldKey.value) return null;
67489
67988
  const list = designCtx.runtime.getFieldList(modelKey.value);
@@ -67589,7 +68088,7 @@ const _sfc_main$1B = /* @__PURE__ */ defineComponent({
67589
68088
  };
67590
68089
  }
67591
68090
  });
67592
- const FixedTablePanel = /* @__PURE__ */ _export_sfc(_sfc_main$1B, [["__scopeId", "data-v-b909e48b"]]);
68091
+ const FixedTablePanel = /* @__PURE__ */ _export_sfc(_sfc_main$1B, [["__scopeId", "data-v-646f62b8"]]);
67593
68092
  const schema$9 = {
67594
68093
  key: "fixed-table.basic",
67595
68094
  title: [
@@ -67618,8 +68117,8 @@ const _sfc_main$1A = /* @__PURE__ */ defineComponent({
67618
68117
  return props.widget.findRegionById(id);
67619
68118
  });
67620
68119
  const isBindDataGroup = withLayoutComputed(() => !!regionRef.value?.itemRegion);
67621
- const modelKey = computed(() => getLastSegment(props.active.context.mainModelKey));
67622
- const fieldKey = computed(() => getLastSegment(regionRef.value?.subFieldKey));
68120
+ const modelKey = computed(() => props.active.context.mainModelKey);
68121
+ const fieldKey = computed(() => regionRef.value?.subFieldKey);
67623
68122
  const fieldInfo = computed(() => {
67624
68123
  if (!modelKey.value || !fieldKey.value) return null;
67625
68124
  const list = designCtx.runtime.getFieldList(modelKey.value);
@@ -67725,7 +68224,7 @@ const _sfc_main$1A = /* @__PURE__ */ defineComponent({
67725
68224
  };
67726
68225
  }
67727
68226
  });
67728
- const CheckTablePanel = /* @__PURE__ */ _export_sfc(_sfc_main$1A, [["__scopeId", "data-v-5792e4ce"]]);
68227
+ const CheckTablePanel = /* @__PURE__ */ _export_sfc(_sfc_main$1A, [["__scopeId", "data-v-e4d1497a"]]);
67729
68228
  const schema$8 = {
67730
68229
  key: "check-table.basic",
67731
68230
  title: [
@@ -67862,13 +68361,18 @@ const _sfc_main$1y = /* @__PURE__ */ defineComponent({
67862
68361
  };
67863
68362
  const props = __props;
67864
68363
  const sheetReadonly = ref(false);
68364
+ const rId = computed(() => props.active.context.regionId?.split("_")[0] ?? "");
68365
+ const regionRef = computed(
68366
+ () => props.widget.findRegionById(rId.value)
68367
+ );
67865
68368
  const optionsMap = computed(() => {
67866
- const { mainModelKey, subFieldKey } = props.active.context;
67867
- if (!mainModelKey || !subFieldKey) {
68369
+ const mainModelKey = props.active.context.mainModelKey;
68370
+ const rowFieldKey = regionRef.value?.subFieldKey;
68371
+ const colFieldKey = regionRef.value?.linkFieldKey;
68372
+ if (!mainModelKey || !rowFieldKey || !colFieldKey) {
67868
68373
  return { row: [], col: [] };
67869
68374
  }
67870
68375
  const mainFields = designCtx.runtime.getFieldList(mainModelKey);
67871
- const [rowFieldKey, colFieldKey] = subFieldKey.replace("$.", "").split(":") ?? [];
67872
68376
  const rowModelKey = mainFields.find((f) => f.key === rowFieldKey)?.bindInfo;
67873
68377
  const colModelKey = mainFields.find((f) => f.key === colFieldKey)?.bindInfo;
67874
68378
  return {
@@ -67876,10 +68380,6 @@ const _sfc_main$1y = /* @__PURE__ */ defineComponent({
67876
68380
  col: getFieldOptions(colModelKey)
67877
68381
  };
67878
68382
  });
67879
- const rId = computed(() => props.active.context.regionId?.split("_")[0] ?? "");
67880
- const regionRef = computed(
67881
- () => props.widget.findRegionById(rId.value)
67882
- );
67883
68383
  const itemRegion = computed(() => regionRef.value?.itemRegion);
67884
68384
  const regionProps = usePanelProps(regionRef, "widgetMeta.props");
67885
68385
  function onDeleteDataGroup2D() {
@@ -67978,7 +68478,7 @@ const _sfc_main$1y = /* @__PURE__ */ defineComponent({
67978
68478
  };
67979
68479
  }
67980
68480
  });
67981
- const DataGroup2DPanel = /* @__PURE__ */ _export_sfc(_sfc_main$1y, [["__scopeId", "data-v-6a36dc19"]]);
68481
+ const DataGroup2DPanel = /* @__PURE__ */ _export_sfc(_sfc_main$1y, [["__scopeId", "data-v-9e4ec5d9"]]);
67982
68482
  const schema$6 = {
67983
68483
  key: "data-group-2d.basic",
67984
68484
  title: [
@@ -76017,7 +76517,7 @@ const __vite_glob_1_6 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.def
76017
76517
  const fieldModules = /* @__PURE__ */ Object.assign({ "./field/boolean/field-boolean-config.vue": __vite_glob_0_0, "./field/boolean/field-boolean-style.vue": __vite_glob_0_1, "./field/business/field-business-config.vue": __vite_glob_0_2, "./field/datetime/field-datetime-config.vue": __vite_glob_0_3, "./field/enum/field-enum-config.vue": __vite_glob_0_4, "./field/enum/field-enum-style.vue": __vite_glob_0_5, "./field/file/field-file-config.vue": __vite_glob_0_6, "./field/image/field-image-config.vue": __vite_glob_0_7, "./field/image/field-image-style.vue": __vite_glob_0_8, "./field/number/field-number-config.vue": __vite_glob_0_9, "./field/org/field-org-config.vue": __vite_glob_0_10, "./field/sign/field-sign-config.vue": __vite_glob_0_11, "./field/sign/field-sign-style.vue": __vite_glob_0_12, "./field/text/field-text-config.vue": __vite_glob_0_13, "./field/trace/field-trace-config.vue": __vite_glob_0_14, "./field/user/field-user-config.vue": __vite_glob_0_15 });
76018
76518
  const widgetModules = /* @__PURE__ */ Object.assign({ "./paper-widget/barcode/widget-barcode-config.vue": __vite_glob_1_0, "./paper-widget/diagonal/widget-diagonal-config.vue": __vite_glob_1_1, "./paper-widget/image/widget-image-config.vue": __vite_glob_1_2, "./paper-widget/line/widget-line-config.vue": __vite_glob_1_3, "./paper-widget/pagination/widget-pagination-config.vue": __vite_glob_1_4, "./paper-widget/qrcode/widget-qrcode-config.vue": __vite_glob_1_5, "./paper-widget/serialnumber/widget-serialnumber-config.vue": __vite_glob_1_6 });
76019
76519
  function buildMap(modules, reg) {
76020
- const map2 = {};
76520
+ const map = {};
76021
76521
  Object.entries(modules).forEach(([filePath, module2]) => {
76022
76522
  try {
76023
76523
  const match = filePath.match(reg);
@@ -76028,20 +76528,20 @@ function buildMap(modules, reg) {
76028
76528
  const [, coreId, typeStr] = match;
76029
76529
  const key = `schema:${coreId}`;
76030
76530
  const type4 = typeStr;
76031
- if (!map2[key]) {
76032
- map2[key] = {};
76531
+ if (!map[key]) {
76532
+ map[key] = {};
76033
76533
  }
76034
- map2[key][type4] = module2.default;
76534
+ map[key][type4] = module2.default;
76035
76535
  } catch (err) {
76036
76536
  console.error(`加载组件 ${filePath} 失败:`, err);
76037
76537
  }
76038
76538
  });
76039
- return map2;
76539
+ return map;
76040
76540
  }
76041
76541
  function mergeMaps(...maps) {
76042
76542
  const result = {};
76043
- maps.forEach((map2) => {
76044
- Object.entries(map2).forEach(([key, value]) => {
76543
+ maps.forEach((map) => {
76544
+ Object.entries(map).forEach(([key, value]) => {
76045
76545
  const _key = key;
76046
76546
  if (!result[_key]) {
76047
76547
  result[_key] = {};
@@ -77396,7 +77896,10 @@ function useTableDropdown(props) {
77396
77896
  strategy.value.linkFieldId,
77397
77897
  fieldMeta.value?.subFieldKey
77398
77898
  );
77399
- const realLinkValuePath = replacePathIndexPlaceholder(runtimeValuePath.value, linkValuePath);
77899
+ const realLinkValuePath = replacePathIndexPlaceholders({
77900
+ refPath: runtimeValuePath.value,
77901
+ templatePath: linkValuePath
77902
+ });
77400
77903
  return getValue$1(docInst.value.dataManager.get(realLinkValuePath), false);
77401
77904
  }
77402
77905
  });
@@ -77406,7 +77909,10 @@ function useTableDropdown(props) {
77406
77909
  strategy.value.clearFieldId,
77407
77910
  fieldMeta.value?.subFieldKey
77408
77911
  );
77409
- const realValuePath = replacePathIndexPlaceholder(runtimeValuePath.value, valuePath);
77912
+ const realValuePath = replacePathIndexPlaceholders({
77913
+ refPath: runtimeValuePath.value,
77914
+ templatePath: valuePath
77915
+ });
77410
77916
  return realValuePath;
77411
77917
  }
77412
77918
  });