This commit is contained in:
wuweihua
2026-11-17 10:16:42 +08:00
76 changed files with 4918 additions and 451 deletions
@@ -1,7 +1,7 @@
<template>
<div v-if="panes.length" class="pay-detail">
<section v-for="pane in panes" :key="pane.key" class="pay-product">
<div class="pay-product-title">{{ pane.item.productName || '未命名产品' }}</div>
<div class="pay-product-title">{{ pane.item.productName || '未命名服务商渠道' }}</div>
<el-descriptions :column="3" border size="small" class="pay-summary">
<el-descriptions-item label="价卡归属">{{ pane.item.supplierName || '-' }}</el-descriptions-item>
<el-descriptions-item label="生效日期">{{ pane.item.effectiveDate || '-' }}</el-descriptions-item>
+94 -3
View File
@@ -11,6 +11,9 @@
scrollbar-always-on
>
<template #toolbar="{ selection, ids }">
<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="Upload" @click="importRef.open()" v-hasPermi="['price:pay:import']">导入价卡</el-button>
</el-col>
@@ -64,6 +67,32 @@
</basic-table>
<pay-import-dialog ref="importRef" @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="产品">
<el-select v-model="bindForm.productId" disabled style="width: 100%">
<el-option :label="bindForm.productName" :value="bindForm.productId" />
</el-select>
</el-form-item>
<el-form-item label="渠道">
<el-select
v-model="bindForm.channelIds"
class="bind-channel-select"
multiple
filterable
clearable
placeholder="输入渠道编码或名称搜索,勾选后显示在框内"
style="width: 100%"
>
<el-option v-for="item in channelOptions" :key="item.id" :label="channelLabel(item)" :value="item.id" />
</el-select>
</el-form-item>
</el-form>
<template #footer>
<el-button @click="bindVisible = false">取消</el-button>
<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>
@@ -192,7 +221,8 @@
</template>
<script setup name="PricePay">
import { listPay, getPay, delPay, updatePay, listPayTerm, updatePayTerm, changePayTermStatus, comparePay, listPaySurchargeRuleLog } from '@/api/price/pay'
import { listPay, getPay, delPay, updatePay, listPayTerm, updatePayTerm, changePayTermStatus, comparePay, listPaySurchargeRuleLog, batchBindChannelPay } from '@/api/price/pay'
import { listChannelOptions } from '@/api/masterdata/serviceChannel'
import PayImportDialog from './components/PayImportDialog.vue'
import PayConfigDetail from './components/PayConfigDetail.vue'
import PaySurchargeRuleDialog from './components/PaySurchargeRuleDialog.vue'
@@ -233,6 +263,10 @@ const detailTitle = computed(() => {
const termVisible = ref(false)
const termSaving = ref(false)
const termForm = reactive({ termId: null, productId: null, effectiveStart: '', effectiveEnd: '' })
const bindVisible = ref(false)
const bindSaving = ref(false)
const channelOptions = ref([])
const bindForm = reactive({ productId: null, productName: '', channelIds: [] })
const statusOptions = [
{ label: '已识别', value: 'OK' },
@@ -241,7 +275,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 },
@@ -261,7 +295,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' },
@@ -331,6 +365,57 @@ function openRule(selection) {
ruleRef.value?.open(selection || [])
}
function channelLabel(item) {
const code = item?.channelCode || ''
const name = item?.channelName || ''
return [code, name].filter(Boolean).join(' ')
}
function openBind(selection) {
if (!selection || selection.length !== 1) return
const row = selection[0]
if (!row?.productId) {
proxy.$modal.msgWarning('这个产品没有编号,不能绑定渠道')
return
}
bindForm.productId = row.productId
bindForm.productName = row.productName || ''
bindForm.channelIds = []
bindVisible.value = true
if (!channelOptions.value.length) {
listChannelOptions().then(res => {
channelOptions.value = res.data || []
})
}
}
function resetBind() {
bindForm.productId = null
bindForm.productName = ''
bindForm.channelIds = []
}
function submitBind() {
if (!bindForm.productId) {
proxy.$modal.msgWarning('请选择一个产品')
return
}
if (!bindForm.channelIds.length) {
proxy.$modal.msgWarning('请选择渠道')
return
}
bindSaving.value = true
batchBindChannelPay({
channelIds: bindForm.channelIds,
apProductId: bindForm.productId
}).then(res => {
proxy.$modal.msgSuccess(typeof res.data === 'string' ? res.data : (res.msg || '绑定成功'))
bindVisible.value = false
}).finally(() => {
bindSaving.value = false
})
}
function openDetail(row) {
detailVisible.value = true
savingRowKey.value = ''
@@ -596,4 +681,10 @@ function statusType(status) {
.compare-panel :deep(tr.compare-removed:hover > td.el-table__cell) {
background: var(--el-color-danger-light-8);
}
.bind-channel-select :deep(.el-select__wrapper),
.bind-channel-select :deep(.el-input__wrapper) {
min-height: 168px;
align-items: flex-start;
padding-top: 8px;
}
</style>
@@ -50,7 +50,7 @@
<el-table-column min-width="180">
<template #header><span class="col-label"><i class="req-star">*</i>费用名称</span></template>
<template #default="{ row }">
<el-select v-model="row.feeType" filterable remote clearable reserve-keyword placeholder="输入费用名称"
<el-select v-model="row.scId" filterable remote clearable reserve-keyword placeholder="输入费用名称"
:remote-method="searchSurcharge" :loading="surchargeLoading" :disabled="locked(row)" style="width: 100%"
@change="id => onFeeChange(row, id)">
<el-option v-for="item in surchargeOptions" :key="item.scId" :label="item.scName" :value="item.scId" />
@@ -240,12 +240,18 @@ async function loadFees(force = false) {
searchSurcharge('')
}
function pickedId(item) {
if (item?.scId != null && item.scId !== '') return String(item.scId)
const type = item?.feeType == null ? '' : String(item.feeType)
return /^\d+$/.test(type) ? type : ''
}
function toRow(item, saved) {
const row = {
rowKey: saved ? `fee-${item.id}` : `new-${++rowSeed}`,
id: saved ? item.id : null,
billCode: item.billCode || '',
feeType: item.feeType == null ? '' : String(item.feeType),
scId: pickedId(item),
feeName: item.feeName || '',
price: item.price === null || item.price === undefined ? null : Number(item.price),
currency: item.currency || '',
@@ -258,7 +264,7 @@ function toRow(item, saved) {
function snapshot(row) {
return {
feeType: row.feeType || '',
scId: row.scId || '',
price: row.price === null || row.price === undefined || row.price === '' ? '' : String(Number(row.price)),
currency: row.currency || '',
remark: (row.remark || '').trim()
@@ -267,7 +273,7 @@ function snapshot(row) {
function currentOf(row) {
return {
feeType: row.feeType || '',
scId: row.scId || '',
price: row.price === null || row.price === undefined || row.price === '' ? '' : String(Number(row.price)),
currency: row.currency || '',
remark: (row.remark || '').trim()
@@ -275,9 +281,9 @@ function currentOf(row) {
}
function rowChanged(row) {
if (!row.origin) return !!(row.feeType || row.price || row.currency || row.remark)
if (!row.origin) return !!(row.scId || row.price || row.currency || row.remark)
const now = currentOf(row)
return now.feeType !== row.origin.feeType || now.price !== row.origin.price
return now.scId !== row.origin.scId || now.price !== row.origin.price
|| now.currency !== row.origin.currency || now.remark !== row.origin.remark
}
@@ -302,7 +308,7 @@ function removeRow(row) {
function rowError(row) {
if (!row.billCode) return '请选择提单'
if (!row.feeType) return '请选择费用名称'
if (!row.scId) return '请选择费用名称'
if (row.price === null || row.price === undefined || row.price === '') return '请填写价格'
if (Number(row.price) < 0) return '价格不能小于0'
if (!row.currency) return '请选择币种'
@@ -323,7 +329,7 @@ function save() {
rows.value.forEach(row => {
if (!rowChanged(row)) return
const payload = {
feeType: row.feeType || '',
scId: row.scId || '',
price: row.price,
currency: row.currency || '',
remark: (row.remark || '').trim()
@@ -401,8 +407,8 @@ function onFeeChange(row, id) {
function pinSelectedFees() {
const known = new Map(surchargeOptions.value.map(item => [String(item.scId), item]))
rows.value.forEach(row => {
if (row.feeType && !known.has(String(row.feeType))) {
known.set(String(row.feeType), { scId: String(row.feeType), scName: row.feeName || String(row.feeType) })
if (row.scId && !known.has(String(row.scId))) {
known.set(String(row.scId), { scId: String(row.scId), scName: row.feeName || String(row.scId) })
}
})
surchargeOptions.value = [...known.values()]
@@ -9,7 +9,7 @@
<el-table-column min-width="160">
<template #header><span class="col-label"><i class="req-star">*</i>费用项</span></template>
<template #default="{ row }">
<el-select v-model="row.feeType" filterable remote clearable reserve-keyword placeholder="输入费用名称"
<el-select v-model="row.scId" filterable remote clearable reserve-keyword placeholder="输入费用名称"
:remote-method="searchSurcharge" :loading="surchargeLoading" :disabled="locked(row)" style="width: 100%" @change="name => onFeeChange(row, name)">
<el-option v-for="item in surchargeOptions" :key="item.scId" :label="item.scName" :value="item.scId" />
</el-select>
@@ -166,7 +166,7 @@ function loadFees() {
rows.value = (feeRes.data || []).map(item => ({
rowKey: `fee-${item.id}`,
id: item.id,
feeType: item.feeType == null ? '' : String(item.feeType),
scId: pickedId(item),
feeName: item.feeName || '',
feeLevel: item.feeLevel == null ? '' : String(item.feeLevel),
allocFlag: item.allocFlag == null || item.allocFlag === '' ? '0' : String(item.allocFlag),
@@ -186,9 +186,9 @@ function loadFees() {
function pinSelectedFees() {
const known = new Map(surchargeOptions.value.map(item => [String(item.scId), item]))
for (const row of rows.value) {
if (!row.feeType) continue
if (!known.has(String(row.feeType))) {
known.set(String(row.feeType), { scId: String(row.feeType), scName: row.feeName || String(row.feeType) })
if (!row.scId) continue
if (!known.has(String(row.scId))) {
known.set(String(row.scId), { scId: String(row.scId), scName: row.feeName || String(row.scId) })
}
}
surchargeOptions.value = [...known.values()]
@@ -264,7 +264,7 @@ function addRow() {
rows.value.push({
rowKey: `new-${rowSeed}`,
id: null,
feeType: '',
scId: '',
feeName: '',
feeLevel: '',
allocFlag: '0',
@@ -315,9 +315,15 @@ function removeRow(row) {
rows.value = rows.value.filter(item => item.rowKey !== row.rowKey)
}
function pickedId(item) {
if (item?.scId != null && item.scId !== '') return String(item.scId)
const type = item?.feeType == null ? '' : String(item.feeType)
return /^\d+$/.test(type) ? type : ''
}
function snapshot(item) {
return {
feeType: item.feeType || '',
scId: pickedId(item),
feeLevel: item.feeLevel || '',
allocFlag: item.allocFlag == null || item.allocFlag === '' ? '0' : String(item.allocFlag),
allocDim: item.allocDim || '',
@@ -329,7 +335,7 @@ function snapshot(item) {
function currentOf(row) {
return {
feeType: row.feeType || '',
scId: row.scId || '',
feeLevel: row.feeLevel || '',
allocFlag: row.allocFlag || '',
allocDim: String(row.allocFlag) === '1' ? (row.allocDim || '') : '',
@@ -348,15 +354,15 @@ function normPrice(value) {
function rowChanged(row) {
if (!row.origin) {
const now = currentOf(row)
return !!(now.feeType || now.price || now.currency || now.remark)
return !!(now.scId || now.price || now.currency || now.remark)
}
const now = currentOf(row)
return now.feeType !== row.origin.feeType || now.price !== row.origin.price
return now.scId !== row.origin.scId || now.price !== row.origin.price
|| now.currency !== row.origin.currency || now.remark !== row.origin.remark
}
function rowError(row) {
if (!row.feeType) return '请选择费用项'
if (!row.scId) return '请选择费用项'
if (row.price === null || row.price === undefined || row.price === '') return '请填写价格'
if (Number(row.price) < 0) return '价格不能小于0'
if (!row.currency) return '请选择收费币种'
@@ -374,7 +380,7 @@ function save() {
rows.value.forEach(row => {
if (!rowChanged(row)) return
const payload = {
feeType: row.feeType || '',
scId: row.scId || '',
feeLevel: row.feeLevel || '',
price: row.price,
currency: row.currency || '',
@@ -0,0 +1,834 @@
<template>
<div class="app-container pay-order-page">
<div v-if="recalcFloatVisible" class="retry-status-float">
<el-tooltip :content="recalcFloatTooltip" placement="bottom">
<el-button class="retry-status-button" type="primary" plain size="small" @click="openRecalcProgress">
<span class="retry-progress-ring" :style="{ '--retry-progress': recalcProgressDegree + 'deg' }" aria-hidden="true">
<span class="retry-progress-value">{{ recalcProgressText }}</span>
</span>
<span class="retry-status-text">
<strong>{{ recalcFloatTitle }}</strong>
<small>{{ recalcFloatSummary }}</small>
</span>
</el-button>
</el-tooltip>
</div>
<el-form :inline="true" :model="query" class="mb8">
<el-form-item label="订单号">
<el-input v-model="query.orderNo" type="textarea" :rows="2" clearable placeholder="多个订单号可用逗号、空格或换行分隔" style="width: 280px" />
</el-form-item>
<el-form-item label="提单号">
<el-input v-model="query.ladingNo" clearable placeholder="提单号" style="width: 180px" @keyup.enter="search" />
</el-form-item>
<el-form-item label="客户">
<el-input v-model="query.customerName" clearable placeholder="客户名称或代码" style="width: 180px" @keyup.enter="search" />
</el-form-item>
<el-form-item>
<el-button type="primary" icon="Search" @click="search">查询</el-button>
<el-button icon="Refresh" @click="reset">重置</el-button>
</el-form-item>
</el-form>
<el-row class="mb8">
<el-button type="primary" plain icon="RefreshRight" :loading="recalcRunning" v-hasPermi="['price:payOrder:recalc']" @click="openRecalc">费用重算</el-button>
</el-row>
<el-table v-loading="loading" :data="rows" border>
<el-table-column prop="orderNo" label="订单号" min-width="160" fixed="left" show-overflow-tooltip />
<el-table-column prop="ladingNo" label="提单号" min-width="150" fixed="left" show-overflow-tooltip>
<template #default="{ row }">{{ row.ladingNo || '-' }}</template>
</el-table-column>
<el-table-column prop="trackingNo" label="运单号" min-width="150" show-overflow-tooltip />
<el-table-column prop="customerName" label="客户" min-width="140" show-overflow-tooltip />
<el-table-column prop="productName" label="产品" min-width="160" show-overflow-tooltip />
<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="currency" label="币种" width="80" align="center" />
<el-table-column label="计费状态" width="100" align="center">
<template #default="{ row }">
<dict-tag v-if="row.payCalcStatus != null && row.payCalcStatus !== ''" :options="bms_pay_calc_status" :value="row.payCalcStatus" />
<span v-else>-</span>
</template>
</el-table-column>
<el-table-column prop="payCalcMsg" label="失败原因" min-width="180" show-overflow-tooltip>
<template #default="{ row }">{{ row.payCalcMsg || '-' }}</template>
</el-table-column>
<el-table-column prop="bizDate" label="计费时间" width="170" align="center" />
<el-table-column prop="updateBy" label="更新人" width="110" show-overflow-tooltip>
<template #default="{ row }">{{ row.updateBy || '-' }}</template>
</el-table-column>
<el-table-column prop="updateTime" label="更新时间" width="170" align="center">
<template #default="{ row }">{{ row.updateTime || '-' }}</template>
</el-table-column>
<el-table-column label="操作" width="190" align="center" fixed="right">
<template #default="{ row }">
<el-button link type="primary" v-hasPermi="['price:payOrder:query']" @click="openDetail(row)">详情</el-button>
<el-button link type="primary" v-hasPermi="['price:payOrder:fee']" @click="openFees(row)">费用</el-button>
<el-button link type="primary" v-hasPermi="['price:payOrder:log']" @click="openLogs(row)">日志</el-button>
</template>
</el-table-column>
</el-table>
<pagination v-show="total > 0" :total="total" v-model:page="query.pageNum" v-model:limit="query.pageSize" @pagination="loadList" />
<bill-detail v-model="detailOpen" title="订单详情" :loading="detailLoading" :detail="detail" />
<el-dialog v-model="feeOpen" :title="feeTitle" width="1280px" append-to-body destroy-on-close>
<div v-loading="feeLoading" class="fee-board">
<section v-for="section in sections" :key="section.level" class="fee-section">
<div class="fee-head">{{ section.title }}</div>
<div class="fee-tools">
<el-button v-hasPermi="['price:payOrder:feeAdd']" type="primary" plain size="small" @click="addFeeRow(section)">增加费用</el-button>
</div>
<el-table class="fee-table" :data="section.fees" border table-layout="fixed" empty-text="无">
<el-table-column label="费用项" min-width="1" header-align="center" show-overflow-tooltip>
<template #default="{ row }">
<el-select v-if="row.editing" v-model="row.pick" filterable allow-create default-first-option placeholder="选择或输入" @change="pickFee(row)">
<el-option v-for="item in (bms_fee_type || [])" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
<span v-else>{{ row.feeName }}</span>
</template>
</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>
</template>
</el-table-column>
<el-table-column label="币种" min-width="1" header-align="center" align="center" show-overflow-tooltip>
<template #default="{ row }">
<el-select v-if="row.editing" v-model="row.currency" filterable>
<el-option v-for="item in (bms_currency || [])" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
<span v-else>{{ row.currency }}</span>
</template>
</el-table-column>
<el-table-column label="说明" min-width="1" header-align="center" show-overflow-tooltip>
<template #default="{ row }">
<el-input v-if="row.editing" v-model="row.remark" maxlength="200" />
<span v-else>{{ row.remark }}</span>
</template>
</el-table-column>
<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 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 />
<el-table-column label="操作" min-width="1" header-align="center" align="center" class-name="fee-op">
<template #default="{ row }">
<el-button v-if="row.editing" link type="primary" @click="saveFeeRow(section, row)">保存</el-button>
<el-button v-if="row.editing" link type="danger" @click="removeFeeRow(section, row)">删除</el-button>
<el-button v-else v-hasPermi="['price:payOrder:feeRemove']" link type="danger" @click="removeFeeRow(section, row)">删除</el-button>
</template>
</el-table-column>
</el-table>
</section>
</div>
</el-dialog>
<el-dialog v-model="logOpen" :title="logTitle" width="980px" append-to-body>
<el-table v-loading="logLoading" class="fee-log-table" :data="logRows" border empty-text="无">
<el-table-column label="变更前" min-width="200" header-align="center">
<template #default="{ row }">
<div v-if="logLines(row, 'before').length" class="log-change">
<div v-for="(line, index) in logLines(row, 'before')" :key="index">{{ line }}</div>
</div>
<span v-else class="log-empty">空</span>
</template>
</el-table-column>
<el-table-column label="变更后" min-width="200" header-align="center">
<template #default="{ row }">
<div v-if="logLines(row, 'after').length" class="log-change">
<div v-for="(line, index) in logLines(row, 'after')" :key="index">{{ line }}</div>
</div>
<span v-else class="log-empty">空</span>
</template>
</el-table-column>
<el-table-column prop="remark" label="备注" min-width="180" header-align="center" show-overflow-tooltip>
<template #default="{ row }">{{ row.remark || '-' }}</template>
</el-table-column>
<el-table-column label="操作类型" width="120" header-align="center" align="center">
<template #default="{ row }">
<dict-tag :options="bms_pay_fee_log_type" :value="row.operationType" />
</template>
</el-table-column>
<el-table-column prop="createBy" label="操作人" width="120" header-align="center" show-overflow-tooltip />
<el-table-column prop="createTime" label="操作时间" width="170" header-align="center" align="center" />
</el-table>
<pagination v-show="logTotal > 0" :total="logTotal" v-model:page="logQuery.pageNum" v-model:limit="logQuery.pageSize" @pagination="loadLogs" />
</el-dialog>
<el-dialog v-model="recalcOpen" title="费用重算" width="720px" append-to-body :close-on-click-modal="false">
<el-form label-width="90px">
<el-form-item label="重算方式">
<el-radio-group v-model="recalcForm.sourceType" :disabled="recalcSaving">
<el-radio value="ORDER">订单号</el-radio>
<el-radio value="LADING">提单号</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item :label="recalcForm.sourceType === 'LADING' ? '提单号' : '订单号'">
<el-input v-model="recalcForm.text" type="textarea" :rows="6" :disabled="recalcSaving" :placeholder="recalcPlaceholder" />
</el-form-item>
</el-form>
<template #footer>
<el-button @click="recalcOpen = false">关闭</el-button>
<el-button type="primary" :loading="recalcSaving" @click="submitRecalc">确认</el-button>
</template>
</el-dialog>
<el-dialog
v-model="recalcProgressVisible"
:title="recalcDialogTitle"
width="560px"
append-to-body
:close-on-click-modal="false"
:close-on-press-escape="true"
:show-close="true"
>
<el-progress
:percentage="recalcProgressPercent"
:status="recalcProgressStatus"
:stroke-width="14"
striped
:striped-flow="recalcRunning"
/>
<div class="rebill-progress__msg">{{ recalcProgressMessage }}</div>
<div v-if="!recalcRunning && recalcFinished" class="rebill-result-stats">
<div class="rebill-result-stats__item">
<span class="rebill-result-stats__label">总数</span>
<strong>{{ recalcProgressTotal }}</strong>
</div>
<div class="rebill-result-stats__item is-success">
<span class="rebill-result-stats__label">成功</span>
<strong>{{ recalcProgressSuccess }}</strong>
</div>
<div class="rebill-result-stats__item is-fail">
<span class="rebill-result-stats__label">失败</span>
<strong>{{ recalcProgressFail }}</strong>
</div>
</div>
<div v-else class="rebill-progress__text">
总数 {{ recalcProgressTotal }}
/ 成功 {{ recalcProgressSuccess }}
/ 失败 {{ recalcProgressFail }}
</div>
<el-table v-if="!recalcRunning && recalcFails.length" :data="recalcFails" border size="small" max-height="220" class="rebill-progress__error" empty-text="没有失败记录">
<el-table-column prop="orderNo" label="订单号" min-width="140" show-overflow-tooltip />
<el-table-column prop="ladingNo" label="提单号" min-width="120" show-overflow-tooltip />
<el-table-column prop="message" label="原因" min-width="180" show-overflow-tooltip />
</el-table>
<p v-if="recalcRunning" class="rebill-progress__hint">重算在后台进行,可收起弹窗继续操作;请勿关闭或刷新本页</p>
<template #footer>
<el-button v-if="recalcRunning" @click="recalcProgressVisible = false">收起</el-button>
<el-button
v-if="recalcRunning"
v-hasPermi="['price:payOrder:recalc']"
type="danger"
plain
:loading="recalcCancelLoading"
@click="handleCancelRecalc"
>取消重算</el-button>
<template v-else>
<el-button v-if="recalcFails.length" v-hasPermi="['price:payOrder:recalc']" type="warning" plain @click="viewRecalcFailed">查看失败订单</el-button>
<el-button type="primary" @click="recalcProgressVisible = false">关闭</el-button>
</template>
</template>
</el-dialog>
</div>
</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 { ElMessage, ElMessageBox } from 'element-plus'
import BillDetail from '../components/BillDetail.vue'
const { proxy } = getCurrentInstance()
const { bms_pay_calc_status, bms_fee_type, bms_currency, bms_pay_fee_log_type } = useDict('bms_pay_calc_status', 'bms_fee_type', 'bms_currency', 'bms_pay_fee_log_type')
const loading = ref(false)
const rows = ref([])
const total = ref(0)
const query = reactive({ orderNo: '', ladingNo: '', customerName: '', pageNum: 1, pageSize: 20 })
const detailOpen = ref(false)
const detailLoading = ref(false)
const detail = ref(null)
const feeOpen = ref(false)
const feeLoading = ref(false)
const feeTitle = ref('应付费用')
const feeBillId = ref('')
const sections = ref([])
const logOpen = ref(false)
const logLoading = ref(false)
const logTitle = ref('费用日志')
const logBillId = ref('')
const logRows = ref([])
const logTotal = ref(0)
const logQuery = reactive({ pageNum: 1, pageSize: 10 })
const recalcOpen = ref(false)
const recalcSaving = ref(false)
const recalcForm = reactive({ sourceType: 'ORDER', text: '' })
const recalcPlaceholder = computed(() => recalcForm.sourceType === 'LADING'
? '多个提单号可用逗号、空格或换行分隔,一次最多10个'
: '多个订单号可用逗号、空格或换行分隔,一次最多500个')
const recalcRunning = ref(false)
const recalcFinished = ref(false)
const recalcProgressVisible = ref(false)
const recalcProgressPercent = ref(0)
const recalcProgressMessage = ref('')
const recalcProgressStatus = ref(undefined)
const recalcProgressTotal = ref(0)
const recalcProgressSuccess = ref(0)
const recalcProgressFail = ref(0)
const recalcLines = ref([])
const recalcTaskId = ref('')
const recalcCancelLoading = ref(false)
let recalcFloatHideTimer = null
const RECALC_TASK_STORAGE_KEY = 'price:payOrder:recalcTaskId'
const recalcFails = computed(() => (recalcLines.value || []).filter(line => line && line.finished && !line.success))
const recalcFloatVisible = computed(() => recalcRunning.value || recalcFinished.value)
const recalcProgressDegree = computed(() => Math.round(((recalcProgressPercent.value || 0) / 100) * 360))
const recalcProgressText = computed(() => (recalcProgressPercent.value || 0) + '%')
const recalcDialogTitle = computed(() => {
if (recalcRunning.value) return '费用重算进行中'
if (recalcFinished.value) return '费用重算完成'
return '费用重算'
})
const recalcFloatTitle = computed(() => {
if (recalcRunning.value) return '费用重算中'
if (recalcProgressStatus.value === 'exception') return '费用重算失败'
if (recalcProgressStatus.value === 'warning' && String(recalcProgressMessage.value || '').includes('已取消')) return '费用重算已取消'
if (recalcFinished.value) return '费用重算完成'
return '费用重算'
})
const recalcFloatSummary = computed(() =>
'成功 ' + (recalcProgressSuccess.value || 0) +
' / 失败 ' + (recalcProgressFail.value || 0) +
' / 总数 ' + (recalcProgressTotal.value || 0)
)
const recalcFloatTooltip = computed(() => recalcProgressMessage.value || '点击查看详情')
const sources = {
CALC: '尾程计算',
LADING: '提单分摊',
MANUAL: '手工'
}
function sourceText(value) {
return sources[value] || value || '-'
}
function logLines(row, side) {
const name = row?.[side + 'FeeName']
const amount = row?.[side + 'Amount']
const currency = row?.[side + 'Currency']
const blank = (name == null || name === '') && (amount == null || amount === '') && (currency == null || currency === '')
if (blank) {
return []
}
return [
'费用项:' + (name || '空'),
'金额:' + (amount == null || amount === '' ? '空' : amount),
'币种:' + (currency || '空')
]
}
function loadLogPage(billId, query, rows, total, loading) {
if (!billId) {
rows.value = []
total.value = 0
return
}
loading.value = true
listPayOrderFeeLogs(billId, { pageNum: query.pageNum, pageSize: query.pageSize }).then(res => {
rows.value = res.rows || []
total.value = res.total || 0
}).catch(() => {
proxy.$modal.msgError('费用日志加载失败')
}).finally(() => {
loading.value = false
})
}
function search() {
query.pageNum = 1
loadList()
}
function reset() {
query.orderNo = ''
query.ladingNo = ''
query.customerName = ''
search()
}
function loadList() {
loading.value = true
listPayOrder(query).then(res => {
rows.value = res.rows || []
total.value = res.total || 0
}).finally(() => {
loading.value = false
})
}
function openDetail(row) {
detail.value = null
detailOpen.value = true
detailLoading.value = true
getBill(row.billId).then(res => {
detail.value = res.data || null
}).finally(() => {
detailLoading.value = false
})
}
function openFees(row) {
feeTitle.value = (row.orderNo || '订单') + '的应付费用'
feeBillId.value = row.billId
sections.value = []
feeOpen.value = true
loadFees()
}
function openLogs(row) {
logTitle.value = (row.orderNo || '订单') + '的费用日志'
logBillId.value = row.billId
logQuery.pageNum = 1
logRows.value = []
logOpen.value = true
loadLogs()
}
function loadLogs() {
loadLogPage(logBillId.value, logQuery, logRows, logTotal, logLoading)
}
function loadFees() {
if (!feeBillId.value) {
return
}
feeLoading.value = true
listPayOrderFees(feeBillId.value).then(res => {
sections.value = res.data?.sections || []
}).catch(() => {
proxy.$modal.msgError('费用加载失败')
}).finally(() => {
feeLoading.value = false
})
}
function addFeeRow(section) {
if ((section.fees || []).some(item => item.editing)) {
proxy.$modal.msgWarning('请先保存当前新增的费用')
return
}
if (!section.fees) {
section.fees = []
}
section.fees.push({
editing: true,
pick: '',
feeType: '',
feeName: '',
amount: null,
currency: 'CNY',
remark: '',
feeSource: 'MANUAL'
})
}
function pickFee(row) {
const dict = (bms_fee_type.value || []).find(item => item.value === row.pick)
if (dict) {
row.feeType = dict.value
row.feeName = dict.label
return
}
row.feeType = row.pick
row.feeName = row.pick
}
function saveFeeRow(section, row) {
if (!row.feeName) {
proxy.$modal.msgWarning('请填写费用项')
return
}
if (row.amount === null || row.amount === undefined || row.amount === '') {
proxy.$modal.msgWarning('请填写金额')
return
}
feeLoading.value = true
addPayOrderFee(feeBillId.value, {
feeType: row.feeType,
feeName: row.feeName,
level: section.level,
amount: row.amount,
currency: row.currency || 'CNY',
remark: row.remark
}).then(() => {
proxy.$modal.msgSuccess('已增加费用')
loadFees()
loadList()
}).catch(() => {
feeLoading.value = false
})
}
function removeFeeRow(section, row) {
if (row.editing) {
section.fees = section.fees.filter(item => item !== row)
return
}
proxy.$modal.confirm('确认删除这条费用?').then(() => {
feeLoading.value = true
return removePayOrderFee(row.feeId)
}).then(() => {
proxy.$modal.msgSuccess('已删除')
loadFees()
loadList()
}).catch(() => {
feeLoading.value = false
})
}
function saveRecalcTaskId(taskId) {
recalcTaskId.value = taskId ? String(taskId) : ''
try {
if (recalcTaskId.value) sessionStorage.setItem(RECALC_TASK_STORAGE_KEY, recalcTaskId.value)
else sessionStorage.removeItem(RECALC_TASK_STORAGE_KEY)
} catch (e) { /* 刷新后恢复不了进度,不影响重算本身 */ }
}
function clearRecalcTaskId() {
saveRecalcTaskId('')
}
function readStoredRecalcTaskId() {
try {
return String(sessionStorage.getItem(RECALC_TASK_STORAGE_KEY) || '').trim()
} catch (e) {
return ''
}
}
function openRecalcProgress() {
recalcProgressVisible.value = true
}
function scheduleHideRecalcFloat() {
if (recalcFloatHideTimer) {
clearTimeout(recalcFloatHideTimer)
recalcFloatHideTimer = null
}
recalcFloatHideTimer = window.setTimeout(() => {
if (!recalcRunning.value && recalcFinished.value) recalcFinished.value = false
recalcFloatHideTimer = null
}, 8000)
}
function applyRecalcProgress(task) {
const total = Number(task.total) || 0
const success = Number(task.successCount) || 0
const fail = Number(task.failCount) || 0
recalcProgressPercent.value = Math.min(100, Number(task.percent) || 0)
recalcProgressTotal.value = total
recalcProgressSuccess.value = success
recalcProgressFail.value = fail
recalcLines.value = Array.isArray(task.lines) ? task.lines : []
const status = String(task.status || '').toUpperCase()
if (status === 'PENDING') {
recalcProgressMessage.value = '排队中…'
} else if (status === 'RUNNING' && String(task.message || '').includes('取消')) {
recalcProgressMessage.value = '正在取消,等待当前订单结束… ' + (success + fail) + '/' + total
} else if (status === 'RUNNING') {
recalcProgressMessage.value = '正在重算 ' + (success + fail) + '/' + total + (fail ? ('(失败 ' + fail + ')') : '')
}
}
function finishRecalcFromTask(task, cancelled) {
const success = Number(task && task.successCount) || 0
const fail = Number(task && task.failCount) || 0
const total = Number(task && task.total) || recalcProgressTotal.value || 0
recalcProgressPercent.value = Math.min(100, Number(task && task.percent) || 100)
recalcProgressStatus.value = cancelled ? 'warning' : (fail > 0 ? 'warning' : 'success')
recalcProgressTotal.value = total
recalcProgressSuccess.value = success
recalcProgressFail.value = fail
recalcLines.value = task && Array.isArray(task.lines) ? task.lines : recalcLines.value
if (cancelled) {
recalcProgressMessage.value = '费用重算已取消:成功 ' + success + ' / 失败 ' + fail + ' / 总数 ' + total
} else if (fail > 0) {
recalcProgressMessage.value = '费用重算完成(含失败):成功 ' + success + ' / 失败 ' + fail + ' / 总数 ' + total
} else {
recalcProgressMessage.value = '费用重算完成:成功 ' + success + ' / 失败 ' + fail + ' / 总数 ' + total
}
recalcFinished.value = true
clearRecalcTaskId()
loadList()
recalcProgressVisible.value = true
if (cancelled) ElMessage.warning(recalcProgressMessage.value)
else if (fail > 0) ElMessage.warning(recalcProgressMessage.value)
else ElMessage.success(recalcProgressMessage.value)
scheduleHideRecalcFloat()
}
async function resumeRecalcTask(taskId) {
if (!taskId || recalcRunning.value) return
recalcRunning.value = true
recalcFinished.value = false
recalcCancelLoading.value = false
saveRecalcTaskId(taskId)
recalcProgressVisible.value = false
recalcProgressPercent.value = 0
recalcProgressStatus.value = undefined
recalcProgressMessage.value = '恢复进度中…'
recalcProgressTotal.value = 0
recalcProgressSuccess.value = 0
recalcProgressFail.value = 0
recalcLines.value = []
let superseded = false
try {
const result = await pollPayOrderRecalc(taskId, applyRecalcProgress)
finishRecalcFromTask(result && result.task, !!(result && result.cancelled))
} catch (e) {
if (e && e.superseded) {
superseded = true
return
}
failRecalc(e)
} finally {
if (!superseded) recalcRunning.value = false
}
}
function failRecalc(e) {
const task = e && e.task
recalcProgressStatus.value = 'exception'
recalcProgressMessage.value = (e && e.message) || '费用重算失败'
recalcFinished.value = true
if (task) {
recalcProgressPercent.value = Math.min(100, Number(task.percent) || 100)
recalcProgressTotal.value = Number(task.total) || 0
recalcProgressSuccess.value = Number(task.successCount) || 0
recalcProgressFail.value = Number(task.failCount) || 0
recalcLines.value = Array.isArray(task.lines) ? task.lines : []
loadList()
}
clearRecalcTaskId()
recalcProgressVisible.value = true
scheduleHideRecalcFloat()
}
async function tryRestoreRecalcProgress() {
const taskId = readStoredRecalcTaskId()
if (!taskId) return
try {
const res = await getPayOrderRecalcTask(taskId)
const task = (res && res.data) || {}
const status = String(task.status || '').toUpperCase()
if (status === 'PENDING' || status === 'RUNNING') {
applyRecalcProgress(task)
resumeRecalcTask(taskId)
return
}
clearRecalcTaskId()
} catch (e) {
clearRecalcTaskId()
}
}
async function runRecalc(payload) {
if (recalcRunning.value) {
openRecalcProgress()
return
}
if (recalcFloatHideTimer) {
clearTimeout(recalcFloatHideTimer)
recalcFloatHideTimer = null
}
recalcRunning.value = true
recalcFinished.value = false
recalcCancelLoading.value = false
clearRecalcTaskId()
recalcProgressVisible.value = true
recalcProgressPercent.value = 0
recalcProgressStatus.value = undefined
recalcProgressMessage.value = '任务提交中…'
recalcProgressTotal.value = 0
recalcProgressSuccess.value = 0
recalcProgressFail.value = 0
recalcLines.value = []
window.setTimeout(() => {
if (recalcRunning.value) recalcProgressVisible.value = false
}, 600)
let superseded = false
try {
const res = await submitPayOrderRecalc(payload)
const taskId = res.data && res.data.taskId
if (!taskId) throw new Error('没有拿到重算任务')
saveRecalcTaskId(taskId)
const result = await pollPayOrderRecalc(taskId, applyRecalcProgress)
finishRecalcFromTask(result && result.task, !!(result && result.cancelled))
} catch (e) {
if (e && e.superseded) {
superseded = true
return
}
failRecalc(e)
} finally {
if (!superseded) recalcRunning.value = false
}
}
function openRecalc() {
if (recalcRunning.value) {
openRecalcProgress()
return
}
recalcForm.sourceType = 'ORDER'
recalcForm.text = ''
recalcOpen.value = true
}
async function submitRecalc() {
const text = String(recalcForm.text || '').trim()
if (!text) {
proxy.$modal.msgWarning(recalcForm.sourceType === 'LADING' ? '请填写提单号' : '请填写订单号')
return
}
if (recalcRunning.value) {
recalcOpen.value = false
openRecalcProgress()
return
}
const label = recalcForm.sourceType === 'LADING' ? '提单号' : '订单号'
const count = text.split(/[\s,,;;]+/).filter(Boolean).length
try {
await ElMessageBox.confirm('将按 ' + count + ' 个' + label + '重算应付费用,确认继续?', '二次确认', { type: 'warning' })
} catch (e) {
return
}
const payload = { sourceType: recalcForm.sourceType, text }
recalcOpen.value = false
runRecalc(payload)
}
async function handleCancelRecalc() {
if (!recalcRunning.value || !recalcTaskId.value || recalcCancelLoading.value) return
try {
await ElMessageBox.confirm('确认取消当前费用重算?已经算完的订单会保留,未开始的将停止。', '取消重算', { type: 'warning' })
} catch (e) {
return
}
recalcCancelLoading.value = true
try {
const res = await cancelPayOrderRecalc(recalcTaskId.value)
const task = (res && res.data) || {}
applyRecalcProgress(task)
recalcProgressMessage.value = '取消请求已提交,等待当前订单结束…'
ElMessage.success('已提交取消')
} catch (e) {
/* 全局拦截器会提示 */
} finally {
recalcCancelLoading.value = false
}
}
function viewRecalcFailed() {
recalcProgressVisible.value = false
const orderNos = [...new Set(recalcFails.value.map(item => item.orderNo).filter(Boolean))]
const ladingNos = [...new Set(recalcFails.value.map(item => item.ladingNo).filter(Boolean))]
if (orderNos.length) {
query.orderNo = orderNos.join('\n')
query.ladingNo = ''
} else if (ladingNos.length) {
query.orderNo = ''
query.ladingNo = ladingNos.join(',')
}
search()
}
onMounted(() => {
tryRestoreRecalcProgress()
})
onBeforeUnmount(() => {
if (recalcFloatHideTimer) {
clearTimeout(recalcFloatHideTimer)
recalcFloatHideTimer = null
}
})
loadList()
</script>
<style scoped>
.fee-board { max-height: 68vh; overflow: auto; }
.fee-section { margin-bottom: 16px; }
.fee-table :deep(.cell) {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.fee-table :deep(.el-table__header .cell) {
text-align: center;
}
.fee-log-table :deep(.el-table__header .cell) {
text-align: center;
}
.fee-table :deep(.el-select),
.fee-table :deep(.el-input),
.fee-table :deep(.el-input-number) {
width: 100%;
}
.fee-table :deep(.fee-op .cell) {
overflow: visible;
text-overflow: clip;
}
.fee-head {
margin-bottom: 8px;
padding: 8px 12px;
text-align: center;
font-weight: 600;
font-size: 15px;
background: var(--el-fill-color-light);
border: 1px solid var(--el-border-color);
}
.fee-tools { margin-bottom: 8px; text-align: right; }
.log-change { line-height: 1.6; }
.log-empty { color: var(--el-text-color-secondary); }
.rebill-progress__msg { margin-top: 12px; color: var(--el-text-color-regular); }
.rebill-result-stats { display: flex; gap: 12px; margin-top: 14px; }
.rebill-result-stats__item { flex: 1; padding: 10px 12px; border-radius: 8px; background: var(--el-fill-color-light); text-align: center; }
.rebill-result-stats__item.is-success { background: var(--el-color-success-light-9); }
.rebill-result-stats__item.is-fail { background: var(--el-color-warning-light-9); }
.rebill-result-stats__label { display: block; font-size: 12px; color: var(--el-text-color-secondary); margin-bottom: 4px; }
.rebill-result-stats__item strong { font-size: 20px; line-height: 1.2; color: var(--el-text-color-primary); }
.rebill-progress__text { margin-top: 8px; font-size: 13px; color: var(--el-text-color-secondary); }
.rebill-progress__hint { margin-top: 12px; font-size: 12px; color: var(--el-color-warning); }
.rebill-progress__error { margin-top: 12px; }
.pay-order-page .retry-status-float { position: fixed; top: 92px; right: 24px; z-index: 3001; }
.pay-order-page .retry-status-button { display: inline-flex; align-items: center; gap: 10px; min-width: 200px; min-height: 68px; padding: 6px 16px 6px 7px; border-radius: 36px; }
.pay-order-page .retry-progress-ring {
position: relative;
display: inline-flex;
align-items: center;
justify-content: center;
flex: 0 0 54px;
width: 54px;
height: 54px;
border-radius: 50%;
background: conic-gradient(var(--el-color-primary) 0deg var(--retry-progress, 45deg), var(--el-color-primary-light-8) var(--retry-progress, 45deg) 360deg);
}
.pay-order-page .retry-progress-ring::after { position: absolute; inset: 5px; content: ''; border-radius: 50%; background: var(--el-bg-color); }
.pay-order-page .retry-progress-value { position: relative; z-index: 1; color: var(--el-color-primary); font-size: 12px; font-weight: 600; line-height: 1; }
.pay-order-page .retry-status-text { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; line-height: 1.2; white-space: nowrap; }
.pay-order-page .retry-status-text strong { font-size: 14px; font-weight: 600; }
.pay-order-page .retry-status-text small { color: var(--el-text-color-secondary); font-size: 11px; }
</style>