收票单推送金蝶与票池实时游标分页前端适配:选票弹窗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
+2 -5
View File
@@ -7,8 +7,6 @@ export const getList = (current, size, params) =>
export const getDetail = id => request({ url: `${baseUrl}/detail`, method: 'get', params: { id } }); export const getDetail = id => request({ url: `${baseUrl}/detail`, method: 'get', params: { id } });
export const queryInvoicePool = params => export const queryInvoicePool = params =>
request({ url: `${baseUrl}/invoice-pool`, method: 'get', params }); request({ url: `${baseUrl}/invoice-pool`, method: 'get', params });
export const fetchInvoicePoolByNo = invoiceNo =>
request({ url: `${baseUrl}/invoice-pool/fetch`, method: 'post', params: { invoiceNo } });
export const getSettlementCandidates = (keyword, receiptId) => export const getSettlementCandidates = (keyword, receiptId) =>
request({ request({
url: `${baseUrl}/settlement-candidates`, url: `${baseUrl}/settlement-candidates`,
@@ -29,9 +27,8 @@ export const returnBill = data => request({ url: `${baseUrl}/return`, method: 'p
export const voidBill = data => request({ url: `${baseUrl}/void`, method: 'post', data }); export const voidBill = data => request({ url: `${baseUrl}/void`, method: 'post', data });
export const syncKingdee = id => export const syncKingdee = id =>
request({ url: `${baseUrl}/sync-kingdee`, method: 'post', params: { id } }); request({ url: `${baseUrl}/sync-kingdee`, method: 'post', params: { id } });
// 手动同步为分钟级长任务,单独放宽超时(全局默认 10s 必超时) export const pushKingdee = ids =>
export const syncInvoicePool = () => request({ url: `${baseUrl}/push-kingdee`, method: 'post', data: ids });
request({ url: `${baseUrl}/sync-invoice-pool`, method: 'post', timeout: 300000 });
export const approvalStatusOptions = [ export const approvalStatusOptions = [
{ label: '草稿', value: 'draft' }, { label: '草稿', value: 'draft' },
-2
View File
@@ -50,5 +50,3 @@ export const claimInvoices = data =>
request({ url: `${baseUrl}/claim-invoices`, method: 'post', data }); request({ url: `${baseUrl}/claim-invoices`, method: 'post', data });
export const queryInvoicePool = params => export const queryInvoicePool = params =>
request({ url: `${baseUrl}/invoice-pool`, method: 'get', params }); request({ url: `${baseUrl}/invoice-pool`, method: 'get', params });
export const fetchInvoicePoolByNo = invoiceNo =>
request({ url: `${baseUrl}/invoice-pool/fetch`, method: 'post', params: { invoiceNo } });
@@ -1,15 +1,5 @@
<template> <template>
<el-dialog <el-dialog v-model="visible" :title="title" width="92%" append-to-body destroy-on-close @open="handleOpen">
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-form :model="query" inline label-width="90px" @submit.prevent> <el-form :model="query" inline label-width="90px" @submit.prevent>
<el-form-item label="发票号码"> <el-form-item label="发票号码">
<el-input v-model="query.invoiceNo" clearable @keyup.enter="handleQuery" /> <el-input v-model="query.invoiceNo" clearable @keyup.enter="handleQuery" />
@@ -24,11 +14,21 @@
end-placeholder="结束日期" end-placeholder="结束日期"
/> />
</el-form-item> </el-form-item>
<el-form-item label="开票单位"> <el-form-item label="销方税号">
<el-input v-model="query.salerName" clearable @keyup.enter="handleQuery" /> <el-input
v-model="query.salerTaxNo"
clearable
style="width: 180px"
@keyup.enter="handleQuery"
/>
</el-form-item> </el-form-item>
<el-form-item label="受票单位"> <el-form-item label="购方税号">
<el-input v-model="query.buyerName" clearable @keyup.enter="handleQuery" /> <el-input
v-model="query.buyerTaxNo"
clearable
style="width: 180px"
@keyup.enter="handleQuery"
/>
</el-form-item> </el-form-item>
<el-form-item label="发票类型"> <el-form-item label="发票类型">
<el-select <el-select
@@ -38,32 +38,34 @@
placeholder="不限" placeholder="不限"
style="width: 230px" 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-select>
</el-form-item> </el-form-item>
<el-form-item label="认领状态"> <el-form-item label="单据使用状态">
<el-select v-model="query.claimed" clearable placeholder="不限" style="width: 130px"> <el-select v-model="query.expenseStatus" clearable placeholder="不限" style="width: 130px">
<el-option label="未认领" :value="false" /> <el-option
<el-option label="已认领" :value="true" /> v-for="option in expenseStatusOptions"
</el-select> :key="option.value"
</el-form-item> :label="option.label"
<el-form-item label="登记状态"> :value="option.value"
<el-select v-model="query.registered" clearable placeholder="不限" style="width: 130px"> />
<el-option label="未登记" :value="false" />
<el-option label="已登记" :value="true" />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button @click="resetQuery">重置</el-button> <el-button :disabled="loading" @click="resetQuery">重置</el-button>
<el-button type="primary" @click="handleQuery">查询</el-button> <el-button type="primary" :disabled="loading" @click="handleQuery">查询</el-button>
<el-button v-if="syncApi" :loading="syncing" @click="handleSync">立即同步</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
<el-table <el-table
ref="poolTable" ref="poolTable"
v-loading="loading" v-loading="loading"
:data="rows" :data="rows"
row-key="id" :row-key="rowKey"
border border
height="520" height="520"
:highlight-current-row="!multiple" :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-if="multiple" type="selection" width="52" fixed="left" align="center" reserve-selection />
<el-table-column v-else width="52" align="center" fixed="left"> <el-table-column v-else width="52" align="center" fixed="left">
<template #default="{ row }"> <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> <span></span>
</el-radio> </el-radio>
</template> </template>
@@ -105,35 +111,19 @@
<el-tag v-else type="info" size="small">未登记</el-tag> <el-tag v-else type="info" size="small">未登记</el-tag>
</template> </template>
</el-table-column> </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"> <el-table-column v-if="!multiple" label="操作" width="90" fixed="right" align="center">
<template #default="{ row }"> <template #default="{ row }">
<el-link type="primary" @click.stop="confirmRows([row])">选择</el-link> <el-link type="primary" @click.stop="confirmRows([row])">选择</el-link>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<div class="kingdee-pool-dialog__footer-bar"> <div class="kingdee-pool-dialog__pager">
<div class="kingdee-pool-dialog__fetch"> <span class="kingdee-pool-dialog__pager-info">第 {{ page.current }} 页</span>
<el-input <el-button :disabled="page.current <= 1 || loading" @click="prevPage">上一页</el-button>
v-model="fetchNo" <el-button :disabled="!page.hasMore || loading" @click="nextPage">下一页</el-button>
placeholder="查不到票输入发票号码从金蝶补查" <el-select v-model="page.size" style="width: 110px" @change="handleSizeChange">
clearable <el-option v-for="n in [10, 20, 50, 100]" :key="n" :label="`${n}条/页`" :value="n" />
style="width: 260px" </el-select>
@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> </div>
<template #footer> <template #footer>
<el-button @click="visible = false">取消</el-button> <el-button @click="visible = false">取消</el-button>
@@ -143,8 +133,6 @@
</template> </template>
<script> <script>
import { ElLoading } from 'element-plus';
export default { export default {
name: 'KingdeeInvoicePoolDialog', name: 'KingdeeInvoicePoolDialog',
props: { props: {
@@ -154,55 +142,27 @@ export default {
multiple: { type: Boolean, default: false }, multiple: { type: Boolean, default: false },
initialInvoiceNo: { type: String, default: '' }, initialInvoiceNo: { type: String, default: '' },
queryApi: { type: Function, required: true }, queryApi: { type: Function, required: true },
fetchApi: { type: Function, required: true },
syncApi: { type: Function, default: null },
}, },
emits: ['update:modelValue', 'confirm'], emits: ['update:modelValue', 'confirm'],
data() { data() {
return { return {
loading: false, loading: false,
fetching: false, // 与后端 BfiConstant.INVOICE_TYPE_NAMES 对齐:value 为发票类型编码,label 为中文名
syncing: false, // 选票场景只开放数电票(普票/专票)
// 与后端 BfiConstant.INVOICE_TYPE_NAMES 中文名对齐(镜像落库即中文名)
invoiceTypeOptions: [ invoiceTypeOptions: [
'增值税电子普通发票', { value: '26', label: '数电发票(普通发票)' },
'增值税电子专用发票', { value: '27', label: '数电发票(增值税专用发票' },
'增值税普通发票', ],
'增值税专用发票', expenseStatusOptions: [
'增值税普通发票(卷票)', { value: '1', label: '未用' },
'通用机打发票', { value: '30', label: '在用' },
'出租车票', { value: '60', label: '已用' },
'火车票', { value: '65', label: '已入账' },
'飞机票',
'其他票',
'机动车销售统一发票',
'二手车销售统一发票',
'定额发票',
'增值税电子普通发票(通行费)',
'汽车票',
'过路(过桥)费发票',
'税收完税证明',
'轮船票',
'海关缴款书',
'通用机打电子发票',
'火车票退票凭证',
'财政电子票据',
'数电发票(普通发票)',
'数电发票(增值税专用发票)',
'数电发票(航空运输电子客票行程单)',
'数电发票(铁路电子客票)',
'海外发票',
'海外收据',
'增值税代扣代缴完税凭证',
'数电发票(通行费发票)',
'数电发票(机动车销售统一发票)',
'数电发票(二手车销售统一发票)',
], ],
rows: [], rows: [],
selected: [], selected: [],
current: null, current: null,
fetchNo: '', page: { current: 1, size: 10, hasMore: false },
page: { current: 1, size: 10, total: 0 },
query: this.emptyQuery(), query: this.emptyQuery(),
}; };
}, },
@@ -220,14 +180,19 @@ export default {
emptyQuery() { emptyQuery() {
return { return {
invoiceNo: '', invoiceNo: '',
invoiceDateRange: [], // 默认查近一个月,随请求传后端并在页面回显
salerName: '', invoiceDateRange: [this.$dayjs().subtract(1, 'month').format('YYYY-MM-DD'), this.$dayjs().format('YYYY-MM-DD')],
buyerName: '', salerTaxNo: '',
buyerTaxNo: '',
invoiceType: '', invoiceType: '',
claimed: null, // 单据使用状态默认"未用"
registered: null, expenseStatus: '1',
}; };
}, },
// 远程实时查询的票未入本地镜像,id 恒空,用发票号码兜底作为行主键
rowKey(row) {
return row.invoiceNo || row.id;
},
handleOpen() { handleOpen() {
this.query = this.emptyQuery(); this.query = this.emptyQuery();
this.query.invoiceNo = this.initialInvoiceNo || ''; this.query.invoiceNo = this.initialInvoiceNo || '';
@@ -245,6 +210,14 @@ export default {
this.page.current = 1; this.page.current = 1;
this.load(); this.load();
}, },
prevPage() {
this.page.current -= 1;
this.load();
},
nextPage() {
this.page.current += 1;
this.load();
},
resetQuery() { resetQuery() {
this.query = this.emptyQuery(); this.query = this.emptyQuery();
this.handleQuery(); this.handleQuery();
@@ -255,6 +228,8 @@ export default {
}, },
async load() { async load() {
this.loading = true; this.loading = true;
// 请求前快照页码:prev/next 会先改写 current,远程失败时回滚避免停留在错页
const lastRequested = this.page.current;
try { try {
const range = this.query.invoiceDateRange || []; const range = this.query.invoiceDateRange || [];
const data = this.unwrap( const data = this.unwrap(
@@ -264,15 +239,19 @@ export default {
invoiceNo: this.query.invoiceNo || undefined, invoiceNo: this.query.invoiceNo || undefined,
invoiceDateStart: range[0] || undefined, invoiceDateStart: range[0] || undefined,
invoiceDateEnd: range[1] || undefined, invoiceDateEnd: range[1] || undefined,
salerName: this.query.salerName || undefined, salerTaxNo: this.query.salerTaxNo || undefined,
buyerName: this.query.buyerName || undefined, buyerTaxNo: this.query.buyerTaxNo || undefined,
invoiceType: this.query.invoiceType || undefined, invoiceType: this.query.invoiceType || undefined,
claimed: this.query.claimed ?? undefined, expenseStatus: this.query.expenseStatus || undefined,
registered: this.query.registered ?? undefined,
}) })
); );
this.rows = data.records || []; 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 { } finally {
this.loading = false; this.loading = false;
} }
@@ -294,52 +273,10 @@ export default {
this.$emit('confirm', rows); this.$emit('confirm', rows);
this.visible = false; 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) { formatMoney(value) {
const number = Number(value); const number = Number(value);
return Number.isFinite(number) ? number.toFixed(2) : '-'; return Number.isFinite(number) ? number.toFixed(2) : '-';
}, },
kingdeeStatusText(value) {
const statusMap = {
unsynced: '未同步',
synced: '已同步',
failed: '同步失败',
};
return statusMap[value] || value || '-';
},
formatRate(value) { formatRate(value) {
const number = Number(value); const number = Number(value);
return Number.isFinite(number) ? `${number}%` : '-'; return Number.isFinite(number) ? `${number}%` : '-';
@@ -349,16 +286,11 @@ export default {
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.kingdee-pool-dialog__footer-bar { .kingdee-pool-dialog__pager {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; gap: 12px;
justify-content: flex-end;
margin-top: 12px; margin-top: 12px;
gap: 16px;
}
.kingdee-pool-dialog__fetch {
display: flex;
align-items: center;
gap: 8px;
} }
</style> </style>
+12 -16
View File
@@ -47,7 +47,7 @@
<el-col :span="6"> <el-col :span="6">
<el-form-item label="开票金额"> <el-form-item label="开票金额">
<el-input <el-input
:model-value="form.kingdeeInvoicePoolId ? formatMoney(form.invoiceAmount) : ''" :model-value="form.invoiceNo ? formatMoney(form.invoiceAmount) : ''"
disabled disabled
placeholder="从金蝶票据池带出" placeholder="从金蝶票据池带出"
/> />
@@ -56,7 +56,7 @@
<el-col :span="6"> <el-col :span="6">
<el-form-item label="税额"> <el-form-item label="税额">
<el-input <el-input
:model-value="form.kingdeeInvoicePoolId ? formatMoney(form.taxAmount) : ''" :model-value="form.invoiceNo ? formatMoney(form.taxAmount) : ''"
disabled disabled
placeholder="从金蝶票据池带出" placeholder="从金蝶票据池带出"
/> />
@@ -154,8 +154,6 @@
title="查询金蝶票据池" title="查询金蝶票据池"
:initial-invoice-no="form.invoiceNo" :initial-invoice-no="form.invoiceNo"
:query-api="apiQueryInvoicePool" :query-api="apiQueryInvoicePool"
:fetch-api="apiFetchInvoicePool"
:sync-api="apiSyncInvoicePool"
@confirm="handleInvoicePicked" @confirm="handleInvoicePicked"
/> />
@@ -217,7 +215,6 @@ import VehicleAttachmentTable from '@/components/vehicle-attachment-table/main.v
const emptyForm = () => ({ const emptyForm = () => ({
id: null, id: null,
kingdeeInvoicePoolId: null,
invoiceNo: '', invoiceNo: '',
invoiceDate: '', invoiceDate: '',
invoiceType: '', invoiceType: '',
@@ -302,12 +299,6 @@ export default {
apiQueryInvoicePool(params) { apiQueryInvoicePool(params) {
return api.queryInvoicePool(params); return api.queryInvoicePool(params);
}, },
apiFetchInvoicePool(invoiceNo) {
return api.fetchInvoicePoolByNo(invoiceNo);
},
apiSyncInvoicePool() {
return api.syncInvoicePool();
},
handleInvoicePicked(rows) { handleInvoicePicked(rows) {
this.confirmInvoice(rows[0]); this.confirmInvoice(rows[0]);
}, },
@@ -356,7 +347,7 @@ export default {
if (this.settlementIds.length) await this.loadReferenceInformation(); if (this.settlementIds.length) await this.loadReferenceInformation();
}, },
validateInvoice(rule, value, callback) { validateInvoice(rule, value, callback) {
if (!value || !this.form.kingdeeInvoicePoolId) { if (!value) {
callback(new Error('请选择金蝶票据池发票')); callback(new Error('请选择金蝶票据池发票'));
return; return;
} }
@@ -393,7 +384,6 @@ export default {
} }
const preserveUserInput = options.preserveUserInput === true; const preserveUserInput = options.preserveUserInput === true;
Object.assign(this.form, { Object.assign(this.form, {
kingdeeInvoicePoolId: selected.id,
invoiceNo: selected.invoiceNo, invoiceNo: selected.invoiceNo,
invoiceDate: selected.invoiceDate, invoiceDate: selected.invoiceDate,
invoiceType: selected.invoiceType, invoiceType: selected.invoiceType,
@@ -517,7 +507,6 @@ export default {
payload() { payload() {
return { return {
id: this.form.id, id: this.form.id,
kingdeeInvoicePoolId: this.form.kingdeeInvoicePoolId,
invoiceNo: this.form.invoiceNo, invoiceNo: this.form.invoiceNo,
invoiceDate: this.form.invoiceDate, invoiceDate: this.form.invoiceDate,
invoiceType: this.form.invoiceType, invoiceType: this.form.invoiceType,
@@ -567,8 +556,15 @@ export default {
this.$message.warning('请先选择金蝶票据池发票'); this.$message.warning('请先选择金蝶票据池发票');
return; return;
} }
const invoice = this.unwrapData(await api.fetchInvoicePoolByNo(this.form.invoiceNo)); const data = this.unwrapData(
if (!invoice || !this.confirmInvoice(invoice, { preserveUserInput: true })) return; await api.queryInvoicePool({ current: 1, size: 1, invoiceNo: this.form.invoiceNo })
);
const invoice = (data.records || []).find(item => item.invoiceNo === this.form.invoiceNo);
if (!invoice) {
this.$message.warning('金蝶票池未查询到该发票');
return;
}
if (!this.confirmInvoice(invoice, { preserveUserInput: true })) return;
if (this.settlementIds.length) await this.loadReferenceInformation(); if (this.settlementIds.length) await this.loadReferenceInformation();
this.$message.success('同步成功'); this.$message.success('同步成功');
}, },
+20
View File
@@ -73,6 +73,13 @@
@click="handleBatchSync" @click="handleBatchSync"
>批量同步</el-button >批量同步</el-button
> >
<el-button
v-if="hasPermission('invoice_receipt_sync')"
type="primary"
plain
@click="handlePushKingdee"
>推送金蝶收票单</el-button
>
<el-button v-if="hasPermission('invoice_receipt_add')" type="primary" @click="openCreate" <el-button v-if="hasPermission('invoice_receipt_add')" type="primary" @click="openCreate"
>新增</el-button >新增</el-button
> >
@@ -373,6 +380,19 @@ export default {
this.$message.success(`已同步${rows.length}条收票登记`); this.$message.success(`已同步${rows.length}条收票登记`);
this.loadTable(); this.loadTable();
}, },
async handlePushKingdee() {
const rows = this.selection.filter(row => row.approvalStatus === 'approved');
if (!rows.length) {
this.$message.warning('请选择至少一条审批通过的收票登记');
return;
}
await this.$confirm(`确认将选中的 ${rows.length} 条收票登记推送金蝶收票单?`, '提示', {
type: 'warning',
});
const summary = this.unwrapData(await api.pushKingdee(rows.map(row => row.id)));
this.$alert(summary || '推送完成', '推送结果', { confirmButtonText: '知道了' });
this.loadTable();
},
async handleExport() { async handleExport() {
const data = this.unwrapData(await api.getList(1, 100000, this.query)); const data = this.unwrapData(await api.getList(1, 100000, this.query));
const exportRows = (data.records || []).map(item => ({ const exportRows = (data.records || []).map(item => ({
@@ -419,7 +419,6 @@
multiple multiple
:initial-invoice-no="String(invoiceClaimNo || '').trim()" :initial-invoice-no="String(invoiceClaimNo || '').trim()"
:query-api="invoicePoolQueryApi" :query-api="invoicePoolQueryApi"
:fetch-api="invoicePoolFetchApi"
@confirm="handleInvoiceClaimConfirm" @confirm="handleInvoiceClaimConfirm"
/> />
@@ -892,7 +891,6 @@ import {
getReceiptClaims, getReceiptClaims,
claimInvoices as claimInvoicesApi, claimInvoices as claimInvoicesApi,
queryInvoicePool, queryInvoicePool,
fetchInvoicePoolByNo,
save, save,
} from '@/api/settlement/formalSettlement'; } from '@/api/settlement/formalSettlement';
import { import {
@@ -2173,9 +2171,6 @@ export default {
invoicePoolQueryApi(params) { invoicePoolQueryApi(params) {
return queryInvoicePool(params); return queryInvoicePool(params);
}, },
invoicePoolFetchApi(invoiceNo) {
return fetchInvoicePoolByNo(invoiceNo);
},
async handleInvoiceClaimConfirm(rows) { async handleInvoiceClaimConfirm(rows) {
// 统一票池行附件字段为复数 attachmentsJson,认领请求契约是单数 attachmentJson,中转处归一 // 统一票池行附件字段为复数 attachmentsJson,认领请求契约是单数 attachmentJson,中转处归一
this.invoiceClaimDialog.selected = rows.map(row => ({ this.invoiceClaimDialog.selected = rows.map(row => ({