diff --git a/.env b/.env index 79153fd..214a3f1 100644 --- a/.env +++ b/.env @@ -2,8 +2,8 @@ VITE_APP_TITLE=金融产品设计及数字化营销沙盘 VITE_PORT=9520 # VITE_PROXY=http://192.168.31.125:8080 VITE_PUBLIC_PATH=./ -VITE_BASE_API=http://192.168.31.51:9000 -# VITE_BASE_API=http://121.37.12.51 +# VITE_BASE_API=http://192.168.31.51:9000 +VITE_BASE_API=http://121.37.12.51 # VITE_BASE_API=https://www.occupationlab.com VITE_I18N_LOCALE=zh-cn VITE_I18N_FALLBACK_LOCALE=zh-cn diff --git a/src/views/report/Index.vue b/src/views/report/Index.vue index 7e378e7..23c444a 100644 --- a/src/views/report/Index.vue +++ b/src/views/report/Index.vue @@ -10,13 +10,13 @@ -
-
+
+
{{ editing ? '保存' : '编辑' }} - 导出报告 + 导出报告
标准实验报告
@@ -154,6 +154,8 @@ const form = ref>({}); const expData = ref[]>([]); const editing = ref(false); const userScores = ref[]>([]); +const loading = ref(false); +const exporting = ref(false); // 处理实验数据 const handleList = (list: Record[]) => { @@ -176,7 +178,7 @@ const handleList = (list: Record[]) => { } }); e.lcStudentAnswer.map((n, i) => { - e.answer += `${i + 1}.${n.userAnswer || '未填写'};` + e.answer += `${i + 1}.${n.userAnswer || '未填写'};`; }); }); console.log('🚀 ~ file: Index.vue:235 ~ handleList ~ list:', list); @@ -184,49 +186,59 @@ const handleList = (list: Record[]) => { }; // 查询详情 const getData = async () => { - const res = await reportDetail(reportId.value); - form.value = res.report; - userScores.value = res.userScores; - const { data } = res.report; - // 如果没有data,则添加,否则,直接使用 - if (!data) { - handleList(res.userScores); - await editExperimentalData({ - reportId: reportId.value, - data: JSON.stringify(res.userScores), - }); - } else { - handleList(res.userScores); + try { + loading.value = true; + const res = await reportDetail(reportId.value); + form.value = res.report; + userScores.value = res.userScores; + const { data } = res.report; + // 如果没有data,则添加,否则,直接使用 + if (!data) { + handleList(res.userScores); + await editExperimentalData({ + reportId: reportId.value, + data: JSON.stringify(res.userScores), + }); + } else { + handleList(res.userScores); + } + } finally { + loading.value = false; } }; // 导出 const exportPage = async () => { - const param = JSON.parse(JSON.stringify(form.value)); - const list = JSON.parse(JSON.stringify(expData.value)); - list.forEach((e, i) => { - e.id = i + 1; - if (e.referenceAnswer && typeof e.referenceAnswer === 'string') - e.referenceAnswer = e.referenceAnswer - .replace(/<[^>]+>/g, '') - .replace(/( |&|%s)/g, '') - .replace(/>/g, '>') - .replace(/]+>/g, ''); - e.answer = e.answer.replace(/( |&|%s)/g, ''); - e.answer = e.answer.replace(/>/g, '>'); - e.answer = e.answer.replace(/ { + e.id = i + 1; + if (e.referenceAnswer && typeof e.referenceAnswer === 'string') + e.referenceAnswer = e.referenceAnswer + .replace(/<[^>]+>/g, '') + .replace(/( |&|%s)/g, '') + .replace(/>/g, '>') + .replace(/]+>/g, ''); + e.answer = e.answer.replace(/( |&|%s)/g, ''); + e.answer = e.answer.replace(/>/g, '>'); + e.answer = e.answer.replace(/]+>/g, ''); } - }); - for (const i in param) { - if (param[i] && typeof param[i] === 'string') param[i] = param[i].replace(/<[^>]+>/g, ''); + param.purpose = param.purpose.replace(/<[^>]+>/g, ''); + const res = await exportBankExperimentReport({ + ...param, + experimentalData: list, + }); + downloadFileDirect(`实验报告.docx`, new Blob([res])); + } finally { + exporting.value = false; } - param.purpose = param.purpose.replace(/<[^>]+>/g, ''); - const res = await exportBankExperimentReport({ - ...param, - experimentalData: list, - }); - downloadFileDirect(`实验报告.docx`, new Blob([res])); }; // 编辑实验报告 const editReport = async () => { @@ -267,9 +279,6 @@ samp { font-family: 'PingFang SC', 'Helvetica Neue', Helvetica, 'microsoft yahei', arial, STHeiTi, sans-serif; } .content { - &.loading { - padding-top: 30px; - } .l-title { @apply flex items-center px-2 py-1 mb-3 bg-[#f7f9fc]; img {