@gct-paas/word 0.2.43-patch.1 → 0.2.43-patch.2
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 +158 -140
- package/dist/runtime/canvas/table/render/material-consume/bom-validator.d.ts +1 -1
- package/dist/runtime/canvas/table/render/material-consume/uom-convert-runtime.d.ts +3 -1
- package/dist/runtime/interface/fetchers.d.ts +1 -1
- package/dist/suites/edhr/panel-schema/rule/utils/rule-field-map.d.ts +2 -0
- package/dist/word.css +7 -7
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @gct-paas/word v0.2.43-patch.
|
|
1
|
+
/*! @gct-paas/word v0.2.43-patch.2 */
|
|
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
|
-
|
|
98564
|
-
if ((
|
|
98565
|
-
|
|
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 = {
|
|
@@ -127406,6 +127407,135 @@ function compare(a, b) {
|
|
|
127406
127407
|
}
|
|
127407
127408
|
var init_number_util = __esmMin((() => {}));
|
|
127408
127409
|
//#endregion
|
|
127410
|
+
//#region src/runtime/canvas/table/render/material-consume/uom-convert-runtime.ts
|
|
127411
|
+
/** 历史表单允许数字字符串,空值和无效计算结果视为未转换。 */
|
|
127412
|
+
function parseConvertedQty(value) {
|
|
127413
|
+
if (typeof value === "string" && value.trim()) value = Number(value);
|
|
127414
|
+
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
127415
|
+
}
|
|
127416
|
+
function isParamMap(map) {
|
|
127417
|
+
return /^formulaRuleParam\d+$/.test(map.key) && !!map.formField;
|
|
127418
|
+
}
|
|
127419
|
+
function getConfiguredParamMaps(fieldMaps = []) {
|
|
127420
|
+
return fieldMaps.filter(isParamMap);
|
|
127421
|
+
}
|
|
127422
|
+
function sameId(a, b) {
|
|
127423
|
+
if (a == null || b == null || a === "" || b === "") return false;
|
|
127424
|
+
return String(a) === String(b);
|
|
127425
|
+
}
|
|
127426
|
+
/** 物料匹配:支持父版本规则命中任意子版本(parent 或 parent:child) */
|
|
127427
|
+
function matchProductId(rowProductId, ruleProductId) {
|
|
127428
|
+
if (!ruleProductId) return true;
|
|
127429
|
+
if (rowProductId == null || rowProductId === "") return false;
|
|
127430
|
+
const rowId = String(rowProductId);
|
|
127431
|
+
const ruleId = String(ruleProductId);
|
|
127432
|
+
if (rowId === ruleId) return true;
|
|
127433
|
+
if (!ruleId.includes(":") && rowId.startsWith(`${ruleId}:`)) return true;
|
|
127434
|
+
return false;
|
|
127435
|
+
}
|
|
127436
|
+
/** 源单位匹配数量单位,目标单位匹配需求数量单位,兼容旧配置保存的固定字段映射。 */
|
|
127437
|
+
function matchBaseUom(row, fieldMaps = []) {
|
|
127438
|
+
const source = fieldMaps.find((m) => m.key === SOURCE_UNIT_KEY$1);
|
|
127439
|
+
const target = fieldMaps.find((m) => m.key === TARGET_UNIT_KEY$1);
|
|
127440
|
+
if (!(source === null || source === void 0 ? void 0 : source.value) || !(target === null || target === void 0 ? void 0 : target.value)) return false;
|
|
127441
|
+
return sameId(row.qty_uom_id_, source.value) && sameId(row.qty_required_uom_id_, target.value);
|
|
127442
|
+
}
|
|
127443
|
+
/**
|
|
127444
|
+
* 规则是否适用于当前行。
|
|
127445
|
+
* 基础单位条件通过后,再按物料 / 参数配置判断。
|
|
127446
|
+
*/
|
|
127447
|
+
function matchRule(rule, row, subFieldKey) {
|
|
127448
|
+
const fieldMaps = rule.fieldMaps ?? [];
|
|
127449
|
+
if (!matchBaseUom(row, fieldMaps)) return false;
|
|
127450
|
+
if (!matchProductId(row.product_id_, rule.productId)) return false;
|
|
127451
|
+
const subParam = getConfiguredParamMaps(fieldMaps).find((m) => m.formSubModel === 1);
|
|
127452
|
+
if ((subParam === null || subParam === void 0 ? void 0 : subParam.formSubFieldKey) && subParam.formSubFieldKey !== subFieldKey) return false;
|
|
127453
|
+
return true;
|
|
127454
|
+
}
|
|
127455
|
+
function buildFormulaValues(rule, row, mainData) {
|
|
127456
|
+
const values = {};
|
|
127457
|
+
const fieldMaps = rule.fieldMaps ?? [];
|
|
127458
|
+
for (const map of fieldMaps) {
|
|
127459
|
+
if (map.key === "formulaRuleInput") {
|
|
127460
|
+
const fieldKey = map.formField || DEFAULT_INPUT_FIELD;
|
|
127461
|
+
values[FORMULA_RULE_INPUT_KEY] = Number(row[fieldKey]);
|
|
127462
|
+
continue;
|
|
127463
|
+
}
|
|
127464
|
+
if (!isParamMap(map) || !map.formField) continue;
|
|
127465
|
+
if (map.formSubModel === 1) values[map.key] = Number(row[map.formField]);
|
|
127466
|
+
else values[map.key] = Number(mainData[map.formField]);
|
|
127467
|
+
}
|
|
127468
|
+
return values;
|
|
127469
|
+
}
|
|
127470
|
+
/**
|
|
127471
|
+
* 按配置顺序命中第一条单位转换规则,写回转换结果字段。
|
|
127472
|
+
* @returns 是否命中并写回,包括清理无效计算结果
|
|
127473
|
+
*/
|
|
127474
|
+
async function applyUnitConversionRules(options) {
|
|
127475
|
+
const { rules, row, mainData, subFieldKey } = options;
|
|
127476
|
+
if (!(rules === null || rules === void 0 ? void 0 : rules.length)) return false;
|
|
127477
|
+
for (const rule of rules) {
|
|
127478
|
+
if (!rule.expressionStr || !matchRule(rule, row, subFieldKey)) continue;
|
|
127479
|
+
const values = buildFormulaValues(rule, row, mainData);
|
|
127480
|
+
let convertedQty;
|
|
127481
|
+
try {
|
|
127482
|
+
convertedQty = parseConvertedQty(await serviceUtil.formulaCalculate(rule.expressionStr, values));
|
|
127483
|
+
} catch (error) {
|
|
127484
|
+
console.error("[applyUnitConversionRules] calculate failed", error);
|
|
127485
|
+
}
|
|
127486
|
+
Object.assign(row, {
|
|
127487
|
+
qty_transfer_: convertedQty,
|
|
127488
|
+
qty_transfer_uom_id_: convertedQty === void 0 ? void 0 : row.qty_required_uom_id_,
|
|
127489
|
+
transfer_formula_: convertedQty === void 0 ? void 0 : rule.expressionStr
|
|
127490
|
+
});
|
|
127491
|
+
return true;
|
|
127492
|
+
}
|
|
127493
|
+
return false;
|
|
127494
|
+
}
|
|
127495
|
+
/** 从文档 config 读取单位转换规则列表 */
|
|
127496
|
+
function getUnitConversionRulesFromDoc(doc) {
|
|
127497
|
+
var _doc$model;
|
|
127498
|
+
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;
|
|
127499
|
+
return Array.isArray(rules) ? rules : [];
|
|
127500
|
+
}
|
|
127501
|
+
/**
|
|
127502
|
+
* 从规则列表中收集所有行级输入字段 key(用于快照去重)。
|
|
127503
|
+
* 不包含 formulaRuleParam* 主表字段(formSubModel != 1)。
|
|
127504
|
+
*/
|
|
127505
|
+
function getUomRowInputFieldKeys(rules) {
|
|
127506
|
+
const keys = /* @__PURE__ */ new Set([
|
|
127507
|
+
DEFAULT_SOURCE_UOM_FIELD,
|
|
127508
|
+
DEFAULT_TARGET_UOM_FIELD,
|
|
127509
|
+
DEFAULT_INPUT_FIELD,
|
|
127510
|
+
"product_id_",
|
|
127511
|
+
"deleted_"
|
|
127512
|
+
]);
|
|
127513
|
+
for (const rule of rules) for (const map of rule.fieldMaps ?? []) {
|
|
127514
|
+
if ((map.key === "sourceUnit" || map.key === "targetUnit" || map.key === "formulaRuleInput") && map.formField) keys.add(map.formField);
|
|
127515
|
+
if (/^formulaRuleParam\d+$/.test(map.key) && map.formSubModel === 1 && map.formField) keys.add(map.formField);
|
|
127516
|
+
}
|
|
127517
|
+
return Array.from(keys);
|
|
127518
|
+
}
|
|
127519
|
+
/**
|
|
127520
|
+
* 从规则列表中收集主表参数字段 key(formSubModel !== 1 的 formulaRuleParam*)。
|
|
127521
|
+
* 这些字段变化时也需要重新触发单位转换计算。
|
|
127522
|
+
*/
|
|
127523
|
+
function getUomMainInputFieldKeys(rules) {
|
|
127524
|
+
const keys = /* @__PURE__ */ new Set();
|
|
127525
|
+
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);
|
|
127526
|
+
return Array.from(keys);
|
|
127527
|
+
}
|
|
127528
|
+
var SOURCE_UNIT_KEY$1, TARGET_UNIT_KEY$1, FORMULA_RULE_INPUT_KEY, DEFAULT_SOURCE_UOM_FIELD, DEFAULT_TARGET_UOM_FIELD, DEFAULT_INPUT_FIELD;
|
|
127529
|
+
var init_uom_convert_runtime = __esmMin((() => {
|
|
127530
|
+
init_ServiceUtil();
|
|
127531
|
+
SOURCE_UNIT_KEY$1 = "sourceUnit";
|
|
127532
|
+
TARGET_UNIT_KEY$1 = "targetUnit";
|
|
127533
|
+
FORMULA_RULE_INPUT_KEY = "formulaRuleInput";
|
|
127534
|
+
DEFAULT_SOURCE_UOM_FIELD = "qty_uom_id_";
|
|
127535
|
+
DEFAULT_TARGET_UOM_FIELD = "qty_required_uom_id_";
|
|
127536
|
+
DEFAULT_INPUT_FIELD = "qty_";
|
|
127537
|
+
}));
|
|
127538
|
+
//#endregion
|
|
127409
127539
|
//#region src/runtime/canvas/table/render/material-consume/bom-validator.ts
|
|
127410
127540
|
function findLastIndex(array, predicate) {
|
|
127411
127541
|
if (!Array.isArray(array)) throw new TypeError("Expected an array");
|
|
@@ -127427,6 +127557,7 @@ var McRowValidateError, BomEntryValidator, BomEntriesValidator;
|
|
|
127427
127557
|
var init_bom_validator$1 = __esmMin((() => {
|
|
127428
127558
|
init_service$5();
|
|
127429
127559
|
init_number_util();
|
|
127560
|
+
init_uom_convert_runtime();
|
|
127430
127561
|
init_defineProperty();
|
|
127431
127562
|
McRowValidateError = class extends Error {
|
|
127432
127563
|
constructor(message, targetFieldId, row) {
|
|
@@ -127442,7 +127573,7 @@ var init_bom_validator$1 = __esmMin((() => {
|
|
|
127442
127573
|
return this.historyQty.toNumber();
|
|
127443
127574
|
}
|
|
127444
127575
|
get remainingQty() {
|
|
127445
|
-
return minus(this.totalQty, this.
|
|
127576
|
+
return minus(this.totalQty, this.calcQtyForBounds(this.historyData, "history"));
|
|
127446
127577
|
}
|
|
127447
127578
|
/** 剩于可消耗数量 */
|
|
127448
127579
|
get remainingNum() {
|
|
@@ -127612,7 +127743,7 @@ var init_bom_validator$1 = __esmMin((() => {
|
|
|
127612
127743
|
async validateNum(arr) {
|
|
127613
127744
|
if (!this.bomEntry.qty_validation_enabled_) return;
|
|
127614
127745
|
if (this.bomEntry.type_ === "view") return;
|
|
127615
|
-
const consumeNum = this.
|
|
127746
|
+
const consumeNum = this.calcQtyForBounds(arr);
|
|
127616
127747
|
if (compare(consumeNum, 0) === 0) return;
|
|
127617
127748
|
if (["eq", "lte"].includes(this.bomEntry.qty_validation_rule_) && compare(consumeNum, this.remainingQty) === 1) throw new Error("当前物料上料总消耗不能大于需求数量");
|
|
127618
127749
|
if (this.bomEntry.qty_validation_rule_ === "bounds") {
|
|
@@ -127641,9 +127772,9 @@ var init_bom_validator$1 = __esmMin((() => {
|
|
|
127641
127772
|
calcQtyConsumed(arr, source = "current") {
|
|
127642
127773
|
return sum(this.filterGroupData(arr, source).map((row) => Number(row.qty_ ?? 0)));
|
|
127643
127774
|
}
|
|
127644
|
-
/**
|
|
127775
|
+
/** 按需求单位校验时优先使用有效的转换数量,历史数据未转换时兼容原数量。 */
|
|
127645
127776
|
calcQtyForBounds(arr, source = "current") {
|
|
127646
|
-
return sum(this.filterGroupData(arr, source).map((row) =>
|
|
127777
|
+
return sum(this.filterGroupData(arr, source).map((row) => parseConvertedQty(row.qty_transfer_) ?? Number(row.qty_ ?? 0)));
|
|
127647
127778
|
}
|
|
127648
127779
|
calcTotalForBounds(arr) {
|
|
127649
127780
|
return plus(this.calcQtyForBounds(arr), this.calcQtyForBounds(this.historyData, "history"));
|
|
@@ -127682,13 +127813,13 @@ var init_bom_validator$1 = __esmMin((() => {
|
|
|
127682
127813
|
const entry = this.bomEntry;
|
|
127683
127814
|
if (!entry.qty_validation_enabled_ || entry.type_ === "view") return;
|
|
127684
127815
|
const groupData = this.filterGroupData(arr);
|
|
127685
|
-
const loaded = this.
|
|
127816
|
+
const loaded = this.calcQtyForBounds(arr);
|
|
127686
127817
|
let required = this.remainingQty;
|
|
127687
127818
|
if (this.isCustomRequiredQty) {
|
|
127688
127819
|
var _groupData$;
|
|
127689
127820
|
const currentQty = (_groupData$ = groupData[0]) === null || _groupData$ === void 0 ? void 0 : _groupData$.qty_required_;
|
|
127690
127821
|
if (typeof currentQty !== "number" || !Number.isFinite(currentQty) || currentQty <= 0) throw new Error(groupNo != null && groupNo > 0 ? `序号${groupNo},需求数量必须大于 0` : "需求数量必须大于 0");
|
|
127691
|
-
required = minus(currentQty, this.
|
|
127822
|
+
required = minus(currentQty, this.calcQtyForBounds(this.historyData, "history"));
|
|
127692
127823
|
}
|
|
127693
127824
|
const diff = compare(minus(loaded, required), 0);
|
|
127694
127825
|
const rule = entry.qty_validation_rule_;
|
|
@@ -127731,7 +127862,7 @@ var init_bom_validator$1 = __esmMin((() => {
|
|
|
127731
127862
|
throw new Error(message);
|
|
127732
127863
|
}
|
|
127733
127864
|
if (this.bomEntry.type_ === "view") return;
|
|
127734
|
-
const consumeNum = this.
|
|
127865
|
+
const consumeNum = this.calcQtyForBounds(groupData);
|
|
127735
127866
|
const zeroComparison = compare(consumeNum, 0);
|
|
127736
127867
|
if (!this.bomEntry.qty_validation_enabled_ && zeroComparison !== null && zeroComparison !== 0) return;
|
|
127737
127868
|
switch (this.bomEntry.qty_validation_rule_) {
|
|
@@ -127745,7 +127876,7 @@ var init_bom_validator$1 = __esmMin((() => {
|
|
|
127745
127876
|
if (zeroComparison === -1 || zeroComparison === 0) throw new Error(message);
|
|
127746
127877
|
break;
|
|
127747
127878
|
case "bounds":
|
|
127748
|
-
const consumeSum =
|
|
127879
|
+
const consumeSum = this.calcTotalForBounds(arr);
|
|
127749
127880
|
const { min } = await this.calcCustomNumberLimit(groupData[0]);
|
|
127750
127881
|
if (min !== void 0 && compare(consumeSum, min) === -1) throw new Error(message);
|
|
127751
127882
|
}
|
|
@@ -128267,129 +128398,6 @@ var init_label_parse_rule = __esmMin((() => {
|
|
|
128267
128398
|
init_useLabelParsingRules();
|
|
128268
128399
|
}));
|
|
128269
128400
|
//#endregion
|
|
128270
|
-
//#region src/runtime/canvas/table/render/material-consume/uom-convert-runtime.ts
|
|
128271
|
-
function isParamMap(map) {
|
|
128272
|
-
return /^formulaRuleParam\d+$/.test(map.key) && !!map.formField;
|
|
128273
|
-
}
|
|
128274
|
-
function getConfiguredParamMaps(fieldMaps = []) {
|
|
128275
|
-
return fieldMaps.filter(isParamMap);
|
|
128276
|
-
}
|
|
128277
|
-
function sameId(a, b) {
|
|
128278
|
-
if (a == null || b == null || a === "" || b === "") return false;
|
|
128279
|
-
return String(a) === String(b);
|
|
128280
|
-
}
|
|
128281
|
-
/** 物料匹配:支持父版本规则命中任意子版本(parent 或 parent:child) */
|
|
128282
|
-
function matchProductId(rowProductId, ruleProductId) {
|
|
128283
|
-
if (!ruleProductId) return true;
|
|
128284
|
-
if (rowProductId == null || rowProductId === "") return false;
|
|
128285
|
-
const rowId = String(rowProductId);
|
|
128286
|
-
const ruleId = String(ruleProductId);
|
|
128287
|
-
if (rowId === ruleId) return true;
|
|
128288
|
-
if (!ruleId.includes(":") && rowId.startsWith(`${ruleId}:`)) return true;
|
|
128289
|
-
return false;
|
|
128290
|
-
}
|
|
128291
|
-
/** 基础条件:需求数量单位=源单位,数量单位=目标单位 */
|
|
128292
|
-
function matchBaseUom(row, fieldMaps = []) {
|
|
128293
|
-
const source = fieldMaps.find((m) => m.key === SOURCE_UNIT_KEY$1);
|
|
128294
|
-
const target = fieldMaps.find((m) => m.key === TARGET_UNIT_KEY$1);
|
|
128295
|
-
if (!(source === null || source === void 0 ? void 0 : source.value) || !(target === null || target === void 0 ? void 0 : target.value)) return false;
|
|
128296
|
-
const sourceField = source.formField || DEFAULT_SOURCE_UOM_FIELD;
|
|
128297
|
-
const targetField = target.formField || DEFAULT_TARGET_UOM_FIELD;
|
|
128298
|
-
return sameId(row[sourceField], source.value) && sameId(row[targetField], target.value);
|
|
128299
|
-
}
|
|
128300
|
-
/**
|
|
128301
|
-
* 规则是否适用于当前行。
|
|
128302
|
-
* 基础单位条件通过后,再按物料 / 参数配置判断。
|
|
128303
|
-
*/
|
|
128304
|
-
function matchRule(rule, row, subFieldKey) {
|
|
128305
|
-
const fieldMaps = rule.fieldMaps ?? [];
|
|
128306
|
-
if (!matchBaseUom(row, fieldMaps)) return false;
|
|
128307
|
-
if (!matchProductId(row.product_id_, rule.productId)) return false;
|
|
128308
|
-
const subParam = getConfiguredParamMaps(fieldMaps).find((m) => m.formSubModel === 1);
|
|
128309
|
-
if ((subParam === null || subParam === void 0 ? void 0 : subParam.formSubFieldKey) && subParam.formSubFieldKey !== subFieldKey) return false;
|
|
128310
|
-
return true;
|
|
128311
|
-
}
|
|
128312
|
-
function buildFormulaValues(rule, row, mainData) {
|
|
128313
|
-
const values = {};
|
|
128314
|
-
const fieldMaps = rule.fieldMaps ?? [];
|
|
128315
|
-
for (const map of fieldMaps) {
|
|
128316
|
-
if (map.key === "formulaRuleInput") {
|
|
128317
|
-
const fieldKey = map.formField || DEFAULT_INPUT_FIELD;
|
|
128318
|
-
values[FORMULA_RULE_INPUT_KEY] = Number(row[fieldKey]);
|
|
128319
|
-
continue;
|
|
128320
|
-
}
|
|
128321
|
-
if (!isParamMap(map) || !map.formField) continue;
|
|
128322
|
-
if (map.formSubModel === 1) values[map.key] = Number(row[map.formField]);
|
|
128323
|
-
else values[map.key] = Number(mainData[map.formField]);
|
|
128324
|
-
}
|
|
128325
|
-
return values;
|
|
128326
|
-
}
|
|
128327
|
-
function getTargetUomId(fieldMaps = []) {
|
|
128328
|
-
var _fieldMaps$find;
|
|
128329
|
-
return (_fieldMaps$find = fieldMaps.find((m) => m.key === "targetUnit")) === null || _fieldMaps$find === void 0 ? void 0 : _fieldMaps$find.value;
|
|
128330
|
-
}
|
|
128331
|
-
/**
|
|
128332
|
-
* 按配置顺序命中第一条单位转换规则,写回转换结果字段。
|
|
128333
|
-
* @returns 是否命中并成功写入
|
|
128334
|
-
*/
|
|
128335
|
-
async function applyUnitConversionRules(options) {
|
|
128336
|
-
const { rules, row, mainData, subFieldKey } = options;
|
|
128337
|
-
if (!(rules === null || rules === void 0 ? void 0 : rules.length)) return false;
|
|
128338
|
-
for (const rule of rules) {
|
|
128339
|
-
if (!rule.expressionStr || !matchRule(rule, row, subFieldKey)) continue;
|
|
128340
|
-
const values = buildFormulaValues(rule, row, mainData);
|
|
128341
|
-
const result = await serviceUtil.formulaCalculate(rule.expressionStr, values);
|
|
128342
|
-
row.qty_transfer_ = Number(result);
|
|
128343
|
-
row.qty_transfer_uom_id_ = getTargetUomId(rule.fieldMaps);
|
|
128344
|
-
row.transfer_formula_ = rule.expressionStr;
|
|
128345
|
-
return true;
|
|
128346
|
-
}
|
|
128347
|
-
return false;
|
|
128348
|
-
}
|
|
128349
|
-
/** 从文档 config 读取单位转换规则列表 */
|
|
128350
|
-
function getUnitConversionRulesFromDoc(doc) {
|
|
128351
|
-
var _doc$model;
|
|
128352
|
-
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;
|
|
128353
|
-
return Array.isArray(rules) ? rules : [];
|
|
128354
|
-
}
|
|
128355
|
-
/**
|
|
128356
|
-
* 从规则列表中收集所有行级输入字段 key(用于快照去重)。
|
|
128357
|
-
* 不包含 formulaRuleParam* 主表字段(formSubModel != 1)。
|
|
128358
|
-
*/
|
|
128359
|
-
function getUomRowInputFieldKeys(rules) {
|
|
128360
|
-
const keys = /* @__PURE__ */ new Set([
|
|
128361
|
-
DEFAULT_SOURCE_UOM_FIELD,
|
|
128362
|
-
DEFAULT_TARGET_UOM_FIELD,
|
|
128363
|
-
DEFAULT_INPUT_FIELD,
|
|
128364
|
-
"product_id_",
|
|
128365
|
-
"deleted_"
|
|
128366
|
-
]);
|
|
128367
|
-
for (const rule of rules) for (const map of rule.fieldMaps ?? []) {
|
|
128368
|
-
if ((map.key === "sourceUnit" || map.key === "targetUnit" || map.key === "formulaRuleInput") && map.formField) keys.add(map.formField);
|
|
128369
|
-
if (/^formulaRuleParam\d+$/.test(map.key) && map.formSubModel === 1 && map.formField) keys.add(map.formField);
|
|
128370
|
-
}
|
|
128371
|
-
return Array.from(keys);
|
|
128372
|
-
}
|
|
128373
|
-
/**
|
|
128374
|
-
* 从规则列表中收集主表参数字段 key(formSubModel !== 1 的 formulaRuleParam*)。
|
|
128375
|
-
* 这些字段变化时也需要重新触发单位转换计算。
|
|
128376
|
-
*/
|
|
128377
|
-
function getUomMainInputFieldKeys(rules) {
|
|
128378
|
-
const keys = /* @__PURE__ */ new Set();
|
|
128379
|
-
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);
|
|
128380
|
-
return Array.from(keys);
|
|
128381
|
-
}
|
|
128382
|
-
var SOURCE_UNIT_KEY$1, TARGET_UNIT_KEY$1, FORMULA_RULE_INPUT_KEY, DEFAULT_SOURCE_UOM_FIELD, DEFAULT_TARGET_UOM_FIELD, DEFAULT_INPUT_FIELD;
|
|
128383
|
-
var init_uom_convert_runtime = __esmMin((() => {
|
|
128384
|
-
init_ServiceUtil();
|
|
128385
|
-
SOURCE_UNIT_KEY$1 = "sourceUnit";
|
|
128386
|
-
TARGET_UNIT_KEY$1 = "targetUnit";
|
|
128387
|
-
FORMULA_RULE_INPUT_KEY = "formulaRuleInput";
|
|
128388
|
-
DEFAULT_SOURCE_UOM_FIELD = "qty_required_uom_id_";
|
|
128389
|
-
DEFAULT_TARGET_UOM_FIELD = "qty_uom_id_";
|
|
128390
|
-
DEFAULT_INPUT_FIELD = "qty_";
|
|
128391
|
-
}));
|
|
128392
|
-
//#endregion
|
|
128393
128401
|
//#region src/runtime/canvas/table/render/material-consume/scan-fill.ts
|
|
128394
128402
|
/**
|
|
128395
128403
|
* 按 ScanFillPlan 切组 / 建组 / 填充,返回新表及本次写入行的身份(不改入参 arr)。
|
|
@@ -171044,8 +171052,8 @@ var GROUP_SUB_PREFIX = "group:sub:";
|
|
|
171044
171052
|
/** 输入值 / 源单位 / 目标单位写死的表单字段 key */
|
|
171045
171053
|
var FIXED_FORM_FIELD_KEYS = {
|
|
171046
171054
|
formulaRuleInput: "qty_",
|
|
171047
|
-
[SOURCE_UNIT_KEY]: "
|
|
171048
|
-
[TARGET_UNIT_KEY]: "
|
|
171055
|
+
[SOURCE_UNIT_KEY]: "qty_uom_id_",
|
|
171056
|
+
[TARGET_UNIT_KEY]: "qty_required_uom_id_"
|
|
171049
171057
|
};
|
|
171050
171058
|
/** 写死字段右侧展示名 */
|
|
171051
171059
|
var FIXED_FORM_FIELD_LABELS = {
|
|
@@ -171168,6 +171176,16 @@ function applyFixedFormField(row, fieldKey) {
|
|
|
171168
171176
|
row.formFieldLabel = FIXED_FORM_FIELD_LABELS[fieldKey] ?? fieldKey;
|
|
171169
171177
|
row.fixed = true;
|
|
171170
171178
|
}
|
|
171179
|
+
/** 编辑旧规则时恢复固定字段的对应关系,保留参数字段和单位值。 */
|
|
171180
|
+
function normalizeFixedFieldMaps(fieldMaps) {
|
|
171181
|
+
return fieldMaps.map((item) => {
|
|
171182
|
+
const fieldKey = FIXED_FORM_FIELD_KEYS[item.key];
|
|
171183
|
+
if (!fieldKey) return item;
|
|
171184
|
+
const row = { ...item };
|
|
171185
|
+
applyFixedFormField(row, fieldKey);
|
|
171186
|
+
return row;
|
|
171187
|
+
});
|
|
171188
|
+
}
|
|
171171
171189
|
/** 按选中规则重建固定映射行 */
|
|
171172
171190
|
function buildFixedFieldMaps(options) {
|
|
171173
171191
|
const { expr, sourceUomId, targetUomId, sourceUomLabel, targetUomLabel } = options;
|
|
@@ -171349,7 +171367,7 @@ var unit_field_map_modal_vue_vue_type_script_setup_true_name_unit_field_map_moda
|
|
|
171349
171367
|
expressionStr: props.item.expressionStr,
|
|
171350
171368
|
productId: props.item.productId,
|
|
171351
171369
|
productName: props.item.productName,
|
|
171352
|
-
fieldMaps: cloneDeep(props.item.fieldMaps ?? [])
|
|
171370
|
+
fieldMaps: normalizeFixedFieldMaps(cloneDeep(props.item.fieldMaps ?? []))
|
|
171353
171371
|
});
|
|
171354
171372
|
const errors = reactive({
|
|
171355
171373
|
ruleId: "",
|
|
@@ -171521,7 +171539,7 @@ var unit_field_map_modal_vue_vue_type_script_setup_true_name_unit_field_map_moda
|
|
|
171521
171539
|
//#endregion
|
|
171522
171540
|
//#region src/suites/edhr/panel-schema/rule/modals/unit-field-map-modal.vue
|
|
171523
171541
|
init__plugin_vue_export_helper();
|
|
171524
|
-
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-
|
|
171542
|
+
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"]]);
|
|
171525
171543
|
//#endregion
|
|
171526
171544
|
//#region src/suites/edhr/panel-schema/rule/modals/open-rule-modal.ts
|
|
171527
171545
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
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-
|
|
13154
|
+
.field-map-panel[data-v-373bcf09] {
|
|
13155
13155
|
margin-top: 12px;
|
|
13156
13156
|
padding: 12px;
|
|
13157
13157
|
border: 1px dashed #e0e3eb;
|