Refactor surcharge management by replacing PrcPriceSetVersionSurcharge with PrcSurchargeRel, introducing price type handling (PRODUCT, SALES, REDLINE) and updating related services, mappers, and front-end components. Enhance validation and error messaging for price type and detail ID requirements. Update database schema to support new relationships and constraints.

This commit is contained in:
wuweihua
2026-10-09 17:20:10 +08:00
parent 70e9c18182
commit 380577f691
19 changed files with 647 additions and 530 deletions
@@ -314,7 +314,7 @@ export function useDetailCascade(refData) {
const row = toEditableDetailRow(d)
if (!row.productCode) return row
// Do NOT prefetch /surcharge/byProduct here: applySetData hydrates every detail row
// on step-1 load; use version snapshot row.surcharges instead. Fetch on demand in picker.
// on step-1 load; use SALES rels on row.surcharges instead. Fetch on demand in picker.
if (setType !== 'FIXED') return row
// Bulk load from DB already has productCountryId + weight bounds: normalize locally,
// do not fire /countries per detail row (was stampeding thousands of identical requests).
@@ -301,8 +301,7 @@ export function surchargeScopeLabel(s) {
/**
* 产品关联附加费(prc_surcharge_rel)是否作用于该明细行
* 与后端 snapshotVersionSurcharges 的过滤口径保持一致:
* 国家三字码一致 + 产品级(detailId 空)直接命中,明细级需 productCountryId 相同
* 产品关联:国家 + productCountryId;SALES:detailId=psdId
*/
export function surchargeAppliesToRow(rel, row) {
if (!rel || !row) return false
@@ -310,6 +309,14 @@ export function surchargeAppliesToRow(rel, row) {
&& String(rel.countryCode).toUpperCase() !== String(row.countryCode).toUpperCase()) {
return false
}
// SALES rel: detail_id = psd_id
if (rel.priceType === 'SALES') {
if (rel.detailId != null && row.psdId != null) {
return Number(rel.detailId) === Number(row.psdId)
}
return true
}
// PRODUCT / REDLINE: product_country detail or product-level
if (rel.detailId == null) return true
return row.productCountryId != null && Number(rel.detailId) === Number(row.productCountryId)
}