From 6a84b9b93897276fc3ecc59ff75ef01df0ff25b7 Mon Sep 17 00:00:00 2001 From: WXL <1785969728@qq.com> Date: 星期一, 22 四月 2024 17:31:07 +0800 Subject: [PATCH] 11 --- src/views/project/unitCost/index.vue | 47 +++++++++++++++++++++++++++++++++++++++++------ 1 files changed, 41 insertions(+), 6 deletions(-) diff --git a/src/views/project/unitCost/index.vue b/src/views/project/unitCost/index.vue index ed51192..1726b5d 100644 --- a/src/views/project/unitCost/index.vue +++ b/src/views/project/unitCost/index.vue @@ -117,7 +117,7 @@ <el-table-column label="鐘舵��" align="center" prop="paystatus"> <template slot-scope="scope"> <dict-tag - :options="dict.type.sys_gathering" + :options="dict.type.Collection_status" :value="scope.row.paystatus" /> </template> @@ -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" @@ -227,10 +227,11 @@ import { listOrganization } from "@/api/project/organization"; import OrgSelecter from "@/views/project/components/orgselect"; +import { getToken } from "@/utils/auth"; export default { name: "Donorcharge", - dicts: ["sys_gathering"], + dicts: ["Collection_status"], components: { OrgSelecter }, @@ -290,6 +291,9 @@ pageNum: 1, pageSize: 10, donorchargeid: null + }, + headers: { + Authorization: "Bearer " + getToken() }, // 琛ㄥ崟鍙傛暟 form: {}, @@ -431,8 +435,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