收票单推送金蝶与票池实时游标分页前端适配:选票弹窗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 queryInvoicePool = 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) =>
request({
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 syncKingdee = id =>
request({ url: `${baseUrl}/sync-kingdee`, method: 'post', params: { id } });
// 手动同步为分钟级长任务,单独放宽超时(全局默认 10s 必超时)
export const syncInvoicePool = () =>
request({ url: `${baseUrl}/sync-invoice-pool`, method: 'post', timeout: 300000 });
export const pushKingdee = ids =>
request({ url: `${baseUrl}/push-kingdee`, method: 'post', data: ids });
export const approvalStatusOptions = [
{ label: '草稿', value: 'draft' },
-2
View File
@@ -50,5 +50,3 @@ export const claimInvoices = data =>
request({ url: `${baseUrl}/claim-invoices`, method: 'post', data });
export const queryInvoicePool = 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>
<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>
+12 -16
View File
@@ -47,7 +47,7 @@
<el-col :span="6">
<el-form-item label="开票金额">
<el-input
:model-value="form.kingdeeInvoicePoolId ? formatMoney(form.invoiceAmount) : ''"
:model-value="form.invoiceNo ? formatMoney(form.invoiceAmount) : ''"
disabled
placeholder="从金蝶票据池带出"
/>
@@ -56,7 +56,7 @@
<el-col :span="6">
<el-form-item label="税额">
<el-input
:model-value="form.kingdeeInvoicePoolId ? formatMoney(form.taxAmount) : ''"
:model-value="form.invoiceNo ? formatMoney(form.taxAmount) : ''"
disabled
placeholder="从金蝶票据池带出"
/>
@@ -154,8 +154,6 @@
title="查询金蝶票据池"
:initial-invoice-no="form.invoiceNo"
:query-api="apiQueryInvoicePool"
:fetch-api="apiFetchInvoicePool"
:sync-api="apiSyncInvoicePool"
@confirm="handleInvoicePicked"
/>
@@ -217,7 +215,6 @@ import VehicleAttachmentTable from '@/components/vehicle-attachment-table/main.v
const emptyForm = () => ({
id: null,
kingdeeInvoicePoolId: null,
invoiceNo: '',
invoiceDate: '',
invoiceType: '',
@@ -302,12 +299,6 @@ export default {
apiQueryInvoicePool(params) {
return api.queryInvoicePool(params);
},
apiFetchInvoicePool(invoiceNo) {
return api.fetchInvoicePoolByNo(invoiceNo);
},
apiSyncInvoicePool() {
return api.syncInvoicePool();
},
handleInvoicePicked(rows) {
this.confirmInvoice(rows[0]);
},
@@ -356,7 +347,7 @@ export default {
if (this.settlementIds.length) await this.loadReferenceInformation();
},
validateInvoice(rule, value, callback) {
if (!value || !this.form.kingdeeInvoicePoolId) {
if (!value) {
callback(new Error('请选择金蝶票据池发票'));
return;
}
@@ -393,7 +384,6 @@ export default {
}
const preserveUserInput = options.preserveUserInput === true;
Object.assign(this.form, {
kingdeeInvoicePoolId: selected.id,
invoiceNo: selected.invoiceNo,
invoiceDate: selected.invoiceDate,
invoiceType: selected.invoiceType,
@@ -517,7 +507,6 @@ export default {
payload() {
return {
id: this.form.id,
kingdeeInvoicePoolId: this.form.kingdeeInvoicePoolId,
invoiceNo: this.form.invoiceNo,
invoiceDate: this.form.invoiceDate,
invoiceType: this.form.invoiceType,
@@ -567,8 +556,15 @@ export default {
this.$message.warning('请先选择金蝶票据池发票');
return;
}
const invoice = this.unwrapData(await api.fetchInvoicePoolByNo(this.form.invoiceNo));
if (!invoice || !this.confirmInvoice(invoice, { preserveUserInput: true })) return;
const data = this.unwrapData(
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();
this.$message.success('同步成功');
},
+20
View File
@@ -73,6 +73,13 @@
@click="handleBatchSync"
>批量同步</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
>
@@ -373,6 +380,19 @@ export default {
this.$message.success(`已同步${rows.length}条收票登记`);
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() {
const data = this.unwrapData(await api.getList(1, 100000, this.query));
const exportRows = (data.records || []).map(item => ({
@@ -419,7 +419,6 @@
multiple
:initial-invoice-no="String(invoiceClaimNo || '').trim()"
:query-api="invoicePoolQueryApi"
:fetch-api="invoicePoolFetchApi"
@confirm="handleInvoiceClaimConfirm"
/>
@@ -892,7 +891,6 @@ import {
getReceiptClaims,
claimInvoices as claimInvoicesApi,
queryInvoicePool,
fetchInvoicePoolByNo,
save,
} from '@/api/settlement/formalSettlement';
import {
@@ -2173,9 +2171,6 @@ export default {
invoicePoolQueryApi(params) {
return queryInvoicePool(params);
},
invoicePoolFetchApi(invoiceNo) {
return fetchInvoicePoolByNo(invoiceNo);
},
async handleInvoiceClaimConfirm(rows) {
// 统一票池行附件字段为复数 attachmentsJson,认领请求契约是单数 attachmentJson,中转处归一
this.invoiceClaimDialog.selected = rows.map(row => ({