收票单推送金蝶与票池实时游标分页前端适配:选票弹窗hasMore分页,下线镜像补查与票池同步入口,保存时按票号重查回填

This commit is contained in:
刘泉佳
2026-09-23 10:22:51 +08:00
parent cc73d544ff
commit 884de893db
6 changed files with 121 additions and 183 deletions
@@ -1,15 +1,5 @@
<template>
<el-dialog
v-model="visible"
:title="title"
width="92%"
append-to-body
destroy-on-close
:show-close="!syncing"
:close-on-click-modal="!syncing"
:close-on-press-escape="!syncing"
@open="handleOpen"
>
<el-dialog v-model="visible" :title="title" width="92%" append-to-body destroy-on-close @open="handleOpen">
<el-form :model="query" inline label-width="90px" @submit.prevent>
<el-form-item label="发票号码">
<el-input v-model="query.invoiceNo" clearable @keyup.enter="handleQuery" />
@@ -24,11 +14,21 @@
end-placeholder="结束日期"
/>
</el-form-item>
<el-form-item label="开票单位">
<el-input v-model="query.salerName" clearable @keyup.enter="handleQuery" />
<el-form-item label="销方税号">
<el-input
v-model="query.salerTaxNo"
clearable
style="width: 180px"
@keyup.enter="handleQuery"
/>
</el-form-item>
<el-form-item label="受票单位">
<el-input v-model="query.buyerName" clearable @keyup.enter="handleQuery" />
<el-form-item label="购方税号">
<el-input
v-model="query.buyerTaxNo"
clearable
style="width: 180px"
@keyup.enter="handleQuery"
/>
</el-form-item>
<el-form-item label="发票类型">
<el-select
@@ -38,32 +38,34 @@
placeholder="不限"
style="width: 230px"
>
<el-option v-for="type in invoiceTypeOptions" :key="type" :label="type" :value="type" />
<el-option
v-for="option in invoiceTypeOptions"
:key="option.value"
:label="option.label"
:value="option.value"
/>
</el-select>
</el-form-item>
<el-form-item label="认领状态">
<el-select v-model="query.claimed" clearable placeholder="不限" style="width: 130px">
<el-option label="未认领" :value="false" />
<el-option label="已认领" :value="true" />
</el-select>
</el-form-item>
<el-form-item label="登记状态">
<el-select v-model="query.registered" clearable placeholder="不限" style="width: 130px">
<el-option label="未登记" :value="false" />
<el-option label="已登记" :value="true" />
<el-form-item label="单据使用状态">
<el-select v-model="query.expenseStatus" clearable placeholder="不限" style="width: 130px">
<el-option
v-for="option in expenseStatusOptions"
:key="option.value"
:label="option.label"
:value="option.value"
/>
</el-select>
</el-form-item>
<el-form-item>
<el-button @click="resetQuery">重置</el-button>
<el-button type="primary" @click="handleQuery">查询</el-button>
<el-button v-if="syncApi" :loading="syncing" @click="handleSync">立即同步</el-button>
<el-button :disabled="loading" @click="resetQuery">重置</el-button>
<el-button type="primary" :disabled="loading" @click="handleQuery">查询</el-button>
</el-form-item>
</el-form>
<el-table
ref="poolTable"
v-loading="loading"
:data="rows"
row-key="id"
:row-key="rowKey"
border
height="520"
:highlight-current-row="!multiple"
@@ -73,7 +75,11 @@
<el-table-column v-if="multiple" type="selection" width="52" fixed="left" align="center" reserve-selection />
<el-table-column v-else width="52" align="center" fixed="left">
<template #default="{ row }">
<el-radio :model-value="current && current.id" :value="row.id" @change="current = row">
<el-radio
:model-value="current && current.invoiceNo"
:value="row.invoiceNo"
@change="current = row"
>
<span></span>
</el-radio>
</template>
@@ -105,35 +111,19 @@
<el-tag v-else type="info" size="small">未登记</el-tag>
</template>
</el-table-column>
<el-table-column label="金蝶同步" min-width="100" align="center">
<template #default="{ row }">{{ kingdeeStatusText(row.kingdeeStatus) }}</template>
</el-table-column>
<el-table-column v-if="!multiple" label="操作" width="90" fixed="right" align="center">
<template #default="{ row }">
<el-link type="primary" @click.stop="confirmRows([row])">选择</el-link>
</template>
</el-table-column>
</el-table>
<div class="kingdee-pool-dialog__footer-bar">
<div class="kingdee-pool-dialog__fetch">
<el-input
v-model="fetchNo"
placeholder="查不到票输入发票号码从金蝶补查"
clearable
style="width: 260px"
@keyup.enter="handleFetch"
/>
<el-button :loading="fetching" @click="handleFetch">补查</el-button>
</div>
<el-pagination
v-model:current-page="page.current"
v-model:page-size="page.size"
:total="page.total"
:page-sizes="[10, 20, 50, 100]"
layout="total, sizes, prev, pager, next, jumper"
@current-change="load"
@size-change="handleSizeChange"
/>
<div class="kingdee-pool-dialog__pager">
<span class="kingdee-pool-dialog__pager-info">第 {{ page.current }} 页</span>
<el-button :disabled="page.current <= 1 || loading" @click="prevPage">上一页</el-button>
<el-button :disabled="!page.hasMore || loading" @click="nextPage">下一页</el-button>
<el-select v-model="page.size" style="width: 110px" @change="handleSizeChange">
<el-option v-for="n in [10, 20, 50, 100]" :key="n" :label="`${n}条/页`" :value="n" />
</el-select>
</div>
<template #footer>
<el-button @click="visible = false">取消</el-button>
@@ -143,8 +133,6 @@
</template>
<script>
import { ElLoading } from 'element-plus';
export default {
name: 'KingdeeInvoicePoolDialog',
props: {
@@ -154,55 +142,27 @@ export default {
multiple: { type: Boolean, default: false },
initialInvoiceNo: { type: String, default: '' },
queryApi: { type: Function, required: true },
fetchApi: { type: Function, required: true },
syncApi: { type: Function, default: null },
},
emits: ['update:modelValue', 'confirm'],
data() {
return {
loading: false,
fetching: false,
syncing: false,
// 与后端 BfiConstant.INVOICE_TYPE_NAMES 中文名对齐(镜像落库即中文名)
// 与后端 BfiConstant.INVOICE_TYPE_NAMES 对齐:value 为发票类型编码,label 为中文名
// 选票场景只开放数电票(普票/专票)
invoiceTypeOptions: [
'增值税电子普通发票',
'增值税电子专用发票',
'增值税普通发票',
'增值税专用发票',
'增值税普通发票(卷票)',
'通用机打发票',
'出租车票',
'火车票',
'飞机票',
'其他票',
'机动车销售统一发票',
'二手车销售统一发票',
'定额发票',
'增值税电子普通发票(通行费)',
'汽车票',
'过路(过桥)费发票',
'税收完税证明',
'轮船票',
'海关缴款书',
'通用机打电子发票',
'火车票退票凭证',
'财政电子票据',
'数电发票(普通发票)',
'数电发票(增值税专用发票)',
'数电发票(航空运输电子客票行程单)',
'数电发票(铁路电子客票)',
'海外发票',
'海外收据',
'增值税代扣代缴完税凭证',
'数电发票(通行费发票)',
'数电发票(机动车销售统一发票)',
'数电发票(二手车销售统一发票)',
{ value: '26', label: '数电发票(普通发票)' },
{ value: '27', label: '数电发票(增值税专用发票' },
],
expenseStatusOptions: [
{ value: '1', label: '未用' },
{ value: '30', label: '在用' },
{ value: '60', label: '已用' },
{ value: '65', label: '已入账' },
],
rows: [],
selected: [],
current: null,
fetchNo: '',
page: { current: 1, size: 10, total: 0 },
page: { current: 1, size: 10, hasMore: false },
query: this.emptyQuery(),
};
},
@@ -220,14 +180,19 @@ export default {
emptyQuery() {
return {
invoiceNo: '',
invoiceDateRange: [],
salerName: '',
buyerName: '',
// 默认查近一个月,随请求传后端并在页面回显
invoiceDateRange: [this.$dayjs().subtract(1, 'month').format('YYYY-MM-DD'), this.$dayjs().format('YYYY-MM-DD')],
salerTaxNo: '',
buyerTaxNo: '',
invoiceType: '',
claimed: null,
registered: null,
// 单据使用状态默认"未用"
expenseStatus: '1',
};
},
// 远程实时查询的票未入本地镜像,id 恒空,用发票号码兜底作为行主键
rowKey(row) {
return row.invoiceNo || row.id;
},
handleOpen() {
this.query = this.emptyQuery();
this.query.invoiceNo = this.initialInvoiceNo || '';
@@ -245,6 +210,14 @@ export default {
this.page.current = 1;
this.load();
},
prevPage() {
this.page.current -= 1;
this.load();
},
nextPage() {
this.page.current += 1;
this.load();
},
resetQuery() {
this.query = this.emptyQuery();
this.handleQuery();
@@ -255,6 +228,8 @@ export default {
},
async load() {
this.loading = true;
// 请求前快照页码:prev/next 会先改写 current,远程失败时回滚避免停留在错页
const lastRequested = this.page.current;
try {
const range = this.query.invoiceDateRange || [];
const data = this.unwrap(
@@ -264,15 +239,19 @@ export default {
invoiceNo: this.query.invoiceNo || undefined,
invoiceDateStart: range[0] || undefined,
invoiceDateEnd: range[1] || undefined,
salerName: this.query.salerName || undefined,
buyerName: this.query.buyerName || undefined,
salerTaxNo: this.query.salerTaxNo || undefined,
buyerTaxNo: this.query.buyerTaxNo || undefined,
invoiceType: this.query.invoiceType || undefined,
claimed: this.query.claimed ?? undefined,
registered: this.query.registered ?? undefined,
expenseStatus: this.query.expenseStatus || undefined,
})
);
this.rows = data.records || [];
this.page.total = Number(data.total || 0);
this.page.hasMore = !!data.hasMore;
} catch (error) {
if (this.page.current !== lastRequested) {
this.page.current = lastRequested;
}
throw error;
} finally {
this.loading = false;
}
@@ -294,52 +273,10 @@ export default {
this.$emit('confirm', rows);
this.visible = false;
},
async handleFetch() {
const invoiceNo = String(this.fetchNo || '').trim();
if (!invoiceNo) {
this.$message.warning('请输入发票号码');
return;
}
this.fetching = true;
try {
await this.fetchApi(invoiceNo);
this.$message.success('补查成功,已刷新列表');
this.page.current = 1;
await this.load();
} finally {
this.fetching = false;
}
},
async handleSync() {
this.syncing = true;
// 全量同步为服务端分钟级同步接口(per-request 超时 300s),全程遮罩提示并锁定弹窗防误关
const loading = ElLoading.service({
lock: true,
text: '正在从金蝶全票池同步发票,预计 1~3 分钟,请勿关闭窗口…',
background: 'rgba(0, 0, 0, 0.5)',
});
try {
const summary = this.unwrap(await this.syncApi());
this.$message.success(String(summary) || '同步完成');
this.page.current = 1;
await this.load();
} finally {
loading.close();
this.syncing = false;
}
},
formatMoney(value) {
const number = Number(value);
return Number.isFinite(number) ? number.toFixed(2) : '-';
},
kingdeeStatusText(value) {
const statusMap = {
unsynced: '未同步',
synced: '已同步',
failed: '同步失败',
};
return statusMap[value] || value || '-';
},
formatRate(value) {
const number = Number(value);
return Number.isFinite(number) ? `${number}%` : '-';
@@ -349,16 +286,11 @@ export default {
</script>
<style lang="scss" scoped>
.kingdee-pool-dialog__footer-bar {
.kingdee-pool-dialog__pager {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
justify-content: flex-end;
margin-top: 12px;
gap: 16px;
}
.kingdee-pool-dialog__fetch {
display: flex;
align-items: center;
gap: 8px;
}
</style>