[测评系统]--前端(用户答题页面)
yj
2024-12-03 7f4105bc2f1d4f8562e1cb9776ce49f8be0c98d2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<template>
  <div v-loading.fullscreen.lock="!formDo">
    <el-container class="app-item-contain" v-if="formDo">
      <el-header class="align-center" style="height: 50px;padding: 1%;margin-top: 4%">
        <H2 v-html="$t('guide')" v-if="formDo.questionTemplateId !== 'job' || formDo.questionTemplateId !== 'values'"></H2>
      </el-header>
      <el-main style="padding-top:0%">
        <div v-html="formDo.guide">
        </div>
        <el-row class="do-align-center">
          <el-button v-if="formDo.questionTemplateId !== 'personality'" @click="doExam" type="primary" round>{{$t('startDo')}}</el-button>
          <el-button v-if="formDo.questionTemplateId === 'job'" @click="openExplain" type="danger" round>{{$t('openJobDesc')}}</el-button>
          <el-button v-if="formDo.questionTemplateId === 'personality'" @click="openExercise" type="primary" round>{{$t('exercise_start')}}</el-button>
        </el-row>
      </el-main>
    </el-container>
  </div>
</template>
 
<script>
import { mapState, mapMutations } from 'vuex'
import examPaperApi from '@/api/examPaper'
export default {
  data () {
    return {
      // formDo: this.$route.query.formDo,
      loading: false
    }
  },
  created () {
    this.getFormDo()
  },
  mounted () {
    // this.swapGuide()
  },
  beforeDestroy () {
  },
  watch: {
    'formDo': function (newVal, oldVal) {
      this.loading = false
    }
  },
  methods: {
    doExam: function () {
      let _this = this
      examPaperApi.updateTestMemberStatus(_this.memberToken).then(re => {
        // LAQ特殊处理
        if (_this.formDo.name.indexOf('LAQ') !== -1) {
          // _this.$router.push({ path: '/exam/' + _this.formDo.questionTemplateId, query: { formDo: _this.formDo } })
          _this.$router.push({ path: '/exam/' + _this.formDo.questionTemplateId })
        } else {
          // _this.$router.push({ path: '/exam/' + _this.doUrl, query: { formDo: _this.formDo } })
          _this.$router.push({ path: '/exam/' + _this.doUrl })
        }
      }).catch(re => {
        _this.$message.error(re.message + ' 更新状态失败')
      })
    },
    openExplain: function () {
      let _this = this
      window.open(_this.formDo.jobDescriptionFile)
    },
 
    // 打开练习页面
    openExercise: function () {
      let _this = this
      // _this.$router.push({ path: '/exam/exercise', query: { formDo: _this.formDo } })
      _this.$router.push({ path: '/exam/exercise' })
    },
 
    // 替换guide的值
    swapGuide: function () {
      // 替换APIFan指导语中的变量
      if (this.formDo.productType === 'API_Fan') {
        let guide = this.formDo.guide
        guide = guide.replace('%%fullName%%', this.formDo.memberName)
        guide = guide.replace('%%company%%', this.formDo.reportCompany)
        this.formDo.guide = guide
      }
    },
 
    ...mapMutations('user', ['getLangType']),
    ...mapMutations('user', ['getFormDo'])
  },
  computed: {
    ...mapState('exam', { doUrl: state => state.doUrl }),
    ...mapState('user', { memberToken: state => state.memberToken }),
    ...mapState('user', { langType: state => state.langType }),
    ...mapState('user', { formDo: state => state.formDo })
  }
}
</script>
 
<style lang="scss" scoped>
  .align-center {
    text-align: center
  }
 
  .exam-question-item {
    padding: 10px;
 
    .el-form-item__label {
      font-size: 15px !important;
    }
  }
 
  .question-title-padding {
    padding-left: 25px;
    padding-right: 25px;
  }
</style>