diff --git a/src/api/system/paper/index.ts b/src/api/system/paper/index.ts index 3e635d7..de1c103 100644 --- a/src/api/system/paper/index.ts +++ b/src/api/system/paper/index.ts @@ -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('下载试卷失败'); + } +} + diff --git a/src/views/paper/question/FileForm.vue b/src/views/paper/question/FileForm.vue index 9c8d72f..d8c092c 100644 --- a/src/views/paper/question/FileForm.vue +++ b/src/views/paper/question/FileForm.vue @@ -192,6 +192,11 @@ --> + + +