1. // const suffix = 'pdf'
    2. // const DOWNLOAD_TYPE_MAP = {
    3. // xls: 'application/vnd.ms-excel',
    4. // xlsx: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
    5. // doc: 'application/msword',
    6. // docx: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
    7. // pdf: 'application/pdf'
    8. // }
    9. // if (!DOWNLOAD_TYPE_MAP[suffix]) {
    10. // throw new Error('请传入文件下载的格式后缀,eg:xls,xlsx,doc,docx,pdf')
    11. // }
    12. // const blob = new Blob([this.permitFileList[0].fileUrl], {
    13. // type: DOWNLOAD_TYPE_MAP[suffix]
    14. // })
    15. // console.log('🚀 ~ file: settledInfo.vue ~ line 1520 ~ permitFileListDownload ~ blob', blob)
    16. // const fileName = `${name}.${suffix}`
    17. // let link = document.createElement('a')
    18. // document.body.appendChild(link)
    19. // link.href = URL.createObjectURL(blob)
    20. // link.setAttribute('download', fileName)
    21. // link.click()
    22. // document.body.removeChild(link)
    23. // URL.revokeObjectURL(link.href) // 销毁url对象
    24. // let link = document.createElement("a"); //创建a标签
    25. // link.style.display = "none"; //使其隐藏
    26. // link.href = this.permitFileList[0].fileUrl; //赋予文件下载地址
    27. // link.setAttribute("download", this.permitFileList[0].fileName); //设置下载属性 以及文件名
    28. // document.body.appendChild(link); //a标签插至页面中
    29. // link.click(); //强制触发a标签事件
    30. // const xhr = new XMLHttpRequest();
    31. // xhr.open('GET', this.permitFileList[0].fileUrl, true);
    32. // xhr.responseType = 'blob';
    33. // xhr.onload = function() {
    34. // if (this.status === 200) {
    35. // const fileName = 'test.jpg';
    36. // const blob = new Blob([this.permitFileList[0].fileUrl]);
    37. // const blobUrl = window.URL.createObjectURL(blob);
    38. // const a = document.createElement('a');
    39. // a.href = blobUrl;
    40. // a.download = fileName;
    41. // a.click();
    42. // window.URL.revokeObjectURL(blobUrl);
    43. // }
    44. // };
    45. // xhr.send();
    46. // let script = document.createElement('script');
    47. // script.src = this.permitFileList[0].fileUrl;
    48. // document.body.appendChild(script)
    49. // script.onload = function(){
    50. // document.body.removeChild(this)
    51. // }