fix: 发票信息查看下载优先走金蝶票池版式文件

This commit is contained in:
刘泉佳
2026-11-08 14:01:21 +08:00
parent b218fc2345
commit 44cec23147
2 changed files with 73 additions and 66 deletions
+40 -36
View File
@@ -745,14 +745,12 @@ import {
} from '@/api/vehicle/customer-archive'; } from '@/api/vehicle/customer-archive';
import { readSettlementTransfer, removeSettlementTransfer } from '@/utils/settlement-transfer'; import { readSettlementTransfer, removeSettlementTransfer } from '@/utils/settlement-transfer';
import { formatContractOptionLabel } from '@/utils/contract'; import { formatContractOptionLabel } from '@/utils/contract';
import { downloadFileByUrl } from '@/utils/util'; import { downloadFile, downloadFileByUrl } from '@/utils/util';
import { loadMkEnabled, submitMkApprovalFlow } from '@/utils/mk-approval'; import { loadMkEnabled, submitMkApprovalFlow } from '@/utils/mk-approval';
import { import {
downloadKingdeeFile, downloadKingdeeFile,
downloadKingdeeInvoiceFile, requestKingdeeFile,
isKingdeePathAttachment,
viewKingdeeFile, viewKingdeeFile,
viewKingdeeInvoiceFile,
} from '@/utils/kingdee-attachment'; } from '@/utils/kingdee-attachment';
import PdfPreview from '@/components/pdf-preview/main.vue'; import PdfPreview from '@/components/pdf-preview/main.vue';
@@ -1913,9 +1911,6 @@ export default {
return {}; return {};
} }
}, },
invoiceAttachmentUrl(row) {
return this.attachmentFileUrl(this.invoiceAttachment(row));
},
invoiceAttachmentName(row) { invoiceAttachmentName(row) {
return ( return (
this.attachmentFileName(this.invoiceAttachment(row)) || `${row.invoiceNo || '发票'}.pdf` this.attachmentFileName(this.invoiceAttachment(row)) || `${row.invoiceNo || '发票'}.pdf`
@@ -1932,38 +1927,47 @@ export default {
} }
}, },
async viewInvoiceAttachment(row) { async viewInvoiceAttachment(row) {
const attachment = this.invoiceAttachment(row); await this.withKingdeeAttachmentBusy(async () => {
// 金蝶侧附件(path 型)经后端代理 A801-2 预览,OSS 直链维持本地预览组件 // 发票版式文件按票号走金蝶票池(A801-2 镜像优先/实时回源),登记扫描件仅在票池无此票时兜底
if (isKingdeePathAttachment(attachment)) { try {
await this.withKingdeeAttachmentBusy(() => const blob = await requestKingdeeFile(row.invoiceNo);
viewKingdeeInvoiceFile(row.invoiceNo, this.invoiceAttachmentName(row)) const url = URL.createObjectURL(blob);
window.open(url, '_blank');
// 延迟释放 objectURL:立即回收可能导致新窗口尚未加载完成即失效
setTimeout(() => URL.revokeObjectURL(url), 60000);
return;
} catch (error) {
// 网络级失败(silent,拦截器已提示)不再回退;票池无此票回退登记附件
if (error?.silent) return;
}
const attachment = this.invoiceAttachment(row);
if (!this.attachmentFileUrl(attachment)) {
this.$message.warning('当前发票没有金蝶版式文件,也没有登记附件');
return;
}
this.previewAttachment(
{ ...attachment, name: this.invoiceAttachmentName(row) },
[attachment]
); );
return; });
}
if (!this.attachmentFileUrl(attachment)) {
this.$message.warning('当前发票暂无可查看附件');
return;
}
this.previewAttachment(
{ ...attachment, name: this.invoiceAttachmentName(row) },
[attachment]
);
}, },
async downloadInvoiceAttachment(row) { async downloadInvoiceAttachment(row) {
const attachment = this.invoiceAttachment(row); await this.withKingdeeAttachmentBusy(async () => {
// 金蝶侧附件(path 型)经后端代理 A801-2 下载,OSS 直链维持前端直连下载 try {
if (isKingdeePathAttachment(attachment)) { const blob = await requestKingdeeFile(row.invoiceNo);
await this.withKingdeeAttachmentBusy(() => downloadFile(blob, this.invoiceAttachmentName(row));
downloadKingdeeInvoiceFile(row.invoiceNo, this.invoiceAttachmentName(row)) return;
); } catch (error) {
return; if (error?.silent) return;
} }
const url = this.attachmentFileUrl(attachment); const attachment = this.invoiceAttachment(row);
if (!url) { const url = this.attachmentFileUrl(attachment);
this.$message.warning('当前发票暂无可下载附件'); if (!url) {
return; this.$message.warning('当前发票没有金蝶版式文件,也没有登记附件');
} return;
downloadFileByUrl(url, this.invoiceAttachmentName(row)); }
downloadFileByUrl(url, this.invoiceAttachmentName(row));
});
}, },
/** 付款记录付款凭证(金蝶电子回单,A801-2 代理):查看=新窗口预览,下载=保存文件 */ /** 付款记录付款凭证(金蝶电子回单,A801-2 代理):查看=新窗口预览,下载=保存文件 */
viewRecordVoucher(row) { viewRecordVoucher(row) {
@@ -1133,12 +1133,8 @@ import {
settlementRecordTypeName, settlementRecordTypeName,
settlementStatusName, settlementStatusName,
} from '@/utils/settlementStatus'; } from '@/utils/settlementStatus';
import { downloadFileByUrl } from '@/utils/util'; import { downloadFile, downloadFileByUrl } from '@/utils/util';
import { import { requestKingdeeFile } from '@/utils/kingdee-attachment';
downloadKingdeeInvoiceFile,
isKingdeePathAttachment,
viewKingdeeInvoiceFile,
} from '@/utils/kingdee-attachment';
import KingdeeInvoicePoolDialog from '@/components/kingdee-invoice-pool-dialog/main.vue'; import KingdeeInvoicePoolDialog from '@/components/kingdee-invoice-pool-dialog/main.vue';
import ChangeRecordDetailDialog from '@/components/change-record-detail-dialog/main.vue'; import ChangeRecordDetailDialog from '@/components/change-record-detail-dialog/main.vue';
import ProjectAdvanceWriteOff from './project-advance-write-off.vue'; import ProjectAdvanceWriteOff from './project-advance-write-off.vue';
@@ -2918,38 +2914,45 @@ export default {
return attachment.originalName || attachment.name || `${row.invoiceNo || '发票'}.pdf`; return attachment.originalName || attachment.name || `${row.invoiceNo || '发票'}.pdf`;
}, },
async viewInvoiceAttachment(row) { async viewInvoiceAttachment(row) {
const attachment = this.invoiceAttachment(row); if (this.kingdeeAttachmentBusy) return;
// 金蝶侧附件(path 型)经后端代理 A801-2 预览,OSS 直链维持 window.open this.kingdeeAttachmentBusy = true;
if (isKingdeePathAttachment(attachment)) { try {
if (this.kingdeeAttachmentBusy) return; // 发票版式文件按票号走金蝶票池(A801-2 镜像优先/实时回源),登记扫描件仅在票池无此票时兜底
this.kingdeeAttachmentBusy = true;
try { try {
await viewKingdeeInvoiceFile(row.invoiceNo, this.invoiceAttachmentName(row)); const blob = await requestKingdeeFile(row.invoiceNo);
} finally { const url = URL.createObjectURL(blob);
this.kingdeeAttachmentBusy = false; window.open(url, '_blank');
// 延迟释放 objectURL:立即回收可能导致新窗口尚未加载完成即失效
setTimeout(() => URL.revokeObjectURL(url), 60000);
return;
} catch (error) {
// 网络级失败(silent,拦截器已提示)不再回退;票池无此票回退登记附件
if (error?.silent) return;
} }
return; const url = this.invoiceAttachmentUrl(row);
if (!url) return this.$message.warning('当前发票没有金蝶版式文件,也没有登记附件');
window.open(url, '_blank');
} finally {
this.kingdeeAttachmentBusy = false;
} }
const url = this.invoiceAttachmentUrl(row);
if (!url) return this.$message.warning('当前发票暂无可查看附件');
window.open(url, '_blank');
}, },
async downloadInvoiceAttachment(row) { async downloadInvoiceAttachment(row) {
const attachment = this.invoiceAttachment(row); if (this.kingdeeAttachmentBusy) return;
// 金蝶侧附件(path 型)经后端代理 A801-2 下载,OSS 直链维持前端直连下载 this.kingdeeAttachmentBusy = true;
if (isKingdeePathAttachment(attachment)) { try {
if (this.kingdeeAttachmentBusy) return;
this.kingdeeAttachmentBusy = true;
try { try {
await downloadKingdeeInvoiceFile(row.invoiceNo, this.invoiceAttachmentName(row)); const blob = await requestKingdeeFile(row.invoiceNo);
} finally { downloadFile(blob, this.invoiceAttachmentName(row));
this.kingdeeAttachmentBusy = false; return;
} catch (error) {
if (error?.silent) return;
} }
return; const url = this.invoiceAttachmentUrl(row);
if (!url) return this.$message.warning('当前发票没有金蝶版式文件,也没有登记附件');
downloadFileByUrl(url, this.invoiceAttachmentName(row));
} finally {
this.kingdeeAttachmentBusy = false;
} }
const url = this.invoiceAttachmentUrl(row);
if (!url) return this.$message.warning('当前发票暂无可下载附件');
downloadFileByUrl(url, this.invoiceAttachmentName(row));
}, },
// 开票发票预览地址:数电PDF优先(OFD浏览器无法预览),退预览图、板式文件 // 开票发票预览地址:数电PDF优先(OFD浏览器无法预览),退预览图、板式文件
issuedInvoicePreviewUrl(row) { issuedInvoicePreviewUrl(row) {