// const suffix = 'pdf'// const DOWNLOAD_TYPE_MAP = {// xls: 'application/vnd.ms-excel',// xlsx: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',// doc: 'application/msword',// docx: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',// pdf: 'application/pdf'// }// if (!DOWNLOAD_TYPE_MAP[suffix]) {// throw new Error('请传入文件下载的格式后缀,eg:xls,xlsx,doc,docx,pdf')// }// const blob = new Blob([this.permitFileList[0].fileUrl], {// type: DOWNLOAD_TYPE_MAP[suffix]// })// console.log('🚀 ~ file: settledInfo.vue ~ line 1520 ~ permitFileListDownload ~ blob', blob)// const fileName = `${name}.${suffix}`// let link = document.createElement('a')// document.body.appendChild(link)// link.href = URL.createObjectURL(blob)// link.setAttribute('download', fileName)// link.click()// document.body.removeChild(link)// URL.revokeObjectURL(link.href) // 销毁url对象// let link = document.createElement("a"); //创建a标签// link.style.display = "none"; //使其隐藏// link.href = this.permitFileList[0].fileUrl; //赋予文件下载地址// link.setAttribute("download", this.permitFileList[0].fileName); //设置下载属性 以及文件名// document.body.appendChild(link); //a标签插至页面中// link.click(); //强制触发a标签事件// const xhr = new XMLHttpRequest();// xhr.open('GET', this.permitFileList[0].fileUrl, true);// xhr.responseType = 'blob';// xhr.onload = function() {// if (this.status === 200) {// const fileName = 'test.jpg';// const blob = new Blob([this.permitFileList[0].fileUrl]);// const blobUrl = window.URL.createObjectURL(blob);// const a = document.createElement('a');// a.href = blobUrl;// a.download = fileName;// a.click();// window.URL.revokeObjectURL(blobUrl);// }// };// xhr.send();// let script = document.createElement('script');// script.src = this.permitFileList[0].fileUrl;// document.body.appendChild(script)// script.onload = function(){// document.body.removeChild(this)// }
