导出详细学习记录 - loading 更改

This commit is contained in:
gengxin
2025-03-03 18:07:15 +08:00
parent 75ca7c72a6
commit c4245231c5
2 changed files with 12 additions and 2 deletions

View File

@@ -92,7 +92,8 @@
</a-button> </a-button>
</a-col> </a-col>
<a-col> <a-col>
<a-button class="cus-btn" style="background: #4ea6ff; color: #fff; width: 150px" @click="exportStudy"> <a-button class="cus-btn" style="background: #4ea6ff; color: #fff; width: 150px" :loading="exportLoading"
@click="exportStudy">
导出详细学习记录 导出详细学习记录
</a-button> </a-button>
</a-col> </a-col>
@@ -329,11 +330,15 @@ function reset() {
function exportStu() { function exportStu() {
window.open(`${process.env.VUE_APP_BASE_API}/admin/student/exportOnlineStudent?type=3&&thirdType=8&pid=${searchParams.value.pid}`); window.open(`${process.env.VUE_APP_BASE_API}/admin/student/exportOnlineStudent?type=3&&thirdType=8&pid=${searchParams.value.pid}`);
} }
const exportLoading = ref(false);
function exportStudy() { function exportStudy() {
if(studentList.value.length == 0){ if(studentList.value.length == 0){
return message.warning('暂无可导出的学习记录') return message.warning('暂无可导出的学习记录')
} }
downLoadXlsx(`${process.env.VUE_APP_BASE_API}/admin/student/exportOnlineStudentDetail?type=4&&thirdType=8&pid=${searchParams.value.pid}`,'在线课学员学习记录') exportLoading.value = true;
let {loading} = downLoadXlsx(`${process.env.VUE_APP_BASE_API}/admin/student/exportOnlineStudentDetail?type=4&&thirdType=8&pid=${searchParams.value.pid}`,'在线课学员学习记录');
exportLoading.value = loading;
} }
defineExpose({ defineExpose({
searchStu, searchStu,

View File

@@ -1,4 +1,5 @@
import axios from 'axios' import axios from 'axios'
import {ref} from 'vue'
import {getCookieForName} from "@/api/method"; import {getCookieForName} from "@/api/method";
const mimeMap = { const mimeMap = {
@@ -13,6 +14,10 @@ export function downLoadXlsx(str, filename) {
headers: { 'Authorization': 'Bearer ' + getCookieForName("token") } headers: { 'Authorization': 'Bearer ' + getCookieForName("token") }
}).then(res => { }).then(res => {
resolveBlob(res, mimeMap.xlsx,filename) resolveBlob(res, mimeMap.xlsx,filename)
return false;
}).catch(error =>{
console.log("downLoadXlsx error",error);
return false;
}) })
} }
const baseUrl = process.env.VUE_APP_ACT_API const baseUrl = process.env.VUE_APP_ACT_API