调整应付配置和应付列表订单的费用重算
This commit is contained in:
@@ -46,6 +46,29 @@ export function payParseProgress(progressId) {
|
||||
})
|
||||
}
|
||||
|
||||
/** 按标准模板预览,不写数据库 */
|
||||
export function previewPayTemplate(file, chargeType) {
|
||||
const data = new FormData()
|
||||
data.append('file', file)
|
||||
data.append('chargeType', chargeType)
|
||||
return request({
|
||||
url: '/price/pay/template/preview',
|
||||
method: 'post',
|
||||
data,
|
||||
headers: { 'Content-Type': 'multipart/form-data', repeatSubmit: false },
|
||||
timeout: 120000
|
||||
})
|
||||
}
|
||||
|
||||
/** 按所选计费模式手工新增一条价卡 */
|
||||
export function savePayManual(data) {
|
||||
return request({
|
||||
url: '/price/pay/manual',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
/** 修改已保存的公共模板 */
|
||||
export function updatePay(data) {
|
||||
return request({
|
||||
@@ -172,29 +195,3 @@ export function delPay(productIds) {
|
||||
})
|
||||
}
|
||||
|
||||
/** 产品上的附加费计费条件,不按价格版本拆开 */
|
||||
export function listPaySurchargeRule(productId) {
|
||||
return request({
|
||||
url: '/price/pay/surchargeRule',
|
||||
method: 'get',
|
||||
params: { productId }
|
||||
})
|
||||
}
|
||||
|
||||
/** 这一版产品上的附加费配置操作记录 */
|
||||
export function listPaySurchargeRuleLog(productId, termId) {
|
||||
return request({
|
||||
url: '/price/pay/surchargeRule/log',
|
||||
method: 'get',
|
||||
params: { productId, termId }
|
||||
})
|
||||
}
|
||||
|
||||
/** 覆盖绑定产品当前版本的计费条件。同一版本只保留这一份。 */
|
||||
export function savePaySurchargeRule(data) {
|
||||
return request({
|
||||
url: '/price/pay/surchargeRule',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
@@ -8,6 +8,13 @@ export function listPayOrder(query) {
|
||||
})
|
||||
}
|
||||
|
||||
export function getPayOrder(billId) {
|
||||
return request({
|
||||
url: '/price/payOrder/' + billId,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
export function listPayOrderFees(billId) {
|
||||
return request({
|
||||
url: '/price/payOrder/' + billId + '/fees',
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<el-descriptions-item label="价卡归属">{{ pane.item.supplierName || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="生效日期">{{ pane.item.effectiveDate || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="国家/口岸">{{ pane.item.countryScope || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="费用类型">{{ pane.item.chargeType || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="费用类型">{{ chargeTypeText(pane.item.chargeType) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="每公斤加价">{{ pane.item.extraPerKg || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="服务类型">{{ pane.item.serviceType || '-' }}</el-descriptions-item>
|
||||
<el-descriptions-item label="分类">{{ pane.item.classification || '-' }}</el-descriptions-item>
|
||||
@@ -269,8 +269,20 @@
|
||||
import { h, onMounted, watch } from 'vue'
|
||||
import { ElInput } from 'element-plus'
|
||||
import { listSurchargeOptions } from '@/api/price/surcharge'
|
||||
import { useDict } from '@/utils/dict'
|
||||
import PaySurchargePickerDialog from './PaySurchargePickerDialog.vue'
|
||||
|
||||
const { order_charge_type } = useDict('order_charge_type')
|
||||
|
||||
function chargeTypeText(value) {
|
||||
const hit = (order_charge_type.value || []).find(item => item.value === value)
|
||||
if (hit) return hit.label
|
||||
if (value === 'PER_KG') return '常规计费'
|
||||
if (value === 'FLAT') return '一口价'
|
||||
if (value === 'EXTRA') return '续重价'
|
||||
return value || '-'
|
||||
}
|
||||
|
||||
const props = defineProps({
|
||||
product: {
|
||||
type: Object,
|
||||
|
||||
@@ -0,0 +1,290 @@
|
||||
<template>
|
||||
<el-dialog v-model="visible" title="新增应付价卡" width="1080px" append-to-body destroy-on-close @closed="reset">
|
||||
<el-form label-width="88px">
|
||||
<el-row :gutter="12">
|
||||
<el-col :span="8">
|
||||
<el-form-item label="计费模式" required>
|
||||
<el-select v-model="form.chargeType" style="width: 100%" @change="onMode">
|
||||
<el-option v-for="item in modes" :key="item.value" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="产品名称" required>
|
||||
<el-input v-model="form.productName" maxlength="80" placeholder="渠道或产品名称" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="价卡归属">
|
||||
<el-input v-model="form.supplierName" maxlength="40" placeholder="供应商" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="币种">
|
||||
<el-select v-model="form.currency" filterable placeholder="请选择币种" style="width: 100%">
|
||||
<el-option v-for="item in currencyOptions" :key="item.value" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="16">
|
||||
<el-form-item label="国家/口岸">
|
||||
<el-select
|
||||
v-model="scopeCodes"
|
||||
multiple
|
||||
filterable
|
||||
collapse-tags
|
||||
collapse-tags-tooltip
|
||||
placeholder="不选则按价格行里的国家汇总"
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-option v-for="item in regions" :key="item.countryCode2" :label="regionLabel(item)" :value="item.countryCode2" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
<div class="bar">
|
||||
<span>{{ hint }}</span>
|
||||
<el-button type="primary" link @click="addRow">添加一行</el-button>
|
||||
</div>
|
||||
<el-table :data="rows" border size="small" max-height="360">
|
||||
<el-table-column label="国家" min-width="200">
|
||||
<template #default="{ row }">
|
||||
<el-select
|
||||
v-model="row.countryCode"
|
||||
filterable
|
||||
clearable
|
||||
size="small"
|
||||
placeholder="选择国家"
|
||||
style="width: 100%"
|
||||
@change="code => onCountry(row, code)"
|
||||
>
|
||||
<el-option v-for="item in regions" :key="item.countryCode2" :label="regionLabel(item)" :value="item.countryCode2" />
|
||||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="分区" min-width="120">
|
||||
<template #default="{ row }"><el-input v-model="row.zoneName" size="small" placeholder="不分区可空" /></template>
|
||||
</el-table-column>
|
||||
<el-table-column v-if="form.chargeType !== 'EXTRA'" label="重量下限KG" width="120">
|
||||
<template #default="{ row }"><el-input v-model="row.weightMin" size="small" /></template>
|
||||
</el-table-column>
|
||||
<el-table-column v-if="form.chargeType !== 'EXTRA'" label="重量上限KG" width="120">
|
||||
<template #default="{ row }"><el-input v-model="row.weightMax" size="small" /></template>
|
||||
</el-table-column>
|
||||
<el-table-column v-if="form.chargeType === 'PER_KG'" label="单价" width="110">
|
||||
<template #default="{ row }"><el-input v-model="row.price" size="small" /></template>
|
||||
</el-table-column>
|
||||
<el-table-column v-if="form.chargeType === 'FLAT'" label="价格" width="110">
|
||||
<template #default="{ row }"><el-input v-model="row.price" size="small" /></template>
|
||||
</el-table-column>
|
||||
<el-table-column v-if="form.chargeType === 'EXTRA'" label="首重KG" width="110">
|
||||
<template #default="{ row }"><el-input v-model="row.weightMax" size="small" /></template>
|
||||
</el-table-column>
|
||||
<el-table-column v-if="form.chargeType === 'EXTRA'" label="首重价格" width="110">
|
||||
<template #default="{ row }"><el-input v-model="row.price" size="small" /></template>
|
||||
</el-table-column>
|
||||
<el-table-column v-if="form.chargeType === 'EXTRA'" label="续重单价" width="110">
|
||||
<template #default="{ row }"><el-input v-model="row.extraPrice" size="small" /></template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="160" align="center">
|
||||
<template #default="{ $index }">
|
||||
<el-button v-if="$index > 0" link type="primary" @click="copyPrev($index)">复制上一行</el-button>
|
||||
<el-button link type="danger" @click="rows.splice($index, 1)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<template #footer>
|
||||
<el-button @click="visible = false">取消</el-button>
|
||||
<el-button type="primary" :loading="saving" @click="submit">保存</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { savePayManual } from '@/api/price/pay'
|
||||
import { listRegionOptions } from '@/api/data/region'
|
||||
import { useDict } from '@/utils/dict'
|
||||
|
||||
const emit = defineEmits(['saved'])
|
||||
const { proxy } = getCurrentInstance()
|
||||
const { order_charge_type, bms_currency } = useDict('order_charge_type', 'bms_currency')
|
||||
|
||||
const fallbackModes = [
|
||||
{ label: '常规计费', value: 'PER_KG' },
|
||||
{ label: '一口价', value: 'FLAT' },
|
||||
{ label: '续重价', value: 'EXTRA' }
|
||||
]
|
||||
|
||||
const visible = ref(false)
|
||||
const saving = ref(false)
|
||||
const regions = ref([])
|
||||
const scopeCodes = ref([])
|
||||
const form = reactive({ chargeType: 'FLAT', productName: '', supplierName: '', currency: 'EUR' })
|
||||
const rows = ref([])
|
||||
|
||||
const currencyOptions = computed(() => {
|
||||
const dict = (bms_currency.value || []).map(item => ({
|
||||
label: item.label || item.value,
|
||||
value: item.value
|
||||
}))
|
||||
return dict.length ? dict : [{ label: 'EUR', value: 'EUR' }]
|
||||
})
|
||||
|
||||
const modes = computed(() => {
|
||||
const dict = (order_charge_type.value || []).filter(item => ['PER_KG', 'FLAT', 'EXTRA'].includes(item.value))
|
||||
return dict.length ? dict : fallbackModes
|
||||
})
|
||||
|
||||
const hint = computed(() => {
|
||||
if (form.chargeType === 'PER_KG') return '常规计费:运费 = 单价 × 计费重(公斤)。重量落在哪一档,就用那一档的单价。'
|
||||
if (form.chargeType === 'EXTRA') return '续重价:不超过首重收首重价格;超出部分 = 超出公斤 × 续重单价。'
|
||||
return '一口价:计费重落在重量段内,收这一档的固定金额。'
|
||||
})
|
||||
|
||||
function open() {
|
||||
reset()
|
||||
loadRegions()
|
||||
visible.value = true
|
||||
}
|
||||
|
||||
function loadRegions() {
|
||||
if (regions.value.length) return
|
||||
listRegionOptions().then(res => {
|
||||
regions.value = res.data || []
|
||||
})
|
||||
}
|
||||
|
||||
function regionLabel(item) {
|
||||
const name = item.countryNameCn || item.countryNameEn || ''
|
||||
const code = item.countryCode2 || ''
|
||||
return name ? `${item.flagEmoji || ''} ${name} (${code})`.trim() : code
|
||||
}
|
||||
|
||||
function regionName(code) {
|
||||
const hit = regions.value.find(item => item.countryCode2 === code)
|
||||
return hit ? (hit.countryNameCn || hit.countryNameEn || code) : code
|
||||
}
|
||||
|
||||
function onCountry(row, code) {
|
||||
row.countryCode = code || ''
|
||||
row.countryName = code ? regionName(code) : ''
|
||||
}
|
||||
|
||||
function reset() {
|
||||
form.chargeType = 'FLAT'
|
||||
form.productName = ''
|
||||
form.supplierName = ''
|
||||
form.currency = 'EUR'
|
||||
scopeCodes.value = []
|
||||
rows.value = [blankRow()]
|
||||
saving.value = false
|
||||
}
|
||||
|
||||
function onMode() {
|
||||
rows.value = [blankRow()]
|
||||
}
|
||||
|
||||
function blankRow() {
|
||||
return { countryName: '', countryCode: '', zoneName: '', weightMin: '0', weightMax: '', price: '', extraPrice: '' }
|
||||
}
|
||||
|
||||
function addRow() {
|
||||
rows.value.push(blankRow())
|
||||
}
|
||||
|
||||
function copyPrev(index) {
|
||||
const prev = rows.value[index - 1]
|
||||
if (!prev) return
|
||||
rows.value[index] = { ...prev }
|
||||
}
|
||||
|
||||
function num(value, title) {
|
||||
const text = String(value ?? '').trim()
|
||||
if (!text) {
|
||||
proxy.$modal.msgError('请填写' + title)
|
||||
return null
|
||||
}
|
||||
const parsed = Number(text)
|
||||
if (Number.isNaN(parsed)) {
|
||||
proxy.$modal.msgError(title + '必须是数字')
|
||||
return null
|
||||
}
|
||||
return parsed
|
||||
}
|
||||
|
||||
async function submit() {
|
||||
if (!form.productName.trim()) {
|
||||
proxy.$modal.msgError('请填写产品名称')
|
||||
return
|
||||
}
|
||||
if (!rows.value.length) {
|
||||
proxy.$modal.msgError('请至少添加一行价格')
|
||||
return
|
||||
}
|
||||
const bands = []
|
||||
const surcharges = []
|
||||
for (const row of rows.value) {
|
||||
const price = num(row.price, form.chargeType === 'PER_KG' ? '单价' : form.chargeType === 'EXTRA' ? '首重价格' : '价格')
|
||||
if (price == null) return
|
||||
if (form.chargeType === 'EXTRA') {
|
||||
const firstKg = num(row.weightMax, '首重KG')
|
||||
const extra = num(row.extraPrice, '续重单价')
|
||||
if (firstKg == null || extra == null) return
|
||||
bands.push({
|
||||
countryName: row.countryName,
|
||||
countryCode: row.countryCode,
|
||||
zoneName: row.zoneName,
|
||||
weightMin: 0,
|
||||
weightMax: firstKg,
|
||||
price
|
||||
})
|
||||
surcharges.push({
|
||||
zoneName: row.zoneName,
|
||||
amount: extra,
|
||||
calcParam: String(firstKg)
|
||||
})
|
||||
continue
|
||||
}
|
||||
const min = num(row.weightMin, '重量下限')
|
||||
const max = num(row.weightMax, '重量上限')
|
||||
if (min == null || max == null) return
|
||||
bands.push({
|
||||
countryName: row.countryName,
|
||||
countryCode: row.countryCode,
|
||||
zoneName: row.zoneName,
|
||||
weightMin: min,
|
||||
weightMax: max,
|
||||
price
|
||||
})
|
||||
}
|
||||
saving.value = true
|
||||
try {
|
||||
const countryScope = scopeCodes.value.map(regionName).filter(Boolean).join('、')
|
||||
await savePayManual({
|
||||
...form,
|
||||
productName: form.productName.trim(),
|
||||
countryScope,
|
||||
weightBands: bands,
|
||||
surcharges
|
||||
})
|
||||
proxy.$modal.msgSuccess('价卡已保存')
|
||||
visible.value = false
|
||||
emit('saved')
|
||||
} finally {
|
||||
saving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
defineExpose({ open })
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 8px;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
</style>
|
||||
@@ -1,7 +1,19 @@
|
||||
<template>
|
||||
<el-dialog v-model="visible" title="导入应付价卡" width="1080px" append-to-body destroy-on-close @closed="reset">
|
||||
<el-form label-width="88px" class="import-form">
|
||||
<el-form-item label="产品">
|
||||
<el-form-item label="导入方式">
|
||||
<el-radio-group v-model="importMode">
|
||||
<el-radio value="template">标准模板</el-radio>
|
||||
<el-radio value="source">承运商原表</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="importMode === 'template'" label="计费模式">
|
||||
<el-select v-model="chargeType" placeholder="选择后下载对应模板" style="width: 280px">
|
||||
<el-option v-for="item in modes" :key="item.value" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
<el-button link type="primary" :disabled="!chargeType" @click="downloadTemplate">下载模板</el-button>
|
||||
</el-form-item>
|
||||
<el-form-item v-else label="产品">
|
||||
<el-select v-model="dictValue" clearable filterable placeholder="不选则按工作表名称匹配全部字典产品" style="width: 420px">
|
||||
<el-option v-for="item in payment_product_type" :key="item.value" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
@@ -19,7 +31,7 @@
|
||||
<el-icon class="upload-icon"><UploadFilled /></el-icon>
|
||||
<div class="el-upload__text">将 xlsx 价卡拖到此处,或<em>点击选择</em></div>
|
||||
<template #tip>
|
||||
<div class="upload-tip">选一个产品就只读对应工作表。不选时,一个文件里有多张表,只读取名称能对上字典的工作表。</div>
|
||||
<div class="upload-tip">{{ importMode === 'template' ? '请先选择计费模式并下载模板,按模板填写后再上传。示例行不会导入。' : '选一个产品就只读对应工作表。不选时,一个文件里有多张表,只读取名称能对上字典的工作表。' }}</div>
|
||||
</template>
|
||||
</el-upload>
|
||||
|
||||
@@ -104,18 +116,29 @@
|
||||
<script setup>
|
||||
import { ElMessageBox } from 'element-plus'
|
||||
import { UploadFilled } from '@element-plus/icons-vue'
|
||||
import { previewPay, payParseProgress, savePay } from '@/api/price/pay'
|
||||
import { previewPay, previewPayTemplate, payParseProgress, savePay } from '@/api/price/pay'
|
||||
import { useDict } from '@/utils/dict'
|
||||
import PayConfigDetail from './PayConfigDetail.vue'
|
||||
|
||||
const emit = defineEmits(['saved'])
|
||||
const { proxy } = getCurrentInstance()
|
||||
const { payment_product_type } = useDict('payment_product_type')
|
||||
const { payment_product_type, order_charge_type } = useDict('payment_product_type', 'order_charge_type')
|
||||
const fallbackModes = [
|
||||
{ label: '常规计费', value: 'PER_KG' },
|
||||
{ label: '一口价', value: 'FLAT' },
|
||||
{ label: '续重价', value: 'EXTRA' }
|
||||
]
|
||||
const modes = computed(() => {
|
||||
const dict = (order_charge_type.value || []).filter(item => ['PER_KG', 'FLAT', 'EXTRA'].includes(item.value))
|
||||
return dict.length ? dict : fallbackModes
|
||||
})
|
||||
|
||||
const visible = ref(false)
|
||||
const recognizing = ref(false)
|
||||
const saving = ref(false)
|
||||
const overwrite = ref(false)
|
||||
const importMode = ref('template')
|
||||
const chargeType = ref('FLAT')
|
||||
const dictValue = ref('')
|
||||
const preview = ref(null)
|
||||
const selected = ref([])
|
||||
@@ -133,6 +156,11 @@ const skippedText = computed(() => (preview.value?.skippedSheets || []).filter(B
|
||||
let parseSeq = 0
|
||||
let progressTimer = null
|
||||
|
||||
function downloadTemplate() {
|
||||
const hit = modes.value.find(item => item.value === chargeType.value)
|
||||
proxy.download('/price/pay/template', { chargeType: chargeType.value }, `${hit?.label || '价卡'}模板.xlsx`)
|
||||
}
|
||||
|
||||
function open() {
|
||||
reset()
|
||||
visible.value = true
|
||||
@@ -143,6 +171,8 @@ function reset() {
|
||||
preview.value = null
|
||||
selected.value = []
|
||||
overwrite.value = false
|
||||
importMode.value = 'template'
|
||||
chargeType.value = 'FLAT'
|
||||
dictValue.value = ''
|
||||
activeKey.value = ''
|
||||
recognizing.value = false
|
||||
@@ -161,6 +191,10 @@ async function onFile(uploadFile) {
|
||||
proxy.$modal.msgError('请上传xlsx价卡')
|
||||
return
|
||||
}
|
||||
if (importMode.value === 'template' && !chargeType.value) {
|
||||
proxy.$modal.msgError('请先选择计费模式')
|
||||
return
|
||||
}
|
||||
const seq = ++parseSeq
|
||||
const progressId = createProgressId()
|
||||
recognizing.value = true
|
||||
@@ -169,7 +203,9 @@ async function onFile(uploadFile) {
|
||||
parseStatus.value = undefined
|
||||
startProgress(seq, progressId)
|
||||
try {
|
||||
const res = await previewPay(raw, dictValue.value, progressId, event => {
|
||||
const requestPreview = importMode.value === 'template'
|
||||
? previewPayTemplate(raw, chargeType.value)
|
||||
: previewPay(raw, dictValue.value, progressId, event => {
|
||||
if (seq !== parseSeq || !event?.total) return
|
||||
const uploaded = Math.min(8, Math.round(event.loaded * 8 / event.total))
|
||||
if (uploaded > parsePercent.value) {
|
||||
@@ -177,6 +213,7 @@ async function onFile(uploadFile) {
|
||||
parseMessage.value = '正在上传价卡…'
|
||||
}
|
||||
})
|
||||
const res = await requestPreview
|
||||
if (seq !== parseSeq) return
|
||||
parsePercent.value = 100
|
||||
parseMessage.value = '解析完成'
|
||||
|
||||
@@ -1,741 +0,0 @@
|
||||
<template>
|
||||
<el-dialog v-model="visible" title="附加费配置" width="1080px" append-to-body destroy-on-close @closed="reset">
|
||||
<div class="rule-body">
|
||||
<div class="rule-block">
|
||||
<div class="rule-title">绑定产品</div>
|
||||
<div class="rule-products">
|
||||
<el-tag v-for="item in products" :key="item.key" closable class="rule-tag" @close="removeProduct(item)">
|
||||
{{ item.productName }}
|
||||
</el-tag>
|
||||
<span v-if="!products.length" class="rule-empty">还没有产品。勾选列表后打开,或在下面查询后加入。</span>
|
||||
</div>
|
||||
<div class="rule-search">
|
||||
<el-input v-model="keyword" clearable placeholder="按产品名称查询" @keyup.enter="searchProducts" />
|
||||
<el-button type="primary" plain :loading="searching" @click="searchProducts">查询</el-button>
|
||||
</div>
|
||||
<el-table v-if="found.length" :data="found" border size="small" max-height="180" empty-text="没有产品">
|
||||
<el-table-column prop="productName" label="产品名称" min-width="180" show-overflow-tooltip />
|
||||
<el-table-column prop="versionNo" label="版本" width="70" align="center" />
|
||||
<el-table-column label="有效期" min-width="180" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ termText(row) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="80" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-button link type="primary" @click="addProduct(row)">加入</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<p class="rule-hint">配置跟产品走,不跟价格版本。计算时用这个产品当前生效版本上的附加费。</p>
|
||||
</div>
|
||||
|
||||
<div class="rule-block">
|
||||
<div class="rule-title">计费条件</div>
|
||||
<div class="rule-switches">
|
||||
<div v-for="rule in ruleDefs" :key="rule.value" class="rule-switch">
|
||||
<span>{{ rule.label }}</span>
|
||||
<el-switch v-model="enabled[rule.value]" @change="value => toggleRule(rule.value, value)" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-for="rule in openedRules" :key="rule.value" class="rule-block">
|
||||
<div class="rule-bar">
|
||||
<span class="rule-title">{{ rule.label }}</span>
|
||||
<el-button type="primary" link @click="addRow(rule.value)">新增一条</el-button>
|
||||
</div>
|
||||
<p class="rule-hint">{{ rule.hint }}</p>
|
||||
<div v-for="(row, index) in groups[rule.value]" :key="index" class="rule-card">
|
||||
<div class="rule-card-bar">
|
||||
<span>第 {{ index + 1 }} 条</span>
|
||||
<el-button link type="danger" @click="groups[rule.value].splice(index, 1)">删除</el-button>
|
||||
</div>
|
||||
|
||||
<div v-if="rule.value === 'SIZE'" class="rule-grid">
|
||||
<div class="field">
|
||||
<span class="label">命中方式</span>
|
||||
<div class="control">
|
||||
<el-select v-model="row.matchMode" size="small">
|
||||
<el-option label="任一命中" value="ANY" />
|
||||
<el-option label="全部命中" value="ALL" />
|
||||
</el-select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<span class="label">重量前提 kg</span>
|
||||
<div class="control">
|
||||
<el-input v-model="row.weightMin" size="small" placeholder="下限" />
|
||||
<span class="sep">至</span>
|
||||
<el-input v-model="row.weightMax" size="small" placeholder="上限" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<span class="label">最长边 cm</span>
|
||||
<div class="control">
|
||||
<el-input v-model="row.longestMin" size="small" placeholder="下限" />
|
||||
<span class="sep">至</span>
|
||||
<el-input v-model="row.longestMax" size="small" placeholder="上限" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<span class="label">次长边 cm</span>
|
||||
<div class="control">
|
||||
<el-input v-model="row.secondMin" size="small" placeholder="下限" />
|
||||
<span class="sep">至</span>
|
||||
<el-input v-model="row.secondMax" size="small" placeholder="上限" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<span class="label">三边之和 cm</span>
|
||||
<div class="control">
|
||||
<el-input v-model="row.sumMin" size="small" placeholder="下限" />
|
||||
<span class="sep">至</span>
|
||||
<el-input v-model="row.sumMax" size="small" placeholder="上限" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<span class="label">围长 cm</span>
|
||||
<div class="control">
|
||||
<el-input v-model="row.girthMin" size="small" placeholder="下限" />
|
||||
<span class="sep">至</span>
|
||||
<el-input v-model="row.girthMax" size="small" placeholder="上限" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<span class="label">箱规 cm</span>
|
||||
<div class="control">
|
||||
<el-select v-model="row.boxMode" size="small" class="mode">
|
||||
<el-option label="任一边超过" value="OVER" />
|
||||
<el-option label="小于最小尺寸" value="UNDER" />
|
||||
</el-select>
|
||||
<el-input v-model="row.boxLength" class="num" size="small" placeholder="长" />
|
||||
<el-input v-model="row.boxWidth" class="num" size="small" placeholder="宽" />
|
||||
<el-input v-model="row.boxHeight" class="num" size="small" placeholder="高" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<span class="label">体积 m³</span>
|
||||
<div class="control">
|
||||
<el-input v-model="row.volumeMin" size="small" placeholder="下限" />
|
||||
<span class="sep">至</span>
|
||||
<el-input v-model="row.volumeMax" size="small" placeholder="上限" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<span class="label">长×宽×高上限 cm³</span>
|
||||
<div class="control">
|
||||
<el-input v-model="row.cubicMax" size="small" placeholder="例如 432000" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<span class="label">每超出 cm</span>
|
||||
<div class="control">
|
||||
<el-input v-model="row.exceedStepCm" size="small" placeholder="例如 10" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<span class="label">运费加收比例 %</span>
|
||||
<div class="control">
|
||||
<el-input v-model="row.exceedRatio" size="small" placeholder="例如 35" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<span class="label">说明</span>
|
||||
<div class="control">
|
||||
<el-input v-model="row.remark" size="small" placeholder="这一档的补充说明" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else-if="rule.value === 'WEIGHT'" class="rule-grid">
|
||||
<div class="field">
|
||||
<span class="label">重量 kg</span>
|
||||
<div class="control">
|
||||
<el-input v-model="row.weightMin" size="small" placeholder="下限" />
|
||||
<span class="sep">至</span>
|
||||
<el-input v-model="row.weightMax" size="small" placeholder="上限" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<span class="label">重量口径</span>
|
||||
<div class="control">
|
||||
<el-select v-model="row.weightBasis" size="small">
|
||||
<el-option label="实重" value="ACTUAL" />
|
||||
<el-option label="计费重" value="CHARGE" />
|
||||
</el-select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<span class="label">每超出 kg</span>
|
||||
<div class="control">
|
||||
<el-input v-model="row.stepKg" size="small" placeholder="超过上限后按每公斤" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<span class="label">最低消费</span>
|
||||
<div class="control">
|
||||
<el-input v-model="row.minCharge" size="small" placeholder="没有就空着" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<span class="label">运费加收比例 %</span>
|
||||
<div class="control">
|
||||
<el-input v-model="row.exceedRatio" size="small" placeholder="按运费比例加收时填写" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<span class="label">说明</span>
|
||||
<div class="control">
|
||||
<el-input v-model="row.remark" size="small" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else-if="rule.value === 'EXTRA_KG'" class="rule-grid">
|
||||
<div class="field">
|
||||
<span class="label">超过 kg</span>
|
||||
<div class="control">
|
||||
<el-input v-model="row.thresholdKg" size="small" placeholder="超过这个重量后开始续收" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<span class="label">每超出 kg</span>
|
||||
<div class="control">
|
||||
<el-input v-model="row.stepKg" size="small" placeholder="例如 1" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<span class="label">重量口径</span>
|
||||
<div class="control">
|
||||
<el-select v-model="row.weightBasis" size="small">
|
||||
<el-option label="实重" value="ACTUAL" />
|
||||
<el-option label="计费重" value="CHARGE" />
|
||||
</el-select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<span class="label">最低消费</span>
|
||||
<div class="control">
|
||||
<el-input v-model="row.minCharge" size="small" placeholder="例如 17.5" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<span class="label">邮编</span>
|
||||
<div class="control">
|
||||
<el-input v-model="row.postcodes" size="small" type="textarea" :rows="2" placeholder="续收还要限定邮编时填写,支持 KA27-28 这种区间" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else-if="rule.value === 'POSTCODE' || rule.value === 'ZONE'" class="rule-grid">
|
||||
<div class="field">
|
||||
<span class="label">分区</span>
|
||||
<div class="control">
|
||||
<el-select v-model="row.zoneName" filterable size="small" placeholder="选择附加费里的高、中、低区">
|
||||
<el-option v-for="zone in zoneOptions" :key="zone" :label="zone" :value="zone" />
|
||||
</el-select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<span class="label">邮编前缀</span>
|
||||
<div class="control">
|
||||
<el-input v-model="row.postcodes" size="small" type="textarea" :rows="2" placeholder="多个用逗号或换行。前缀、完整邮编、1000-1099、KA27-28 都可以" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<span class="label">国家</span>
|
||||
<div class="control">
|
||||
<el-input v-model="row.country" size="small" placeholder="不填则不限,例如 DE 或 德国" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else-if="rule.value === 'ALWAYS'" class="rule-grid">
|
||||
<div class="field">
|
||||
<span class="label">费用项</span>
|
||||
<div class="control">
|
||||
<el-select v-model="row.feeName" filterable size="small" placeholder="选择这一条要每票收取的费用" @change="(name) => pickFee(row, name)">
|
||||
<el-option v-for="item in feeOptions" :key="item.feeName" :label="item.feeName" :value="item.feeName" />
|
||||
</el-select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<span class="label">计费方式</span>
|
||||
<div class="control">
|
||||
<el-select v-model="row.rateMode" size="small">
|
||||
<el-option label="固定金额" value="FIXED" />
|
||||
<el-option label="按比例" value="RATIO" />
|
||||
</el-select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<span class="label">比例 %</span>
|
||||
<div class="control">
|
||||
<el-input v-model="row.ratio" size="small" placeholder="燃油、战争附加费这类" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<span class="label">计费基数</span>
|
||||
<div class="control">
|
||||
<el-select v-model="row.chargeBase" size="small" clearable placeholder="按比例时选择">
|
||||
<el-option label="处理费" value="HANDLE" />
|
||||
<el-option label="派送费" value="DELIVERY" />
|
||||
<el-option label="运费加附加费" value="FREIGHT_FEE" />
|
||||
</el-select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<span class="label">生效日期</span>
|
||||
<div class="control">
|
||||
<el-date-picker v-model="row.periodStart" type="date" value-format="YYYY-MM-DD" placeholder="开始日期" size="small" clearable />
|
||||
<span class="sep">至</span>
|
||||
<el-date-picker v-model="row.periodEnd" type="date" value-format="YYYY-MM-DD" placeholder="结束日期" size="small" clearable />
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<span class="label">说明</span>
|
||||
<div class="control">
|
||||
<el-input v-model="row.remark" size="small" placeholder="例如每年 11、12 月固定收取" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else class="rule-grid">
|
||||
<div class="field">
|
||||
<span class="label">退回方式</span>
|
||||
<div class="control">
|
||||
<el-select v-model="row.chargeMode" size="small">
|
||||
<el-option label="同正向运费" value="SAME" />
|
||||
<el-option label="空运退回" value="AIR" />
|
||||
<el-option label="陆运退回" value="ROAD" />
|
||||
<el-option label="固定金额" value="FIXED" />
|
||||
</el-select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<span class="label">重量 kg</span>
|
||||
<div class="control">
|
||||
<el-input v-model="row.weightMin" size="small" placeholder="下限" />
|
||||
<span class="sep">至</span>
|
||||
<el-input v-model="row.weightMax" size="small" placeholder="上限" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<span class="label">尺寸命中</span>
|
||||
<div class="control">
|
||||
<el-select v-model="row.matchMode" size="small" clearable placeholder="退件还看尺寸时选择">
|
||||
<el-option label="任一命中" value="ANY" />
|
||||
<el-option label="全部命中" value="ALL" />
|
||||
</el-select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<span class="label">最长边 cm</span>
|
||||
<div class="control">
|
||||
<el-input v-model="row.longestMin" size="small" placeholder="下限" />
|
||||
<span class="sep">至</span>
|
||||
<el-input v-model="row.longestMax" size="small" placeholder="上限" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<span class="label">围长 cm</span>
|
||||
<div class="control">
|
||||
<el-input v-model="row.girthMin" size="small" placeholder="下限" />
|
||||
<span class="sep">至</span>
|
||||
<el-input v-model="row.girthMax" size="small" placeholder="上限" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<span class="label">三边之和 cm</span>
|
||||
<div class="control">
|
||||
<el-input v-model="row.sumMin" size="small" placeholder="下限" />
|
||||
<span class="sep">至</span>
|
||||
<el-input v-model="row.sumMax" size="small" placeholder="上限" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<span class="label">说明</span>
|
||||
<div class="control">
|
||||
<el-input v-model="row.remark" size="small" placeholder="例如拒收、地址错误退回" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<template #footer>
|
||||
<el-button @click="visible = false">取消</el-button>
|
||||
<el-button type="primary" :loading="saving" @click="save">保存</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { getPay, listPay, listPaySurchargeRule, savePaySurchargeRule } from '@/api/price/pay'
|
||||
|
||||
const { proxy } = getCurrentInstance()
|
||||
|
||||
const ruleDefs = [
|
||||
{
|
||||
value: 'SIZE',
|
||||
label: '超尺寸',
|
||||
hint: '按报价里的每一档填写。只写最长边>120 就只填下限;100<最长边≤200 则下限、上限都填。围长是长+2×(宽+高)。任一命中对应「或 / 任一边超过」,全部命中对应「且 / 同时满足」。运费另加 35%、70% 填加收比例,每超出 10cm 填超出步长。'
|
||||
},
|
||||
{
|
||||
value: 'WEIGHT',
|
||||
label: '超重',
|
||||
hint: '30<W≤70 填下限 30、上限 70;只写超过 30KG 就只填下限。超过 300kg 后每公斤续收的,填每超出。报价写明按实际重量、不按体积重时,口径选实重。'
|
||||
},
|
||||
{
|
||||
value: 'EXTRA_KG',
|
||||
label: '超重续收',
|
||||
hint: '超过某个重量后只收超出部分。偏远按公斤且有最低消费的,把邮编和最低消费写在这一条。'
|
||||
},
|
||||
{
|
||||
value: 'POSTCODE',
|
||||
label: '命中邮编',
|
||||
hint: '按附加费里的高、中、低区填写邮编前缀。订单邮编命中这一区,才加这一区的附加费。前缀、完整邮编和区间都认。国家不填则不限目的国。'
|
||||
},
|
||||
{
|
||||
value: 'ZONE',
|
||||
label: '命中分区',
|
||||
hint: '写法和命中邮编一样,表示这些邮编属于哪个地区。命中后按该地区的附加费收取。运费用的地区仍按应付邮编配置。'
|
||||
},
|
||||
{
|
||||
value: 'ALWAYS',
|
||||
label: '每票都收',
|
||||
hint: '每一条都要选费用项,没被选中的费用不会按每票收取。燃油、去碳按比例填写比例和基数,旺季再填生效日期。'
|
||||
},
|
||||
{
|
||||
value: 'RETURN',
|
||||
label: '退件',
|
||||
hint: '同正向运费、空运或陆运分开配。超尺寸或超重才退件的,把重量和最长边、围长写在同一条。'
|
||||
}
|
||||
]
|
||||
|
||||
const visible = ref(false)
|
||||
const saving = ref(false)
|
||||
const searching = ref(false)
|
||||
const keyword = ref('')
|
||||
const found = ref([])
|
||||
const products = ref([])
|
||||
const feeOptions = ref([])
|
||||
const feeCounts = ref({})
|
||||
const zoneOptions = ref([])
|
||||
const enabled = reactive({})
|
||||
const groups = reactive({})
|
||||
|
||||
function blank(rule) {
|
||||
if (rule === 'SIZE') {
|
||||
return { matchMode: 'ANY', boxMode: 'OVER', weightMin: '', weightMax: '', longestMin: '', longestMax: '', secondMin: '', secondMax: '', sumMin: '', sumMax: '', girthMin: '', girthMax: '', boxLength: '', boxWidth: '', boxHeight: '', volumeMin: '', volumeMax: '', cubicMax: '', exceedStepCm: '', exceedRatio: '', remark: '' }
|
||||
}
|
||||
if (rule === 'WEIGHT') {
|
||||
return { weightMin: '', weightMax: '', weightBasis: 'ACTUAL', stepKg: '', minCharge: '', exceedRatio: '', remark: '' }
|
||||
}
|
||||
if (rule === 'EXTRA_KG') {
|
||||
return { thresholdKg: '', stepKg: '1', weightBasis: 'ACTUAL', minCharge: '', postcodes: '' }
|
||||
}
|
||||
if (rule === 'POSTCODE' || rule === 'ZONE') {
|
||||
return { zoneName: '', postcodes: '', country: '' }
|
||||
}
|
||||
if (rule === 'ALWAYS') {
|
||||
return { feeName: '', scId: '', rateMode: 'FIXED', ratio: '', chargeBase: '', periodStart: '', periodEnd: '', remark: '' }
|
||||
}
|
||||
return { chargeMode: 'SAME', weightMin: '', weightMax: '', matchMode: '', longestMin: '', longestMax: '', girthMin: '', girthMax: '', sumMin: '', sumMax: '', remark: '' }
|
||||
}
|
||||
|
||||
function blankGroups() {
|
||||
for (const rule of ruleDefs) {
|
||||
enabled[rule.value] = false
|
||||
groups[rule.value] = []
|
||||
}
|
||||
}
|
||||
|
||||
function reset() {
|
||||
keyword.value = ''
|
||||
found.value = []
|
||||
products.value = []
|
||||
feeOptions.value = []
|
||||
feeCounts.value = {}
|
||||
zoneOptions.value = []
|
||||
blankGroups()
|
||||
saving.value = false
|
||||
searching.value = false
|
||||
}
|
||||
|
||||
function open(rows) {
|
||||
reset()
|
||||
visible.value = true
|
||||
const skipped = []
|
||||
for (const row of rows || []) addProduct(row, skipped)
|
||||
if (skipped.length) proxy.$modal.msgWarning('有产品还没有生效版本,未带入:' + skipped.join('、'))
|
||||
const first = products.value[0]
|
||||
if (first) loadRules(first.productId)
|
||||
}
|
||||
|
||||
function versionOf(row) {
|
||||
return {
|
||||
key: String(row.productId),
|
||||
productId: row.productId,
|
||||
feeProductId: row.versionProductId || row.productId,
|
||||
productName: row.productName || '未命名产品'
|
||||
}
|
||||
}
|
||||
|
||||
function addProduct(row, skipped) {
|
||||
const item = versionOf(row)
|
||||
if (!item.productId) {
|
||||
if (skipped) skipped.push(item.productName)
|
||||
else proxy.$modal.msgWarning(item.productName + '不能绑定')
|
||||
return
|
||||
}
|
||||
if (products.value.some(product => product.key === item.key)) return
|
||||
products.value.push(item)
|
||||
loadFees()
|
||||
}
|
||||
|
||||
function removeProduct(item) {
|
||||
products.value = products.value.filter(product => product.key !== item.key)
|
||||
loadFees()
|
||||
}
|
||||
|
||||
let feeToken = 0
|
||||
|
||||
function loadFees() {
|
||||
const token = ++feeToken
|
||||
const bound = products.value.slice()
|
||||
if (!bound.length) {
|
||||
feeOptions.value = []
|
||||
feeCounts.value = {}
|
||||
zoneOptions.value = keepZones([])
|
||||
return Promise.resolve()
|
||||
}
|
||||
return Promise.all(bound.map(item => getPay(item.feeProductId || item.productId).catch(() => null))).then(results => {
|
||||
if (token !== feeToken) return
|
||||
const map = new Map()
|
||||
const counts = {}
|
||||
const zones = new Set()
|
||||
results.forEach(res => {
|
||||
const local = {}
|
||||
const rows = res?.data?.surcharges || []
|
||||
rows.forEach(fee => {
|
||||
const name = String(fee.feeName || '').trim()
|
||||
const zone = String(fee.zoneName || '').trim()
|
||||
if (zone) zones.add(zone)
|
||||
if (!name) return
|
||||
local[name] = (local[name] || 0) + 1
|
||||
if (!map.has(name)) map.set(name, { feeName: name, scId: fee.scId || '' })
|
||||
})
|
||||
Object.keys(local).forEach(name => {
|
||||
counts[name] = Math.max(counts[name] || 0, local[name])
|
||||
})
|
||||
})
|
||||
zoneOptions.value = keepZones([...zones])
|
||||
feeCounts.value = counts
|
||||
for (const row of groups.ALWAYS || []) {
|
||||
const name = String(row.feeName || '').trim()
|
||||
if (name && !map.has(name)) map.set(name, { feeName: name, scId: row.scId || '' })
|
||||
}
|
||||
feeOptions.value = [...map.values()]
|
||||
})
|
||||
}
|
||||
|
||||
function keepZones(zones) {
|
||||
const set = new Set(zones)
|
||||
for (const rule of ['POSTCODE', 'ZONE']) {
|
||||
for (const row of groups[rule] || []) {
|
||||
const zone = String(row.zoneName || '').trim()
|
||||
if (zone) set.add(zone)
|
||||
}
|
||||
}
|
||||
return [...set]
|
||||
}
|
||||
|
||||
function pickFee(row, name) {
|
||||
const found = feeOptions.value.find(item => item.feeName === name)
|
||||
row.scId = found?.scId || ''
|
||||
}
|
||||
|
||||
function termText(row) {
|
||||
const start = row.termStart || row.effectiveStart || ''
|
||||
const end = row.termEnd || row.effectiveEnd || ''
|
||||
if (!start && !end) return '-'
|
||||
return (String(start).slice(0, 10) || '不限') + ' 至 ' + (String(end).slice(0, 10) || '不限')
|
||||
}
|
||||
|
||||
function searchProducts() {
|
||||
searching.value = true
|
||||
listPay({ productName: keyword.value.trim(), templateOnly: true, currentOnly: true, pageNum: 1, pageSize: 20 }).then(res => {
|
||||
found.value = res.rows || []
|
||||
}).finally(() => {
|
||||
searching.value = false
|
||||
})
|
||||
}
|
||||
|
||||
function toggleRule(rule, value) {
|
||||
const def = ruleDefs.find(item => item.value === rule)
|
||||
if (def?.switchOnly) return
|
||||
if (value && !groups[rule].length) groups[rule].push(blank(rule))
|
||||
}
|
||||
|
||||
function addRow(rule) {
|
||||
groups[rule].push(blank(rule))
|
||||
}
|
||||
|
||||
function applyRules(list) {
|
||||
blankGroups()
|
||||
for (const item of list || []) {
|
||||
const rule = item.calcRule
|
||||
if (!groups[rule]) continue
|
||||
enabled[rule] = item.enabled !== '0'
|
||||
if (ruleDefs.find(def => def.value === rule)?.switchOnly) continue
|
||||
if (item.enabled === '0') continue
|
||||
const row = blank(rule)
|
||||
const detail = item.detail || {}
|
||||
Object.keys(row).forEach(key => {
|
||||
if (detail[key] === undefined || detail[key] === null) return
|
||||
row[key] = key === 'periodStart' || key === 'periodEnd' ? asDate(detail[key]) : String(detail[key])
|
||||
})
|
||||
groups[rule].push(row)
|
||||
}
|
||||
for (const rule of ruleDefs) {
|
||||
if (rule.switchOnly) continue
|
||||
if (enabled[rule.value] && !groups[rule.value].length) groups[rule.value].push(blank(rule.value))
|
||||
}
|
||||
const map = new Map(feeOptions.value.map(item => [item.feeName, item]))
|
||||
for (const row of groups.ALWAYS || []) {
|
||||
const name = String(row.feeName || '').trim()
|
||||
if (name && !map.has(name)) map.set(name, { feeName: name, scId: row.scId || '' })
|
||||
}
|
||||
feeOptions.value = [...map.values()]
|
||||
zoneOptions.value = keepZones(zoneOptions.value)
|
||||
}
|
||||
|
||||
function asDate(value) {
|
||||
const text = String(value).trim()
|
||||
if (/^\d{4}-\d{2}-\d{2}/.test(text)) return text.slice(0, 10)
|
||||
const monthDay = text.match(/^(\d{1,2})-(\d{1,2})$/)
|
||||
if (!monthDay) return ''
|
||||
const year = new Date().getFullYear()
|
||||
return `${year}-${monthDay[1].padStart(2, '0')}-${monthDay[2].padStart(2, '0')}`
|
||||
}
|
||||
|
||||
function loadRules(productId) {
|
||||
listPaySurchargeRule(productId).then(res => applyRules(res.data || []))
|
||||
}
|
||||
|
||||
const openedRules = computed(() => ruleDefs.filter(rule => enabled[rule.value] && !rule.switchOnly))
|
||||
|
||||
function detailOf(rule, row) {
|
||||
const detail = {}
|
||||
const template = blank(rule)
|
||||
Object.keys(template).forEach(key => {
|
||||
const value = row[key]
|
||||
if (value === '' || value === null || value === undefined) return
|
||||
detail[key] = value
|
||||
})
|
||||
return detail
|
||||
}
|
||||
|
||||
function payloadRules() {
|
||||
const rules = []
|
||||
for (const rule of ruleDefs) {
|
||||
if (!enabled[rule.value]) continue
|
||||
if (rule.switchOnly) {
|
||||
rules.push({ calcRule: rule.value, enabled: '1', detail: {} })
|
||||
continue
|
||||
}
|
||||
const rows = groups[rule.value].length ? groups[rule.value] : [blank(rule.value)]
|
||||
rows.forEach(row => {
|
||||
rules.push({ calcRule: rule.value, enabled: '1', detail: detailOf(rule.value, row) })
|
||||
})
|
||||
}
|
||||
return rules
|
||||
}
|
||||
|
||||
function save() {
|
||||
if (!products.value.length) {
|
||||
proxy.$modal.msgError('请选择要绑定的产品')
|
||||
return
|
||||
}
|
||||
for (const rule of ['POSTCODE', 'ZONE']) {
|
||||
if (!enabled[rule]) continue
|
||||
const label = rule === 'POSTCODE' ? '命中邮编' : '命中分区'
|
||||
for (const row of groups[rule]) {
|
||||
if (!String(row.zoneName || '').trim() || !String(row.postcodes || '').trim()) {
|
||||
proxy.$modal.msgError(label + '要选择分区,并填写邮编前缀')
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
if (enabled.ALWAYS) {
|
||||
for (const row of groups.ALWAYS) {
|
||||
if (!String(row.feeName || '').trim()) {
|
||||
proxy.$modal.msgError('每票都收要选择费用项')
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
saving.value = true
|
||||
loadFees().then(() => {
|
||||
const duplicated = sameTypeFees()
|
||||
if (duplicated.length) {
|
||||
proxy.$modal.alert('存在两笔同类型的附加费:' + duplicated.join('、'))
|
||||
return
|
||||
}
|
||||
return savePaySurchargeRule({
|
||||
products: products.value.map(item => ({
|
||||
productId: item.productId,
|
||||
productName: item.productName
|
||||
})),
|
||||
rules: payloadRules()
|
||||
}).then(() => {
|
||||
proxy.$modal.msgSuccess('已保存,计算时按当前生效版本上的附加费执行')
|
||||
visible.value = false
|
||||
})
|
||||
}).finally(() => {
|
||||
saving.value = false
|
||||
})
|
||||
}
|
||||
|
||||
function sameTypeFees() {
|
||||
if (!enabled.ALWAYS) return []
|
||||
const seen = new Set()
|
||||
const duplicated = []
|
||||
for (const row of groups.ALWAYS) {
|
||||
const name = String(row.feeName || '').trim()
|
||||
if (!name) continue
|
||||
if (seen.has(name) || Number(feeCounts.value[name] || 0) >= 2) duplicated.push(name)
|
||||
seen.add(name)
|
||||
}
|
||||
return [...new Set(duplicated)]
|
||||
}
|
||||
|
||||
defineExpose({ open })
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.rule-body { max-height: 68vh; overflow: auto; padding-right: 4px; }
|
||||
.rule-block { margin-bottom: 16px; }
|
||||
.rule-title { font-weight: 600; }
|
||||
.rule-products { display: flex; flex-wrap: wrap; gap: 8px; min-height: 32px; margin: 8px 0; }
|
||||
.rule-tag { margin: 0; }
|
||||
.rule-empty { color: var(--el-text-color-secondary); font-size: 13px; }
|
||||
.rule-search { display: flex; gap: 8px; margin-bottom: 8px; }
|
||||
.rule-hint { margin: 6px 0 8px; color: var(--el-text-color-secondary); font-size: 12px; line-height: 1.5; }
|
||||
.rule-switches { display: flex; flex-wrap: wrap; gap: 12px 20px; margin-top: 8px; }
|
||||
.rule-switch { display: flex; align-items: center; gap: 8px; }
|
||||
.rule-bar, .rule-card-bar { display: flex; align-items: center; justify-content: space-between; }
|
||||
.rule-card { border: 1px solid var(--el-border-color); border-radius: 6px; padding: 12px 20px 12px 28px; margin-bottom: 10px; overflow: visible; }
|
||||
.rule-grid { display: grid; grid-template-columns: 1fr 1fr; column-gap: 48px; row-gap: 12px; align-items: center; }
|
||||
.field { display: grid; grid-template-columns: 104px minmax(0, 1fr); column-gap: 8px; align-items: center; min-width: 0; }
|
||||
.field .label { width: 104px; min-width: 0; justify-self: end; text-align: right; white-space: nowrap; overflow: visible; font-size: 13px; line-height: 24px; color: var(--el-text-color-regular); }
|
||||
.control { display: flex; align-items: center; gap: 6px; min-width: 0; }
|
||||
.control :deep(.el-input),
|
||||
.control :deep(.el-select),
|
||||
.control :deep(.el-textarea),
|
||||
.control :deep(.el-date-editor) { flex: 1 1 0; width: 0 !important; min-width: 0; max-width: none; }
|
||||
.control :deep(.mode) { flex: 1.7 1 0; }
|
||||
.control :deep(.num) { flex: 0.75 1 0; }
|
||||
.field .sep { flex: none; color: var(--el-text-color-secondary); line-height: 24px; }
|
||||
</style>
|
||||
@@ -14,6 +14,9 @@
|
||||
<el-col :span="1.5">
|
||||
<el-button type="primary" plain icon="Link" :disabled="selection.length !== 1" @click="openBind(selection)" v-hasPermi="['price:pay:bind']">绑定渠道</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="primary" plain icon="Plus" @click="createRef.open()" v-hasPermi="['price:pay:add']">新增价卡</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="primary" plain icon="Upload" @click="importRef.open()" v-hasPermi="['price:pay:import']">导入价卡</el-button>
|
||||
</el-col>
|
||||
@@ -26,9 +29,10 @@
|
||||
<el-col :span="1.5">
|
||||
<el-button type="warning" plain icon="Download" @click="handleExportDetail" v-hasPermi="['price:pay:export']">导出明细</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="primary" plain icon="Setting" @click="openRule(selection)" v-hasPermi="['price:pay:edit']">附加费配置</el-button>
|
||||
</el-col>
|
||||
</template>
|
||||
|
||||
<template #col-chargeType="{ row }">
|
||||
<span>{{ chargeTypeText(row.chargeType) }}</span>
|
||||
</template>
|
||||
|
||||
<template #col-sourceFile="{ row }">
|
||||
@@ -67,6 +71,7 @@
|
||||
</basic-table>
|
||||
|
||||
<pay-import-dialog ref="importRef" @saved="tableRef.refresh()" />
|
||||
<pay-create-dialog ref="createRef" @saved="tableRef.refresh()" />
|
||||
<el-dialog v-model="bindVisible" title="绑定渠道" width="640px" append-to-body @closed="resetBind">
|
||||
<el-form label-width="70px">
|
||||
<el-form-item label="产品">
|
||||
@@ -93,8 +98,6 @@
|
||||
<el-button type="primary" :loading="bindSaving" @click="submitBind">确认</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
<pay-surcharge-rule-dialog ref="ruleRef" />
|
||||
|
||||
<el-drawer v-model="historyVisible" :title="historyTitle" size="980px" append-to-body destroy-on-close>
|
||||
<div class="history-bar">
|
||||
<el-button type="primary" plain :disabled="historyPicked.length !== 2" @click="openCompare">比对所选版本</el-button>
|
||||
@@ -120,31 +123,12 @@
|
||||
<el-table-column label="操作" width="220" align="center">
|
||||
<template #default="{ row }">
|
||||
<el-button link type="primary" @click="downloadSource(row)" v-hasPermi="['price:pay:query']">下载</el-button>
|
||||
<el-button link type="primary" @click="openRuleLog(row)" v-hasPermi="['price:pay:query']">附加费记录</el-button>
|
||||
<el-button link type="primary" @click="openDetail(row)" v-hasPermi="['price:pay:query']">查看</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-drawer>
|
||||
|
||||
<el-dialog v-model="ruleLogVisible" :title="ruleLogTitle" width="860px" append-to-body>
|
||||
<el-table v-loading="ruleLogLoading" :data="ruleLogRows" border size="small" empty-text="这一版还没有附加费配置记录">
|
||||
<el-table-column label="操作" width="70" align="center">
|
||||
<template #default="{ row }">{{ ruleLogAction(row.operationType) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="更改前" min-width="220" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ ruleLogSide(row, 'before') }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="更改后" min-width="220" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ ruleLogSide(row, 'after') }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="createBy" label="操作人" width="100" align="center" />
|
||||
<el-table-column label="操作时间" width="160" align="center">
|
||||
<template #default="{ row }">{{ row.createTime || '-' }}</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog v-model="termVisible" title="修改有效期" width="460px" append-to-body>
|
||||
<el-form label-width="90px">
|
||||
<el-form-item label="生效开始" required>
|
||||
@@ -221,16 +205,18 @@
|
||||
</template>
|
||||
|
||||
<script setup name="PricePay">
|
||||
import { listPay, getPay, delPay, updatePay, listPayTerm, updatePayTerm, changePayTermStatus, comparePay, listPaySurchargeRuleLog, batchBindChannelPay } from '@/api/price/pay'
|
||||
import { listPay, getPay, delPay, updatePay, listPayTerm, updatePayTerm, changePayTermStatus, comparePay, batchBindChannelPay } from '@/api/price/pay'
|
||||
import { listChannelOptions } from '@/api/masterdata/serviceChannel'
|
||||
import { useDict } from '@/utils/dict'
|
||||
import PayImportDialog from './components/PayImportDialog.vue'
|
||||
import PayCreateDialog from './components/PayCreateDialog.vue'
|
||||
import PayConfigDetail from './components/PayConfigDetail.vue'
|
||||
import PaySurchargeRuleDialog from './components/PaySurchargeRuleDialog.vue'
|
||||
|
||||
const { proxy } = getCurrentInstance()
|
||||
const { order_charge_type } = useDict('order_charge_type')
|
||||
const tableRef = ref()
|
||||
const importRef = ref()
|
||||
const ruleRef = ref()
|
||||
const createRef = ref()
|
||||
const detailVisible = ref(false)
|
||||
const detailLoading = ref(false)
|
||||
const savingRowKey = ref('')
|
||||
@@ -241,10 +227,6 @@ const historyRows = ref([])
|
||||
const historyTitle = ref('价格版本')
|
||||
const historyProductId = ref(null)
|
||||
const historyPicked = ref([])
|
||||
const ruleLogVisible = ref(false)
|
||||
const ruleLogLoading = ref(false)
|
||||
const ruleLogRows = ref([])
|
||||
const ruleLogTitle = ref('附加费配置记录')
|
||||
const compareVisible = ref(false)
|
||||
const compareLoading = ref(false)
|
||||
const compareTitle = ref('版本比对')
|
||||
@@ -275,7 +257,7 @@ const statusOptions = [
|
||||
]
|
||||
|
||||
const columns = [
|
||||
{ label: '服务商渠道名称', prop: 'productName', align: 'center', minWidth: 180, showOverflowTooltip: true, fixed: 'left' },
|
||||
{ label: '应付价卡名称', prop: 'productName', align: 'center', minWidth: 180, showOverflowTooltip: true, fixed: 'left' },
|
||||
{ label: '价卡归属', prop: 'supplierName', align: 'center', width: 100 },
|
||||
{ label: '国家/口岸', prop: 'countryScope', align: 'center', minWidth: 120, showOverflowTooltip: true },
|
||||
{ label: '费用类型', prop: 'chargeType', align: 'center', width: 110 },
|
||||
@@ -295,7 +277,7 @@ const columns = [
|
||||
]
|
||||
|
||||
const searchColumns = [
|
||||
{ label: '服务商渠道名称', prop: 'productName', component: 'input', placeholder: '产品名称', width: '180px' },
|
||||
{ label: '应付价卡名称', prop: 'productName', component: 'input', placeholder: '产品名称', width: '180px' },
|
||||
{ label: '价卡归属', prop: 'supplierName', component: 'input', placeholder: '威狮、易德、GWE', width: '160px' },
|
||||
{ label: '来源文件', prop: 'sourceFile', component: 'input', placeholder: '文件名', width: '180px' },
|
||||
{ label: '报价工作表', prop: 'sheetName', component: 'input', placeholder: '工作表', width: '160px' },
|
||||
@@ -361,8 +343,13 @@ function handleDelete(ids) {
|
||||
}).catch(() => {})
|
||||
}
|
||||
|
||||
function openRule(selection) {
|
||||
ruleRef.value?.open(selection || [])
|
||||
function chargeTypeText(value) {
|
||||
const hit = (order_charge_type.value || []).find(item => item.value === value)
|
||||
if (hit) return hit.label
|
||||
if (value === 'PER_KG') return '常规计费'
|
||||
if (value === 'FLAT') return '一口价'
|
||||
if (value === 'EXTRA') return '续重价'
|
||||
return value || '-'
|
||||
}
|
||||
|
||||
function channelLabel(item) {
|
||||
@@ -397,7 +384,7 @@ function resetBind() {
|
||||
|
||||
function submitBind() {
|
||||
if (!bindForm.productId) {
|
||||
proxy.$modal.msgWarning('请选择一个产品')
|
||||
proxy.$modal.msgWarning('请选择一个应付价卡')
|
||||
return
|
||||
}
|
||||
if (!bindForm.channelIds.length) {
|
||||
@@ -476,40 +463,6 @@ function termText(row) {
|
||||
return `${start || '不限'} 至 ${end || '不限'}`
|
||||
}
|
||||
|
||||
function openRuleLog(row) {
|
||||
ruleLogTitle.value = `${row.productName || '产品'} 第 ${row.versionNo || '-'} 版的附加费配置记录`
|
||||
ruleLogRows.value = []
|
||||
ruleLogVisible.value = true
|
||||
ruleLogLoading.value = true
|
||||
listPaySurchargeRuleLog(row.productId, row.termId).then(res => {
|
||||
ruleLogRows.value = res.data || []
|
||||
}).finally(() => {
|
||||
ruleLogLoading.value = false
|
||||
})
|
||||
}
|
||||
|
||||
function ruleLogAction(type) {
|
||||
if (type === '1') return '新增'
|
||||
if (type === '2') return '修改'
|
||||
if (type === '3') return '删除'
|
||||
return '-'
|
||||
}
|
||||
|
||||
function ruleLogSide(row, side) {
|
||||
let content = row.changeContent
|
||||
if (typeof content === 'string') {
|
||||
try {
|
||||
content = JSON.parse(content)
|
||||
} catch (error) {
|
||||
return side === 'after' ? content : '-'
|
||||
}
|
||||
}
|
||||
const values = content?.[side]
|
||||
if (!values || typeof values !== 'object') return '-'
|
||||
const text = Object.entries(values).map(([label, value]) => `${label}:${value}`).join(';')
|
||||
return text || '-'
|
||||
}
|
||||
|
||||
function openHistory(row) {
|
||||
historyProductId.value = row.productId
|
||||
historyTitle.value = `${row.productName || '产品'}的价格版本`
|
||||
|
||||
@@ -158,7 +158,7 @@
|
||||
</el-table-column>
|
||||
<el-table-column label="金额" min-width="120" align="right">
|
||||
<template #default="{ row }">
|
||||
<span class="fee-amount">{{ formatMoney(row.amount) }}</span>
|
||||
<span class="fee-amount">{{ formatFeeAmount(row.amount) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="币种" width="90" align="center">
|
||||
@@ -342,6 +342,13 @@ function formatMoney(val) {
|
||||
return num.toFixed(2)
|
||||
}
|
||||
|
||||
function formatFeeAmount(val) {
|
||||
if (val === null || val === undefined || val === '') return '-'
|
||||
const num = Number(val)
|
||||
if (Number.isNaN(num)) return val
|
||||
return num.toFixed(3)
|
||||
}
|
||||
|
||||
function formatWeight(val) {
|
||||
if (val === null || val === undefined || val === '') return '-'
|
||||
const num = Number(val)
|
||||
|
||||
@@ -44,7 +44,9 @@
|
||||
<el-table-column prop="countryName" label="目的国" width="110" show-overflow-tooltip />
|
||||
<el-table-column prop="channelName" label="渠道" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column prop="chargeWeight" label="计费重" width="90" align="right" />
|
||||
<el-table-column prop="payTotal" label="应付总额" width="110" align="right" />
|
||||
<el-table-column prop="payTotal" label="应付总额" width="110" align="right">
|
||||
<template #default="{ row }">{{ money2(row.payTotal) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="currency" label="币种" width="80" align="center" />
|
||||
<el-table-column label="计费状态" width="100" align="center">
|
||||
<template #default="{ row }">
|
||||
@@ -92,8 +94,8 @@
|
||||
</el-table-column>
|
||||
<el-table-column label="金额" min-width="1" header-align="center" align="right" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
<el-input-number v-if="row.editing" v-model="row.amount" :precision="2" :controls="false" />
|
||||
<span v-else>{{ row.amount }}</span>
|
||||
<el-input-number v-if="row.editing" v-model="row.amount" :precision="3" :controls="false" />
|
||||
<span v-else>{{ money3(row.amount) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="币种" min-width="1" header-align="center" align="center" show-overflow-tooltip>
|
||||
@@ -113,7 +115,9 @@
|
||||
<el-table-column label="来源" min-width="1" header-align="center" align="center" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ sourceText(row.feeSource) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="createBy" label="创建人" min-width="1" header-align="center" show-overflow-tooltip />
|
||||
<el-table-column label="创建人" min-width="1" header-align="center" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ row.createBy || '-' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="createTime" label="创建时间" min-width="1" header-align="center" show-overflow-tooltip />
|
||||
<el-table-column prop="updateBy" label="更新人" min-width="1" header-align="center" show-overflow-tooltip />
|
||||
<el-table-column prop="updateTime" label="更新时间" min-width="1" header-align="center" show-overflow-tooltip />
|
||||
@@ -241,8 +245,7 @@
|
||||
</template>
|
||||
|
||||
<script setup name="PayOrderList">
|
||||
import { getBill } from '@/api/price/billing'
|
||||
import { addPayOrderFee, cancelPayOrderRecalc, getPayOrderRecalcTask, listPayOrder, listPayOrderFeeLogs, listPayOrderFees, pollPayOrderRecalc, removePayOrderFee, submitPayOrderRecalc } from '@/api/price/payOrder'
|
||||
import { addPayOrderFee, cancelPayOrderRecalc, getPayOrder, getPayOrderRecalcTask, listPayOrder, listPayOrderFeeLogs, listPayOrderFees, pollPayOrderRecalc, removePayOrderFee, submitPayOrderRecalc } from '@/api/price/payOrder'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import BillDetail from '../components/BillDetail.vue'
|
||||
|
||||
@@ -319,6 +322,18 @@ const sources = {
|
||||
MANUAL: '手工'
|
||||
}
|
||||
|
||||
function money2(value) {
|
||||
if (value === null || value === undefined || value === '') return '-'
|
||||
const num = Number(value)
|
||||
return Number.isNaN(num) ? value : num.toFixed(2)
|
||||
}
|
||||
|
||||
function money3(value) {
|
||||
if (value === null || value === undefined || value === '') return '-'
|
||||
const num = Number(value)
|
||||
return Number.isNaN(num) ? value : num.toFixed(3)
|
||||
}
|
||||
|
||||
function sourceText(value) {
|
||||
return sources[value] || value || '-'
|
||||
}
|
||||
@@ -381,7 +396,7 @@ function openDetail(row) {
|
||||
detail.value = null
|
||||
detailOpen.value = true
|
||||
detailLoading.value = true
|
||||
getBill(row.billId).then(res => {
|
||||
getPayOrder(row.billId).then(res => {
|
||||
detail.value = res.data || null
|
||||
}).finally(() => {
|
||||
detailLoading.value = false
|
||||
|
||||
Reference in New Issue
Block a user