mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-portal.git
synced 2025-12-09 19:06:43 +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}`)
|
// 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}`
|
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({
|
// axios({
|
||||||
// method: 'get',
|
// method: 'get',
|
||||||
// url: url,
|
// url: url,
|
||||||
// responseType: 'blob',
|
// responseType: 'blob',
|
||||||
// headers: { 'X-Access-Token': getToken() }
|
// headers: { 'X-Access-Token': getToken() }
|
||||||
// }).then((res) => {
|
// }).then((response) => {
|
||||||
// this.resolveBlob(res, 'application/zip',`${params.courseName}【作业】`)
|
// if (response.status === 200) {
|
||||||
// })
|
// this.isTrue = false;
|
||||||
axios({
|
// if (!(response.headers['content-type']).startsWith('application/json')) {
|
||||||
method: 'get',
|
// this.resolveBlob(response, 'application/zip', `${params.courseName}【作业】`);
|
||||||
url: url,
|
// } else {
|
||||||
responseType: 'blob',
|
// console.log(response,'response')
|
||||||
headers: { 'X-Access-Token': getToken() }
|
// const reader = new FileReader();
|
||||||
}).then((response) => {
|
// reader.onload = (e) => {
|
||||||
if (response.status === 200) {
|
// const errorData = JSON.parse(e.target.result)
|
||||||
this.isTrue = false;
|
// this.$message.error(errorData.result)
|
||||||
if (!(response.headers['content-type']).startsWith('application/json')) {
|
// };
|
||||||
this.resolveBlob(response, 'application/zip', `${params.courseName}【作业】`);
|
// reader.readAsText(response.data);
|
||||||
} else {
|
// }
|
||||||
console.log(response,'response')
|
// }
|
||||||
const reader = new FileReader();
|
// }).catch((error) => {
|
||||||
reader.onload = (e) => {
|
// this.isTrue = false;
|
||||||
const errorData = JSON.parse(e.target.result)
|
// // 错误处理
|
||||||
this.$message.error(errorData.result)
|
// console.log(error);
|
||||||
};
|
// this.$message.error(error.data ? error.data.message : error.toString());
|
||||||
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) {
|
resolveBlob(res, mimeType,filename) {
|
||||||
const link = document.createElement('a');// 创建a标签
|
const link = document.createElement('a');// 创建a标签
|
||||||
|
|||||||
Reference in New Issue
Block a user