瀏覽代碼

订单查询-报价详情电子保单下载

lihongxiao 3 年之前
父節點
當前提交
834fc5c536
共有 1 個文件被更改,包括 16 次插入33 次删除
  1. 16 33
      src/views/Letter/Orderlist.vue

+ 16 - 33
src/views/Letter/Orderlist.vue

@@ -1662,19 +1662,6 @@ export default {
       this.pageRequest.pageNum = val;
       this.findPage();
     },
-    getBlob(url) {
-      return new Promise(resolve => {
-        const xhr = new XMLHttpRequest()
-        xhr.open('GET', url)
-        xhr.responseType = 'blob'
-        xhr.onload = () => {
-          if (xhr.status === 200) {
-            resolve(xhr.response)
-          }
-        }
-        xhr.send()
-      })
-    },
     saveAs(blob, filename) {
       var link = document.createElement('a')
       link.href = window.URL.createObjectURL(blob)
@@ -1685,26 +1672,22 @@ export default {
 
     //预览文件
     viewfile(index) {
-      console.log(index,11111111)
-
-      // fetch(index.fileUrl)
-      // .then(response => response.blob())
-      // .then(blob => {
-      //   console.log(blob,11111111)
-      //   this.saveAs(blob,  this.licenseNo  +'.pdf')
-      // })
-      // .catch(error => {
-      // });
-
-      // this.getBlob(index.fileUrl).then(blob => {
-      //   this.saveAs(blob,  this.licenseNo  +'.pdf')
-      // })
-
-      const a = document.createElement('a')
-      a.href = index.fileurl
-      a.target = '_ blank';
-      a.download = this.licenseNo+ '.pdf';  // 下载文件的名字
-      a.click()
+      let name=index.fileurl.lastIndexOf("\/")
+      fetch(index.fileurl)
+      .then(response => response.blob())
+      .then(blob => {
+        this.saveAs(blob,  index.fileurl.substring (name + 1, index.fileurl.length))
+      })
+      .catch(error => {
+      });
+
+      // const a = document.createElement('a')
+      // a.style.display = 'none'
+      // a.href = index.fileurl
+      // a.target = '_ blank';
+      // a.download = this.licenseNo+ '.pdf';  // 下载文件的名字
+      // document.body.appendChild(a)
+      // a.click()
     },
     //锚链接
     jump(obj) {