应付计费邮编改造
This commit is contained in:
@@ -420,6 +420,7 @@ const keyword = ref('')
|
||||
const found = ref([])
|
||||
const products = ref([])
|
||||
const feeOptions = ref([])
|
||||
const feeCounts = ref({})
|
||||
const zoneOptions = ref([])
|
||||
const enabled = reactive({})
|
||||
const groups = reactive({})
|
||||
@@ -455,6 +456,7 @@ function reset() {
|
||||
found.value = []
|
||||
products.value = []
|
||||
feeOptions.value = []
|
||||
feeCounts.value = {}
|
||||
zoneOptions.value = []
|
||||
blankGroups()
|
||||
saving.value = false
|
||||
@@ -504,24 +506,32 @@ function loadFees() {
|
||||
const bound = products.value.slice()
|
||||
if (!bound.length) {
|
||||
feeOptions.value = []
|
||||
feeCounts.value = {}
|
||||
zoneOptions.value = keepZones([])
|
||||
return
|
||||
return Promise.resolve()
|
||||
}
|
||||
Promise.all(bound.map(item => getPay(item.feeProductId || item.productId).catch(() => null))).then(results => {
|
||||
return Promise.all(bound.map(item => getPay(item.feeProductId || item.productId).catch(() => null))).then(results => {
|
||||
if (token !== feeToken) return
|
||||
const map = new Map()
|
||||
const counts = {}
|
||||
const zones = new Set()
|
||||
results.forEach(res => {
|
||||
const local = {}
|
||||
const rows = res?.data?.surcharges || []
|
||||
rows.forEach(fee => {
|
||||
const name = String(fee.feeName || '').trim()
|
||||
const zone = String(fee.zoneName || '').trim()
|
||||
if (zone) zones.add(zone)
|
||||
if (!name || map.has(name)) return
|
||||
map.set(name, { feeName: name, scId: fee.scId || '' })
|
||||
if (!name) return
|
||||
local[name] = (local[name] || 0) + 1
|
||||
if (!map.has(name)) map.set(name, { feeName: name, scId: fee.scId || '' })
|
||||
})
|
||||
Object.keys(local).forEach(name => {
|
||||
counts[name] = Math.max(counts[name] || 0, local[name])
|
||||
})
|
||||
})
|
||||
zoneOptions.value = keepZones([...zones])
|
||||
feeCounts.value = counts
|
||||
for (const row of groups.ALWAYS || []) {
|
||||
const name = String(row.feeName || '').trim()
|
||||
if (name && !map.has(name)) map.set(name, { feeName: name, scId: row.scId || '' })
|
||||
@@ -659,35 +669,48 @@ function save() {
|
||||
}
|
||||
}
|
||||
if (enabled.ALWAYS) {
|
||||
const names = new Set()
|
||||
for (const row of groups.ALWAYS) {
|
||||
const name = String(row.feeName || '').trim()
|
||||
if (!name) {
|
||||
if (!String(row.feeName || '').trim()) {
|
||||
proxy.$modal.msgError('每票都收要选择费用项')
|
||||
return
|
||||
}
|
||||
if (names.has(name)) {
|
||||
proxy.$modal.msgError('每票都收的费用项不能重复:' + name)
|
||||
return
|
||||
}
|
||||
names.add(name)
|
||||
}
|
||||
}
|
||||
saving.value = true
|
||||
savePaySurchargeRule({
|
||||
products: products.value.map(item => ({
|
||||
productId: item.productId,
|
||||
productName: item.productName
|
||||
})),
|
||||
rules: payloadRules()
|
||||
}).then(() => {
|
||||
proxy.$modal.msgSuccess('已保存,计算时按当前生效版本上的附加费执行')
|
||||
visible.value = false
|
||||
loadFees().then(() => {
|
||||
const duplicated = sameTypeFees()
|
||||
if (duplicated.length) {
|
||||
proxy.$modal.alert('存在两笔同类型的附加费:' + duplicated.join('、'))
|
||||
return
|
||||
}
|
||||
return savePaySurchargeRule({
|
||||
products: products.value.map(item => ({
|
||||
productId: item.productId,
|
||||
productName: item.productName
|
||||
})),
|
||||
rules: payloadRules()
|
||||
}).then(() => {
|
||||
proxy.$modal.msgSuccess('已保存,计算时按当前生效版本上的附加费执行')
|
||||
visible.value = false
|
||||
})
|
||||
}).finally(() => {
|
||||
saving.value = false
|
||||
})
|
||||
}
|
||||
|
||||
function sameTypeFees() {
|
||||
if (!enabled.ALWAYS) return []
|
||||
const seen = new Set()
|
||||
const duplicated = []
|
||||
for (const row of groups.ALWAYS) {
|
||||
const name = String(row.feeName || '').trim()
|
||||
if (!name) continue
|
||||
if (seen.has(name) || Number(feeCounts.value[name] || 0) >= 2) duplicated.push(name)
|
||||
seen.add(name)
|
||||
}
|
||||
return [...new Set(duplicated)]
|
||||
}
|
||||
|
||||
defineExpose({ open })
|
||||
</script>
|
||||
|
||||
|
||||
@@ -281,10 +281,12 @@
|
||||
|
||||
<script setup name="PayBill">
|
||||
import { getToken } from '@/utils/auth'
|
||||
import useUserStore from '@/store/modules/user'
|
||||
import { listSupplier } from '@/api/customersuppliermanagement/supplierinfo/supplier'
|
||||
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 userStore = useUserStore()
|
||||
const loading = ref(false)
|
||||
const rows = ref([])
|
||||
const total = ref(0)
|
||||
@@ -480,7 +482,8 @@ function submitRow(row) {
|
||||
}
|
||||
|
||||
function approveRow(row) {
|
||||
proxy.$modal.confirm('审核通过?蓝字需要发票价税合计、税额和账单一致,审核人不能是提交人。').then(() => approvePayBill(row.billId)).then(() => {
|
||||
const limit = String(userStore.id) === '1' ? '' : ',审核人不能是提交人'
|
||||
proxy.$modal.confirm('审核通过?蓝字需要发票价税合计、税额和账单一致' + limit + '。').then(() => approvePayBill(row.billId)).then(() => {
|
||||
proxy.$modal.msgSuccess('已审核通过')
|
||||
loadList()
|
||||
if (detail.value?.billId === row.billId) reloadDetail()
|
||||
@@ -558,6 +561,11 @@ function onFileUploaded(res) {
|
||||
fileUrl: res.url || res.fileName
|
||||
}).then(() => {
|
||||
proxy.$modal.msgSuccess('凭证已上传')
|
||||
fileForm.fileType = 'INVOICE'
|
||||
fileForm.invoiceNo = ''
|
||||
fileForm.amount = null
|
||||
fileForm.taxAmount = 0
|
||||
fileForm.sellerName = ''
|
||||
reloadDetail()
|
||||
})
|
||||
}
|
||||
|
||||
@@ -38,8 +38,8 @@
|
||||
<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>
|
||||
<el-button v-if="canAct(row)" link type="warning" @click="openAct(row, 'reverse')" v-hasPermi="['price:payPayment:confirm']">反核销</el-button>
|
||||
<el-button v-if="canAct(row)" link type="danger" @click="openAct(row, 'refund')" v-hasPermi="['price:payPayment:confirm']">退款</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@@ -119,14 +119,55 @@
|
||||
</el-table>
|
||||
</template>
|
||||
</el-drawer>
|
||||
|
||||
<el-dialog v-model="actVisible" :title="actTitle" width="920px" append-to-body>
|
||||
<div v-loading="actLoading">
|
||||
<template v-if="actPayment">
|
||||
<el-descriptions :column="3" border size="small" class="mb8">
|
||||
<el-descriptions-item label="付款单号">{{ actPayment.paymentNo }}</el-descriptions-item>
|
||||
<el-descriptions-item label="供应商">{{ actPayment.supplierName }}</el-descriptions-item>
|
||||
<el-descriptions-item label="币种">{{ actPayment.currency }}</el-descriptions-item>
|
||||
<el-descriptions-item label="付款金额">{{ actPayment.amount }}</el-descriptions-item>
|
||||
<el-descriptions-item label="已核销">{{ actPayment.allocAmount || 0 }}</el-descriptions-item>
|
||||
<el-descriptions-item label="手续费">{{ actPayment.bankFee }}</el-descriptions-item>
|
||||
<el-descriptions-item label="付款日">{{ actPayment.payDate }}</el-descriptions-item>
|
||||
<el-descriptions-item label="方式">{{ methodText(actPayment.payMethod) }}</el-descriptions-item>
|
||||
<el-descriptions-item label="账户">{{ actPayment.bankAccount || '-' }}</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
<div class="mb8">核销账单</div>
|
||||
<el-table :data="actAllocs" border size="small" class="mb8" empty-text="没有仍有效的核销">
|
||||
<el-table-column prop="billNo" label="账单号" min-width="160" />
|
||||
<el-table-column prop="allocAmount" label="核销金额" width="120" align="right" />
|
||||
<el-table-column prop="currency" label="币种" width="80" align="center" />
|
||||
</el-table>
|
||||
<div class="mb8">费用明细</div>
|
||||
<el-table :data="actFees" border size="small" max-height="280" empty-text="没有费用明细">
|
||||
<el-table-column prop="billNo" label="账单号" min-width="150" />
|
||||
<el-table-column prop="orderNo" label="订单号" min-width="140" />
|
||||
<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="110" align="right" />
|
||||
<el-table-column prop="currency" label="币种" width="80" align="center" />
|
||||
</el-table>
|
||||
<div class="act-hint">{{ actHint }}</div>
|
||||
</template>
|
||||
</div>
|
||||
<template #footer>
|
||||
<el-button @click="actVisible = false">取消</el-button>
|
||||
<el-button :type="actType === 'refund' ? 'danger' : 'warning'" :loading="actSaving" :disabled="!actPayment" @click="runAct">确认</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="PayPayment">
|
||||
import useUserStore from '@/store/modules/user'
|
||||
import { listSupplier } from '@/api/customersuppliermanagement/supplierinfo/supplier'
|
||||
import { listPayPayment, getPayPayment, openPayBills, createPayPayment, confirmPayPayment, voidPayPayment, reversePayPayment, refundPayPayment } from '@/api/price/payPayment'
|
||||
import { getPayBill } from '@/api/price/payBill'
|
||||
|
||||
const { proxy } = getCurrentInstance()
|
||||
const userStore = useUserStore()
|
||||
const { bms_currency } = useDict('bms_currency')
|
||||
const loading = ref(false)
|
||||
const saving = ref(false)
|
||||
@@ -145,8 +186,23 @@ 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 actVisible = ref(false)
|
||||
const actLoading = ref(false)
|
||||
const actSaving = ref(false)
|
||||
const actType = ref('reverse')
|
||||
const actPayment = ref(null)
|
||||
const actFees = ref([])
|
||||
|
||||
const allocTotal = computed(() => openBills.value.reduce((sum, item) => sum + (Number(item.allocAmount) || 0), 0).toFixed(2))
|
||||
const actTitle = computed(() => actType.value === 'refund' ? '应付退款' : '应付反核销')
|
||||
const actAllocs = computed(() => (actPayment.value?.allocs || []).filter(item => item.allocStatus !== 'REVERSED'))
|
||||
const actHint = computed(() => {
|
||||
const admin = String(userStore.id) === '1'
|
||||
if (actType.value === 'refund') {
|
||||
return admin ? '确认后这些核销会冲回,付款单变为已退款。' : '确认后这些核销会冲回,付款单变为已退款。确认人不能自己退款。'
|
||||
}
|
||||
return admin ? '确认后这些核销会冲回,账单未付金额会回来。' : '确认后这些核销会冲回,账单未付金额会回来。确认人不能自己反核销。'
|
||||
})
|
||||
|
||||
function statusText(value) {
|
||||
return statusOptions.find(item => item.value === value)?.label || value || '-'
|
||||
@@ -156,6 +212,10 @@ function methodText(value) {
|
||||
return { BANK: '银行转账', CASH: '现金', OTHER: '其他' }[value] || value || '-'
|
||||
}
|
||||
|
||||
function canAct(row) {
|
||||
return row.status === 'PAID' && Number(row.allocAmount) > 0
|
||||
}
|
||||
|
||||
function loadList() {
|
||||
loading.value = true
|
||||
listPayPayment(query).then(res => {
|
||||
@@ -205,22 +265,46 @@ function openDetail(row) {
|
||||
})
|
||||
}
|
||||
|
||||
function reverseRow(row) {
|
||||
proxy.$modal.confirm('反核销这张付款?账单未付金额会回来。确认人不能自己反核销。').then(() => reversePayPayment(row.paymentId)).then(() => {
|
||||
proxy.$modal.msgSuccess('已反核销')
|
||||
loadList()
|
||||
}).catch(() => {})
|
||||
function openAct(row, type) {
|
||||
actType.value = type
|
||||
actPayment.value = null
|
||||
actFees.value = []
|
||||
actVisible.value = true
|
||||
actLoading.value = true
|
||||
getPayPayment(row.paymentId).then(res => {
|
||||
actPayment.value = res.data
|
||||
const allocs = (res.data?.allocs || []).filter(item => item.allocStatus !== 'REVERSED' && item.billId)
|
||||
return Promise.all(allocs.map(alloc => getPayBill(alloc.billId).then(billRes => {
|
||||
const bill = billRes.data || {}
|
||||
return (bill.lines || []).map(line => ({
|
||||
billNo: alloc.billNo || bill.billNo,
|
||||
orderNo: line.orderNo,
|
||||
ladingNo: line.ladingNo,
|
||||
feeName: line.feeName,
|
||||
amount: line.amount,
|
||||
currency: line.currency || bill.currency
|
||||
}))
|
||||
}).catch(() => [])))
|
||||
}).then(groups => {
|
||||
if (Array.isArray(groups)) actFees.value = groups.flat()
|
||||
}).finally(() => { actLoading.value = false })
|
||||
}
|
||||
|
||||
function refundRow(row) {
|
||||
proxy.$modal.confirm('把这笔付款退回?已核销金额会冲回。').then(() => refundPayPayment(row.paymentId)).then(() => {
|
||||
proxy.$modal.msgSuccess('已退款')
|
||||
function runAct() {
|
||||
if (!actPayment.value) return
|
||||
const request = actType.value === 'refund' ? refundPayPayment : reversePayPayment
|
||||
actSaving.value = true
|
||||
request(actPayment.value.paymentId).then(() => {
|
||||
proxy.$modal.msgSuccess(actType.value === 'refund' ? '已退款' : '已反核销')
|
||||
actVisible.value = false
|
||||
loadList()
|
||||
}).catch(() => {})
|
||||
if (detail.value?.paymentId === actPayment.value.paymentId) openDetail(actPayment.value)
|
||||
}).finally(() => { actSaving.value = false })
|
||||
}
|
||||
|
||||
function confirmRow(row) {
|
||||
proxy.$modal.confirm('确认这张付款?登记人和确认人不能是同一人。').then(() => confirmPayPayment(row.paymentId)).then(() => {
|
||||
const limit = String(userStore.id) === '1' ? '' : '登记人和确认人不能是同一人。'
|
||||
proxy.$modal.confirm('确认这张付款?' + limit).then(() => confirmPayPayment(row.paymentId)).then(() => {
|
||||
proxy.$modal.msgSuccess('已确认付款')
|
||||
loadList()
|
||||
}).catch(() => {})
|
||||
@@ -238,4 +322,5 @@ loadList()
|
||||
|
||||
<style scoped>
|
||||
.mb8 { margin-bottom: 8px; }
|
||||
.act-hint { margin-top: 8px; }
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user