From 9f468e0447a71eb7fcc4f1d78df3be9d348f6fe0 Mon Sep 17 00:00:00 2001
From: WXL <1785969728@qq.com>
Date: 星期一, 25 三月 2024 11:33:02 +0800
Subject: [PATCH] 11

---
 src/views/project/unitCost/index.vue |   68 ++++++++++++++++++++++++++++-----
 1 files changed, 57 insertions(+), 11 deletions(-)

diff --git a/src/views/project/unitCost/index.vue b/src/views/project/unitCost/index.vue
index 5585253..229c77e 100644
--- a/src/views/project/unitCost/index.vue
+++ b/src/views/project/unitCost/index.vue
@@ -128,7 +128,12 @@
         prop="receivableamount"
       />
       <el-table-column label="宸叉敹閲戦" align="center" prop="receivedamount" />
-      <el-table-column label="鏀舵鏃ユ湡" width="180" align="center" prop="receivedtime" />
+      <el-table-column
+        label="鏀舵鏃ユ湡"
+        width="180"
+        align="center"
+        prop="receivedtime"
+      />
       <el-table-column label="缁忓姙浜�" align="center" prop="updateBy" />
       <el-table-column label="鎿嶄綔" width="280" align="center">
         <template slot-scope="scope">
@@ -157,6 +162,13 @@
               ><i class="el-icon-delete"></i>鍒犻櫎</span
             ></el-button
           >
+          <el-button
+            size="mini"
+            type="primary"
+            @click="download(scope.row.id)"
+            icon="el-icon-download"
+            circle
+          ></el-button>
         </template>
       </el-table-column>
     </el-table>
@@ -169,12 +181,10 @@
       @pagination="getList"
     />
 
-
-
     <el-dialog
       :visible.sync="showSelectionDialog"
       :close-on-click-modal="false"
-      :title="'璇烽�夋嫨鎹愮尞妗堜緥'"
+      :title="'浠樻鍖荤枟鏈烘瀯閫夋嫨'"
       width="500px"
       style="text-align: center"
       v-loading="loading"
@@ -211,11 +221,13 @@
   addDonorcharge,
   updateDonorcharge,
   exportDonorcharge,
-  listDonorpayment
+  listDonorpayment,
+  dyDonorpayment
 } from "@/api/project/donorcharge";
 import { listOrganization } from "@/api/project/organization";
 
 import OrgSelecter from "@/views/project/components/orgselect";
+import { getToken } from "@/utils/auth";
 
 export default {
   name: "Donorcharge",
@@ -244,7 +256,7 @@
       // 鎹愮尞妗堜緥鍣ㄥ畼鍒楄〃鏍兼暟鎹�
       donorchargeList: [],
       donorchargerogans: [],
-    
+
       //鎹愮尞妗堜緥閫夋嫨
       showSelectionDialog: false,
       donorlist: [],
@@ -279,6 +291,9 @@
         pageNum: 1,
         pageSize: 10,
         donorchargeid: null
+      },
+      headers: {
+        Authorization: "Bearer " + getToken()
       },
       // 琛ㄥ崟鍙傛暟
       form: {},
@@ -327,7 +342,6 @@
         this.loading = false;
       });
     },
-
 
     // 琛ㄥ崟閲嶇疆
     reset() {
@@ -403,8 +417,6 @@
 
         this.showSelectionDialog = true;
       }
-
-
     },
 
     /** 淇敼鎸夐挳鎿嶄綔 */
@@ -420,6 +432,41 @@
       this.$router.push({
         path: "/cost/particulars",
         query: { id: row.id, operation: "detail", data: row }
+      });
+    },
+    // 鎵撳嵃
+    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);
+          });
       });
     },
 
@@ -452,8 +499,7 @@
           this.exportLoading = false;
         })
         .catch(() => {});
-    },
- 
+    }
   }
 };
 </script>

--
Gitblit v1.9.3