downloadFileMethod(file){
let that = this;
event.preventDefault();
axios({
method: 'get',
url: that.downloadCommonUrl+'?id='+file.id,
responseType: 'blob'
}).then(data => {
let balo = data.data;
if(balo.length=0){
return;
}
let url = window.URL.createObjectURL(new Blob([balo]))
let link = document.createElement('a')
link.style.display = 'none'
link.href = url
link.setAttribute('download', file.name)
document.body.appendChild(link)
link.click()
})
}
writeExcelFile(pd).then((res) => {
const balo = res;
const url = window.URL.createObjectURL(new Blob([balo]));
var file = new File([balo], this.detail.reportTypeName + '.xlsx');
const formData = new FormData();
formData.append('files', file);
formData.append('sysName', 'operateMoniter');
//接收到后发送给后端
uploadImage(formData).then((res) => {
const url = res.data[0].url;
saveUrl({ id: this.id, url }).then(() => {
this.$message.success('生成报表成功!');
});
});
const link = document.createElement('a');
link.style.display = 'none';
link.href = url;
link.setAttribute('download', this.detail.reportTypeName + '.xlsx');
document.body.appendChild(link);
link.click();
this.handleBack();
});
},
下载文件模拟a标签点击,接收blob二进制文件,文件格式进行发送
最新推荐文章于 2024-04-29 18:19:28 发布