应付费用重算优化以及样式调整
This commit is contained in:
@@ -15,6 +15,14 @@ export function listPayOrderFees(billId) {
|
||||
})
|
||||
}
|
||||
|
||||
export function listPayOrderFeeLogs(billId, query) {
|
||||
return request({
|
||||
url: '/price/payOrder/' + billId + '/feeLogs',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
export function addPayOrderFee(billId, data) {
|
||||
return request({
|
||||
url: '/price/payOrder/' + billId + '/fees',
|
||||
@@ -30,10 +38,67 @@ export function removePayOrderFee(feeId) {
|
||||
})
|
||||
}
|
||||
|
||||
export function recalcPayOrder(data) {
|
||||
export function submitPayOrderRecalc(data) {
|
||||
return request({
|
||||
url: '/price/payOrder/recalc',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export function getPayOrderRecalcTask(taskId) {
|
||||
return request({
|
||||
url: '/price/payOrder/recalc/task/' + taskId,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
export function cancelPayOrderRecalc(taskId) {
|
||||
return request({
|
||||
url: '/price/payOrder/recalc/task/' + taskId + '/cancel',
|
||||
method: 'post'
|
||||
})
|
||||
}
|
||||
|
||||
const payOrderRecalcPolls = new Map()
|
||||
|
||||
/** 轮询应付重算进度,直到完成、取消或失败。同一任务只保留一轮轮询。 */
|
||||
export async function pollPayOrderRecalc(taskId, onProgress) {
|
||||
const id = String(taskId || '')
|
||||
if (!id) throw new Error('没有拿到重算任务')
|
||||
const prev = payOrderRecalcPolls.get(id)
|
||||
if (prev) prev.aborted = true
|
||||
const ctrl = { aborted: false }
|
||||
payOrderRecalcPolls.set(id, ctrl)
|
||||
const started = Date.now()
|
||||
let lastSig = ''
|
||||
try {
|
||||
while (Date.now() - started < 30 * 60 * 1000) {
|
||||
if (ctrl.aborted) {
|
||||
const err = new Error('poll superseded')
|
||||
err.superseded = true
|
||||
throw err
|
||||
}
|
||||
const hidden = typeof document !== 'undefined' && document.visibilityState === 'hidden'
|
||||
const res = await getPayOrderRecalcTask(id)
|
||||
const task = res.data || {}
|
||||
const status = String(task.status || '').toUpperCase()
|
||||
const sig = [status, task.percent, task.successCount, task.failCount, task.total].join('|')
|
||||
if (typeof onProgress === 'function' && sig !== lastSig) {
|
||||
lastSig = sig
|
||||
onProgress(task)
|
||||
}
|
||||
if (status === 'SUCCESS') return { task }
|
||||
if (status === 'CANCELLED') return { task, cancelled: true }
|
||||
if (status === 'FAIL') {
|
||||
const err = new Error(task.message || '费用重算失败')
|
||||
err.task = task
|
||||
throw err
|
||||
}
|
||||
await new Promise(resolve => setTimeout(resolve, hidden ? 2500 : 1000))
|
||||
}
|
||||
throw new Error('费用重算进度查询超时,请稍后在列表查看结果')
|
||||
} finally {
|
||||
if (payOrderRecalcPolls.get(id) === ctrl) payOrderRecalcPolls.delete(id)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,22 +175,24 @@
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog v-model="batchBindOpen" title="批量绑定应收/应付产品" width="520px" append-to-body @closed="onBatchBindClosed">
|
||||
<el-form label-width="100px">
|
||||
<el-dialog v-model="batchBindOpen" title="批量绑定应收/应付服务商渠道" width="560px" append-to-body @closed="onBatchBindClosed">
|
||||
<el-form class="batch-bind-form" label-width="132px">
|
||||
<el-form-item label="已选渠道">
|
||||
<span>{{ batchBindIds.length }} 个</span>
|
||||
<span class="batch-bind-count">{{ batchBindIds.length }} 个</span>
|
||||
</el-form-item>
|
||||
<el-form-item label="应付产品">
|
||||
<el-select v-model="batchApId" filterable clearable placeholder="可选,不选则不改应付绑定" style="width: 100%">
|
||||
<el-form-item label="应付服务商渠道">
|
||||
<el-select v-model="batchApId" class="batch-bind-select" filterable clearable placeholder="可选,不选则不改应付绑定">
|
||||
<el-option v-for="item in payOptions" :key="'ap-' + item.productId" :label="payOptionLabel(item)" :value="item.productId" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="应收产品">
|
||||
<el-select v-model="batchArId" filterable clearable placeholder="可选,不选则不改应收绑定" style="width: 100%">
|
||||
<!--
|
||||
<el-form-item label="应收服务商渠道">
|
||||
<el-select v-model="batchArId" class="batch-bind-select" filterable clearable placeholder="可选,不选则不改应收绑定">
|
||||
<el-option v-for="item in arOptions" :key="'ar-' + item.productId" :label="payOptionLabel(item)" :value="item.productId" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<div class="pay-tip">至少选择一个产品;将覆盖已选渠道对应收付类型的绑定。</div>
|
||||
-->
|
||||
<div class="batch-bind-tip">至少选择一个服务商渠道;将覆盖已选渠道对应收付类型的绑定。</div>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="batchBindOpen = false">取消</el-button>
|
||||
@@ -231,18 +233,18 @@ const batchArId = ref()
|
||||
const payTip = computed(() => {
|
||||
if (viewing.value) {
|
||||
if (payProduct.value?.versionNo) return `已绑定第 ${payProduct.value.versionNo} 版。`
|
||||
return payOriginId.value ? '已绑定应付产品。' : '未绑定应付产品。'
|
||||
return payOriginId.value ? '已绑定应付服务商渠道。' : '未绑定应付服务商渠道。'
|
||||
}
|
||||
if (!form.value?.id) return '先保存渠道,再选择应付产品。渠道绑定的是产品编号,更新价格不会换编号。'
|
||||
if (!form.value?.id) return '先保存渠道,再选择应付服务商渠道。渠道绑定的是产品编号,更新价格不会换编号。'
|
||||
if (payProduct.value?.versionNo) return `当前按有效期使用第 ${payProduct.value.versionNo} 版。历史订单按下单或计费时间取当时的版本。`
|
||||
return '选择产品后即绑定,按应付 AP 保存。'
|
||||
})
|
||||
const arTip = computed(() => {
|
||||
if (viewing.value) {
|
||||
if (arProduct.value?.versionNo) return `已绑定第 ${arProduct.value.versionNo} 版。`
|
||||
return arOriginId.value ? '已绑定应收产品。' : '未绑定应收产品。'
|
||||
return arOriginId.value ? '已绑定应收服务商渠道。' : '未绑定应收服务商渠道。'
|
||||
}
|
||||
if (!form.value?.id) return '先保存渠道,再选择应收产品。渠道绑定的是产品编号,更新价格不会换编号。'
|
||||
if (!form.value?.id) return '先保存渠道,再选择应收服务商渠道。渠道绑定的是服务商渠道编号,更新价格不会换编号。'
|
||||
if (arProduct.value?.versionNo) return `当前按有效期使用第 ${arProduct.value.versionNo} 版。历史订单按下单或计费时间取当时的版本。`
|
||||
return '选择产品后即绑定,按应收 AR 保存。'
|
||||
})
|
||||
@@ -533,4 +535,32 @@ function submitBatchBind() {
|
||||
font-size: 12px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
.batch-bind-form :deep(.el-form-item) {
|
||||
align-items: center;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
.batch-bind-form :deep(.el-form-item__label) {
|
||||
height: 32px;
|
||||
line-height: 32px;
|
||||
white-space: nowrap;
|
||||
align-items: center;
|
||||
}
|
||||
.batch-bind-form :deep(.el-form-item__content) {
|
||||
line-height: 32px;
|
||||
}
|
||||
.batch-bind-count {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
height: 32px;
|
||||
line-height: 32px;
|
||||
}
|
||||
.batch-bind-select {
|
||||
width: 100%;
|
||||
}
|
||||
.batch-bind-tip {
|
||||
margin: 0 0 4px 132px;
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: 12px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,5 +1,18 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<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" />
|
||||
@@ -17,7 +30,7 @@
|
||||
</el-form>
|
||||
|
||||
<el-row class="mb8">
|
||||
<el-button type="primary" plain icon="RefreshRight" v-hasPermi="['price:payOrder:recalc']" @click="openRecalc">费用重算</el-button>
|
||||
<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>
|
||||
@@ -43,10 +56,17 @@
|
||||
<template #default="{ row }">{{ row.payCalcMsg || '-' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="bizDate" label="计费时间" width="170" align="center" />
|
||||
<el-table-column label="操作" width="140" align="center" fixed="right">
|
||||
<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>
|
||||
@@ -61,43 +81,43 @@
|
||||
<div class="fee-tools">
|
||||
<el-button v-hasPermi="['price:payOrder:feeAdd']" type="primary" plain size="small" @click="addFeeRow(section)">增加费用</el-button>
|
||||
</div>
|
||||
<el-table :data="section.fees" border empty-text="无">
|
||||
<el-table-column label="费用项" min-width="180">
|
||||
<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="选择或输入" style="width: 100%" @change="pickFee(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="金额" width="140" align="right">
|
||||
<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" style="width: 100%" />
|
||||
<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="币种" width="110" align="center">
|
||||
<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 style="width: 100%">
|
||||
<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="180">
|
||||
<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="来源" width="100" align="center">
|
||||
<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="创建人" width="100" show-overflow-tooltip />
|
||||
<el-table-column prop="createTime" label="创建时间" width="160" />
|
||||
<el-table-column prop="updateBy" label="更新人" width="100" show-overflow-tooltip />
|
||||
<el-table-column prop="updateTime" label="更新时间" width="160" />
|
||||
<el-table-column label="操作" width="130" align="center" fixed="right">
|
||||
<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>
|
||||
@@ -106,55 +126,124 @@
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</section>
|
||||
<section class="fee-section">
|
||||
<div class="fee-head">费用日志</div>
|
||||
<el-table :data="feeLogs" border empty-text="无" max-height="280">
|
||||
<el-table-column prop="feeName" label="费用项" min-width="160" show-overflow-tooltip />
|
||||
<el-table-column prop="amount" label="金额" width="120" align="right" />
|
||||
<el-table-column prop="currency" label="币种" width="90" align="center" />
|
||||
<el-table-column label="操作类型" width="120" 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" show-overflow-tooltip />
|
||||
<el-table-column prop="createTime" label="操作时间" width="170" align="center" />
|
||||
</el-table>
|
||||
</section>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog v-model="recalcOpen" title="费用重算" width="720px" append-to-body @closed="resetRecalc">
|
||||
<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">
|
||||
<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" :placeholder="recalcPlaceholder" />
|
||||
<el-input v-model="recalcForm.text" type="textarea" :rows="6" :disabled="recalcSaving" :placeholder="recalcPlaceholder" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div v-if="recalcResult" class="recalc-result">
|
||||
<span>成功 {{ recalcResult.successCount }} 票,失败 {{ recalcResult.failCount }} 票</span>
|
||||
<el-table :data="recalcFails" border size="small" max-height="240" empty-text="没有失败记录">
|
||||
<el-table-column prop="orderNo" label="订单号" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column prop="ladingNo" label="提单号" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column prop="message" label="原因" min-width="220" show-overflow-tooltip />
|
||||
</el-table>
|
||||
</div>
|
||||
<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, listPayOrder, listPayOrderFees, recalcPayOrder, removePayOrderFee } from '@/api/price/payOrder'
|
||||
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()
|
||||
@@ -174,15 +263,55 @@ const feeLoading = ref(false)
|
||||
const feeTitle = ref('应付费用')
|
||||
const feeBillId = ref('')
|
||||
const sections = ref([])
|
||||
const feeLogs = 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 recalcResult = ref(null)
|
||||
const recalcFails = computed(() => (recalcResult.value?.lines || []).filter(line => !line.success))
|
||||
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: '尾程计算',
|
||||
@@ -194,6 +323,38 @@ 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()
|
||||
@@ -231,11 +392,23 @@ function openFees(row) {
|
||||
feeTitle.value = (row.orderNo || '订单') + '的应付费用'
|
||||
feeBillId.value = row.billId
|
||||
sections.value = []
|
||||
feeLogs.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
|
||||
@@ -243,7 +416,6 @@ function loadFees() {
|
||||
feeLoading.value = true
|
||||
listPayOrderFees(feeBillId.value).then(res => {
|
||||
sections.value = res.data?.sections || []
|
||||
feeLogs.value = res.data?.logs || []
|
||||
}).catch(() => {
|
||||
proxy.$modal.msgError('费用加载失败')
|
||||
}).finally(() => {
|
||||
@@ -325,37 +497,300 @@ function removeFeeRow(section, row) {
|
||||
})
|
||||
}
|
||||
|
||||
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() {
|
||||
recalcResult.value = null
|
||||
if (recalcRunning.value) {
|
||||
openRecalcProgress()
|
||||
return
|
||||
}
|
||||
recalcForm.sourceType = 'ORDER'
|
||||
recalcForm.text = ''
|
||||
recalcOpen.value = true
|
||||
}
|
||||
|
||||
function resetRecalc() {
|
||||
recalcForm.sourceType = 'ORDER'
|
||||
recalcForm.text = ''
|
||||
recalcResult.value = null
|
||||
}
|
||||
|
||||
function submitRecalc() {
|
||||
if (!recalcForm.text || !recalcForm.text.trim()) {
|
||||
async function submitRecalc() {
|
||||
const text = String(recalcForm.text || '').trim()
|
||||
if (!text) {
|
||||
proxy.$modal.msgWarning(recalcForm.sourceType === 'LADING' ? '请填写提单号' : '请填写订单号')
|
||||
return
|
||||
}
|
||||
recalcSaving.value = true
|
||||
recalcPayOrder({ sourceType: recalcForm.sourceType, text: recalcForm.text }).then(res => {
|
||||
recalcResult.value = res.data || { successCount: 0, failCount: 0, lines: [] }
|
||||
loadList()
|
||||
}).finally(() => {
|
||||
recalcSaving.value = false
|
||||
})
|
||||
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;
|
||||
@@ -366,6 +801,34 @@ loadList()
|
||||
border: 1px solid var(--el-border-color);
|
||||
}
|
||||
.fee-tools { margin-bottom: 8px; text-align: right; }
|
||||
.recalc-result { margin-top: 8px; }
|
||||
.recalc-result > span { display: block; margin-bottom: 8px; }
|
||||
.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>
|
||||
|
||||
Reference in New Issue
Block a user