Merge branch 'test' into feauture-20261104

# Conflicts:
#	bms-front/src/views/price/billing/components/BillDetail.vue
This commit is contained in:
liuminghui
2026-11-06 17:30:48 +08:00
52 changed files with 3529 additions and 456 deletions
@@ -49,18 +49,22 @@
</template>
<template #col-action="{ row }">
<el-button link type="primary" v-hasPermi="['price:airBill:query']" @click="openDetail(row)">详情</el-button>
<el-button link type="primary" v-hasPermi="['price:airBill:fee']" @click="openFee(row)">费用</el-button>
</template>
</basic-table>
<air-bill-detail v-model="open" :title="title" :loading="loading" :detail="detail" />
<air-bill-fee-dialog ref="feeRef" />
</div>
</template>
<script setup name="AirBill">
import { listAirBill, getAirBill } from '@/api/price/airBill'
import AirBillDetail from './components/AirBillDetail.vue'
import AirBillFeeDialog from './components/AirBillFeeDialog.vue'
const tableRef = ref()
const feeRef = ref()
const tableHeight = ref(480)
let tableResizeObserver = null
@@ -102,7 +106,7 @@ const columns = [
{ label: '到达时间', prop: 'arriveTime', width: 170, parseTime: true },
{ label: '到仓时间', prop: 'arriveStockTime', width: 170, parseTime: true },
{ label: '清关时间', prop: 'clearanceTime', width: 170, parseTime: true },
{ label: '操作', prop: 'action', align: 'center', width: 90, fixed: 'right', slot: 'action', showInToolbar: false, showOverflowTooltip: false }
{ label: '操作', prop: 'action', align: 'center', width: 130, fixed: 'right', slot: 'action', showInToolbar: false, showOverflowTooltip: false }
]
const searchColumns = [
@@ -163,6 +167,10 @@ function queryList(params) {
return listAirBill(normalizeQuery(params))
}
function openFee(row) {
feeRef.value?.open(row)
}
function openDetail(row) {
if (!row?.billCode) return
open.value = true
+275 -24
View File
@@ -1,5 +1,20 @@
<template>
<div class="app-container billing-bill">
<div v-if="exportFloatVisible" class="retry-status-float export-status-float">
<el-tooltip :content="exportFloatTooltip" placement="bottom">
<el-button class="retry-status-button" type="warning" plain size="small" @click="openExportProgress()">
<span class="retry-progress-ring" :style="{ '--retry-progress': exportProgressDegree + 'deg' }" aria-hidden="true">
<span class="retry-progress-value">{{ exportProgressText }}</span>
</span>
<span class="retry-status-text">
<strong>{{ exportFloatTitle }}</strong>
<small>{{ exportFloatSummary }}</small>
</span>
</el-button>
</el-tooltip>
</div>
<basic-table
ref="tableRef"
:columns="columns"
@@ -157,6 +172,8 @@
type="warning"
plain
icon="Download"
:loading="exportLoading"
:disabled="exportLoading"
v-hasPermi="['price:billing:export']"
@click="handleExport"
>导出</el-button>
@@ -268,7 +285,33 @@
</div>
</el-dialog>
<excel-export-field-dialog
<el-dialog
v-model="exportProgressVisible"
:title="exportDialogTitle"
width="480px"
append-to-body
:close-on-click-modal="false"
:close-on-press-escape="true"
:show-close="true"
>
<el-progress
:percentage="exportProgressPercent"
:status="exportProgressStatus"
:stroke-width="14"
striped
:striped-flow="exportLoading"
/>
<div class="export-progress__msg">{{ exportProgressMessage }}</div>
<div class="export-progress__text">
导出行数 {{ exportProgressRowCount }}
</div>
<p v-if="exportLoading" class="export-progress__hint">导出在后台进行,可收起弹窗继续操作;请勿关闭或刷新本页</p>
<template #footer>
<el-button v-if="exportLoading" @click="exportProgressVisible = false">收起</el-button>
<el-button v-else type="primary" @click="exportProgressVisible = false">关闭</el-button>
</template>
</el-dialog>
<excel-export-field-dialog
ref="exportFieldRef"
:fields="BILLING_BILL_EXPORT_FIELDS"
storage-key="exportFields:billingBill"
@@ -322,6 +365,78 @@ const productOptions = computed(() =>
.map(p => ({ code: p.productCode, name: p.productName || p.productCode }))
)
const exportLoading = ref(false)
const exportFinished = ref(false)
const exportProgressVisible = ref(false)
const exportProgressPercent = ref(0)
const exportProgressMessage = ref('')
const exportProgressStatus = ref(undefined)
const exportProgressRowCount = ref(0)
const exportTaskId = ref('')
let exportFloatHideTimer = null
const exportFloatVisible = computed(() => exportLoading.value || exportFinished.value)
const exportProgressDegree = computed(() => Math.round(((exportProgressPercent.value || 0) / 100) * 360))
const exportProgressText = computed(() => (exportProgressPercent.value || 0) + '%')
const exportDialogTitle = computed(() => {
if (exportLoading.value) return '异步导出进行中'
if (exportFinished.value) return '异步导出完成'
return '异步导出'
})
const exportFloatTitle = computed(() => {
if (exportLoading.value) return '导出中'
if (exportProgressStatus.value === 'exception') return '导出失败'
if (exportFinished.value) return '导出完成'
return '导出'
})
const exportFloatSummary = computed(() => {
const pct = exportProgressPercent.value || 0
const rows = exportProgressRowCount.value || 0
if (rows > 0) return pct + '% / ' + rows + ' 行'
return pct + '%'
})
const exportFloatTooltip = computed(() => exportProgressMessage.value || '点击查看详情')
function openExportProgress() {
exportProgressVisible.value = true
}
function scheduleHideExportFloat() {
if (exportFloatHideTimer) {
clearTimeout(exportFloatHideTimer)
exportFloatHideTimer = null
}
exportFloatHideTimer = window.setTimeout(() => {
if (!exportLoading.value && exportFinished.value) {
exportFinished.value = false
}
exportFloatHideTimer = null
}, 8000)
}
function applyExportProgress(t) {
const pct = Math.min(100, Number(t && t.percent) || 0)
exportProgressPercent.value = pct
exportProgressRowCount.value = Number(t && t.rowCount) || 0
const st = String((t && t.status) || '').toUpperCase()
if (st === 'PENDING') {
exportProgressMessage.value = (t && t.message) || '排队中...'
exportProgressStatus.value = undefined
} else if (st === 'RUNNING') {
exportProgressMessage.value = (t && t.message) || ('导出中 ' + pct + '%')
exportProgressStatus.value = undefined
} else if (st === 'SUCCESS') {
exportProgressMessage.value = (t && t.message) || '导出完成,正在下载'
exportProgressStatus.value = 'success'
exportProgressPercent.value = 100
} else if (st === 'FAIL' || st === 'FAILED') {
exportProgressMessage.value = (t && (t.error || t.message)) || '导出失败'
exportProgressStatus.value = 'exception'
} else {
exportProgressMessage.value = (t && t.message) || ''
}
}
const tableRef = ref()
const exportFieldRef = ref()
const tableHeight = ref(480)
@@ -460,7 +575,7 @@ const columns = [
{ label: '额度欠费', prop: 'creditArrearsStatus', align: 'center', width: 100, slot: 'creditArrearsStatus' },
// { label: '退费状态', prop: 'refundStatus', align: 'center', width: 100, slot: 'refundStatus' },
{ label: '计费时间', prop: 'bizDate', align: 'center', width: 170, parseTime: true },
{ label: '提货时间', prop: 'pickupDate', align: 'center', width: 170, parseTime: true },
{ label: '收货时间', prop: 'pickupDate', align: 'center', width: 170, parseTime: true },
{ label: '销售员', prop: 'belongSaler', minWidth: 100, showOverflowTooltip: true },
{ label: '结算员', prop: 'settlementMan', minWidth: 100, showOverflowTooltip: true },
{ label: '客服员', prop: 'serviceMan', minWidth: 100, showOverflowTooltip: true },
@@ -534,20 +649,35 @@ const searchColumns = [
// 只选日期时自动补全为当天 00:00:00 ~ 23:59:59
defaultTime: [new Date(2000, 0, 1, 0, 0, 0), new Date(2000, 0, 1, 23, 59, 59)]
}
},
{
label: '收货时间',
prop: 'pickupDateRange',
component: 'datetimerange',
colSpan: 2,
props: {
clearable: true,
defaultTime: [new Date(2000, 0, 1, 0, 0, 0), new Date(2000, 0, 1, 23, 59, 59)]
}
}
]
function buildBillQuery(params) {
const { bizDateRange, orderIdentifiers: rawOrderIdentifiers, ...rest } = params || {}
const { bizDateRange, pickupDateRange, orderIdentifiers: rawOrderIdentifiers, ...rest } = params || {}
const query = { ...rest }
const orderIdentifiers = parseOrderIdentifiers(rawOrderIdentifiers)
if (orderIdentifiers.length) query.orderIdentifiers = orderIdentifiers
const rangeParams = {}
if (Array.isArray(bizDateRange) && (bizDateRange[0] || bizDateRange[1])) {
query.params = {
...(query.params || {}),
beginBizDate: bizDateRange[0] || null,
endBizDate: bizDateRange[1] || null
}
rangeParams.beginBizDate = bizDateRange[0] || null
rangeParams.endBizDate = bizDateRange[1] || null
}
if (Array.isArray(pickupDateRange) && (pickupDateRange[0] || pickupDateRange[1])) {
rangeParams.beginPickupDate = pickupDateRange[0] || null
rangeParams.endPickupDate = pickupDateRange[1] || null
}
if (Object.keys(rangeParams).length) {
query.params = { ...(query.params || {}), ...rangeParams }
}
return query
}
@@ -561,21 +691,66 @@ function queryList(params) {
}
async function handleExport() {
if (exportLoading.value) return
const params = tableRef.value?.getQueryParams?.() || {}
if (!validateOrderIdentifierLimit(params.orderIdentifiers)) return
const fields = await exportFieldRef.value?.open?.()
if (!fields || !fields.length) return
return exportAsyncFromTable({
baseUrl: '/price/billing/bill/export',
tableRef: tableRef.value,
normalize: (raw) => {
const q = buildBillQuery(raw)
q.exportFields = fields
return q
},
filePrefix: 'billing_bill',
requireFilter: true
})
if (exportFloatHideTimer) {
clearTimeout(exportFloatHideTimer)
exportFloatHideTimer = null
}
exportLoading.value = true
exportFinished.value = false
exportProgressVisible.value = false
exportProgressPercent.value = 0
exportProgressRowCount.value = 0
exportProgressStatus.value = undefined
exportProgressMessage.value = '导出任务已提交'
exportTaskId.value = ''
try {
const result = await exportAsyncFromTable({
baseUrl: '/price/billing/bill/export',
tableRef: tableRef.value,
normalize: (raw) => {
const q = buildBillQuery(raw)
q.exportFields = fields
return q
},
filePrefix: 'billing_bill',
requireFilter: true,
showLoading: false,
showSuccessMessage: true,
showErrorMessage: true,
onTaskId: (id) => { exportTaskId.value = id },
onProgress: (task) => applyExportProgress(task || {})
})
if (result && result.task) {
applyExportProgress({ ...(result.task || {}), status: 'SUCCESS', percent: 100 })
exportFinished.value = true
scheduleHideExportFloat()
} else if (!exportTaskId.value) {
exportFinished.value = false
exportProgressPercent.value = 0
exportProgressMessage.value = ''
exportProgressStatus.value = undefined
} else if (exportProgressStatus.value !== 'exception') {
exportProgressStatus.value = 'exception'
exportProgressMessage.value = exportProgressMessage.value || '导出失败'
exportFinished.value = true
scheduleHideExportFloat()
} else {
exportFinished.value = true
scheduleHideExportFloat()
}
} catch (e) {
exportProgressStatus.value = 'exception'
exportProgressMessage.value = (e && e.message) || '导出失败'
exportFinished.value = true
scheduleHideExportFloat()
} finally {
exportLoading.value = false
}
}
@@ -666,14 +841,15 @@ function hasBatchFeeQuery(q) {
|| hasArr(q.productCodes)
|| hasArr(q.billingFailStatuses)
|| hasArr(q.bizDateRange)
|| hasArr(q.pickupDateRange)
|| !!(q.creditArrearsStatus && String(q.creditArrearsStatus).trim())
}
function openBatchFee() {
const q = tableRef.value?.getQueryParams?.() || {}
if (!validateOrderIdentifierLimit(q.orderIdentifiers)) return
const { pageNum, pageSize, bizDateRange, ...rest } = q
if (!hasBatchFeeQuery({ ...rest, bizDateRange })) {
const { pageNum, pageSize, bizDateRange, pickupDateRange, ...rest } = q
if (!hasBatchFeeQuery({ ...rest, bizDateRange, pickupDateRange })) {
ElMessage.warning('请先设置列表查询条件')
return
}
@@ -685,6 +861,10 @@ function openBatchFee() {
listQuery.beginBizDate = bizDateRange[0] || null
listQuery.endBizDate = bizDateRange[1] || null
}
if (Array.isArray(pickupDateRange) && (pickupDateRange[0] || pickupDateRange[1])) {
listQuery.beginPickupDate = pickupDateRange[0] || null
listQuery.endPickupDate = pickupDateRange[1] || null
}
batchFeeListQuery.value = listQuery
batchFeeSelectedIds.value = tableRef.value?.getSelectionIds?.() || []
batchFeeOpen.value = true
@@ -697,8 +877,8 @@ function onBatchFeeSuccess() {
function buildRecalcPayload() {
const q = tableRef.value?.getQueryParams?.() || {}
if (!validateOrderIdentifierLimit(q.orderIdentifiers)) return null
const { pageNum, pageSize, bizDateRange, ...rest } = q
if (!hasBatchFeeQuery({ ...rest, bizDateRange })) {
const { pageNum, pageSize, bizDateRange, pickupDateRange, ...rest } = q
if (!hasBatchFeeQuery({ ...rest, bizDateRange, pickupDateRange })) {
ElMessage.warning('请先设置列表查询条件')
return null
}
@@ -720,6 +900,10 @@ function buildRecalcPayload() {
payload.beginBizDate = bizDateRange[0] || null
payload.endBizDate = bizDateRange[1] || null
}
if (Array.isArray(pickupDateRange) && (pickupDateRange[0] || pickupDateRange[1])) {
payload.beginPickupDate = pickupDateRange[0] || null
payload.endPickupDate = pickupDateRange[1] || null
}
return payload
}
@@ -796,7 +980,7 @@ function onChargeWeightUpdated() {
function buildChargeWeightTemplateQuery() {
const q = tableRef.value?.getQueryParams?.() || {}
const { pageNum, pageSize, bizDateRange, ...rest } = q
const { pageNum, pageSize, bizDateRange, pickupDateRange, ...rest } = q
const payload = {
fillByFilter: !!cwFillByFilter.value,
orderNos: rest.orderNos || [],
@@ -812,6 +996,10 @@ function buildChargeWeightTemplateQuery() {
payload.beginBizDate = bizDateRange[0] || null
payload.endBizDate = bizDateRange[1] || null
}
if (Array.isArray(pickupDateRange) && (pickupDateRange[0] || pickupDateRange[1])) {
payload.beginPickupDate = pickupDateRange[0] || null
payload.endPickupDate = pickupDateRange[1] || null
}
return payload
}
@@ -1020,4 +1208,67 @@ function refundTagType(status) {
width: 100%;
}
.order-identifier-search { width: 100%; }
.billing-bill .retry-status-float {
position: fixed;
top: 92px;
right: 24px;
z-index: 3001;
}
.billing-bill .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;
}
.billing-bill .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-warning) 0deg var(--retry-progress, 45deg),
var(--el-color-warning-light-8) var(--retry-progress, 45deg) 360deg
);
}
.billing-bill .retry-progress-ring::after {
position: absolute;
inset: 5px;
content: '';
border-radius: 50%;
background: var(--el-bg-color);
}
.billing-bill .retry-progress-value {
position: relative;
z-index: 1;
color: var(--el-color-warning);
font-size: 12px;
font-weight: 600;
line-height: 1;
}
.billing-bill .retry-status-text {
display: flex;
flex-direction: column;
align-items: flex-start;
gap: 3px;
line-height: 1.2;
white-space: nowrap;
}
.billing-bill .retry-status-text strong {
font-size: 14px;
font-weight: 600;
}
.billing-bill .retry-status-text small {
color: var(--el-text-color-secondary);
font-size: 11px;
}
.export-progress__msg { margin-top: 12px; color: var(--el-text-color-regular); }
.export-progress__text { margin-top: 8px; font-size: 13px; color: var(--el-text-color-secondary); }
.export-progress__hint { margin-top: 12px; font-size: 12px; color: var(--el-color-warning); }
</style>
@@ -0,0 +1,341 @@
<template>
<el-dialog v-model="visible" :title="title" width="980px" append-to-body destroy-on-close @closed="reset">
<div v-loading="loading">
<div class="fee-toolbar">
<el-button type="primary" plain icon="Plus" @click="addRow">新增</el-button>
<span class="fee-hint">只保存本次新增、修改和删除的费用,未改动的行不会重写。</span>
</div>
<el-table :data="rows" border size="small" max-height="320" row-key="rowKey" empty-text="暂无费用,点击新增">
<el-table-column label="费用项" min-width="160">
<template #default="{ row }">
<el-select v-model="row.feeType" filterable clearable placeholder="请选择" style="width: 100%">
<el-option v-for="item in bms_fee_type" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</template>
</el-table-column>
<el-table-column label="价格" width="150">
<template #default="{ row }">
<el-input-number v-model="row.price" :min="0" :precision="4" :controls="false" :value-on-clear="null" placeholder="价格" style="width: 100%" />
</template>
</el-table-column>
<el-table-column label="收费币种" width="140">
<template #default="{ row }">
<el-select v-model="row.currency" filterable clearable placeholder="请选择" style="width: 100%">
<el-option v-for="item in bms_currency" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</template>
</el-table-column>
<el-table-column label="备注" min-width="180">
<template #default="{ row }">
<el-input v-model="row.remark" maxlength="500" clearable placeholder="备注" />
</template>
</el-table-column>
<el-table-column label="操作" width="80" align="center">
<template #default="{ row }">
<el-button link type="danger" @click="removeRow(row)">删除</el-button>
</template>
</el-table-column>
</el-table>
</div>
<div class="log-title">操作日志</div>
<div v-loading="logLoading">
<el-table :data="logs" border size="small" max-height="320" empty-text="暂无操作记录">
<el-table-column label="操作时间" width="168">
<template #default="{ row }">{{ logTime(row) }}</template>
</el-table-column>
<el-table-column label="操作类型" width="90" align="center">
<template #default="{ row }">
<el-tag size="small" :type="logType(row.operationType)">{{ logAction(row.operationType) }}</el-tag>
</template>
</el-table-column>
<el-table-column label="更改前" min-width="200">
<template #default="{ row }">
<div v-if="blankSide(row, 'old')" class="log-empty">空</div>
<div v-else class="log-change">
<div v-for="change in row.changes" :key="change.field">{{ change.fieldLabel || change.field }}:{{ showValue(change.oldValue) }}</div>
</div>
</template>
</el-table-column>
<el-table-column label="更改后" min-width="200">
<template #default="{ row }">
<div v-if="blankSide(row, 'new')" class="log-empty">空</div>
<div v-else class="log-change">
<div v-for="change in row.changes" :key="change.field">{{ change.fieldLabel || change.field }}:{{ showValue(change.newValue) }}</div>
</div>
</template>
</el-table-column>
<el-table-column label="操作人" width="110" show-overflow-tooltip>
<template #default="{ row }">{{ row.createByName || row.createBy || '-' }}</template>
</el-table-column>
</el-table>
<el-pagination
v-model:current-page="logPageNum"
v-model:page-size="logPageSize"
class="log-pager"
:total="logTotal"
:page-sizes="[10, 20, 50]"
layout="total, sizes, prev, pager, next"
background
small
@current-change="loadLogs"
@size-change="changeLogSize"
/>
</div>
<template #footer>
<el-button @click="visible = false">取消</el-button>
<el-button type="primary" :disabled="!dirty" :loading="saving" @click="save">保存</el-button>
</template>
</el-dialog>
</template>
<script setup>
import { listAirBillFee, listAirBillFeeLog, saveAirBillFee } from '@/api/price/airBill'
import { parseTime } from '@/utils/bms'
const { proxy } = getCurrentInstance()
const { bms_fee_type, bms_currency } = useDict('bms_fee_type', 'bms_currency')
const visible = ref(false)
const loading = ref(false)
const logLoading = ref(false)
const saving = ref(false)
const billCode = ref('')
const rows = ref([])
const deletedIds = ref([])
const logs = ref([])
const logPageNum = ref(1)
const logPageSize = ref(10)
const logTotal = ref(0)
let rowSeed = 0
let logSeq = 0
const title = computed(() => billCode.value ? `提单费用 - ${billCode.value}` : '提单费用')
const dirty = computed(() => deletedIds.value.length > 0 || rows.value.some(row => rowChanged(row)))
function open(row) {
if (!row?.billCode) return
billCode.value = row.billCode
visible.value = true
load()
}
function reset() {
if (visible.value) return
billCode.value = ''
rows.value = []
deletedIds.value = []
logs.value = []
logPageNum.value = 1
logPageSize.value = 10
logTotal.value = 0
logSeq += 1
saving.value = false
loading.value = false
logLoading.value = false
}
function load() {
logPageNum.value = 1
loadFees()
loadLogs()
}
function loadFees() {
const code = billCode.value
loading.value = true
listAirBillFee(code).then(feeRes => {
if (code !== billCode.value) return
deletedIds.value = []
rows.value = (feeRes.data || []).map(item => ({
rowKey: `fee-${item.id}`,
id: item.id,
feeType: item.feeType == null ? '' : String(item.feeType),
price: item.price === null || item.price === undefined ? null : Number(item.price),
currency: item.currency || '',
remark: item.remark || '',
origin: snapshot(item)
}))
}).finally(() => {
if (code === billCode.value) loading.value = false
})
}
function unwrapLogs(res) {
const rows = res?.rows
if (Array.isArray(rows)) {
const total = Number(res.total)
return { list: rows, total: Number.isFinite(total) ? total : rows.length }
}
if (rows && Array.isArray(rows.list)) {
const total = Number(rows.total ?? res.total)
return { list: rows.list, total: Number.isFinite(total) ? total : rows.list.length }
}
if (Array.isArray(res?.data)) {
return { list: res.data, total: res.data.length }
}
return { list: [], total: 0 }
}
function loadLogs() {
const code = billCode.value
if (!code) return
const seq = ++logSeq
logLoading.value = true
listAirBillFeeLog({
billCode: code,
pageNum: logPageNum.value,
pageSize: logPageSize.value
}).then(logRes => {
if (seq !== logSeq || code !== billCode.value) return
const page = unwrapLogs(logRes)
logs.value = page.list
logTotal.value = page.total
}).finally(() => {
if (seq === logSeq && code === billCode.value) logLoading.value = false
})
}
function changeLogSize() {
logPageNum.value = 1
loadLogs()
}
function addRow() {
rowSeed += 1
rows.value.push({
rowKey: `new-${rowSeed}`,
id: null,
feeType: '',
price: null,
currency: '',
remark: '',
origin: null
})
}
function removeRow(row) {
if (row.id != null && !deletedIds.value.some(id => String(id) === String(row.id))) {
deletedIds.value.push(row.id)
}
rows.value = rows.value.filter(item => item.rowKey !== row.rowKey)
}
function snapshot(item) {
return {
feeType: item.feeType || '',
price: normPrice(item.price),
currency: item.currency || '',
remark: (item.remark || '').trim()
}
}
function currentOf(row) {
return {
feeType: row.feeType || '',
price: normPrice(row.price),
currency: row.currency || '',
remark: (row.remark || '').trim()
}
}
function normPrice(value) {
if (value === null || value === undefined || value === '') return ''
const number = Number(value)
return Number.isNaN(number) ? String(value).trim() : String(number)
}
function rowChanged(row) {
if (!row.origin) {
const now = currentOf(row)
return !!(now.feeType || now.price || now.currency || now.remark)
}
const now = currentOf(row)
return now.feeType !== row.origin.feeType || now.price !== row.origin.price
|| now.currency !== row.origin.currency || now.remark !== row.origin.remark
}
function save() {
const inserts = []
const updates = []
rows.value.forEach(row => {
if (!rowChanged(row)) return
const payload = {
feeType: row.feeType || '',
price: row.price,
currency: row.currency || '',
remark: (row.remark || '').trim()
}
if (row.id) updates.push({ id: row.id, ...payload })
else inserts.push(payload)
})
if (!inserts.length && !updates.length && !deletedIds.value.length) {
proxy.$modal.msgError('没有需要保存的变更')
return
}
saving.value = true
saveAirBillFee({ billCode: billCode.value, inserts, updates, deletes: deletedIds.value }).then(res => {
proxy.$modal.msgSuccess(res.msg || '保存成功')
load()
}).catch(() => {
load()
}).finally(() => {
saving.value = false
})
}
function logAction(type) {
return { 1: '新增', 2: '修改', 3: '删除' }[String(type)] || '维护'
}
function logType(type) {
if (String(type) === '1') return 'success'
if (String(type) === '3') return 'danger'
return 'warning'
}
function logTime(item) {
return parseTime(item.createTime) || ''
}
function showValue(value) {
return value === null || value === undefined || value === '' ? '空' : value
}
function blankSide(row, side) {
const changes = row.changes || []
if (!changes.length) return true
const key = side === 'old' ? 'oldValue' : 'newValue'
return changes.every(change => showValue(change[key]) === '空')
}
defineExpose({ open })
</script>
<style scoped>
.fee-toolbar {
display: flex;
align-items: center;
gap: 12px;
margin-bottom: 10px;
}
.fee-hint {
color: var(--el-text-color-secondary);
font-size: 12px;
}
.log-title {
margin: 16px 0 8px;
font-weight: 600;
}
.log-change {
line-height: 1.7;
white-space: normal;
}
.log-empty {
color: var(--el-text-color-secondary);
}
.log-pager {
margin-top: 10px;
justify-content: flex-end;
}
</style>
@@ -0,0 +1,265 @@
<template>
<el-drawer
:model-value="modelValue"
:title="title"
size="860px"
append-to-body
destroy-on-close
@update:model-value="$emit('update:modelValue', $event)"
>
<div class="hist-wrap" v-loading="loading">
<el-table :data="rows" border height="calc(100vh - 220px)" :empty-text="emptyText">
<el-table-column :label="colTime" width="170" align="center" prop="updateTime" />
<el-table-column :label="colAction" width="100" align="center">
<template #default="{ row }">
<el-tag size="small" :type="actionTag(row)">{{ actionLabel(row) }}</el-tag>
</template>
</el-table-column>
<el-table-column :label="colStatus" width="90" align="center">
<template #default="{ row }">
<el-tag size="small" :type="statusTag(row.status)">{{ statusLabel(row.status) }}</el-tag>
</template>
</el-table-column>
<el-table-column :label="colSet" min-width="150" show-overflow-tooltip>
<template #default="{ row }">{{ priceSetOf(row) }}</template>
</el-table-column>
<el-table-column :label="colVer" width="90" align="center">
<template #default="{ row }">{{ versionOf(row) }}</template>
</el-table-column>
<el-table-column :label="colPsd" width="100" align="center">
<template #default="{ row }">{{ psdOf(row) }}</template>
</el-table-column>
<el-table-column :label="colAmount" width="110" align="right">
<template #default="{ row }">{{ amountOf(row) }}</template>
</el-table-column>
<el-table-column :label="colOps" width="80" align="center" fixed="right">
<template #default="{ row }">
<el-button link type="primary" @click="openDetail(row)">查看</el-button>
</template>
</el-table-column>
</el-table>
<div class="pager">
<el-pagination
v-model:current-page="query.pageNum"
v-model:page-size="query.pageSize"
:total="total"
:page-sizes="[10, 20, 50]"
layout="total, sizes, prev, pager, next"
@size-change="reload"
@current-change="reload"
/>
</div>
</div>
<el-drawer v-model="detailOpen" size="720px" :title="detailTitle" append-to-body destroy-on-close>
<div v-if="!active">
<el-empty :description="emptyDetail" />
</div>
<div v-else>
<el-descriptions :column="2" border size="small" class="mb12">
<el-descriptions-item :label="colTime">{{ active.updateTime || '-' }}</el-descriptions-item>
<el-descriptions-item :label="colAction">{{ actionLabel(active) }}</el-descriptions-item>
<el-descriptions-item :label="colStatus">{{ statusLabel(active.status) }}</el-descriptions-item>
<el-descriptions-item :label="colSet">{{ priceSetOf(active) }}</el-descriptions-item>
<el-descriptions-item :label="colVer">{{ versionOf(active) }}</el-descriptions-item>
<el-descriptions-item :label="colPsd">{{ psdOf(active) }}</el-descriptions-item>
<el-descriptions-item :label="colAmount">{{ amountOf(active) }}</el-descriptions-item>
<el-descriptions-item :label="lbMatch">{{ matchMsgOf(active) }}</el-descriptions-item>
<el-descriptions-item v-if="active.errorMessage" :label="lbError" :span="2">
<span class="err">{{ active.errorMessage }}</span>
</el-descriptions-item>
</el-descriptions>
<div class="json-panel">
<div class="json-panel__head">请求报文</div>
<pre class="code-pre">{{ formatJson(active.requestJson) }}</pre>
</div>
<div class="json-panel">
<div class="json-panel__head">返回报文</div>
<pre class="code-pre">{{ formatJson(active.responseJson) }}</pre>
</div>
</div>
</el-drawer>
</el-drawer>
</template>
<script setup name="BillBillingHistoryDrawer">
import { listBillHistory } from '@/api/price/billing'
const props = defineProps({
modelValue: { type: Boolean, default: false },
billId: { type: String, default: '' },
orderNo: { type: String, default: '' }
})
defineEmits(['update:modelValue'])
const loading = ref(false)
const rows = ref([])
const total = ref(0)
const query = reactive({ pageNum: 1, pageSize: 10 })
const detailOpen = ref(false)
const active = ref(null)
const emptyText = '暂无历史计费记录'
const emptyDetail = '暂无详情'
const colTime = '写入时间'
const colAction = '类型'
const colStatus = '状态'
const colSet = '套餐'
const colVer = '版本'
const colPsd = '明细ID'
const colAmount = '应收总额'
const colOps = '操作'
const lbMatch = '命中说明'
const lbError = '错误信息'
const title = computed(() => {
const no = props.orderNo || ''
return no ? '历史计费记录 · ' + no : '历史计费记录'
})
const detailTitle = computed(() => '计费记录详情')
function parseJson(val) {
if (val == null || val === '') return {}
if (typeof val === 'object') return val
try { return JSON.parse(val) } catch (e) { return {} }
}
function respOf(row) {
return parseJson(row && row.responseJson)
}
function reqOf(row) {
return parseJson(row && row.requestJson)
}
function actionLabel(row) {
const req = reqOf(row)
if (req.action === 'UPSTREAM_SYNC') return '上游同步'
if (row && row.status === 'FAIL') return '计费失败'
const resp = respOf(row)
if (resp.matchSource === 'BILLING_FAIL' || resp.billingFailStatus) return '计费失败'
return '计费'
}
function actionTag(row) {
const label = actionLabel(row)
if (label === '上游同步') return 'info'
if (label === '计费失败') return 'danger'
return 'success'
}
function statusLabel(status) {
return status === 'FAIL' ? '失败' : '成功'
}
function statusTag(status) {
return status === 'FAIL' ? 'danger' : 'success'
}
function priceSetOf(row) {
const r = respOf(row)
if (r.priceSetName && r.priceSetCode) return r.priceSetName + ' (' + r.priceSetCode + ')'
return r.priceSetName || r.priceSetCode || (r.priceSetId != null ? String(r.priceSetId) : '-')
}
function versionOf(row) {
const r = respOf(row)
if (r.versionNo) return r.versionNo
return r.psvId != null ? ('psv=' + r.psvId) : '-'
}
function psdOf(row) {
const r = respOf(row)
return r.psdId != null ? String(r.psdId) : '-'
}
function amountOf(row) {
const r = respOf(row)
const v = r.incomeTotal != null ? r.incomeTotal : r.payableTotal
if (v == null || v === '') return '-'
const n = Number(v)
return Number.isNaN(n) ? String(v) : n.toFixed(2)
}
function matchMsgOf(row) {
return respOf(row).matchMessage || '-'
}
function formatJson(val) {
if (val == null || val === '') return '无数据'
if (typeof val === 'object') {
try { return JSON.stringify(val, null, 2) } catch (e) { return String(val) }
}
try { return JSON.stringify(JSON.parse(val), null, 2) } catch (e) { return String(val) }
}
function openDetail(row) {
active.value = row
detailOpen.value = true
}
async function reload() {
if (!props.billId) {
rows.value = []
total.value = 0
return
}
loading.value = true
try {
const res = await listBillHistory(props.billId, {
pageNum: query.pageNum,
pageSize: query.pageSize
})
rows.value = res.rows || []
total.value = Number(res.total) || 0
} finally {
loading.value = false
}
}
watch(
() => [props.modelValue, props.billId],
([open]) => {
if (open) {
query.pageNum = 1
detailOpen.value = false
active.value = null
reload()
}
}
)
</script>
<style scoped>
.hist-wrap { min-height: 200px; }
.pager {
display: flex;
justify-content: flex-end;
margin-top: 12px;
}
.mb12 { margin-bottom: 12px; }
.err { color: #f56c6c; word-break: break-all; }
.json-panel {
margin-bottom: 12px;
background: #f7f9fb;
border: 1px solid #e8ecf0;
border-radius: 6px;
overflow: hidden;
}
.json-panel__head {
padding: 8px 12px;
font-size: 13px;
font-weight: 600;
color: #606266;
background: #fafbfc;
border-bottom: 1px solid #ebeef5;
}
.code-pre {
margin: 0;
padding: 12px 14px;
max-height: 260px;
overflow: auto;
white-space: pre-wrap;
word-break: break-all;
}
</style>
@@ -41,7 +41,17 @@
</section>
<section class="detail-block">
<div class="sec-title">计费信息</div>
<div class="sec-title">
计费信息
<el-button
v-if="detail && detail.billId"
type="primary"
link
size="small"
class="hist-btn"
@click="historyOpen = true"
>历史计费</el-button>
</div>
<div class="amount-summary">
<div class="amount-card">
<div class="amount-label">运费金额</div>
@@ -187,6 +197,11 @@
:current-charge-weight="detail?.chargeWeight"
@success="onChargeWeightUpdated"
/>
<bill-billing-history-drawer
v-model="historyOpen"
:bill-id="detail?.billId || ''"
:order-no="detail?.orderNo || ''"
/>
</el-drawer>
</template>
@@ -196,6 +211,8 @@ import EditChargeWeightDialog from './EditChargeWeightDialog.vue'
import { deleteIncomeBillFee, getBill } from '@/api/price/billing'
import { generatePayBill } from '@/api/price/pay'
import { ElMessage, ElMessageBox } from 'element-plus'
import BillBillingHistoryDrawer from './BillBillingHistoryDrawer.vue'
import { deleteIncomeBillFee } from '@/api/price/billing'
const { proxy } = getCurrentInstance()
@@ -210,6 +227,7 @@ const props = defineProps({
const emit = defineEmits(['update:modelValue', 'updated'])
const feeTab = ref('income')
const historyOpen = ref(false)
const addFeeOpen = ref(false)
const editFeeRow = ref(null)
const editCwOpen = ref(false)
@@ -229,6 +247,7 @@ const payFees = computed(() => {
watch(() => props.detail, () => {
feeTab.value = 'income'
historyOpen.value = false
})
function handlePayBill() {
@@ -493,6 +512,9 @@ function refundLabel(status) {
border-radius: 2px;
background: var(--el-color-primary);
}
.hist-btn {
margin-left: auto;
}
.amount-summary {
display: grid;
grid-template-columns: repeat(5, 1fr);