【新增】生成笔试试卷按钮,细节修改
This commit is contained in:
@@ -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,29 @@ 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;
|
||||
link.setAttribute('download', '试卷.docx');
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
link.remove();
|
||||
window.URL.revokeObjectURL(url); // 释放内存
|
||||
} catch (e) {
|
||||
console.error('下载失败:', e);
|
||||
throw new Error('下载试卷失败');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user