[测评系统]--前端(用户答题页面)
zhijie
2023-12-03 166f256cda92ce8755ce0bf982ee2d355d7b6e42
src/views/exam/paper/values.vue
@@ -1,14 +1,31 @@
<template>
   <div>
      <el-container class="app-item-contain step1" v-if="step === 'step0'">
         <el-header class="">
            <h1>{{$t('values_step_0_title')}}</h1>
         </el-header>
         <el-main class="">
            <div v-html="$t('values_step_0_content')"></div>
            <el-row class="do-align-center">
              <el-button @click="step0_next" type="primary" round>{{$t('startDo')}}</el-button>
            </el-row>
         </el-main>
      </el-container>
      <el-container class="app-item-contain step1" v-if="step === 'step1'">
         <el-header class="">
            <h1>{{$t('values_title')}}</h1>
         </el-header>
         <el-main class="" style="padding-top: 3%;">
            <div v-html="$t('values_title_description')">
         <el-main class="">
            <div>
               <div v-html="$t('values_title_description')"></div>
               <div>{{$t('values_title_description_1')}}<img class="tools-button" src="@/assets/exam-paper/good.png" style="width: 15px;position: absolute;margin-top: 2px"/><span style="margin-left: 20px;">{{$t('values_title_description_1_2')}}</span></div>
               <div>{{$t('values_title_description_2')}}<img class="tools-button" src="@/assets/exam-paper/nogood.png" style="width: 15px;position: absolute;margin-top: 2px"/><span style="margin-left: 20px;">{{$t('values_title_description_2_2')}}</span></div>
               <div>{{$t('values_title_description_3')}}<img class="tools-button" src="@/assets/exam-paper/question.png" style="width: 15px;position: absolute;margin-top: 2px"/><span style="margin-left: 20px;">{{$t('values_title_description_3_2')}}</span></div>
               <div>{{$t('values_title_description_4')}}<img class="tools-button" src="@/assets/exam-paper/scale.png" style="width: 15px;height: 15px;position: absolute;margin-top: 2px"/><span style="margin-left: 20px;">{{$t('values_title_description_4_2')}}</span></div>
            </div>
            <div style="display: flex;justify-content: flex-start;padding: 10px 0;">
               <el-button @click="step1_start" type="primary" round v-if="!step1Start">{{$t('start')}}</el-button>
               <el-button style="margin-top: 12px;" @click="step1_start" type="primary" round v-if="!step1Start">{{$t('start')}}</el-button>
               <el-button style="margin-top: 12px;" type="primary" round @click="step1_next"
                  v-if="(step1Start && itemSize>0)">
                  {{$t('next')}}
@@ -35,30 +52,53 @@
            </div>
         </el-main>
      </el-container>
      <el-container class="app-item-contain step1" v-if="step === 'step2-0'">
         <el-header class="">
            <h1>{{$t('values_step_2_title')}}</h1>
         </el-header>
         <el-main class="">
            <div v-html="$t('values_step_2_content')"></div>
            <el-row class="do-align-center">
              <el-button @click="step2_0_next" type="primary" round>{{$t('startDo')}}</el-button>
            </el-row>
         </el-main>
      </el-container>
      <el-container class="app-item-contain step2" v-if="step === 'step2'">
         <el-main class="">
            <div>
               <div class="tag-group">
               <div class="tag-group" style="display: flex;">
                  <span class="tag-group__title"
                     style="padding-right: 20px;font-size: 26px;">{{$t('values_cur_step')}}({{step2SubStep}} /
                     style="padding-right: 10px;font-size: 26px;margin: auto 0px;">{{$t('values_cur_step')}}({{step2SubStep}} /
                     {{step2ScoreRanges.length}})</span>
                  <el-tag v-for="item in step2ScoreRanges" :key="item.itemOrder"
                     :type="getStep2StepTagType(item.step)" style="margin: 0 2px;font-size: 26px;" size="large"
                     effect="light">
                     {{ item.quantity }}
                  </el-tag>
                  <div>
                        <div style="display: flex;padding: 5px 0;">
                        <div v-for="item in step2ScoreRanges" :key="item.itemOrder" style="margin: 0 2px;font-size: 12px;width: 100px;text-align: center;" size="large">
                           {{ item.stepName }}
                        </div>
                        </div>
                        <div>
                        <el-tag v-for="item in step2ScoreRanges" :key="item.itemOrder"
                           :type="getStep2StepTagType(item.step)" style="margin: 0 2px;font-size: 26px;width: 100px;text-align: center;" size="large"
                           effect="light">
                           {{ item.quantity }}
                        </el-tag>
                        </div>
                     </div>
               </div>
               <div style="display: flex;justify-content: space-between;">
                  <div style="line-height: 50px;text-indent: 2em;">
                     <span
                     <div
                        v-if="(step2SubStep == step2ScoreRanges.length) && (step2ScoreRanges.length % 2 == 1)">
                        {{$t('values_step_tips_for_3').replace('%N',getStep2StepItem(step2SubStep).quantity)}}
                     </span>
                     <span v-else>
                        {{(step2SubStep % 2 == 1)?$t('values_step_tips_for_1').replace('%N',getStep2StepItem(step2SubStep).quantity):$t('values_step_tips_for_2').replace('%N',getStep2StepItem(step2SubStep).quantity)}}
                     </span>
                        {{$t('values_step_tips_for_3').replace('%N',getStep2StepItem(step2SubStep).quantity).replace('%C',getStep2StepItem(step2SubStep).stepName.toUpperCase())}}
                     </div>
                     <div v-else>
                        {{$t('values_step_tips_for_1').replace('%N',getStep2StepItem(step2SubStep).quantity).replace('%C',getStep2StepItem(step2SubStep).stepName.toUpperCase())}}
                     </div>
                     <div style="color: red;">
                        {{$t('values_step_tips')}}
                     </div>
                  </div>
                  <div style="display: flex;justify-content: flex-end;">
                  <div style="margin-top: auto;">
                     <el-button type="primary" round @click="step2_pre" v-if="step2SubStep>1">{{$t('pre')}}
                     </el-button>
                     <el-button type="primary" round @click="step2_next">{{$t('next')}}</el-button>
@@ -111,11 +151,11 @@
         <el-main class="">
            <div style="position: fixed;z-index: 999; width:90%; top: 56px;">
               <div style="display: flex;justify-content: flex-end;padding: 10px;background-color: #f5f7fa;">
                  <div style="padding-right: 20px;" v-html="$t('values_pic_tmpArea_desc')"></div>
                  <div style="padding: 0 10px;">{{$t('values_pic_tmpArea')}}</div>
                  <div style="padding-right: 20px;width:50%;" v-html="$t('values_pic_tmpArea_desc')"></div>
                  <div style="padding: 0 10px;width:80px;">{{$t('values_pic_tmpArea')}}</div>
                  <draggable animation="300" class="pic-tmparea-div"
                     style="border: 1px solid gray;padding: 10px;width: 50%;"
                     :list="step3EWEIArea[0]" :options="{group:{name:'EWEIArea',pull:'clone'}}"
                     style="border: 1px solid gray;padding: 10px;width: 45%;"
                     :list="step3EWEIArea[0]" :options="{group:{name:'EWEIArea',pull:'clone'}}"
                     @start="ev=>step3TmpAreaStart(ev,0)"
                     @end="step3TmpAreaMoveEnd">
                     <div v-for="q in step3EWEIArea[0]" :key="q.id" class="mullinediv-item2"
@@ -129,11 +169,16 @@
                  </el-button>
               </div>
            </div>
            <div style="display:flex;margin-top: 160px;">
               <div style="display: inline-block;min-width: 150px;text-align: right;">
                  <div class="mul-inlinediv-row mul-inlinediv-lineheight"
            <div style="display:flex;margin-top: 200px;">
               <div style="display: inline-block;min-width: 150px;text-align: right;padding-right: 5px;">
                  <div class="mul-inlinediv-row mul-inlinediv-lineheight"
                     v-for="(item,index) in step2ScoreRanges">
                     {{(index == 0)?$t('values_mostLikeMe'):' '}}{{(index == (step2ScoreRanges.length-1))?$t('values_mostUnLikeMe'):' '}}&nbsp;&nbsp;
                     <span v-if="item.stepName=='不确定是否相似'">
                        不确定是否与你相似 <span v-if="item.step<step2ScoreRanges.length">{{$t('values_step_names_unit')}}</span>
                     </span>
                     <span v-else>
                        {{$t('values_step_names_unit_pre')}}{{item.stepName}} <span v-if="item.step<step2ScoreRanges.length">{{$t('values_step_names_unit')}}</span>
                     </span>
                  </div>
               </div>
               <div style="display: inline-block;width: 20px;margin-top: 4px;">
@@ -141,12 +186,14 @@
                     v-for="(item,index) in step2ScoreRanges">
                  </div>
               </div>
               <!--
               <div style="display: inline-block;min-width: 20px;text-align: right;">
                  <div class="mul-inlinediv-row mul-inlinediv-lineheight"
                  <div class="mul-inlinediv-row mul-inlinediv-lineheight"
                     v-for="(item,index) in step2ScoreRanges">
                     {{item.deviate}}
                     {{$t('values_step_names_unit')}}
                  </div>
               </div>
               -->
               <div class="mul-inlinediv-box">
                  <div class="mul-inlinediv" v-for="item in step2ScoreRanges">
@@ -205,7 +252,7 @@
      },
      data() {
         return {
            step: 'step1',
            step: 'step0',
            step1Start: false,
            step1SelectedNum: 0,
            step2ScoreRanges: [
@@ -224,6 +271,7 @@
               "completed": false,
               "questionReports": null,
               "step": 0,
               "stepName":'',
               "selected": 0
            }],
            step2SubStep: 1,
@@ -232,210 +280,7 @@
               "subjectId": null,
            },
            step3EWEIArea: [1],
            form: {
               "id": 92,
               "level": 1,
               "subjectId": null,
               "paperType": 1,
               "name": "VAQ",
               "suggestTime": null,
               "limitDateTime": null,
               "titleItems": [{
                  "guide": "",
                  "name": "",
                  "description": "",
                  "permanentId": null,
                  "questionOrder": 0,
                  "questionReport": null,
                  "questionItems": [{
                        "id": 786,
                        "questionType": 1,
                        "subjectId": null,
                        "title": "麻将桌",
                        "gradeLevel": null,
                        "items": [{
                           "prefix": "1",
                           "content": "0",
                           "score": "0"
                        }],
                        "analyze": null,
                        "correctArray": null,
                        "correct": null,
                        "score": "0",
                        "difficult": null,
                        "itemOrder": 1,
                        "questionOrder": 0,
                        "permanentId": "VAQ00001",
                        "questionReport": null,
                        "startTime": null,
                        "endTime": null,
                        "partOrder": 1,
                        "parentQuestionId": null,
                        "template": null,
                        "questionNumber": null,
                        "content": null,
                        "imgUrl": "http://127.0.0.1:8090/profile/images/2022/12/26/b698d623e7c9a55d9017ffa08477b121.jpg"
                     },
                     {
                        "id": 787,
                        "questionType": 1,
                        "subjectId": null,
                        "title": "麻将桌2",
                        "gradeLevel": null,
                        "items": [{
                           "prefix": "1",
                           "content": "0",
                           "score": "0"
                        }],
                        "analyze": null,
                        "correctArray": null,
                        "correct": null,
                        "score": "0",
                        "difficult": null,
                        "itemOrder": 2,
                        "questionOrder": 1,
                        "permanentId": "VAQ00002",
                        "questionReport": null,
                        "startTime": null,
                        "endTime": null,
                        "partOrder": 2,
                        "parentQuestionId": null,
                        "template": null,
                        "questionNumber": null,
                        "content": null,
                        "imgUrl": "http://127.0.0.1:8090/profile/images/2022/12/26/123f79ad0cc38507368c22b8a7ec9b09.jpg"
                     },
                     {
                        "id": 788,
                        "questionType": 1,
                        "subjectId": null,
                        "title": "测试1",
                        "gradeLevel": null,
                        "items": [{
                           "prefix": "1",
                           "content": "0",
                           "score": "0"
                        }],
                        "analyze": null,
                        "correctArray": null,
                        "correct": null,
                        "score": "0",
                        "difficult": null,
                        "itemOrder": 3,
                        "questionOrder": 2,
                        "permanentId": "VAQ00003",
                        "questionReport": null,
                        "startTime": null,
                        "endTime": null,
                        "partOrder": 3,
                        "parentQuestionId": null,
                        "template": null,
                        "questionNumber": null,
                        "content": null,
                        "imgUrl": "http://127.0.0.1:8090/profile/images/2023/01/09/6b80baab47a9eba6ceeec5a723397109.jpg"
                     },
                     {
                        "id": 789,
                        "questionType": 1,
                        "subjectId": null,
                        "title": "测试2",
                        "gradeLevel": null,
                        "items": [{
                           "prefix": "1",
                           "content": "0",
                           "score": "0"
                        }],
                        "analyze": null,
                        "correctArray": null,
                        "correct": null,
                        "score": "0",
                        "difficult": null,
                        "itemOrder": 4,
                        "questionOrder": 3,
                        "permanentId": "VAQ00004",
                        "questionReport": null,
                        "startTime": null,
                        "endTime": null,
                        "partOrder": 4,
                        "parentQuestionId": null,
                        "template": null,
                        "questionNumber": null,
                        "content": null,
                        "imgUrl": "http://127.0.0.1:8090/profile/images/2023/01/09/3f8e18280f1d47362c69b18e80ddf1a3.jpg"
                     },
                     {
                        "id": 790,
                        "questionType": 1,
                        "subjectId": null,
                        "title": "测试3",
                        "gradeLevel": null,
                        "items": [{
                           "prefix": "1",
                           "content": "0",
                           "score": "0"
                        }],
                        "analyze": null,
                        "correctArray": null,
                        "correct": null,
                        "score": "0",
                        "difficult": null,
                        "itemOrder": 5,
                        "questionOrder": 4,
                        "permanentId": "VAQ00005",
                        "questionReport": null,
                        "startTime": null,
                        "endTime": null,
                        "partOrder": 5,
                        "parentQuestionId": null,
                        "template": null,
                        "questionNumber": null,
                        "content": null,
                        "imgUrl": "http://127.0.0.1:8090/profile/images/2023/01/09/447616cb14745241f0ac700b56d0770b.jpg"
                     }
                  ],
                  "startTime": null,
                  "endTime": null,
                  "parts": [],
                  "scoreRanges": [{
                        "itemOrder": 1,
                        "quantity": 2,
                        "score": 5,
                        "completed": false,
                        "questionReports": null
                     },
                     {
                        "itemOrder": 2,
                        "quantity": 1,
                        "score": 10,
                        "completed": false,
                        "questionReports": null
                     },
                     {
                        "itemOrder": 3,
                        "quantity": 2,
                        "score": 5,
                        "completed": false,
                        "questionReports": null
                     }
                  ]
               }],
               "score": null,
               "guide": "VAQ",
               "questionOrder": [
                  0,
                  1,
                  2,
                  3,
                  4
               ],
               "parts": [],
               "questionTemplateId": "values",
               "reportTemplateId": "61",
               "memberName": "test4",
               "optionOrder": null,
               "timeOut": null,
               "jobDescriptionFile": null
            },
            form:{},
            formLoading: false,
            answer: {
               questionId: null,
@@ -471,7 +316,9 @@
         }
      },
      created: function() {
      //created: function() {
      mounted: function() {
         console.log(".....................mounted start......................")
         //console.log(".....................Test. config start......................")
         //if(this.memberToken == '' || this.memberToken == undefined) this.setMemberTocken("4bdcf437-185c-4f4e-9528-382c99509ea6")
         //console.log(".....................Test. config ednd.......................")
@@ -497,12 +344,14 @@
            _this.initStep2ScoreRanges(_this.form.titleItems[0].scoreRanges)
         } else {
            console.log(".....................mounted 刷新......................")
            _this.formLoading = true
            // 防止刷新成了不同的语言
            demographyApi.queryDemographyParamInfo(_this.memberToken).then(
               re => {
                  if (re.response[0].langType !== null || re.response[0].langType.trim() !== '') {
                     _this.setLangType(re.response[0].langType)
                     console.log("lang type",re.response[0].langType,_this.langType)
                  }
                  // 加载题目
                  examPaperApi.select(_this.memberToken, _this.langType).then(re => {
@@ -577,18 +426,26 @@
               }
            ).catch(e => {})
         }
      },
      mounted() {
         //console.log("mounted......")
         document.body.ondrop = function(event) {
            event.preventDefault();
            event.stopPropagation();
         }
      },
      // mounted() {
      //    //console.log("mounted......")
      //    document.body.ondrop = function(event) {
      //       event.preventDefault();
      //       event.stopPropagation();
      //    }
      // },
      beforeDestroy() {
         window.clearInterval(this.timer)
      },
      methods: {
         step0_next(){
            this.step = "step1"
         },
         step1_start() {
            this.step = "step1"
            this.step1Start = true
@@ -600,9 +457,7 @@
            //回显,没有可选的时候,进入下一步
            let c = this.sumStep1UnSelectedNum()
            if (c <= 0 && this.itemSize > 0) {
               this.step = "step2"
               this.sortQuestions()
               this.caculateScoreRangeSelectedById(this.getStep2StepItem(this.step2SubStep).itemOrder)
               this.step1_next()
            }
         },
         step1_next() {
@@ -612,9 +467,26 @@
               this.$message.error(_this.$t('values_nextStepTips_choices_all'))
               return
            }
            this.step = "step2"
            this.sortQuestions()
            this.caculateScoreRangeSelectedById(this.getStep2StepItem(this.step2SubStep).itemOrder)
            /*
            this.$confirm(_this.$t('values_nextStepTips_tips'), _this.$t('prompt'), {
               confirmButtonText: _this.$t('determine'),
               cancelButtonText: _this.$t('cancel'),
               type: 'warning'
            }).then(() => {
                _this.step = "step2"
                _this.sortQuestions()
                _this.caculateScoreRangeSelectedById(this.getStep2StepItem(this.step2SubStep).itemOrder)
        }).catch(() => {
        });
            */
            this.step = "step2-0"
         },
         step2_0_next(){
            let _this = this
            _this.step = "step2"
            _this.sortQuestions()
            _this.caculateScoreRangeSelectedById(this.getStep2StepItem(this.step2SubStep).itemOrder)
         },
         step2_pre() {
            if (this.step2SubStep > 1) {
@@ -837,9 +709,9 @@
         sortQuestions() {
            let type = this.getLikeType(this.step2SubStep)
            switch (type) {
               case 0: //0:最像我
                  this.questionItems.sort(function(i2, i1) {
                     return (i2.content == 0) ? -1 : 1
               case 0: //0:最像我 数字排序(数字和升序)
                  this.questionItems.sort(function(a, b) {
                     return a.content - b.content
                  })
                  break
               case 1: //1:有疑问
@@ -847,9 +719,9 @@
                     return (i2.content == 1) ? -1 : 1
                  })
                  break
               case 2: //2:最不像我
                  this.questionItems.sort(function(i2, i1) {
                     return (i2.content == 2) ? -1 : 1
               case 2: //2:最不像我 数字排序(数字和降序)
                  this.questionItems.sort(function(a, b) {
                     return b.content - a.content
                  })
                  break
            }
@@ -972,6 +844,10 @@
            }
            console.log('initTestData...e', this.questionItems)
         },
         /**
          * 设置step2ScoreRanges子项的步骤顺序及正负距离值
          * @param {Object} arr
          */
         initStep2ScoreRanges(arr) {
            //console.log('initStep2ScoreRanges...s', arr)
            let _this = this
@@ -1017,8 +893,36 @@
               //设置每项已选择的数量
               _this.step2ScoreRanges[i]['selected'] = 0
            }
            console.log('initStep2ScoreRanges...e', this.step2ScoreRanges)
            //console.log('initStep2ScoreRanges...e', this.step2ScoreRanges)
            _this.initStep2ScoreRangesStepName()
            _this.initQuestionItems()
         },
         initStep2ScoreRangesStepName(){
            let _this = this
            let max = _this.step2ScoreRanges.length
            let splitChar = ","
            if(_this.$t('values_step_names').indexOf(",")>=0){
               splitChar = ","
            }
            //console.log('lang type',_this.langType)
            let names = _this.$t('values_step_names').split(splitChar)
            console.log('initStep2ScoreRangesStepName',names)
            for (let i = 0; i < _this.step2ScoreRanges.length; i++) {
               if(_this.step2ScoreRanges[i]['step'] > names.length){
                  _this.step2ScoreRanges[i]['stepName'] = names[names.length-1]
               } else {
                  _this.step2ScoreRanges[i]['stepName'] = names[_this.step2ScoreRanges[i]['step']-1]
               }
               //设置最后的Step的StepName为固定值
               if(_this.step2ScoreRanges[i]['step'] >= max){
                  if(max % 2 == 0){//偶数
                  } else {//奇数
                     _this.step2ScoreRanges[i]['stepName'] = names[names.length-1]
                  }
               }
            }
            console.log('initStep2ScoreRangesStepName',_this.step2ScoreRanges)
         },
         initQuestionItems(){
            let _this = this
@@ -1032,6 +936,15 @@
            console.log('initQuestionItems...e', this.questionItems)
         },
         getStep2StepTagType(step) {
            if (this.step2SubStep > step) {
               return ''
            } else if (this.step2SubStep == step) {
               return 'success'
            } else {
               return 'info'
            }
         },
         getStep2StepTagTypeName(step) {
            if (this.step2SubStep > step) {
               return ''
            } else if (this.step2SubStep == step) {
@@ -1187,7 +1100,7 @@
                  answerItem.startTime = ''
               }
               answerItem.completed = true
               answerItem.content = this.getContentByQuestionId(answerItem.questionId)
               answerItem.content = this.getContentByQuestionId(answerItem.questionId)
                  //this.getLikeTypeByScoreRangeItemOrder(answerItem.subjectId)
               answerItem.questionReport = {
                  questionOrder: answerItem.questionId,
@@ -1230,7 +1143,7 @@
                        langType: question.langType, //答题语言
                        partOrder: question.partOrder, //分片
                        imgUrl: question.imgUrl, //图片地址
                        answer: question.content //题目答案
                        answer: question.content //题目答案
                     })
                  }
               }
@@ -1514,7 +1427,7 @@
      justify-content: center;
      width: 100%;
   }
   .mul-inlinediv-down {
      min-width: 16px;
      //line-height: 106px;