+
{{ 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 {