提交 fe34fc16 authored 作者: lihuihui's avatar lihuihui
...@@ -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) {
if (groups.length) {
this.questionGroups = groups this.questionGroups = groups
this.questionCount = groups.length }
} }
}, },
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,6 +262,7 @@ export default { ...@@ -262,6 +262,7 @@ 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) => {
if (question.question_list.length) {
question.question_list.forEach(list => { question.question_list.forEach(list => {
list = list.map(item => { list = list.map(item => {
let userAnswers = [] let userAnswers = []
...@@ -280,6 +281,9 @@ export default { ...@@ -280,6 +281,9 @@ export default {
}) })
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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论