应付模块菜单调整,新增应付费用编辑等

This commit is contained in:
liuminghui
2026-11-16 15:50:51 +08:00
parent 5b8d4de262
commit 49f24a6b1b
66 changed files with 3247 additions and 119 deletions
@@ -26,6 +26,15 @@ export function addSupplier(data) {
})
}
// 只保存这一家供应商绑定的渠道
export function bindSupplierChannels(supplierId, data) {
return request({
url: '/customersupplier/supplierinfo/' + supplierId + '/channels',
method: 'put',
data: data
})
}
// 修改供应商
export function updateSupplier(data) {
return request({
+39
View File
@@ -0,0 +1,39 @@
import request from '@/utils/request'
export function listPayOrder(query) {
return request({
url: '/price/payOrder/list',
method: 'get',
params: query
})
}
export function listPayOrderFees(billId) {
return request({
url: '/price/payOrder/' + billId + '/fees',
method: 'get'
})
}
export function addPayOrderFee(billId, data) {
return request({
url: '/price/payOrder/' + billId + '/fees',
method: 'post',
data
})
}
export function removePayOrderFee(feeId) {
return request({
url: '/price/payOrder/fees/' + feeId,
method: 'delete'
})
}
export function recalcPayOrder(data) {
return request({
url: '/price/payOrder/recalc',
method: 'post',
data
})
}
@@ -1,12 +1,14 @@
<template>
<div class="channel-select">
<el-button type="primary" plain icon="Connection" @click="openDialog">
{{ selectedCodes.length ? '重新选择渠道' : '选择渠道' }}
</el-button>
<span class="cs-summary">
已绑定 <b>{{ selectedCodes.length }}</b> 个渠道
<el-button v-if="selectedCodes.length" link type="danger" @click="clearSelection">清空</el-button>
</span>
<template v-if="showTrigger">
<el-button type="primary" plain icon="Connection" @click="openDialog">
{{ selectedCodes.length ? '重新选择渠道' : '选择渠道' }}
</el-button>
<span class="cs-summary">
已绑定 <b>{{ selectedCodes.length }}</b> 个渠道
<el-button v-if="selectedCodes.length" link type="danger" @click="clearSelection">清空</el-button>
</span>
</template>
<el-dialog
v-model="dialogVisible"
@@ -85,7 +87,9 @@ import { useChannels } from './useChannels'
const props = defineProps({
/** v-model 绑定值:逗号分隔的渠道编码串,如 "SK_DEPDHLL,015A" */
modelValue: { type: [String, Number], default: '' }
modelValue: { type: [String, Number], default: '' },
/** 为 false 时不显示按钮,由父页面调用 open() 打开同一个弹框 */
showTrigger: { type: Boolean, default: true }
})
const emit = defineEmits(['update:modelValue', 'change'])
@@ -186,8 +190,8 @@ function clearSelection() {
emit('change', [])
}
/** 供父组件预加载渠道缓存(tab 内明细表格使用) */
defineExpose({ ensureChannels })
/** 供父组件预加载渠道缓存,或直接打开选择弹框 */
defineExpose({ ensureChannels, open: openDialog })
</script>
<style scoped>
@@ -172,6 +172,12 @@
<el-table-column v-if="isColVisible('cooperationStatus')" label="合作状态" align="center" prop="cooperationStatus">
<template #default="scope">{{ formatOption(cooperationStatusOptions, scope.row.cooperationStatus) }}</template>
</el-table-column>
<el-table-column v-if="isColVisible('dataSource')" label="数据来源" align="center" prop="dataSource" width="110">
<template #default="scope">
<dict-tag v-if="scope.row.dataSource" :options="bms_supplier_data_source" :value="scope.row.dataSource" />
<span v-else>-</span>
</template>
</el-table-column>
<el-table-column v-if="isColVisible('channelIds')" label="绑定渠道" align="center" prop="channelIds" min-width="200" show-overflow-tooltip>
<template #default="scope">
<span v-if="channelNames(scope.row.channelIds)">{{ channelNames(scope.row.channelIds) }}</span>
@@ -179,9 +185,10 @@
</template>
</el-table-column>
<el-table-column v-if="isColVisible('remark')" label="备注说明" align="center" prop="remark" :show-overflow-tooltip="true" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="180" fixed="right">
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="270" fixed="right">
<template #default="scope">
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['customersupplier:supplierinfo:edit']">修改</el-button>
<el-button link type="primary" icon="Connection" @click="openBind(scope.row)" v-hasPermi="['customersupplier:supplierinfo:bindChannel']">绑定渠道</el-button>
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['customersupplier:supplierinfo:remove']">删除</el-button>
</template>
</el-table-column>
@@ -195,6 +202,8 @@
@pagination="getList"
/>
<channel-select ref="channelSelectRef" v-model="bindChannelIds" :show-trigger="false" @change="saveBind" />
<!-- 右键复制列值 -->
<table-copy-menu
ref="copyMenuRef"
@@ -206,7 +215,7 @@
</template>
<script setup name="Supplier">
import { listSupplier, delSupplier } from "@/api/customersuppliermanagement/supplierinfo/supplier.js"
import { bindSupplierChannels, listSupplier, delSupplier } from "@/api/customersuppliermanagement/supplierinfo/supplier.js"
import { useChannels, parseChannelCodes } from '@/components/ChannelSelect/useChannels'
import { useUsers } from '@/components/UserSelect/useUsers'
import { useColumnSettings } from '@/utils/columnSettings'
@@ -245,6 +254,7 @@ const columnDefs = [
{ key: 'cooperationStartDate', label: '合作开始日期' },
{ key: 'contractEndDate', label: '合同结束时间' },
{ key: 'cooperationStatus', label: '合作状态' },
{ key: 'dataSource', label: '数据来源' },
{ key: 'channelIds', label: '绑定渠道' },
{ key: 'remark', label: '备注说明' }
]
@@ -258,7 +268,7 @@ const single = ref(true)
const multiple = ref(true)
const total = ref(0)
const { sys_normal_disable, settlement_type, bms_supplier_type: supplierTypeOptions } = useDict("sys_normal_disable", "settlement_type", "bms_supplier_type")
const { sys_normal_disable, settlement_type, bms_supplier_type: supplierTypeOptions, bms_supplier_data_source } = useDict("sys_normal_disable", "settlement_type", "bms_supplier_type", "bms_supplier_data_source")
const invoiceTypeOptions = ref([
{ value: "1", label: "增值税普通发票" },
{ value: "2", label: "增值税专用发票" },
@@ -318,6 +328,7 @@ const copyColumns = computed(() => [
{ key: 'cooperationStartDate', label: '合作开始日期', get: r => formatDateOnly(r.cooperationStartDate) },
{ key: 'contractEndDate', label: '合同结束时间', get: r => formatDateOnly(r.contractEndDate) },
{ key: 'cooperationStatus', label: '合作状态', get: r => formatOption(cooperationStatusOptions.value, r.cooperationStatus) },
{ key: 'dataSource', label: '数据来源', get: r => proxy.selectDictLabel(bms_supplier_data_source.value, r.dataSource) },
{ key: 'channelIds', label: '绑定渠道', get: r => channelNames(r.channelIds) },
{ key: 'remark', label: '备注说明', get: r => r.remark || '' }
])
@@ -415,6 +426,36 @@ function handleUpdate(row) {
})
}
const channelSelectRef = ref(null)
const bindRow = ref(null)
const bindChannelIds = ref('')
/** 打开和编辑页相同的选择渠道弹框,确定后只保存这一家的渠道 */
function openBind(row) {
if (!row || !row.supplierId) {
return
}
bindRow.value = row
bindChannelIds.value = row.channelIds || ''
nextTick(() => {
channelSelectRef.value && channelSelectRef.value.open()
})
}
function saveBind() {
const row = bindRow.value
if (!row || !row.supplierId) {
return
}
const channelIds = bindChannelIds.value || ''
bindSupplierChannels(row.supplierId, { channelIds }).then(() => {
proxy.$modal.msgSuccess('渠道已绑定')
getList()
}).catch(() => {
bindChannelIds.value = row.channelIds || ''
})
}
/** 删除按钮操作 */
function handleDelete(row) {
const _supplierIds = row.supplierId || ids.value
@@ -173,6 +173,13 @@
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="数据来源" prop="dataSource">
<el-select v-model="form.dataSource" placeholder="请选择数据来源" clearable style="width: 100%;">
<el-option v-for="opt in bms_supplier_data_source" :key="opt.value" :label="opt.label" :value="opt.value" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="备注说明" prop="remark">
<el-input v-model="form.remark" type="textarea" :rows="3" placeholder="请输入内容" />
@@ -646,7 +653,7 @@ const rules = {
supplierName: [{ required: true, message: '供应商名称不能为空', trigger: 'blur' }]
}
const { bms_supplier_type: supplierTypeOptions } = useDict('bms_supplier_type')
const { bms_supplier_type: supplierTypeOptions, bms_supplier_data_source } = useDict('bms_supplier_type', 'bms_supplier_data_source')
const invoiceTypeOptions = ref([
{ value: '1', label: '增值税普通发票' },
{ value: '2', label: '增值税专用发票' },
@@ -693,6 +700,7 @@ function buildEmptyForm() {
cooperationStartDate: null,
contractEndDate: null,
cooperationStatus: null,
dataSource: null,
channelIds: null,
attachmentList: [],
companyList: [],
@@ -1,7 +1,7 @@
<template>
<div v-if="panes.length" class="pay-detail">
<section v-for="pane in panes" :key="pane.key" class="pay-product">
<div class="pay-product-title">{{ pane.item.productName || '未命名产品' }}</div>
<div class="pay-product-title">{{ pane.item.productName || '未命名服务商渠道' }}</div>
<el-descriptions :column="3" border size="small" class="pay-summary">
<el-descriptions-item label="价卡归属">{{ pane.item.supplierName || '-' }}</el-descriptions-item>
<el-descriptions-item label="生效日期">{{ pane.item.effectiveDate || '-' }}</el-descriptions-item>
+94 -3
View File
@@ -11,6 +11,9 @@
scrollbar-always-on
>
<template #toolbar="{ selection, ids }">
<el-col :span="1.5">
<el-button type="primary" plain icon="Link" :disabled="selection.length !== 1" @click="openBind(selection)" v-hasPermi="['price:pay:bind']">绑定渠道</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="primary" plain icon="Upload" @click="importRef.open()" v-hasPermi="['price:pay:import']">导入价卡</el-button>
</el-col>
@@ -64,6 +67,32 @@
</basic-table>
<pay-import-dialog ref="importRef" @saved="tableRef.refresh()" />
<el-dialog v-model="bindVisible" title="绑定渠道" width="640px" append-to-body @closed="resetBind">
<el-form label-width="70px">
<el-form-item label="产品">
<el-select v-model="bindForm.productId" disabled style="width: 100%">
<el-option :label="bindForm.productName" :value="bindForm.productId" />
</el-select>
</el-form-item>
<el-form-item label="渠道">
<el-select
v-model="bindForm.channelIds"
class="bind-channel-select"
multiple
filterable
clearable
placeholder="输入渠道编码或名称搜索,勾选后显示在框内"
style="width: 100%"
>
<el-option v-for="item in channelOptions" :key="item.id" :label="channelLabel(item)" :value="item.id" />
</el-select>
</el-form-item>
</el-form>
<template #footer>
<el-button @click="bindVisible = false">取消</el-button>
<el-button type="primary" :loading="bindSaving" @click="submitBind">确认</el-button>
</template>
</el-dialog>
<pay-surcharge-rule-dialog ref="ruleRef" />
<el-drawer v-model="historyVisible" :title="historyTitle" size="980px" append-to-body destroy-on-close>
@@ -192,7 +221,8 @@
</template>
<script setup name="PricePay">
import { listPay, getPay, delPay, updatePay, listPayTerm, updatePayTerm, changePayTermStatus, comparePay, listPaySurchargeRuleLog } from '@/api/price/pay'
import { listPay, getPay, delPay, updatePay, listPayTerm, updatePayTerm, changePayTermStatus, comparePay, listPaySurchargeRuleLog, batchBindChannelPay } from '@/api/price/pay'
import { listChannelOptions } from '@/api/masterdata/serviceChannel'
import PayImportDialog from './components/PayImportDialog.vue'
import PayConfigDetail from './components/PayConfigDetail.vue'
import PaySurchargeRuleDialog from './components/PaySurchargeRuleDialog.vue'
@@ -233,6 +263,10 @@ const detailTitle = computed(() => {
const termVisible = ref(false)
const termSaving = ref(false)
const termForm = reactive({ termId: null, productId: null, effectiveStart: '', effectiveEnd: '' })
const bindVisible = ref(false)
const bindSaving = ref(false)
const channelOptions = ref([])
const bindForm = reactive({ productId: null, productName: '', channelIds: [] })
const statusOptions = [
{ label: '已识别', value: 'OK' },
@@ -241,7 +275,7 @@ const statusOptions = [
]
const columns = [
{ label: '产品名称', prop: 'productName', align: 'center', minWidth: 180, showOverflowTooltip: true, fixed: 'left' },
{ label: '服务商渠道名称', prop: 'productName', align: 'center', minWidth: 180, showOverflowTooltip: true, fixed: 'left' },
{ label: '价卡归属', prop: 'supplierName', align: 'center', width: 100 },
{ label: '国家/口岸', prop: 'countryScope', align: 'center', minWidth: 120, showOverflowTooltip: true },
{ label: '费用类型', prop: 'chargeType', align: 'center', width: 110 },
@@ -261,7 +295,7 @@ const columns = [
]
const searchColumns = [
{ label: '产品名称', prop: 'productName', component: 'input', placeholder: '产品名称', width: '180px' },
{ label: '服务商渠道名称', prop: 'productName', component: 'input', placeholder: '产品名称', width: '180px' },
{ label: '价卡归属', prop: 'supplierName', component: 'input', placeholder: '威狮、易德、GWE', width: '160px' },
{ label: '来源文件', prop: 'sourceFile', component: 'input', placeholder: '文件名', width: '180px' },
{ label: '报价工作表', prop: 'sheetName', component: 'input', placeholder: '工作表', width: '160px' },
@@ -331,6 +365,57 @@ function openRule(selection) {
ruleRef.value?.open(selection || [])
}
function channelLabel(item) {
const code = item?.channelCode || ''
const name = item?.channelName || ''
return [code, name].filter(Boolean).join(' ')
}
function openBind(selection) {
if (!selection || selection.length !== 1) return
const row = selection[0]
if (!row?.productId) {
proxy.$modal.msgWarning('这个产品没有编号,不能绑定渠道')
return
}
bindForm.productId = row.productId
bindForm.productName = row.productName || ''
bindForm.channelIds = []
bindVisible.value = true
if (!channelOptions.value.length) {
listChannelOptions().then(res => {
channelOptions.value = res.data || []
})
}
}
function resetBind() {
bindForm.productId = null
bindForm.productName = ''
bindForm.channelIds = []
}
function submitBind() {
if (!bindForm.productId) {
proxy.$modal.msgWarning('请选择一个产品')
return
}
if (!bindForm.channelIds.length) {
proxy.$modal.msgWarning('请选择渠道')
return
}
bindSaving.value = true
batchBindChannelPay({
channelIds: bindForm.channelIds,
apProductId: bindForm.productId
}).then(res => {
proxy.$modal.msgSuccess(typeof res.data === 'string' ? res.data : (res.msg || '绑定成功'))
bindVisible.value = false
}).finally(() => {
bindSaving.value = false
})
}
function openDetail(row) {
detailVisible.value = true
savingRowKey.value = ''
@@ -596,4 +681,10 @@ function statusType(status) {
.compare-panel :deep(tr.compare-removed:hover > td.el-table__cell) {
background: var(--el-color-danger-light-8);
}
.bind-channel-select :deep(.el-select__wrapper),
.bind-channel-select :deep(.el-input__wrapper) {
min-height: 168px;
align-items: flex-start;
padding-top: 8px;
}
</style>
@@ -50,7 +50,7 @@
<el-table-column min-width="180">
<template #header><span class="col-label"><i class="req-star">*</i>费用名称</span></template>
<template #default="{ row }">
<el-select v-model="row.feeType" filterable remote clearable reserve-keyword placeholder="输入费用名称"
<el-select v-model="row.scId" filterable remote clearable reserve-keyword placeholder="输入费用名称"
:remote-method="searchSurcharge" :loading="surchargeLoading" :disabled="locked(row)" style="width: 100%"
@change="id => onFeeChange(row, id)">
<el-option v-for="item in surchargeOptions" :key="item.scId" :label="item.scName" :value="item.scId" />
@@ -240,12 +240,18 @@ async function loadFees(force = false) {
searchSurcharge('')
}
function pickedId(item) {
if (item?.scId != null && item.scId !== '') return String(item.scId)
const type = item?.feeType == null ? '' : String(item.feeType)
return /^\d+$/.test(type) ? type : ''
}
function toRow(item, saved) {
const row = {
rowKey: saved ? `fee-${item.id}` : `new-${++rowSeed}`,
id: saved ? item.id : null,
billCode: item.billCode || '',
feeType: item.feeType == null ? '' : String(item.feeType),
scId: pickedId(item),
feeName: item.feeName || '',
price: item.price === null || item.price === undefined ? null : Number(item.price),
currency: item.currency || '',
@@ -258,7 +264,7 @@ function toRow(item, saved) {
function snapshot(row) {
return {
feeType: row.feeType || '',
scId: row.scId || '',
price: row.price === null || row.price === undefined || row.price === '' ? '' : String(Number(row.price)),
currency: row.currency || '',
remark: (row.remark || '').trim()
@@ -267,7 +273,7 @@ function snapshot(row) {
function currentOf(row) {
return {
feeType: row.feeType || '',
scId: row.scId || '',
price: row.price === null || row.price === undefined || row.price === '' ? '' : String(Number(row.price)),
currency: row.currency || '',
remark: (row.remark || '').trim()
@@ -275,9 +281,9 @@ function currentOf(row) {
}
function rowChanged(row) {
if (!row.origin) return !!(row.feeType || row.price || row.currency || row.remark)
if (!row.origin) return !!(row.scId || row.price || row.currency || row.remark)
const now = currentOf(row)
return now.feeType !== row.origin.feeType || now.price !== row.origin.price
return now.scId !== row.origin.scId || now.price !== row.origin.price
|| now.currency !== row.origin.currency || now.remark !== row.origin.remark
}
@@ -302,7 +308,7 @@ function removeRow(row) {
function rowError(row) {
if (!row.billCode) return '请选择提单'
if (!row.feeType) return '请选择费用名称'
if (!row.scId) return '请选择费用名称'
if (row.price === null || row.price === undefined || row.price === '') return '请填写价格'
if (Number(row.price) < 0) return '价格不能小于0'
if (!row.currency) return '请选择币种'
@@ -323,7 +329,7 @@ function save() {
rows.value.forEach(row => {
if (!rowChanged(row)) return
const payload = {
feeType: row.feeType || '',
scId: row.scId || '',
price: row.price,
currency: row.currency || '',
remark: (row.remark || '').trim()
@@ -401,8 +407,8 @@ function onFeeChange(row, id) {
function pinSelectedFees() {
const known = new Map(surchargeOptions.value.map(item => [String(item.scId), item]))
rows.value.forEach(row => {
if (row.feeType && !known.has(String(row.feeType))) {
known.set(String(row.feeType), { scId: String(row.feeType), scName: row.feeName || String(row.feeType) })
if (row.scId && !known.has(String(row.scId))) {
known.set(String(row.scId), { scId: String(row.scId), scName: row.feeName || String(row.scId) })
}
})
surchargeOptions.value = [...known.values()]
@@ -9,7 +9,7 @@
<el-table-column min-width="160">
<template #header><span class="col-label"><i class="req-star">*</i>费用项</span></template>
<template #default="{ row }">
<el-select v-model="row.feeType" filterable remote clearable reserve-keyword placeholder="输入费用名称"
<el-select v-model="row.scId" filterable remote clearable reserve-keyword placeholder="输入费用名称"
:remote-method="searchSurcharge" :loading="surchargeLoading" :disabled="locked(row)" style="width: 100%" @change="name => onFeeChange(row, name)">
<el-option v-for="item in surchargeOptions" :key="item.scId" :label="item.scName" :value="item.scId" />
</el-select>
@@ -166,7 +166,7 @@ function loadFees() {
rows.value = (feeRes.data || []).map(item => ({
rowKey: `fee-${item.id}`,
id: item.id,
feeType: item.feeType == null ? '' : String(item.feeType),
scId: pickedId(item),
feeName: item.feeName || '',
feeLevel: item.feeLevel == null ? '' : String(item.feeLevel),
allocFlag: item.allocFlag == null || item.allocFlag === '' ? '0' : String(item.allocFlag),
@@ -186,9 +186,9 @@ function loadFees() {
function pinSelectedFees() {
const known = new Map(surchargeOptions.value.map(item => [String(item.scId), item]))
for (const row of rows.value) {
if (!row.feeType) continue
if (!known.has(String(row.feeType))) {
known.set(String(row.feeType), { scId: String(row.feeType), scName: row.feeName || String(row.feeType) })
if (!row.scId) continue
if (!known.has(String(row.scId))) {
known.set(String(row.scId), { scId: String(row.scId), scName: row.feeName || String(row.scId) })
}
}
surchargeOptions.value = [...known.values()]
@@ -264,7 +264,7 @@ function addRow() {
rows.value.push({
rowKey: `new-${rowSeed}`,
id: null,
feeType: '',
scId: '',
feeName: '',
feeLevel: '',
allocFlag: '0',
@@ -315,9 +315,15 @@ function removeRow(row) {
rows.value = rows.value.filter(item => item.rowKey !== row.rowKey)
}
function pickedId(item) {
if (item?.scId != null && item.scId !== '') return String(item.scId)
const type = item?.feeType == null ? '' : String(item.feeType)
return /^\d+$/.test(type) ? type : ''
}
function snapshot(item) {
return {
feeType: item.feeType || '',
scId: pickedId(item),
feeLevel: item.feeLevel || '',
allocFlag: item.allocFlag == null || item.allocFlag === '' ? '0' : String(item.allocFlag),
allocDim: item.allocDim || '',
@@ -329,7 +335,7 @@ function snapshot(item) {
function currentOf(row) {
return {
feeType: row.feeType || '',
scId: row.scId || '',
feeLevel: row.feeLevel || '',
allocFlag: row.allocFlag || '',
allocDim: String(row.allocFlag) === '1' ? (row.allocDim || '') : '',
@@ -348,15 +354,15 @@ function normPrice(value) {
function rowChanged(row) {
if (!row.origin) {
const now = currentOf(row)
return !!(now.feeType || now.price || now.currency || now.remark)
return !!(now.scId || now.price || now.currency || now.remark)
}
const now = currentOf(row)
return now.feeType !== row.origin.feeType || now.price !== row.origin.price
return now.scId !== row.origin.scId || now.price !== row.origin.price
|| now.currency !== row.origin.currency || now.remark !== row.origin.remark
}
function rowError(row) {
if (!row.feeType) return '请选择费用项'
if (!row.scId) return '请选择费用项'
if (row.price === null || row.price === undefined || row.price === '') return '请填写价格'
if (Number(row.price) < 0) return '价格不能小于0'
if (!row.currency) return '请选择收费币种'
@@ -374,7 +380,7 @@ function save() {
rows.value.forEach(row => {
if (!rowChanged(row)) return
const payload = {
feeType: row.feeType || '',
scId: row.scId || '',
feeLevel: row.feeLevel || '',
price: row.price,
currency: row.currency || '',
@@ -0,0 +1,368 @@
<template>
<div class="app-container">
<el-form :inline="true" :model="query" class="mb8">
<el-form-item label="订单号">
<el-input v-model="query.orderNo" type="textarea" :rows="2" clearable placeholder="多个订单号可用逗号、空格或换行分隔" style="width: 280px" />
</el-form-item>
<el-form-item label="提单号">
<el-input v-model="query.ladingNo" clearable placeholder="提单号" style="width: 180px" @keyup.enter="search" />
</el-form-item>
<el-form-item label="客户">
<el-input v-model="query.customerName" clearable placeholder="客户名称或代码" style="width: 180px" @keyup.enter="search" />
</el-form-item>
<el-form-item>
<el-button type="primary" icon="Search" @click="search">查询</el-button>
<el-button icon="Refresh" @click="reset">重置</el-button>
</el-form-item>
</el-form>
<el-row class="mb8">
<el-button type="primary" plain icon="RefreshRight" v-hasPermi="['price:payOrder:recalc']" @click="openRecalc">费用重算</el-button>
</el-row>
<el-table v-loading="loading" :data="rows" border>
<el-table-column prop="orderNo" label="订单号" min-width="160" fixed="left" show-overflow-tooltip />
<el-table-column prop="ladingNo" label="提单号" min-width="150" fixed="left" show-overflow-tooltip>
<template #default="{ row }">{{ row.ladingNo || '-' }}</template>
</el-table-column>
<el-table-column prop="trackingNo" label="运单号" min-width="150" show-overflow-tooltip />
<el-table-column prop="customerName" label="客户" min-width="140" show-overflow-tooltip />
<el-table-column prop="productName" label="产品" min-width="160" show-overflow-tooltip />
<el-table-column prop="countryName" label="目的国" width="110" show-overflow-tooltip />
<el-table-column prop="channelName" label="渠道" min-width="140" show-overflow-tooltip />
<el-table-column prop="chargeWeight" label="计费重" width="90" align="right" />
<el-table-column prop="payTotal" label="应付总额" width="110" align="right" />
<el-table-column prop="currency" label="币种" width="80" align="center" />
<el-table-column label="计费状态" width="100" align="center">
<template #default="{ row }">
<dict-tag v-if="row.payCalcStatus != null && row.payCalcStatus !== ''" :options="bms_pay_calc_status" :value="row.payCalcStatus" />
<span v-else>-</span>
</template>
</el-table-column>
<el-table-column prop="payCalcMsg" label="失败原因" min-width="180" show-overflow-tooltip>
<template #default="{ row }">{{ row.payCalcMsg || '-' }}</template>
</el-table-column>
<el-table-column prop="bizDate" label="计费时间" width="170" align="center" />
<el-table-column label="操作" width="140" align="center" fixed="right">
<template #default="{ row }">
<el-button link type="primary" v-hasPermi="['price:payOrder:query']" @click="openDetail(row)">详情</el-button>
<el-button link type="primary" v-hasPermi="['price:payOrder:fee']" @click="openFees(row)">费用</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" />
<bill-detail v-model="detailOpen" title="订单详情" :loading="detailLoading" :detail="detail" />
<el-dialog v-model="feeOpen" :title="feeTitle" width="1280px" append-to-body destroy-on-close>
<div v-loading="feeLoading" class="fee-board">
<section v-for="section in sections" :key="section.level" class="fee-section">
<div class="fee-head">{{ section.title }}</div>
<div class="fee-tools">
<el-button v-hasPermi="['price:payOrder:feeAdd']" type="primary" plain size="small" @click="addFeeRow(section)">增加费用</el-button>
</div>
<el-table :data="section.fees" border empty-text="无">
<el-table-column label="费用项" min-width="180">
<template #default="{ row }">
<el-select v-if="row.editing" v-model="row.pick" filterable allow-create default-first-option placeholder="选择或输入" style="width: 100%" @change="pickFee(row)">
<el-option v-for="item in (bms_fee_type || [])" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
<span v-else>{{ row.feeName }}</span>
</template>
</el-table-column>
<el-table-column label="金额" width="140" align="right">
<template #default="{ row }">
<el-input-number v-if="row.editing" v-model="row.amount" :precision="2" :controls="false" style="width: 100%" />
<span v-else>{{ row.amount }}</span>
</template>
</el-table-column>
<el-table-column label="币种" width="110" align="center">
<template #default="{ row }">
<el-select v-if="row.editing" v-model="row.currency" filterable style="width: 100%">
<el-option v-for="item in (bms_currency || [])" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
<span v-else>{{ row.currency }}</span>
</template>
</el-table-column>
<el-table-column label="说明" min-width="180">
<template #default="{ row }">
<el-input v-if="row.editing" v-model="row.remark" maxlength="200" />
<span v-else>{{ row.remark }}</span>
</template>
</el-table-column>
<el-table-column label="来源" width="100" align="center">
<template #default="{ row }">{{ sourceText(row.feeSource) }}</template>
</el-table-column>
<el-table-column prop="createBy" label="创建人" width="100" show-overflow-tooltip />
<el-table-column prop="createTime" label="创建时间" width="160" />
<el-table-column prop="updateBy" label="更新人" width="100" show-overflow-tooltip />
<el-table-column prop="updateTime" label="更新时间" width="160" />
<el-table-column label="操作" width="130" align="center" fixed="right">
<template #default="{ row }">
<el-button v-if="row.editing" link type="primary" @click="saveFeeRow(section, row)">保存</el-button>
<el-button v-if="row.editing" link type="danger" @click="removeFeeRow(section, row)">删除</el-button>
<el-button v-else v-hasPermi="['price:payOrder:feeRemove']" link type="danger" @click="removeFeeRow(section, row)">删除</el-button>
</template>
</el-table-column>
</el-table>
</section>
<section class="fee-section">
<div class="fee-head">费用日志</div>
<el-table :data="feeLogs" border empty-text="无" max-height="280">
<el-table-column prop="feeName" label="费用项" min-width="160" show-overflow-tooltip />
<el-table-column prop="amount" label="金额" width="120" align="right" />
<el-table-column prop="currency" label="币种" width="90" align="center" />
<el-table-column label="操作类型" width="120" align="center">
<template #default="{ row }">
<dict-tag :options="bms_pay_fee_log_type" :value="row.operationType" />
</template>
</el-table-column>
<el-table-column prop="createBy" label="操作人" width="120" show-overflow-tooltip />
<el-table-column prop="createTime" label="操作时间" width="170" align="center" />
</el-table>
</section>
</div>
</el-dialog>
<el-dialog v-model="recalcOpen" title="费用重算" width="720px" append-to-body @closed="resetRecalc">
<el-form label-width="90px">
<el-form-item label="重算方式">
<el-radio-group v-model="recalcForm.sourceType">
<el-radio value="ORDER">订单号</el-radio>
<el-radio value="LADING">提单号</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item :label="recalcForm.sourceType === 'LADING' ? '提单号' : '订单号'">
<el-input v-model="recalcForm.text" type="textarea" :rows="6" placeholder="多个单号可用逗号、空格或换行分隔,一次最多500个" />
</el-form-item>
</el-form>
<div v-if="recalcResult" class="recalc-result">
<span>成功 {{ recalcResult.successCount }} 票,失败 {{ recalcResult.failCount }} 票</span>
<el-table :data="recalcFails" border size="small" max-height="240" empty-text="没有失败记录">
<el-table-column prop="orderNo" label="订单号" min-width="140" show-overflow-tooltip />
<el-table-column prop="ladingNo" label="提单号" min-width="140" show-overflow-tooltip />
<el-table-column prop="message" label="原因" min-width="220" show-overflow-tooltip />
</el-table>
</div>
<template #footer>
<el-button @click="recalcOpen = false">关闭</el-button>
<el-button type="primary" :loading="recalcSaving" @click="submitRecalc">确认</el-button>
</template>
</el-dialog>
</div>
</template>
<script setup name="PayOrderList">
import { getBill } from '@/api/price/billing'
import { addPayOrderFee, listPayOrder, listPayOrderFees, recalcPayOrder, removePayOrderFee } from '@/api/price/payOrder'
import BillDetail from '../components/BillDetail.vue'
const { proxy } = getCurrentInstance()
const { bms_pay_calc_status, bms_fee_type, bms_currency, bms_pay_fee_log_type } = useDict('bms_pay_calc_status', 'bms_fee_type', 'bms_currency', 'bms_pay_fee_log_type')
const loading = ref(false)
const rows = ref([])
const total = ref(0)
const query = reactive({ orderNo: '', ladingNo: '', customerName: '', pageNum: 1, pageSize: 20 })
const detailOpen = ref(false)
const detailLoading = ref(false)
const detail = ref(null)
const feeOpen = ref(false)
const feeLoading = ref(false)
const feeTitle = ref('应付费用')
const feeBillId = ref('')
const sections = ref([])
const feeLogs = ref([])
const recalcOpen = ref(false)
const recalcSaving = ref(false)
const recalcForm = reactive({ sourceType: 'ORDER', text: '' })
const recalcResult = ref(null)
const recalcFails = computed(() => (recalcResult.value?.lines || []).filter(line => !line.success))
const sources = {
CALC: '尾程计算',
LADING: '提单分摊',
MANUAL: '手工'
}
function sourceText(value) {
return sources[value] || value || '-'
}
function search() {
query.pageNum = 1
loadList()
}
function reset() {
query.orderNo = ''
query.ladingNo = ''
query.customerName = ''
search()
}
function loadList() {
loading.value = true
listPayOrder(query).then(res => {
rows.value = res.rows || []
total.value = res.total || 0
}).finally(() => {
loading.value = false
})
}
function openDetail(row) {
detail.value = null
detailOpen.value = true
detailLoading.value = true
getBill(row.billId).then(res => {
detail.value = res.data || null
}).finally(() => {
detailLoading.value = false
})
}
function openFees(row) {
feeTitle.value = (row.orderNo || '订单') + '的应付费用'
feeBillId.value = row.billId
sections.value = []
feeLogs.value = []
feeOpen.value = true
loadFees()
}
function loadFees() {
if (!feeBillId.value) {
return
}
feeLoading.value = true
listPayOrderFees(feeBillId.value).then(res => {
sections.value = res.data?.sections || []
feeLogs.value = res.data?.logs || []
}).catch(() => {
proxy.$modal.msgError('费用加载失败')
}).finally(() => {
feeLoading.value = false
})
}
function addFeeRow(section) {
if ((section.fees || []).some(item => item.editing)) {
proxy.$modal.msgWarning('请先保存当前新增的费用')
return
}
if (!section.fees) {
section.fees = []
}
section.fees.push({
editing: true,
pick: '',
feeType: '',
feeName: '',
amount: null,
currency: 'CNY',
remark: '',
feeSource: 'MANUAL'
})
}
function pickFee(row) {
const dict = (bms_fee_type.value || []).find(item => item.value === row.pick)
if (dict) {
row.feeType = dict.value
row.feeName = dict.label
return
}
row.feeType = row.pick
row.feeName = row.pick
}
function saveFeeRow(section, row) {
if (!row.feeName) {
proxy.$modal.msgWarning('请填写费用项')
return
}
if (row.amount === null || row.amount === undefined || row.amount === '') {
proxy.$modal.msgWarning('请填写金额')
return
}
feeLoading.value = true
addPayOrderFee(feeBillId.value, {
feeType: row.feeType,
feeName: row.feeName,
level: section.level,
amount: row.amount,
currency: row.currency || 'CNY',
remark: row.remark
}).then(() => {
proxy.$modal.msgSuccess('已增加费用')
loadFees()
loadList()
}).catch(() => {
feeLoading.value = false
})
}
function removeFeeRow(section, row) {
if (row.editing) {
section.fees = section.fees.filter(item => item !== row)
return
}
proxy.$modal.confirm('确认删除这条费用?').then(() => {
feeLoading.value = true
return removePayOrderFee(row.feeId)
}).then(() => {
proxy.$modal.msgSuccess('已删除')
loadFees()
loadList()
}).catch(() => {
feeLoading.value = false
})
}
function openRecalc() {
recalcResult.value = null
recalcOpen.value = true
}
function resetRecalc() {
recalcForm.sourceType = 'ORDER'
recalcForm.text = ''
recalcResult.value = null
}
function submitRecalc() {
if (!recalcForm.text || !recalcForm.text.trim()) {
proxy.$modal.msgWarning(recalcForm.sourceType === 'LADING' ? '请填写提单号' : '请填写订单号')
return
}
recalcSaving.value = true
recalcPayOrder({ sourceType: recalcForm.sourceType, text: recalcForm.text }).then(res => {
recalcResult.value = res.data || { successCount: 0, failCount: 0, lines: [] }
loadList()
}).finally(() => {
recalcSaving.value = false
})
}
loadList()
</script>
<style scoped>
.fee-board { max-height: 68vh; overflow: auto; }
.fee-section { margin-bottom: 16px; }
.fee-head {
margin-bottom: 8px;
padding: 8px 12px;
text-align: center;
font-weight: 600;
font-size: 15px;
background: var(--el-fill-color-light);
border: 1px solid var(--el-border-color);
}
.fee-tools { margin-bottom: 8px; text-align: right; }
.recalc-result { margin-top: 8px; }
.recalc-result > span { display: block; margin-bottom: 8px; }
</style>