//导出答卷-vue
uploadExamMet(exam) {
// userId 用户id let userId = exam.examRecordInfo.userId;
// examRecordId 考试记录
let userId = this.userInfo.id;
let examRecordId = exam.examRecordInfo.examRecordId;
uploadExam(userId, examRecordId).then((response) => {
if (response.status == 200) {
// this.download(response.request.responseURL);
this.download(response);
console.log(response);
// exportExcel(response);
}
});
},
download(res) {
if ("download" in document.createElement("a")) {
let url = window.URL.createObjectURL(res.data);
let link = document.createElement("a");
link.style.display = "none";
link.href = url;
link.setAttribute("download", "xxx.xlsx");
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
} else {
navigator.msSaveBlob(res.data, "xxx.xlsx");
}
},
//导出答卷-axios
export function uploadExam(userId, examRecordId) {
return request({
url:
"/api/exam/v1/examRecord/examResultExport/" + userId + "/" + examRecordId,
method: "get",
responseType: "blob"
});
}
vue下载 导出
最新推荐文章于 2022-11-23 17:15:54 发布