diff --git a/src/components/vehicle-attachment-table/main.vue b/src/components/vehicle-attachment-table/main.vue
index f725c49..fc43c86 100644
--- a/src/components/vehicle-attachment-table/main.vue
+++ b/src/components/vehicle-attachment-table/main.vue
@@ -40,9 +40,23 @@
-
-
- 删除
+
+
+
+ 查看
+ 下载
+ 删除
+
@@ -68,6 +82,7 @@
width="90%"
top="4vh"
class="vehicle-attachment-table__viewer-dialog"
+ @closed="handlePreviewClosed"
>
this.attachmentUrl(row));
- if (!downloadableRows.length) {
+ const kingdeeRows = rows.filter(row => this.isKingdeeRow(row));
+ const urlRows = rows.filter(row => !this.isKingdeeRow(row) && this.attachmentUrl(row));
+ if (!kingdeeRows.length && !urlRows.length) {
this.$message.warning(
this.selectedRows.length ? '所选附件暂无可下载地址' : '暂无可下载附件'
);
return;
}
- downloadableRows.forEach((row, index) => {
+ urlRows.forEach((row, index) => {
window.setTimeout(() => this.downloadAttachment(row), index * 500);
});
+ // 金蝶侧附件走代理接口,串行触发避免并发重复回源
+ this.downloadKingdeeRows(kingdeeRows);
+ },
+ async downloadKingdeeRows(rows) {
+ if (this.kingdeeBusy) return;
+ this.kingdeeBusy = true;
+ try {
+ for (const row of rows) {
+ await downloadKingdeeInvoiceFile(this.kingdeeInvoiceNoOf(row), this.attachmentName(row));
+ }
+ } finally {
+ this.kingdeeBusy = false;
+ }
},
previewAttachment(row) {
+ // 金蝶侧附件经 A801-2 代理取流后进弹窗预览,OSS 直链维持原逻辑
+ if (this.isKingdeeRow(row)) {
+ return this.previewKingdeeAttachment(row);
+ }
const url = this.attachmentUrl(row);
if (!url) {
this.$message.warning('附件地址为空,无法预览');
@@ -288,6 +359,37 @@ export default {
};
this.documentPreviewVisible = true;
},
+ async previewKingdeeAttachment(row) {
+ if (this.kingdeeBusy) return;
+ this.kingdeeBusy = true;
+ try {
+ const blob = await requestKingdeeFile(this.kingdeeInvoiceNoOf(row));
+ this.releaseKingdeeObjectUrl();
+ const isPdf = this.isPdf(row) || String(blob.type || '').includes('application/pdf');
+ this.kingdeeObjectUrl = URL.createObjectURL(blob);
+ this.previewFile = {
+ name: this.attachmentName(row),
+ url: this.kingdeeObjectUrl,
+ mimeType: isPdf ? 'application/pdf' : blob.type || '',
+ isPdf,
+ };
+ this.documentPreviewVisible = true;
+ } catch (error) {
+ if (!error?.silent) this.$message.error(error?.message || '附件预览失败');
+ } finally {
+ this.kingdeeBusy = false;
+ }
+ },
+ handlePreviewClosed() {
+ this.releaseKingdeeObjectUrl();
+ this.previewFile = {};
+ },
+ releaseKingdeeObjectUrl() {
+ if (this.kingdeeObjectUrl) {
+ URL.revokeObjectURL(this.kingdeeObjectUrl);
+ this.kingdeeObjectUrl = '';
+ }
+ },
handlePreviewUnsupported() {
this.$message.warning('当前文件暂不支持在线预览');
},
@@ -318,6 +420,17 @@ export default {
text-decoration: underline;
}
+ &__actions {
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ gap: 12px;
+
+ :deep(.el-link) {
+ font-size: 13px;
+ }
+ }
+
&__upload {
display: flex;
justify-content: flex-start;
diff --git a/src/utils/kingdee-attachment.js b/src/utils/kingdee-attachment.js
index c66a970..a7ac977 100644
--- a/src/utils/kingdee-attachment.js
+++ b/src/utils/kingdee-attachment.js
@@ -3,7 +3,7 @@
*
* 票池发票附件为 {source:'piaozone', path, name}:path 是金蝶侧文件 id(非 http 直链),
* 须由后端代理 A801-2 流式回源;OSS 直链附件(url/link/fileUrl)仍由前端直连下载/预览。
- * 三处入口共用:票池弹窗、正式结算认领发票行、付款申请发票附件行。
+ * 入口共用:票池弹窗、正式结算认领发票行、付款申请发票附件行、收票登记附件表。
*/
import { ElMessage } from 'element-plus';
import { downloadFile } from '@/utils/util';
@@ -22,11 +22,12 @@ export const isKingdeePathAttachment = attachment => {
/**
* 请求金蝶文件流:成功返回 Blob;业务失败为 HTTP 200 + R.fail JSON(响应通道未写流时后端即失败),
- * 按 Content-Type 识别并抛出带 msg 的错误;网络级失败拦截器已提示,标记 silent 避免重复提示
+ * 按 Content-Type 识别并抛出带 msg 的错误;网络级失败拦截器已提示,标记 silent 避免重复提示。
+ * 供查看(弹窗内预览)/下载两类入口复用
* @param {String} invoiceNo 发票号码
* @returns {Promise}
*/
-const requestKingdeeFile = async invoiceNo => {
+export const requestKingdeeFile = async invoiceNo => {
let res;
try {
res = await downloadInvoicePoolAttachment(invoiceNo);
diff --git a/src/views/payment/invoice-receipt-form.vue b/src/views/payment/invoice-receipt-form.vue
index 144ca1c..6a5b524 100644
--- a/src/views/payment/invoice-receipt-form.vue
+++ b/src/views/payment/invoice-receipt-form.vue
@@ -118,7 +118,13 @@
-
+
+