|
|
@@ -251,10 +251,50 @@ function downLoadBehaviorData(){
|
|
|
apis.downLoadBehaviorData(currentEngagement.value.studentId,currentEngagement.value.assignmentId)
|
|
|
.then((res:any) => {
|
|
|
console.log(res)
|
|
|
+ if (res && res.status === 200){
|
|
|
+ let blob = res.data as Blob;
|
|
|
+ const fileName = '行为数据.xlsx';
|
|
|
+ if ('download' in document.createElement('a')) {
|
|
|
+ const link = document.createElement('a');
|
|
|
+ link.download = fileName;
|
|
|
+ link.style.display = 'none';
|
|
|
+ link.href = URL.createObjectURL(blob);
|
|
|
+ document.body.appendChild(link);
|
|
|
+ link.click();
|
|
|
+ ElMessage.success('下载成功')
|
|
|
+ URL.revokeObjectURL(link.href); // 释放URL对象
|
|
|
+ document.body.removeChild(link);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch((err:any) => {
|
|
|
+ console.log(err)
|
|
|
+ ElMessage.success('下载失败')
|
|
|
})
|
|
|
}
|
|
|
else if (selectedType.value === 'all'){
|
|
|
apis.downLoadAllBehaviorData(selectedAssignment.value.assignmentId)
|
|
|
+ .then((res:any) => {
|
|
|
+ if (res && res.status === 200){
|
|
|
+ let blob = res.data as Blob;
|
|
|
+ const fileName = '行为数据.xlsx';
|
|
|
+ if ('download' in document.createElement('a')) {
|
|
|
+ const link = document.createElement('a');
|
|
|
+ link.download = fileName;
|
|
|
+ link.style.display = 'none';
|
|
|
+ link.href = URL.createObjectURL(blob);
|
|
|
+ document.body.appendChild(link);
|
|
|
+ link.click();
|
|
|
+ ElMessage.success('下载成功')
|
|
|
+ URL.revokeObjectURL(link.href); // 释放URL对象
|
|
|
+ document.body.removeChild(link);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch((err:any) => {
|
|
|
+ console.log(err)
|
|
|
+ ElMessage.success('下载失败')
|
|
|
+ })
|
|
|
}
|
|
|
else{
|
|
|
ElMessage.error("请选择下载类型")
|