download(loadAddress, id) {
// 下载产品
let files = {};
files.name = "作品压缩包";
// files.filePath = loadAddress
let notifyinfo = this.$notify({
title: '正在下载产品...',
iconClass:'el-icon-loading'
});
let filePath = loadAddress;
request
.requestDownload({ filePath })
.then((res) => {
console.log("000000", res);
const blob = new Blob([res], { type: res.type });
const downloadElement = document.createElement("a");
const href = window.URL.createObjectURL(blob); //创建下载的链接
downloadElement.href = href;
downloadElement.download = files.name; //下载后文件名
document.body.appendChild(downloadElement);
downloadElement.click(); //点击下载
document.body.removeChild(downloadElement); //下载完成移除元素
window.URL.revokeObjectURL(href); //释放blob对象
// 新增下载记录
let downloadAdd = {
opertionName: "dl_records_save",
params: {
product_dl_records$pdlr_product: id,
},
};
request
.request(JSON.stringify(downloadAdd))
.then((res) => {
console.log(res)
notifyinfo.close()
if(res.results) {
this.selectSearchLish()
}
})
.catch((err) => {
console.log(err);
});
})
.catch((err) => {
console.log(err);
});
},