mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-portal.git
synced 2025-12-09 10:56:44 +08:00
整体修改导出作业
This commit is contained in:
@@ -521,40 +521,51 @@ export default {
|
||||
}
|
||||
// window.open(`/systemapi/xboe/m/course/portal/export?contentId=${params.contentId}&courseName=${params.courseName}&courseId=${params.courseId}&status=${params.status}&name=${params.name}`)
|
||||
const url = `/systemapi/xboe/m/course/portal/export?contentId=${params.contentId}&courseName=${params.courseName}&courseId=${params.courseId}&status=${params.status}&name=${params.name}`
|
||||
axios({
|
||||
method: 'get',
|
||||
url: url,
|
||||
// responseType: 'blob',
|
||||
headers: { 'X-Access-Token': getToken() }
|
||||
}).then((res) => {
|
||||
this.isTrue = false;
|
||||
console.log(res,'res')
|
||||
if(res.data.status == 200){
|
||||
if(res.data.result.includes('home')){
|
||||
window.open(res.data.result)
|
||||
}else{
|
||||
this.$message.warning(res.data.result)
|
||||
}
|
||||
}
|
||||
}).catch(err=>{
|
||||
this.isTrue = false;
|
||||
this.$message.error(err.data.message)
|
||||
})
|
||||
// axios({
|
||||
// method: 'get',
|
||||
// url: url,
|
||||
// responseType: 'blob',
|
||||
// headers: { 'X-Access-Token': getToken() }
|
||||
// }).then((res) => {
|
||||
// this.resolveBlob(res, 'application/zip',`${params.courseName}【作业】`)
|
||||
// })
|
||||
axios({
|
||||
method: 'get',
|
||||
url: url,
|
||||
responseType: 'blob',
|
||||
headers: { 'X-Access-Token': getToken() }
|
||||
}).then((response) => {
|
||||
if (response.status === 200) {
|
||||
this.isTrue = false;
|
||||
if (!(response.headers['content-type']).startsWith('application/json')) {
|
||||
this.resolveBlob(response, 'application/zip', `${params.courseName}【作业】`);
|
||||
} else {
|
||||
console.log(response,'response')
|
||||
const reader = new FileReader();
|
||||
reader.onload = (e) => {
|
||||
const errorData = JSON.parse(e.target.result)
|
||||
this.$message.error(errorData.result)
|
||||
};
|
||||
reader.readAsText(response.data);
|
||||
}
|
||||
}
|
||||
}).catch((error) => {
|
||||
this.isTrue = false;
|
||||
// 错误处理
|
||||
console.log(error);
|
||||
this.$message.error(error.data ? error.data.message : error.toString());
|
||||
});
|
||||
// }).then((response) => {
|
||||
// if (response.status === 200) {
|
||||
// this.isTrue = false;
|
||||
// if (!(response.headers['content-type']).startsWith('application/json')) {
|
||||
// this.resolveBlob(response, 'application/zip', `${params.courseName}【作业】`);
|
||||
// } else {
|
||||
// console.log(response,'response')
|
||||
// const reader = new FileReader();
|
||||
// reader.onload = (e) => {
|
||||
// const errorData = JSON.parse(e.target.result)
|
||||
// this.$message.error(errorData.result)
|
||||
// };
|
||||
// reader.readAsText(response.data);
|
||||
// }
|
||||
// }
|
||||
// }).catch((error) => {
|
||||
// this.isTrue = false;
|
||||
// // 错误处理
|
||||
// console.log(error);
|
||||
// this.$message.error(error.data ? error.data.message : error.toString());
|
||||
// });
|
||||
},
|
||||
resolveBlob(res, mimeType,filename) {
|
||||
const link = document.createElement('a');// 创建a标签
|
||||
|
||||
Reference in New Issue
Block a user