diff --git a/src/api/modules/courseStudy.js b/src/api/modules/courseStudy.js index 193420ab..e13a72c4 100644 --- a/src/api/modules/courseStudy.js +++ b/src/api/modules/courseStudy.js @@ -389,7 +389,10 @@ const followIds=function (data){ const myStudysFromES=function (data){ return ajax.post('/xboe/school/study/es/search',data); } - +//导出作业 +const homeworkExport=function (data){ + return ajax.get(`/xboe/m/course/portal/export?contentId=${data.contentId}&courseName=${data.courseName}`); +} /**根据id集合查询,传入的是id数组*/ const findByIds=function (ids){ return ajax.postJson('/xboe/school/study/es/list-by-ids',ids); @@ -425,6 +428,7 @@ export default { myExamList2, myCourseStudy, myStudysFromES, + homeworkExport, findByIds, deleteSignUp, ids, diff --git a/src/components/Study/manager.vue b/src/components/Study/manager.vue index 1cc1d5be..7ec869af 100644 --- a/src/components/Study/manager.vue +++ b/src/components/Study/manager.vue @@ -292,6 +292,7 @@ 搜索 + 导出全部作业 @@ -349,6 +350,7 @@ export default { data() { return { typePress: false, + isHomeWork: false, catalogRecordTree:[], catalogRecordList:[], resOwnerListMap:[], @@ -499,6 +501,32 @@ export default { } }); }, + downLoad(){ + if(this.learningSituation.list.length == 0){ + this.$message.warning('当前暂无数据'); + return + } + let params = { + courseName:this.manageStudyData.name, + contentId:this.contentId + } + apicourseStudy.homeworkExport(params).then(res=>{ + console.log(res,'res') + const link = document.createElement('a');// 创建a标签 + let blob = new Blob([res], { type: 'application/vnd.ms-excel;charset=UTF-8' }); // 设置文件类型 + link.style.display = "none"; + link.href = URL.createObjectURL(blob); // 创建URL + console.log(link.href); + link.setAttribute("download", "作业.xlsx"); + document.body.appendChild(link); + link.click(); + URL.revokeObjectURL(link.href) + document.body.removeChild(link); + }).catch(err=>{ + console.log(err,'err') + this.$message.warning(err.data.msg); + }) + }, handleSizeChangeSituation(val) { this.learningSituation.pageSize = val; this.learningSituation.pageIndex = 1; @@ -702,6 +730,11 @@ export default { }else{ this.typePress = false } + if(type == '作业'){ + this.isHomeWork = true + }else{ + this.isHomeWork = false + } this.contentId = row.id; this.study.catalogueShow = true; this.learningSituation.pageIndex = 1;//重置为第一页