参考答案:
@@ -273,10 +274,11 @@ export default {
};
},
mounted () {
- this.getData()
+ this.switchRecord(0, 1)
+ this.getData(1)
},
methods: {
- async getData () {
+ async getData (init) {
this.loading = true
try {
const { userAnswers: outline, report } = await this.$get(`${this.api.reviewTheDetailsReport}?reportId=${this.reportId}&status=${this.curReview}`)
@@ -351,8 +353,8 @@ export default {
n.isCorrect = n.userScore && n.questionScore === n.userScore ? 1 : (rightLen ? 3 : 2)
} else if (type === 'essay') { // 简答题
if (!n.userScore) n.userScore = ''
- if (!n.reviewScore) n.reviewScore = ''
- n.isCorrect = 4 // 简答题显示待判分
+ if (isNaN(n.reviewScore)) n.reviewScore = ''
+ this.handleEssayScore(n)
}
n.originUserScore = n.reviewScore
n.newComments = n.comments || ''
@@ -360,7 +362,12 @@ export default {
paper.push(e)
}
})
-
+ // 初始化的时候,如果没有待评阅的试题,则查询已评阅
+ if (!paper.length && init) {
+ this.curReview = 1
+ this.getData()
+ return false
+ }
this.paper = paper
this.loading = false
@@ -368,13 +375,17 @@ export default {
this.loading = false
}
},
+ // 判断简答题的对错
+ handleEssayScore (n) {
+ n.isCorrect = n.reviewScore === '' ? 4 : (n.reviewScore === n.questionScore ? 1 : n.reviewScore ? 3 : 2) // 简答题没有reviewScore则显示待判分, 有则判断是否跟题目分数相同,完全相同是正确,小于则部分正确,0则错误
+ },
scrollToSmooth (position, duration) {
let startTime = Date.now()
function scroll () {
let now = Date.now()
let progress = Math.min(1, (now - startTime) / duration)
- document.querySelector('#right').scrollTo(0, position * progress)
+ document.querySelector('#quesWrap').scrollTo(0, position * progress)
if (progress < 1) {
window.requestAnimationFrame(scroll)
@@ -388,7 +399,7 @@ export default {
item.shrink = false
const el = document.querySelector('#ques' + e.id)
this.$nextTick(() => {
- el && this.scrollToSmooth(el.offsetTop - document.querySelector('#right').offsetTop, 200)
+ el && this.scrollToSmooth(el.offsetTop - document.querySelector('#quesWrap').offsetTop, 200)
})
},
// 左侧评阅切换
@@ -427,6 +438,7 @@ export default {
reviewScore: ques.reviewScore,
}])
ques.originUserScore = ques.reviewScore
+ this.handleEssayScore(ques)
Util.successMsg('保存成功')
},
// 填空题的小空对错点击回调
@@ -466,21 +478,53 @@ export default {
Util.successMsg('删除成功')
},
+ // 判断是否需要弹框提示保存分数
+ async handleLeave (cb) {
+ const { paper } = this
+ let invalid = 0
+ for (const e of paper) {
+ if (e.userAnswerList.some(n => n.originUserScore !== n.reviewScore)) {
+ invalid = 1
+ break
+ }
+ }
+
+ if (invalid) {
+ try {
+ await this.$confirm('还有未保存的分数,是否保存并继续?', '提示', {
+ confirmButtonText: '确定',
+ cancelButtonText: '取消',
+ type: 'warning',
+ closeOnClickModal: false,
+ })
+ await this.saveAll()
+
+ cb()
+ } catch (e) { }
+ } else {
+ cb()
+ }
+ },
// 下一个、上一个
- async switchRecord (isNext) {
- const res = await this.$post(this.api.getTheLabReportIdUpAndDown, {
- competitionId: this.competitionId,
- stageId: this.stageId,
- currentReportId: this.reportId
+ async switchRecord (isNext, init) {
+ this.handleLeave(async () => {
+ const res = await this.$post(this.api.getTheLabReportIdUpAndDown, {
+ competitionId: this.competitionId,
+ stageId: this.stageId,
+ currentReportId: this.reportId
+ })
+ this.showNext = !init && !isNext && res.previousReportId ? true : (init ? !!res.nextReportId : !!res.nextNextReportId)
+ this.showPrev = !init && isNext && res.nextReportId ? true : (init ? !!res.previousReportId : !!res.previousPreviousReportId)
+
+ if (!init) {
+ const id = res[isNext ? 'nextReportId' : 'previousReportId']
+ if (id) {
+ this.reportId = id
+ this.$router.push(`/theoryReview?id=${id}&u=${this.showUserInfo}&m=${this.hasManualScoreType}&c=${this.competitionId}&s=${this.stageId}`)
+ this.getData()
+ }
+ }
})
- const id = res[isNext ? 'nextReportId' : 'previousReportId']
- this.showNext = !!res.nextReportId
- this.showPrev = !!res.previousReportId
- if (id) {
- this.reportId = id
- this.$router.push(`/theoryReview?id=${id}&u=${this.showUserInfo}&c=${this.competitionId}&s=${this.stageId}`)
- this.getData()
- }
},
// 一键保存分数
async saveAll () {
@@ -495,6 +539,8 @@ export default {
assignmentDetailId: n.assignmentDetailId,
reviewScore: n.reviewScore,
})
+ n.originUserScore = n.reviewScore
+ this.handleEssayScore(n)
})
})
if (params.length) await this.$post(this.api.reviewPaper, params)
@@ -504,7 +550,7 @@ export default {
}
},
close () {
- window.close()
+ this.handleLeave(window.close)
},
}
};
@@ -833,7 +879,7 @@ export default {
}
.stem {
- max-width: calc(100% - 207px);
+ max-width: calc(100% - 216px);
}
.ques-info {
@@ -853,6 +899,7 @@ export default {
color: #fff;
background-color: #fe9f0a;
transform: rotate(45deg);
+ opacity: .7;
}
}
}