From a40c5148ad225760859297b7c55b664da4c4aa28 Mon Sep 17 00:00:00 2001
From: WXL <1785969728@qq.com>
Date: 星期二, 19 三月 2024 11:07:15 +0800
Subject: [PATCH] 11
---
src/views/project/unitCost/index.vue | 39 +++++++++++++++++++++++++++++++++++----
1 files changed, 35 insertions(+), 4 deletions(-)
diff --git a/src/views/project/unitCost/index.vue b/src/views/project/unitCost/index.vue
index ed51192..291cb22 100644
--- a/src/views/project/unitCost/index.vue
+++ b/src/views/project/unitCost/index.vue
@@ -165,7 +165,7 @@
<el-button
size="mini"
type="primary"
- @click="download(scope.row)"
+ @click="download(scope.row.id)"
icon="el-icon-download"
circle
></el-button>
@@ -184,7 +184,7 @@
<el-dialog
:visible.sync="showSelectionDialog"
:close-on-click-modal="false"
- :title="'璇烽�夋嫨鎹愮尞妗堜緥'"
+ :title="'浠樻鍖荤枟鏈烘瀯閫夋嫨'"
width="500px"
style="text-align: center"
v-loading="loading"
@@ -431,8 +431,39 @@
});
},
// 鎵撳嵃
- download(row) {
- dyDonorpayment(row.id).then(res => {});
+ download(id) {
+ // const id =this.row.id
+ dyDonorpayment(id).then(res => {
+ var fileUrl = res;
+ //鑾峰彇褰撳墠缃戝潃
+ var urlBase = process.env.VUE_APP_BASE_API;
+ var curWWWPath = window.document.location.href;
+ var pos = curWWWPath.indexOf(window.document.location.pathname);
+ // 鍒涘缓a鏍囩
+ var aEle = document.createElement("a");
+ aEle.href =
+ curWWWPath.substring(0, pos) + urlBase + fileUrl["downloadUrl"];
+ console.log(aEle.href);
+ // 娣诲姞Authorization澶撮儴
+ fetch(aEle.href, {
+ headers: this.headers
+ })
+ .then(response => {
+ // 灏嗘枃浠朵笅杞介摼鎺ヤ綔涓篵lob瀵硅薄杩涜涓嬭浇
+ return response.blob();
+ })
+ .then(blob => {
+ const url = window.URL.createObjectURL(new Blob([blob]));
+ console.log(url);
+ const link = document.createElement("a");
+ link.href = url;
+ const name = fileUrl["downloadName"];
+ link.setAttribute("download", name); // 鏇挎崲file.pdf涓哄疄闄呯殑鏂囦欢鍚�
+ document.body.appendChild(link);
+ link.click();
+ link.parentNode.removeChild(link);
+ });
+ });
},
/** 鍒犻櫎鎸夐挳鎿嶄綔 */
--
Gitblit v1.9.3