diff --git a/src/api/system/paper/index.ts b/src/api/system/paper/index.ts index de1c103..9577aa1 100644 --- a/src/api/system/paper/index.ts +++ b/src/api/system/paper/index.ts @@ -104,7 +104,9 @@ export async function openDown(ids) { const url = window.URL.createObjectURL(blob); const link = document.createElement('a'); link.href = url; - link.setAttribute('download', '试卷.docx'); + // 使用示例 + const filename = `${getNowTimeString()}.zip`; + link.setAttribute('download', filename); document.body.appendChild(link); link.click(); link.remove(); @@ -115,4 +117,13 @@ export async function openDown(ids) { } } - +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}`; +} diff --git a/src/views/task/exam/components/steps/step2/index.vue b/src/views/task/exam/components/steps/step2/index.vue index d6a9aa2..031308e 100644 --- a/src/views/task/exam/components/steps/step2/index.vue +++ b/src/views/task/exam/components/steps/step2/index.vue @@ -56,13 +56,16 @@ > 抽卷调整 - - 生成笔试试卷 - + + + 生成笔试试卷 + - + @@ -259,7 +262,9 @@ const reload = () => { getList(); }; - +const handleSelectionChange = (rows) => { + selections.value = rows; +} // 搜索操作 const handleQuery = () => { queryParams.pageNo = 1; @@ -288,22 +293,30 @@ const openSet = () => { }; /** 表格选中数据 */ const selections = ref([]); +const downloadLoading = ref(false) + const openDown = async () => { - - try { + try { const rows = selections.value; - if (!rows.length) { - message.error('请至少选择一条数据'); - return; + if (!rows.length) { + message.error('请至少选择一条数据'); + return; + } + + downloadLoading.value = true; + message.info('正在生成试卷中,请稍后...'); + + selectedRows.value = rows.map((d: any) => d.paperId); + await PaperApi.openDown(selectedRows.value); + + message.success(t('下载成功')); + await getList(); + } catch (error) { + console.error(error); + message.error('下载失败'); + } finally { + downloadLoading.value = false; } - - selectedRows.value = rows.map((d: any) => d.paperId); // 保存选中的行数据 - await PaperApi.openDown(selectedRows.value) - message.success(t('common.delSuccess')) - // 刷新列表 - await getList() - } catch {} - }; // 打开编辑弹窗 const openEdit = (type: string, row?: object) => { diff --git a/src/views/task/sprint/components/steps/step2/index.vue b/src/views/task/sprint/components/steps/step2/index.vue index bc72501..acb95bd 100644 --- a/src/views/task/sprint/components/steps/step2/index.vue +++ b/src/views/task/sprint/components/steps/step2/index.vue @@ -56,13 +56,16 @@ > 抽卷调整 - - 生成笔试试卷 - + + + 生成笔试试卷 + - + @@ -260,6 +263,9 @@ const reload = () => { }; +const handleSelectionChange = (rows) => { + selections.value = rows; +} // 搜索操作 const handleQuery = () => { queryParams.pageNo = 1; @@ -288,22 +294,30 @@ const openSet = () => { }; /** 表格选中数据 */ const selections = ref([]); +const downloadLoading = ref(false) + const openDown = async () => { - - try { + try { const rows = selections.value; - if (!rows.length) { - message.error('请至少选择一条数据'); - return; + if (!rows.length) { + message.error('请至少选择一条数据'); + return; + } + + downloadLoading.value = true; + message.info('正在生成试卷中,请稍后...'); + + selectedRows.value = rows.map((d: any) => d.paperId); + await PaperApi.openDown(selectedRows.value); + + message.success(t('下载成功')); + await getList(); + } catch (error) { + console.error(error); + message.error('下载失败'); + } finally { + downloadLoading.value = false; } - - selectedRows.value = rows.map((d: any) => d.paperId); // 保存选中的行数据 - await PaperApi.openDown(selectedRows.value) - message.success(t('common.delSuccess')) - // 刷新列表 - await getList() - } catch {} - }; // 打开编辑弹窗 const openEdit = (type: string, row?: object) => { diff --git a/src/views/task/trans/components/steps/step2/index.vue b/src/views/task/trans/components/steps/step2/index.vue index 233ced0..3b1986a 100644 --- a/src/views/task/trans/components/steps/step2/index.vue +++ b/src/views/task/trans/components/steps/step2/index.vue @@ -56,13 +56,17 @@ > 抽卷调整 - - 生成笔试试卷 - + + + 生成笔试试卷 + +