导入新产品,20.套餐编辑的时候,不能低于基准价,低于就提示不能保存

This commit is contained in:
wuweihua
2026-09-21 15:11:25 +08:00
parent 6322e20ea4
commit 83f19e1dca
11 changed files with 739 additions and 11 deletions
@@ -268,6 +268,8 @@ function countryToDetail(item, productCode, productName) {
const baseReg = item.registrationFee != null ? Number(item.registrationFee) : undefined
row._baseFreight = baseFv
row._baseReg = baseReg
row._floorFreight = baseFv
row._floorReg = baseReg
row.fvValue = baseFv
row.fvRegistrationFee = baseReg
row.effectiveDate = item.effectiveDate
@@ -293,7 +295,9 @@ function openPrice(row) {
return r
})
editGroup.value = row
priceVisible.value = true
Promise.resolve(stampPriceFloors(editRows.value, row.productCode)).finally(() => {
priceVisible.value = true
})
}
/** 抽屉里点附加费:带行 = 行级(只改该行,国家+重量段),不带 = 产品级(覆盖全部明细行) */
@@ -319,10 +323,45 @@ async function persistDetail(row, withSurcharge) {
/** drawer field change -> immediate DB update */
async function onRowPriceChange(row) {
if (!row || !row.psdId) return
const prevFv = row._editPrevFv
const prevReg = row._editPrevReg
try {
await persistDetail(row, false)
proxy.$modal.msgSuccess('价格已更新')
} catch (e) {}
} catch (e) {
if (prevFv !== undefined) row.fvValue = prevFv
if (prevReg !== undefined) row.fvRegistrationFee = prevReg
}
}
function applyImportedFloor(row, hit) {
if (!row || !hit) return
if (hit.freightPrice != null) row._floorFreight = Number(hit.freightPrice)
if (hit.registrationFee != null) row._floorReg = Number(hit.registrationFee)
}
function findImportedCountry(rows, row) {
if (!rows || !rows.length || !row) return null
if (row.productCountryId != null) {
const byId = rows.find(item => Number(item.detailId) === Number(row.productCountryId))
if (byId) return byId
}
return rows.find(item => {
const sameCountry = (row.countryCode && item.countryCode
&& String(row.countryCode).toUpperCase() === String(item.countryCode).toUpperCase())
|| (!row.countryCode && row.countryName && item.countryName && row.countryName === item.countryName)
if (!sameCountry) return false
if (row.weightMin != null && item.weightMin != null && Number(row.weightMin) !== Number(item.weightMin)) return false
if (row.weightMax != null && item.weightMax != null && Number(row.weightMax) !== Number(item.weightMax)) return false
return row.weightMin != null || row.weightMax != null
}) || null
}
function stampPriceFloors(rows, productCode) {
if (!props.refData || !productCode || !rows || !rows.length) return Promise.resolve()
return props.refData.ensureCountries(productCode, props.effectiveTime).then(list => {
rows.forEach(row => applyImportedFloor(row, findImportedCountry(list, row)))
})
}
async function saveDiscount() {