[测评系统]--前端(用户答题页面)
yj
2024-05-07 6ad528944f24daec8547126bf591868a00b1176a
src/views/exam/paper/personality.vue
@@ -16,14 +16,14 @@
              <div class="align-center"><span style="font-size: small; float: left">{{$t('examinee')}}{{memberName}}</span><span style="margin-top: 0px;padding-right: 11%">●{{form.name}}●</span></div>
              <hr style="border : 1px dashed #b3d8ff;" />
              <el-form-item :key="itemOrder" label-width="1px">
                <QuestionEdit @callNextSubject="nextSubject" :qType="questionItem.questionType" :question="questionItem"
                <QuestionEdit @callSelected="callSelected" @callNextSubject="nextSubject" :qType="questionItem.questionType" :question="questionItem"
                              :answer="answer.answerItems[questionItem.itemOrder-1]" :qLabel="itemOrder+'/'+itemSize"/>
              </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="nextSubject" type="primary" v-if ="nextDisable" round>{{$t('nextQuestion')}}</el-button>
            <el-button @click="preSubject" type="warning"  v-if ="preDisable" :disabled="preDisable2" round>{{$t('lastQuestion')}}</el-button>
            <el-button @click="nextSubject" type="primary" v-if ="nextDisable" :disabled="nextDisable2" round>{{$t('nextQuestion')}}</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>
@@ -88,7 +88,9 @@
      submitDisable: true,
      doTime: 0,
      preDisable: false,
      preDisable2: false,
      nextDisable: false,
      nextDisable2: false,
      partOrder: 0,
      parts: [],
      guideTitle: '',
@@ -142,12 +144,10 @@
            _this.initAnswer()
            _this.formLoading = false
            _this.memberName = _this.form.memberName
            examPaperApi.selectTokenId(_this.memberToken).then(re => {
              _this.answered = re.response.examItemOrderAndContentList
              _this.doTime = re.response.doTime
              _this.timeReduce()
              if (_this.answered !== null) {
                _this.answered.forEach(it => {
                  _this.answer.answerItems[parseInt(it.itemOrder) - 1].content = it.content
@@ -166,7 +166,7 @@
                }
                if (_this.isForFinish(i)) {
                  _this.$router.push({ path: '/exam/finish', query: { name: '', content: _this.$t('finishMsg') } })
                  _this.$router.push({ path: '/exam/finish', query: { name: '', content: _this.$t('finishMsg'), tokenId: _this.memberToken } })
                }
              }
              // 如果上一题不是本段,则不能返回上一段
@@ -187,11 +187,26 @@
      ).catch(e => {
      })
    }
  },
  mounted () {
  },
  beforeDestroy () {
    window.clearInterval(this.timer)
  },
  watch: {
    guideDescirption: function (newVal, oldVal) {
      // 处理指导语,更换变量
      if (newVal) {
        if (this.form) {
          let productType = this.form.productType
          if (productType === 'API_Fan') {
            newVal = newVal.replace('%%company%%', this.form.reportCompany)
            this.guideDescirption = newVal
          }
        }
      }
    }
  },
  methods: {
    formatSeconds (theTime) {
@@ -314,6 +329,8 @@
    },
    nextSubject: function () {
      let _this = this
      _this.preDisable2 = true
      _this.nextDisable2 = true
      _this.isShowGuide(false)
      let nowPartOrder = _this.partOrder
      // 设置上一题的结束时间
@@ -344,6 +361,7 @@
      }
      this.answer.answerItems[_this.order].readOnly = true
      let answerSubmit = _this.getSubmitAnswerValue(nowPartOrder)
      // 已经答到了最后一题了,不用自动跳到下一题
      if (this.order + 1 > this.problemLength) {
        this.submitDisable = false
@@ -375,12 +393,21 @@
        } else {
          this.nextQuestionOrder(nowPartOrder)
        }
        _this.preDisable2 = false
        _this.nextDisable2 = false
      }).catch(e => {
        if (_this.isNotEmpty(loading)) {
          loading.close()
        }
        _this.reloadPage(e)
        _this.preDisable2 = false
        _this.nextDisable2 = false
      })
    },
    callSelected: function () {
      let _this = this
      _this.preDisable2 = true
      _this.nextDisable2 = true
    },
    getSubmitAnswerValue (nowPartOrder) {
      let _this = this
@@ -400,8 +427,16 @@
    },
    preSubject () {
      let _this = this
      _this.nextDisable2 = false
      _this.isShowGuide(false)
      if (_this.order > 0) {
        // 清空本题的选择
        _this.answer.answerItems[_this.order].content = null
        _this.answer.answerItems[_this.order].completed = false
        _this.answer.answerItems[_this.order].questionReport = null
        _this.answer.answerItems[_this.order].readOnly = false
        // 设置回到上一题
        let num = --_this.order
        _this.itemOrder = _this.form.titleItems[0].questionItems[num].itemOrder
        _this.questionItem = _this.form.titleItems[0].questionItems[num]
@@ -420,7 +455,9 @@
      for (let i = 0; i < _this.answer.answerItems.length; i++) {
        if (_this.answer.answerItems[i].content === null) {
          unFinish = true
          _this.answer.finish = 0
          // 有未完成的答题应该是 2答题中
          // 之前是0未处理
          _this.answer.finish = 2
        }
      }
      if (unFinish) {
@@ -440,7 +477,16 @@
      } else {
        _this.answer.verifyStatus = 1
        _this.answer.finish = 1
        _this.submitAnswer(_this.$t('finishPersonalityInfo'))
        if (this.form) {
          let productType = this.form.productType
          if (productType === 'API_Fan') {
            _this.submitAnswer(_this.$t('finishPersonalityInfo_apifan'))
          } else {
            _this.submitAnswer(_this.$t('finishPersonalityInfo'))
          }
        } else {
          _this.submitAnswer(_this.$t('finishPersonalityInfo'))
        }
      }
    },
    startDo: function () {
@@ -462,7 +508,18 @@
      examPaperAnswerApi.answerSubmit(answerSubmit, _this.memberToken).then(re => {
        loading.close()
        if (re.code === 1) {
          _this.$router.push({ path: '/exam/finish', query: { name: _this.form.name, content: mess } })
          // 特殊处理 LAQ测试包 MAQ+CAQ
          if (_this.form.name.indexOf('LAQ') !== -1) {
            console.log('答完题,看看要不要去CAQ1')
            examPaperApi.select(_this.memberToken, _this.langType).then(re => {
              _this.form = re.response
              _this.$router.push({ path: '/guide/index', query: { formDo: _this.form } })
            }).catch(e => {
              _this.$message.error(_this.$t('noquestionMsg'))
            })
          } else {
            _this.$router.push({ path: '/exam/finish', query: { name: _this.form.name, content: mess, tokenId: _this.memberToken } })
          }
        } else {
          _this.$message.error(re.message + '/exam/finish')
        }