210 lines
7.7 KiB
Vue
210 lines
7.7 KiB
Vue
<template>
|
|
<div class="app-container billing-bill">
|
|
<basic-table
|
|
ref="tableRef"
|
|
:columns="columns"
|
|
:search-columns="searchColumns"
|
|
:query="queryList"
|
|
search-action-align="center"
|
|
row-key="billId"
|
|
>
|
|
<template #search-orderNos="{ model }">
|
|
<multi-value-input v-model="model.orderNos" placeholder="订单号" width="100%" :search-method="searchOrderNoOptions" />
|
|
</template>
|
|
<template #search-customerCodes="{ model }">
|
|
<customer-select
|
|
v-model="model.customerCodes"
|
|
type="customer"
|
|
value-key="customerCode"
|
|
label-key="customerName"
|
|
code-key="customerCode"
|
|
placeholder="请输入"
|
|
multiple
|
|
/>
|
|
</template>
|
|
<template #search-productCodes="{ model }">
|
|
<el-select
|
|
v-model="model.productCodes"
|
|
multiple
|
|
filterable
|
|
clearable
|
|
collapse-tags
|
|
collapse-tags-tooltip
|
|
placeholder="请输入"
|
|
style="width: 100%;"
|
|
>
|
|
<el-option v-for="p in productOptions" :key="p.code" :label="p.name" :value="p.code">
|
|
<span>{{ p.name }}</span>
|
|
<span style="float: right; color: var(--el-text-color-secondary); font-size: 12px;">{{ p.code }}</span>
|
|
</el-option>
|
|
</el-select>
|
|
</template>
|
|
<template #col-product="{ row }">
|
|
{{ row.productName || '-' }} ({{ row.productCode }})
|
|
</template>
|
|
<template #col-country="{ row }">
|
|
{{ row.countryName || '-' }} ({{ row.countryCode || '-' }})
|
|
</template>
|
|
<template #col-matchSource="{ row }">
|
|
<el-tag size="small" :type="sourceTagType(row.matchSource)">{{ sourceLabel(row.matchSource) }}</el-tag>
|
|
</template>
|
|
<template #col-customerActiveStatus="{ row }">
|
|
<el-tag size="small" :type="customerActiveTagType(row.customerActiveStatus)">{{ customerActiveLabel(row.customerActiveStatus) }}</el-tag>
|
|
</template>
|
|
<template #col-creditArrearsStatus="{ row }">
|
|
<el-tag size="small" :type="creditArrearsTagType(row.creditArrearsStatus)">{{ creditArrearsLabel(row.creditArrearsStatus) }}</el-tag>
|
|
</template>
|
|
<template #col-incomeTotal="{ row }">
|
|
<span class="payable">{{ formatMoney(row.incomeTotal) }}</span>
|
|
</template>
|
|
<template #col-payTotal="{ row }">
|
|
<span class="payable">{{ formatMoney(row.payTotal) }}</span>
|
|
</template>
|
|
<template #col-action="{ row }">
|
|
<el-button link type="primary" icon="View" @click="handleView(row)">查看</el-button>
|
|
</template>
|
|
</basic-table>
|
|
|
|
<bill-detail v-model="open" :title="title" :loading="loading" :detail="detail" />
|
|
</div>
|
|
</template>
|
|
|
|
<script setup name="BillingBill">
|
|
import { listBill, getBill, listOrderNoOptions } from '@/api/price/billing'
|
|
import { useProducts } from '@/components/ProductSelect/useProducts'
|
|
import BillDetail from './components/BillDetail.vue'
|
|
|
|
// 订单号下拉远程搜索:返回匹配的订单号列表(最多 20 条)
|
|
function searchOrderNoOptions(keyword) {
|
|
return listOrderNoOptions(keyword).then(res => res.data || [])
|
|
}
|
|
|
|
// 产品下拉选项:复用 ProductSelect 的模块级产品缓存(全应用只拉一次)
|
|
const { productList, ensureProducts } = useProducts()
|
|
ensureProducts()
|
|
const productOptions = computed(() =>
|
|
productList.value
|
|
.filter(p => p.productCode)
|
|
.map(p => ({ code: p.productCode, name: p.productName || p.productCode }))
|
|
)
|
|
|
|
const tableRef = ref()
|
|
const open = ref(false)
|
|
const title = ref('计费详情')
|
|
const loading = ref(false)
|
|
const detail = ref(null)
|
|
|
|
const columns = [
|
|
{ label: '订单号', prop: 'orderNo', minWidth: 140, showOverflowTooltip: true },
|
|
{ label: '运单号', prop: 'trackingNo', minWidth: 140, showOverflowTooltip: true },
|
|
{ label: '转单号', prop: 'transferNo', minWidth: 140, showOverflowTooltip: true },
|
|
{ label: '客户', prop: 'customerName', minWidth: 140, showOverflowTooltip: true },
|
|
{ label: '客户代码', prop: 'customerCode', width: 120 },
|
|
{ label: '产品', prop: 'product', minWidth: 160, slot: 'product' },
|
|
{ label: '国家', prop: 'country', minWidth: 130, slot: 'country' },
|
|
{ label: '件数', prop: 'pieces', align: 'center', width: 70 },
|
|
{ label: '计费重', prop: 'chargeWeight', align: 'center', width: 90 },
|
|
{ label: '应收总额', prop: 'incomeTotal', align: 'right', width: 120, slot: 'incomeTotal' },
|
|
{ label: '应付总额', prop: 'payTotal', align: 'right', width: 120, slot: 'payTotal' },
|
|
{ label: '计价来源', prop: 'matchSource', align: 'center', width: 130, slot: 'matchSource' },
|
|
{ label: '客户生效', prop: 'customerActiveStatus', align: 'center', width: 100, slot: 'customerActiveStatus' },
|
|
{ label: '额度欠费', prop: 'creditArrearsStatus', align: 'center', width: 100, slot: 'creditArrearsStatus' },
|
|
{ label: '下单时间', prop: 'orderTime', align: 'center', width: 170, parseTime: true },
|
|
{ label: '操作', prop: 'action', align: 'center', width: 90, fixed: 'right', slot: 'action', showInToolbar: false }
|
|
]
|
|
|
|
const searchColumns = [
|
|
{ label: '订单号', prop: 'orderNos', placeholder: '订单号' },
|
|
{ label: '运单号', prop: 'trackingNo', component: 'input', placeholder: '运单号' },
|
|
{ label: '转单号', prop: 'transferNo', component: 'input', placeholder: '转单号' },
|
|
{ label: '客户', prop: 'customerCodes', placeholder: '客户代码' },
|
|
{ label: '产品代码', prop: 'productCodes', placeholder: '产品代码' }
|
|
]
|
|
|
|
function queryList(params) {
|
|
return listBill(params)
|
|
}
|
|
|
|
function handleView(row) {
|
|
title.value = '计费详情 #' + (row.orderNo || row.billId)
|
|
open.value = true
|
|
loading.value = true
|
|
detail.value = null
|
|
getBill(row.billId).then(res => {
|
|
detail.value = res.data || null
|
|
}).finally(() => {
|
|
loading.value = false
|
|
})
|
|
}
|
|
|
|
function formatMoney(val) {
|
|
if (val === null || val === undefined || val === '') return '-'
|
|
const num = Number(val)
|
|
if (Number.isNaN(num)) return val
|
|
return num.toFixed(4)
|
|
}
|
|
|
|
function sourceLabel(source) {
|
|
const map = {
|
|
PACKAGE_FIXED: '客户固定价套餐',
|
|
PACKAGE_DISCOUNT: '客户折扣套餐',
|
|
PRODUCT_DEFAULT: '产品默认价',
|
|
FIXED: '客户固定价套餐',
|
|
DISCOUNT: '客户折扣套餐'
|
|
}
|
|
return map[source] || source || '-'
|
|
}
|
|
|
|
function sourceTagType(source) {
|
|
if (source === 'PACKAGE_FIXED' || source === 'FIXED') return 'success'
|
|
if (source === 'PACKAGE_DISCOUNT' || source === 'DISCOUNT') return 'warning'
|
|
if (source === 'PRODUCT_DEFAULT') return 'info'
|
|
return ''
|
|
}
|
|
|
|
function customerActiveLabel(status) {
|
|
const map = { ACTIVE: '正常', MISSING: '不存在', DISABLED: '停用' }
|
|
return map[status] || status || '-'
|
|
}
|
|
|
|
function customerActiveTagType(status) {
|
|
if (status === 'ACTIVE') return 'success'
|
|
if (status === 'DISABLED') return 'warning'
|
|
if (status === 'MISSING') return 'danger'
|
|
return 'info'
|
|
}
|
|
|
|
function creditArrearsLabel(status) {
|
|
const map = { NORMAL: '正常', ARREARS: '欠费' }
|
|
return map[status] || status || '-'
|
|
}
|
|
|
|
function creditArrearsTagType(status) {
|
|
if (status === 'NORMAL') return 'success'
|
|
if (status === 'ARREARS') return 'danger'
|
|
return 'info'
|
|
}
|
|
</script>
|
|
|
|
<style scoped>
|
|
.billing-bill .payable {
|
|
color: #f56c6c;
|
|
font-weight: 600;
|
|
font-variant-numeric: tabular-nums;
|
|
}
|
|
|
|
/* 搜索栏铺满整行:搜索项 flex 等分拉伸,控件占满所在项 */
|
|
.billing-bill :deep(.basic-form.el-form--inline) {
|
|
display: flex;
|
|
flex-wrap: wrap;
|
|
}
|
|
.billing-bill :deep(.basic-form.el-form--inline > .el-form-item:not(.basic-form-action--center)) {
|
|
flex: 1 1 0;
|
|
margin-right: 12px;
|
|
}
|
|
.billing-bill :deep(.basic-form.el-form--inline .el-form-item .el-select),
|
|
.billing-bill :deep(.basic-form.el-form--inline .el-form-item .el-input) {
|
|
width: 100%;
|
|
}
|
|
</style>
|