|
|
|
@ -3,7 +3,7 @@ |
|
|
|
<navbar title="答题测评" leftClick @leftClick="$utils.navigateBack" bgColor="transparent" /> |
|
|
|
|
|
|
|
<!-- 答题完成 --> |
|
|
|
<template v-if="current === total"> |
|
|
|
<template v-if="total && current === total"> |
|
|
|
<view class="flex main is-finish"> |
|
|
|
<view class="card"> |
|
|
|
<image class="card-bg" src="@/pages_order/static/test/bg-test-finsih.png" mode="widthFix"></image> |
|
|
|
@ -42,30 +42,16 @@ |
|
|
|
<view class="question">{{ currentQuestion.question }}</view> |
|
|
|
</view> |
|
|
|
<view class="card-content"> |
|
|
|
<template v-if="currentQuestion.component === 'select'"> |
|
|
|
<view class="select"> |
|
|
|
<view |
|
|
|
v-for="item in currentQuestion.options" |
|
|
|
:key="item.id" |
|
|
|
:class="['select-option', item.id === value ? 'is-active' : '']" |
|
|
|
@click="onSelect(item.id)" |
|
|
|
> |
|
|
|
{{ item.content }} |
|
|
|
</view> |
|
|
|
<view class="select"> |
|
|
|
<view |
|
|
|
v-for="item in currentQuestion.options" |
|
|
|
:key="item.id" |
|
|
|
:class="['select-option', item.id === value ? 'is-active' : '']" |
|
|
|
@click="onSelect(item.id)" |
|
|
|
> |
|
|
|
{{ item.content }} |
|
|
|
</view> |
|
|
|
</template> |
|
|
|
<template v-else-if="currentQuestion.component === 'select-multiple'"> |
|
|
|
<view class="select"> |
|
|
|
<view |
|
|
|
v-for="item in currentQuestion.options" |
|
|
|
:key="item.id" |
|
|
|
:class="['select-option', value.includes(item.id) ? 'is-active' : '']" |
|
|
|
@click="onSelectMulitple(item.id)" |
|
|
|
> |
|
|
|
{{ item.content }} |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</template> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
|
|
|
|
@ -82,8 +68,6 @@ |
|
|
|
</template> |
|
|
|
|
|
|
|
<script> |
|
|
|
import { mapState } from 'vuex' |
|
|
|
|
|
|
|
export default { |
|
|
|
data() { |
|
|
|
return { |
|
|
|
@ -91,7 +75,6 @@ |
|
|
|
tabs: [], |
|
|
|
value: null, |
|
|
|
answers: [], |
|
|
|
paperTags: [], |
|
|
|
batchNo: null, |
|
|
|
questionsList: [], |
|
|
|
total: 0, |
|
|
|
@ -113,65 +96,42 @@ |
|
|
|
}, |
|
|
|
}, |
|
|
|
onLoad(arg) { |
|
|
|
this.fetchQuestionList() |
|
|
|
this.switchQuestion(parseInt(arg.current || 0)) |
|
|
|
const { ids, examId, current } = arg |
|
|
|
this.current = parseInt(current || 0) |
|
|
|
this.fetchQuestionList(ids, examId) |
|
|
|
this.value = this.answers[this.current] |
|
|
|
|
|
|
|
console.log('paperTags', this.paperTags) |
|
|
|
console.log('currentQuestion', this.currentQuestion) |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
async fetchQuestionList(categories) { |
|
|
|
async fetchQuestionList(categories, examId) { |
|
|
|
|
|
|
|
const result = await this.$fetch('queryQuestionList', { categories }) |
|
|
|
let result |
|
|
|
|
|
|
|
// todo: set batchNo |
|
|
|
if (examId) { |
|
|
|
result = await this.$fetch('queryExamById', { examId }) |
|
|
|
} else { |
|
|
|
result = await this.$fetch('queryQuestionList', { categories }) |
|
|
|
} |
|
|
|
|
|
|
|
// todo: transfer |
|
|
|
const questionsList = new Array(23).fill(1).map((item, index) => { |
|
|
|
const id = `00${index}` |
|
|
|
const { batchNo, pageList } = result |
|
|
|
|
|
|
|
return { |
|
|
|
id, |
|
|
|
text: '问题内容文字问题内容文字问题内容文字问题内容文字问题内容文字?', |
|
|
|
type: '0', |
|
|
|
options: new Array(4).fill(1).map((option, oIdx) => { |
|
|
|
return { |
|
|
|
id: `${id}${oIdx}`, |
|
|
|
content: '答案内容', |
|
|
|
} |
|
|
|
}), |
|
|
|
} |
|
|
|
}) |
|
|
|
this.batchNo = batchNo |
|
|
|
|
|
|
|
this.questionsList = questionsList.map((item, index) => { |
|
|
|
const { id, text, type, options, needTag, required, multiple: _multiple, content } = item |
|
|
|
|
|
|
|
let component = 'select' |
|
|
|
const multiple = _multiple == 'Y' |
|
|
|
|
|
|
|
switch(type) { // 0-单选题 1-填空题 2-图片单选题 |
|
|
|
case '1': |
|
|
|
component = options?.length > 1 ? 'input-group' : 'input' |
|
|
|
break |
|
|
|
case '2': |
|
|
|
component = multiple ? 'select-box-multiple' : 'select-box' |
|
|
|
break |
|
|
|
default: |
|
|
|
component = multiple ? 'select-multiple' : 'select' |
|
|
|
break |
|
|
|
} |
|
|
|
this.questionsList = pageList.map((item, index) => { |
|
|
|
const { id, question, answerList } = item |
|
|
|
|
|
|
|
return { |
|
|
|
id, |
|
|
|
question: `${index + 1}、${text}`, |
|
|
|
type, |
|
|
|
component, |
|
|
|
options: options.map((option, oIdx) => ({ id: option.id, content: `${String.fromCharCode(oIdx+65)}、${option.content}` })), |
|
|
|
needTag: needTag ? JSON.parse(needTag).map(config => config.tags).filter(tags => tags.length) : null, |
|
|
|
required: required == 'Y', |
|
|
|
multiple, |
|
|
|
desc: content, |
|
|
|
// question: `${index + 1}、${question}`, |
|
|
|
question, |
|
|
|
options: answerList.map((option, oIdx) => { |
|
|
|
return { |
|
|
|
id: option.id, |
|
|
|
// content: `${String.fromCharCode(oIdx+65)}、${option.answer}` |
|
|
|
content: `${option.answerNo}、${option.answer}` |
|
|
|
} |
|
|
|
}), |
|
|
|
} |
|
|
|
}) |
|
|
|
this.total = this.questionsList.length |
|
|
|
@ -181,50 +141,10 @@ |
|
|
|
console.log('questionsList', this.questionsList) |
|
|
|
console.log('answers', this.answers) |
|
|
|
}, |
|
|
|
switchQuestion(current) { |
|
|
|
console.log('current', this.current, 'target', current) |
|
|
|
let { needTag } = this.questionsList[current] |
|
|
|
|
|
|
|
console.log('needTag length', needTag?.length) |
|
|
|
if (!needTag?.length) { |
|
|
|
this.current = current |
|
|
|
this.tabs.push(this.current) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
const selectTags = this.paperTags.flat(1) |
|
|
|
console.log('selectTags', selectTags) |
|
|
|
console.log('needTag', needTag) |
|
|
|
|
|
|
|
let valid = needTag.some(tags => { |
|
|
|
return tags.every(tag => { |
|
|
|
const { value, exclude } = tag |
|
|
|
|
|
|
|
let include = selectTags.includes(value) |
|
|
|
|
|
|
|
return exclude ? !include : include |
|
|
|
}) |
|
|
|
}) |
|
|
|
console.log('valid', valid) |
|
|
|
|
|
|
|
if (valid) { |
|
|
|
this.current = current |
|
|
|
this.tabs.push(this.current) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
if (current + 1 < this.questionsList.length) { |
|
|
|
current += 1 |
|
|
|
this.switchQuestion(current) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
this.fetchFinish() |
|
|
|
}, |
|
|
|
async fetchAnswer() { |
|
|
|
try { |
|
|
|
|
|
|
|
const { id: questionsId, type, required, multiple, options } = this.currentQuestion |
|
|
|
const { id: questionId } = this.currentQuestion |
|
|
|
|
|
|
|
console.log('currentQuestion', this.currentQuestion) |
|
|
|
console.log('value', this.value) |
|
|
|
@ -240,7 +160,7 @@ |
|
|
|
|
|
|
|
let params = { |
|
|
|
batchNo: this.batchNo, |
|
|
|
questionsId, |
|
|
|
questionId, |
|
|
|
answerId: this.value, |
|
|
|
} |
|
|
|
await this.$fetch('updateAnswer', params) |
|
|
|
@ -279,7 +199,7 @@ |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
this.switchQuestion(this.current + 1) |
|
|
|
this.current += 1 |
|
|
|
this.value = this.answers[this.current] |
|
|
|
}, |
|
|
|
async finish() { |
|
|
|
@ -298,7 +218,7 @@ |
|
|
|
this.value = this.value.includes(id) ? this.value.filter(item => item !== id) : this.value.concat(id) |
|
|
|
}, |
|
|
|
onCreateReport() { |
|
|
|
uni.navigateTo({ |
|
|
|
uni.redirectTo({ |
|
|
|
url: `/pages_order/report/pay?batchNo=${this.batchNo}` |
|
|
|
}) |
|
|
|
}, |
|
|
|
@ -463,10 +383,20 @@ |
|
|
|
|
|
|
|
.card { |
|
|
|
min-height: 745rpx; |
|
|
|
padding: 0; |
|
|
|
|
|
|
|
&-bg { |
|
|
|
width: 100%; |
|
|
|
height: auto; |
|
|
|
} |
|
|
|
|
|
|
|
&-content { |
|
|
|
position: absolute; |
|
|
|
top: 0; |
|
|
|
left: 0; |
|
|
|
justify-content: flex-end; |
|
|
|
width: 100%; |
|
|
|
height: 100%; |
|
|
|
padding: 69rpx 94rpx; |
|
|
|
box-sizing: border-box; |
|
|
|
|
|
|
|
|