Merge branch 'test' of https://git.lionquexpress.com/wuweihua/BMS into test
This commit is contained in:
@@ -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({
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
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 listPayOrderFeeLogs(billId, query) {
|
||||
return request({
|
||||
url: '/price/payOrder/' + billId + '/feeLogs',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
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 submitPayOrderRecalc(data) {
|
||||
return request({
|
||||
url: '/price/payOrder/recalc',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export function getPayOrderRecalcTask(taskId) {
|
||||
return request({
|
||||
url: '/price/payOrder/recalc/task/' + taskId,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
export function cancelPayOrderRecalc(taskId) {
|
||||
return request({
|
||||
url: '/price/payOrder/recalc/task/' + taskId + '/cancel',
|
||||
method: 'post'
|
||||
})
|
||||
}
|
||||
|
||||
const payOrderRecalcPolls = new Map()
|
||||
|
||||
/** 轮询应付重算进度,直到完成、取消或失败。同一任务只保留一轮轮询。 */
|
||||
export async function pollPayOrderRecalc(taskId, onProgress) {
|
||||
const id = String(taskId || '')
|
||||
if (!id) throw new Error('没有拿到重算任务')
|
||||
const prev = payOrderRecalcPolls.get(id)
|
||||
if (prev) prev.aborted = true
|
||||
const ctrl = { aborted: false }
|
||||
payOrderRecalcPolls.set(id, ctrl)
|
||||
const started = Date.now()
|
||||
let lastSig = ''
|
||||
try {
|
||||
while (Date.now() - started < 30 * 60 * 1000) {
|
||||
if (ctrl.aborted) {
|
||||
const err = new Error('poll superseded')
|
||||
err.superseded = true
|
||||
throw err
|
||||
}
|
||||
const hidden = typeof document !== 'undefined' && document.visibilityState === 'hidden'
|
||||
const res = await getPayOrderRecalcTask(id)
|
||||
const task = res.data || {}
|
||||
const status = String(task.status || '').toUpperCase()
|
||||
const sig = [status, task.percent, task.successCount, task.failCount, task.total].join('|')
|
||||
if (typeof onProgress === 'function' && sig !== lastSig) {
|
||||
lastSig = sig
|
||||
onProgress(task)
|
||||
}
|
||||
if (status === 'SUCCESS') return { task }
|
||||
if (status === 'CANCELLED') return { task, cancelled: true }
|
||||
if (status === 'FAIL') {
|
||||
const err = new Error(task.message || '费用重算失败')
|
||||
err.task = task
|
||||
throw err
|
||||
}
|
||||
await new Promise(resolve => setTimeout(resolve, hidden ? 2500 : 1000))
|
||||
}
|
||||
throw new Error('费用重算进度查询超时,请稍后在列表查看结果')
|
||||
} finally {
|
||||
if (payOrderRecalcPolls.get(id) === ctrl) payOrderRecalcPolls.delete(id)
|
||||
}
|
||||
}
|
||||
@@ -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: [],
|
||||
|
||||
@@ -175,22 +175,24 @@
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog v-model="batchBindOpen" title="批量绑定应收/应付产品" width="520px" append-to-body @closed="onBatchBindClosed">
|
||||
<el-form label-width="100px">
|
||||
<el-dialog v-model="batchBindOpen" title="批量绑定应收/应付服务商渠道" width="560px" append-to-body @closed="onBatchBindClosed">
|
||||
<el-form class="batch-bind-form" label-width="132px">
|
||||
<el-form-item label="已选渠道">
|
||||
<span>{{ batchBindIds.length }} 个</span>
|
||||
<span class="batch-bind-count">{{ batchBindIds.length }} 个</span>
|
||||
</el-form-item>
|
||||
<el-form-item label="应付产品">
|
||||
<el-select v-model="batchApId" filterable clearable placeholder="可选,不选则不改应付绑定" style="width: 100%">
|
||||
<el-form-item label="应付服务商渠道">
|
||||
<el-select v-model="batchApId" class="batch-bind-select" filterable clearable placeholder="可选,不选则不改应付绑定">
|
||||
<el-option v-for="item in payOptions" :key="'ap-' + item.productId" :label="payOptionLabel(item)" :value="item.productId" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="应收产品">
|
||||
<el-select v-model="batchArId" filterable clearable placeholder="可选,不选则不改应收绑定" style="width: 100%">
|
||||
<!--
|
||||
<el-form-item label="应收服务商渠道">
|
||||
<el-select v-model="batchArId" class="batch-bind-select" filterable clearable placeholder="可选,不选则不改应收绑定">
|
||||
<el-option v-for="item in arOptions" :key="'ar-' + item.productId" :label="payOptionLabel(item)" :value="item.productId" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<div class="pay-tip">至少选择一个产品;将覆盖已选渠道对应收付类型的绑定。</div>
|
||||
-->
|
||||
<div class="batch-bind-tip">至少选择一个服务商渠道;将覆盖已选渠道对应收付类型的绑定。</div>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="batchBindOpen = false">取消</el-button>
|
||||
@@ -231,18 +233,18 @@ const batchArId = ref()
|
||||
const payTip = computed(() => {
|
||||
if (viewing.value) {
|
||||
if (payProduct.value?.versionNo) return `已绑定第 ${payProduct.value.versionNo} 版。`
|
||||
return payOriginId.value ? '已绑定应付产品。' : '未绑定应付产品。'
|
||||
return payOriginId.value ? '已绑定应付服务商渠道。' : '未绑定应付服务商渠道。'
|
||||
}
|
||||
if (!form.value?.id) return '先保存渠道,再选择应付产品。渠道绑定的是产品编号,更新价格不会换编号。'
|
||||
if (!form.value?.id) return '先保存渠道,再选择应付服务商渠道。渠道绑定的是产品编号,更新价格不会换编号。'
|
||||
if (payProduct.value?.versionNo) return `当前按有效期使用第 ${payProduct.value.versionNo} 版。历史订单按下单或计费时间取当时的版本。`
|
||||
return '选择产品后即绑定,按应付 AP 保存。'
|
||||
})
|
||||
const arTip = computed(() => {
|
||||
if (viewing.value) {
|
||||
if (arProduct.value?.versionNo) return `已绑定第 ${arProduct.value.versionNo} 版。`
|
||||
return arOriginId.value ? '已绑定应收产品。' : '未绑定应收产品。'
|
||||
return arOriginId.value ? '已绑定应收服务商渠道。' : '未绑定应收服务商渠道。'
|
||||
}
|
||||
if (!form.value?.id) return '先保存渠道,再选择应收产品。渠道绑定的是产品编号,更新价格不会换编号。'
|
||||
if (!form.value?.id) return '先保存渠道,再选择应收服务商渠道。渠道绑定的是服务商渠道编号,更新价格不会换编号。'
|
||||
if (arProduct.value?.versionNo) return `当前按有效期使用第 ${arProduct.value.versionNo} 版。历史订单按下单或计费时间取当时的版本。`
|
||||
return '选择产品后即绑定,按应收 AR 保存。'
|
||||
})
|
||||
@@ -533,4 +535,32 @@ function submitBatchBind() {
|
||||
font-size: 12px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
.batch-bind-form :deep(.el-form-item) {
|
||||
align-items: center;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
.batch-bind-form :deep(.el-form-item__label) {
|
||||
height: 32px;
|
||||
line-height: 32px;
|
||||
white-space: nowrap;
|
||||
align-items: center;
|
||||
}
|
||||
.batch-bind-form :deep(.el-form-item__content) {
|
||||
line-height: 32px;
|
||||
}
|
||||
.batch-bind-count {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
height: 32px;
|
||||
line-height: 32px;
|
||||
}
|
||||
.batch-bind-select {
|
||||
width: 100%;
|
||||
}
|
||||
.batch-bind-tip {
|
||||
margin: 0 0 4px 132px;
|
||||
color: var(--el-text-color-secondary);
|
||||
font-size: 12px;
|
||||
line-height: 1.5;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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,834 @@
|
||||
<template>
|
||||
<div class="app-container pay-order-page">
|
||||
<div v-if="recalcFloatVisible" class="retry-status-float">
|
||||
<el-tooltip :content="recalcFloatTooltip" placement="bottom">
|
||||
<el-button class="retry-status-button" type="primary" plain size="small" @click="openRecalcProgress">
|
||||
<span class="retry-progress-ring" :style="{ '--retry-progress': recalcProgressDegree + 'deg' }" aria-hidden="true">
|
||||
<span class="retry-progress-value">{{ recalcProgressText }}</span>
|
||||
</span>
|
||||
<span class="retry-status-text">
|
||||
<strong>{{ recalcFloatTitle }}</strong>
|
||||
<small>{{ recalcFloatSummary }}</small>
|
||||
</span>
|
||||
</el-button>
|
||||
</el-tooltip>
|
||||
</div>
|
||||
<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" :loading="recalcRunning" 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 prop="updateBy" label="更新人" width="110" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ row.updateBy || '-' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="updateTime" label="更新时间" width="170" align="center">
|
||||
<template #default="{ row }">{{ row.updateTime || '-' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="190" 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>
|
||||
<el-button link type="primary" v-hasPermi="['price:payOrder:log']" @click="openLogs(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 class="fee-table" :data="section.fees" border table-layout="fixed" empty-text="无">
|
||||
<el-table-column label="费用项" min-width="1" header-align="center" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
<el-select v-if="row.editing" v-model="row.pick" filterable allow-create default-first-option placeholder="选择或输入" @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="金额" min-width="1" header-align="center" align="right" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
<el-input-number v-if="row.editing" v-model="row.amount" :precision="2" :controls="false" />
|
||||
<span v-else>{{ row.amount }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="币种" min-width="1" header-align="center" align="center" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
<el-select v-if="row.editing" v-model="row.currency" filterable>
|
||||
<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="1" header-align="center" show-overflow-tooltip>
|
||||
<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="来源" min-width="1" header-align="center" align="center" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ sourceText(row.feeSource) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="createBy" label="创建人" min-width="1" header-align="center" show-overflow-tooltip />
|
||||
<el-table-column prop="createTime" label="创建时间" min-width="1" header-align="center" show-overflow-tooltip />
|
||||
<el-table-column prop="updateBy" label="更新人" min-width="1" header-align="center" show-overflow-tooltip />
|
||||
<el-table-column prop="updateTime" label="更新时间" min-width="1" header-align="center" show-overflow-tooltip />
|
||||
<el-table-column label="操作" min-width="1" header-align="center" align="center" class-name="fee-op">
|
||||
<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>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog v-model="logOpen" :title="logTitle" width="980px" append-to-body>
|
||||
<el-table v-loading="logLoading" class="fee-log-table" :data="logRows" border empty-text="无">
|
||||
<el-table-column label="变更前" min-width="200" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<div v-if="logLines(row, 'before').length" class="log-change">
|
||||
<div v-for="(line, index) in logLines(row, 'before')" :key="index">{{ line }}</div>
|
||||
</div>
|
||||
<span v-else class="log-empty">空</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="变更后" min-width="200" header-align="center">
|
||||
<template #default="{ row }">
|
||||
<div v-if="logLines(row, 'after').length" class="log-change">
|
||||
<div v-for="(line, index) in logLines(row, 'after')" :key="index">{{ line }}</div>
|
||||
</div>
|
||||
<span v-else class="log-empty">空</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="remark" label="备注" min-width="180" header-align="center" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ row.remark || '-' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作类型" width="120" header-align="center" 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" header-align="center" show-overflow-tooltip />
|
||||
<el-table-column prop="createTime" label="操作时间" width="170" header-align="center" align="center" />
|
||||
</el-table>
|
||||
<pagination v-show="logTotal > 0" :total="logTotal" v-model:page="logQuery.pageNum" v-model:limit="logQuery.pageSize" @pagination="loadLogs" />
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog v-model="recalcOpen" title="费用重算" width="720px" append-to-body :close-on-click-modal="false">
|
||||
<el-form label-width="90px">
|
||||
<el-form-item label="重算方式">
|
||||
<el-radio-group v-model="recalcForm.sourceType" :disabled="recalcSaving">
|
||||
<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" :disabled="recalcSaving" :placeholder="recalcPlaceholder" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="recalcOpen = false">关闭</el-button>
|
||||
<el-button type="primary" :loading="recalcSaving" @click="submitRecalc">确认</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog
|
||||
v-model="recalcProgressVisible"
|
||||
:title="recalcDialogTitle"
|
||||
width="560px"
|
||||
append-to-body
|
||||
:close-on-click-modal="false"
|
||||
:close-on-press-escape="true"
|
||||
:show-close="true"
|
||||
>
|
||||
<el-progress
|
||||
:percentage="recalcProgressPercent"
|
||||
:status="recalcProgressStatus"
|
||||
:stroke-width="14"
|
||||
striped
|
||||
:striped-flow="recalcRunning"
|
||||
/>
|
||||
<div class="rebill-progress__msg">{{ recalcProgressMessage }}</div>
|
||||
<div v-if="!recalcRunning && recalcFinished" class="rebill-result-stats">
|
||||
<div class="rebill-result-stats__item">
|
||||
<span class="rebill-result-stats__label">总数</span>
|
||||
<strong>{{ recalcProgressTotal }}</strong>
|
||||
</div>
|
||||
<div class="rebill-result-stats__item is-success">
|
||||
<span class="rebill-result-stats__label">成功</span>
|
||||
<strong>{{ recalcProgressSuccess }}</strong>
|
||||
</div>
|
||||
<div class="rebill-result-stats__item is-fail">
|
||||
<span class="rebill-result-stats__label">失败</span>
|
||||
<strong>{{ recalcProgressFail }}</strong>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="rebill-progress__text">
|
||||
总数 {{ recalcProgressTotal }}
|
||||
/ 成功 {{ recalcProgressSuccess }}
|
||||
/ 失败 {{ recalcProgressFail }}
|
||||
</div>
|
||||
<el-table v-if="!recalcRunning && recalcFails.length" :data="recalcFails" border size="small" max-height="220" class="rebill-progress__error" empty-text="没有失败记录">
|
||||
<el-table-column prop="orderNo" label="订单号" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column prop="ladingNo" label="提单号" min-width="120" show-overflow-tooltip />
|
||||
<el-table-column prop="message" label="原因" min-width="180" show-overflow-tooltip />
|
||||
</el-table>
|
||||
<p v-if="recalcRunning" class="rebill-progress__hint">重算在后台进行,可收起弹窗继续操作;请勿关闭或刷新本页</p>
|
||||
<template #footer>
|
||||
<el-button v-if="recalcRunning" @click="recalcProgressVisible = false">收起</el-button>
|
||||
<el-button
|
||||
v-if="recalcRunning"
|
||||
v-hasPermi="['price:payOrder:recalc']"
|
||||
type="danger"
|
||||
plain
|
||||
:loading="recalcCancelLoading"
|
||||
@click="handleCancelRecalc"
|
||||
>取消重算</el-button>
|
||||
<template v-else>
|
||||
<el-button v-if="recalcFails.length" v-hasPermi="['price:payOrder:recalc']" type="warning" plain @click="viewRecalcFailed">查看失败订单</el-button>
|
||||
<el-button type="primary" @click="recalcProgressVisible = false">关闭</el-button>
|
||||
</template>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="PayOrderList">
|
||||
import { getBill } from '@/api/price/billing'
|
||||
import { addPayOrderFee, cancelPayOrderRecalc, getPayOrderRecalcTask, listPayOrder, listPayOrderFeeLogs, listPayOrderFees, pollPayOrderRecalc, removePayOrderFee, submitPayOrderRecalc } from '@/api/price/payOrder'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
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 logOpen = ref(false)
|
||||
const logLoading = ref(false)
|
||||
const logTitle = ref('费用日志')
|
||||
const logBillId = ref('')
|
||||
const logRows = ref([])
|
||||
const logTotal = ref(0)
|
||||
const logQuery = reactive({ pageNum: 1, pageSize: 10 })
|
||||
const recalcOpen = ref(false)
|
||||
const recalcSaving = ref(false)
|
||||
const recalcForm = reactive({ sourceType: 'ORDER', text: '' })
|
||||
const recalcPlaceholder = computed(() => recalcForm.sourceType === 'LADING'
|
||||
? '多个提单号可用逗号、空格或换行分隔,一次最多10个'
|
||||
: '多个订单号可用逗号、空格或换行分隔,一次最多500个')
|
||||
const recalcRunning = ref(false)
|
||||
const recalcFinished = ref(false)
|
||||
const recalcProgressVisible = ref(false)
|
||||
const recalcProgressPercent = ref(0)
|
||||
const recalcProgressMessage = ref('')
|
||||
const recalcProgressStatus = ref(undefined)
|
||||
const recalcProgressTotal = ref(0)
|
||||
const recalcProgressSuccess = ref(0)
|
||||
const recalcProgressFail = ref(0)
|
||||
const recalcLines = ref([])
|
||||
const recalcTaskId = ref('')
|
||||
const recalcCancelLoading = ref(false)
|
||||
let recalcFloatHideTimer = null
|
||||
const RECALC_TASK_STORAGE_KEY = 'price:payOrder:recalcTaskId'
|
||||
const recalcFails = computed(() => (recalcLines.value || []).filter(line => line && line.finished && !line.success))
|
||||
const recalcFloatVisible = computed(() => recalcRunning.value || recalcFinished.value)
|
||||
const recalcProgressDegree = computed(() => Math.round(((recalcProgressPercent.value || 0) / 100) * 360))
|
||||
const recalcProgressText = computed(() => (recalcProgressPercent.value || 0) + '%')
|
||||
const recalcDialogTitle = computed(() => {
|
||||
if (recalcRunning.value) return '费用重算进行中'
|
||||
if (recalcFinished.value) return '费用重算完成'
|
||||
return '费用重算'
|
||||
})
|
||||
const recalcFloatTitle = computed(() => {
|
||||
if (recalcRunning.value) return '费用重算中'
|
||||
if (recalcProgressStatus.value === 'exception') return '费用重算失败'
|
||||
if (recalcProgressStatus.value === 'warning' && String(recalcProgressMessage.value || '').includes('已取消')) return '费用重算已取消'
|
||||
if (recalcFinished.value) return '费用重算完成'
|
||||
return '费用重算'
|
||||
})
|
||||
const recalcFloatSummary = computed(() =>
|
||||
'成功 ' + (recalcProgressSuccess.value || 0) +
|
||||
' / 失败 ' + (recalcProgressFail.value || 0) +
|
||||
' / 总数 ' + (recalcProgressTotal.value || 0)
|
||||
)
|
||||
const recalcFloatTooltip = computed(() => recalcProgressMessage.value || '点击查看详情')
|
||||
|
||||
const sources = {
|
||||
CALC: '尾程计算',
|
||||
LADING: '提单分摊',
|
||||
MANUAL: '手工'
|
||||
}
|
||||
|
||||
function sourceText(value) {
|
||||
return sources[value] || value || '-'
|
||||
}
|
||||
|
||||
function logLines(row, side) {
|
||||
const name = row?.[side + 'FeeName']
|
||||
const amount = row?.[side + 'Amount']
|
||||
const currency = row?.[side + 'Currency']
|
||||
const blank = (name == null || name === '') && (amount == null || amount === '') && (currency == null || currency === '')
|
||||
if (blank) {
|
||||
return []
|
||||
}
|
||||
return [
|
||||
'费用项:' + (name || '空'),
|
||||
'金额:' + (amount == null || amount === '' ? '空' : amount),
|
||||
'币种:' + (currency || '空')
|
||||
]
|
||||
}
|
||||
|
||||
function loadLogPage(billId, query, rows, total, loading) {
|
||||
if (!billId) {
|
||||
rows.value = []
|
||||
total.value = 0
|
||||
return
|
||||
}
|
||||
loading.value = true
|
||||
listPayOrderFeeLogs(billId, { pageNum: query.pageNum, pageSize: query.pageSize }).then(res => {
|
||||
rows.value = res.rows || []
|
||||
total.value = res.total || 0
|
||||
}).catch(() => {
|
||||
proxy.$modal.msgError('费用日志加载失败')
|
||||
}).finally(() => {
|
||||
loading.value = false
|
||||
})
|
||||
}
|
||||
|
||||
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 = []
|
||||
feeOpen.value = true
|
||||
loadFees()
|
||||
}
|
||||
|
||||
function openLogs(row) {
|
||||
logTitle.value = (row.orderNo || '订单') + '的费用日志'
|
||||
logBillId.value = row.billId
|
||||
logQuery.pageNum = 1
|
||||
logRows.value = []
|
||||
logOpen.value = true
|
||||
loadLogs()
|
||||
}
|
||||
|
||||
function loadLogs() {
|
||||
loadLogPage(logBillId.value, logQuery, logRows, logTotal, logLoading)
|
||||
}
|
||||
|
||||
function loadFees() {
|
||||
if (!feeBillId.value) {
|
||||
return
|
||||
}
|
||||
feeLoading.value = true
|
||||
listPayOrderFees(feeBillId.value).then(res => {
|
||||
sections.value = res.data?.sections || []
|
||||
}).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 saveRecalcTaskId(taskId) {
|
||||
recalcTaskId.value = taskId ? String(taskId) : ''
|
||||
try {
|
||||
if (recalcTaskId.value) sessionStorage.setItem(RECALC_TASK_STORAGE_KEY, recalcTaskId.value)
|
||||
else sessionStorage.removeItem(RECALC_TASK_STORAGE_KEY)
|
||||
} catch (e) { /* 刷新后恢复不了进度,不影响重算本身 */ }
|
||||
}
|
||||
|
||||
function clearRecalcTaskId() {
|
||||
saveRecalcTaskId('')
|
||||
}
|
||||
|
||||
function readStoredRecalcTaskId() {
|
||||
try {
|
||||
return String(sessionStorage.getItem(RECALC_TASK_STORAGE_KEY) || '').trim()
|
||||
} catch (e) {
|
||||
return ''
|
||||
}
|
||||
}
|
||||
|
||||
function openRecalcProgress() {
|
||||
recalcProgressVisible.value = true
|
||||
}
|
||||
|
||||
function scheduleHideRecalcFloat() {
|
||||
if (recalcFloatHideTimer) {
|
||||
clearTimeout(recalcFloatHideTimer)
|
||||
recalcFloatHideTimer = null
|
||||
}
|
||||
recalcFloatHideTimer = window.setTimeout(() => {
|
||||
if (!recalcRunning.value && recalcFinished.value) recalcFinished.value = false
|
||||
recalcFloatHideTimer = null
|
||||
}, 8000)
|
||||
}
|
||||
|
||||
function applyRecalcProgress(task) {
|
||||
const total = Number(task.total) || 0
|
||||
const success = Number(task.successCount) || 0
|
||||
const fail = Number(task.failCount) || 0
|
||||
recalcProgressPercent.value = Math.min(100, Number(task.percent) || 0)
|
||||
recalcProgressTotal.value = total
|
||||
recalcProgressSuccess.value = success
|
||||
recalcProgressFail.value = fail
|
||||
recalcLines.value = Array.isArray(task.lines) ? task.lines : []
|
||||
const status = String(task.status || '').toUpperCase()
|
||||
if (status === 'PENDING') {
|
||||
recalcProgressMessage.value = '排队中…'
|
||||
} else if (status === 'RUNNING' && String(task.message || '').includes('取消')) {
|
||||
recalcProgressMessage.value = '正在取消,等待当前订单结束… ' + (success + fail) + '/' + total
|
||||
} else if (status === 'RUNNING') {
|
||||
recalcProgressMessage.value = '正在重算 ' + (success + fail) + '/' + total + (fail ? ('(失败 ' + fail + ')') : '')
|
||||
}
|
||||
}
|
||||
|
||||
function finishRecalcFromTask(task, cancelled) {
|
||||
const success = Number(task && task.successCount) || 0
|
||||
const fail = Number(task && task.failCount) || 0
|
||||
const total = Number(task && task.total) || recalcProgressTotal.value || 0
|
||||
recalcProgressPercent.value = Math.min(100, Number(task && task.percent) || 100)
|
||||
recalcProgressStatus.value = cancelled ? 'warning' : (fail > 0 ? 'warning' : 'success')
|
||||
recalcProgressTotal.value = total
|
||||
recalcProgressSuccess.value = success
|
||||
recalcProgressFail.value = fail
|
||||
recalcLines.value = task && Array.isArray(task.lines) ? task.lines : recalcLines.value
|
||||
if (cancelled) {
|
||||
recalcProgressMessage.value = '费用重算已取消:成功 ' + success + ' / 失败 ' + fail + ' / 总数 ' + total
|
||||
} else if (fail > 0) {
|
||||
recalcProgressMessage.value = '费用重算完成(含失败):成功 ' + success + ' / 失败 ' + fail + ' / 总数 ' + total
|
||||
} else {
|
||||
recalcProgressMessage.value = '费用重算完成:成功 ' + success + ' / 失败 ' + fail + ' / 总数 ' + total
|
||||
}
|
||||
recalcFinished.value = true
|
||||
clearRecalcTaskId()
|
||||
loadList()
|
||||
recalcProgressVisible.value = true
|
||||
if (cancelled) ElMessage.warning(recalcProgressMessage.value)
|
||||
else if (fail > 0) ElMessage.warning(recalcProgressMessage.value)
|
||||
else ElMessage.success(recalcProgressMessage.value)
|
||||
scheduleHideRecalcFloat()
|
||||
}
|
||||
|
||||
async function resumeRecalcTask(taskId) {
|
||||
if (!taskId || recalcRunning.value) return
|
||||
recalcRunning.value = true
|
||||
recalcFinished.value = false
|
||||
recalcCancelLoading.value = false
|
||||
saveRecalcTaskId(taskId)
|
||||
recalcProgressVisible.value = false
|
||||
recalcProgressPercent.value = 0
|
||||
recalcProgressStatus.value = undefined
|
||||
recalcProgressMessage.value = '恢复进度中…'
|
||||
recalcProgressTotal.value = 0
|
||||
recalcProgressSuccess.value = 0
|
||||
recalcProgressFail.value = 0
|
||||
recalcLines.value = []
|
||||
let superseded = false
|
||||
try {
|
||||
const result = await pollPayOrderRecalc(taskId, applyRecalcProgress)
|
||||
finishRecalcFromTask(result && result.task, !!(result && result.cancelled))
|
||||
} catch (e) {
|
||||
if (e && e.superseded) {
|
||||
superseded = true
|
||||
return
|
||||
}
|
||||
failRecalc(e)
|
||||
} finally {
|
||||
if (!superseded) recalcRunning.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function failRecalc(e) {
|
||||
const task = e && e.task
|
||||
recalcProgressStatus.value = 'exception'
|
||||
recalcProgressMessage.value = (e && e.message) || '费用重算失败'
|
||||
recalcFinished.value = true
|
||||
if (task) {
|
||||
recalcProgressPercent.value = Math.min(100, Number(task.percent) || 100)
|
||||
recalcProgressTotal.value = Number(task.total) || 0
|
||||
recalcProgressSuccess.value = Number(task.successCount) || 0
|
||||
recalcProgressFail.value = Number(task.failCount) || 0
|
||||
recalcLines.value = Array.isArray(task.lines) ? task.lines : []
|
||||
loadList()
|
||||
}
|
||||
clearRecalcTaskId()
|
||||
recalcProgressVisible.value = true
|
||||
scheduleHideRecalcFloat()
|
||||
}
|
||||
|
||||
async function tryRestoreRecalcProgress() {
|
||||
const taskId = readStoredRecalcTaskId()
|
||||
if (!taskId) return
|
||||
try {
|
||||
const res = await getPayOrderRecalcTask(taskId)
|
||||
const task = (res && res.data) || {}
|
||||
const status = String(task.status || '').toUpperCase()
|
||||
if (status === 'PENDING' || status === 'RUNNING') {
|
||||
applyRecalcProgress(task)
|
||||
resumeRecalcTask(taskId)
|
||||
return
|
||||
}
|
||||
clearRecalcTaskId()
|
||||
} catch (e) {
|
||||
clearRecalcTaskId()
|
||||
}
|
||||
}
|
||||
|
||||
async function runRecalc(payload) {
|
||||
if (recalcRunning.value) {
|
||||
openRecalcProgress()
|
||||
return
|
||||
}
|
||||
if (recalcFloatHideTimer) {
|
||||
clearTimeout(recalcFloatHideTimer)
|
||||
recalcFloatHideTimer = null
|
||||
}
|
||||
recalcRunning.value = true
|
||||
recalcFinished.value = false
|
||||
recalcCancelLoading.value = false
|
||||
clearRecalcTaskId()
|
||||
recalcProgressVisible.value = true
|
||||
recalcProgressPercent.value = 0
|
||||
recalcProgressStatus.value = undefined
|
||||
recalcProgressMessage.value = '任务提交中…'
|
||||
recalcProgressTotal.value = 0
|
||||
recalcProgressSuccess.value = 0
|
||||
recalcProgressFail.value = 0
|
||||
recalcLines.value = []
|
||||
window.setTimeout(() => {
|
||||
if (recalcRunning.value) recalcProgressVisible.value = false
|
||||
}, 600)
|
||||
let superseded = false
|
||||
try {
|
||||
const res = await submitPayOrderRecalc(payload)
|
||||
const taskId = res.data && res.data.taskId
|
||||
if (!taskId) throw new Error('没有拿到重算任务')
|
||||
saveRecalcTaskId(taskId)
|
||||
const result = await pollPayOrderRecalc(taskId, applyRecalcProgress)
|
||||
finishRecalcFromTask(result && result.task, !!(result && result.cancelled))
|
||||
} catch (e) {
|
||||
if (e && e.superseded) {
|
||||
superseded = true
|
||||
return
|
||||
}
|
||||
failRecalc(e)
|
||||
} finally {
|
||||
if (!superseded) recalcRunning.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function openRecalc() {
|
||||
if (recalcRunning.value) {
|
||||
openRecalcProgress()
|
||||
return
|
||||
}
|
||||
recalcForm.sourceType = 'ORDER'
|
||||
recalcForm.text = ''
|
||||
recalcOpen.value = true
|
||||
}
|
||||
|
||||
async function submitRecalc() {
|
||||
const text = String(recalcForm.text || '').trim()
|
||||
if (!text) {
|
||||
proxy.$modal.msgWarning(recalcForm.sourceType === 'LADING' ? '请填写提单号' : '请填写订单号')
|
||||
return
|
||||
}
|
||||
if (recalcRunning.value) {
|
||||
recalcOpen.value = false
|
||||
openRecalcProgress()
|
||||
return
|
||||
}
|
||||
const label = recalcForm.sourceType === 'LADING' ? '提单号' : '订单号'
|
||||
const count = text.split(/[\s,,;;]+/).filter(Boolean).length
|
||||
try {
|
||||
await ElMessageBox.confirm('将按 ' + count + ' 个' + label + '重算应付费用,确认继续?', '二次确认', { type: 'warning' })
|
||||
} catch (e) {
|
||||
return
|
||||
}
|
||||
const payload = { sourceType: recalcForm.sourceType, text }
|
||||
recalcOpen.value = false
|
||||
runRecalc(payload)
|
||||
}
|
||||
|
||||
async function handleCancelRecalc() {
|
||||
if (!recalcRunning.value || !recalcTaskId.value || recalcCancelLoading.value) return
|
||||
try {
|
||||
await ElMessageBox.confirm('确认取消当前费用重算?已经算完的订单会保留,未开始的将停止。', '取消重算', { type: 'warning' })
|
||||
} catch (e) {
|
||||
return
|
||||
}
|
||||
recalcCancelLoading.value = true
|
||||
try {
|
||||
const res = await cancelPayOrderRecalc(recalcTaskId.value)
|
||||
const task = (res && res.data) || {}
|
||||
applyRecalcProgress(task)
|
||||
recalcProgressMessage.value = '取消请求已提交,等待当前订单结束…'
|
||||
ElMessage.success('已提交取消')
|
||||
} catch (e) {
|
||||
/* 全局拦截器会提示 */
|
||||
} finally {
|
||||
recalcCancelLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function viewRecalcFailed() {
|
||||
recalcProgressVisible.value = false
|
||||
const orderNos = [...new Set(recalcFails.value.map(item => item.orderNo).filter(Boolean))]
|
||||
const ladingNos = [...new Set(recalcFails.value.map(item => item.ladingNo).filter(Boolean))]
|
||||
if (orderNos.length) {
|
||||
query.orderNo = orderNos.join('\n')
|
||||
query.ladingNo = ''
|
||||
} else if (ladingNos.length) {
|
||||
query.orderNo = ''
|
||||
query.ladingNo = ladingNos.join(',')
|
||||
}
|
||||
search()
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
tryRestoreRecalcProgress()
|
||||
})
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
if (recalcFloatHideTimer) {
|
||||
clearTimeout(recalcFloatHideTimer)
|
||||
recalcFloatHideTimer = null
|
||||
}
|
||||
})
|
||||
|
||||
loadList()
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.fee-board { max-height: 68vh; overflow: auto; }
|
||||
.fee-section { margin-bottom: 16px; }
|
||||
.fee-table :deep(.cell) {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.fee-table :deep(.el-table__header .cell) {
|
||||
text-align: center;
|
||||
}
|
||||
.fee-log-table :deep(.el-table__header .cell) {
|
||||
text-align: center;
|
||||
}
|
||||
.fee-table :deep(.el-select),
|
||||
.fee-table :deep(.el-input),
|
||||
.fee-table :deep(.el-input-number) {
|
||||
width: 100%;
|
||||
}
|
||||
.fee-table :deep(.fee-op .cell) {
|
||||
overflow: visible;
|
||||
text-overflow: clip;
|
||||
}
|
||||
.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; }
|
||||
.log-change { line-height: 1.6; }
|
||||
.log-empty { color: var(--el-text-color-secondary); }
|
||||
.rebill-progress__msg { margin-top: 12px; color: var(--el-text-color-regular); }
|
||||
.rebill-result-stats { display: flex; gap: 12px; margin-top: 14px; }
|
||||
.rebill-result-stats__item { flex: 1; padding: 10px 12px; border-radius: 8px; background: var(--el-fill-color-light); text-align: center; }
|
||||
.rebill-result-stats__item.is-success { background: var(--el-color-success-light-9); }
|
||||
.rebill-result-stats__item.is-fail { background: var(--el-color-warning-light-9); }
|
||||
.rebill-result-stats__label { display: block; font-size: 12px; color: var(--el-text-color-secondary); margin-bottom: 4px; }
|
||||
.rebill-result-stats__item strong { font-size: 20px; line-height: 1.2; color: var(--el-text-color-primary); }
|
||||
.rebill-progress__text { margin-top: 8px; font-size: 13px; color: var(--el-text-color-secondary); }
|
||||
.rebill-progress__hint { margin-top: 12px; font-size: 12px; color: var(--el-color-warning); }
|
||||
.rebill-progress__error { margin-top: 12px; }
|
||||
.pay-order-page .retry-status-float { position: fixed; top: 92px; right: 24px; z-index: 3001; }
|
||||
.pay-order-page .retry-status-button { display: inline-flex; align-items: center; gap: 10px; min-width: 200px; min-height: 68px; padding: 6px 16px 6px 7px; border-radius: 36px; }
|
||||
.pay-order-page .retry-progress-ring {
|
||||
position: relative;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex: 0 0 54px;
|
||||
width: 54px;
|
||||
height: 54px;
|
||||
border-radius: 50%;
|
||||
background: conic-gradient(var(--el-color-primary) 0deg var(--retry-progress, 45deg), var(--el-color-primary-light-8) var(--retry-progress, 45deg) 360deg);
|
||||
}
|
||||
.pay-order-page .retry-progress-ring::after { position: absolute; inset: 5px; content: ''; border-radius: 50%; background: var(--el-bg-color); }
|
||||
.pay-order-page .retry-progress-value { position: relative; z-index: 1; color: var(--el-color-primary); font-size: 12px; font-weight: 600; line-height: 1; }
|
||||
.pay-order-page .retry-status-text { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; line-height: 1.2; white-space: nowrap; }
|
||||
.pay-order-page .retry-status-text strong { font-size: 14px; font-weight: 600; }
|
||||
.pay-order-page .retry-status-text small { color: var(--el-text-color-secondary); font-size: 11px; }
|
||||
</style>
|
||||
@@ -24,7 +24,7 @@
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :xs="24" :sm="12" :lg="8">
|
||||
<el-form-item label="客户名称" class="filter-item" required>
|
||||
<el-form-item label="客户名称" class="filter-item">
|
||||
<customer-select
|
||||
v-model="query.customerCode"
|
||||
:fetch-options="listProfitCustomerOptions"
|
||||
@@ -46,6 +46,28 @@
|
||||
<el-input v-model="query.productCode" clearable placeholder="输入产品代码" class="filter-control" @keyup.enter="handleSearch" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :xs="24" :sm="12" :lg="8">
|
||||
<el-form-item label="产品名称" class="filter-item">
|
||||
<el-input v-model="query.productName" clearable placeholder="输入产品名称" class="filter-control" @keyup.enter="handleSearch" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :xs="24" :sm="12" :lg="8">
|
||||
<el-form-item label="国家/地区" class="filter-item">
|
||||
<el-input v-model="query.countryName" clearable placeholder="输入国家/地区名称" class="filter-control" @keyup.enter="handleSearch" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :xs="24" :sm="12" :lg="8">
|
||||
<el-form-item label="国家代码" class="filter-item">
|
||||
<el-input v-model="query.countryCode" clearable placeholder="输入国家代码" class="filter-control" @keyup.enter="handleSearch" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :xs="24" :sm="12" :lg="8">
|
||||
<el-form-item label="币种" class="filter-item">
|
||||
<el-select v-model="query.currency" clearable filterable allow-create default-first-option placeholder="选择或输入币种" class="filter-control">
|
||||
<el-option v-for="item in bms_currency" :key="item.value" :label="item.label || item.value" :value="item.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :xs="24" :sm="12" :lg="8">
|
||||
<el-form-item label="订单号" class="filter-item">
|
||||
<el-input
|
||||
@@ -59,7 +81,7 @@
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col v-if="dimension === 'order'" :xs="24" :sm="12" :lg="8">
|
||||
<el-col :xs="24" :sm="12" :lg="8">
|
||||
<el-form-item label="应收状态" class="filter-item">
|
||||
<el-select v-model="arBillStatus" clearable placeholder="全部状态" class="filter-control" @change="clearReportResults">
|
||||
<el-option label="未出账" value="UNBILLED" />
|
||||
@@ -119,10 +141,7 @@
|
||||
|
||||
<el-card shadow="never" class="table-card">
|
||||
<div class="table-heading">
|
||||
<el-tabs v-model="dimension" @tab-change="handleDimensionChange">
|
||||
<el-tab-pane label="产品维度" name="product" />
|
||||
<el-tab-pane label="订单维度" name="order" />
|
||||
</el-tabs>
|
||||
<span class="table-title">订单明细</span>
|
||||
<div class="table-toolbar">
|
||||
<!-- 提成功能暂停使用。
|
||||
<el-button
|
||||
@@ -144,62 +163,38 @@
|
||||
:loading="exporting"
|
||||
:disabled="!hasProfitRule() || !hasSearched"
|
||||
@click="handleExport"
|
||||
>导出当前维度</el-button>
|
||||
>导出订单明细</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-text-drag-copy="true" class="report-table-copy-area">
|
||||
<el-table :key="dimension + '-' + currentRule" v-loading="loading" :data="rows" border stripe :row-key="rowKey">
|
||||
<template v-if="dimension === 'product'">
|
||||
<el-table-column prop="productCode" label="产品代码" min-width="120" show-overflow-tooltip />
|
||||
<el-table-column prop="productName" label="产品名称" min-width="180" show-overflow-tooltip />
|
||||
<el-table-column prop="countryName" label="国家/地区" min-width="120" show-overflow-tooltip />
|
||||
<el-table-column prop="countryCode" label="国家代码" width="100" align="center" />
|
||||
<el-table-column prop="currency" label="币种" width="80" align="center" />
|
||||
<el-table-column prop="orderCount" label="订单数" width="100" align="right">
|
||||
<template #default="{ row }"><span class="success-value order-count-link" :class="{ 'is-disabled': !row.orderCount }" @click.stop="openOrderList(row)">{{ row.orderCount }}</span></template>
|
||||
</el-table-column>
|
||||
<el-table-column v-if="!isGuangzhou" prop="costAmount" label="产品价" min-width="130" align="right"><template #default="{ row }">{{ money(row.costAmount) }}</template></el-table-column>
|
||||
<el-table-column prop="redlineAmount" label="红线价" min-width="130" align="right"><template #default="{ row }">{{ money(row.redlineAmount) }}</template></el-table-column>
|
||||
<el-table-column v-if="!isGuangzhou" prop="redlineGrossProfit" label="红线毛利" min-width="130" align="right"><template #default="{ row }">{{ money(row.redlineGrossProfit) }}</template></el-table-column>
|
||||
<el-table-column v-if="!isGuangzhou" prop="redlineGrossMarginRate" label="红线毛利率" min-width="120" align="right"><template #default="{ row }">{{ rate(row.redlineGrossMarginRate) }}</template></el-table-column>
|
||||
<el-table-column prop="salesAmount" label="销售价" min-width="130" align="right"><template #default="{ row }">{{ money(row.salesAmount) }}</template></el-table-column>
|
||||
<el-table-column prop="salesGrossProfit" label="销售毛利" min-width="130" align="right"><template #default="{ row }">{{ money(row.salesGrossProfit) }}</template></el-table-column>
|
||||
<el-table-column prop="salesGrossMarginRate" label="销售毛利率" min-width="120" align="right"><template #default="{ row }">{{ rate(row.salesGrossMarginRate) }}</template></el-table-column>
|
||||
<!-- 提成功能暂停使用。
|
||||
<el-table-column prop="commissionAmount" label="提成金额" min-width="120" align="right"><template #default="{ row }">{{ money(row.commissionAmount) }}</template></el-table-column>
|
||||
<el-table-column prop="commissionMissingOrderCount" label="提成未计算订单" width="150" align="right">
|
||||
<template #default="{ row }"><span class="success-value order-count-link" :class="{ 'is-disabled': !row.commissionMissingOrderCount }" @click.stop="openOrderList(row, 'COMMISSION_MISSING', '提成未计算订单')">{{ row.commissionMissingOrderCount }}</span></template>
|
||||
</el-table-column>
|
||||
-->
|
||||
</template>
|
||||
<template v-else>
|
||||
<el-table-column prop="bizDate" label="计费时间" width="170" align="center"><template #default="{ row }">{{ parseTime(row.bizDate) }}</template></el-table-column>
|
||||
<el-table-column prop="orderNo" label="订单号" min-width="160" show-overflow-tooltip />
|
||||
<el-table-column prop="customerCode" label="客户代码" width="120" />
|
||||
<el-table-column prop="customerName" label="客户名称" min-width="160" show-overflow-tooltip />
|
||||
<el-table-column prop="belongSalerCode" label="业务员编码" min-width="150" show-overflow-tooltip />
|
||||
<el-table-column prop="belongSaler" label="业务员" min-width="110" show-overflow-tooltip />
|
||||
<el-table-column prop="productCode" label="产品代码" width="120" />
|
||||
<el-table-column prop="productName" label="产品名称" min-width="160" show-overflow-tooltip />
|
||||
<el-table-column prop="countryName" label="国家/地区" min-width="110" show-overflow-tooltip />
|
||||
<el-table-column prop="currency" label="币种" width="80" align="center" />
|
||||
<el-table-column v-if="!isGuangzhou" prop="costAmount" label="产品价" min-width="130" align="right"><template #default="{ row }">{{ money(row.costAmount) }}</template></el-table-column>
|
||||
<el-table-column prop="redlineAmount" label="红线价" min-width="130" align="right"><template #default="{ row }">{{ money(row.redlineAmount) }}</template></el-table-column>
|
||||
<el-table-column v-if="!isGuangzhou" prop="redlineGrossProfit" label="红线毛利" min-width="130" align="right"><template #default="{ row }">{{ money(row.redlineGrossProfit) }}</template></el-table-column>
|
||||
<el-table-column v-if="!isGuangzhou" prop="redlineGrossMarginRate" label="红线毛利率" min-width="120" align="right"><template #default="{ row }">{{ rate(row.redlineGrossMarginRate) }}</template></el-table-column>
|
||||
<el-table-column prop="salesAmount" label="销售价" min-width="130" align="right"><template #default="{ row }">{{ money(row.salesAmount) }}</template></el-table-column>
|
||||
<el-table-column prop="salesGrossProfit" label="销售毛利" min-width="130" align="right"><template #default="{ row }">{{ money(row.salesGrossProfit) }}</template></el-table-column>
|
||||
<el-table-column prop="salesGrossMarginRate" label="销售毛利率" min-width="120" align="right"><template #default="{ row }">{{ rate(row.salesGrossMarginRate) }}</template></el-table-column>
|
||||
<!-- 提成功能暂停使用。
|
||||
<el-table-column prop="commissionRate" label="提成比例" width="110" align="right"><template #default="{ row }">{{ commissionRateFormat(row.commissionRate) }}</template></el-table-column>
|
||||
<el-table-column prop="commissionAmount" label="提成金额" min-width="120" align="right"><template #default="{ row }">{{ money(row.commissionAmount) }}</template></el-table-column>
|
||||
-->
|
||||
<el-table-column prop="arBillStatus" label="应收状态" width="110" align="center">
|
||||
<template #default="{ row }">{{ arBillStatusLabel(row.arBillStatus) }}</template>
|
||||
</el-table-column>
|
||||
</template>
|
||||
<template #empty><el-empty :description="hasSearched ? '暂无符合条件的数据' : '请选择计费日期和客户名称后点击搜索'" /></template>
|
||||
<el-table :key="currentRule" v-loading="loading" :data="rows" border stripe row-key="orderNo">
|
||||
<el-table-column prop="bizDate" label="计费时间" width="170" align="center"><template #default="{ row }">{{ parseTime(row.bizDate) }}</template></el-table-column>
|
||||
<el-table-column prop="orderNo" label="订单号" min-width="160" show-overflow-tooltip />
|
||||
<el-table-column prop="customerCode" label="客户代码" width="120" />
|
||||
<el-table-column prop="customerName" label="客户名称" min-width="160" show-overflow-tooltip />
|
||||
<el-table-column prop="belongSalerCode" label="业务员编码" min-width="150" show-overflow-tooltip />
|
||||
<el-table-column prop="belongSaler" label="业务员" min-width="110" show-overflow-tooltip />
|
||||
<el-table-column prop="productCode" label="产品代码" width="120" />
|
||||
<el-table-column prop="productName" label="产品名称" min-width="160" show-overflow-tooltip />
|
||||
<el-table-column prop="countryName" label="国家/地区" min-width="110" show-overflow-tooltip />
|
||||
<el-table-column prop="countryCode" label="国家代码" width="100" align="center" />
|
||||
<el-table-column prop="currency" label="币种" width="80" align="center" />
|
||||
<el-table-column v-if="!isGuangzhou" prop="costAmount" label="产品价" min-width="130" align="right"><template #default="{ row }">{{ money(row.costAmount) }}</template></el-table-column>
|
||||
<el-table-column prop="redlineAmount" label="红线价" min-width="130" align="right"><template #default="{ row }">{{ money(row.redlineAmount) }}</template></el-table-column>
|
||||
<el-table-column v-if="!isGuangzhou" prop="redlineGrossProfit" label="红线毛利" min-width="130" align="right"><template #default="{ row }">{{ money(row.redlineGrossProfit) }}</template></el-table-column>
|
||||
<el-table-column v-if="!isGuangzhou" prop="redlineGrossMarginRate" label="红线毛利率" min-width="120" align="right"><template #default="{ row }">{{ rate(row.redlineGrossMarginRate) }}</template></el-table-column>
|
||||
<el-table-column prop="salesAmount" label="销售价" min-width="130" align="right"><template #default="{ row }">{{ money(row.salesAmount) }}</template></el-table-column>
|
||||
<el-table-column prop="salesGrossProfit" label="销售毛利" min-width="130" align="right"><template #default="{ row }">{{ money(row.salesGrossProfit) }}</template></el-table-column>
|
||||
<el-table-column prop="salesGrossMarginRate" label="销售毛利率" min-width="120" align="right"><template #default="{ row }">{{ rate(row.salesGrossMarginRate) }}</template></el-table-column>
|
||||
<!-- 提成功能暂停使用。
|
||||
<el-table-column prop="commissionRate" label="提成比例" width="110" align="right"><template #default="{ row }">{{ commissionRateFormat(row.commissionRate) }}</template></el-table-column>
|
||||
<el-table-column prop="commissionAmount" label="提成金额" min-width="120" align="right"><template #default="{ row }">{{ money(row.commissionAmount) }}</template></el-table-column>
|
||||
-->
|
||||
<el-table-column prop="arBillStatus" label="应收状态" width="110" align="center">
|
||||
<template #default="{ row }">{{ arBillStatusLabel(row.arBillStatus) }}</template>
|
||||
</el-table-column>
|
||||
<template #empty><el-empty :description="hasSearched ? '暂无符合条件的数据' : '请选择计费日期后点击搜索'" /></template>
|
||||
</el-table>
|
||||
</div>
|
||||
|
||||
@@ -212,35 +207,6 @@
|
||||
/>
|
||||
</el-card>
|
||||
|
||||
<el-dialog v-model="orderListDialogVisible" :title="orderListTitle" width="1280px" append-to-body>
|
||||
<el-table v-loading="orderListLoading" :data="orderListRows" border stripe>
|
||||
<el-table-column prop="bizDate" label="计费时间" width="170" align="center"><template #default="{ row }">{{ parseTime(row.bizDate) }}</template></el-table-column>
|
||||
<el-table-column prop="orderNo" label="订单号" min-width="170" show-overflow-tooltip />
|
||||
<el-table-column prop="customerCode" label="客户代码" width="120" />
|
||||
<el-table-column prop="customerName" label="客户名称" min-width="160" show-overflow-tooltip />
|
||||
<el-table-column prop="belongSalerCode" label="业务员编码" width="130" />
|
||||
<el-table-column prop="productCode" label="产品代码" width="120" />
|
||||
<el-table-column prop="productName" label="产品名称" min-width="160" show-overflow-tooltip />
|
||||
<el-table-column prop="countryName" label="国家/地区" width="110" />
|
||||
<el-table-column prop="currency" label="币种" width="80" align="center" />
|
||||
<el-table-column v-if="!isGuangzhou" prop="costAmount" label="产品价" width="110" align="right"><template #default="{ row }">{{ money(row.costAmount) }}</template></el-table-column>
|
||||
<el-table-column prop="redlineAmount" label="红线价" width="110" align="right"><template #default="{ row }">{{ money(row.redlineAmount) }}</template></el-table-column>
|
||||
<el-table-column prop="salesAmount" label="销售价" width="110" align="right"><template #default="{ row }">{{ money(row.salesAmount) }}</template></el-table-column>
|
||||
<el-table-column v-if="isGuangzhou" prop="salesGrossProfit" label="销售毛利" width="110" align="right"><template #default="{ row }">{{ money(row.salesGrossProfit) }}</template></el-table-column>
|
||||
<el-table-column v-if="isGuangzhou" prop="salesGrossMarginRate" label="销售毛利率" width="110" align="right"><template #default="{ row }">{{ rate(row.salesGrossMarginRate) }}</template></el-table-column>
|
||||
<el-table-column prop="arBillStatus" label="应收状态" width="100" align="center"><template #default="{ row }">{{ arBillStatusLabel(row.arBillStatus) }}</template></el-table-column>
|
||||
<template #empty><el-empty description="暂无符合条件的订单" /></template>
|
||||
</el-table>
|
||||
<pagination
|
||||
v-show="orderListTotal > 0"
|
||||
v-model:page="orderListPageNum"
|
||||
v-model:limit="orderListPageSize"
|
||||
:total="orderListTotal"
|
||||
@pagination="loadOrderList"
|
||||
/>
|
||||
<template #footer><el-button @click="orderListDialogVisible = false">关闭</el-button></template>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog v-model="exportLogVisible" title="毛利分析导出日志" width="1000px" append-to-body>
|
||||
<el-table v-loading="exportLogLoading" :data="exportLogs" border stripe>
|
||||
<el-table-column prop="fileName" label="文件名" min-width="280" show-overflow-tooltip />
|
||||
@@ -309,15 +275,14 @@
|
||||
</template>
|
||||
|
||||
<script setup name="ProfitReport">
|
||||
import { downloadProfitExport, exportProfitOrders, exportProfitProducts, listProfitAreaRules, listProfitCustomerOptions, listProfitExports, listProfitOrders, listProfitProducts, listProfitSummary } from '@/api/report/profit'
|
||||
import { downloadProfitExport, exportProfitOrders, listProfitAreaRules, listProfitCustomerOptions, listProfitExports, listProfitOrders, listProfitSummary } from '@/api/report/profit'
|
||||
// 提成功能暂停使用:import { deleteProfitCommissionRate, listProfitCommissionRates, saveProfitCommissionRate } from '@/api/report/profit'
|
||||
import { parseTime } from '@/utils/bms'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { saveAs } from 'file-saver'
|
||||
// 提成功能暂停使用:import { ElMessageBox } from 'element-plus'
|
||||
|
||||
const dimension = ref('product')
|
||||
const { customer_area } = useDict('customer_area')
|
||||
const { customer_area, bms_currency } = useDict('customer_area', 'bms_currency')
|
||||
const multiValueFilterLimit = 2000
|
||||
const dateRange = ref([formatLocalDate(-30), formatLocalDate(0)])
|
||||
const arBillStatus = ref('')
|
||||
@@ -326,7 +291,11 @@ const query = reactive({
|
||||
orderNo: '',
|
||||
customerCode: '',
|
||||
belongSalerCode: '',
|
||||
productCode: ''
|
||||
productCode: '',
|
||||
productName: '',
|
||||
countryName: '',
|
||||
countryCode: '',
|
||||
currency: ''
|
||||
})
|
||||
const areaRules = ref(null)
|
||||
const areaRulesFailed = ref(false)
|
||||
@@ -350,15 +319,6 @@ const exportLogTotal = ref(0)
|
||||
const pageNum = ref(1)
|
||||
const pageSize = ref(10)
|
||||
const total = ref(0)
|
||||
const orderListDialogVisible = ref(false)
|
||||
const orderListTitle = ref('订单列表')
|
||||
const orderListLoading = ref(false)
|
||||
const orderListRows = ref([])
|
||||
const orderListTotal = ref(0)
|
||||
const orderListPageNum = ref(1)
|
||||
const orderListPageSize = ref(10)
|
||||
const orderListContext = ref(null)
|
||||
let orderListRequestVersion = 0
|
||||
/* 提成表单状态与初始化暂停使用,保留代码便于恢复。
|
||||
const commissionDialogVisible = ref(false)
|
||||
const commissionLoading = ref(false)
|
||||
@@ -394,9 +354,9 @@ function formatLocalDate(offset) {
|
||||
return `${year}-${month}-${day}`
|
||||
}
|
||||
|
||||
function buildQuery(paged = true, includeArBillStatus = dimension.value === 'order') {
|
||||
function buildQuery(paged = true) {
|
||||
const params = { ...query }
|
||||
if (includeArBillStatus && arBillStatus.value) params.arBillStatus = arBillStatus.value
|
||||
if (arBillStatus.value) params.arBillStatus = arBillStatus.value
|
||||
if (dateRange.value?.[0]) params.beginBizDate = dateRange.value[0] + ' 00:00:00'
|
||||
if (dateRange.value?.[1]) params.endBizDate = dateRange.value[1] + ' 23:59:59'
|
||||
if (paged) {
|
||||
@@ -437,10 +397,6 @@ function validateRequiredFilters(showMessage = true) {
|
||||
if (showMessage) ElMessage.warning('请选择完整的计费日期')
|
||||
return false
|
||||
}
|
||||
if (!query.customerCode) {
|
||||
if (showMessage) ElMessage.warning('请选择客户名称')
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -458,11 +414,9 @@ function loadSummary() {
|
||||
function loadRows() {
|
||||
if (!hasSearched.value || !validateRequiredFilters(false) || !hasProfitRule() || !validateMultiValueFilters()) return Promise.resolve()
|
||||
const requestVersion = ++rowsRequestVersion
|
||||
const requestDimension = dimension.value
|
||||
loading.value = true
|
||||
const api = requestDimension === 'product' ? listProfitProducts : listProfitOrders
|
||||
return api(buildQuery()).then(res => {
|
||||
if (requestVersion !== rowsRequestVersion || requestDimension !== dimension.value) return
|
||||
return listProfitOrders(buildQuery()).then(res => {
|
||||
if (requestVersion !== rowsRequestVersion) return
|
||||
rows.value = res.rows || []
|
||||
total.value = res.total || 0
|
||||
}).finally(() => {
|
||||
@@ -474,17 +428,11 @@ function clearReportResults() {
|
||||
hasSearched.value = false
|
||||
summaryRequestVersion++
|
||||
rowsRequestVersion++
|
||||
orderListRequestVersion++
|
||||
summaryList.value = []
|
||||
summaryLoaded.value = false
|
||||
rows.value = []
|
||||
total.value = 0
|
||||
loading.value = false
|
||||
orderListDialogVisible.value = false
|
||||
orderListLoading.value = false
|
||||
orderListRows.value = []
|
||||
orderListTotal.value = 0
|
||||
orderListContext.value = null
|
||||
}
|
||||
|
||||
function handleSearch() {
|
||||
@@ -505,59 +453,6 @@ function handleReset() {
|
||||
clearReportResults()
|
||||
}
|
||||
|
||||
function handleDimensionChange() {
|
||||
if (dimension.value !== 'order') arBillStatus.value = ''
|
||||
pageNum.value = 1
|
||||
rows.value = []
|
||||
total.value = 0
|
||||
if (!hasSearched.value || !validateRequiredFilters(false)) return
|
||||
Promise.all([loadSummary(), loadRows()])
|
||||
}
|
||||
|
||||
function openOrderList(row) {
|
||||
if (!hasSearched.value || !validateRequiredFilters()) return
|
||||
if (!validateMultiValueFilters()) return
|
||||
if (!row.orderCount) return
|
||||
orderListTitle.value = '订单列表'
|
||||
orderListContext.value = {
|
||||
productDrilldown: true,
|
||||
productCode: row.productCode,
|
||||
countryCode: row.countryCode,
|
||||
currency: row.currency
|
||||
}
|
||||
orderListPageNum.value = 1
|
||||
orderListTotal.value = 0
|
||||
orderListRows.value = []
|
||||
orderListDialogVisible.value = true
|
||||
loadOrderList()
|
||||
}
|
||||
|
||||
function loadOrderList() {
|
||||
if (!orderListContext.value) return
|
||||
if (!hasSearched.value || !validateRequiredFilters(false) || !hasProfitRule() || !validateMultiValueFilters()) return
|
||||
const requestVersion = ++orderListRequestVersion
|
||||
orderListLoading.value = true
|
||||
const params = {
|
||||
...buildQuery(false),
|
||||
...orderListContext.value,
|
||||
pageNum: orderListPageNum.value,
|
||||
pageSize: orderListPageSize.value
|
||||
}
|
||||
listProfitOrders(params).then(res => {
|
||||
if (requestVersion !== orderListRequestVersion) return
|
||||
orderListRows.value = res.rows || []
|
||||
orderListTotal.value = res.total || 0
|
||||
}).finally(() => {
|
||||
if (requestVersion === orderListRequestVersion) orderListLoading.value = false
|
||||
})
|
||||
}
|
||||
|
||||
function rowKey(row) {
|
||||
return dimension.value === 'product'
|
||||
? [row.productCode, row.countryCode, row.currency].join('|')
|
||||
: row.orderNo
|
||||
}
|
||||
|
||||
function money(value) {
|
||||
if (value === null || value === undefined || value === '') return '-'
|
||||
const number = Number(value)
|
||||
@@ -591,9 +486,8 @@ async function handleExport() {
|
||||
if (!hasSearched.value || !validateRequiredFilters()) return
|
||||
if (!hasProfitRule() || !validateMultiValueFilters()) return
|
||||
exporting.value = true
|
||||
const exporter = dimension.value === 'product' ? exportProfitProducts : exportProfitOrders
|
||||
try {
|
||||
const response = await exporter(buildQuery(false))
|
||||
const response = await exportProfitOrders(buildQuery(false))
|
||||
const exportLog = response.data
|
||||
const file = await downloadProfitExport(exportLog.exportId)
|
||||
if (file.type?.includes('json')) {
|
||||
@@ -726,6 +620,10 @@ watch(() => [
|
||||
query.customerCode,
|
||||
query.belongSalerCode,
|
||||
query.productCode,
|
||||
query.productName,
|
||||
query.countryName,
|
||||
query.countryCode,
|
||||
query.currency,
|
||||
dateRange.value?.[0],
|
||||
dateRange.value?.[1]
|
||||
], () => {
|
||||
@@ -834,23 +732,6 @@ watch(() => [
|
||||
color: var(--el-color-primary);
|
||||
}
|
||||
|
||||
.success-value {
|
||||
color: var(--el-color-success);
|
||||
}
|
||||
|
||||
.order-count-link {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.order-count-link:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.order-count-link.is-disabled {
|
||||
cursor: default;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.table-heading {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -860,17 +741,9 @@ watch(() => [
|
||||
border-bottom: 1px solid var(--el-border-color-light);
|
||||
}
|
||||
|
||||
.table-heading :deep(.el-tabs) {
|
||||
flex: 1;
|
||||
min-width: 180px;
|
||||
}
|
||||
|
||||
.table-heading :deep(.el-tabs__header) {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.table-heading :deep(.el-tabs__nav-wrap::after) {
|
||||
display: none;
|
||||
.table-title {
|
||||
font-weight: 600;
|
||||
padding-bottom: 8px;
|
||||
}
|
||||
|
||||
.table-toolbar {
|
||||
|
||||
Reference in New Issue
Block a user