新增邮编相关字段及优化附加费计算逻辑
This commit is contained in:
@@ -100,14 +100,11 @@
|
||||
<template #default="{ row }"><b>{{ row.productCode }}</b></template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="colName" prop="productName" min-width="80" show-overflow-tooltip />
|
||||
<el-table-column :label="colLevel" prop="serviceLevel" width="90" align="center" />
|
||||
<el-table-column :label="colCargo" width="200" align="center">
|
||||
<el-table-column :label="colSc" min-width="200">
|
||||
<template #default="{ row }">
|
||||
<el-tag v-if="row.cargoAttr" type="primary" size="small" effect="plain">{{ row.cargoAttr }}</el-tag>
|
||||
<span v-else>-</span>
|
||||
<surcharge-tags :list="productSurcharges(row)" :empty-text="noneSc" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="colRegion" prop="destRegion" width="90" align="center" />
|
||||
<el-table-column :label="colAction" width="220" align="center" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button link type="primary" @click="openPrice(row)">编辑价格</el-button>
|
||||
@@ -211,6 +208,7 @@
|
||||
import ExcelImportDialog from '@/components/ExcelImportDialog'
|
||||
import PriceEditDrawer from './PriceEditDrawer.vue'
|
||||
import SurchargePickerDialog from './SurchargePickerDialog.vue'
|
||||
import SurchargeTags from '../SurchargeTags.vue'
|
||||
import { useDetailCascade } from '../../composables/usePriceSetRefData'
|
||||
import {
|
||||
createEmptyDetailRow,
|
||||
@@ -271,10 +269,8 @@ const phKeyword = '产品代码/名称'
|
||||
const phTax = '全部税模式'
|
||||
const colCode = '产品代码'
|
||||
const colName = '产品名称'
|
||||
const colLevel = '时效等级'
|
||||
const colCargo = '走货属性'
|
||||
const colRegion = '目的区域'
|
||||
// const colTax = '税模式'
|
||||
const colSc = '附加费'
|
||||
const noneSc = '无'
|
||||
const colAction = '操作'
|
||||
const colDiscount = '产品折扣'
|
||||
|
||||
@@ -505,14 +501,24 @@ const productGroups = computed(() => {
|
||||
return (props.products || []).filter(p => p && p.productCode).map(p => ({
|
||||
productCode: p.productCode,
|
||||
productName: p.productName || p.productCode,
|
||||
serviceLevel: p.serviceLevel,
|
||||
cargoAttr: p.cargoAttr,
|
||||
destRegion: p.destRegion,
|
||||
taxMode: p.taxMode,
|
||||
rows: detailByProduct[p.productCode] || []
|
||||
}))
|
||||
})
|
||||
|
||||
/** 产品级附加费:合并该产品下所有明细行的 scId(去重) */
|
||||
function productSurcharges(product) {
|
||||
const map = new Map()
|
||||
for (const r of product?.rows || []) {
|
||||
for (const s of r?.surcharges || []) {
|
||||
if (!s || s.scId == null) continue
|
||||
const key = String(s.scId)
|
||||
if (!map.has(key)) map.set(key, s)
|
||||
}
|
||||
}
|
||||
return [...map.values()]
|
||||
}
|
||||
|
||||
const filteredProducts = computed(() => {
|
||||
const kw = (query.keyword || '').trim().toLowerCase()
|
||||
return productGroups.value.filter(p => {
|
||||
@@ -632,6 +638,46 @@ watch(
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
/** 编辑页:按版本一次拉齐明细,供产品表展示附加费 */
|
||||
async function preloadVersionDetails() {
|
||||
if (!props.livePersist) {
|
||||
const byCode = {}
|
||||
for (const d of props.details || []) {
|
||||
if (!d?.productCode) continue
|
||||
if (!byCode[d.productCode]) byCode[d.productCode] = []
|
||||
byCode[d.productCode].push(d)
|
||||
}
|
||||
Object.keys(detailByProduct).forEach(k => delete detailByProduct[k])
|
||||
Object.assign(detailByProduct, byCode)
|
||||
return
|
||||
}
|
||||
const psvId = props.psvId || resolvedPsvId.value
|
||||
if (!psvId) return
|
||||
try {
|
||||
const res = await api.listSetDetailByVersion(psvId)
|
||||
const byCode = {}
|
||||
for (const raw of res.data || []) {
|
||||
if (!raw?.productCode) continue
|
||||
const d = hydrateRow(raw, props.setType)
|
||||
if (!byCode[d.productCode]) byCode[d.productCode] = []
|
||||
byCode[d.productCode].push(d)
|
||||
}
|
||||
Object.keys(detailByProduct).forEach(k => delete detailByProduct[k])
|
||||
Object.assign(detailByProduct, byCode)
|
||||
if (Array.isArray(props.details)) {
|
||||
props.details.splice(0, props.details.length, ...Object.values(byCode).flat())
|
||||
}
|
||||
} catch (e) {
|
||||
/* 预加载失败不阻断编辑;点附加费时仍会按产品拉取 */
|
||||
}
|
||||
}
|
||||
|
||||
watch(
|
||||
() => [props.livePersist, props.psvId, props.products?.length],
|
||||
() => { preloadVersionDetails() },
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
async function openImport() {
|
||||
if (!(await canOpenImport())) return
|
||||
importRef.value && importRef.value.open()
|
||||
|
||||
@@ -21,14 +21,11 @@
|
||||
<template #default="{ row }"><b>{{ row.productCode }}</b></template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="colName" prop="productName" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column :label="colLevel" prop="serviceLevel" width="90" align="center" />
|
||||
<el-table-column :label="colCargo" min-width="140" align="center" show-overflow-tooltip>
|
||||
<el-table-column :label="colSc" min-width="200">
|
||||
<template #default="{ row }">
|
||||
<el-tag v-if="row.cargoAttr" type="primary" size="small" effect="plain">{{ row.cargoAttr }}</el-tag>
|
||||
<span v-else>-</span>
|
||||
<surcharge-tags :list="row.surcharges || []" :empty-text="noneSc" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="colRegion" prop="destRegion" width="100" align="center" />
|
||||
<el-table-column :label="colAction" width="110" align="center" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button link type="primary" @click.stop="openProductDetail(row)">查看明细</el-button>
|
||||
@@ -159,9 +156,6 @@ const emptyProduct = '暂无产品'
|
||||
const emptyDetail = '暂无明细'
|
||||
const colCode = '产品代码'
|
||||
const colName = '产品名称'
|
||||
const colLevel = '时效等级'
|
||||
const colCargo = '走货属性'
|
||||
const colRegion = '目的区域'
|
||||
const colAction = '操作'
|
||||
const colCountry = '国家'
|
||||
const colZone = '分区'
|
||||
@@ -300,13 +294,30 @@ function normalizeProducts(list) {
|
||||
.map(p => ({
|
||||
productCode: p.productCode || p.code,
|
||||
productName: p.productName || p.name || p.productCode || p.code,
|
||||
serviceLevel: p.serviceLevel,
|
||||
cargoAttr: p.cargoAttr,
|
||||
destRegion: p.destRegion,
|
||||
taxMode: p.taxMode
|
||||
taxMode: p.taxMode,
|
||||
surcharges: []
|
||||
}))
|
||||
}
|
||||
|
||||
/** 按产品汇总版本明细上的附加费(scId 去重) */
|
||||
function attachProductSurcharges(productList, detailRows) {
|
||||
const byCode = new Map()
|
||||
for (const d of detailRows || []) {
|
||||
if (!d?.productCode) continue
|
||||
if (!byCode.has(d.productCode)) byCode.set(d.productCode, new Map())
|
||||
const map = byCode.get(d.productCode)
|
||||
for (const s of d.surcharges || []) {
|
||||
if (!s || s.scId == null) continue
|
||||
const key = String(s.scId)
|
||||
if (!map.has(key)) map.set(key, s)
|
||||
}
|
||||
}
|
||||
return (productList || []).map(p => ({
|
||||
...p,
|
||||
surcharges: [...(byCode.get(p.productCode)?.values() || [])]
|
||||
}))
|
||||
}
|
||||
|
||||
async function loadProducts() {
|
||||
const v = props.version || {}
|
||||
const psvId = v.psvId
|
||||
@@ -316,14 +327,16 @@ async function loadProducts() {
|
||||
}
|
||||
loading.value = true
|
||||
try {
|
||||
const fromVersion = normalizeProducts(v.products)
|
||||
if (fromVersion.length) {
|
||||
products.value = fromVersion
|
||||
return
|
||||
let list = normalizeProducts(v.products)
|
||||
if (!list.length) {
|
||||
const res = await api.listSetDetailOptions(psvId)
|
||||
const data = res.data || {}
|
||||
list = normalizeProducts(data.products || [])
|
||||
}
|
||||
const res = await api.listSetDetailOptions(psvId)
|
||||
const data = res.data || {}
|
||||
products.value = normalizeProducts(data.products || [])
|
||||
const detailRes = await api.listSetDetailByVersion(psvId)
|
||||
products.value = attachProductSurcharges(list, detailRes.data || [])
|
||||
} catch (e) {
|
||||
products.value = normalizeProducts(v.products)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user