From 032c20ce8059523a89031a5837e94ea685c46600 Mon Sep 17 00:00:00 2001 From: yujialong <479214531@qq.com> Date: Thu, 5 Sep 2024 11:14:59 +0800 Subject: [PATCH] fix --- src/pages/ques/detail/index.vue | 16 +++++++++---- src/pages/ques/list/batchImport.vue | 4 ++-- src/pages/testPaper/detail/index.vue | 34 +++++++++++++++++----------- 3 files changed, 34 insertions(+), 20 deletions(-) diff --git a/src/pages/ques/detail/index.vue b/src/pages/ques/detail/index.vue index 1062a95..c121ef5 100644 --- a/src/pages/ques/detail/index.vue +++ b/src/pages/ques/detail/index.vue @@ -649,7 +649,7 @@ export default { if (gapfillingItems !== null) { gapfillingItems.forEach(function (span, index) { let pairRegex = /(.*?)______(.*?)<\/span>/ - if (span.includes('data-id')) pairRegex = /(.*?)______(.*?)<\/span>/ + // if (span.includes('data-id')) pairRegex = /(.*?)______(.*?)<\/span>/ pairRegex.test(span) newFormItem.push({ fills: [{ val: '' }], uuid: RegExp.$1, scoreProportion: '' }) }) @@ -712,15 +712,21 @@ export default { let scorePro = 0 // 分值占比总和 let filledPro = 0 // 已填写的分值占比数量 for (const e of blanks) { - if (e.fills.every(n => !n.val)) { + if (!e.fills.some(n => n.val)) { Util.warningMsg('请输入填空项正确答案') invalid = 1 break } const pro = e.scoreProportion - if (pro && !isNaN(pro)) { - filledPro++ - scorePro = Decimal(scorePro).add(pro || 0).toNumber() + if (pro) { + if (isNaN(pro)) { + Util.warningMsg('分值占比请输入数字') + invalid = 1 + break + } else { + filledPro++ + scorePro = Decimal(scorePro).add(pro || 0).toNumber() + } } } if (filledPro && blanks.length !== filledPro) return Util.warningMsg('分值占比未填写完成') diff --git a/src/pages/ques/list/batchImport.vue b/src/pages/ques/list/batchImport.vue index 60e33b0..14c7d0b 100644 --- a/src/pages/ques/list/batchImport.vue +++ b/src/pages/ques/list/batchImport.vue @@ -90,7 +90,7 @@ export default { Util.downloadFileDirect('批量导入试题模板.xlsx', new Blob([res.data])) }, // 上传文件 - handleExceed (files, fileList) { + handleExceed () { Util.warningMsg( `当前限制选择 1 个文件,如需更换,请删除上一个文件再重新选择!` ) @@ -113,7 +113,7 @@ export default { Util.errorMsg(message || '上传失败,请检查数据', 3000) } }, - uploadError (err, file, fileList) { + uploadError () { this.uploading = false this.$message({ message: "上传出错,请重试!", diff --git a/src/pages/testPaper/detail/index.vue b/src/pages/testPaper/detail/index.vue index f4bac76..3400866 100644 --- a/src/pages/testPaper/detail/index.vue +++ b/src/pages/testPaper/detail/index.vue @@ -419,16 +419,15 @@ export default { let totalScore = 0 let alreadyScore = 0 paper.forEach(e => { - questionCount += +e.questionNum // 试卷目标总题数 + if (!isNaN(e.questionNum)) questionCount += +e.questionNum // 试卷目标总题数 if (e.examQuestions) { alreadyQuesCount += e.examQuestions.length // 已添加总题数 - totalScore = Decimal(totalScore).add(+e.targetScore || 0).toNumber() // 试卷目标总分 + if (!isNaN(e.targetScore)) totalScore = Decimal(totalScore).add(+e.targetScore || 0).toNumber() // 试卷目标总分 e.examQuestions.forEach(n => { - alreadyScore = Decimal(alreadyScore).add(+n.score || 0).toNumber() // 已分配总分值 + if (!isNaN(n.score)) alreadyScore = Decimal(alreadyScore).add(+n.score || 0).toNumber() // 已分配总分值 }) } }) - console.log("🚀 ~ overview ~ alreadyScore:", alreadyScore, totalScore) return { questionCount, alreadyQuesCount, @@ -715,7 +714,7 @@ export default { getQuesAlreadyScore (item) { let total = 0 item.examQuestions.forEach(e => { - total = Decimal(total).add(+e.score).toNumber() + if (!isNaN(e.score)) total = Decimal(total).add(+e.score).toNumber() }) item.curQuesTotalScore = total return total @@ -911,7 +910,12 @@ export default { loop1: for (const i in paper) { const e = paper[i] - const chineseNum = this.arabicToChinese(+i + 1) + const chineseNum = Util.arabicToChinese(+i + 1) + if (!e.outlineName) { + Util.warningMsg(`第${chineseNum}大题请输入大题名称`) + invalid = 1 + break + } if (!e.questionType) { Util.warningMsg('请选择题型') invalid = 1 @@ -922,11 +926,6 @@ export default { invalid = 1 break } - if (!e.outlineName) { - Util.warningMsg(`第${chineseNum}大题请输入大题名称`) - invalid = 1 - break - } if (!e.targetScore) { Util.warningMsg('请输入目标分值') invalid = 1 @@ -949,8 +948,8 @@ export default { const { fillScores } = n if (fillScores) { for (const e of fillScores) { - if (e.val === '' || e.val === undefined || e.val === null) { - Util.warningMsg(`第${chineseNum}大题的第${this.arabicToChinese(+j + 1)}小题填空分数未填写完成,请重新修改`) + if (e.val === '' || e.val === null || isNaN(e.val)) { + Util.warningMsg(`第${chineseNum}大题的第${Util.arabicToChinese(+j + 1)}小题填空分数请填写数字`) invalid = 1 break loop1 } @@ -965,6 +964,15 @@ export default { break } } else { + for (const j in e.examQuestions) { + const n = e.examQuestions[j] + if (n.score === '' || n.score === null || isNaN(n.score)) { + Util.warningMsg(`第${chineseNum}大题的第${Util.arabicToChinese(+j + 1)}小题分数请填写数字`) + invalid = 1 + break loop1 + } + } + if (+e.targetScore !== e.curQuesTotalScore) { // 该大题里的小题总分需等于目标分值 Util.warningMsg(`第${chineseNum}大题的小题总分跟目标分值不一致,请重新修改`)