From 44cec23147f122eed27bf13f7c32248c41627583 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=B3=89=E4=BD=B3?= <1107186916@qq.com> Date: Sun, 8 Nov 2026 14:01:21 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=8F=91=E7=A5=A8=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E6=9F=A5=E7=9C=8B=E4=B8=8B=E8=BD=BD=E4=BC=98=E5=85=88=E8=B5=B0?= =?UTF-8?q?=E9=87=91=E8=9D=B6=E7=A5=A8=E6=B1=A0=E7=89=88=E5=BC=8F=E6=96=87?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../payment/payment-application-form.vue | 76 ++++++++++--------- .../components/formal-settlement-editor.vue | 63 +++++++-------- 2 files changed, 73 insertions(+), 66 deletions(-) diff --git a/src/views/payment/payment-application-form.vue b/src/views/payment/payment-application-form.vue index 4de8874..c9bf613 100644 --- a/src/views/payment/payment-application-form.vue +++ b/src/views/payment/payment-application-form.vue @@ -745,14 +745,12 @@ import { } from '@/api/vehicle/customer-archive'; import { readSettlementTransfer, removeSettlementTransfer } from '@/utils/settlement-transfer'; import { formatContractOptionLabel } from '@/utils/contract'; -import { downloadFileByUrl } from '@/utils/util'; +import { downloadFile, downloadFileByUrl } from '@/utils/util'; import { loadMkEnabled, submitMkApprovalFlow } from '@/utils/mk-approval'; import { downloadKingdeeFile, - downloadKingdeeInvoiceFile, - isKingdeePathAttachment, + requestKingdeeFile, viewKingdeeFile, - viewKingdeeInvoiceFile, } from '@/utils/kingdee-attachment'; import PdfPreview from '@/components/pdf-preview/main.vue'; @@ -1913,9 +1911,6 @@ export default { return {}; } }, - invoiceAttachmentUrl(row) { - return this.attachmentFileUrl(this.invoiceAttachment(row)); - }, invoiceAttachmentName(row) { return ( this.attachmentFileName(this.invoiceAttachment(row)) || `${row.invoiceNo || '发票'}.pdf` @@ -1932,38 +1927,47 @@ export default { } }, async viewInvoiceAttachment(row) { - const attachment = this.invoiceAttachment(row); - // 金蝶侧附件(path 型)经后端代理 A801-2 预览,OSS 直链维持本地预览组件 - if (isKingdeePathAttachment(attachment)) { - await this.withKingdeeAttachmentBusy(() => - viewKingdeeInvoiceFile(row.invoiceNo, this.invoiceAttachmentName(row)) + await this.withKingdeeAttachmentBusy(async () => { + // 发票版式文件按票号走金蝶票池(A801-2 镜像优先/实时回源),登记扫描件仅在票池无此票时兜底 + try { + const blob = await requestKingdeeFile(row.invoiceNo); + 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) { - const attachment = this.invoiceAttachment(row); - // 金蝶侧附件(path 型)经后端代理 A801-2 下载,OSS 直链维持前端直连下载 - if (isKingdeePathAttachment(attachment)) { - await this.withKingdeeAttachmentBusy(() => - downloadKingdeeInvoiceFile(row.invoiceNo, this.invoiceAttachmentName(row)) - ); - return; - } - const url = this.attachmentFileUrl(attachment); - if (!url) { - this.$message.warning('当前发票暂无可下载附件'); - return; - } - downloadFileByUrl(url, this.invoiceAttachmentName(row)); + await this.withKingdeeAttachmentBusy(async () => { + try { + const blob = await requestKingdeeFile(row.invoiceNo); + downloadFile(blob, this.invoiceAttachmentName(row)); + return; + } catch (error) { + if (error?.silent) return; + } + const attachment = this.invoiceAttachment(row); + const url = this.attachmentFileUrl(attachment); + if (!url) { + this.$message.warning('当前发票没有金蝶版式文件,也没有登记附件'); + return; + } + downloadFileByUrl(url, this.invoiceAttachmentName(row)); + }); }, /** 付款记录付款凭证(金蝶电子回单,A801-2 代理):查看=新窗口预览,下载=保存文件 */ viewRecordVoucher(row) { diff --git a/src/views/settlement/components/formal-settlement-editor.vue b/src/views/settlement/components/formal-settlement-editor.vue index bf279bb..aeb56cc 100644 --- a/src/views/settlement/components/formal-settlement-editor.vue +++ b/src/views/settlement/components/formal-settlement-editor.vue @@ -1133,12 +1133,8 @@ import { settlementRecordTypeName, settlementStatusName, } from '@/utils/settlementStatus'; -import { downloadFileByUrl } from '@/utils/util'; -import { - downloadKingdeeInvoiceFile, - isKingdeePathAttachment, - viewKingdeeInvoiceFile, -} from '@/utils/kingdee-attachment'; +import { downloadFile, downloadFileByUrl } from '@/utils/util'; +import { requestKingdeeFile } from '@/utils/kingdee-attachment'; import KingdeeInvoicePoolDialog from '@/components/kingdee-invoice-pool-dialog/main.vue'; import ChangeRecordDetailDialog from '@/components/change-record-detail-dialog/main.vue'; import ProjectAdvanceWriteOff from './project-advance-write-off.vue'; @@ -2918,38 +2914,45 @@ export default { return attachment.originalName || attachment.name || `${row.invoiceNo || '发票'}.pdf`; }, async viewInvoiceAttachment(row) { - const attachment = this.invoiceAttachment(row); - // 金蝶侧附件(path 型)经后端代理 A801-2 预览,OSS 直链维持 window.open - if (isKingdeePathAttachment(attachment)) { - if (this.kingdeeAttachmentBusy) return; - this.kingdeeAttachmentBusy = true; + if (this.kingdeeAttachmentBusy) return; + this.kingdeeAttachmentBusy = true; + try { + // 发票版式文件按票号走金蝶票池(A801-2 镜像优先/实时回源),登记扫描件仅在票池无此票时兜底 try { - await viewKingdeeInvoiceFile(row.invoiceNo, this.invoiceAttachmentName(row)); - } finally { - this.kingdeeAttachmentBusy = false; + const blob = await requestKingdeeFile(row.invoiceNo); + const url = URL.createObjectURL(blob); + 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) { - const attachment = this.invoiceAttachment(row); - // 金蝶侧附件(path 型)经后端代理 A801-2 下载,OSS 直链维持前端直连下载 - if (isKingdeePathAttachment(attachment)) { - if (this.kingdeeAttachmentBusy) return; - this.kingdeeAttachmentBusy = true; + if (this.kingdeeAttachmentBusy) return; + this.kingdeeAttachmentBusy = true; + try { try { - await downloadKingdeeInvoiceFile(row.invoiceNo, this.invoiceAttachmentName(row)); - } finally { - this.kingdeeAttachmentBusy = false; + const blob = await requestKingdeeFile(row.invoiceNo); + downloadFile(blob, this.invoiceAttachmentName(row)); + 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浏览器无法预览),退预览图、板式文件 issuedInvoicePreviewUrl(row) {