新增附加费计费标识,优化附加费管理逻辑
This commit is contained in:
@@ -21,9 +21,18 @@
|
||||
<span>{{ cardTitle }}</span>
|
||||
<span class="header-tip">{{ headerTip }}</span>
|
||||
</div>
|
||||
<el-button type="primary" plain icon="Upload" @click="openImport" v-hasPermi="['price:label:import', 'price:label:add']">
|
||||
导入价卡
|
||||
</el-button>
|
||||
<div class="header-actions">
|
||||
<el-button
|
||||
type="danger"
|
||||
plain
|
||||
icon="Delete"
|
||||
:disabled="!selectedProducts.length"
|
||||
@click="removeSelectedProducts"
|
||||
>批量删除</el-button>
|
||||
<el-button type="primary" plain icon="Upload" @click="openImport" v-hasPermi="['price:label:import', 'price:label:add']">
|
||||
导入价卡
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -36,7 +45,18 @@
|
||||
class="meta-alert"
|
||||
/>
|
||||
|
||||
<el-table v-loading="loadingProducts" :data="productRows" border size="small" max-height="420" empty-text="请点击右上角「导入价卡」">
|
||||
<el-table
|
||||
ref="productTableRef"
|
||||
v-loading="loadingProducts"
|
||||
:data="productRows"
|
||||
border
|
||||
size="small"
|
||||
max-height="420"
|
||||
row-key="rowKey"
|
||||
empty-text="请点击右上角「导入价卡」"
|
||||
@selection-change="onProductSelect"
|
||||
>
|
||||
<el-table-column type="selection" width="48" align="center" />
|
||||
<el-table-column prop="productName" label="产品" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column prop="sheetName" label="报价工作表" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column prop="countryScope" label="国家/口岸" min-width="110" show-overflow-tooltip />
|
||||
@@ -54,9 +74,10 @@
|
||||
<span v-else>新记录</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="90" align="center" fixed="right">
|
||||
<el-table-column label="操作" width="140" align="center" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button link type="primary" icon="View" @click="openDetail(row)">查看</el-button>
|
||||
<el-button link type="primary" icon="Edit" @click="openDetail(row)">编辑</el-button>
|
||||
<el-button link type="danger" icon="Delete" @click="removeProduct(row)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@@ -79,6 +100,7 @@
|
||||
<pay-config-detail
|
||||
:product="detailProduct"
|
||||
:editable="true"
|
||||
:bill-select="true"
|
||||
:saving-row-key="savingRowKey"
|
||||
@save-row="saveDetailRow"
|
||||
/>
|
||||
@@ -104,6 +126,8 @@ const form = reactive({
|
||||
basic: createEmptyBasicInfo()
|
||||
})
|
||||
const productRows = ref([])
|
||||
const productTableRef = ref()
|
||||
const selectedProducts = ref([])
|
||||
const importMeta = reactive({
|
||||
sourceFile: '',
|
||||
supplierName: '',
|
||||
@@ -141,7 +165,7 @@ const pageBanner = computed(() => {
|
||||
const headerTip = computed(() => {
|
||||
if (editVersionMode.value) return '可重新导入或修改明细;完成后覆盖本版本,不新增版本号'
|
||||
if (newVersionMode.value) return '导入后生成待生效新版本;生效时间请回详情页设置'
|
||||
return '打单价卡与应付独立;解析后回填到此表,查看明细后可在行内保存修改'
|
||||
return '打单价卡与应付独立;解析后回填到此表,可删除不需要的产品,编辑明细后点完成保存'
|
||||
})
|
||||
|
||||
function goBack() {
|
||||
@@ -196,7 +220,9 @@ async function loadEditProducts() {
|
||||
}
|
||||
}
|
||||
}))
|
||||
productRows.value = details
|
||||
// 库中已落库的附加费默认勾选(保留原计费项)
|
||||
productRows.value = markSurchargeBillFlags(details, true)
|
||||
selectedProducts.value = []
|
||||
importMeta.sourceFile = details[0]?.sourceFile || ''
|
||||
importMeta.supplierName = details[0]?.supplierName || ''
|
||||
importMeta.overwrite = true
|
||||
@@ -209,8 +235,71 @@ async function openImport() {
|
||||
importRef.value?.open()
|
||||
}
|
||||
|
||||
function markSurchargeBillFlags(products, defaultNeedBill) {
|
||||
return (products || []).map(product => ({
|
||||
...product,
|
||||
surcharges: (product.surcharges || []).map(fee => ({
|
||||
...fee,
|
||||
needBill: fee?.needBill === true ? true : (fee?.needBill === false ? false : !!defaultNeedBill)
|
||||
}))
|
||||
}))
|
||||
}
|
||||
|
||||
function withBillableSurcharges(products) {
|
||||
return (products || []).map(product => ({
|
||||
...product,
|
||||
surcharges: (product.surcharges || []).filter(fee => fee && fee.needBill === true)
|
||||
}))
|
||||
}
|
||||
|
||||
function onProductSelect(rows) {
|
||||
selectedProducts.value = rows || []
|
||||
}
|
||||
|
||||
function productKey(row) {
|
||||
return row?.rowKey || `${row?.sheetName || ''}-${row?.productName || ''}`
|
||||
}
|
||||
|
||||
async function removeProduct(row) {
|
||||
if (!row) return
|
||||
try {
|
||||
await proxy.$modal.confirm(`确认从本次导入中移除产品「${row.productName || row.sheetName || ''}」?`)
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
const key = productKey(row)
|
||||
productRows.value = productRows.value.filter(item => productKey(item) !== key)
|
||||
selectedProducts.value = selectedProducts.value.filter(item => productKey(item) !== key)
|
||||
if (detailRowKey.value === key) {
|
||||
detailVisible.value = false
|
||||
}
|
||||
proxy.$modal.msgSuccess('已删除')
|
||||
}
|
||||
|
||||
async function removeSelectedProducts() {
|
||||
const rows = selectedProducts.value || []
|
||||
if (!rows.length) {
|
||||
proxy.$modal.msgWarning('请先勾选要删除的产品')
|
||||
return
|
||||
}
|
||||
try {
|
||||
await proxy.$modal.confirm(`确认删除所选 ${rows.length} 个产品?`)
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
const keys = new Set(rows.map(productKey))
|
||||
productRows.value = productRows.value.filter(item => !keys.has(productKey(item)))
|
||||
selectedProducts.value = []
|
||||
if (keys.has(detailRowKey.value)) {
|
||||
detailVisible.value = false
|
||||
}
|
||||
proxy.$modal.msgSuccess('已批量删除')
|
||||
}
|
||||
|
||||
function onImportConfirm(payload) {
|
||||
productRows.value = payload?.products || []
|
||||
// 价卡解析行默认不计费,需手动勾选
|
||||
productRows.value = markSurchargeBillFlags(payload?.products || [], false)
|
||||
selectedProducts.value = []
|
||||
importMeta.sourceFile = payload?.sourceFile || ''
|
||||
importMeta.supplierName = payload?.supplierName || ''
|
||||
importMeta.effectiveDate = payload?.effectiveDate || ''
|
||||
@@ -226,6 +315,10 @@ function openDetail(row) {
|
||||
}
|
||||
|
||||
function onDetailClosed() {
|
||||
// 关闭抽屉时回写勾选结果(不依赖行内「保存」)
|
||||
if (detailProduct.value && detailRowKey.value) {
|
||||
applyEditedProduct()
|
||||
}
|
||||
detailProduct.value = null
|
||||
detailRowKey.value = ''
|
||||
savingRowKey.value = ''
|
||||
@@ -303,6 +396,10 @@ async function finish() {
|
||||
proxy.$modal.msgWarning('请先导入并确认价卡产品')
|
||||
return
|
||||
}
|
||||
// 抽屉未关闭时先回写勾选,避免丢失
|
||||
if (detailVisible.value && detailProduct.value && detailRowKey.value) {
|
||||
applyEditedProduct()
|
||||
}
|
||||
const tip = editVersionMode.value
|
||||
? `将覆盖版本 V${versionNo.value} 的 ${productRows.value.length} 个产品,确认继续?`
|
||||
: newVersionMode.value
|
||||
@@ -317,7 +414,7 @@ async function finish() {
|
||||
try {
|
||||
const payload = {
|
||||
overwrite: editVersionMode.value ? true : importMeta.overwrite,
|
||||
products: productRows.value
|
||||
products: withBillableSurcharges(productRows.value)
|
||||
}
|
||||
if (editVersionMode.value) {
|
||||
payload.priceSetId = priceSetId.value
|
||||
@@ -367,6 +464,11 @@ watch([priceSetId, versionNo, () => route.query.editVersion, () => route.query.n
|
||||
color: #909399;
|
||||
font-weight: normal;
|
||||
}
|
||||
.header-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
.meta-alert {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user