提交 5847a4fe authored 作者: 王鹏飞's avatar 王鹏飞

bug fixes

上级 a201ddd6
...@@ -89,7 +89,6 @@ export default { ...@@ -89,7 +89,6 @@ export default {
countdownTimer: null, // 倒计时计时器 countdownTimer: null, // 倒计时计时器
countdownText: '', // 倒计时显示时间 countdownText: '', // 倒计时显示时间
questionGroups: this.groups, // 所有试题分组,一组一页 questionGroups: this.groups, // 所有试题分组,一组一页
questionCount: 0, // 小题数量
currentGroupPage: this.groupPage, // 大题页码 currentGroupPage: this.groupPage, // 大题页码
currentGroupCount: this.groupPageCount // 大题总页数 currentGroupCount: this.groupPageCount // 大题总页数
} }
...@@ -131,15 +130,17 @@ export default { ...@@ -131,15 +130,17 @@ export default {
}, },
watch: { watch: {
data: { data: {
deep: true, immediate: true,
handler(data) { handler(data) {
data && this.dataInit(data) data && this.dataInit(data)
} }
}, },
groups: { groups: {
immediate: true,
handler(groups) { handler(groups) {
this.questionGroups = groups if (groups.length) {
this.questionCount = groups.length this.questionGroups = groups
}
} }
}, },
groupPage(value) { groupPage(value) {
...@@ -245,7 +246,6 @@ export default { ...@@ -245,7 +246,6 @@ export default {
const isSubmited = ['1', '2'].includes(data.status) const isSubmited = ['1', '2'].includes(data.status)
this.disabled = isSubmited this.disabled = isSubmited
this.hasResult = isSubmited this.hasResult = isSubmited
this.questionCount = data.questions.total_question_count
this.genQuestions(data) this.genQuestions(data)
this.currentGroupCount = this.questionGroups.length this.currentGroupCount = this.questionGroups.length
if (this.$route.query.id) { if (this.$route.query.id) {
...@@ -262,24 +262,28 @@ export default { ...@@ -262,24 +262,28 @@ export default {
const { questions, answers = {} } = data const { questions, answers = {} } = data
if (!questions) return [] if (!questions) return []
this.questionGroups = questions.question_items.reduce((result, question) => { this.questionGroups = questions.question_items.reduce((result, question) => {
question.question_list.forEach(list => { if (question.question_list.length) {
list = list.map(item => { question.question_list.forEach(list => {
let userAnswers = [] list = list.map(item => {
let sign = false let userAnswers = []
if (answers) { let sign = false
// 大题答案包含所有小题答案 if (answers) {
const bigQuestionAnswer = answers[question.question_item_id] // 大题答案包含所有小题答案
if (bigQuestionAnswer) { const bigQuestionAnswer = answers[question.question_item_id]
// 小题答案 if (bigQuestionAnswer) {
const questionAnswer = bigQuestionAnswer[item.id] || {} // 小题答案
userAnswers = questionAnswer.answer || [] const questionAnswer = bigQuestionAnswer[item.id] || {}
sign = questionAnswer.sign || false userAnswers = questionAnswer.answer || []
sign = questionAnswer.sign || false
}
} }
} return { ...item, user_answer: userAnswers, sign }
return { ...item, user_answer: userAnswers, sign } })
result.push(Object.assign({}, question, { question_list: list }))
}) })
result.push(Object.assign({}, question, { question_list: list })) } else {
}) result.push(Object.assign({}, question, { question_list: [] }))
}
return result return result
}, []) }, [])
}, },
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论