diff --git a/src/pages/myReview/theoryReview/index.vue b/src/pages/myReview/theoryReview/index.vue index dce01b5..6a4e404 100644 --- a/src/pages/myReview/theoryReview/index.vue +++ b/src/pages/myReview/theoryReview/index.vue @@ -272,6 +272,7 @@ export default { pdfVisible: false, pdfSrc: '', submiting: false, + savePromise: null, }; }, mounted () { @@ -494,28 +495,41 @@ export default { } } + let notReview = 0 + // 判断是否还有未评阅的试题 + if (this.curReview) { + // 如果当前是已评阅的切换,则查询待评阅的试题是否还有试题,有则算还未评阅完 + const { userAnswers: outline } = await this.$get(`${this.api.reviewTheDetailsReport}?reportId=${this.reportId}&status=0`) + for (const e of outline) { + if (e.userAnswerList.length) { + notReview = 1 + break + } + } + } else { + for (const e of paper) { + if (e.userAnswerList.some(n => n.reviewScore === '')) { + notReview = 1 + break + } + } + } + if (invalid) { try { - await this.$confirm('还有未保存的分数,是否保存并继续?', '提示', { + await this.$confirm(`还有未保存的分数,${notReview ? '并且还有试题未评阅,' : ''}是否保存并继续?`, '提示', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning', closeOnClickModal: false, }) await this.saveAll() - - cb() + this.savePromise.then(() => { + cb() + }) } catch (e) { } } else { - // 如果没有未保存的分数,则判断是否还有未评阅的试题 - const { userAnswers: outline } = await this.$get(`${this.api.reviewTheDetailsReport}?reportId=${this.reportId}&status=0`) - for (const e of outline) { - if (e.userAnswerList.length) { - invalid = 1 - break - } - } - if (invalid) { + if (notReview) { await this.$confirm(`还有试题未评阅,确定要${!type ? '前往上一个' : type === 1 ? '前往下一个' : '退出'}吗?`, '提示', { confirmButtonText: '确定', cancelButtonText: '取消', @@ -565,18 +579,38 @@ export default { this.submiting = true const { paper } = this const params = [] - paper.forEach(e => { - e.userAnswerList.forEach(n => { - n.originUserScore !== n.reviewScore && params.push({ - assignmentDetailId: n.assignmentDetailId, - reviewScore: n.reviewScore, - }) - n.originUserScore = n.reviewScore - this.handleIsCorrect(n) + let invalid = 0 + + loop1: for (const e of paper) { + for (const i in e.userAnswerList) { + const n = e.userAnswerList[i] + if (n.questionScore < n.reviewScore) { + Util.warningMsg(`${e.outlineName}的第${+i + 1}小题的考生得分不得大于题目分值!`) + invalid = 1 + break loop1 + } else { + n.originUserScore !== n.reviewScore && params.push({ + assignmentDetailId: n.assignmentDetailId, + reviewScore: n.reviewScore, + }) + } + } + } + if (invalid) return false + + if (params.length) { + this.savePromise = new Promise(async (resolve, reject) => { + await this.$post(this.api.reviewPaper, params) + for (const e of paper) { + for (const n of e.userAnswerList) { + n.originUserScore = n.reviewScore + this.handleIsCorrect(n) + } + } + Util.successMsg('保存成功') + resolve() }) - }) - if (params.length) await this.$post(this.api.reviewPaper, params) - Util.successMsg('保存成功') + } } finally { this.submiting = false } @@ -695,7 +729,7 @@ export default { li { position: relative; - width: 30px; + min-width: 30px; margin: 7px 9px; font-size: 13px; text-align: center; @@ -738,6 +772,7 @@ export default { .score { height: 22px; + padding: 0 2px; border: 1px solid #d3d3d3; border-top: 0; line-height: 22px;