This commit is contained in:
wuweihua
2026-09-17 10:00:13 +08:00
48 changed files with 1871 additions and 1815 deletions
+6 -1
View File
@@ -1,6 +1,6 @@
<template>
<div class="app-container ar-bill-page">
<basic-table ref="tableRef" :columns="columns" :search-columns="searchColumns" :search-label-width="82" :query="queryList" row-key="arBillId" :selection="false">
<basic-table ref="tableRef" :columns="columns" :search-columns="searchColumns" :search-label-width="82" :query="queryList" :default-params="defaultSearchParams" row-key="arBillId" :selection="false">
<template #toolbar>
<el-col :span="1.5"><el-button type="primary" plain icon="Plus" v-hasPermi="['ar:bill:generate']" @click="generateOpen = true">生成账单</el-button></el-col>
</template>
@@ -32,7 +32,12 @@ import GenerateBillDialog from './components/GenerateBillDialog.vue'
import { AR_BILL_STATUS, AR_BILL_STATUS_OPTIONS, AR_BILL_STATUS_TYPES } from '@/constants/ar/bill'
const { proxy } = getCurrentInstance()
const route = useRoute()
const tableRef = ref()
// 从客户余额页“查看账单”跳入时,按当前客户预筛选(重置后仍保留该条件)
const defaultSearchParams = computed(() => ({
customerId: route.query.customerId ? Number(route.query.customerId) : undefined
}))
const detailOpen = ref(false)
const detailLoading = ref(false)
const detail = ref(null)
+3 -3
View File
@@ -10,7 +10,7 @@
import { listArBillLogs } from '@/api/ar/bill'
const tableRef = ref()
const searchColumns = [
{ label: '对象类型', prop: 'objectType', component: 'select', options: [{ label: '应收账单', value: 'BILL' }, { label: '账单导出', value: 'EXPORT' }, { label: '应收收款', value: 'RECEIPT' }, { label: '收款核销', value: 'WRITEOFF' }], width: '130px' },
{ label: '对象类型', prop: 'objectType', component: 'select', options: [{ label: '应收账单', value: 'BILL' }, { label: '账单导出', value: 'EXPORT' }, { label: '余额核销', value: 'BALANCE_WRITEOFF' }], width: '130px' },
{ label: '操作类型', prop: 'operationType', component: 'input', width: '140px' }, { label: '结果', prop: 'result', component: 'select', options: [{ label: '成功', value: 'SUCCESS' }, { label: '失败', value: 'FAILED' }], width: '120px' }
]
const columns = [
@@ -20,8 +20,8 @@ const columns = [
{ label: '结果', prop: 'result', width: 90, slot: 'result' }, { label: '时间', prop: 'createTime', width: 170, parseTime: true }
]
const objectTypeLabels = { BILL: '应收账单', EXPORT: '账单导出', RECEIPT: '应收收款', WRITEOFF: '收款核销' }
const operationLabels = { CONFIRM: '确认账单', VOID: '作废账单', EXPORT: '导出账单', RECEIPT: '登记收款', CANCEL_RECEIPT: '取消收款', WRITEOFF: '收款核销', CANCEL_WRITEOFF: '取消核销' }
const objectTypeLabels = { BILL: '应收账单', EXPORT: '账单导出', BALANCE_WRITEOFF: '余额核销' }
const operationLabels = { CONFIRM: '确认账单', VOID: '作废账单', EXPORT: '导出账单', BALANCE_WRITEOFF: '余额核销', CANCEL_BALANCE_WRITEOFF: '取消余额核销' }
const statusLabels = { DRAFT: '草稿', CONFIRMED: '已确认', PARTIAL_WRITTEN_OFF: '部分核销', WRITTEN_OFF: '已核销', VOID: '已作废', REGISTERED: '已登记', CANCELLED: '已取消', EFFECTIVE: '有效' }
function objectTypeText(value) { return objectTypeLabels[value] || value || '-' }
function operationText(value) { return operationLabels[value] || value || '-' }
-105
View File
@@ -1,105 +0,0 @@
<template>
<div class="app-container ar-receipt-page">
<basic-table ref="tableRef" :columns="columns" :search-columns="searchColumns" :query="queryList" row-key="receiptId" :selection="false">
<template #search-customerId="{ model }">
<customer-select v-model="model.customerId" placeholder="请选择客户" class="receipt-customer-search" />
</template>
<template #toolbar><el-col :span="1.5"><el-button type="primary" plain icon="Plus" v-hasPermi="['ar:receipt:add']" @click="openRegister">登记收款</el-button></el-col></template>
<template #col-receiptAmount="{ row }"><span class="income">{{ row.currency }} {{ money(row.receiptAmount) }}</span></template>
<template #col-unallocatedAmount="{ row }"><span class="pending">{{ money(row.unallocatedAmount) }}</span></template>
<template #col-status="{ row }"><el-tag :type="receiptStatusType(row.status)">{{ receiptStatusText(row.status) }}</el-tag></template>
<template #col-action="{ row }">
<el-button v-if="row.status !== 'CANCELLED' && Number(row.unallocatedAmount) > 0" link type="primary" v-hasPermi="['ar:receipt:writeoff']" @click="openWriteoff(row)">核销</el-button>
<el-button v-if="row.status === 'REGISTERED'" link type="warning" v-hasPermi="['ar:receipt:cancel']" @click="cancelReceipt(row)">取消收款</el-button>
<el-button link type="primary" @click="openWriteoffHistory(row)">核销记录</el-button>
</template>
</basic-table>
<el-dialog v-model="registerOpen" title="登记应收收款" width="620px" append-to-body>
<el-form ref="registerFormRef" :model="registerForm" :rules="registerRules" label-width="110px">
<el-row :gutter="12">
<el-col :span="12"><el-form-item label="客户" prop="customerId"><customer-select v-model="registerForm.customerId" placeholder="请选择客户" /></el-form-item></el-col>
<el-col :span="12"><el-form-item label="到账日期" prop="receiptDate"><el-date-picker v-model="registerForm.receiptDate" type="date" value-format="YYYY-MM-DD" style="width: 100%;" /></el-form-item></el-col>
<el-col :span="12"><el-form-item label="到账金额" prop="receiptAmount"><el-input v-model="registerForm.receiptAmount" type="number" /></el-form-item></el-col>
<el-col :span="12"><el-form-item label="币种"><el-select v-model="registerForm.currency" style="width: 100%;"><el-option label="人民币 CNY" value="CNY" /><el-option label="美元 USD" value="USD" /></el-select></el-form-item></el-col>
<el-col :span="12"><el-form-item label="收款方式"><el-select v-model="registerForm.paymentMethod" style="width: 100%;"><el-option label="银行转账" value="BANK" /><el-option label="支付宝" value="ALIPAY" /><el-option label="微信" value="WECHAT" /><el-option label="现金" value="CASH" /></el-select></el-form-item></el-col>
<el-col :span="12"><el-form-item label="银行流水号"><el-input v-model="registerForm.bankReference" /></el-form-item></el-col>
<el-col :span="24"><el-form-item label="收款单号"><el-input v-model="registerForm.receiptNo" placeholder="不填则自动生成" /></el-form-item></el-col>
<el-col :span="24"><el-form-item label="备注"><el-input v-model="registerForm.remark" type="textarea" :rows="2" /></el-form-item></el-col>
</el-row>
</el-form>
<template #footer><el-button type="primary" :loading="registerLoading" @click="submitRegister">登记</el-button><el-button @click="registerOpen = false">取消</el-button></template>
</el-dialog>
<el-dialog v-model="writeoffOpen" title="批量核销收款" width="680px" append-to-body>
<el-descriptions :column="3" border size="small" class="writeoff-summary"><el-descriptions-item label="收款单号">{{ writeoffForm.receiptNo }}</el-descriptions-item><el-descriptions-item label="币种">{{ writeoffForm.currency }}</el-descriptions-item><el-descriptions-item label="可核销">{{ money(writeoffForm.unallocatedAmount) }}</el-descriptions-item></el-descriptions>
<el-form label-width="90px" class="allocation-form"><div v-for="(item, index) in writeoffForm.allocations" :key="index" class="allocation-row"><el-form-item label="账单"><el-select v-model="item.arBillId" filterable clearable :loading="billLoading" placeholder="请选择账单" class="bill-select"><el-option v-for="bill in billOptions" :key="bill.arBillId" :label="billOptionLabel(bill)" :value="bill.arBillId" /></el-select></el-form-item><el-form-item label="核销金额"><el-input v-model="item.amount" type="number" /></el-form-item><el-button v-if="writeoffForm.allocations.length > 1" link type="danger" icon="Delete" @click="removeAllocation(index)" /></div><div v-if="writeoffOpen && !billLoading && !billOptions.length" class="bill-empty">当前客户暂无可核销账单</div><el-button link type="primary" icon="Plus" @click="addAllocation">添加账单</el-button><el-form-item label="核销日期"><el-date-picker v-model="writeoffForm.writeoffDate" type="date" value-format="YYYY-MM-DD" /></el-form-item><el-form-item label="备注"><el-input v-model="writeoffForm.remark" /></el-form-item></el-form>
<template #footer><el-button type="primary" :loading="writeoffLoading" @click="submitWriteoff">确认核销</el-button><el-button @click="writeoffOpen = false">取消</el-button></template>
</el-dialog>
<el-dialog v-model="historyOpen" title="核销记录" width="820px" append-to-body>
<el-table :data="historyRows" border size="small" v-loading="historyLoading">
<el-table-column prop="writeoffNo" label="核销单号" min-width="180" />
<el-table-column prop="billNo" label="账单号" min-width="180" show-overflow-tooltip />
<el-table-column prop="writeoffAmount" label="核销金额" width="120" align="right"><template #default="{ row }">{{ money(row.writeoffAmount) }}</template></el-table-column>
<el-table-column prop="writeoffDate" label="核销日期" width="120" />
<el-table-column prop="status" label="状态" width="100"><template #default="{ row }"><el-tag :type="row.status === 'EFFECTIVE' ? 'success' : 'info'">{{ row.status === 'EFFECTIVE' ? '有效' : '已取消' }}</el-tag></template></el-table-column>
<el-table-column label="操作" width="90"><template #default="{ row }"><el-button v-if="row.status === 'EFFECTIVE'" link type="danger" v-hasPermi="['ar:receipt:cancel']" @click="cancelWriteoff(row)">取消</el-button></template></el-table-column>
</el-table>
</el-dialog>
</div>
</template>
<script setup name="ArReceipt">
import { listArReceipt, addArReceipt, cancelArReceipt, listArWriteoffs, writeoffArReceipt, cancelArWriteoff } from '@/api/ar/receipt'
import { listArBill } from '@/api/ar/bill'
const { proxy } = getCurrentInstance()
const tableRef = ref()
const registerOpen = ref(false), registerLoading = ref(false), registerFormRef = ref()
const writeoffOpen = ref(false), writeoffLoading = ref(false)
const billLoading = ref(false), billOptions = ref([])
const historyOpen = ref(false), historyLoading = ref(false), historyRows = ref([]), historyReceiptId = ref(null)
const today = () => proxy.parseTime(new Date(), '{y}-{m}-{d}')
const registerForm = reactive({ customerId: '', receiptDate: today(), receiptAmount: '', currency: 'CNY', paymentMethod: 'BANK', bankReference: '', receiptNo: '', remark: '' })
const registerRules = { customerId: [{ required: true, message: '请选择客户', trigger: 'change' }], receiptDate: [{ required: true, message: '到账日期不能为空', trigger: 'change' }], receiptAmount: [{ required: true, message: '到账金额不能为空', trigger: 'blur' }] }
const writeoffForm = reactive({ receiptId: null, receiptNo: '', currency: '', unallocatedAmount: 0, writeoffDate: today(), remark: '', allocations: [{ arBillId: '', amount: '' }] })
const columns = [
{ label: '收款单号', prop: 'receiptNo', minWidth: 190, showOverflowTooltip: true }, { label: '客户', prop: 'customerName', minWidth: 180, showOverflowTooltip: true, formatter: row => customerText(row) }, { label: '到账日期', prop: 'receiptDate', width: 120 },
{ label: '到账金额', prop: 'receiptAmount', width: 135, align: 'right', slot: 'receiptAmount' }, { label: '未分配', prop: 'unallocatedAmount', width: 120, align: 'right', slot: 'unallocatedAmount' },
{ label: '收款方式', prop: 'paymentMethod', width: 110, formatter: row => methodText(row.paymentMethod) }, { label: '流水号', prop: 'bankReference', minWidth: 160, showOverflowTooltip: true },
{ label: '状态', prop: 'status', width: 120, slot: 'status' }, { label: '登记人', prop: 'createBy', width: 100 }, { label: '操作', prop: 'action', width: 150, fixed: 'right', slot: 'action', showInToolbar: false }
]
const searchColumns = [
{ label: '客户', prop: 'customerId', component: 'input', width: '160px' }, { label: '收款单号', prop: 'receiptNo', component: 'input', width: '180px' },
{ label: '状态', prop: 'status', component: 'select', options: [{ label: '已登记', value: 'REGISTERED' }, { label: '部分核销', value: 'PARTIAL_WRITTEN_OFF' }, { label: '已核销', value: 'WRITTEN_OFF' }, { label: '已取消', value: 'CANCELLED' }], width: '140px' },
{ label: '到账日期', prop: 'dateRange', component: 'daterange', width: '280px' }
]
function queryList(params) { const query = { ...params }; if (query.dateRange?.length === 2) { query.receiptDateStart = query.dateRange[0]; query.receiptDateEnd = query.dateRange[1] }; delete query.dateRange; return listArReceipt(query) }
function openRegister() { Object.assign(registerForm, { customerId: '', receiptDate: today(), receiptAmount: '', currency: 'CNY', paymentMethod: 'BANK', bankReference: '', receiptNo: '', remark: '' }); registerOpen.value = true; nextTick(() => registerFormRef.value?.clearValidate()) }
function submitRegister() { registerFormRef.value.validate(valid => { if (!valid) return; registerLoading.value = true; const data = { ...registerForm, customerId: Number(registerForm.customerId), receiptAmount: String(registerForm.receiptAmount) }; addArReceipt(data).then(() => { proxy.$modal.msgSuccess('收款登记成功'); registerOpen.value = false; tableRef.value.refresh() }).finally(() => { registerLoading.value = false }) }) }
function cancelReceipt(row) { proxy.$modal.confirm(`确认取消收款「${row.receiptNo}」?`).then(() => cancelArReceipt(row.receiptId, { remark: '页面取消收款' })).then(() => { proxy.$modal.msgSuccess('收款已取消'); tableRef.value.refresh() }).catch(() => {}) }
function openWriteoff(row) { Object.assign(writeoffForm, { receiptId: row.receiptId, receiptNo: row.receiptNo, currency: row.currency, unallocatedAmount: row.unallocatedAmount, writeoffDate: today(), remark: '', allocations: [{ arBillId: '', amount: '' }] }); billOptions.value = []; writeoffOpen.value = true; loadBillOptions(row) }
function loadBillOptions(row) { billLoading.value = true; return listArBill({ pageNum: 1, pageSize: 1000, customerId: row.customerId, currency: row.currency }).then(res => { billOptions.value = (res.rows || []).filter(bill => ['CONFIRMED', 'PARTIAL_WRITTEN_OFF'].includes(bill.status) && Number(bill.unwrittenAmount) > 0) }).finally(() => { billLoading.value = false }) }
function billOptionLabel(bill) { return `${bill.billNo || '未命名账单'}(未核销:${money(bill.unwrittenAmount)})` }
function addAllocation() { writeoffForm.allocations.push({ arBillId: '', amount: '' }) }
function removeAllocation(index) { writeoffForm.allocations.splice(index, 1) }
function submitWriteoff() { const allocations = writeoffForm.allocations.filter(item => item.arBillId && item.amount).map(item => ({ arBillId: Number(item.arBillId), amount: String(item.amount) })); if (!allocations.length) { proxy.$modal.msgError('请至少填写一条账单核销金额'); return }; writeoffLoading.value = true; writeoffArReceipt({ receiptId: writeoffForm.receiptId, currency: writeoffForm.currency, writeoffDate: writeoffForm.writeoffDate, remark: writeoffForm.remark, allocations }).then(() => { proxy.$modal.msgSuccess('核销成功'); writeoffOpen.value = false; tableRef.value.refresh(); if (historyOpen.value) openWriteoffHistory({ receiptId: writeoffForm.receiptId }) }).finally(() => { writeoffLoading.value = false }) }
function openWriteoffHistory(row) { historyReceiptId.value = row.receiptId; historyOpen.value = true; historyLoading.value = true; listArWriteoffs(row.receiptId).then(res => { historyRows.value = res.data || [] }).finally(() => { historyLoading.value = false }) }
function cancelWriteoff(row) { proxy.$modal.confirm(`确认取消核销「${row.writeoffNo}」?`).then(() => cancelArWriteoff(row.writeoffId, { remark: '页面取消核销' })).then(() => { proxy.$modal.msgSuccess('核销已取消'); openWriteoffHistory({ receiptId: historyReceiptId.value }); tableRef.value.refresh() }).catch(() => {}) }
function money(value) { const num = Number(value); return Number.isNaN(num) ? '-' : num.toFixed(2) }
function customerText(row) { return row.customerName ? `${row.customerName}${row.customerCode ? `(${row.customerCode})` : ''}` : row.customerCode || '-' }
function methodText(value) { return { BANK: '银行转账', ALIPAY: '支付宝', WECHAT: '微信', CASH: '现金' }[value] || value || '-' }
function receiptStatusText(value) { return { REGISTERED: '已登记', PARTIAL_WRITTEN_OFF: '部分核销', WRITTEN_OFF: '已核销', CANCELLED: '已取消' }[value] || value || '-' }
function receiptStatusType(value) { return { REGISTERED: 'info', PARTIAL_WRITTEN_OFF: 'warning', WRITTEN_OFF: 'success', CANCELLED: 'danger' }[value] || 'info' }
</script>
<style scoped>
.ar-receipt-page .income { color: #67c23a; font-weight: 600; }
.ar-receipt-page .pending { color: #e6a23c; font-weight: 600; }
.writeoff-summary { margin-bottom: 18px; }
.allocation-row { display: flex; align-items: center; gap: 10px; }
.allocation-row .el-form-item { flex: 1; }
.bill-select { width: 100%; }
.bill-empty { margin: -4px 0 12px 90px; color: var(--el-text-color-secondary); font-size: 13px; }
</style>
@@ -1,301 +0,0 @@
<template>
<div class="app-container">
<!-- 查询条件 -->
<el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch">
<el-form-item label="账单号" prop="billNo">
<el-input v-model="queryParams.billNo" placeholder="请输入账单号" clearable style="width: 180px" @keyup.enter="handleQuery" />
</el-form-item>
<el-form-item label="账单名称" prop="billName">
<el-input v-model="queryParams.billName" placeholder="请输入账单名称" clearable style="width: 180px" @keyup.enter="handleQuery" />
</el-form-item>
<el-form-item label="客户名称" prop="customerName">
<el-input v-model="queryParams.customerName" placeholder="请输入客户名称" clearable style="width: 180px" @keyup.enter="handleQuery" />
</el-form-item>
<el-form-item label="状态" prop="status">
<el-select v-model="queryParams.status" placeholder="全部状态" clearable style="width: 140px">
<el-option v-for="opt in statusOptions" :key="opt.value" :label="opt.label" :value="opt.value" />
</el-select>
</el-form-item>
<el-form-item label="币种" prop="currency">
<el-select v-model="queryParams.currency" placeholder="全部币种" clearable style="width: 120px">
<el-option v-for="c in currencyOptions" :key="c" :label="c" :value="c" />
</el-select>
</el-form-item>
<el-form-item label="账期">
<el-date-picker
v-model="dateRange"
value-format="YYYY-MM-DD"
type="daterange"
range-separator="-"
start-placeholder="开始"
end-placeholder="结束"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button icon="Search" @click="toggleSearch">{{ showSearch ? '收起' : '展开' }}</el-button>
</el-col>
<right-toolbar v-model:showSearch="showSearch" />
</el-row>
<el-table v-loading="loading" :data="billList" border>
<el-table-column label="账单号" align="center" prop="billNo" min-width="170" show-overflow-tooltip />
<el-table-column label="账单名称" align="center" prop="billName" min-width="150" show-overflow-tooltip />
<el-table-column label="客户" align="center" prop="customerName" min-width="150" show-overflow-tooltip />
<el-table-column label="账期开始" align="center" prop="billPeriodStart" width="110">
<template #default="scope">{{ fmtDate(scope.row.billPeriodStart) }}</template>
</el-table-column>
<el-table-column label="账期结束" align="center" prop="billPeriodEnd" width="110">
<template #default="scope">{{ fmtDate(scope.row.billPeriodEnd) }}</template>
</el-table-column>
<el-table-column label="账单日期" align="center" prop="billDate" width="110">
<template #default="scope">{{ fmtDate(scope.row.billDate) }}</template>
</el-table-column>
<el-table-column label="订单数" align="center" prop="orderCount" width="80" />
<el-table-column label="应收金额" align="right" width="130">
<template #default="scope">
<span class="amount">{{ scope.row.currency }} {{ fmtMoney(scope.row.totalAmount) }}</span>
</template>
</el-table-column>
<el-table-column label="已核销" align="right" width="120">
<template #default="scope"><span class="written">{{ fmtMoney(scope.row.writtenOffAmount) }}</span></template>
</el-table-column>
<el-table-column label="未核销" align="right" width="120">
<template #default="scope"><span class="unwritten">{{ fmtMoney(scope.row.unwrittenAmount) }}</span></template>
</el-table-column>
<el-table-column label="状态" align="center" width="100">
<template #default="scope">
<el-tag :type="statusTag(scope.row.status)">{{ statusLabel(scope.row.status) }}</el-tag>
</template>
</el-table-column>
<el-table-column label="操作" align="center" width="80" fixed="right">
<template #default="scope">
<el-button link type="primary" icon="View" @click="handleView(scope.row)"
v-hasPermi="['customer:bill:query']">详情</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total > 0"
:total="total"
v-model:page="queryParams.pageNum"
v-model:limit="queryParams.pageSize"
@pagination="getList"
/>
<!-- 账单详情抽屉(只读) -->
<el-drawer v-model="detailOpen" size="72%" :title="drawerTitle" destroy-on-close>
<div v-loading="detailLoading" class="bill-detail">
<template v-if="detail">
<el-descriptions :column="3" border size="small">
<el-descriptions-item label="账单号">{{ detail.billNo }}</el-descriptions-item>
<el-descriptions-item label="账单名称" :span="2">{{ detail.billName || '-' }}</el-descriptions-item>
<el-descriptions-item label="客户">{{ detail.customerName }}</el-descriptions-item>
<el-descriptions-item label="客户编码">{{ detail.customerCode || '-' }}</el-descriptions-item>
<el-descriptions-item label="状态">
<el-tag :type="statusTag(detail.status)">{{ statusLabel(detail.status) }}</el-tag>
</el-descriptions-item>
<el-descriptions-item label="账期开始">{{ fmtDate(detail.billPeriodStart) }}</el-descriptions-item>
<el-descriptions-item label="账期结束">{{ fmtDate(detail.billPeriodEnd) }}</el-descriptions-item>
<el-descriptions-item label="账单日期">{{ fmtDate(detail.billDate) }}</el-descriptions-item>
<el-descriptions-item label="币种">{{ detail.currency }}</el-descriptions-item>
<el-descriptions-item label="订单数">{{ detail.orderCount }}</el-descriptions-item>
<el-descriptions-item label="应收金额">
<span class="amount">{{ fmtMoney(detail.totalAmount) }}</span>
</el-descriptions-item>
<el-descriptions-item label="已核销金额">
<span class="written">{{ fmtMoney(detail.writtenOffAmount) }}</span>
</el-descriptions-item>
<el-descriptions-item label="未核销金额">
<span class="unwritten">{{ fmtMoney(detail.unwrittenAmount) }}</span>
</el-descriptions-item>
<el-descriptions-item label="确认人">{{ detail.confirmedBy || '-' }}</el-descriptions-item>
<el-descriptions-item label="确认时间">{{ fmtDateTime(detail.confirmedTime) }}</el-descriptions-item>
<el-descriptions-item label="收款银行">
{{ [detail.bankName, detail.bankAccountName].filter(Boolean).join(' / ') || '-' }}
</el-descriptions-item>
<el-descriptions-item label="备注" :span="3">{{ detail.remark || '-' }}</el-descriptions-item>
</el-descriptions>
<div class="detail-title">订单明细({{ detail.details?.length || 0 }} 单)</div>
<el-table :data="detail.details || []" border size="small" row-key="detailId">
<el-table-column type="expand">
<template #default="props">
<div class="fee-wrap">
<div class="fee-title">费用明细</div>
<el-table :data="props.row.fees || []" border size="small">
<el-table-column label="序号" type="index" width="55" align="center" />
<el-table-column label="费用名称" prop="feeName" min-width="120" show-overflow-tooltip />
<el-table-column label="数量" prop="quantity" width="90" align="right" />
<el-table-column label="单位" prop="unit" width="70" align="center" />
<el-table-column label="单价" prop="unitPrice" width="100" align="right" />
<el-table-column label="金额" prop="amount" width="110" align="right">
<template #default="f">{{ f.row.currency }} {{ fmtMoney(f.row.amount) }}</template>
</el-table-column>
<el-table-column label="备注" prop="remark" min-width="120" show-overflow-tooltip />
<template #empty><span class="empty-tip">无费用明细</span></template>
</el-table>
</div>
</template>
</el-table-column>
<el-table-column label="序号" prop="detailNo" width="60" align="center" />
<el-table-column label="订单号" prop="orderNo" min-width="140" show-overflow-tooltip />
<el-table-column label="跟踪号" prop="trackingNo" min-width="140" show-overflow-tooltip />
<el-table-column label="产品" prop="productName" min-width="120" show-overflow-tooltip />
<el-table-column label="目的国" prop="countryName" width="100" align="center" />
<el-table-column label="实重" prop="actualWeight" width="80" align="right" />
<el-table-column label="体积重" prop="volumeWeight" width="80" align="right" />
<el-table-column label="计费重" prop="chargeWeight" width="80" align="right" />
<el-table-column label="金额" prop="totalAmount" width="120" align="right">
<template #default="scope">{{ scope.row.currency }} {{ fmtMoney(scope.row.totalAmount) }}</template>
</el-table-column>
</el-table>
</template>
</div>
</el-drawer>
</div>
</template>
<script setup name="CustomerBill">
import { listCustomerBill, getCustomerBill } from '@/api/customersuppliermanagement/customermoney/customerbill'
const { proxy } = getCurrentInstance()
const route = useRoute()
const statusOptions = [
{ value: 'DRAFT', label: '草稿' },
{ value: 'CONFIRMED', label: '已确认' },
{ value: 'PARTIAL_WRITTEN_OFF', label: '部分核销' },
{ value: 'WRITTEN_OFF', label: '已核销' },
{ value: 'VOID', label: '已作废' }
]
const statusTagMap = { DRAFT: 'info', CONFIRMED: 'warning', PARTIAL_WRITTEN_OFF: 'primary', WRITTEN_OFF: 'success', VOID: 'danger' }
const currencyOptions = ['CNY', 'USD', 'EUR', 'GBP', 'HKD', 'JPY']
const billList = ref([])
const loading = ref(false)
const total = ref(0)
const showSearch = ref(true)
const dateRange = ref([])
const queryParams = reactive({
pageNum: 1,
pageSize: 10,
billNo: '',
billName: '',
customerName: '',
customerId: route.query.customerId || undefined,
status: '',
currency: ''
})
const detailOpen = ref(false)
const detailLoading = ref(false)
const detail = ref(null)
const drawerTitle = computed(() => detail.value ? `账单详情 - ${detail.value.billNo}` : '账单详情')
function statusLabel(v) {
return statusOptions.find(o => o.value === v)?.label || v || '-'
}
function statusTag(v) {
return statusTagMap[v] || 'info'
}
function fmtMoney(v) {
const n = Number(v)
return isNaN(n) ? '0.00' : n.toFixed(2)
}
function fmtDate(v) {
return v ? String(v).substring(0, 10) : '-'
}
function fmtDateTime(v) {
return v ? String(v).substring(0, 16) : '-'
}
function getList() {
loading.value = true
const params = proxy.addDateRange({ ...queryParams }, dateRange.value)
listCustomerBill(params).then(res => {
billList.value = res.rows || []
total.value = res.total || 0
}).finally(() => {
loading.value = false
})
}
function handleQuery() {
queryParams.pageNum = 1
getList()
}
function resetQuery() {
dateRange.value = []
proxy.resetForm('queryRef')
// 从客户余额页跳入时保留客户过滤
queryParams.customerId = route.query.customerId || undefined
handleQuery()
}
function toggleSearch() {
showSearch.value = !showSearch.value
}
function handleView(row) {
detail.value = null
detailOpen.value = true
detailLoading.value = true
getCustomerBill(row.arBillId).then(res => {
detail.value = res.data || null
}).finally(() => {
detailLoading.value = false
})
}
getList()
</script>
<style scoped>
.amount {
color: var(--el-color-danger);
font-weight: 600;
}
.written {
color: var(--el-color-success);
font-weight: 600;
}
.unwritten {
color: var(--el-color-warning);
font-weight: 600;
}
.bill-detail {
padding: 0 16px 16px;
}
.detail-title {
font-weight: 600;
font-size: 14px;
margin: 16px 0 8px;
padding-left: 8px;
border-left: 3px solid var(--el-color-primary);
}
.fee-wrap {
padding: 8px 16px;
background: var(--el-fill-color-light);
}
.fee-title {
font-weight: 600;
margin-bottom: 8px;
font-size: 13px;
}
.empty-tip {
color: var(--el-text-color-secondary);
font-size: 12px;
}
.mb8 {
margin-bottom: 8px;
}
</style>
@@ -14,14 +14,14 @@
<el-button
icon="Document"
@click="goBillView"
v-hasPermi="['customer:bill:list']"
v-hasPermi="['ar:bill:list']"
>查看账单</el-button>
<el-button
type="primary"
icon="Money"
@click="openAdjustDialog()"
v-hasPermi="['customer:credit:adjust']"
>额度调整</el-button>
>额度调整申请</el-button>
</div>
</div>
</el-card>
@@ -339,6 +339,97 @@
@pagination="getCreditFlowList"
/>
</el-tab-pane>
<!-- ====== 额度审批(信用/额外额度调整申请) ====== -->
<el-tab-pane label="额度审批" name="creditApply">
<el-alert type="warning" :closable="false" class="credit-apply-tip">
信用额度 / 额外额度调整需先提交申请,审批通过后额度才会调整并写入额度流水。
</el-alert>
<el-form :model="applyQuery" :inline="true" class="search-form">
<el-form-item label="额度类型" prop="creditType">
<el-select v-model="applyQuery.creditType" placeholder="全部" clearable style="width: 130px;">
<el-option v-for="opt in creditTypeOptions" :key="opt.value" :label="opt.label" :value="opt.value" />
</el-select>
</el-form-item>
<el-form-item label="状态" prop="status">
<el-select v-model="applyQuery.status" placeholder="全部" clearable style="width: 130px;">
<el-option v-for="opt in applyStatusOptions" :key="opt.value" :label="opt.label" :value="opt.value" />
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="Search" @click="getApplyList">搜索</el-button>
<el-button icon="Refresh" @click="resetApplyQuery">重置</el-button>
</el-form-item>
</el-form>
<el-table :data="applyList" border v-loading="applyLoading">
<el-table-column label="申请单号" align="center" prop="applyNo" width="180" />
<el-table-column label="额度类型" align="center" prop="creditType" width="100">
<template #default="scope">
<el-tag :type="scope.row.creditType === 'TEMP' ? 'warning' : ''">
{{ formatOption(creditTypeOptions, scope.row.creditType) }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="调整方式" align="center" prop="adjustMode" width="90">
<template #default="scope">{{ formatOption(adjustModeOptions, scope.row.adjustMode) }}</template>
</el-table-column>
<el-table-column label="调整金额" align="center" prop="changeAmount" width="110">
<template #default="scope">{{ formatMoney(scope.row.changeAmount) }}</template>
</el-table-column>
<el-table-column label="生效日期" align="center" prop="effectiveDate" width="100">
<template #default="scope">{{ scope.row.effectiveDate || '-' }}</template>
</el-table-column>
<el-table-column label="失效日期" align="center" prop="expireDate" width="100">
<template #default="scope">{{ scope.row.expireDate || '长期' }}</template>
</el-table-column>
<el-table-column label="调整原因" align="center" prop="reason" min-width="150" show-overflow-tooltip />
<el-table-column label="状态" align="center" prop="status" width="90">
<template #default="scope">
<el-tag :type="applyStatusTag(scope.row.status)" size="small">
{{ formatOption(applyStatusOptions, scope.row.status) }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="申请人" align="center" prop="applyBy" width="100" />
<el-table-column label="申请时间" align="center" prop="applyTime" width="150">
<template #default="scope">{{ formatDateTime(scope.row.applyTime) }}</template>
</el-table-column>
<el-table-column label="审批人" align="center" prop="approveBy" width="100">
<template #default="scope">{{ scope.row.approveBy || '-' }}</template>
</el-table-column>
<el-table-column label="审批时间" align="center" prop="approveTime" width="150">
<template #default="scope">{{ scope.row.approveTime ? formatDateTime(scope.row.approveTime) : '-' }}</template>
</el-table-column>
<el-table-column label="审批意见" align="center" prop="approveRemark" min-width="140" show-overflow-tooltip>
<template #default="scope">{{ scope.row.approveRemark || '-' }}</template>
</el-table-column>
<el-table-column label="操作" align="center" width="150" fixed="right">
<template #default="scope">
<template v-if="scope.row.status === 'PENDING'">
<el-button link type="success" size="small"
@click="handleApproveApply(scope.row)"
v-hasPermi="['customer:credit:approve']">通过</el-button>
<el-button link type="danger" size="small"
@click="handleRejectApply(scope.row)"
v-hasPermi="['customer:credit:approve']">驳回</el-button>
<el-button link type="warning" size="small"
@click="handleCancelApply(scope.row)"
v-hasPermi="['customer:credit:adjust']">撤销</el-button>
</template>
<span v-else>-</span>
</template>
</el-table-column>
</el-table>
<pagination
v-show="applyTotal > 0"
:total="applyTotal"
v-model:page="applyQuery.pageNum"
v-model:limit="applyQuery.pageSize"
@pagination="getApplyList"
/>
</el-tab-pane>
<!-- ====== 账单核销(用账户余额核销应收账单) ====== -->
<el-tab-pane label="账单核销" name="billWriteoff">
<el-alert type="info" :closable="false" class="writeoff-summary">
@@ -348,7 +439,7 @@
<span>账户余额:<b class="money-in">CNY {{ formatMoney(currentAccount.balance) }}</b></span>
<el-button type="primary" link size="small" icon="Refresh" @click="loadBillWriteoffData">刷新</el-button>
<el-button type="primary" plain size="small" @click="goBillView"
v-hasPermi="['customer:bill:list']">查看全部账单</el-button>
v-hasPermi="['ar:bill:list']">查看全部账单</el-button>
</div>
</el-alert>
@@ -621,9 +712,9 @@
</template>
</el-dialog>
<!-- ====== 额度调整弹窗 ====== -->
<!-- ====== 额度调整申请弹窗 ====== -->
<el-dialog
:title="creditDialog.form.creditType === 'TEMP' ? '临时额度调整' : '信用额度调整'"
:title="(creditDialog.form.creditType === 'TEMP' ? '额外额度调整申请' : '信用额度调整申请') + '(提交后需审批)'"
v-model="creditDialog.visible"
width="600px"
append-to-body
@@ -724,7 +815,7 @@
</div>
<template #footer>
<el-button type="primary" :loading="creditSubmitLoading" @click="submitAdjustCredit">确 定</el-button>
<el-button type="primary" :loading="creditSubmitLoading" @click="submitAdjustCredit">提交申请</el-button>
<el-button @click="creditDialog.visible = false">取 消</el-button>
</template>
</el-dialog>
@@ -804,7 +895,7 @@
import axios from 'axios'
import { saveAs } from 'file-saver'
import { getCustomer } from "@/api/customersuppliermanagement/customerinfo/customer.js"
import { listAccount, listReceipt, getReceipt, addReceipt, confirmReceipt, cancelReceipt, listFlow, listCreditFlow, adjustCredit } from "@/api/customersuppliermanagement/customermoney/customermoney.js"
import { listAccount, listReceipt, getReceipt, addReceipt, confirmReceipt, cancelReceipt, listFlow, listCreditFlow, applyCreditAdjust, listCreditApply, approveCreditApply, rejectCreditApply, cancelCreditApply } from "@/api/customersuppliermanagement/customermoney/customermoney.js"
import { listUnsettledBill, listBalanceWriteoff, balanceWriteoff, cancelBalanceWriteoff } from "@/api/customersuppliermanagement/customermoney/customerbill.js"
import { convertToBase } from "@/api/data/exchangeRate"
import { getToken } from "@/utils/auth"
@@ -881,7 +972,9 @@ const creditTypeOptions = [
const creditChangeTypeOptions = [
{ value: 'INIT', label: '初始化' },
{ value: 'ADJUST', label: '手工调整' },
{ value: 'EXPIRE', label: '到期失效' }
{ value: 'EXPIRE', label: '到期失效' },
{ value: 'OCCUPY', label: '授信占用' },
{ value: 'RELEASE', label: '授信释放' }
]
const adjustModeOptions = [
{ value: 'SET', label: '设置为' },
@@ -889,7 +982,7 @@ const adjustModeOptions = [
{ value: 'SUB', label: '减少' }
]
function creditChangeTag(v) {
return { INIT: '', ADJUST: 'primary', EXPIRE: 'danger' }[v] || 'info'
return { INIT: '', ADJUST: 'primary', EXPIRE: 'danger', OCCUPY: 'warning', RELEASE: 'success' }[v] || 'info'
}
function formatMoney(val) {
const num = Number(val)
@@ -1056,12 +1149,12 @@ function submitAdjustCredit() {
payload.expireDate = f.expireDate || null
}
creditSubmitLoading.value = true
adjustCredit(payload).then(() => {
proxy.$modal.msgSuccess('额度调整成功')
applyCreditAdjust(payload).then(() => {
proxy.$modal.msgSuccess('申请已提交,等待审批')
creditDialog.visible = false
loadCustomer()
loadAccounts()
getCreditFlowList()
if (creditApplyLoaded) {
getApplyList()
}
}).finally(() => {
creditSubmitLoading.value = false
})
@@ -1346,6 +1439,88 @@ function resetCreditFlowQuery() {
getCreditFlowList()
}
/* ================= 额度调整申请/审批 ================= */
const applyStatusOptions = [
{ value: 'PENDING', label: '待审批' },
{ value: 'APPROVED', label: '已通过' },
{ value: 'REJECTED', label: '已驳回' },
{ value: 'CANCELLED', label: '已撤销' }
]
const applyStatusTagMap = { PENDING: 'warning', APPROVED: 'success', REJECTED: 'danger', CANCELLED: 'info' }
function applyStatusTag(v) {
return applyStatusTagMap[v] || 'info'
}
const applyList = ref([])
const applyTotal = ref(0)
const applyLoading = ref(false)
const applyQuery = reactive({
pageNum: 1,
pageSize: 10,
customerId: route.query.customerId,
creditType: '',
status: ''
})
let creditApplyLoaded = false
function getApplyList() {
const customerId = route.query.customerId
if (!customerId) return
applyLoading.value = true
applyQuery.customerId = customerId
listCreditApply({ ...applyQuery }).then(res => {
applyList.value = res.rows || []
applyTotal.value = res.total || 0
}).finally(() => {
applyLoading.value = false
})
}
function resetApplyQuery() {
applyQuery.creditType = ''
applyQuery.status = ''
applyQuery.pageNum = 1
getApplyList()
}
/** 审批通过后刷新账户卡片与额度流水 */
function afterApplyHandled() {
getApplyList()
loadAccounts()
getCreditFlowList()
}
function handleApproveApply(row) {
proxy.$modal.confirm(`确认通过额度调整申请「${row.applyNo}」?通过后将立即调整客户额度并写入额度流水。`)
.then(() => approveCreditApply(row.applyId, '审批通过'))
.then(() => {
proxy.$modal.msgSuccess('已审批通过')
afterApplyHandled()
}).catch(() => {})
}
function handleRejectApply(row) {
proxy.$prompt('请输入驳回原因', '驳回额度调整申请', {
confirmButtonText: '确认驳回',
cancelButtonText: '取消',
inputType: 'textarea',
inputPattern: /\S+/,
inputErrorMessage: '驳回原因不能为空'
}).then(({ value }) => rejectCreditApply(row.applyId, value)).then(() => {
proxy.$modal.msgSuccess('已驳回')
getApplyList()
}).catch(() => {})
}
function handleCancelApply(row) {
proxy.$modal.confirm(`确认撤销待审批申请「${row.applyNo}」?`)
.then(() => cancelCreditApply(row.applyId))
.then(() => {
proxy.$modal.msgSuccess('已撤销')
getApplyList()
}).catch(() => {})
}
/* ================= 账单核销 ================= */
const billStatusMap = {
DRAFT: { label: '草稿', type: 'info' },
@@ -1366,7 +1541,7 @@ function formatDate(val) {
}
function goBillView() {
router.push({
path: '/customersuppliermanagement/customerbill',
path: '/ar/bill',
query: { customerId: route.query.customerId || '' }
})
}
@@ -1510,6 +1685,10 @@ function submitCancelWriteoff() {
}
watch(activeTab, (tab) => {
if (tab === 'creditApply' && !creditApplyLoaded) {
creditApplyLoaded = true
getApplyList()
}
if (tab === 'billWriteoff' && !billWriteoffLoaded) {
billWriteoffLoaded = true
loadBillWriteoffData()
@@ -1632,6 +1811,13 @@ function initPage() {
flowTotal.value = 0
creditFlowList.value = []
creditFlowTotal.value = 0
applyList.value = []
applyTotal.value = 0
applyQuery.customerId = customerId
applyQuery.creditType = ''
applyQuery.status = ''
applyQuery.pageNum = 1
creditApplyLoaded = false
unsettledList.value = []
writeoffList.value = []
writeoffTotal.value = 0
@@ -1716,6 +1902,9 @@ watch(() => route.query.customerId, (newId, oldId) => {
.credit-tip {
margin-bottom: 12px;
}
.credit-apply-tip {
margin-bottom: 12px;
}
.credit-preview {
margin-top: 4px;
padding: 10px 14px;
@@ -124,7 +124,11 @@
<el-table-column label="客户名称" align="center" prop="customerName" />
<el-table-column label="对外代码" align="center" prop="customerCodeDw" />
<el-table-column label="统一社会信用代码" align="center" prop="creditCode" />
<el-table-column label="业务类型" align="center" prop="customerType" />
<el-table-column label="业务类型" align="center" prop="customerType">
<template #default="scope">
<dict-tag :options="customer_type" :value="scope.row.customerType" />
</template>
</el-table-column>
<el-table-column label="启用状态" align="center" prop="isEnable">
<template #default="scope">
<dict-tag :options="sys_normal_disable" :value="scope.row.isEnable" />
@@ -154,7 +158,14 @@
<el-table-column label="重量阈值" align="center" prop="weightThreshold" />
<el-table-column label="抛比" align="center" prop="throwRatio" />
<el-table-column label="信用额度" align="center" prop="creditEd" />
<el-table-column label="绑定产品ID" align="center" prop="productIds" />
<el-table-column label="绑定产品" align="center" prop="productIds" min-width="180">
<template #default="scope">
<span v-if="productNames(scope.row.productIds)" :title="productNames(scope.row.productIds)">
{{ productNames(scope.row.productIds) }}
</span>
<span v-else>-</span>
</template>
</el-table-column>
<el-table-column label="备注说明" align="center" prop="remark" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="240">
<template #default="scope">
@@ -178,6 +189,7 @@
<script setup name="Customer">
import { listCustomer, delCustomer } from "@/api/customersuppliermanagement/customerinfo/customer.js"
import { useProducts, parseProductIds } from '@/components/ProductSelect/useProducts'
const { proxy } = getCurrentInstance()
@@ -189,7 +201,14 @@ const single = ref(true)
const multiple = ref(true)
const total = ref(0)
const { sys_normal_disable, settlement_type } = useDict("sys_normal_disable", "settlement_type")
const { sys_normal_disable, settlement_type, customer_type } = useDict("sys_normal_disable", "settlement_type", "customer_type")
/** 绑定产品ID串 -> 产品名称展示(产品代码+名称;查不到的产品回显原ID) */
const { ensureProducts, getProductLabel } = useProducts()
function productNames(productIds) {
return parseProductIds(productIds).map(id => getProductLabel(id)).join(',')
}
ensureProducts()
/** 格式化余额(数据源 customer_account 余额表) */
function formatBalance(val) {