@gct-paas/word 0.2.43 → 0.2.44

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
@@ -1,4 +1,4 @@
1
- /*! @gct-paas/word v0.2.43 */
1
+ /*! @gct-paas/word v0.2.44 */
2
2
  import { Fragment, Suspense, Teleport, Transition, TransitionGroup, cloneVNode, computed, createApp, createBlock, createCommentVNode, createElementBlock, createElementVNode, createSlots, createStaticVNode, createTextVNode, createVNode, defineAsyncComponent, defineComponent, getCurrentInstance, getCurrentScope, guardReactiveProps, h, inject, isRef, isVNode, markRaw, mergeModels, mergeProps, nextTick, normalizeClass, normalizeProps, normalizeStyle, onBeforeMount, onBeforeUnmount, onMounted, onScopeDispose, onUnmounted, openBlock, provide, reactive, readonly, ref, render, renderList, renderSlot, resolveComponent, resolveDynamicComponent, shallowRef, toDisplayString, toHandlers, toRaw, toRef, toValue, unref, useAttrs, useCssVars, useModel, useSlots, vModelRadio, vModelText, vShow, watch, watchEffect, withCtx, withDirectives, withKeys, withModifiers } from "vue";
3
3
  import da, { PopperWrapper } from "floating-vue";
4
4
  import VueKonva from "vue-konva";
@@ -98541,7 +98541,7 @@ var init_fetchers = __esmMin((() => {
98541
98541
  };
98542
98542
  return {
98543
98543
  options: this.toOptions(result.data, params.optionMapping),
98544
- totalPage: result.totalPage,
98544
+ totalPage: result.totalPage ?? 0,
98545
98545
  totalCount: result.totalCount
98546
98546
  };
98547
98547
  }
@@ -98560,9 +98560,10 @@ var init_fetchers = __esmMin((() => {
98560
98560
  /** 多条转 Options */
98561
98561
  toOptions(items, optionMapping) {
98562
98562
  var _this$config$transfor2;
98563
- if ((optionMapping === null || optionMapping === void 0 ? void 0 : optionMapping.value) || (optionMapping === null || optionMapping === void 0 ? void 0 : optionMapping.label)) return createTransformer(optionMapping.label ?? LABEL_FIELDS.default, optionMapping.value ?? VALUE_FIELDS.default).toOptions(items);
98564
- if ((_this$config$transfor2 = this.config.transformers) === null || _this$config$transfor2 === void 0 ? void 0 : _this$config$transfor2.toOptions) return this.config.transformers.toOptions(items);
98565
- return (items === null || items === void 0 ? void 0 : items.map((i) => this.toOption(i))) ?? [];
98563
+ const data = items ?? [];
98564
+ if ((optionMapping === null || optionMapping === void 0 ? void 0 : optionMapping.value) || (optionMapping === null || optionMapping === void 0 ? void 0 : optionMapping.label)) return createTransformer(optionMapping.label ?? LABEL_FIELDS.default, optionMapping.value ?? VALUE_FIELDS.default).toOptions(data);
98565
+ if ((_this$config$transfor2 = this.config.transformers) === null || _this$config$transfor2 === void 0 ? void 0 : _this$config$transfor2.toOptions) return this.config.transformers.toOptions(data);
98566
+ return data.map((i) => this.toOption(i));
98566
98567
  }
98567
98568
  };
98568
98569
  apiFetchers = {
@@ -127407,6 +127408,135 @@ function compare(a, b) {
127407
127408
  }
127408
127409
  var init_number_util = __esmMin((() => {}));
127409
127410
  //#endregion
127411
+ //#region src/runtime/canvas/table/render/material-consume/uom-convert-runtime.ts
127412
+ /** 历史表单允许数字字符串,空值和无效计算结果视为未转换。 */
127413
+ function parseConvertedQty(value) {
127414
+ if (typeof value === "string" && value.trim()) value = Number(value);
127415
+ return typeof value === "number" && Number.isFinite(value) ? value : void 0;
127416
+ }
127417
+ function isParamMap(map) {
127418
+ return /^formulaRuleParam\d+$/.test(map.key) && !!map.formField;
127419
+ }
127420
+ function getConfiguredParamMaps(fieldMaps = []) {
127421
+ return fieldMaps.filter(isParamMap);
127422
+ }
127423
+ function sameId(a, b) {
127424
+ if (a == null || b == null || a === "" || b === "") return false;
127425
+ return String(a) === String(b);
127426
+ }
127427
+ /** 物料匹配:支持父版本规则命中任意子版本(parent 或 parent:child) */
127428
+ function matchProductId(rowProductId, ruleProductId) {
127429
+ if (!ruleProductId) return true;
127430
+ if (rowProductId == null || rowProductId === "") return false;
127431
+ const rowId = String(rowProductId);
127432
+ const ruleId = String(ruleProductId);
127433
+ if (rowId === ruleId) return true;
127434
+ if (!ruleId.includes(":") && rowId.startsWith(`${ruleId}:`)) return true;
127435
+ return false;
127436
+ }
127437
+ /** 源单位匹配数量单位,目标单位匹配需求数量单位,兼容旧配置保存的固定字段映射。 */
127438
+ function matchBaseUom(row, fieldMaps = []) {
127439
+ const source = fieldMaps.find((m) => m.key === SOURCE_UNIT_KEY$1);
127440
+ const target = fieldMaps.find((m) => m.key === TARGET_UNIT_KEY$1);
127441
+ if (!(source === null || source === void 0 ? void 0 : source.value) || !(target === null || target === void 0 ? void 0 : target.value)) return false;
127442
+ return sameId(row.qty_uom_id_, source.value) && sameId(row.qty_required_uom_id_, target.value);
127443
+ }
127444
+ /**
127445
+ * 规则是否适用于当前行。
127446
+ * 基础单位条件通过后,再按物料 / 参数配置判断。
127447
+ */
127448
+ function matchRule(rule, row, subFieldKey) {
127449
+ const fieldMaps = rule.fieldMaps ?? [];
127450
+ if (!matchBaseUom(row, fieldMaps)) return false;
127451
+ if (!matchProductId(row.product_id_, rule.productId)) return false;
127452
+ const subParam = getConfiguredParamMaps(fieldMaps).find((m) => m.formSubModel === 1);
127453
+ if ((subParam === null || subParam === void 0 ? void 0 : subParam.formSubFieldKey) && subParam.formSubFieldKey !== subFieldKey) return false;
127454
+ return true;
127455
+ }
127456
+ function buildFormulaValues(rule, row, mainData) {
127457
+ const values = {};
127458
+ const fieldMaps = rule.fieldMaps ?? [];
127459
+ for (const map of fieldMaps) {
127460
+ if (map.key === "formulaRuleInput") {
127461
+ const fieldKey = map.formField || DEFAULT_INPUT_FIELD;
127462
+ values[FORMULA_RULE_INPUT_KEY] = Number(row[fieldKey]);
127463
+ continue;
127464
+ }
127465
+ if (!isParamMap(map) || !map.formField) continue;
127466
+ if (map.formSubModel === 1) values[map.key] = Number(row[map.formField]);
127467
+ else values[map.key] = Number(mainData[map.formField]);
127468
+ }
127469
+ return values;
127470
+ }
127471
+ /**
127472
+ * 按配置顺序命中第一条单位转换规则,写回转换结果字段。
127473
+ * @returns 是否命中并写回,包括清理无效计算结果
127474
+ */
127475
+ async function applyUnitConversionRules(options) {
127476
+ const { rules, row, mainData, subFieldKey } = options;
127477
+ if (!(rules === null || rules === void 0 ? void 0 : rules.length)) return false;
127478
+ for (const rule of rules) {
127479
+ if (!rule.expressionStr || !matchRule(rule, row, subFieldKey)) continue;
127480
+ const values = buildFormulaValues(rule, row, mainData);
127481
+ let convertedQty;
127482
+ try {
127483
+ convertedQty = parseConvertedQty(await serviceUtil.formulaCalculate(rule.expressionStr, values));
127484
+ } catch (error) {
127485
+ console.error("[applyUnitConversionRules] calculate failed", error);
127486
+ }
127487
+ Object.assign(row, {
127488
+ qty_transfer_: convertedQty,
127489
+ qty_transfer_uom_id_: convertedQty === void 0 ? void 0 : row.qty_required_uom_id_,
127490
+ transfer_formula_: convertedQty === void 0 ? void 0 : rule.expressionStr
127491
+ });
127492
+ return true;
127493
+ }
127494
+ return false;
127495
+ }
127496
+ /** 从文档 config 读取单位转换规则列表 */
127497
+ function getUnitConversionRulesFromDoc(doc) {
127498
+ var _doc$model;
127499
+ const rules = (_doc$model = doc.model) === null || _doc$model === void 0 || (_doc$model = _doc$model.document) === null || _doc$model === void 0 || (_doc$model = _doc$model.config) === null || _doc$model === void 0 || (_doc$model = _doc$model.rules) === null || _doc$model === void 0 ? void 0 : _doc$model.unitConversionRules;
127500
+ return Array.isArray(rules) ? rules : [];
127501
+ }
127502
+ /**
127503
+ * 从规则列表中收集所有行级输入字段 key(用于快照去重)。
127504
+ * 不包含 formulaRuleParam* 主表字段(formSubModel != 1)。
127505
+ */
127506
+ function getUomRowInputFieldKeys(rules) {
127507
+ const keys = /* @__PURE__ */ new Set([
127508
+ DEFAULT_SOURCE_UOM_FIELD,
127509
+ DEFAULT_TARGET_UOM_FIELD,
127510
+ DEFAULT_INPUT_FIELD,
127511
+ "product_id_",
127512
+ "deleted_"
127513
+ ]);
127514
+ for (const rule of rules) for (const map of rule.fieldMaps ?? []) {
127515
+ if ((map.key === "sourceUnit" || map.key === "targetUnit" || map.key === "formulaRuleInput") && map.formField) keys.add(map.formField);
127516
+ if (/^formulaRuleParam\d+$/.test(map.key) && map.formSubModel === 1 && map.formField) keys.add(map.formField);
127517
+ }
127518
+ return Array.from(keys);
127519
+ }
127520
+ /**
127521
+ * 从规则列表中收集主表参数字段 key(formSubModel !== 1 的 formulaRuleParam*)。
127522
+ * 这些字段变化时也需要重新触发单位转换计算。
127523
+ */
127524
+ function getUomMainInputFieldKeys(rules) {
127525
+ const keys = /* @__PURE__ */ new Set();
127526
+ for (const rule of rules) for (const map of rule.fieldMaps ?? []) if (/^formulaRuleParam\d+$/.test(map.key) && map.formSubModel !== 1 && map.formField) keys.add(map.formField);
127527
+ return Array.from(keys);
127528
+ }
127529
+ var SOURCE_UNIT_KEY$1, TARGET_UNIT_KEY$1, FORMULA_RULE_INPUT_KEY, DEFAULT_SOURCE_UOM_FIELD, DEFAULT_TARGET_UOM_FIELD, DEFAULT_INPUT_FIELD;
127530
+ var init_uom_convert_runtime = __esmMin((() => {
127531
+ init_ServiceUtil();
127532
+ SOURCE_UNIT_KEY$1 = "sourceUnit";
127533
+ TARGET_UNIT_KEY$1 = "targetUnit";
127534
+ FORMULA_RULE_INPUT_KEY = "formulaRuleInput";
127535
+ DEFAULT_SOURCE_UOM_FIELD = "qty_uom_id_";
127536
+ DEFAULT_TARGET_UOM_FIELD = "qty_required_uom_id_";
127537
+ DEFAULT_INPUT_FIELD = "qty_";
127538
+ }));
127539
+ //#endregion
127410
127540
  //#region src/runtime/canvas/table/render/material-consume/bom-validator.ts
127411
127541
  function findLastIndex(array, predicate) {
127412
127542
  if (!Array.isArray(array)) throw new TypeError("Expected an array");
@@ -127428,6 +127558,7 @@ var McRowValidateError, BomEntryValidator, BomEntriesValidator;
127428
127558
  var init_bom_validator$1 = __esmMin((() => {
127429
127559
  init_service$5();
127430
127560
  init_number_util();
127561
+ init_uom_convert_runtime();
127431
127562
  init_defineProperty();
127432
127563
  McRowValidateError = class extends Error {
127433
127564
  constructor(message, targetFieldId, row) {
@@ -127443,7 +127574,7 @@ var init_bom_validator$1 = __esmMin((() => {
127443
127574
  return this.historyQty.toNumber();
127444
127575
  }
127445
127576
  get remainingQty() {
127446
- return minus(this.totalQty, this.historyQty);
127577
+ return minus(this.totalQty, this.calcQtyForBounds(this.historyData, "history"));
127447
127578
  }
127448
127579
  /** 剩于可消耗数量 */
127449
127580
  get remainingNum() {
@@ -127613,7 +127744,7 @@ var init_bom_validator$1 = __esmMin((() => {
127613
127744
  async validateNum(arr) {
127614
127745
  if (!this.bomEntry.qty_validation_enabled_) return;
127615
127746
  if (this.bomEntry.type_ === "view") return;
127616
- const consumeNum = this.calcQtyConsumed(arr);
127747
+ const consumeNum = this.calcQtyForBounds(arr);
127617
127748
  if (compare(consumeNum, 0) === 0) return;
127618
127749
  if (["eq", "lte"].includes(this.bomEntry.qty_validation_rule_) && compare(consumeNum, this.remainingQty) === 1) throw new Error("当前物料上料总消耗不能大于需求数量");
127619
127750
  if (this.bomEntry.qty_validation_rule_ === "bounds") {
@@ -127642,9 +127773,9 @@ var init_bom_validator$1 = __esmMin((() => {
127642
127773
  calcQtyConsumed(arr, source = "current") {
127643
127774
  return sum(this.filterGroupData(arr, source).map((row) => Number(row.qty_ ?? 0)));
127644
127775
  }
127645
- /** 上下限校验优先使用单位转换后的数量,历史数据未转换时兼容原数量。 */
127776
+ /** 按需求单位校验时优先使用有效的转换数量,历史数据未转换时兼容原数量。 */
127646
127777
  calcQtyForBounds(arr, source = "current") {
127647
- return sum(this.filterGroupData(arr, source).map((row) => Number(row.qty_transfer_ ?? row.qty_ ?? 0)));
127778
+ return sum(this.filterGroupData(arr, source).map((row) => parseConvertedQty(row.qty_transfer_) ?? Number(row.qty_ ?? 0)));
127648
127779
  }
127649
127780
  calcTotalForBounds(arr) {
127650
127781
  return plus(this.calcQtyForBounds(arr), this.calcQtyForBounds(this.historyData, "history"));
@@ -127683,13 +127814,13 @@ var init_bom_validator$1 = __esmMin((() => {
127683
127814
  const entry = this.bomEntry;
127684
127815
  if (!entry.qty_validation_enabled_ || entry.type_ === "view") return;
127685
127816
  const groupData = this.filterGroupData(arr);
127686
- const loaded = this.calcQtyConsumed(arr);
127817
+ const loaded = this.calcQtyForBounds(arr);
127687
127818
  let required = this.remainingQty;
127688
127819
  if (this.isCustomRequiredQty) {
127689
127820
  var _groupData$;
127690
127821
  const currentQty = (_groupData$ = groupData[0]) === null || _groupData$ === void 0 ? void 0 : _groupData$.qty_required_;
127691
127822
  if (typeof currentQty !== "number" || !Number.isFinite(currentQty) || currentQty <= 0) throw new Error(groupNo != null && groupNo > 0 ? `序号${groupNo},需求数量必须大于 0` : "需求数量必须大于 0");
127692
- required = minus(currentQty, this.historyQty);
127823
+ required = minus(currentQty, this.calcQtyForBounds(this.historyData, "history"));
127693
127824
  }
127694
127825
  const diff = compare(minus(loaded, required), 0);
127695
127826
  const rule = entry.qty_validation_rule_;
@@ -127732,7 +127863,7 @@ var init_bom_validator$1 = __esmMin((() => {
127732
127863
  throw new Error(message);
127733
127864
  }
127734
127865
  if (this.bomEntry.type_ === "view") return;
127735
- const consumeNum = this.calcQtyConsumed(groupData);
127866
+ const consumeNum = this.calcQtyForBounds(groupData);
127736
127867
  const zeroComparison = compare(consumeNum, 0);
127737
127868
  if (!this.bomEntry.qty_validation_enabled_ && zeroComparison !== null && zeroComparison !== 0) return;
127738
127869
  switch (this.bomEntry.qty_validation_rule_) {
@@ -127746,7 +127877,7 @@ var init_bom_validator$1 = __esmMin((() => {
127746
127877
  if (zeroComparison === -1 || zeroComparison === 0) throw new Error(message);
127747
127878
  break;
127748
127879
  case "bounds":
127749
- const consumeSum = plus(consumeNum, this.historyQty);
127880
+ const consumeSum = this.calcTotalForBounds(arr);
127750
127881
  const { min } = await this.calcCustomNumberLimit(groupData[0]);
127751
127882
  if (min !== void 0 && compare(consumeSum, min) === -1) throw new Error(message);
127752
127883
  }
@@ -128268,129 +128399,6 @@ var init_label_parse_rule = __esmMin((() => {
128268
128399
  init_useLabelParsingRules();
128269
128400
  }));
128270
128401
  //#endregion
128271
- //#region src/runtime/canvas/table/render/material-consume/uom-convert-runtime.ts
128272
- function isParamMap(map) {
128273
- return /^formulaRuleParam\d+$/.test(map.key) && !!map.formField;
128274
- }
128275
- function getConfiguredParamMaps(fieldMaps = []) {
128276
- return fieldMaps.filter(isParamMap);
128277
- }
128278
- function sameId(a, b) {
128279
- if (a == null || b == null || a === "" || b === "") return false;
128280
- return String(a) === String(b);
128281
- }
128282
- /** 物料匹配:支持父版本规则命中任意子版本(parent 或 parent:child) */
128283
- function matchProductId(rowProductId, ruleProductId) {
128284
- if (!ruleProductId) return true;
128285
- if (rowProductId == null || rowProductId === "") return false;
128286
- const rowId = String(rowProductId);
128287
- const ruleId = String(ruleProductId);
128288
- if (rowId === ruleId) return true;
128289
- if (!ruleId.includes(":") && rowId.startsWith(`${ruleId}:`)) return true;
128290
- return false;
128291
- }
128292
- /** 基础条件:需求数量单位=源单位,数量单位=目标单位 */
128293
- function matchBaseUom(row, fieldMaps = []) {
128294
- const source = fieldMaps.find((m) => m.key === SOURCE_UNIT_KEY$1);
128295
- const target = fieldMaps.find((m) => m.key === TARGET_UNIT_KEY$1);
128296
- if (!(source === null || source === void 0 ? void 0 : source.value) || !(target === null || target === void 0 ? void 0 : target.value)) return false;
128297
- const sourceField = source.formField || DEFAULT_SOURCE_UOM_FIELD;
128298
- const targetField = target.formField || DEFAULT_TARGET_UOM_FIELD;
128299
- return sameId(row[sourceField], source.value) && sameId(row[targetField], target.value);
128300
- }
128301
- /**
128302
- * 规则是否适用于当前行。
128303
- * 基础单位条件通过后,再按物料 / 参数配置判断。
128304
- */
128305
- function matchRule(rule, row, subFieldKey) {
128306
- const fieldMaps = rule.fieldMaps ?? [];
128307
- if (!matchBaseUom(row, fieldMaps)) return false;
128308
- if (!matchProductId(row.product_id_, rule.productId)) return false;
128309
- const subParam = getConfiguredParamMaps(fieldMaps).find((m) => m.formSubModel === 1);
128310
- if ((subParam === null || subParam === void 0 ? void 0 : subParam.formSubFieldKey) && subParam.formSubFieldKey !== subFieldKey) return false;
128311
- return true;
128312
- }
128313
- function buildFormulaValues(rule, row, mainData) {
128314
- const values = {};
128315
- const fieldMaps = rule.fieldMaps ?? [];
128316
- for (const map of fieldMaps) {
128317
- if (map.key === "formulaRuleInput") {
128318
- const fieldKey = map.formField || DEFAULT_INPUT_FIELD;
128319
- values[FORMULA_RULE_INPUT_KEY] = Number(row[fieldKey]);
128320
- continue;
128321
- }
128322
- if (!isParamMap(map) || !map.formField) continue;
128323
- if (map.formSubModel === 1) values[map.key] = Number(row[map.formField]);
128324
- else values[map.key] = Number(mainData[map.formField]);
128325
- }
128326
- return values;
128327
- }
128328
- function getTargetUomId(fieldMaps = []) {
128329
- var _fieldMaps$find;
128330
- return (_fieldMaps$find = fieldMaps.find((m) => m.key === "targetUnit")) === null || _fieldMaps$find === void 0 ? void 0 : _fieldMaps$find.value;
128331
- }
128332
- /**
128333
- * 按配置顺序命中第一条单位转换规则,写回转换结果字段。
128334
- * @returns 是否命中并成功写入
128335
- */
128336
- async function applyUnitConversionRules(options) {
128337
- const { rules, row, mainData, subFieldKey } = options;
128338
- if (!(rules === null || rules === void 0 ? void 0 : rules.length)) return false;
128339
- for (const rule of rules) {
128340
- if (!rule.expressionStr || !matchRule(rule, row, subFieldKey)) continue;
128341
- const values = buildFormulaValues(rule, row, mainData);
128342
- const result = await serviceUtil.formulaCalculate(rule.expressionStr, values);
128343
- row.qty_transfer_ = Number(result);
128344
- row.qty_transfer_uom_id_ = getTargetUomId(rule.fieldMaps);
128345
- row.transfer_formula_ = rule.expressionStr;
128346
- return true;
128347
- }
128348
- return false;
128349
- }
128350
- /** 从文档 config 读取单位转换规则列表 */
128351
- function getUnitConversionRulesFromDoc(doc) {
128352
- var _doc$model;
128353
- const rules = (_doc$model = doc.model) === null || _doc$model === void 0 || (_doc$model = _doc$model.document) === null || _doc$model === void 0 || (_doc$model = _doc$model.config) === null || _doc$model === void 0 || (_doc$model = _doc$model.rules) === null || _doc$model === void 0 ? void 0 : _doc$model.unitConversionRules;
128354
- return Array.isArray(rules) ? rules : [];
128355
- }
128356
- /**
128357
- * 从规则列表中收集所有行级输入字段 key(用于快照去重)。
128358
- * 不包含 formulaRuleParam* 主表字段(formSubModel != 1)。
128359
- */
128360
- function getUomRowInputFieldKeys(rules) {
128361
- const keys = /* @__PURE__ */ new Set([
128362
- DEFAULT_SOURCE_UOM_FIELD,
128363
- DEFAULT_TARGET_UOM_FIELD,
128364
- DEFAULT_INPUT_FIELD,
128365
- "product_id_",
128366
- "deleted_"
128367
- ]);
128368
- for (const rule of rules) for (const map of rule.fieldMaps ?? []) {
128369
- if ((map.key === "sourceUnit" || map.key === "targetUnit" || map.key === "formulaRuleInput") && map.formField) keys.add(map.formField);
128370
- if (/^formulaRuleParam\d+$/.test(map.key) && map.formSubModel === 1 && map.formField) keys.add(map.formField);
128371
- }
128372
- return Array.from(keys);
128373
- }
128374
- /**
128375
- * 从规则列表中收集主表参数字段 key(formSubModel !== 1 的 formulaRuleParam*)。
128376
- * 这些字段变化时也需要重新触发单位转换计算。
128377
- */
128378
- function getUomMainInputFieldKeys(rules) {
128379
- const keys = /* @__PURE__ */ new Set();
128380
- for (const rule of rules) for (const map of rule.fieldMaps ?? []) if (/^formulaRuleParam\d+$/.test(map.key) && map.formSubModel !== 1 && map.formField) keys.add(map.formField);
128381
- return Array.from(keys);
128382
- }
128383
- var SOURCE_UNIT_KEY$1, TARGET_UNIT_KEY$1, FORMULA_RULE_INPUT_KEY, DEFAULT_SOURCE_UOM_FIELD, DEFAULT_TARGET_UOM_FIELD, DEFAULT_INPUT_FIELD;
128384
- var init_uom_convert_runtime = __esmMin((() => {
128385
- init_ServiceUtil();
128386
- SOURCE_UNIT_KEY$1 = "sourceUnit";
128387
- TARGET_UNIT_KEY$1 = "targetUnit";
128388
- FORMULA_RULE_INPUT_KEY = "formulaRuleInput";
128389
- DEFAULT_SOURCE_UOM_FIELD = "qty_required_uom_id_";
128390
- DEFAULT_TARGET_UOM_FIELD = "qty_uom_id_";
128391
- DEFAULT_INPUT_FIELD = "qty_";
128392
- }));
128393
- //#endregion
128394
128402
  //#region src/runtime/canvas/table/render/material-consume/scan-fill.ts
128395
128403
  /**
128396
128404
  * 按 ScanFillPlan 切组 / 建组 / 填充,返回新表及本次写入行的身份(不改入参 arr)。
@@ -171045,8 +171053,8 @@ var GROUP_SUB_PREFIX = "group:sub:";
171045
171053
  /** 输入值 / 源单位 / 目标单位写死的表单字段 key */
171046
171054
  var FIXED_FORM_FIELD_KEYS = {
171047
171055
  formulaRuleInput: "qty_",
171048
- [SOURCE_UNIT_KEY]: "qty_required_uom_id_",
171049
- [TARGET_UNIT_KEY]: "qty_uom_id_"
171056
+ [SOURCE_UNIT_KEY]: "qty_uom_id_",
171057
+ [TARGET_UNIT_KEY]: "qty_required_uom_id_"
171050
171058
  };
171051
171059
  /** 写死字段右侧展示名 */
171052
171060
  var FIXED_FORM_FIELD_LABELS = {
@@ -171169,6 +171177,16 @@ function applyFixedFormField(row, fieldKey) {
171169
171177
  row.formFieldLabel = FIXED_FORM_FIELD_LABELS[fieldKey] ?? fieldKey;
171170
171178
  row.fixed = true;
171171
171179
  }
171180
+ /** 编辑旧规则时恢复固定字段的对应关系,保留参数字段和单位值。 */
171181
+ function normalizeFixedFieldMaps(fieldMaps) {
171182
+ return fieldMaps.map((item) => {
171183
+ const fieldKey = FIXED_FORM_FIELD_KEYS[item.key];
171184
+ if (!fieldKey) return item;
171185
+ const row = { ...item };
171186
+ applyFixedFormField(row, fieldKey);
171187
+ return row;
171188
+ });
171189
+ }
171172
171190
  /** 按选中规则重建固定映射行 */
171173
171191
  function buildFixedFieldMaps(options) {
171174
171192
  const { expr, sourceUomId, targetUomId, sourceUomLabel, targetUomLabel } = options;
@@ -171350,7 +171368,7 @@ var unit_field_map_modal_vue_vue_type_script_setup_true_name_unit_field_map_moda
171350
171368
  expressionStr: props.item.expressionStr,
171351
171369
  productId: props.item.productId,
171352
171370
  productName: props.item.productName,
171353
- fieldMaps: cloneDeep(props.item.fieldMaps ?? [])
171371
+ fieldMaps: normalizeFixedFieldMaps(cloneDeep(props.item.fieldMaps ?? []))
171354
171372
  });
171355
171373
  const errors = reactive({
171356
171374
  ruleId: "",
@@ -171522,7 +171540,7 @@ var unit_field_map_modal_vue_vue_type_script_setup_true_name_unit_field_map_moda
171522
171540
  //#endregion
171523
171541
  //#region src/suites/edhr/panel-schema/rule/modals/unit-field-map-modal.vue
171524
171542
  init__plugin_vue_export_helper();
171525
- var unit_field_map_modal_default = /*#__PURE__*/ _plugin_vue_export_helper_default(unit_field_map_modal_vue_vue_type_script_setup_true_name_unit_field_map_modal_lang_default, [["__scopeId", "data-v-8c1e7e39"]]);
171543
+ var unit_field_map_modal_default = /*#__PURE__*/ _plugin_vue_export_helper_default(unit_field_map_modal_vue_vue_type_script_setup_true_name_unit_field_map_modal_lang_default, [["__scopeId", "data-v-373bcf09"]]);
171526
171544
  //#endregion
171527
171545
  //#region src/suites/edhr/panel-schema/rule/modals/open-rule-modal.ts
171528
171546
  init_base$2();
@@ -114,7 +114,7 @@ export declare class BomEntryValidator {
114
114
  * @return {*}
115
115
  */
116
116
  calcQtyConsumed(arr: IMaterialConsumeData[], source?: ConsumeDataSource): BigNumber;
117
- /** 上下限校验优先使用单位转换后的数量,历史数据未转换时兼容原数量。 */
117
+ /** 按需求单位校验时优先使用有效的转换数量,历史数据未转换时兼容原数量。 */
118
118
  calcQtyForBounds(arr: IMaterialConsumeData[], source?: ConsumeDataSource): BigNumber;
119
119
  private calcTotalForBounds;
120
120
  calcRunningQtyConsumed(arr: IMaterialConsumeData[]): number;
@@ -2,6 +2,8 @@ import { IMaterialConsumeData } from '../../../../../domain/table/business/mater
2
2
  export declare const SOURCE_UNIT_KEY = "sourceUnit";
3
3
  export declare const TARGET_UNIT_KEY = "targetUnit";
4
4
  export declare const FORMULA_RULE_INPUT_KEY = "formulaRuleInput";
5
+ /** 历史表单允许数字字符串,空值和无效计算结果视为未转换。 */
6
+ export declare function parseConvertedQty(value: unknown): number | undefined;
5
7
  interface UomConvertFieldMap {
6
8
  key: string;
7
9
  value?: string;
@@ -25,7 +27,7 @@ interface ApplyUnitConversionOptions {
25
27
  }
26
28
  /**
27
29
  * 按配置顺序命中第一条单位转换规则,写回转换结果字段。
28
- * @returns 是否命中并成功写入
30
+ * @returns 是否命中并写回,包括清理无效计算结果
29
31
  */
30
32
  export declare function applyUnitConversionRules(options: ApplyUnitConversionOptions): Promise<boolean>;
31
33
  /** 从文档 config 读取单位转换规则列表 */
@@ -88,7 +88,7 @@ declare class APIFetcher {
88
88
  label?: string;
89
89
  }): Option;
90
90
  /** 多条转 Options */
91
- protected toOptions(items: any[], optionMapping?: {
91
+ protected toOptions(items: any[] | null | undefined, optionMapping?: {
92
92
  value?: string;
93
93
  label?: string;
94
94
  }): Option[];
@@ -19,6 +19,8 @@ export declare function resolveLockedSubFieldKey(fieldMaps: RuleFieldMap[]): str
19
19
  export declare function clearIncompatibleParamFormFields(fieldMaps: RuleFieldMap[], lockedSubFieldKey?: string): void;
20
20
  export declare function clearFormFieldSelection(item: RuleFieldMap): void;
21
21
  export declare function applyFormFieldSelection(item: RuleFieldMap, meta?: FieldTreeTargetMeta): void;
22
+ /** 编辑旧规则时恢复固定字段的对应关系,保留参数字段和单位值。 */
23
+ export declare function normalizeFixedFieldMaps(fieldMaps: RuleFieldMap[]): RuleFieldMap[];
22
24
  /** 按选中规则重建固定映射行 */
23
25
  export declare function buildFixedFieldMaps(options: {
24
26
  expr?: string;
package/dist/word.css CHANGED
@@ -13111,18 +13111,18 @@ svg.portrait-icon[data-v-8bdb451e] {
13111
13111
  font-size: 12px;
13112
13112
  line-height: 18px;
13113
13113
  }
13114
- .unit-field-map-modal__filters[data-v-8c1e7e39] {
13114
+ .unit-field-map-modal__filters[data-v-373bcf09] {
13115
13115
  display: grid;
13116
13116
  grid-template-columns: 1fr 1fr;
13117
13117
  gap: 12px;
13118
13118
  }
13119
- .error-text[data-v-8c1e7e39] {
13119
+ .error-text[data-v-373bcf09] {
13120
13120
  margin-top: 4px;
13121
13121
  color: #ff4d4f;
13122
13122
  font-size: 12px;
13123
13123
  line-height: 18px;
13124
13124
  }
13125
- .expression-show[data-v-8c1e7e39] {
13125
+ .expression-show[data-v-373bcf09] {
13126
13126
  margin-top: 12px;
13127
13127
  position: relative;
13128
13128
  padding: 12px;
@@ -13130,13 +13130,13 @@ svg.portrait-icon[data-v-8bdb451e] {
13130
13130
  border-radius: 4px;
13131
13131
  background: #f9fafb;
13132
13132
  }
13133
- .expression-show__title[data-v-8c1e7e39] {
13133
+ .expression-show__title[data-v-373bcf09] {
13134
13134
  color: #1a1d23;
13135
13135
  font-size: 12px;
13136
13136
  font-weight: 400;
13137
13137
  line-height: 18px;
13138
13138
  }
13139
- .expression-show__value[data-v-8c1e7e39] {
13139
+ .expression-show__value[data-v-373bcf09] {
13140
13140
  border: 1px solid #e8ebf0;
13141
13141
  border-radius: 4px;
13142
13142
  text-align: center;
@@ -13148,10 +13148,10 @@ svg.portrait-icon[data-v-8bdb451e] {
13148
13148
  line-height: 18px;
13149
13149
  margin-top: 6px;
13150
13150
  }
13151
- .expression-show__value.placeholder[data-v-8c1e7e39] {
13151
+ .expression-show__value.placeholder[data-v-373bcf09] {
13152
13152
  color: rgba(0, 0, 0, 0.25);
13153
13153
  }
13154
- .field-map-panel[data-v-8c1e7e39] {
13154
+ .field-map-panel[data-v-373bcf09] {
13155
13155
  margin-top: 12px;
13156
13156
  padding: 12px;
13157
13157
  border: 1px dashed #e0e3eb;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gct-paas/word",
3
- "version": "0.2.43",
3
+ "version": "0.2.44",
4
4
  "description": "GCT 在线 word",
5
5
  "keywords": [
6
6
  "vue",