<template>
|
<div>
|
<el-container class="app-item-contain">
|
<el-header class="align-center" v-if="guide">
|
<h1></h1>
|
</el-header>
|
<el-main style="">
|
<div v-html="guideDescirption" v-if="guide" :style="ismobile?'padding-top: 2%;':'padding-top: 2%;margin: 0 auto;width:66%'"></div>
|
<el-row class="do-align-center" v-if="guide">
|
<el-button @click="startDo" type="primary" :disable="startDoDisable">{{$t('start')}}</el-button>
|
</el-row >
|
<el-form :model="form" ref="form" v-loading="formLoading" label-width="100%" v-else>
|
<el-row :key="index" v-for="(titleItem,index) in titleItems" ref="titleItem">
|
<div class="q-content">{{titleItem.description}}</div>
|
<el-card class="exampaper-item-box" style="border:2px solid #2b90ff;" :body-style="{padding: '0px 20px 20px 20px' }">
|
<div class="align-center" style="padding-top:20px;height:50px;position: sticky;top: 0px; z-index: 1; background-color: white;"><span style="font-size: small; float: left">{{$t('examinee')}}{{memberName}}</span><span style="margin-top: 0px;padding-right: 11%">●{{form.name}}●</span><span style="font-size: small; float: right">{{$t('partRemailTime')}}{{formatSecondsG(remainTime,$t('hour'),$t('min'),$t('second'))}}</span></div>
|
<hr style="margin:0px;border : 1px dashed #b3d8ff;position: sticky;top: 50px; z-index: 1; background-color: white;" />
|
<el-form-item :class="(questionItem.questionType==1 && questionItem.template==='intelligence_title')?'fixed-div':''" :key="index" label-width="1px" v-for="(questionItem, index) in questionItems">
|
<QuestionIntelligenceEdit @callNextSubject="onChoice" :qType="questionItem.questionType" :question="questionItem"
|
:answer="answer.answerItems[questionItem.itemOrder-1]" :qLabel="questionItem.questionNumber" :order = "questionItem.itemOrder-1" :displayVal="displayVal"/>
|
</el-form-item>
|
<hr style="border : 0.5px dashed #b3d8ff;" />
|
<div style="color: red;font-size: smaller">{{$t('pleaseAnswerCarefully')}}</div>
|
<el-row class="do-align-center" v-if="order < problemLength">
|
<el-button @click="preSubject" type="warning" v-if ="preDisable" round>{{$t('lastQuestion')}}</el-button>
|
<el-button @click="nextOrder" type="primary" v-if ="nextDisable" round>{{$t('nextQuestion')}}</el-button>
|
<el-button @click="submitClick" type="success" v-if ="submitDisable" round>{{$t('submission')}}</el-button>
|
</el-row>
|
<el-row class="do-align-center" v-else>
|
<el-button @click="preSubject" type="warning" v-if ="preDisable" round>{{$t('lastQuestion')}}</el-button>
|
<el-button @click="submitForm" type="success" v-if ="submitDisable" round>{{$t('submission')}}</el-button>
|
</el-row>
|
</el-card>
|
</el-row>
|
</el-form>
|
|
</el-main>
|
</el-container>
|
<!-- <el-row class="do-exam-title footer"> -->
|
<!-- <el-col :span="24"> -->
|
<!--测试的时候打开-->
|
<!--<span class="do-exam-time">-->
|
<!--<label>{{$t('remainingTime')}}</label>-->
|
<!--<label>{{formatSecondsG(remainTime,$t('hour'),$t('min'),$t('second'))}}</label>-->
|
<!--</span>-->
|
<!-- </el-col> -->
|
<!-- </el-row> -->
|
</div>
|
</template>
|
|
<script>
|
import { mapState, mapGetters, mapMutations } from 'vuex'
|
import { formatSeconds, formatSecondsG, formatDate } from '@/utils'
|
import QuestionIntelligenceEdit from '../components/QuestionIntelligenceEdit'
|
import examPaperApi from '@/api/examPaper'
|
import examPaperAnswerApi from '@/api/examPaperAnswer'
|
import demographyApi from '@/api/demography'
|
|
export default {
|
name: 'intelligence',
|
components: { QuestionIntelligenceEdit },
|
data () {
|
return {
|
form: {},
|
formLoading: false,
|
answer: {
|
questionId: null,
|
doTime: 0,
|
answerItems: [],
|
verifyStatus: 2
|
},
|
timer: null,
|
problemLength: 0,
|
titleItemsLength: 0,
|
remainTime: 999999,
|
titleItemName: '', // 考试第二标题
|
itemOrder: '', // 题目的序号
|
questionItem: {}, // 题目
|
titleItems: [],
|
order: 0,
|
guide: false,
|
answered: [],
|
submitDisable: false,
|
doTime: 0,
|
preDisable: false,
|
nextDisable: true,
|
partOrder: 1,
|
parts: [],
|
guideTitle: '',
|
guideDescirption: '',
|
isCallTain: '',
|
memberName: '',
|
startDoDisable: true,
|
ismobile: false,
|
questionItems: [],
|
isNotToTime: false,
|
originalTime: 0,
|
isSubmiting: false,
|
displayVal: 'block',
|
isSubmitClick: false,
|
timeoutValue: 6
|
}
|
},
|
created: function () {
|
let _this = this
|
window.addEventListener('beforeunload', e => this.beforeunloadFn(e))
|
_this.ismobile = /ipad|iphone|midp|rv:1.2.3.4|ucweb|android|windows ce|windows mobile/.test(navigator.userAgent.toLowerCase())
|
// 多语言
|
_this.setLangFlag(false)
|
_this.form = this.$route.query.formDo
|
if (_this.form !== {} && _this.form !== undefined) {
|
_this.timeReduce()
|
_this.initAnswer()
|
this.initCreate()
|
_this.showNextGuide(false)
|
} else {
|
// 防止刷新成了不同的语言
|
demographyApi.queryDemographyParamInfo(_this.memberToken).then(
|
re => {
|
if (re.response[0].langType !== null || re.response[0].langType.trim() !== '') {
|
_this.setLangType(re.response[0].langType)
|
}
|
// 加载题目
|
examPaperApi.select(_this.memberToken, _this.langType).then(re => {
|
_this.form = re.response
|
_this.initAnswer()
|
examPaperApi.selectTokenId(_this.memberToken).then(re => {
|
_this.answered = re.response.examItemOrderAndContentList
|
_this.remainTime = re.response.remainTime
|
let intelligenceRemainTime = this.getLocalValue('intelligenceRemainTime')
|
if (this.isNotEmpty(intelligenceRemainTime) && intelligenceRemainTime > 0 && intelligenceRemainTime <= _this.remainTime) {
|
_this.remainTime = intelligenceRemainTime
|
}
|
this.initCreate()
|
_this.originalTime = _this.remainTime // 中间变量,原来的时间
|
_this.isNotToTime = true // 先不记时
|
_this.timeReduce()
|
if (_this.answered !== null) {
|
_this.answered.forEach(it => {
|
_this.answer.answerItems[parseInt(it.itemOrder) - 1].content = it.content
|
_this.answer.answerItems[parseInt(it.itemOrder) - 1].completed = true
|
})
|
}
|
for (let i = 0; i < _this.answer.answerItems.length; i++) {
|
if (!_this.answer.answerItems[i].completed || _this.answer.answerItems[i].content === null || _this.answer.answerItems[i].content === '') {
|
_this.questionItem = _this.form.titleItems[0].questionItems[i]
|
_this.partOrder = _this.questionItem.partOrder
|
_this.itemOrder = _this.form.titleItems[0].questionItems[i].itemOrder
|
_this.order = i
|
_this.preDisable = true
|
break
|
}
|
_this.isNotToTime = false
|
|
if (_this.isForFinish(i)) {
|
_this.setSubmiting(true)
|
_this.$router.push({ path: '/exam/finish', query: { name: '', content: _this.$t('finishMsg') } })
|
}
|
}
|
// 如果上一题不是本段,则不能返回上一段
|
if (this.isDiffPartOrder()) {
|
_this.isNotToTime = true
|
_this.preDisable = false
|
}
|
|
if (this.isDiffPartOrder()) {
|
_this.showNextGuide(false)
|
}
|
|
this.determineWhetherIntelligenceTitle()
|
}).catch(e => {
|
// _this.$message.error('题目查询异常')
|
})
|
}).catch(e => {
|
_this.$message.info(_this.$t('noquestionMsg'))
|
})
|
}
|
).catch(e => {
|
})
|
}
|
},
|
updated () {
|
// const elements = document.querySelectorAll('.exampaper-item-box')
|
// if (elements) {
|
// elements.forEach(element => {
|
// if (element) {
|
// element.addEventListener('scroll', this.handleCardScroll, true)
|
// }
|
// })
|
// }
|
},
|
beforeDestroy () {
|
window.clearInterval(this.timer)
|
},
|
destroyed () {
|
window.removeEventListener('beforeunload', e => this.beforeunloadFn(e))
|
},
|
methods: {
|
handleCardScroll (e) {
|
const scrollTop = e.target.scrollTop;
|
const elements = e.target.querySelectorAll('.q-title p img')
|
if (scrollTop > 200) {
|
elements.forEach(element => {
|
element.style.transition = 'width 0.5s ease-in-out'
|
element.style.width = '30%'
|
})
|
}
|
if (scrollTop === 0) {
|
elements.forEach(element => {
|
if (elements.length > 1) {
|
element.style.transition = 'width 0.5s ease-in-out'
|
element.style.width = '50%'
|
} else {
|
element.style.transition = 'width 0.5s ease-in-out'
|
element.style.width = '50%'
|
}
|
})
|
}
|
},
|
beforeunloadFn (e) {
|
if (!this.isSubmiting) {
|
if (this.isLastQuestionOrderNum(this.order)) {
|
this.answer.answerItems[this.order].content = ''
|
this.answer.answerItems[this.order].completed = false
|
}
|
this.submitStage()
|
}
|
},
|
autoChoiceTitleAndSwer: function (order) {
|
let _this = this
|
if (_this.form.titleItems[0].questionItems[order].template === 'intelligence_title') {
|
_this.answer.answerItems[order].content = '1'
|
_this.answer.answerItems[order].completed = true
|
}
|
},
|
doCanNotOption: function (flag) {
|
for (let i = 0; i < this.answer.answerItems.length; i++) {
|
this.answer.answerItems[i].readOnly = flag
|
}
|
},
|
determineWhetherIntelligenceTitle: function () {
|
let _this = this
|
_this.questionItems = []
|
if (_this.remainTime === 0) {
|
this.doCanNotOption(true)
|
}
|
while (_this.isNotEmpty(_this.form.titleItems[0].questionItems[_this.order].parentQuestionId)) {
|
_this.order--
|
// 如果是第一题,上一题不显示了
|
if (_this.order === 0) {
|
_this.preDisable = false
|
}
|
}
|
if (_this.form.titleItems[0].questionItems[_this.order].template === 'intelligence_title') {
|
_this.autoChoiceTitleAndSwer(_this.order)
|
// 答题要放进去先
|
_this.questionItems.push(_this.form.titleItems[0].questionItems[_this.order])
|
let id = _this.form.titleItems[0].questionItems[_this.order].id
|
for (let i = _this.order + 1; i < _this.form.titleItems[0].questionItems.length; i++) {
|
// 后台已经排好顺序了。
|
if (_this.form.titleItems[0].questionItems[i].parentQuestionId !== id.toString()) {
|
break
|
}
|
_this.order = i
|
_this.questionItems.push(_this.form.titleItems[0].questionItems[_this.order])
|
_this.partOrder = _this.form.titleItems[0].questionItems[_this.order].partOrder
|
}
|
|
// 横排还是竖排
|
_this.displayVal = 'block'
|
} else {
|
_this.questionItems.push(_this.form.titleItems[0].questionItems[_this.order])
|
_this.partOrder = _this.form.titleItems[0].questionItems[_this.order].partOrder
|
_this.displayVal = null
|
}
|
// 如果是本段的最后一题,显示提交按钮
|
if (_this.isLastQuestionOrder()) {
|
_this.submitDisable = true
|
} else {
|
_this.submitDisable = false
|
}
|
},
|
initCreate: function () {
|
let _this = this
|
_this.formLoading = true
|
if (_this.isEmpty(_this.remainTime)) {
|
_this.remainTime = _this.form.parts[0].timeOut * 60
|
}
|
_this.problemLength = _this.form.titleItems[0].questionItems.length - 1
|
_this.titleItemsLength = _this.form.titleItems.length
|
_this.titleItems.push(_this.form.titleItems[0])
|
_this.questionItem = _this.form.titleItems[0].questionItems[0]
|
_this.partOrder = _this.questionItem.partOrder
|
_this.itemOrder = _this.form.titleItems[0].questionItems[0].itemOrder
|
_this.formLoading = false
|
_this.memberName = _this.form.memberName
|
_this.questionItems.push(_this.form.titleItems[0].questionItems[0])
|
this.determineWhetherIntelligenceTitle()
|
},
|
formatSeconds (theTime) {
|
return formatSeconds(theTime)
|
},
|
formatSecondsG (theTime, hour, min, second) {
|
return formatSecondsG(theTime, hour, min, second)
|
},
|
formatDate (time, formatsrc) {
|
return formatDate(time, formatsrc)
|
},
|
// 进入第二段的时候,把第一段没有答的都答一下。
|
setPartDefaulAnswer: function (answerSubmit) {
|
let _this = this
|
answerSubmit.answerItems.forEach(it => {
|
if (_this.partOrder > it.partOrder && it.content === null) {
|
it.content = '0'
|
}
|
})
|
},
|
submitNextSubject: function (answerSubmit, nowPartOrder) {
|
let _this = this
|
_this.setSubmiting(true)
|
// _this.setPartDefaulAnswer(answerSubmit)
|
examPaperAnswerApi.answerSubmit(answerSubmit, _this.memberToken).then(re => {
|
_this.formLoading = false // 控制不转圈
|
_this.setSubmiting(false)
|
if (re.code === 1) {
|
// 跳到下一段
|
if (!_this.isNull(re.response) && re.response.jump === 'next') {
|
}
|
} else {
|
_this.$message.error(re.message)
|
}
|
// 展示指导语
|
if (_this.isNextShowGuide(nowPartOrder)) {
|
// 展示指导语
|
_this.showNextGuide(true)
|
} else {
|
_this.nextQuestionOrder(nowPartOrder)
|
}
|
}).catch(e => {
|
_this.reloadPage(e)
|
})
|
},
|
submitStage: function () {
|
let _this = this
|
let nowPartOrder = _this.partOrder
|
let answerSubmit = _this.getSubmitAnswerValue(nowPartOrder)
|
_this.preDisable = false
|
_this.questionItems = []
|
this.submitNextSubject(answerSubmit, nowPartOrder)
|
},
|
timeOutNextPart: function () {
|
let _this = this
|
// 自动跳到下一段
|
let questionNum = 0
|
while (_this.isLastQuestionOrderNum(questionNum) || _this.form.titleItems[0].questionItems[questionNum].partOrder <= _this.partOrder) {
|
if (!_this.isContentNotEmpty(questionNum)) {
|
_this.answer.answerItems[questionNum].content = '0'
|
_this.answer.answerItems[questionNum].completed = true
|
}
|
if (_this.isLastQuestionOrderNum(questionNum)) {
|
_this.answer.finish = _this.timeoutValue
|
_this.submitForm()
|
return
|
}
|
_this.order = questionNum++
|
}
|
// if (!_this.isContentNotEmpty(_this.order)) {
|
// _this.answer.answerItems[_this.order].content = '0'
|
// _this.answer.answerItems[_this.order].completed = true
|
// }
|
this.submitStage()
|
_this.isNotToTime = true
|
},
|
setLocalValue: function (key, value) {
|
localStorage.setItem(key, value)
|
},
|
getLocalValue: function (key) {
|
return localStorage.getItem(key)
|
},
|
removeLocalValue: function (key) {
|
localStorage.removeItem(key)
|
},
|
timeReduce: function () {
|
let _this = this
|
_this.answer.doTime += _this.doTime
|
_this.remainTime -= _this.doTime
|
this.timer = setInterval(function () {
|
if (_this.isNotToTime) {
|
_this.remainTime = 0
|
} else if (_this.remainTime <= 0) {
|
_this.remainTime = 0
|
++_this.answer.doTime
|
_this.formLoading = true
|
_this.originalTime = 0 // 跳到下一段之后,就不能用后台返回的时间了
|
_this.timeOutNextPart()
|
} else {
|
++_this.answer.doTime
|
--_this.remainTime
|
}
|
// 测试的时候去掉
|
_this.setLocalValue('intelligenceRemainTime', _this.remainTime)
|
}, 1000)
|
},
|
questionCompleted (completed) {
|
return this.enumFormat(this.doCompletedTag, completed)
|
},
|
goAnchor (selector) {
|
let _this = this
|
let num = parseInt(selector.substr(10)) - 1
|
this.itemOrder = _this.form.titleItems[0].questionItems[num].itemOrder
|
this.questionItem = _this.form.titleItems[0].questionItems[num]
|
_this.order = num
|
setTimeout(function () {
|
_this.$el.querySelector(selector).scrollIntoView({ behavior: 'instant', block: 'center', inline: 'nearest' })
|
}, 200)
|
_this.$refs['popovertag'].doClose()
|
},
|
initAnswer () {
|
this.answer.id = this.form.id
|
this.answer.questionOrder = this.form.questionOrder
|
this.answer.optionOrder = this.form.optionOrder
|
let titleItemArray = this.form.titleItems
|
for (let tIndex in titleItemArray) {
|
let questionArray = titleItemArray[tIndex].questionItems
|
for (let qIndex in questionArray) {
|
let question = questionArray[qIndex]
|
this.answer.answerItems.push({ title: question.title, permanentId: question.permanentId, questionId: question.id, content: null, contentArray: [], completed: false, itemOrder: question.itemOrder, lastContent: null, startTime: question.startTime, endTime: question.endTime, partOrder: question.partOrder, questionReport: {}, readOnly: false })
|
}
|
}
|
|
// 初始化开始时间,设置第一个时间
|
for (let i = 0; i < this.answer.answerItems.length; i++) {
|
if (this.answer.answerItems[i].startTime == null || this.answer.answerItems[i].startTime.trim() === '') {
|
this.answer.answerItems[i].startTime = this.formatDate(new Date(), 'yyyy-MM-dd hh:mm:ss')
|
break
|
}
|
}
|
},
|
isContentNotEmpty: function (num) {
|
let _this = this
|
return _this.answer.answerItems[num].content !== '' && _this.answer.answerItems[num].content !== null && _this.answer.answerItems[num].content.trim() !== ''
|
},
|
nextQuestion: function (nowPartOrder) {
|
let _this = this
|
let num = _this.order + 1
|
// 跳到没有答的题目的段
|
while (_this.isContentNotEmpty(num) && num !== _this.answer.answerItems.length - 1) {
|
num = _this.order + 1
|
this.getEmptySubjct(num)
|
}
|
this.determineWhetherIntelligenceTitle()
|
if (_this.partOrder !== nowPartOrder) {
|
_this.isShowGuide(true)
|
}
|
_this.preDisable = true
|
_this.isShowNextQuestionButton(_this)
|
_this.answer.answerItems[_this.order].startTime = _this.formatDate(new Date(), 'yyyy-MM-dd hh:mm:ss')
|
|
// 如果是最后一个并且已经完成了,就提交
|
if (num === _this.answer.answerItems.length - 1 && _this.isForFinish(num)) {
|
this.submitForm()
|
}
|
},
|
nextQuestionOrder: function (nowPartOrder) {
|
if (this.order < this.problemLength) {
|
this.nextQuestion(nowPartOrder)
|
}
|
},
|
isNextShowGuide: function (nowPartOrder) {
|
let _this = this
|
// 本段的每一题都打完要指导语
|
let showGuideFlag = true
|
for (let i = 0; i < _this.answer.answerItems.length; i++) {
|
if (_this.form.titleItems[0].questionItems[i].partOrder === nowPartOrder && !_this.isContentNotEmpty(i)) {
|
showGuideFlag = false
|
}
|
}
|
return showGuideFlag
|
},
|
catThaiSubmit: function (answerSubmit) {
|
answerSubmit.isCallTain = 'CallThai'
|
},
|
getEmptySubjct: function (order) {
|
let _this = this
|
_this.itemOrder = _this.form.titleItems[0].questionItems[order].itemOrder
|
_this.questionItem = _this.form.titleItems[0].questionItems[order]
|
_this.partOrder = _this.questionItem.partOrder
|
_this.preDisable = false
|
_this.order = order
|
_this.determineWhetherIntelligenceTitle()
|
},
|
onChoice () { // 是否显示提交按钮
|
if (this.isLastQuestionOrder()) {
|
return
|
}
|
this.isShowNextQuestionButton(this)
|
},
|
// 下一题
|
nextSubject: function (data) {
|
let _this = this
|
_this.isShowGuide(false)
|
let nowPartOrder = _this.partOrder
|
// 设置上一题的结束时间
|
this.answer.answerItems[data[0]].endTime = _this.formatDate(new Date(), 'yyyy-MM-dd hh:mm:ss')
|
// 跳到还没完成的拿到题的
|
let complateOrder = _this.order
|
// 停留在这道题
|
if (_this.form.titleItems[0].questionItems[_this.order].parentQuestionId !== '') {
|
complateOrder++
|
}
|
for (let i = 0; i < complateOrder; i++) {
|
if (!_this.isContentNotEmpty(i)) {
|
return
|
}
|
}
|
// 循环没有答的题目
|
for (let i = 0; i < _this.order; i++) {
|
if (!this.isContentNotEmpty(i)) {
|
// 返回之前没做的那道题
|
this.getEmptySubjct(i)
|
return
|
}
|
// 如果循环到最后一题就提交
|
if (_this.isForFinish(i)) {
|
_this.submitForm()
|
return
|
}
|
}
|
|
// 全部答完了就可以提交了,但是如果是最后一题就自己提交
|
for (let i = 0; i < _this.answer.answerItems.length; i++) {
|
if (!_this.isContentNotEmpty(i)) {
|
break
|
}
|
if (i === _this.answer.answerItems.length - 1 && _this.order !== _this.answer.answerItems.length - 1) {
|
_this.submitForm()
|
return
|
}
|
}
|
// this.answer.answerItems[_this.order].readOnly = true
|
let answerSubmit = _this.getSubmitAnswerValue(nowPartOrder)
|
// 已经答到了最后一题了,不用自动跳到下一题
|
if (this.order + 1 > this.problemLength) {
|
return
|
}
|
_this.preDisable = false
|
this.submitNextSubject(answerSubmit, nowPartOrder)
|
},
|
isLastQuestionOrder: function () {
|
let _this = this
|
return _this.order >= _this.form.titleItems[0].questionItems.length - 1
|
},
|
isLastQuestionOrderNum: function (num) {
|
let _this = this
|
return num >= _this.form.titleItems[0].questionItems.length - 1
|
},
|
isSamePartOrder: function () {
|
return this.form.titleItems[0].questionItems[this.order].partOrder === this.form.titleItems[0].questionItems[this.order + 1].partOrder
|
},
|
isPreSamePartOrder: function () {
|
if (this.isEmpty(this.form.titleItems[0].questionItems[this.order - 1])) {
|
return false
|
}
|
return this.form.titleItems[0].questionItems[this.order].partOrder === this.form.titleItems[0].questionItems[this.order - 1].partOrder
|
},
|
isShowNextQuestionButton: function (_this) {
|
if (_this.isLastQuestionOrder()) {
|
_this.nextDisable = false
|
return
|
}
|
_this.nextDisable = true
|
},
|
isFinishThisPart () {
|
for (let i = 0; i <= this.order; i++) {
|
if (!this.isContentNotEmpty(i)) {
|
return false
|
}
|
}
|
return true
|
},
|
nextOrder () {
|
let _this = this
|
_this.order++
|
// 如果是已经完成本段,提交展示指导语
|
if (_this.isPreSamePartOrder(this)) {
|
_this.preDisable = true
|
} else {
|
_this.preDisable = false
|
}
|
_this.determineWhetherIntelligenceTitle()
|
// 展示指导语
|
if (_this.isDiffPartOrder()) {
|
this.showGuideDetail()
|
this.submitStage() // 跳到下一段的时候,关闭浏览器有保存不上的现象,所以这里中途保存一下
|
}
|
_this.isShowNextQuestionButton(_this)
|
},
|
getSubmitAnswerValue (nowPartOrder) {
|
let _this = this
|
let answerSubmit = JSON.parse(JSON.stringify(_this.answer))
|
answerSubmit.answerItems.forEach(answerItem => {
|
// 题目报表,如果没有结束时间,开始时间也不需要
|
if (answerItem.endTime == null || answerItem.endTime === '') {
|
answerItem.startTime = ''
|
}
|
answerItem.questionReport = { questionOrder: answerItem.questionId, questionTitle: answerItem.title, permanentId: answerItem.permanentId, startTime: answerItem.startTime, endTime: answerItem.endTime, langType: _this.langType, partOrder: answerItem.partOrder, answer: answerItem.content }
|
})
|
answerSubmit.langType = _this.langType
|
answerSubmit.isCallTain = _this.isCallTain
|
answerSubmit.partOrder = nowPartOrder
|
answerSubmit.itemOrder = _this.itemOrder
|
answerSubmit.remainTime = _this.remainTime
|
answerSubmit.submitClick = _this.isSubmitClick
|
return answerSubmit
|
},
|
preSubject () {
|
let _this = this
|
_this.isShowGuide(false)
|
if (_this.order <= 0) {
|
_this.preDisable = false
|
return
|
}
|
--this.order
|
// 循环一直找到上一题
|
if (_this.isNotEmpty(_this.form.titleItems[0].questionItems[_this.order].parentQuestionId)) {
|
while (_this.isNotEmpty(_this.form.titleItems[0].questionItems[_this.order].parentQuestionId) && _this.form.titleItems[0].questionItems[_this.order].template !== 'intelligence_title') {
|
--this.order
|
}
|
--this.order
|
// 回到上一题的上一题
|
while (_this.isNotEmpty(_this.form.titleItems[0].questionItems[_this.order].parentQuestionId) && _this.form.titleItems[0].questionItems[_this.order].template !== 'intelligence_title') {
|
--this.order
|
}
|
}
|
// 控制回到上一题的按钮的出现
|
if (_this.order > 0 && _this.form.titleItems[0].questionItems[_this.order].partOrder === _this.form.titleItems[0].questionItems[_this.order - 1].partOrder) {
|
_this.preDisable = true
|
} else {
|
_this.preDisable = false
|
}
|
_this.determineWhetherIntelligenceTitle()
|
_this.isShowNextQuestionButton(_this)
|
},
|
isNotEmpty (obj) {
|
return obj !== null && obj !== undefined && obj !== ''
|
},
|
isEmpty (obj) {
|
return !this.isNotEmpty(obj)
|
},
|
submitClick () {
|
let _this = this
|
_this.isSubmitClick = true
|
_this.$confirm(_this.$t('unfinish'), {
|
title: _this.$t('prompt'),
|
confirmButtonText: _this.$t('determine'),
|
cancelButtonText: _this.$t('cancel'),
|
showClose: false
|
}).then(async () => {
|
_this.submitForm()
|
}).catch(async () => {
|
})
|
},
|
submitForm () {
|
let _this = this
|
_this.submitDisable = false
|
window.clearInterval(_this.timer)
|
_this.formLoading = true
|
if (_this.answer.finish === _this.timeoutValue) {
|
_this.answer.verifyStatus = 1
|
_this.submitAnswer(_this.$t('timeOutSubmit'))
|
} else {
|
_this.answer.verifyStatus = 1
|
_this.answer.finish = 1
|
for (let i = 0; i < _this.answer.answerItems.length; i++) {
|
if (_this.answer.answerItems[i].content === null) {
|
_this.answer.answerItems[i].content = '0'
|
}
|
}
|
_this.submitAnswer(_this.$t('finishIntelligenceInfo'))
|
}
|
},
|
startDo: function () {
|
let _this = this
|
_this.guide = false
|
_this.isCallTain = ''
|
_this.isNotToTime = false
|
// _this.originalTime 跳到下一段之后会返回0的
|
_this.remainTime = _this.originalTime !== 0 ? _this.originalTime : _this.form.parts[_this.partOrder - 1].timeOut * 60
|
this.doCanNotOption(false)
|
},
|
isTimeoutFinish: function () { // 超时提交
|
let _this = this
|
return _this.answer.finish === _this.timeoutValue
|
},
|
submitAnswer: function (mess) {
|
let _this = this
|
this.answer.answerItems[_this.order].endTime = this.formatDate(new Date(), 'yyyy-MM-dd hh:mm:ss')
|
// 提交之前提交最后一段
|
let answerSubmit = _this.getSubmitAnswerValue(_this.partOrder)
|
_this.catThaiSubmit(answerSubmit)
|
let loading = _this.$loading({
|
lock: false,
|
text: _this.$t('uploadInfo'),
|
spinner: 'el-icon-loading'
|
})
|
// 超时马上返回
|
if (this.isTimeoutFinish()) {
|
loading.close()
|
_this.$router.push({ path: '/exam/finish', query: { name: _this.form.name, content: mess } })
|
}
|
_this.setSubmiting(true)
|
examPaperAnswerApi.answerSubmit(answerSubmit, _this.memberToken).then(re => {
|
this.removeLocalValue('intelligenceRemainTime')
|
if (re.code === 1) {
|
loading.close()
|
if (re.response.signalObject.code === 'fail') {
|
_this.$router.push({
|
path: '/exam/exception',
|
query: { name: _this.form.name, content: _this.$t('submitExceptionInfo') }
|
})
|
return
|
}
|
if (this.isTimeoutFinish()) {
|
return
|
}
|
// 特殊处理 LAQ测试包 结束提示语
|
if (_this.form.name.indexOf('LAQ') !== -1) {
|
_this.$router.push({ path: '/exam/finish', query: { name: _this.form.name, content: _this.$t('finishMsg') } })
|
return
|
}
|
_this.$router.push({ path: '/exam/finish', query: { name: _this.form.name, content: mess } })
|
} else {
|
_this.$message.error(re.message + '/exam/finish')
|
}
|
_this.formLoading = false
|
}).catch(e => {
|
_this.reloadPage(e)
|
loading.close()
|
})
|
},
|
setSubmiting (flag) {
|
this.isSubmiting = flag
|
},
|
guideView: function () {
|
// 数组的下标要减1
|
let _this = this
|
if (_this.isNotEmpty(_this.guideDescirption)) {
|
_this.isNotToTime = true
|
_this.isShowGuide(true)
|
_this.preDisable = false
|
} else {
|
_this.isShowGuide(false)
|
_this.preDisable = false
|
}
|
},
|
showGuideDetail: function () {
|
let _this = this
|
if (_this.form.parts[_this.partOrder - 1].signals.length > 0) {
|
_this.guideDescirption = _this.form.parts[_this.partOrder - 1].signals[0].signalDescription
|
}
|
// 指导语展示
|
_this.guideView()
|
_this.startDoDisable = false
|
},
|
showNextGuide: function (nextQuestion) {
|
let _this = this
|
if (!nextQuestion) {
|
this.showGuideDetail()
|
return
|
}
|
_this.isShowGuide(true)
|
_this.nextQuestionOrder()
|
this.showGuideDetail()
|
},
|
isNull: function (obj) {
|
return obj === null || obj === undefined
|
},
|
isShowGuide (flag) {
|
let _this = this
|
_this.guide = flag
|
},
|
reloadPage (e) {
|
let _this = this
|
let mes = ''
|
if (e.message !== null && e.message !== undefined && e.message.indexOf('timeout') !== -1) {
|
mes = _this.$t('submitTimeout') + ',' + 'order:' + _this.order + ',' + e.message// 提交后台超时
|
} else {
|
mes = JSON.stringify(e) + ',' + 'order:' + _this.order + ',' + e.message
|
}
|
// 调试用
|
// _this.$router.push({ path: '/exam/exception', query: { name: _this.form.name, content: _this.$t('submitExceptionInfo') + '<br>' + mes } })
|
_this.$router.push({ path: '/exam/exception', query: { name: _this.form.name, content: _this.$t('submitExceptionInfo') } })
|
_this.formLoading = false
|
},
|
isForFinish (i) {
|
return i === this.answer.answerItems.length - 1 && (this.answer.answerItems[i].content !== null && this.answer.answerItems[i].content !== '')
|
},
|
isDiffPartOrder: function () {
|
let _this = this
|
return _this.form.titleItems[0].questionItems[_this.order].partOrder !== _this.form.titleItems[0].questionItems[_this.order - 1].partOrder
|
},
|
isLastPartOrder: function () {
|
let _this = this
|
// 最后一题和第一题不显示提交按钮
|
if (_this.isEmpty(_this.form.titleItems[0].questionItems[_this.order + 1]) || _this.form.titleItems[0].questionItems[_this.order].partOrder === 0) {
|
return false
|
}
|
return _this.form.titleItems[0].questionItems[_this.order].partOrder !== _this.form.titleItems[0].questionItems[_this.order + 1].partOrder
|
},
|
...mapMutations('user', ['setLangType']),
|
...mapMutations('user', ['setLangFlag'])
|
},
|
computed: {
|
...mapGetters('enumItem', ['enumFormat']),
|
...mapState('enumItem', { doCompletedTag: state => state.exam.question.answer.doCompletedTag }),
|
...mapState('user', { memberToken: state => state.memberToken }),
|
...mapState('user', { langType: state => state.langType }),
|
...mapState('user', { langFlag: state => state.langFlag }),
|
...mapState('exam', { doUrl: state => state.doUrl })
|
}
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
.align-center {
|
text-align: center;
|
}
|
|
.exam-question-item {
|
padding: 10px;
|
font-size: large;
|
|
.el-form-item__label {
|
font-size: large !important;
|
}
|
}
|
|
.question-title-padding {
|
padding-left: 25px;
|
padding-right: 25px;
|
}
|
.footer {
|
position: absolute;
|
position: fixed;
|
z-index: 1000;
|
bottom: 0px;
|
}
|
|
.exampaper-item-box {
|
position: relative;
|
overflow-y: auto; /* 允许内容滚动 */
|
height: calc(100vh - 110px); /* 根据需要设置盒子的最大高度 */
|
}
|
|
.fixed-div {
|
position: sticky;
|
top: 51px; /* 固定在盒子的顶部 */
|
background-color: white; /* 背景颜色以覆盖滚动内容 */
|
z-index: 1; /* 确保标题在滚动时高于其他内容 */
|
border-bottom: 1px dotted #ccc;
|
}
|
</style>
|