应付账单初始化
This commit is contained in:
@@ -164,6 +164,8 @@
|
||||
</template>
|
||||
<template #col-action="{ row }">
|
||||
<el-button link type="primary" icon="View" @click="handleView(row)">查看</el-button>
|
||||
<el-button link type="primary" icon="Money" v-hasPermi="['price:billing:bill']" @click="handlePayBill(row)">生成应付</el-button>
|
||||
<el-button
|
||||
<!-- <el-button
|
||||
link
|
||||
type="primary"
|
||||
@@ -276,6 +278,7 @@
|
||||
|
||||
<script setup name="BillingBill">
|
||||
import { listBill, getBill, refundBill, updateCreditArrears, importChargeWeightAsync, downloadChargeWeightTemplate, recalcBillPriceAsync } from '@/api/price/billing'
|
||||
import { generatePayBill } from '@/api/price/pay'
|
||||
import { exportAsyncFromTable } from '@/utils/excelExport'
|
||||
import ExcelExportFieldDialog from '@/components/ExcelExportFieldDialog/index.vue'
|
||||
import { BILLING_BILL_EXPORT_FIELDS } from '@/utils/exportFieldDefs'
|
||||
@@ -461,6 +464,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: 320, fixed: 'right', slot: 'action', showInToolbar: false, showOverflowTooltip: false }
|
||||
{ label: '操作', prop: 'action', align: 'center', width: 150, fixed: 'right', slot: 'action', showInToolbar: false, showOverflowTooltip: false }
|
||||
]
|
||||
|
||||
@@ -597,6 +601,23 @@ function handleUpdateArrears(ids, selection) {
|
||||
}).catch(() => {})
|
||||
}
|
||||
|
||||
function handlePayBill(row) {
|
||||
if (!row || !row.billId) return
|
||||
ElMessageBox.confirm(
|
||||
'按订单的渠道服务商和已配置的应付产品计算应付?',
|
||||
'生成应付',
|
||||
{ type: 'warning' }
|
||||
).then(() => generatePayBill(row.billId)).then(res => {
|
||||
const data = res.data || {}
|
||||
if (data.skipped && data.skipped.length) {
|
||||
ElMessageBox.alert(data.skipped.join('\n'), data.message || '应付已生成', { type: 'warning' })
|
||||
} else {
|
||||
ElMessage.success(data.message || '应付已生成')
|
||||
}
|
||||
tableRef.value?.refresh?.()
|
||||
}).catch(() => {})
|
||||
}
|
||||
|
||||
function handleRefund(row) {
|
||||
if (!row || !row.billId) return
|
||||
if (row.refundStatus === 'REFUNDED') {
|
||||
|
||||
@@ -137,6 +137,9 @@
|
||||
<el-empty v-else description="暂无应收明细" :image-size="64" />
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="应付" name="pay">
|
||||
<div v-if="!readonly" class="pay-generate">
|
||||
<el-button type="primary" plain size="small" v-hasPermi="['price:billing:bill']" @click="handlePayBill">生成应付</el-button>
|
||||
</div>
|
||||
<el-table v-if="payFees.length" :data="payFees" border size="small" class="fee-table">
|
||||
<el-table-column label="费用名称" min-width="140" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ displayFeeName(row) }}</template>
|
||||
@@ -190,7 +193,9 @@
|
||||
<script setup>
|
||||
import AddIncomeFeeDialog from './AddIncomeFeeDialog.vue'
|
||||
import EditChargeWeightDialog from './EditChargeWeightDialog.vue'
|
||||
import { deleteIncomeBillFee } from '@/api/price/billing'
|
||||
import { deleteIncomeBillFee, getBill } from '@/api/price/billing'
|
||||
import { generatePayBill } from '@/api/price/pay'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
|
||||
const { proxy } = getCurrentInstance()
|
||||
|
||||
@@ -226,6 +231,26 @@ watch(() => props.detail, () => {
|
||||
feeTab.value = 'income'
|
||||
})
|
||||
|
||||
function handlePayBill() {
|
||||
const billId = props.detail?.billId
|
||||
if (!billId) return
|
||||
ElMessageBox.confirm('按订单的渠道服务商和已配置的应付产品计算应付?', '生成应付', { type: 'warning' })
|
||||
.then(() => generatePayBill(billId))
|
||||
.then(res => {
|
||||
const data = res.data || {}
|
||||
if (data.skipped && data.skipped.length) {
|
||||
ElMessageBox.alert(data.skipped.join('\n'), data.message || '应付已生成', { type: 'warning' })
|
||||
} else {
|
||||
ElMessage.success(data.message || '应付已生成')
|
||||
}
|
||||
return getBill(billId)
|
||||
})
|
||||
.then(res => {
|
||||
if (res && res.data) emit('updated', res.data)
|
||||
})
|
||||
.catch(() => {})
|
||||
}
|
||||
|
||||
function canEditManualFee(row) {
|
||||
return row && String(row.manualFlag) === '1' && row.arBillStatus !== 'BILLED'
|
||||
}
|
||||
@@ -439,6 +464,9 @@ function refundLabel(status) {
|
||||
.bill-detail-wrap {
|
||||
min-height: 240px;
|
||||
}
|
||||
.pay-generate {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
.bill-detail {
|
||||
padding-bottom: 8px;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,288 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-form :inline="true" :model="query" class="mb8">
|
||||
<el-form-item label="账单号">
|
||||
<el-input v-model="query.billNo" clearable placeholder="账单号" style="width: 180px" />
|
||||
</el-form-item>
|
||||
<el-form-item label="供应商">
|
||||
<el-input v-model="query.supplierName" clearable placeholder="供应商" style="width: 180px" />
|
||||
</el-form-item>
|
||||
<el-form-item label="状态">
|
||||
<el-select v-model="query.status" clearable placeholder="全部" style="width: 140px">
|
||||
<el-option v-for="item in statusOptions" :key="item.value" :label="item.label" :value="item.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="Search" @click="loadList">查询</el-button>
|
||||
<el-button type="primary" plain icon="Plus" @click="openCreate" v-hasPermi="['price:payBill:add']">生成账单</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-table v-loading="loading" :data="rows" border>
|
||||
<el-table-column prop="billNo" label="账单号" min-width="170" />
|
||||
<el-table-column prop="supplierName" label="供应商" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column prop="currency" label="币种" width="80" align="center" />
|
||||
<el-table-column prop="orderCount" label="订单数" width="80" align="center" />
|
||||
<el-table-column prop="totalAmount" label="应付总额" width="120" align="right" />
|
||||
<el-table-column label="来源" width="90" align="center">
|
||||
<template #default="{ row }">{{ sourceText(row.sourceType) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="状态" width="90" align="center">
|
||||
<template #default="{ row }">{{ statusText(row.status) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="createTime" label="生成时间" width="170" />
|
||||
<el-table-column label="操作" width="260" align="center" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button link type="primary" @click="openDetail(row)">查看</el-button>
|
||||
<el-button v-if="row.status === 'DRAFT'" link type="primary" @click="confirmRow(row)" v-hasPermi="['price:payBill:confirm']">确认</el-button>
|
||||
<el-button v-if="row.status === 'CONFIRMED'" link type="primary" @click="payRow(row)" v-hasPermi="['price:payBill:confirm']">登记付款</el-button>
|
||||
<el-button v-if="row.status !== 'VOID' && row.status !== 'PAID'" link type="danger" @click="openVoid(row)" v-hasPermi="['price:payBill:void']">作废</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<pagination v-show="total > 0" :total="total" v-model:page="query.pageNum" v-model:limit="query.pageSize" @pagination="loadList" />
|
||||
|
||||
<el-dialog v-model="createVisible" title="生成应付账单" width="1180px" append-to-body>
|
||||
<el-form label-width="90px">
|
||||
<el-form-item label="选出方式">
|
||||
<el-radio-group v-model="command.sourceType">
|
||||
<el-radio value="ORDER">订单号</el-radio>
|
||||
<el-radio value="TIME">计费日</el-radio>
|
||||
<el-radio value="LADING">提单</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="command.sourceType === 'ORDER'" label="订单号">
|
||||
<el-input v-model="command.orderText" type="textarea" :rows="4" placeholder="可用逗号、空格或换行分隔" />
|
||||
</el-form-item>
|
||||
<el-form-item v-if="command.sourceType === 'TIME'" label="计费日" class="pay-bill-date">
|
||||
<el-date-picker v-model="dateRange" type="daterange" value-format="YYYY-MM-DD" start-placeholder="开始" end-placeholder="结束" />
|
||||
</el-form-item>
|
||||
<el-form-item v-if="command.sourceType === 'LADING'" label="提单号">
|
||||
<el-input v-model="command.ladingText" type="textarea" :rows="4" placeholder="多张提单可用逗号、空格或换行分隔" />
|
||||
</el-form-item>
|
||||
<el-form-item label="供应商" required>
|
||||
<el-select v-model="command.supplierId" filterable placeholder="选择供应商" style="width: 280px">
|
||||
<el-option v-for="item in suppliers" :key="item.supplierId" :label="item.supplierName" :value="item.supplierId" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div class="mb8">
|
||||
<el-button @click="runPreview">查询订单</el-button>
|
||||
<span v-if="previewRows.length" class="preview-msg">查询到 {{ previewRows.length }} 票,件数 {{ piecesTotal }},可生成 {{ preview.orders.length }} 票</span>
|
||||
<span v-if="preview.message" class="preview-msg">{{ preview.message }}</span>
|
||||
</div>
|
||||
<el-table :data="previewRows" border size="small" max-height="360" empty-text="先查询订单">
|
||||
<el-table-column prop="orderNo" label="订单号" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column prop="trackingNo" label="运单号" min-width="130" show-overflow-tooltip />
|
||||
<el-table-column prop="ladingNo" label="提单号" min-width="120" show-overflow-tooltip />
|
||||
<el-table-column prop="supplierName" label="供应商" min-width="120" show-overflow-tooltip />
|
||||
<el-table-column label="目的地" min-width="140" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ destText(row) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="pieces" label="件数" width="70" align="center" />
|
||||
<el-table-column prop="chargeWeight" label="计费重" width="90" align="right" />
|
||||
<el-table-column prop="channelName" label="渠道" min-width="120" show-overflow-tooltip />
|
||||
<el-table-column prop="productName" label="产品" min-width="120" show-overflow-tooltip />
|
||||
<el-table-column prop="feeText" label="费用" min-width="180" show-overflow-tooltip />
|
||||
<el-table-column prop="currency" label="币种" width="70" align="center" />
|
||||
<el-table-column prop="payTotal" label="应付总额" width="100" align="right" />
|
||||
<el-table-column prop="bizDate" label="计费日" width="160" />
|
||||
<el-table-column label="状态" width="150" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ row.occupiedBillNo ? '已入账 ' + row.occupiedBillNo : '可生成' }}</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<template #footer>
|
||||
<el-button @click="createVisible = false">取消</el-button>
|
||||
<el-button type="primary" :loading="saving" @click="runGenerate">生成</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<el-drawer v-model="detailVisible" :title="detail?.billNo || '应付账单'" size="70%">
|
||||
<template v-if="detail">
|
||||
<el-descriptions :column="3" border size="small" class="mb8">
|
||||
<el-descriptions-item label="供应商">{{ detail.supplierName }}</el-descriptions-item>
|
||||
<el-descriptions-item label="币种">{{ detail.currency }}</el-descriptions-item>
|
||||
<el-descriptions-item label="状态">{{ statusText(detail.status) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="应付总额">{{ detail.totalAmount }}</el-descriptions-item>
|
||||
<el-descriptions-item label="订单数">{{ detail.orderCount }}</el-descriptions-item>
|
||||
<el-descriptions-item label="作废原因">{{ detail.voidReason || '-' }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
<el-table :data="detail.lines || []" border size="small" max-height="320">
|
||||
<el-table-column prop="orderNo" label="订单号" min-width="130" />
|
||||
<el-table-column prop="ladingNo" label="提单号" min-width="120" />
|
||||
<el-table-column prop="feeName" label="费用" min-width="120" />
|
||||
<el-table-column prop="amount" label="金额" width="100" align="right" />
|
||||
<el-table-column prop="currency" label="币种" width="70" />
|
||||
<el-table-column prop="versionNo" label="版本" width="70" />
|
||||
</el-table>
|
||||
<h4>操作记录</h4>
|
||||
<el-table :data="detail.logs || []" border size="small">
|
||||
<el-table-column prop="createTime" label="时间" width="170" />
|
||||
<el-table-column prop="operatorName" label="操作人" width="100" />
|
||||
<el-table-column prop="operationType" label="动作" width="100" />
|
||||
<el-table-column prop="fromStatus" label="原状态" width="110" />
|
||||
<el-table-column prop="toStatus" label="新状态" width="110" />
|
||||
<el-table-column prop="operationDesc" label="说明" min-width="180" show-overflow-tooltip />
|
||||
</el-table>
|
||||
</template>
|
||||
</el-drawer>
|
||||
|
||||
<el-dialog v-model="voidVisible" title="作废应付账单" width="460px" append-to-body>
|
||||
<el-input v-model="voidReason" type="textarea" :rows="3" placeholder="作废原因" />
|
||||
<template #footer>
|
||||
<el-button @click="voidVisible = false">取消</el-button>
|
||||
<el-button type="danger" @click="runVoid">确认作废</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="PayBill">
|
||||
import { listSupplier } from '@/api/customersuppliermanagement/supplierinfo/supplier'
|
||||
import { listPayBill, getPayBill, previewPayBill, generatePayBill, confirmPayBill, payPayBill, voidPayBill } from '@/api/price/payBill'
|
||||
|
||||
const { proxy } = getCurrentInstance()
|
||||
const loading = ref(false)
|
||||
const rows = ref([])
|
||||
const total = ref(0)
|
||||
const query = reactive({ pageNum: 1, pageSize: 10, billNo: '', supplierName: '', status: '' })
|
||||
const statusOptions = [
|
||||
{ label: '草稿', value: 'DRAFT' },
|
||||
{ label: '已确认', value: 'CONFIRMED' },
|
||||
{ label: '已付款', value: 'PAID' },
|
||||
{ label: '已作废', value: 'VOID' }
|
||||
]
|
||||
const createVisible = ref(false)
|
||||
const saving = ref(false)
|
||||
const suppliers = ref([])
|
||||
const dateRange = ref([])
|
||||
const command = reactive({ sourceType: 'ORDER', orderText: '', ladingText: '', supplierId: null, beginDate: '', endDate: '' })
|
||||
const preview = reactive({ orders: [], occupied: [], missingNos: [], message: '' })
|
||||
const detailVisible = ref(false)
|
||||
const detail = ref(null)
|
||||
const voidVisible = ref(false)
|
||||
const voidReason = ref('')
|
||||
const voidId = ref(null)
|
||||
|
||||
const previewRows = computed(() => [...(preview.orders || []), ...(preview.occupied || [])])
|
||||
const piecesTotal = computed(() => previewRows.value.reduce((sum, item) => sum + (Number(item.pieces) || 0), 0))
|
||||
|
||||
function destText(row) {
|
||||
const country = [row.countryName, row.countryCode].filter(Boolean).join(' ')
|
||||
return [country, row.destPostcode].filter(Boolean).join(' / ') || '-'
|
||||
}
|
||||
|
||||
function statusText(value) {
|
||||
return statusOptions.find(item => item.value === value)?.label || value || '-'
|
||||
}
|
||||
|
||||
function sourceText(value) {
|
||||
return { ORDER: '订单号', TIME: '计费日', LADING: '提单' }[value] || value || '-'
|
||||
}
|
||||
|
||||
function loadList() {
|
||||
loading.value = true
|
||||
listPayBill(query).then(res => {
|
||||
rows.value = res.rows || []
|
||||
total.value = res.total || 0
|
||||
}).finally(() => {
|
||||
loading.value = false
|
||||
})
|
||||
}
|
||||
|
||||
function openCreate() {
|
||||
preview.orders = []
|
||||
preview.occupied = []
|
||||
preview.missingNos = []
|
||||
preview.message = ''
|
||||
createVisible.value = true
|
||||
if (!suppliers.value.length) {
|
||||
listSupplier({ pageNum: 1, pageSize: 500 }).then(res => {
|
||||
suppliers.value = res.rows || []
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function buildCommand() {
|
||||
const data = { ...command }
|
||||
if (command.sourceType === 'TIME' && dateRange.value?.length === 2) {
|
||||
data.beginDate = dateRange.value[0]
|
||||
data.endDate = dateRange.value[1]
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
function runPreview() {
|
||||
previewPayBill(buildCommand()).then(res => {
|
||||
const data = res.data || {}
|
||||
preview.orders = data.orders || []
|
||||
preview.occupied = data.occupied || []
|
||||
preview.missingNos = data.missingNos || []
|
||||
preview.message = data.message || ''
|
||||
})
|
||||
}
|
||||
|
||||
function runGenerate() {
|
||||
saving.value = true
|
||||
generatePayBill(buildCommand()).then(() => {
|
||||
proxy.$modal.msgSuccess('应付账单已生成')
|
||||
createVisible.value = false
|
||||
loadList()
|
||||
}).finally(() => {
|
||||
saving.value = false
|
||||
})
|
||||
}
|
||||
|
||||
function openDetail(row) {
|
||||
getPayBill(row.billId).then(res => {
|
||||
detail.value = res.data
|
||||
detailVisible.value = true
|
||||
})
|
||||
}
|
||||
|
||||
function confirmRow(row) {
|
||||
proxy.$modal.confirm('确认这张应付账单?确认后金额锁定。').then(() => confirmPayBill(row.billId)).then(() => {
|
||||
proxy.$modal.msgSuccess('已确认')
|
||||
loadList()
|
||||
}).catch(() => {})
|
||||
}
|
||||
|
||||
function payRow(row) {
|
||||
proxy.$modal.confirm('登记这张账单已付款?已付款后不能直接作废。').then(() => payPayBill(row.billId)).then(() => {
|
||||
proxy.$modal.msgSuccess('已登记付款')
|
||||
loadList()
|
||||
}).catch(() => {})
|
||||
}
|
||||
|
||||
function openVoid(row) {
|
||||
voidId.value = row.billId
|
||||
voidReason.value = ''
|
||||
voidVisible.value = true
|
||||
}
|
||||
|
||||
function runVoid() {
|
||||
if (!voidReason.value.trim()) {
|
||||
proxy.$modal.msgWarning('请填写作废原因')
|
||||
return
|
||||
}
|
||||
voidPayBill({ billId: voidId.value, voidReason: voidReason.value.trim() }).then(() => {
|
||||
proxy.$modal.msgSuccess('已作废,历史账单仍可查看')
|
||||
voidVisible.value = false
|
||||
loadList()
|
||||
})
|
||||
}
|
||||
|
||||
loadList()
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.preview-msg { margin-left: 12px; color: #909399; }
|
||||
.mb8 { margin-bottom: 8px; }
|
||||
.pay-bill-date :deep(.el-date-editor) {
|
||||
width: 280px !important;
|
||||
max-width: 280px;
|
||||
flex: 0 0 280px;
|
||||
--el-date-editor-width: 280px;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user