应付配置增加附加费配置,应付账单新增核销、对账、凭证、审核功能

This commit is contained in:
liuminghui
2026-11-12 18:20:32 +08:00
parent 1ba431540d
commit 6675808dfc
55 changed files with 5898 additions and 185 deletions
+27
View File
@@ -171,3 +171,30 @@ export function delPay(productIds) {
method: 'delete'
})
}
/** 当前版本的附加费计费条件 */
export function listPaySurchargeRule(productId, termId) {
return request({
url: '/price/pay/surchargeRule',
method: 'get',
params: { productId, termId }
})
}
/** 上一版计费条件,复制到当前页编辑 */
export function previousPaySurchargeRule(productId) {
return request({
url: '/price/pay/surchargeRule/previous',
method: 'get',
params: { productId }
})
}
/** 覆盖绑定产品当前版本的计费条件。同一版本只保留这一份。 */
export function savePaySurchargeRule(data) {
return request({
url: '/price/pay/surchargeRule',
method: 'post',
data
})
}
+55
View File
@@ -27,3 +27,58 @@ export function payPayBill(billId) {
export function voidPayBill(data) {
return request({ url: '/price/payBill/void', method: 'put', data })
}
export function submitPayBill(billId) {
return request({ url: '/price/payBill/submit/' + billId, method: 'put' })
}
export function approvePayBill(billId) {
return request({ url: '/price/payBill/approve/' + billId, method: 'put' })
}
export function rejectPayBill(data) {
return request({ url: '/price/payBill/reject', method: 'put', data })
}
export function savePayBillDiff(data) {
return request({ url: '/price/payBill/diff', method: 'put', data })
}
export function acceptPayBillDiff(data) {
return request({ url: '/price/payBill/diff/accept', method: 'put', data })
}
export function removePayBillLine(data) {
return request({ url: '/price/payBill/line/remove', method: 'put', data })
}
export function savePayBillFile(data) {
return request({ url: '/price/payBill/file', method: 'post', data })
}
export function deletePayBillFile(fileId) {
return request({ url: '/price/payBill/file/' + fileId, method: 'delete' })
}
export function listPayBillFile(query) {
return request({ url: '/price/payBill/file/list', method: 'get', params: query })
}
export function redPayBill(data) {
return request({ url: '/price/payBill/red', method: 'post', data })
}
export function savePayFinance(data) {
return request({ url: '/price/payBill/finance', method: 'put', data })
}
export function exportPayStatement(billId) {
return request({ url: '/price/payBill/statement/' + billId, method: 'get', responseType: 'blob' })
}
export function importPaySupplier(billId, file) {
const data = new FormData()
data.append('billId', billId)
data.append('file', file)
return request({ url: '/price/payBill/diff/import', method: 'post', data })
}
+33
View File
@@ -0,0 +1,33 @@
import request from '@/utils/request'
export function listPayPayment(query) {
return request({ url: '/price/payPayment/list', method: 'get', params: query })
}
export function getPayPayment(paymentId) {
return request({ url: '/price/payPayment/' + paymentId, method: 'get' })
}
export function openPayBills(supplierId, currency) {
return request({ url: '/price/payPayment/open', method: 'get', params: { supplierId, currency } })
}
export function createPayPayment(data) {
return request({ url: '/price/payPayment', method: 'post', data })
}
export function confirmPayPayment(paymentId) {
return request({ url: '/price/payPayment/confirm/' + paymentId, method: 'put' })
}
export function voidPayPayment(paymentId) {
return request({ url: '/price/payPayment/void/' + paymentId, method: 'put' })
}
export function reversePayPayment(paymentId) {
return request({ url: '/price/payPayment/reverse/' + paymentId, method: 'put' })
}
export function refundPayPayment(paymentId) {
return request({ url: '/price/payPayment/refund/' + paymentId, method: 'put' })
}
@@ -8,9 +8,22 @@
@closed="handleClosed"
class="excel-import-dialog"
>
<template v-if="descOnTitle" #header>
<div class="import-title-bar">
<span>{{ title }}</span>
<el-tooltip v-if="importDesc.length" placement="bottom-start" effect="light" :show-after="200">
<template #content>
<ul class="title-tip-list">
<li v-for="(line, i) in importDesc" :key="i">{{ line }}</li>
</ul>
</template>
<el-icon class="title-tip-icon"><Info-Filled /></el-icon>
</el-tooltip>
</div>
</template>
<div class="import-body">
<!-- 业务说明(可选) -->
<div v-if="importDesc.length" class="import-desc">
<div v-if="importDesc.length && !descOnTitle" class="import-desc">
<el-icon class="desc-icon"><Info-Filled /></el-icon>
<ul class="desc-list">
<li v-for="(line, i) in importDesc" :key="i">{{ line }}</li>
@@ -180,6 +193,11 @@ const props = defineProps({
type: Array,
default: () => []
},
// 为 true 时,说明改到标题文字后的图标上,悬停展开
descOnTitle: {
type: Boolean,
default: false
},
extraQuery: {
type: Object,
default: () => ({})
@@ -577,6 +595,32 @@ defineExpose({ open, close, setProgress })
vertical-align: baseline;
}
.import-title-bar {
display: inline-flex;
align-items: center;
gap: 6px;
font-size: 16px;
font-weight: 600;
line-height: 24px;
color: var(--el-text-color-primary);
}
.title-tip-icon {
font-size: 16px;
color: var(--el-color-warning);
cursor: help;
}
.title-tip-list {
margin: 0;
padding-left: 18px;
max-width: 420px;
font-size: 13px;
font-weight: 400;
line-height: 1.7;
color: var(--el-text-color-regular);
}
.import-desc {
margin-bottom: 14px;
padding: 12px 14px;
@@ -191,23 +191,11 @@
</el-table-column>
<el-table-column prop="calcRule" label="计费条件" width="140">
<template #default="{ row }">
<el-select v-if="isRowEditing(row)" v-model="row.calcRule" size="small" placeholder="暂不计费">
<el-option v-for="item in calcRules" :key="item.value" :label="item.label" :value="item.value" />
<el-select v-if="isRowEditing(row)" :model-value="feeBillFlag(row)" size="small" @change="value => setFeeBill(row, value)">
<el-option label="需要计费" value="BILL" />
<el-option label="暂不计费" value="MANUAL" />
</el-select>
<span v-else>{{ calcRuleLabel(row.calcRule) }}</span>
</template>
</el-table-column>
<el-table-column prop="calcParam" label="条件参数" min-width="220" show-overflow-tooltip>
<template #default="{ row }">
<span v-if="!isRowEditing(row)">{{ feeCondition(row) }}</span>
<template v-else>
<div v-if="conditionHint(row)" class="pay-cond-hint">{{ conditionHint(row) }}</div>
<cell-text
v-if="showCalcParamEditor(row)"
v-model="row.calcParam"
:edit="true"
/>
</template>
<span v-else>{{ feeBillFlag(row) === 'BILL' ? '需要计费' : '暂不计费' }}</span>
</template>
</el-table-column>
<el-table-column v-if="editable" label="操作" width="120" align="center" fixed="right">
@@ -471,50 +459,16 @@ const CellText = {
}
}
const calcRules = [
{ value: 'ALWAYS', label: '每票都收' },
{ value: 'POSTCODE', label: '命中邮编' },
{ value: 'ZONE', label: '命中分区' },
{ value: 'EXTRA_KG', label: '超重续收' },
{ value: 'WEIGHT', label: '超重' },
{ value: 'SIZE', label: '超尺寸' },
{ value: 'RETURN', label: '退件' },
{ value: 'MANUAL', label: '暂不计费' }
]
function calcRuleLabel(value) {
return calcRules.find(item => item.value === value)?.label || '暂不计费'
function feeBillFlag(row) {
return row?.calcRule && row.calcRule !== 'MANUAL' ? 'BILL' : 'MANUAL'
}
function conditionHint(row) {
const parts = []
const hasMin = row.weightMin != null && row.weightMin !== ''
const hasMax = row.weightMax != null && row.weightMax !== ''
if (hasMin || hasMax) {
parts.push(`${hasMin ? row.weightMin : ''}-${hasMax ? row.weightMax : ''}kg`)
function setFeeBill(row, value) {
if (value === 'MANUAL') {
row.calcRule = 'MANUAL'
return
}
if (row.postcodeParam) {
parts.push(`邮编 ${row.postcodeParam}`)
}
return parts.join(';')
}
function hasCalcParam(row) {
const text = String(row?.calcParam ?? '').trim()
if (!text) return false
return text !== String(row?.postcodeParam ?? '').trim()
}
function showCalcParamEditor(row) {
return hasCalcParam(row) || !conditionHint(row)
}
function feeCondition(row) {
const parts = []
const hint = conditionHint(row)
if (hint) parts.push(hint)
if (hasCalcParam(row)) parts.push(String(row.calcParam).trim())
return parts.join(';') || '-'
if (!row.calcRule || row.calcRule === 'MANUAL') row.calcRule = 'ALWAYS'
}
const pageSize = 20
@@ -0,0 +1,530 @@
<template>
<el-dialog v-model="visible" title="附加费配置" width="1080px" append-to-body destroy-on-close @closed="reset">
<div class="rule-body">
<div class="rule-block">
<div class="rule-title">绑定产品</div>
<div class="rule-products">
<el-tag v-for="item in products" :key="item.key" closable class="rule-tag" @close="removeProduct(item)">
{{ item.productName }} · 第 {{ item.versionNo || 1 }} 版
</el-tag>
<span v-if="!products.length" class="rule-empty">还没有产品。勾选列表后打开,或在下面查询后加入。</span>
</div>
<div class="rule-search">
<el-input v-model="keyword" clearable placeholder="按产品名称查询" @keyup.enter="searchProducts" />
<el-button type="primary" plain :loading="searching" @click="searchProducts">查询</el-button>
</div>
<el-table v-if="found.length" :data="found" border size="small" max-height="180" empty-text="没有产品">
<el-table-column prop="productName" label="产品名称" min-width="180" show-overflow-tooltip />
<el-table-column prop="versionNo" label="版本" width="70" align="center" />
<el-table-column label="有效期" min-width="180" show-overflow-tooltip>
<template #default="{ row }">{{ termText(row) }}</template>
</el-table-column>
<el-table-column label="操作" width="80" align="center">
<template #default="{ row }">
<el-button link type="primary" @click="addProduct(row)">加入</el-button>
</template>
</el-table-column>
</el-table>
<p class="rule-hint">配置写到每个产品当前生效的版本。同一版本再次保存会覆盖原来的一份。</p>
</div>
<div class="rule-block">
<div class="rule-title">计费条件</div>
<div class="rule-switches">
<div v-for="rule in ruleDefs" :key="rule.value" class="rule-switch">
<span>{{ rule.label }}</span>
<el-switch v-model="enabled[rule.value]" @change="value => toggleRule(rule.value, value)" />
</div>
</div>
<p v-if="enabled.POSTCODE" class="rule-hint">打开后,用订单目的国去应付邮编配置里对国家和邮编。邮编前缀和完整邮编都会判断,命中偏远或岛屿才加这笔附加费。</p>
<p v-if="enabled.ZONE" class="rule-hint">打开后,用订单目的国和邮编去应付邮编配置里对上分区,再加这一档附加费。</p>
</div>
<div v-for="rule in openedRules" :key="rule.value" class="rule-block">
<div class="rule-bar">
<span class="rule-title">{{ rule.label }}</span>
<el-button type="primary" link @click="addRow(rule.value)">新增一条</el-button>
</div>
<p class="rule-hint">{{ rule.hint }}</p>
<div v-for="(row, index) in groups[rule.value]" :key="index" class="rule-card">
<div class="rule-card-bar">
<span>第 {{ index + 1 }} 条</span>
<el-button link type="danger" @click="groups[rule.value].splice(index, 1)">删除</el-button>
</div>
<div v-if="rule.value === 'SIZE'" class="rule-grid">
<div class="field">
<span class="label">命中方式</span>
<el-select v-model="row.matchMode" size="small">
<el-option label="任一命中" value="ANY" />
<el-option label="全部命中" value="ALL" />
</el-select>
</div>
<div class="field">
<span class="label">重量前提 kg</span>
<el-input v-model="row.weightMin" size="small" placeholder="下限" />
<span class="sep">至</span>
<el-input v-model="row.weightMax" size="small" placeholder="上限" />
</div>
<div class="field">
<span class="label">最长边 cm</span>
<el-input v-model="row.longestMin" size="small" placeholder="下限" />
<span class="sep">至</span>
<el-input v-model="row.longestMax" size="small" placeholder="上限" />
</div>
<div class="field">
<span class="label">次长边 cm</span>
<el-input v-model="row.secondMin" size="small" placeholder="下限" />
<span class="sep">至</span>
<el-input v-model="row.secondMax" size="small" placeholder="上限" />
</div>
<div class="field">
<span class="label">三边之和 cm</span>
<el-input v-model="row.sumMin" size="small" placeholder="下限" />
<span class="sep">至</span>
<el-input v-model="row.sumMax" size="small" placeholder="上限" />
</div>
<div class="field">
<span class="label">围长 cm</span>
<el-input v-model="row.girthMin" size="small" placeholder="下限" />
<span class="sep">至</span>
<el-input v-model="row.girthMax" size="small" placeholder="上限" />
</div>
<div class="field">
<span class="label">箱规 cm</span>
<el-select v-model="row.boxMode" size="small" class="mode">
<el-option label="任一边超过" value="OVER" />
<el-option label="小于最小尺寸" value="UNDER" />
</el-select>
<el-input v-model="row.boxLength" size="small" placeholder="长" />
<el-input v-model="row.boxWidth" size="small" placeholder="宽" />
<el-input v-model="row.boxHeight" size="small" placeholder="高" />
</div>
<div class="field">
<span class="label">体积 m³</span>
<el-input v-model="row.volumeMin" size="small" placeholder="下限" />
<span class="sep">至</span>
<el-input v-model="row.volumeMax" size="small" placeholder="上限" />
</div>
<div class="field">
<span class="label">长×宽×高上限 cm³</span>
<el-input v-model="row.cubicMax" size="small" placeholder="例如 432000" />
</div>
<div class="field">
<span class="label">每超出 cm</span>
<el-input v-model="row.exceedStepCm" size="small" placeholder="例如 10" />
</div>
<div class="field">
<span class="label">运费加收比例 %</span>
<el-input v-model="row.exceedRatio" size="small" placeholder="例如 35" />
</div>
<div class="field span-2">
<span class="label">说明</span>
<el-input v-model="row.remark" size="small" placeholder="这一档的补充说明" />
</div>
</div>
<div v-else-if="rule.value === 'WEIGHT'" class="rule-grid">
<div class="field">
<span class="label">重量 kg</span>
<el-input v-model="row.weightMin" size="small" placeholder="下限" />
<span class="sep">至</span>
<el-input v-model="row.weightMax" size="small" placeholder="上限" />
</div>
<div class="field">
<span class="label">重量口径</span>
<el-select v-model="row.weightBasis" size="small">
<el-option label="实重" value="ACTUAL" />
<el-option label="计费重" value="CHARGE" />
</el-select>
</div>
<div class="field">
<span class="label">每超出 kg</span>
<el-input v-model="row.stepKg" size="small" placeholder="超过上限后按每公斤" />
</div>
<div class="field">
<span class="label">最低消费</span>
<el-input v-model="row.minCharge" size="small" placeholder="没有就空着" />
</div>
<div class="field">
<span class="label">运费加收比例 %</span>
<el-input v-model="row.exceedRatio" size="small" placeholder="按运费比例加收时填写" />
</div>
<div class="field">
<span class="label">说明</span>
<el-input v-model="row.remark" size="small" />
</div>
</div>
<div v-else-if="rule.value === 'EXTRA_KG'" class="rule-grid">
<div class="field">
<span class="label">超过 kg</span>
<el-input v-model="row.thresholdKg" size="small" placeholder="超过这个重量后开始续收" />
</div>
<div class="field">
<span class="label">每超出 kg</span>
<el-input v-model="row.stepKg" size="small" placeholder="例如 1" />
</div>
<div class="field">
<span class="label">重量口径</span>
<el-select v-model="row.weightBasis" size="small">
<el-option label="实重" value="ACTUAL" />
<el-option label="计费重" value="CHARGE" />
</el-select>
</div>
<div class="field">
<span class="label">最低消费</span>
<el-input v-model="row.minCharge" size="small" placeholder="例如 17.5" />
</div>
<div class="field span-2">
<span class="label">邮编</span>
<el-input v-model="row.postcodes" size="small" type="textarea" :rows="2" placeholder="续收还要限定邮编时填写,支持 KA27-28 这种区间" />
</div>
</div>
<div v-else-if="rule.value === 'ALWAYS'" class="rule-grid">
<div class="field">
<span class="label">计费方式</span>
<el-select v-model="row.rateMode" size="small">
<el-option label="固定金额" value="FIXED" />
<el-option label="按比例" value="RATIO" />
</el-select>
</div>
<div class="field">
<span class="label">比例 %</span>
<el-input v-model="row.ratio" size="small" placeholder="燃油、战争附加费这类" />
</div>
<div class="field">
<span class="label">计费基数</span>
<el-select v-model="row.chargeBase" size="small" clearable placeholder="按比例时选择">
<el-option label="处理费" value="HANDLE" />
<el-option label="派送费" value="DELIVERY" />
<el-option label="运费加附加费" value="FREIGHT_FEE" />
</el-select>
</div>
<div class="field">
<span class="label">生效日期</span>
<el-input v-model="row.periodStart" size="small" placeholder="开始,如 11-01" />
<span class="sep">至</span>
<el-input v-model="row.periodEnd" size="small" placeholder="结束,如 12-23" />
</div>
<div class="field span-2">
<span class="label">说明</span>
<el-input v-model="row.remark" size="small" placeholder="例如每年 11、12 月固定收取" />
</div>
</div>
<div v-else class="rule-grid">
<div class="field">
<span class="label">退回方式</span>
<el-select v-model="row.chargeMode" size="small">
<el-option label="同正向运费" value="SAME" />
<el-option label="空运退回" value="AIR" />
<el-option label="陆运退回" value="ROAD" />
<el-option label="固定金额" value="FIXED" />
</el-select>
</div>
<div class="field">
<span class="label">重量 kg</span>
<el-input v-model="row.weightMin" size="small" placeholder="下限" />
<span class="sep">至</span>
<el-input v-model="row.weightMax" size="small" placeholder="上限" />
</div>
<div class="field">
<span class="label">尺寸命中</span>
<el-select v-model="row.matchMode" size="small" clearable placeholder="退件还看尺寸时选择">
<el-option label="任一命中" value="ANY" />
<el-option label="全部命中" value="ALL" />
</el-select>
</div>
<div class="field">
<span class="label">最长边 cm</span>
<el-input v-model="row.longestMin" size="small" placeholder="下限" />
<span class="sep">至</span>
<el-input v-model="row.longestMax" size="small" placeholder="上限" />
</div>
<div class="field">
<span class="label">围长 cm</span>
<el-input v-model="row.girthMin" size="small" placeholder="下限" />
<span class="sep">至</span>
<el-input v-model="row.girthMax" size="small" placeholder="上限" />
</div>
<div class="field">
<span class="label">三边之和 cm</span>
<el-input v-model="row.sumMin" size="small" placeholder="下限" />
<span class="sep">至</span>
<el-input v-model="row.sumMax" size="small" placeholder="上限" />
</div>
<div class="field span-2">
<span class="label">说明</span>
<el-input v-model="row.remark" size="small" placeholder="例如拒收、地址错误退回" />
</div>
</div>
</div>
</div>
</div>
<template #footer>
<el-button :disabled="!products.length" :loading="copying" @click="copyPrevious">复制上一版本</el-button>
<el-button @click="visible = false">取消</el-button>
<el-button type="primary" :loading="saving" @click="save">保存</el-button>
</template>
</el-dialog>
</template>
<script setup>
import { listPay, listPaySurchargeRule, previousPaySurchargeRule, savePaySurchargeRule } from '@/api/price/pay'
const { proxy } = getCurrentInstance()
const ruleDefs = [
{
value: 'SIZE',
label: '超尺寸',
hint: '按报价里的每一档填写。只写最长边>120 就只填下限;100<最长边≤200 则下限、上限都填。围长是长+2×(宽+高)。任一命中对应「或 / 任一边超过」,全部命中对应「且 / 同时满足」。运费另加 35%、70% 填加收比例,每超出 10cm 填超出步长。'
},
{
value: 'WEIGHT',
label: '超重',
hint: '30<W≤70 填下限 30、上限 70;只写超过 30KG 就只填下限。超过 300kg 后每公斤续收的,填每超出。报价写明按实际重量、不按体积重时,口径选实重。'
},
{
value: 'EXTRA_KG',
label: '超重续收',
hint: '超过某个重量后只收超出部分。偏远按公斤且有最低消费的,把邮编和最低消费写在这一条。'
},
{ value: 'POSTCODE', label: '命中邮编', switchOnly: true },
{ value: 'ZONE', label: '命中分区', switchOnly: true },
{
value: 'ALWAYS',
label: '每票都收',
hint: '燃油、去碳、道路通行、旺季这类。按比例的填写比例和基数,旺季填写生效日期。'
},
{
value: 'RETURN',
label: '退件',
hint: '同正向运费、空运或陆运分开配。超尺寸或超重才退件的,把重量和最长边、围长写在同一条。'
}
]
const visible = ref(false)
const saving = ref(false)
const copying = ref(false)
const searching = ref(false)
const keyword = ref('')
const found = ref([])
const products = ref([])
const enabled = reactive({})
const groups = reactive({})
function blank(rule) {
if (rule === 'SIZE') {
return { matchMode: 'ANY', boxMode: 'OVER', weightMin: '', weightMax: '', longestMin: '', longestMax: '', secondMin: '', secondMax: '', sumMin: '', sumMax: '', girthMin: '', girthMax: '', boxLength: '', boxWidth: '', boxHeight: '', volumeMin: '', volumeMax: '', cubicMax: '', exceedStepCm: '', exceedRatio: '', remark: '' }
}
if (rule === 'WEIGHT') {
return { weightMin: '', weightMax: '', weightBasis: 'ACTUAL', stepKg: '', minCharge: '', exceedRatio: '', remark: '' }
}
if (rule === 'EXTRA_KG') {
return { thresholdKg: '', stepKg: '1', weightBasis: 'ACTUAL', minCharge: '', postcodes: '' }
}
if (rule === 'ALWAYS') {
return { rateMode: 'FIXED', ratio: '', chargeBase: '', periodStart: '', periodEnd: '', remark: '' }
}
return { chargeMode: 'SAME', weightMin: '', weightMax: '', matchMode: '', longestMin: '', longestMax: '', girthMin: '', girthMax: '', sumMin: '', sumMax: '', remark: '' }
}
function blankGroups() {
for (const rule of ruleDefs) {
enabled[rule.value] = false
groups[rule.value] = []
}
}
function reset() {
keyword.value = ''
found.value = []
products.value = []
blankGroups()
saving.value = false
copying.value = false
searching.value = false
}
function open(rows) {
reset()
visible.value = true
const skipped = []
for (const row of rows || []) addProduct(row, skipped)
if (skipped.length) proxy.$modal.msgWarning('有产品还没有生效版本,未带入:' + skipped.join('、'))
const first = products.value[0]
if (first) loadRules(first.productId, first.termId)
}
function versionOf(row) {
return {
key: String(row.versionProductId || row.productId) + ':' + String(row.termId || ''),
productId: row.versionProductId || row.productId,
termId: row.termId,
versionNo: row.versionNo,
productName: row.productName || '未命名产品'
}
}
function addProduct(row, skipped) {
const item = versionOf(row)
if (!item.productId || !item.termId) {
if (skipped) skipped.push(item.productName)
else proxy.$modal.msgWarning(item.productName + '还没有生效版本,不能绑定')
return
}
if (products.value.some(product => product.key === item.key)) return
products.value.push(item)
}
function removeProduct(item) {
products.value = products.value.filter(product => product.key !== item.key)
}
function termText(row) {
const start = row.termStart || row.effectiveStart || ''
const end = row.termEnd || row.effectiveEnd || ''
if (!start && !end) return '-'
return (String(start).slice(0, 10) || '不限') + ' 至 ' + (String(end).slice(0, 10) || '不限')
}
function searchProducts() {
searching.value = true
listPay({ productName: keyword.value.trim(), templateOnly: true, currentOnly: true, pageNum: 1, pageSize: 20 }).then(res => {
found.value = res.rows || []
}).finally(() => {
searching.value = false
})
}
function toggleRule(rule, value) {
const def = ruleDefs.find(item => item.value === rule)
if (def?.switchOnly) return
if (value && !groups[rule].length) groups[rule].push(blank(rule))
}
function addRow(rule) {
groups[rule].push(blank(rule))
}
function applyRules(list) {
blankGroups()
for (const item of list || []) {
const rule = item.calcRule
if (!groups[rule]) continue
enabled[rule] = item.enabled !== '0'
if (ruleDefs.find(def => def.value === rule)?.switchOnly) continue
if (item.enabled === '0') continue
const row = blank(rule)
const detail = item.detail || {}
Object.keys(row).forEach(key => {
if (detail[key] !== undefined && detail[key] !== null) row[key] = String(detail[key])
})
groups[rule].push(row)
}
for (const rule of ruleDefs) {
if (rule.switchOnly) continue
if (enabled[rule.value] && !groups[rule.value].length) groups[rule.value].push(blank(rule.value))
}
}
function loadRules(productId, termId) {
listPaySurchargeRule(productId, termId).then(res => applyRules(res.data || []))
}
const openedRules = computed(() => ruleDefs.filter(rule => enabled[rule.value] && !rule.switchOnly))
function detailOf(rule, row) {
const detail = {}
const template = blank(rule)
Object.keys(template).forEach(key => {
const value = row[key]
if (value === '' || value === null || value === undefined) return
detail[key] = value
})
return detail
}
function payloadRules() {
const rules = []
for (const rule of ruleDefs) {
if (!enabled[rule.value]) continue
if (rule.switchOnly) {
rules.push({ calcRule: rule.value, enabled: '1', detail: {} })
continue
}
const rows = groups[rule.value].length ? groups[rule.value] : [blank(rule.value)]
rows.forEach(row => {
rules.push({ calcRule: rule.value, enabled: '1', detail: detailOf(rule.value, row) })
})
}
return rules
}
function copyPrevious() {
const first = products.value[0]
if (!first) return
copying.value = true
previousPaySurchargeRule(first.productId).then(res => {
const list = res.data || []
if (!list.length) {
proxy.$modal.msgWarning('上一版本没有计费条件')
return
}
applyRules(list)
proxy.$modal.msgSuccess('已带入上一版本,保存后写到当前版本')
}).finally(() => {
copying.value = false
})
}
function save() {
if (!products.value.length) {
proxy.$modal.msgError('请选择要绑定的产品')
return
}
saving.value = true
savePaySurchargeRule({
products: products.value.map(item => ({
productId: item.productId,
termId: item.termId,
versionNo: item.versionNo,
productName: item.productName
})),
rules: payloadRules()
}).then(() => {
proxy.$modal.msgSuccess('已保存到当前版本')
visible.value = false
}).finally(() => {
saving.value = false
})
}
defineExpose({ open })
</script>
<style scoped>
.rule-body { max-height: 68vh; overflow: auto; padding-right: 4px; }
.rule-block { margin-bottom: 16px; }
.rule-title { font-weight: 600; }
.rule-products { display: flex; flex-wrap: wrap; gap: 8px; min-height: 32px; margin: 8px 0; }
.rule-tag { margin: 0; }
.rule-empty { color: var(--el-text-color-secondary); font-size: 13px; }
.rule-search { display: flex; gap: 8px; margin-bottom: 8px; }
.rule-hint { margin: 6px 0 8px; color: var(--el-text-color-secondary); font-size: 12px; line-height: 1.5; }
.rule-switches { display: flex; flex-wrap: wrap; gap: 12px 20px; margin-top: 8px; }
.rule-switch { display: flex; align-items: center; gap: 8px; }
.rule-bar, .rule-card-bar { display: flex; align-items: center; justify-content: space-between; }
.rule-card { border: 1px solid var(--el-border-color); border-radius: 6px; padding: 8px 12px 12px; margin-bottom: 10px; }
.rule-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; }
.field { display: flex; align-items: center; gap: 6px; min-width: 0; }
.field .label { width: 118px; flex: none; font-size: 13px; color: var(--el-text-color-regular); }
.field .el-input, .field .el-select { flex: 1; min-width: 0; }
.field .sep { flex: none; color: var(--el-text-color-secondary); }
.field .mode { flex: 0 0 118px; }
.span-2 { grid-column: 1 / -1; }
</style>
@@ -22,6 +22,9 @@
<el-col :span="1.5">
<el-button type="warning" plain icon="Download" @click="handleExportDetail" v-hasPermi="['price:pay:export']">导出明细</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="primary" plain icon="Setting" @click="openRule(selection)" v-hasPermi="['price:pay:edit']">附加费配置</el-button>
</el-col>
</template>
<template #col-sourceFile="{ row }">
@@ -60,6 +63,7 @@
</basic-table>
<pay-import-dialog ref="importRef" @saved="tableRef.refresh()" />
<pay-surcharge-rule-dialog ref="ruleRef" />
<el-drawer v-model="historyVisible" :title="historyTitle" size="980px" append-to-body destroy-on-close>
<div class="history-bar">
@@ -187,10 +191,12 @@
import { listPay, getPay, delPay, updatePay, listPayTerm, updatePayTerm, changePayTermStatus, comparePay } from '@/api/price/pay'
import PayImportDialog from './components/PayImportDialog.vue'
import PayConfigDetail from './components/PayConfigDetail.vue'
import PaySurchargeRuleDialog from './components/PaySurchargeRuleDialog.vue'
const { proxy } = getCurrentInstance()
const tableRef = ref()
const importRef = ref()
const ruleRef = ref()
const detailVisible = ref(false)
const detailLoading = ref(false)
const savingRowKey = ref('')
@@ -314,6 +320,10 @@ function handleDelete(ids) {
}).catch(() => {})
}
function openRule(selection) {
ruleRef.value?.open(selection || [])
}
function openDetail(row) {
detailVisible.value = true
savingRowKey.value = ''
@@ -93,6 +93,7 @@
width="640px"
:show-update-support="false"
:import-desc="importDesc"
desc-on-title
:template-download-handler="downloadTemplate"
:submit-handler="submitImport"
/>
@@ -23,7 +23,9 @@
<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 prop="totalAmount" label="我方金额" width="110" align="right" />
<el-table-column prop="paidAmount" label="已核销" width="100" align="right" />
<el-table-column prop="dueDate" label="到期日" width="120" />
<el-table-column label="来源" width="90" align="center">
<template #default="{ row }">{{ sourceText(row.sourceType) }}</template>
</el-table-column>
@@ -31,12 +33,14 @@
<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">
<el-table-column label="操作" width="280" 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>
<el-button v-if="row.status === 'DRAFT'" link type="primary" @click="submitRow(row)" v-hasPermi="['price:payBill:submit', 'price:payBill:confirm']">提交审核</el-button>
<el-button v-if="row.status === 'PENDING'" link type="primary" @click="approveRow(row)" v-hasPermi="['price:payBill:approve', 'price:payBill:confirm']">通过</el-button>
<el-button v-if="row.status === 'PENDING'" link type="warning" @click="openReject(row)" v-hasPermi="['price:payBill:approve', 'price:payBill:confirm']">驳回</el-button>
<el-button v-if="canRed(row)" link type="warning" @click="openRed(row)" v-hasPermi="['price:payBill:approve', 'price:payBill:confirm']">红字</el-button>
<el-button v-if="row.status === 'DRAFT' || row.status === 'PENDING'" link type="danger" @click="openVoid(row)" v-hasPermi="['price:payBill:void']">作废</el-button>
</template>
</el-table-column>
</el-table>
@@ -65,6 +69,9 @@
<el-option v-for="item in suppliers" :key="item.supplierId" :label="item.supplierName" :value="item.supplierId" />
</el-select>
</el-form-item>
<el-form-item label="到期日">
<el-date-picker v-model="command.dueDate" type="date" value-format="YYYY-MM-DD" placeholder="不填则按供应商账期" style="width: 220px" />
</el-form-item>
</el-form>
<div class="mb8">
<el-button @click="runPreview">查询订单</el-button>
@@ -87,8 +94,8 @@
<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 label="状态" width="170" show-overflow-tooltip>
<template #default="{ row }">{{ previewStatus(row) }}</template>
</el-table-column>
</el-table>
<template #footer>
@@ -97,36 +104,170 @@
</template>
</el-dialog>
<el-drawer v-model="detailVisible" :title="detail?.billNo || '应付账单'" size="70%">
<el-drawer v-model="detailVisible" :title="detailTitle" size="78%">
<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.totalAmount }}</el-descriptions-item>
<el-descriptions-item label="对方金额">{{ detail.supplierAmount }}</el-descriptions-item>
<el-descriptions-item label="已核销">{{ detail.paidAmount || 0 }}</el-descriptions-item>
<el-descriptions-item label="不含税">{{ detail.amountNet || 0 }}</el-descriptions-item>
<el-descriptions-item label="税额">{{ detail.taxAmount || 0 }}</el-descriptions-item>
<el-descriptions-item label="汇率">{{ detail.exchangeRate || 1 }}</el-descriptions-item>
<el-descriptions-item label="本位币">{{ detail.baseAmount || 0 }}</el-descriptions-item>
<el-descriptions-item label="到期日">{{ detail.dueDate || '-' }}</el-descriptions-item>
<el-descriptions-item label="订单数">{{ detail.orderCount }}</el-descriptions-item>
<el-descriptions-item label="单据">{{ detail.billKind === 'RED' ? '红字' : '蓝字' }}</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>
<el-tabs>
<el-tab-pane label="费用">
<div class="mb8">
<el-button v-if="detail.status === 'DRAFT'" type="primary" @click="saveDiff" v-hasPermi="['price:payBill:add', 'price:payBill:submit']">保存对方金额</el-button>
<el-button v-if="detail.status === 'DRAFT'" @click="openFinance" v-hasPermi="['price:payBill:add', 'price:payBill:submit']">价税汇率</el-button>
<el-button @click="downloadStatement" v-hasPermi="['price:payBill:query']">导出对账单</el-button>
<el-upload v-if="detail.status === 'DRAFT'" class="inline-upload" :show-file-list="false" accept=".xlsx" :http-request="importSupplier" v-hasPermi="['price:payBill:add', 'price:payBill:submit']">
<el-button>导入对方金额</el-button>
</el-upload>
</div>
<el-table :data="detail.lines || []" border size="small" max-height="360">
<el-table-column prop="orderNo" label="订单号" min-width="130" />
<el-table-column prop="ladingNo" label="提单号" min-width="110" />
<el-table-column prop="feeName" label="费用" min-width="120" />
<el-table-column prop="amount" label="我方金额" width="100" align="right" />
<el-table-column label="对方金额" width="130">
<template #default="{ row }">
<el-input-number v-if="detail.status === 'DRAFT'" v-model="row.supplierAmount" :precision="4" :controls="false" style="width: 110px" />
<span v-else>{{ row.supplierAmount ?? '-' }}</span>
</template>
</el-table-column>
<el-table-column label="差异" width="90" align="center">
<template #default="{ row }">{{ diffText(row.diffStatus) }}</template>
</el-table-column>
<el-table-column label="处理" width="180" align="center">
<template #default="{ row }">
<template v-if="detail.status === 'DRAFT' && row.diffStatus === 'OPEN'">
<el-button link type="primary" @click="acceptDiff(row, 'OURS')">接受我方</el-button>
<el-button link type="primary" @click="acceptDiff(row, 'THEIRS')">接受对方</el-button>
</template>
<el-button v-if="detail.status === 'DRAFT'" link type="danger" @click="removeLine(row)">剔除</el-button>
</template>
</el-table-column>
</el-table>
</el-tab-pane>
<el-tab-pane label="凭证">
<el-form v-if="detail.status !== 'VOID' && detail.status !== 'RED'" :inline="true" class="mb8">
<el-form-item label="类型">
<el-select v-model="fileForm.fileType" style="width: 120px">
<el-option label="发票" value="INVOICE" />
<el-option label="对账单" value="STATEMENT" />
<el-option label="费用通知" value="DEBIT" />
<el-option label="其他" value="OTHER" />
</el-select>
</el-form-item>
<el-form-item label="发票号">
<el-input v-model="fileForm.invoiceNo" style="width: 140px" />
</el-form-item>
<el-form-item label="价税合计">
<el-input-number v-model="fileForm.amount" :precision="2" :controls="false" style="width: 120px" />
</el-form-item>
<el-form-item label="税额">
<el-input-number v-model="fileForm.taxAmount" :precision="2" :controls="false" style="width: 110px" />
</el-form-item>
<el-form-item label="销方">
<el-input v-model="fileForm.sellerName" style="width: 140px" />
</el-form-item>
<el-form-item>
<el-upload :action="uploadAction" :headers="uploadHeaders" :show-file-list="false" :on-success="onFileUploaded">
<el-button type="primary" v-hasPermi="['price:payVoucher:add', 'price:payBill:add']">上传</el-button>
</el-upload>
</el-form-item>
</el-form>
<el-table :data="detail.files || []" border size="small">
<el-table-column label="类型" width="100">
<template #default="{ row }">{{ fileTypeText(row.fileType) }}</template>
</el-table-column>
<el-table-column prop="invoiceNo" label="发票号" width="140" />
<el-table-column prop="amount" label="价税合计" width="110" align="right" />
<el-table-column prop="taxAmount" label="税额" width="90" align="right" />
<el-table-column prop="matchedAmount" label="已勾稽" width="90" align="right" />
<el-table-column prop="fileName" label="文件" min-width="160" show-overflow-tooltip />
<el-table-column prop="createBy" label="上传人" width="100" />
<el-table-column prop="createTime" label="时间" width="170" />
<el-table-column label="操作" width="120" align="center">
<template #default="{ row }">
<el-link :href="row.fileUrl" target="_blank" type="primary">查看</el-link>
<el-button v-if="detail.status === 'DRAFT' || detail.status === 'PENDING'" link type="danger" @click="removeFile(row)" v-hasPermi="['price:payVoucher:remove', 'price:payBill:void']">删除</el-button>
</template>
</el-table-column>
</el-table>
</el-tab-pane>
<el-tab-pane label="审核">
<el-table :data="detail.approvals || []" border size="small">
<el-table-column prop="createTime" label="时间" width="170" />
<el-table-column prop="operatorName" label="操作人" width="100" />
<el-table-column label="动作" width="100">
<template #default="{ row }">{{ actionText(row.action) }}</template>
</el-table-column>
<el-table-column prop="opinion" label="意见" min-width="180" />
</el-table>
</el-tab-pane>
<el-tab-pane label="操作记录">
<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 label="动作" width="110">
<template #default="{ row }">{{ actionText(row.operationType) }}</template>
</el-table-column>
<el-table-column label="状态" width="160">
<template #default="{ row }">{{ statusText(row.fromStatus) }} → {{ statusText(row.toStatus) }}</template>
</el-table-column>
<el-table-column prop="amountBefore" label="改前" width="90" align="right" />
<el-table-column prop="amountAfter" label="改后" width="90" align="right" />
<el-table-column prop="operationDesc" label="说明" min-width="180" show-overflow-tooltip />
</el-table>
</el-tab-pane>
</el-tabs>
</template>
</el-drawer>
<el-dialog v-model="rejectVisible" title="驳回应付账单" width="460px" append-to-body>
<el-input v-model="rejectOpinion" type="textarea" :rows="3" placeholder="驳回意见" />
<template #footer>
<el-button @click="rejectVisible = false">取消</el-button>
<el-button type="warning" @click="runReject">确认驳回</el-button>
</template>
</el-dialog>
<el-dialog v-model="redVisible" title="应付红字" width="460px" append-to-body>
<el-input v-model="redReason" type="textarea" :rows="3" placeholder="红字原因" />
<template #footer>
<el-button @click="redVisible = false">取消</el-button>
<el-button type="warning" @click="runRed">生成红字</el-button>
</template>
</el-dialog>
<el-dialog v-model="financeVisible" title="价税与汇率" width="460px" append-to-body>
<el-form label-width="90px">
<el-form-item label="税率">
<el-input-number v-model="financeForm.taxRate" :min="0" :max="0.9999" :precision="4" :step="0.01" :controls="false" style="width: 180px" />
</el-form-item>
<el-form-item label="汇率">
<el-input-number v-model="financeForm.exchangeRate" :min="0.000001" :precision="6" :controls="false" style="width: 180px" />
</el-form-item>
<el-form-item label="汇率日期">
<el-date-picker v-model="financeForm.rateDate" type="date" value-format="YYYY-MM-DD" style="width: 180px" />
</el-form-item>
</el-form>
<div class="preview-msg">税率填小数,0.06 表示 6%。金额按价税合计拆成不含税和税额,再按汇率折人民币。</div>
<template #footer>
<el-button @click="financeVisible = false">取消</el-button>
<el-button type="primary" @click="saveFinance">保存</el-button>
</template>
</el-dialog>
<el-dialog v-model="voidVisible" title="作废应付账单" width="460px" append-to-body>
<el-input v-model="voidReason" type="textarea" :rows="3" placeholder="作废原因" />
<template #footer>
@@ -139,8 +280,9 @@
</template>
<script setup name="PayBill">
import { getToken } from '@/utils/auth'
import { listSupplier } from '@/api/customersuppliermanagement/supplierinfo/supplier'
import { listPayBill, getPayBill, previewPayBill, generatePayBill, confirmPayBill, payPayBill, voidPayBill } from '@/api/price/payBill'
import { listPayBill, getPayBill, previewPayBill, generatePayBill, voidPayBill, submitPayBill, approvePayBill, rejectPayBill, savePayBillDiff, acceptPayBillDiff, removePayBillLine, savePayBillFile, deletePayBillFile, redPayBill, savePayFinance, exportPayStatement, importPaySupplier } from '@/api/price/payBill'
const { proxy } = getCurrentInstance()
const loading = ref(false)
@@ -149,15 +291,30 @@ const total = ref(0)
const query = reactive({ pageNum: 1, pageSize: 10, billNo: '', supplierName: '', status: '' })
const statusOptions = [
{ label: '草稿', value: 'DRAFT' },
{ label: '待审核', value: 'PENDING' },
{ label: '已确认', value: 'CONFIRMED' },
{ label: '已付款', value: 'PAID' },
{ label: '部分付款', value: 'PARTIAL' },
{ label: '已付清', value: 'PAID' },
{ label: '已红冲', value: 'RED' },
{ label: '已作废', value: 'VOID' }
]
const uploadAction = import.meta.env.VITE_APP_BASE_API + '/common/upload'
const uploadHeaders = { Authorization: 'Bearer ' + getToken() }
const fileForm = reactive({ fileType: 'INVOICE', invoiceNo: '', amount: null, taxAmount: 0, sellerName: '' })
const rejectVisible = ref(false)
const rejectOpinion = ref('')
const rejectId = ref(null)
const redVisible = ref(false)
const redReason = ref('')
const redId = ref(null)
const detailTitle = computed(() => detail.value?.billNo || '应付账单')
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 command = reactive({ sourceType: 'ORDER', orderText: '', ladingText: '', supplierId: null, beginDate: '', endDate: '', dueDate: '' })
const financeVisible = ref(false)
const financeForm = reactive({ taxRate: 0, exchangeRate: 1, rateDate: '' })
const preview = reactive({ orders: [], occupied: [], missingNos: [], message: '' })
const detailVisible = ref(false)
const detail = ref(null)
@@ -181,6 +338,37 @@ function sourceText(value) {
return { ORDER: '订单号', TIME: '计费日', LADING: '提单' }[value] || value || '-'
}
function diffText(value) {
return { NONE: '-', OPEN: '待处理', ACCEPT_OURS: '接受我方', ACCEPT_THEIRS: '接受对方' }[value] || value || '-'
}
function fileTypeText(value) {
return { INVOICE: '发票', STATEMENT: '对账单', DEBIT: '费用通知', OTHER: '其他' }[value] || value || '-'
}
function actionText(value) {
return {
CREATE: '生成', SUBMIT: '提交审核', APPROVE: '审核通过', REJECT: '驳回', CONFIRM: '确认',
VOID: '作废', REMOVE: '剔除', DIFF: '登记差异', ACCEPT: '处理差异', FILE: '上传凭证',
FILE_DEL: '删除凭证', RED: '红字', PAY: '付款核销', TAX: '价税汇率', EXPORT: '导出对账单', REVERSE: '反核销'
}[value] || value || '-'
}
function previewStatus(row) {
if (row.unbilledCount > 0 && row.occupiedBillNo) return '部分可出 ' + row.occupiedBillNo
if (row.occupiedBillNo) return '已入账 ' + row.occupiedBillNo
return '可生成'
}
function canRed(row) {
return (row.status === 'CONFIRMED' || row.status === 'PARTIAL') && row.billKind !== 'RED' && !(Number(row.paidAmount) > 0)
}
function reloadDetail() {
if (!detail.value?.billId) return
getPayBill(detail.value.billId).then(res => { detail.value = res.data })
}
function loadList() {
loading.value = true
listPayBill(query).then(res => {
@@ -191,17 +379,55 @@ function loadList() {
})
}
function ensureSuppliers() {
if (!suppliers.value.length) {
listSupplier({ pageNum: 1, pageSize: 500 }).then(res => {
suppliers.value = res.rows || []
})
}
}
function openFinance() {
financeForm.taxRate = Number(detail.value.taxRate || 0)
financeForm.exchangeRate = Number(detail.value.exchangeRate || 1)
financeForm.rateDate = detail.value.rateDate || ''
financeVisible.value = true
}
function saveFinance() {
savePayFinance({ billId: detail.value.billId, taxRate: financeForm.taxRate, exchangeRate: financeForm.exchangeRate, rateDate: financeForm.rateDate }).then(() => {
proxy.$modal.msgSuccess('价税和汇率已保存')
financeVisible.value = false
reloadDetail()
})
}
function downloadStatement() {
exportPayStatement(detail.value.billId).then(data => {
const blob = new Blob([data])
const url = URL.createObjectURL(blob)
const link = document.createElement('a')
link.href = url
link.download = (detail.value.billNo || '对账单') + '.xlsx'
link.click()
URL.revokeObjectURL(url)
})
}
function importSupplier(option) {
importPaySupplier(detail.value.billId, option.file).then(() => {
proxy.$modal.msgSuccess('对方金额已导入')
reloadDetail()
})
}
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 || []
})
}
ensureSuppliers()
}
function buildCommand() {
@@ -225,8 +451,13 @@ function runPreview() {
function runGenerate() {
saving.value = true
generatePayBill(buildCommand()).then(() => {
proxy.$modal.msgSuccess('应付账单已生成')
generatePayBill(buildCommand()).then(res => {
const desc = (res.data?.logs || []).find(item => item.operationType === 'CREATE')?.operationDesc || ''
if (desc.includes('未并入')) {
proxy.$modal.msgWarning(desc)
} else {
proxy.$modal.msgSuccess('应付账单已生成')
}
createVisible.value = false
loadList()
}).finally(() => {
@@ -241,17 +472,100 @@ function openDetail(row) {
})
}
function confirmRow(row) {
proxy.$modal.confirm('确认这张应付账单?确认后金额锁定。').then(() => confirmPayBill(row.billId)).then(() => {
proxy.$modal.msgSuccess('已确认')
function submitRow(row) {
proxy.$modal.confirm('提交这张应付账单审核?有未处理差异时不能提交。').then(() => submitPayBill(row.billId)).then(() => {
proxy.$modal.msgSuccess('已提交审核')
loadList()
}).catch(() => {})
}
function payRow(row) {
proxy.$modal.confirm('登记这张账单已付款?已付款后不能直接作废。').then(() => payPayBill(row.billId)).then(() => {
proxy.$modal.msgSuccess('已登记付款')
function approveRow(row) {
proxy.$modal.confirm('审核通过?蓝字需要发票价税合计、税额和账单一致,审核人不能是提交人。').then(() => approvePayBill(row.billId)).then(() => {
proxy.$modal.msgSuccess('已审核通过')
loadList()
if (detail.value?.billId === row.billId) reloadDetail()
}).catch(() => {})
}
function openReject(row) {
rejectId.value = row.billId
rejectOpinion.value = ''
rejectVisible.value = true
}
function runReject() {
if (!rejectOpinion.value.trim()) {
proxy.$modal.msgWarning('请填写驳回意见')
return
}
rejectPayBill({ billId: rejectId.value, opinion: rejectOpinion.value.trim() }).then(() => {
proxy.$modal.msgSuccess('已驳回')
rejectVisible.value = false
loadList()
})
}
function openRed(row) {
redId.value = row.billId
redReason.value = ''
redVisible.value = true
}
function runRed() {
redPayBill({ billId: redId.value, reason: redReason.value.trim() }).then(() => {
proxy.$modal.msgSuccess('红字草稿已生成,审核通过后原费用才可以再次出账')
redVisible.value = false
loadList()
})
}
function saveDiff() {
savePayBillDiff({ billId: detail.value.billId, lines: detail.value.lines }).then(() => {
proxy.$modal.msgSuccess('对方金额已保存')
reloadDetail()
})
}
function acceptDiff(row, handleType) {
const text = handleType === 'THEIRS' ? '接受对方金额?差额会另写一条对账调整,原来的计算金额不变。' : '接受我方金额?'
proxy.$modal.confirm(text).then(() => acceptPayBillDiff({ billId: detail.value.billId, lineId: row.lineId, handleType })).then(() => {
proxy.$modal.msgSuccess('差异已处理')
reloadDetail()
}).catch(() => {})
}
function removeLine(row) {
proxy.$modal.confirm('从这张草稿剔除这条费用?剔除后它可以进入别的账单。').then(() => removePayBillLine({ billId: detail.value.billId, lineId: row.lineId })).then(() => {
proxy.$modal.msgSuccess('已剔除')
reloadDetail()
loadList()
}).catch(() => {})
}
function onFileUploaded(res) {
if (res.code !== 200) {
proxy.$modal.msgError(res.msg || '上传失败')
return
}
savePayBillFile({
billId: detail.value.billId,
fileType: fileForm.fileType,
invoiceNo: fileForm.invoiceNo,
amount: fileForm.amount,
taxAmount: fileForm.taxAmount,
sellerName: fileForm.sellerName,
fileName: res.originalFilename || res.newFileName,
fileUrl: res.url || res.fileName
}).then(() => {
proxy.$modal.msgSuccess('凭证已上传')
reloadDetail()
})
}
function removeFile(row) {
proxy.$modal.confirm('删除这张凭证?').then(() => deletePayBillFile(row.fileId)).then(() => {
proxy.$modal.msgSuccess('已删除')
reloadDetail()
}).catch(() => {})
}
@@ -278,6 +592,7 @@ loadList()
<style scoped>
.preview-msg { margin-left: 12px; color: #909399; }
.inline-upload { display: inline-block; margin: 0 8px; vertical-align: middle; }
.mb8 { margin-bottom: 8px; }
.pay-bill-date :deep(.el-date-editor) {
width: 280px !important;
@@ -0,0 +1,241 @@
<template>
<div class="app-container">
<el-form :inline="true" :model="query" class="mb8">
<el-form-item label="付款单号">
<el-input v-model="query.paymentNo" clearable style="width: 180px" />
</el-form-item>
<el-form-item label="供应商">
<el-input v-model="query.supplierName" clearable style="width: 180px" />
</el-form-item>
<el-form-item label="状态">
<el-select v-model="query.status" clearable placeholder="全部" style="width: 120px">
<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:payPayment:add']">登记付款</el-button>
</el-form-item>
</el-form>
<el-table v-loading="loading" :data="rows" border>
<el-table-column prop="paymentNo" 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="payDate" label="付款日" width="120" />
<el-table-column label="方式" width="100" align="center">
<template #default="{ row }">{{ methodText(row.payMethod) }}</template>
</el-table-column>
<el-table-column prop="amount" label="付款金额" width="120" align="right" />
<el-table-column prop="allocAmount" label="已核销" width="110" align="right" />
<el-table-column prop="bankFee" label="手续费" width="100" align="right" />
<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="280" 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:payPayment:confirm']">确认付款</el-button>
<el-button v-if="row.status === 'DRAFT'" link type="danger" @click="voidRow(row)" v-hasPermi="['price:payPayment:void']">作废</el-button>
<el-button v-if="row.status === 'PAID'" link type="warning" @click="reverseRow(row)" v-hasPermi="['price:payPayment:confirm']">反核销</el-button>
<el-button v-if="row.status === 'PAID'" link type="danger" @click="refundRow(row)" v-hasPermi="['price:payPayment:confirm']">退款</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="920px" append-to-body>
<el-form :inline="true" label-width="80px">
<el-form-item label="供应商" required>
<el-select v-model="form.supplierId" filterable placeholder="选择供应商" style="width: 220px" @change="loadOpen">
<el-option v-for="item in suppliers" :key="item.supplierId" :label="item.supplierName" :value="item.supplierId" />
</el-select>
</el-form-item>
<el-form-item label="币种" required>
<el-select v-model="form.currency" filterable style="width: 120px" @change="loadOpen">
<el-option v-for="item in bms_currency" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
<el-form-item label="付款日" required>
<el-date-picker v-model="form.payDate" type="date" value-format="YYYY-MM-DD" style="width: 150px" />
</el-form-item>
<el-form-item label="方式">
<el-select v-model="form.payMethod" style="width: 130px">
<el-option label="银行转账" value="BANK" />
<el-option label="现金" value="CASH" />
<el-option label="其他" value="OTHER" />
</el-select>
</el-form-item>
<el-form-item label="账户">
<el-input v-model="form.bankAccount" style="width: 180px" />
</el-form-item>
<el-form-item label="付款金额" required>
<el-input-number v-model="form.amount" :min="0" :precision="2" :controls="false" style="width: 140px" />
</el-form-item>
<el-form-item label="手续费">
<el-input-number v-model="form.bankFee" :min="0" :precision="2" :controls="false" style="width: 120px" />
</el-form-item>
<el-form-item label="汇率">
<el-input-number v-model="form.exchangeRate" :min="0.000001" :precision="6" :controls="false" style="width: 140px" />
</el-form-item>
</el-form>
<div class="mb8">未付账单。本次核销合计 {{ allocTotal }}。本次核销合计不能超过付款金额。</div>
<el-table :data="openBills" border size="small" max-height="320" empty-text="先选择供应商和币种">
<el-table-column prop="billNo" label="账单号" min-width="160" />
<el-table-column prop="openAmount" label="未付金额" width="120" align="right" />
<el-table-column label="本次核销" width="150">
<template #default="{ row }">
<el-input-number v-model="row.allocAmount" :min="0" :precision="2" :controls="false" style="width: 120px" />
</template>
</el-table-column>
</el-table>
<template #footer>
<el-button @click="createVisible = false">取消</el-button>
<el-button type="primary" :loading="saving" @click="savePayment">保存草稿</el-button>
</template>
</el-dialog>
<el-drawer v-model="detailVisible" :title="detail?.paymentNo || '应付付款'" size="60%">
<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.amount }}</el-descriptions-item>
<el-descriptions-item label="已核销">{{ detail.allocAmount || 0 }}</el-descriptions-item>
<el-descriptions-item label="汇率">{{ detail.exchangeRate || 1 }}</el-descriptions-item>
<el-descriptions-item label="本位币">{{ detail.baseAmount || 0 }}</el-descriptions-item>
<el-descriptions-item label="手续费">{{ detail.bankFee }}</el-descriptions-item>
<el-descriptions-item label="付款日">{{ detail.payDate }}</el-descriptions-item>
<el-descriptions-item label="账户">{{ detail.bankAccount || '-' }}</el-descriptions-item>
</el-descriptions>
<el-table :data="detail.allocs || []" border size="small">
<el-table-column prop="billNo" label="账单号" min-width="160" />
<el-table-column prop="allocAmount" label="核销金额" width="120" align="right" />
<el-table-column label="状态" width="100">
<template #default="{ row }">{{ row.allocStatus === 'REVERSED' ? '已反核销' : '有效' }}</template>
</el-table-column>
</el-table>
</template>
</el-drawer>
</div>
</template>
<script setup name="PayPayment">
import { listSupplier } from '@/api/customersuppliermanagement/supplierinfo/supplier'
import { listPayPayment, getPayPayment, openPayBills, createPayPayment, confirmPayPayment, voidPayPayment, reversePayPayment, refundPayPayment } from '@/api/price/payPayment'
const { proxy } = getCurrentInstance()
const { bms_currency } = useDict('bms_currency')
const loading = ref(false)
const saving = ref(false)
const rows = ref([])
const total = ref(0)
const query = reactive({ pageNum: 1, pageSize: 10, paymentNo: '', supplierName: '', status: '' })
const statusOptions = [
{ label: '草稿', value: 'DRAFT' },
{ label: '已付款', value: 'PAID' },
{ label: '已退款', value: 'REFUNDED' },
{ label: '已作废', value: 'VOID' }
]
const createVisible = ref(false)
const suppliers = ref([])
const openBills = ref([])
const form = reactive({ supplierId: null, currency: 'CNY', payDate: '', payMethod: 'BANK', bankAccount: '', amount: null, bankFee: 0, exchangeRate: 1 })
const detailVisible = ref(false)
const detail = ref(null)
const allocTotal = computed(() => openBills.value.reduce((sum, item) => sum + (Number(item.allocAmount) || 0), 0).toFixed(2))
function statusText(value) {
return statusOptions.find(item => item.value === value)?.label || value || '-'
}
function methodText(value) {
return { BANK: '银行转账', CASH: '现金', OTHER: '其他' }[value] || value || '-'
}
function loadList() {
loading.value = true
listPayPayment(query).then(res => {
rows.value = res.rows || []
total.value = res.total || 0
}).finally(() => { loading.value = false })
}
function openCreate() {
openBills.value = []
form.supplierId = null
form.payDate = ''
form.amount = null
form.bankFee = 0
form.exchangeRate = 1
form.bankAccount = ''
createVisible.value = true
if (!suppliers.value.length) {
listSupplier({ pageNum: 1, pageSize: 500 }).then(res => { suppliers.value = res.rows || [] })
}
}
function loadOpen() {
openBills.value = []
if (!form.supplierId || !form.currency) return
openPayBills(form.supplierId, form.currency).then(res => {
openBills.value = (res.data || []).map(item => ({ ...item, allocAmount: null }))
})
}
function savePayment() {
const allocs = openBills.value
.filter(item => Number(item.allocAmount) > 0)
.map(item => ({ billId: item.billId, allocAmount: item.allocAmount }))
saving.value = true
createPayPayment({ ...form, allocs }).then(() => {
proxy.$modal.msgSuccess('付款草稿已保存,确认后才会核销账单')
createVisible.value = false
loadList()
}).finally(() => { saving.value = false })
}
function openDetail(row) {
getPayPayment(row.paymentId).then(res => {
detail.value = res.data
detailVisible.value = true
})
}
function reverseRow(row) {
proxy.$modal.confirm('反核销这张付款?账单未付金额会回来。确认人不能自己反核销。').then(() => reversePayPayment(row.paymentId)).then(() => {
proxy.$modal.msgSuccess('已反核销')
loadList()
}).catch(() => {})
}
function refundRow(row) {
proxy.$modal.confirm('把这笔付款退回?已核销金额会冲回。').then(() => refundPayPayment(row.paymentId)).then(() => {
proxy.$modal.msgSuccess('已退款')
loadList()
}).catch(() => {})
}
function confirmRow(row) {
proxy.$modal.confirm('确认这张付款?登记人和确认人不能是同一人。').then(() => confirmPayPayment(row.paymentId)).then(() => {
proxy.$modal.msgSuccess('已确认付款')
loadList()
}).catch(() => {})
}
function voidRow(row) {
proxy.$modal.confirm('作废这张草稿付款?').then(() => voidPayPayment(row.paymentId)).then(() => {
proxy.$modal.msgSuccess('已作废')
loadList()
}).catch(() => {})
}
loadList()
</script>
<style scoped>
.mb8 { margin-bottom: 8px; }
</style>
@@ -0,0 +1,75 @@
<template>
<div class="app-container">
<el-form :inline="true" :model="query" class="mb8">
<el-form-item label="账单号">
<el-input v-model="query.billNo" clearable style="width: 180px" />
</el-form-item>
<el-form-item label="供应商">
<el-input v-model="query.supplierName" clearable style="width: 180px" />
</el-form-item>
<el-form-item label="发票号">
<el-input v-model="query.invoiceNo" clearable style="width: 160px" />
</el-form-item>
<el-form-item label="类型">
<el-select v-model="query.fileType" clearable placeholder="全部" style="width: 120px">
<el-option label="发票" value="INVOICE" />
<el-option label="对账单" value="STATEMENT" />
<el-option label="费用通知" value="DEBIT" />
<el-option label="其他" value="OTHER" />
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="Search" @click="loadList">查询</el-button>
</el-form-item>
</el-form>
<div class="mb8 hint">凭证挂在应付账单上。上传、删除请打开对应的应付账单。</div>
<el-table v-loading="loading" :data="rows" border>
<el-table-column prop="billNo" label="账单号" min-width="160" />
<el-table-column prop="supplierName" label="供应商" min-width="140" show-overflow-tooltip />
<el-table-column label="类型" width="100" align="center">
<template #default="{ row }">{{ fileTypeText(row.fileType) }}</template>
</el-table-column>
<el-table-column prop="invoiceNo" label="发票号" min-width="140" />
<el-table-column prop="invoiceDate" label="开票日" width="120" />
<el-table-column prop="amount" label="价税合计" width="110" align="right" />
<el-table-column prop="taxAmount" label="税额" width="100" align="right" />
<el-table-column prop="fileName" label="文件" min-width="160" show-overflow-tooltip />
<el-table-column prop="createBy" label="上传人" width="100" />
<el-table-column prop="createTime" label="上传时间" width="170" />
<el-table-column label="操作" width="80" align="center">
<template #default="{ row }">
<el-link v-if="row.fileUrl" :href="row.fileUrl" target="_blank" type="primary">查看</el-link>
</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" />
</div>
</template>
<script setup name="PayVoucher">
import { listPayBillFile } from '@/api/price/payBill'
const loading = ref(false)
const rows = ref([])
const total = ref(0)
const query = reactive({ pageNum: 1, pageSize: 10, billNo: '', supplierName: '', invoiceNo: '', fileType: '' })
function fileTypeText(value) {
return { INVOICE: '发票', STATEMENT: '对账单', DEBIT: '费用通知', OTHER: '其他' }[value] || value || '-'
}
function loadList() {
loading.value = true
listPayBillFile(query).then(res => {
rows.value = res.rows || []
total.value = res.total || 0
}).finally(() => { loading.value = false })
}
loadList()
</script>
<style scoped>
.mb8 { margin-bottom: 8px; }
.hint { color: var(--el-text-color-secondary); font-size: 13px; }
</style>