Accept Merge Request #83: (hyc -> master)

Merge Request: 【修改】生成笔试试卷按钮 加载状态

Created By: @华允传
Accepted By: @华允传
URL: https://g-iswv8783.coding.net/p/education/d/pengchen-ui-exam-vue3/git/merge/83?initial=true
This commit is contained in:
华允传
2025-05-27 16:06:09 +08:00
committed by Coding
23 changed files with 262 additions and 26 deletions

View File

@@ -69,7 +69,6 @@ export async function exportPapers(params) {
}
export async function getPaperDetailByTaskId(paperId) {
return await request.get({ url: '/exam/qu/getPaper' , params:{paperId} })
}
@@ -91,4 +90,40 @@ export async function updatePaperStatus(paperId: string, status: number) {
data: { paperId, status } // 使用data
})
}
export async function openDown(ids) {
try {
// 1. 将数组转换为逗号分隔的字符串(例如 ["id1", "id2"] → "id1,id2"
const paperIdsParam = ids.join(',');
const res = await request.download({
url: `/exam/paper/addUpload/${paperIdsParam}`,
});
// 3. 创建 Blob 并触发下载
const blob = new Blob([res]);
const url = window.URL.createObjectURL(blob);
const link = document.createElement('a');
link.href = url;
// 使用示例
const filename = `${getNowTimeString()}.zip`;
link.setAttribute('download', filename);
document.body.appendChild(link);
link.click();
link.remove();
window.URL.revokeObjectURL(url); // 释放内存
} catch (e) {
console.error('下载失败:', e);
throw new Error('下载试卷失败');
}
}
function getNowTimeString() {
const now = new Date();
const Y = now.getFullYear();
const M = String(now.getMonth() + 1).padStart(2, '0');
const D = String(now.getDate()).padStart(2, '0');
const h = String(now.getHours()).padStart(2, '0');
const m = String(now.getMinutes()).padStart(2, '0');
const s = String(now.getSeconds()).padStart(2, '0');
return `${Y}${M}${D}${h}${m}${s}`;
}