修改套餐价格
This commit is contained in:
@@ -40,6 +40,29 @@ const STATUS_TAG = {
|
||||
/** 默认取值方式 */
|
||||
export const DEFAULT_ROUND_MODE = 'HALF_UP'
|
||||
|
||||
/** version status: 0 draft / 1 active / 2 expired */
|
||||
export const VER_STATUS = {
|
||||
DRAFT: '0',
|
||||
EFFECT: '1',
|
||||
EXPIRED: '2'
|
||||
}
|
||||
|
||||
export function versionStatusLabel(status) {
|
||||
const map = { '0': '草稿', '1': '生效', '2': '失效' }
|
||||
return map[status] || status || '-'
|
||||
}
|
||||
|
||||
export function versionStatusTag(status) {
|
||||
const map = { '0': 'warning', '1': 'success', '2': 'info' }
|
||||
return map[status] || 'info'
|
||||
}
|
||||
|
||||
export function nextVersionNo(versions) {
|
||||
const seqs = (versions || []).map(v => Number(v.versionSeq) || 0)
|
||||
const max = seqs.length ? Math.max.apply(null, seqs) : 0
|
||||
return 'V' + (max + 1)
|
||||
}
|
||||
|
||||
/** 状态文案(已过期优先) */
|
||||
export function setStatusLabel(set) {
|
||||
if (set && set.expired) return '已过期'
|
||||
@@ -201,7 +224,11 @@ export function buildWeightOptions(rows, row) {
|
||||
zoneCode: item.zoneCode,
|
||||
zoneName: item.zoneName,
|
||||
freightPrice: item.freightPrice,
|
||||
registrationFee: item.registrationFee
|
||||
registrationFee: item.registrationFee,
|
||||
weightMin: item.weightMin,
|
||||
weightMax: item.weightMax,
|
||||
effectiveDate: item.effectiveDate,
|
||||
expireDate: item.expireDate
|
||||
})
|
||||
})
|
||||
return [...map.values()]
|
||||
@@ -217,11 +244,29 @@ export function formatChargeValue(row) {
|
||||
|
||||
/** 附加费作用范围文案 */
|
||||
export function surchargeScopeLabel(s) {
|
||||
if (s.detailId == null) return '产品级'
|
||||
// 主表(prc_surcharge)数据:country_code 有值 = 该国专属(计费归属),空 = 全部国家
|
||||
if (s.detailId == null && s.psdId == null) {
|
||||
return s.countryCode ? `国家 ${s.countryCode}` : '全部国家'
|
||||
}
|
||||
const w = s.weightMin != null && s.weightMax != null ? `${s.weightMin}-${s.weightMax}kg` : '-'
|
||||
return `${s.countryName || '-'} · ${w}`
|
||||
}
|
||||
|
||||
/**
|
||||
* 产品关联附加费(prc_surcharge_rel)是否作用于该明细行
|
||||
* 与后端 snapshotVersionSurcharges 的过滤口径保持一致:
|
||||
* 国家三字码一致 + 产品级(detailId 空)直接命中,明细级需 productCountryId 相同
|
||||
*/
|
||||
export function surchargeAppliesToRow(rel, row) {
|
||||
if (!rel || !row) return false
|
||||
if (rel.countryCode && row.countryCode
|
||||
&& String(rel.countryCode).toUpperCase() !== String(row.countryCode).toUpperCase()) {
|
||||
return false
|
||||
}
|
||||
if (rel.detailId == null) return true
|
||||
return row.productCountryId != null && Number(rel.detailId) === Number(row.productCountryId)
|
||||
}
|
||||
|
||||
/** 附加费标签文案 */
|
||||
export function surchargeTagLabel(s) {
|
||||
return `${s.scName} ${formatChargeValue(s)}`
|
||||
@@ -239,11 +284,19 @@ export function createEmptyDetailRow() {
|
||||
zoneCode: undefined,
|
||||
zoneName: undefined,
|
||||
weightLabel: undefined,
|
||||
weightMin: undefined,
|
||||
weightMax: undefined,
|
||||
productCountryId: undefined,
|
||||
fvValue: undefined,
|
||||
fvRegistrationFee: undefined,
|
||||
/** product default freight when copied from bms_product_country */
|
||||
_baseFreight: undefined,
|
||||
/** product default registration fee */
|
||||
_baseReg: undefined,
|
||||
discountValue: undefined,
|
||||
roundMode: DEFAULT_ROUND_MODE
|
||||
roundMode: DEFAULT_ROUND_MODE,
|
||||
effectiveDate: undefined,
|
||||
expireDate: undefined
|
||||
}
|
||||
}
|
||||
|
||||
@@ -252,10 +305,20 @@ export function toEditableDetailRow(row) {
|
||||
return {
|
||||
...row,
|
||||
roundMode: row.roundMode || DEFAULT_ROUND_MODE,
|
||||
_countryKey: countryKeyOf(row)
|
||||
_countryKey: countryKeyOf(row),
|
||||
_baseFreight: row._baseFreight != null ? row._baseFreight : undefined,
|
||||
_baseReg: row._baseReg != null ? row._baseReg : undefined
|
||||
}
|
||||
}
|
||||
|
||||
/** FIXED row changed vs product default */
|
||||
export function isDetailPriceChanged(row) {
|
||||
if (!row) return false
|
||||
if (row._baseFreight != null && Number(row.fvValue) !== Number(row._baseFreight)) return true
|
||||
if (row._baseReg != null && Number(row.fvRegistrationFee) !== Number(row._baseReg)) return true
|
||||
return false
|
||||
}
|
||||
|
||||
/** 新增一条空客户绑定行 */
|
||||
export function createEmptyCustomerRow({ effectiveDate, expireDate, seq = 1 } = {}) {
|
||||
return {
|
||||
@@ -283,6 +346,9 @@ export function createEmptyBasicInfo() {
|
||||
/** 明细行 -> 提交后端的 payload */
|
||||
export function toDetailPayload(d) {
|
||||
return {
|
||||
psdId: d.psdId || undefined,
|
||||
psvId: d.psvId || undefined,
|
||||
priceSetId: d.priceSetId || undefined,
|
||||
productCode: d.productCode,
|
||||
productName: d.productName,
|
||||
countryCode: d.countryCode || undefined,
|
||||
@@ -291,11 +357,17 @@ export function toDetailPayload(d) {
|
||||
zoneCode: d.zoneCode || undefined,
|
||||
zoneName: d.zoneName || undefined,
|
||||
weightLabel: d.weightLabel || undefined,
|
||||
weightMin: d.weightMin,
|
||||
weightMax: d.weightMax,
|
||||
productCountryId: d.productCountryId || undefined,
|
||||
fvValue: d.fvValue,
|
||||
fvRegistrationFee: d.fvRegistrationFee,
|
||||
discountValue: d.discountValue,
|
||||
roundMode: d.roundMode || DEFAULT_ROUND_MODE
|
||||
roundMode: d.roundMode || DEFAULT_ROUND_MODE,
|
||||
effectiveDate: d.effectiveDate || undefined,
|
||||
expireDate: d.expireDate || undefined,
|
||||
/** 勾选保存的附加费:带数组即按勾选落快照,空数组=一条都不选 */
|
||||
surcharges: Array.isArray(d.surcharges) ? d.surcharges.map(s => ({ scId: s.scId })) : undefined
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user