feat: 金蝶票池选票弹窗回切本地镜像标准分页(total跳页+名称模糊+认领登记三态过滤,下线游标翻页;附件查看下载与可用金额列保留)
This commit is contained in:
@@ -14,7 +14,13 @@
|
||||
end-placeholder="结束日期"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="销方(开票方税号)">
|
||||
<el-form-item label="开票单位">
|
||||
<el-input v-model="query.salerName" clearable @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="受票单位">
|
||||
<el-input v-model="query.buyerName" clearable @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
<el-form-item label="销方税号">
|
||||
<el-input
|
||||
v-model="query.salerTaxNo"
|
||||
clearable
|
||||
@@ -22,7 +28,7 @@
|
||||
@keyup.enter="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="购方(收票方税号)">
|
||||
<el-form-item label="购方税号">
|
||||
<el-input
|
||||
v-model="query.buyerTaxNo"
|
||||
clearable
|
||||
@@ -46,6 +52,18 @@
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="认领状态">
|
||||
<el-select v-model="query.claimed" clearable placeholder="不限" style="width: 120px">
|
||||
<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: 120px">
|
||||
<el-option label="未登记" :value="false" />
|
||||
<el-option label="已登记" :value="true" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button :disabled="loading" @click="resetQuery">重置</el-button>
|
||||
<el-button type="primary" :disabled="loading" @click="handleQuery">查询</el-button>
|
||||
@@ -129,12 +147,17 @@
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<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>
|
||||
<span class="kingdee-pool-dialog__pager-tip">按名称检索范围为已同步票,未找到请改用发票号码或税号精确查找</span>
|
||||
<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"
|
||||
:disabled="loading"
|
||||
@current-change="load"
|
||||
@size-change="handleSizeChange"
|
||||
/>
|
||||
</div>
|
||||
<template #footer>
|
||||
<el-button @click="visible = false">取消</el-button>
|
||||
@@ -164,7 +187,7 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
loading: false,
|
||||
// 与后端 BfiConstant.INVOICE_TYPE_NAMES 对齐:value 为发票类型编码,label 为中文名
|
||||
// 与后端 BfiConstant.INVOICE_TYPE_NAMES 对齐:value 为发票类型编码(镜像按 invoice_type_code 精确匹配)
|
||||
// 选票场景只开放数电票(普票/专票)
|
||||
invoiceTypeOptions: [
|
||||
{ value: '26', label: '数电发票(普通发票)' },
|
||||
@@ -173,13 +196,7 @@ export default {
|
||||
rows: [],
|
||||
selected: [],
|
||||
current: null,
|
||||
page: { current: 1, size: 10, hasMore: false },
|
||||
// 续扫游标(服务端过滤补页后翻页须按游标对齐,防漏行/重行)
|
||||
nextCursor: null,
|
||||
// 下一页请求待回传的游标:nextPage 时暂存,load 成功或失败后清空
|
||||
pendingCursor: null,
|
||||
// 已浏览页缓存:上一页直接回显不再请求(0 远程调用)
|
||||
pageCache: {},
|
||||
page: { current: 1, size: 10, total: 0 },
|
||||
// 正在查看/下载附件的发票号(行级 loading 守卫)
|
||||
attachmentBusy: null,
|
||||
query: this.emptyQuery(),
|
||||
@@ -201,14 +218,18 @@ export default {
|
||||
invoiceNo: '',
|
||||
// 默认查近一个月,随请求传后端并在页面回显
|
||||
invoiceDateRange: [this.$dayjs().subtract(1, 'month').format('YYYY-MM-DD'), this.$dayjs().format('YYYY-MM-DD')],
|
||||
salerName: '',
|
||||
buyerName: '',
|
||||
salerTaxNo: '',
|
||||
buyerTaxNo: '',
|
||||
invoiceType: '',
|
||||
claimed: null,
|
||||
registered: null,
|
||||
};
|
||||
},
|
||||
// 远程实时查询的票未入本地镜像,id 恒空,用发票号码兜底作为行主键
|
||||
// 镜像行主键为 id,回源入库前的响应仍可能无 id,用发票号码兜底
|
||||
rowKey(row) {
|
||||
return row.invoiceNo || row.id;
|
||||
return row.id || row.invoiceNo;
|
||||
},
|
||||
// 票池行附件字段为复数 attachmentsJson,行内首项即发票文件({source,path,name})
|
||||
rowAttachment(row = {}) {
|
||||
@@ -261,81 +282,46 @@ export default {
|
||||
this.selected = [];
|
||||
this.$refs.poolTable?.clearSelection();
|
||||
this.page.current = 1;
|
||||
this.resetScanState();
|
||||
this.load();
|
||||
},
|
||||
handleQuery() {
|
||||
this.page.current = 1;
|
||||
this.resetScanState();
|
||||
this.load();
|
||||
},
|
||||
handleSizeChange() {
|
||||
this.page.current = 1;
|
||||
this.resetScanState();
|
||||
this.load();
|
||||
},
|
||||
prevPage() {
|
||||
// 已浏览页直接回显缓存,不再请求
|
||||
const cached = this.pageCache[this.page.current - 1];
|
||||
if (cached) {
|
||||
this.page.current -= 1;
|
||||
this.rows = cached.rows;
|
||||
this.page.hasMore = cached.hasMore;
|
||||
this.nextCursor = cached.nextCursor;
|
||||
return;
|
||||
}
|
||||
this.page.current -= 1;
|
||||
this.load();
|
||||
},
|
||||
nextPage() {
|
||||
this.pendingCursor = this.nextCursor;
|
||||
this.page.current += 1;
|
||||
this.load();
|
||||
},
|
||||
resetQuery() {
|
||||
this.query = this.emptyQuery();
|
||||
this.handleQuery();
|
||||
},
|
||||
// 新查询/换页容量/重新打开时清空游标与已浏览页缓存,重新锚定扫描
|
||||
resetScanState() {
|
||||
this.nextCursor = null;
|
||||
this.pendingCursor = null;
|
||||
this.pageCache = {};
|
||||
},
|
||||
unwrap(response) {
|
||||
const body = response?.data || response || {};
|
||||
return body?.data || body;
|
||||
},
|
||||
async load() {
|
||||
this.loading = true;
|
||||
// 请求前快照页码:prev/next 会先改写 current,远程失败时回滚避免停留在错页
|
||||
const lastRequested = this.page.current;
|
||||
const cursor = this.pendingCursor;
|
||||
this.pendingCursor = null;
|
||||
try {
|
||||
const range = this.query.invoiceDateRange || [];
|
||||
const data = this.unwrap(
|
||||
await this.queryApi({
|
||||
current: this.page.current,
|
||||
size: this.page.size,
|
||||
cursor: cursor || undefined,
|
||||
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,
|
||||
})
|
||||
);
|
||||
this.rows = data.records || [];
|
||||
this.page.hasMore = !!data.hasMore;
|
||||
this.nextCursor = data.nextCursor || null;
|
||||
this.pageCache[this.page.current] = { rows: this.rows, hasMore: this.page.hasMore, nextCursor: this.nextCursor };
|
||||
} catch (error) {
|
||||
if (this.page.current !== lastRequested) {
|
||||
this.page.current = lastRequested;
|
||||
}
|
||||
throw error;
|
||||
this.page.total = Number(data.total || 0);
|
||||
} finally {
|
||||
this.loading = false;
|
||||
}
|
||||
@@ -373,8 +359,12 @@ export default {
|
||||
.kingdee-pool-dialog__pager {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
justify-content: flex-end;
|
||||
justify-content: space-between;
|
||||
margin-top: 12px;
|
||||
gap: 16px;
|
||||
}
|
||||
.kingdee-pool-dialog__pager-tip {
|
||||
color: #909399;
|
||||
font-size: 12px;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user