增加可修改计费重功能

This commit is contained in:
wuweihua
2026-10-14 15:25:26 +08:00
parent 2d7bd678f3
commit 6a50b0f122
16 changed files with 1306 additions and 10 deletions
+211 -2
View File
@@ -83,9 +83,26 @@
@click="openBatchFee"
>批量增加费用</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="Upload"
v-hasPermi="['price:billing:chargeWeightEdit']"
@click="openChargeWeightImport"
>批量修改计费重</el-button>
</el-col>
</template>
<template #col-action="{ row }">
<el-button link type="primary" icon="View" @click="handleView(row)">查看</el-button>
<el-button
link
type="primary"
icon="Edit"
:disabled="row.refundStatus === 'REFUNDED'"
v-hasPermi="['price:billing:chargeWeightEdit']"
@click="openEditChargeWeight(row)"
>改计费重</el-button>
<el-button
link
type="danger"
@@ -106,15 +123,61 @@
:selected-ids="batchFeeSelectedIds"
@success="onBatchFeeSuccess"
/>
<edit-charge-weight-dialog
v-model="editCwOpen"
:bill-id="editCwRow?.billId || ''"
:order-no="editCwRow?.orderNo || ''"
:origin-weight="editCwRow?.weight"
:current-charge-weight="editCwRow?.chargeWeight"
@success="onChargeWeightUpdated"
/>
<excel-import-dialog
ref="chargeWeightImportRef"
title="批量修改计费重"
width="520px"
action="/price/billing/bill/chargeWeight/importData"
template-file-name="批量修改计费重导入模板"
:show-update-support="false"
:import-desc="chargeWeightImportDesc"
:template-download-handler="downloadChargeWeightImportTemplate"
:submit-handler="runChargeWeightImportAsync"
@success="onChargeWeightImportSuccess"
>
<template #extra>
<el-checkbox v-model="cwFillByFilter">按当前筛选条件带出订单号和客户</el-checkbox>
<div class="cw-fill-hint">勾选后下载模板会写入筛选结果的订单号、客户代码;人工修改计费重列留空待填</div>
</template>
</excel-import-dialog>
<el-dialog
v-model="cwImportProgressVisible"
title="正在导入修改计费重"
width="420px"
:close-on-click-modal="false"
:close-on-press-escape="false"
:show-close="false"
append-to-body
>
<div class="import-progress">
<el-progress
:percentage="cwImportProgressPercent"
:status="cwImportProgressStatus"
:indeterminate="cwImportProgressIndeterminate"
:stroke-width="10"
/>
<div class="import-progress-msg">{{ cwImportProgressMessage }}</div>
</div>
</el-dialog>
</div>
</template>
<script setup name="BillingBill">
import { listBill, getBill, refundBill, listOrderNoOptions, listTrackingNoOptions, listTransferNoOptions, updateCreditArrears } from '@/api/price/billing'
import { listBill, getBill, refundBill, listOrderNoOptions, listTrackingNoOptions, listTransferNoOptions, updateCreditArrears, importChargeWeightAsync, downloadChargeWeightTemplate } from '@/api/price/billing'
import { ElMessage, ElMessageBox } from 'element-plus'
import { useProducts } from '@/components/ProductSelect/useProducts'
import BillDetail from './components/BillDetail.vue'
import BatchAddIncomeFeeDialog from './components/BatchAddIncomeFeeDialog.vue'
import EditChargeWeightDialog from './components/EditChargeWeightDialog.vue'
import ExcelImportDialog from '@/components/ExcelImportDialog'
// 订单号下拉远程搜索:返回匹配的订单号列表(最多 20 条)
function searchOrderNoOptions(keyword) {
@@ -149,6 +212,21 @@ const batchFeeOpen = ref(false)
const batchFeeListQuery = ref({})
const batchFeeSelectedIds = ref([])
const refundingKey = ref(null)
const editCwOpen = ref(false)
const editCwRow = ref(null)
const chargeWeightImportRef = ref()
const chargeWeightImportDesc = [
'模板列:订单号、客户、人工修改计费重(kg)',
'客户可填名称或代码,须与订单客户一致',
'导入后异步写入计费重并重新计费;原计费重(weight)不覆盖',
'下载模板可选:按当前列表筛选条件带出订单号和客户'
]
const cwFillByFilter = ref(false)
const cwImportProgressVisible = ref(false)
const cwImportProgressPercent = ref(0)
const cwImportProgressMessage = ref('')
const cwImportProgressStatus = ref(undefined)
const cwImportProgressIndeterminate = ref(false)
const columns = [
{ label: '订单号', prop: 'orderNo', minWidth: 140, showOverflowTooltip: true },
@@ -160,6 +238,7 @@ const columns = [
{ label: '国家', prop: 'country', minWidth: 130, slot: 'country' },
{ label: '件数', prop: 'pieces', align: 'center', width: 70 },
{ label: '计费重', prop: 'chargeWeight', align: 'center', width: 90, slot: 'chargeWeight' },
{ label: '原计费重', prop: 'weight', align: 'center', width: 100, slot: 'chargeWeight' },
{ label: '收货重', prop: 'receiveWeight', align: 'center', width: 90, slot: 'chargeWeight' },
{ label: '应收总额', prop: 'incomeTotal', align: 'right', width: 120, slot: 'incomeTotal' },
{ label: '应付总额', prop: 'payTotal', align: 'right', width: 120, slot: 'payTotal' },
@@ -172,7 +251,7 @@ const columns = [
{ label: '销售员', prop: 'belongSaler', minWidth: 100, showOverflowTooltip: true },
{ label: '结算员', prop: 'settlementMan', minWidth: 100, showOverflowTooltip: true },
// { label: '客服员', prop: 'serviceMan', minWidth: 100, showOverflowTooltip: true },
{ label: '操作', prop: 'action', align: 'center', width: 160, fixed: 'right', slot: 'action', showInToolbar: false }
{ label: '操作', prop: 'action', align: 'center', width: 240, fixed: 'right', slot: 'action', showInToolbar: false }
]
const arrearsStatusOptions = [
@@ -316,6 +395,120 @@ function onBatchFeeSuccess() {
tableRef.value?.refresh?.()
}
function openEditChargeWeight(row) {
if (!row || !row.billId) return
if (row.refundStatus === 'REFUNDED') {
ElMessage.warning('该订单已退费')
return
}
editCwRow.value = row
editCwOpen.value = true
}
function onChargeWeightUpdated() {
tableRef.value?.refresh?.()
}
function buildChargeWeightTemplateQuery() {
const q = tableRef.value?.getQueryParams?.() || {}
const { pageNum, pageSize, bizDateRange, ...rest } = q
const payload = {
fillByFilter: !!cwFillByFilter.value,
orderNos: rest.orderNos || [],
trackingNos: rest.trackingNos || [],
transferNos: rest.transferNos || [],
customerCodes: rest.customerCodes || [],
productCodes: rest.productCodes || [],
creditArrearsStatus: rest.creditArrearsStatus || undefined
}
if (Array.isArray(bizDateRange) && (bizDateRange[0] || bizDateRange[1])) {
payload.beginBizDate = bizDateRange[0] || null
payload.endBizDate = bizDateRange[1] || null
}
return payload
}
async function downloadChargeWeightImportTemplate() {
const payload = buildChargeWeightTemplateQuery()
if (payload.fillByFilter && !hasBatchFeeQuery(tableRef.value?.getQueryParams?.() || {})) {
throw new Error('请先设置列表筛选条件')
}
await downloadChargeWeightTemplate(payload)
}
function openChargeWeightImport() {
cwFillByFilter.value = false
chargeWeightImportRef.value?.open?.()
}
function applyCwImportProgress(t) {
cwImportProgressIndeterminate.value = false
cwImportProgressPercent.value = Math.min(100, Number(t.percent) || 0)
const total = Number(t.total) || 0
const success = Number(t.success) || 0
const fail = Number(t.fail) || 0
if (t.status === 'PENDING') {
cwImportProgressMessage.value = '\u6392\u961f\u4e2d\u2026'
} else if (t.status === 'RUNNING') {
if (total > 0) {
cwImportProgressMessage.value = '\u6b63\u5728\u5904\u7406 ' + success + '/' + total +
(fail ? ('\uff08\u5931\u8d25 ' + fail + '\uff09') : '')
} else {
cwImportProgressMessage.value = t.message || '\u6b63\u5728\u5bfc\u5165\u2026'
}
} else if (t.status === 'SUCCESS') {
cwImportProgressMessage.value = '\u5b8c\u6210\uff1a\u6210\u529f ' + success + '\uff0c\u5931\u8d25 ' + fail
cwImportProgressStatus.value = fail > 0 ? 'warning' : 'success'
} else if (t.status === 'FAIL') {
cwImportProgressMessage.value = t.error || t.message || '\u5bfc\u5165\u5931\u8d25'
cwImportProgressStatus.value = 'exception'
}
}
async function runChargeWeightImportAsync(uploadFile) {
const raw = uploadFile && (uploadFile.raw || uploadFile)
if (!raw) throw new Error('\u8bf7\u5148\u9009\u62e9\u6587\u4ef6')
// Close import dialog so progress dialog is the only visible wait UI
chargeWeightImportRef.value?.close?.()
cwImportProgressVisible.value = true
cwImportProgressPercent.value = 0
cwImportProgressIndeterminate.value = true
cwImportProgressMessage.value = '\u6b63\u5728\u89e3\u6790Excel\u5e76\u6821\u9a8c\u8ba2\u5355\uff0c\u8bf7\u7a0d\u5019\u2026'
cwImportProgressStatus.value = undefined
try {
const { task } = await importChargeWeightAsync(raw, applyCwImportProgress)
cwImportProgressIndeterminate.value = false
cwImportProgressPercent.value = 100
const success = Number(task && task.success) || 0
const fail = Number(task && task.fail) || 0
const tip = '\u5bfc\u5165\u5b8c\u6210\uff1a\u6210\u529f ' + success + '\uff0c\u5931\u8d25 ' + fail
if (fail > 0) {
cwImportProgressStatus.value = 'warning'
cwImportProgressMessage.value = tip + (task && task.error ? ('\uff1b' + task.error) : '')
await new Promise(resolve => setTimeout(resolve, 1500))
return tip + (task && task.error ? ('\uff1b' + task.error) : '')
}
cwImportProgressStatus.value = 'success'
cwImportProgressMessage.value = tip
await new Promise(resolve => setTimeout(resolve, 1200))
return tip
} catch (e) {
cwImportProgressIndeterminate.value = false
cwImportProgressStatus.value = 'exception'
const tip = (e && e.task && e.task.error) || (e && e.message) || '\u5bfc\u5165\u5931\u8d25'
cwImportProgressMessage.value = tip
await new Promise(resolve => setTimeout(resolve, 1200))
throw e
} finally {
cwImportProgressVisible.value = false
cwImportProgressIndeterminate.value = false
}
}
function onChargeWeightImportSuccess() {
tableRef.value?.refresh?.()
}
function formatMoney(val) {
if (val === null || val === undefined || val === '') return '-'
const num = Number(val)
@@ -388,6 +581,22 @@ function refundTagType(status) {
font-weight: 600;
font-variant-numeric: tabular-nums;
}
.cw-fill-hint {
margin-top: 6px;
font-size: 12px;
color: var(--el-text-color-secondary);
line-height: 1.5;
}
.import-progress { padding: 8px 4px 4px; }
.import-progress-msg {
margin-top: 12px;
color: var(--el-text-color-secondary);
font-size: 13px;
line-height: 1.5;
word-break: break-word;
max-height: 160px;
overflow: auto;
}
/* 搜索栏走 BasicTable search-per-row=4 的栅格布局(固定 4 项一行,多余换行),
这里只补齐插槽渲染的控件宽度,不再覆盖 BasicForm 的布局 */