//点击下载附件
async downFn(type, data) {
this.filename = data.filename;
let [name, status] = data.filename.split(".");
this.downloadFile(data.url, name, "." + status);
},
//downloadFiles
downloadFile(blobUrl, filename, fileType) {
// const fileReader = new FileReader();
// let a = document.createElement("a");
// a.download = filename;
// a.href = blobUrl;
// document.body.appendChild(a);
// a.click();
// document.body.removeChild(a);
let urlList = blobUrl.split(".com");
let urls = "/downLoad/" + urlList[1];
axios({
method: "get",
url: urls,
responseType: "blob", //返回是个文件
}).then((res) => {
const fileReader = new FileReader();
fileReader.readAsDataURL(res.data);
fileReader.onload = (event) => {
let a = document.createElement("a");
a.download = filename+fileType;
a.href = event.target.result;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
};
});
},