✨ 支持应收账单明细按单号和产品搜索
This commit is contained in:
@@ -19,6 +19,20 @@
|
||||
|
||||
<!-- 账单明细独立分页;费用明细在展开行时再懒加载。 -->
|
||||
<div class="section-title">账单明细({{ detail.orderCount || 0 }})</div>
|
||||
<el-form :model="detailSearchForm" label-width="44px" size="small" class="detail-search-form" @submit.prevent>
|
||||
<el-form-item label="单号">
|
||||
<el-input v-model="detailSearchForm.orderKeyword" placeholder="订单号、运单号或转单号" clearable
|
||||
:maxlength="64" @keyup.enter="handleDetailSearch" />
|
||||
</el-form-item>
|
||||
<el-form-item label="产品">
|
||||
<el-input v-model="detailSearchForm.productKeyword" placeholder="产品代码或名称" clearable
|
||||
:maxlength="100" @keyup.enter="handleDetailSearch" />
|
||||
</el-form-item>
|
||||
<el-form-item class="detail-search-actions" label-width="0">
|
||||
<el-button type="primary" icon="Search" @click="handleDetailSearch">搜索</el-button>
|
||||
<el-button icon="Refresh" @click="resetDetailSearch">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<el-table v-loading="detailListLoading" :data="detailRows" row-key="detailId" border size="small" @expand-change="handleExpandChange">
|
||||
<el-table-column type="expand">
|
||||
<template #default="{ row }">
|
||||
@@ -48,14 +62,14 @@
|
||||
<el-table-column prop="redlineAmount" label="整单红线价" width="130" align="right"><template #default="{ row }">{{ amount4(row.redlineAmount) }}</template></el-table-column>
|
||||
</el-table>
|
||||
<el-pagination
|
||||
v-if="detailTotal > 0"
|
||||
v-if="detailTotal > 0 || appliedDetailQuery.orderKeyword || appliedDetailQuery.productKeyword"
|
||||
class="detail-pagination"
|
||||
v-model:current-page="detailPageNum"
|
||||
v-model:page-size="detailPageSize"
|
||||
:current-page="detailPageNum"
|
||||
:page-size="detailPageSize"
|
||||
:page-sizes="[10, 20, 50]"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
:total="detailTotal"
|
||||
@current-change="loadDetails"
|
||||
@current-change="handleDetailPageChange"
|
||||
@size-change="handleDetailSizeChange"
|
||||
/>
|
||||
|
||||
@@ -86,6 +100,9 @@ const detailPageNum = ref(1)
|
||||
// 详情默认每页 10 条,避免几十万条账单明细一次性进入浏览器内存。
|
||||
const detailPageSize = ref(10)
|
||||
const detailListLoading = ref(false)
|
||||
const detailSearchForm = reactive({ orderKeyword: '', productKeyword: '' })
|
||||
// 翻页沿用最后一次搜索的条件,输入中的文本只在点击搜索或回车时应用。
|
||||
const appliedDetailQuery = ref({ orderKeyword: '', productKeyword: '' })
|
||||
let detailRequestSerial = 0
|
||||
|
||||
// 切换账单时重置分页和请求序号,旧账单的慢响应不能覆盖新账单。
|
||||
@@ -94,6 +111,9 @@ watch(() => props.detail?.arBillId, billId => {
|
||||
detailPageNum.value = 1
|
||||
detailTotal.value = 0
|
||||
detailRows.value = []
|
||||
detailListLoading.value = false
|
||||
Object.assign(detailSearchForm, { orderKeyword: '', productKeyword: '' })
|
||||
appliedDetailQuery.value = { orderKeyword: '', productKeyword: '' }
|
||||
if (billId) loadDetails()
|
||||
}, { immediate: true })
|
||||
|
||||
@@ -103,16 +123,45 @@ function loadDetails() {
|
||||
if (!billId) return
|
||||
const serial = ++detailRequestSerial
|
||||
detailListLoading.value = true
|
||||
listArBillDetails(billId, { pageNum: detailPageNum.value, pageSize: detailPageSize.value }).then(res => {
|
||||
listArBillDetails(billId, {
|
||||
...appliedDetailQuery.value,
|
||||
pageNum: detailPageNum.value,
|
||||
pageSize: detailPageSize.value
|
||||
}).then(res => {
|
||||
if (serial !== detailRequestSerial) return
|
||||
detailRows.value = (res.rows || []).map(row => ({ ...row, fees: [], feesLoaded: false, feeLoading: false }))
|
||||
detailTotal.value = Number(res.total) || 0
|
||||
}).catch(() => {
|
||||
if (serial !== detailRequestSerial) return
|
||||
detailRows.value = []
|
||||
detailTotal.value = 0
|
||||
}).finally(() => {
|
||||
if (serial === detailRequestSerial) detailListLoading.value = false
|
||||
})
|
||||
}
|
||||
|
||||
function handleDetailSearch() {
|
||||
appliedDetailQuery.value = {
|
||||
orderKeyword: detailSearchForm.orderKeyword.trim(),
|
||||
productKeyword: detailSearchForm.productKeyword.trim()
|
||||
}
|
||||
detailPageNum.value = 1
|
||||
loadDetails()
|
||||
}
|
||||
|
||||
function resetDetailSearch() {
|
||||
Object.assign(detailSearchForm, { orderKeyword: '', productKeyword: '' })
|
||||
handleDetailSearch()
|
||||
}
|
||||
|
||||
function handleDetailPageChange(page) {
|
||||
if (page === detailPageNum.value) return
|
||||
detailPageNum.value = page
|
||||
loadDetails()
|
||||
}
|
||||
|
||||
function handleDetailSizeChange(size) {
|
||||
if (size === detailPageSize.value) return
|
||||
detailPageSize.value = size
|
||||
detailPageNum.value = 1
|
||||
loadDetails()
|
||||
@@ -151,6 +200,9 @@ function mask(value) { if (!value) return '-'; return value.length <= 4 ? '****'
|
||||
.section-title::before { content: ''; width: 3px; height: 15px; border-radius: 2px; background: var(--el-color-primary); }
|
||||
.export-title { justify-content: space-between; }
|
||||
.export-title::before { margin-right: auto; }
|
||||
.detail-search-form { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 12px; }
|
||||
.detail-search-form :deep(.el-form-item) { flex: 1 1 260px; max-width: 360px; margin: 0; }
|
||||
.detail-search-form :deep(.detail-search-actions) { flex: 0 0 auto; max-width: none; }
|
||||
.detail-pagination { justify-content: flex-end; margin: 12px 0 4px; }
|
||||
.fee-panel { min-height: 54px; padding: 4px 12px 8px 42px; background: #fafafa; }
|
||||
.fee-table { background: #fafafa; }
|
||||
|
||||
Reference in New Issue
Block a user