导出作业

This commit is contained in:
zhangsir
2024-07-26 13:33:49 +08:00
parent 2c754fc60a
commit c8a72140af
2 changed files with 38 additions and 1 deletions

View File

@@ -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,

View File

@@ -292,6 +292,7 @@
<el-form-item>
<el-button type="primary" @click="studyContentRecords">搜索</el-button>
</el-form-item>
<el-button v-if="isHomeWork" style="padding:10px 15px;margin-bottom: 10px;" type="primary" @click="downLoad">导出全部作业</el-button>
</el-form>
<el-table max-height="500" border :data="learningSituation.list" style="width: 100%">
<el-table-column prop="aname" label="姓名" width="180"></el-table-column>
@@ -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;//重置为第一页