Merge branch 'test'

This commit is contained in:
caojia
2026-10-27 18:25:18 +08:00
11 changed files with 285 additions and 18 deletions
+22 -9
View File
@@ -126,15 +126,18 @@
</template>
</el-table>
<!-- 分页 -->
<pagination
v-show="total > 0"
:total="total"
v-model:page="queryParams.pageNum"
v-model:limit="queryParams.pageSize"
:page-sizes="pageSizes"
@pagination="getList"
/>
<!-- 分页;可选的分页前置内容用于展示汇总等信息。 -->
<div class="basic-table-pagination" :class="{ 'basic-table-pagination--with-extra': $slots['pagination-extra'] }">
<slot name="pagination-extra" />
<pagination
v-show="total > 0"
:total="total"
v-model:page="queryParams.pageNum"
v-model:limit="queryParams.pageSize"
:page-sizes="pageSizes"
@pagination="getList"
/>
</div>
</div>
</template>
@@ -727,6 +730,16 @@ onBeforeUnmount(() => {
.basic-table {
width: 100%;
}
.basic-table-pagination--with-extra {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16px;
flex-wrap: wrap;
}
.basic-table-pagination--with-extra :deep(.pagination-container) {
margin-left: auto;
}
.basic-table-virtual {
width: 100%;
min-height: 240px;
+33 -2
View File
@@ -32,6 +32,9 @@
<el-col :span="1.5"><el-button type="primary" plain icon="Plus" v-hasPermi="['ar:bill:generate']" @click="generateOpen = true">生成账单</el-button></el-col>
<el-col v-if="customerScoped" :span="1.5"><el-button type="info" plain icon="Close" @click="clearCustomerFilter">清除客户条件</el-button></el-col>
</template>
<template #search-extra>
<el-button type="warning" plain icon="Download" v-hasPermi="['ar:bill:export']" @click="handleExport">导出</el-button>
</template>
<template #search-customerId="{ model }">
<customer-select v-model="model.customerId" placeholder="请输入客户名称或代码搜索" :remote-search="true" :page-size="20" />
</template>
@@ -45,6 +48,7 @@
<el-button v-if="row.status === AR_BILL_STATUS.DRAFT || row.status === AR_BILL_STATUS.CONFIRMED" link type="warning" v-hasPermi="['ar:bill:void']" @click="voidBill(row)">作废</el-button>
<el-button v-if="row.status !== AR_BILL_STATUS.DRAFT && row.status !== AR_BILL_STATUS.VOID" link type="primary" v-hasPermi="['ar:bill:export']" @click="exportBill(row)">导出明细</el-button>
<el-button v-if="canGoWriteoff(row)" link type="primary" v-hasPermi="['customer:bill:writeoff']" @click="goWriteoff(row)">去核销</el-button>
<el-button v-if="canGoReverseWriteoff(row)" link type="warning" v-hasPermi="['customer:bill:writeoff:cancel']" @click="goReverseWriteoff(row)">反核销</el-button>
</template>
</basic-table>
@@ -150,7 +154,7 @@ const columns = [
{ label: '账单截止日', prop: 'billPeriodEnd', minWidth: 120, formatter: row => `截至 ${date(row.billPeriodEnd)}` }, { label: '订单数', prop: 'orderCount', width: 80 },
{ label: '应收总额', prop: 'totalAmount', width: 120, align: 'right', slot: 'totalAmount' }, { label: '已核销', prop: 'writtenOffAmount', width: 110, align: 'right', slot: 'writtenOffAmount' },
{ label: '未核销', prop: 'unwrittenAmount', width: 110, align: 'right', slot: 'unwrittenAmount' }, { label: '状态', prop: 'status', width: 110, slot: 'status' },
{ label: '账单日期', prop: 'billDate', width: 120, formatter: row => date(row.billDate) }, { label: '操作', prop: 'action', width: 330, fixed: 'right', slot: 'action', showInToolbar: false }
{ label: '账单日期', prop: 'billDate', width: 120, formatter: row => date(row.billDate) }, { label: '操作', prop: 'action', width: 380, fixed: 'right', slot: 'action', showInToolbar: false }
]
const searchColumns = [
{ label: '账单号', prop: 'billNo', component: 'input', placeholder: '账单号', width: '180px' }, { label: '账单名称', prop: 'billName', component: 'input', placeholder: '账单名称', width: '180px' }, { label: '客户名称', prop: 'customerId', component: 'input', placeholder: '请选择客户', width: '220px' },
@@ -158,7 +162,22 @@ const searchColumns = [
]
// 将页面日期范围转换为后端查询字段,其他筛选条件原样透传。
function queryList(params) { const query = { ...params }; if (query.billDateRange?.length === 2) { query.billDateStart = query.billDateRange[0]; query.billDateEnd = query.billDateRange[1] }; delete query.billDateRange; return listArBill(query) }
function normalizeBillQuery(params) {
const query = { ...params }
if (query.billDateRange?.length === 2) {
query.billDateStart = query.billDateRange[0]
query.billDateEnd = query.billDateRange[1]
}
delete query.billDateRange
return query
}
function queryList(params) { return listArBill(normalizeBillQuery(params)) }
function handleExport() {
const query = normalizeBillQuery(tableRef.value?.getQueryParams() || defaultSearchParams.value)
delete query.pageNum
delete query.pageSize
proxy.download('/ar/bill/export', query, `ar_bill_${Date.now()}.xlsx`)
}
// 生成弹窗只提交任务,账单明细由后台异步批量写入;这里负责刷新列表并开始轮询。
function handleGenerateSuccess(task) {
tableRef.value?.refresh()
@@ -392,8 +411,20 @@ function canGoWriteoff(row) {
|| row.status === AR_BILL_STATUS.PARTIAL_WRITTEN_OFF
return canWriteoffStatus && Number(row.unwrittenAmount) > 0
}
function canGoReverseWriteoff(row) {
if (!row?.customerId || !(Number(row.writtenOffAmount) > 0)) return false
return row.status === AR_BILL_STATUS.PARTIAL_WRITTEN_OFF
|| row.status === AR_BILL_STATUS.WRITTEN_OFF
}
function goWriteoff(row) {
if (!canGoWriteoff(row)) return
goCustomerBillWriteoff(row)
}
function goReverseWriteoff(row) {
if (!canGoReverseWriteoff(row)) return
goCustomerBillWriteoff(row)
}
function goCustomerBillWriteoff(row) {
router.push({
path: '/customersupplier/customer-money/index',
query: {
@@ -16,8 +16,24 @@
:border="true"
:max-height="560"
:page-size="10"
ref="tableRef"
row-key="arBillId"
>
<template #search-extra>
<el-button
type="warning"
icon="Download"
@click="handleExport"
v-hasPermi="['customersupplier:customerinfo:export']"
>导出</el-button>
</template>
<template #pagination-extra>
<div class="bill-summary">
<span>应收总额:<b class="amount">{{ money(billSummary.totalAmount) }}</b></span>
<span>已核销:<b class="written">{{ money(billSummary.writtenOffAmount) }}</b></span>
<span>未核销:<b class="unwritten">{{ money(billSummary.unwrittenAmount) }}</b></span>
</div>
</template>
<template #col-status="{ row }">
<el-tag :type="statusType(row.status)">{{ statusText(row.status) }}</el-tag>
</template>
@@ -38,7 +54,7 @@
</template>
<script setup>
import { computed } from 'vue'
import { computed, getCurrentInstance, ref } from 'vue'
import { listCustomerBills } from '@/api/customersuppliermanagement/customermoney/customerbill'
import { AR_BILL_STATUS_OPTIONS, AR_BILL_STATUS_TYPES } from '@/constants/ar/bill'
import { arEnumLabel } from '@/constants/ar/enums'
@@ -48,6 +64,7 @@ const props = defineProps({
customerId: { type: [String, Number], required: true },
customerName: { type: String, default: '' }
})
const { proxy } = getCurrentInstance()
const emit = defineEmits(['update:modelValue'])
const visible = computed({
@@ -58,6 +75,9 @@ const dialogTitle = computed(() => props.customerName ? `客户账单 - ${props.
// BasicTable merges these fixed parameters after search and pagination state.
const fixedParams = computed(() => ({ customerId: Number(props.customerId) }))
const tableRef = ref()
const billSummary = ref({ totalAmount: 0, writtenOffAmount: 0, unwrittenAmount: 0 })
let querySerial = 0
const statusOptions = AR_BILL_STATUS_OPTIONS
const columns = [
{ label: '账单号', prop: 'billNo', minWidth: 180, showOverflowTooltip: true },
@@ -81,6 +101,28 @@ const searchColumns = [
]
function queryBills(params) {
const query = normalizeBillQuery(params)
const serial = ++querySerial
return listCustomerBills(props.customerId, query).then(response => {
if (serial === querySerial) {
billSummary.value = response.summary || { totalAmount: 0, writtenOffAmount: 0, unwrittenAmount: 0 }
}
return response
})
}
function handleExport() {
const query = normalizeBillQuery(tableRef.value?.getQueryParams() || {})
delete query.pageNum
delete query.pageSize
proxy.download(
`/customersupplier/customerbill/export/${props.customerId}`,
query,
`客户账单_${props.customerId}_${Date.now()}.xlsx`
)
}
function normalizeBillQuery(params) {
const query = { ...params }
const range = query.billDateRange
if (Array.isArray(range) && range.length === 2) {
@@ -90,7 +132,7 @@ function queryBills(params) {
delete query.billDateRange
// The route parameter is authoritative; the customer ID cannot be changed by search/reset.
delete query.customerId
return listCustomerBills(props.customerId, query)
return query
}
function date(value) { return value ? String(value).slice(0, 10) : '-' }
@@ -103,6 +145,14 @@ function statusType(value) { return AR_BILL_STATUS_TYPES[value] || 'info' }
</script>
<style scoped>
.bill-summary {
display: flex;
flex-wrap: wrap;
gap: 8px 20px;
color: var(--el-text-color-regular);
font-size: 13px;
}
.bill-summary b { font-weight: 600; }
.amount { color: #f56c6c; font-weight: 600; }
.written { color: var(--el-color-success); }
.unwritten { color: var(--el-color-warning); }