智慧保安考试系统
zhongrj
2023-06-25 545522da7622f5623731d7ab257bcf442cd9d5ec
src/views/startexam/index.vue
@@ -11,19 +11,9 @@
                    <div class="time-remain_title">剩余时间 :</div>
                    <div class="time">
                      <count-down
                        v-on:start_callback="countDownS_cb(1)"
                        v-on:end_callback="countDownE_cb(1)"
                        :current-time="currentTime"
                        :start-time="startTime"
                        :end-time="endTime"
                        :tip-text="'距离考试开始'"
                        :tip-text-end="'距离考试结束'"
                        :end-text="'考试结束'"
                        :hourTxt="':'"
                        :minutesTxt="':'"
                        :secondsTxt="''"
                      >
                      <count-down v-on:start_callback="countDownS_cb(1)" v-on:end_callback="countDownE_cb(1)"
                        :current-time="currentTime" :start-time="startTime" :end-time="endTime" :tip-text="'距离考试开始'"
                        :tip-text-end="'距离考试结束'" :end-text="'考试结束'" :hourTxt="':'" :minutesTxt="':'" :secondsTxt="''">
                      </count-down>
                    </div>
                  </div>
@@ -31,13 +21,8 @@
                    当前进度: {{ subjectIndex }}/{{ subjectIds.length }}
                  </div>
                  <div class="answer-card">
                    <el-button
                      type="text"
                      icon="el-icon-date el-dates"
                      class="el-dates"
                      @click="answerCard"
                      >答题卡</el-button
                    >
                    <el-button type="text" icon="el-icon-date el-dates" class="el-dates"
                      @click="answerCard">答题卡</el-button>
                  </div>
                  <!-- <el-button
                    type="success"
@@ -59,34 +44,19 @@
                    <!-- 题目内容 -->
                    <choices ref="choices" v-show="this.query.type === 0" />
                    <multiple-choices
                      ref="multipleChoices"
                      v-show="this.query.type === 1"
                    />
                    <multiple-choices ref="multipleChoices" v-show="this.query.type === 1" />
                    <judgement ref="judgement" v-show="this.query.type === 2" />
                    <practical-operation
                      ref="practicalOperation"
                      v-show="this.query.type === 3"
                    />
                    <practical-operation ref="practicalOperation" v-show="this.query.type === 3" />
                    <short-answer
                      ref="shortAnswer"
                      v-show="this.query.type === 4"
                    />
                    <short-answer ref="shortAnswer" v-show="this.query.type === 4" />
                    <div class="subject-buttons" v-if="query.subjectId !== ''">
                      <!-- <el-button plain @click="last" :loading="loadingLast"
                      >上一题</el-button
                    > -->
                      <el-button
                        @click="next"
                        class="buttons"
                        :loading="loadingNext"
                        type="primary"
                        >下一题</el-button
                      >
                      <el-button @click="next" class="buttons" :loading="loadingNext" type="primary">下一题</el-button>
                      <!-- <el-button
                      :disabled="timesIT"
                      type="success"
@@ -100,26 +70,15 @@
                      "
                      >完成考试 {{ time }}</el-button
                    > -->
                      <el-button
                        type="success"
                        @click="submitExam"
                        :disabled="subjectIndex != 60"
                        >完成考试 {{ time }}
                      <el-button type="success" @click="submitExam" :disabled="subjectIndex != 100">完成考试 {{ time }}
                      </el-button>
                    </div>
                  </div>
                </div>
              </el-col>
            </el-row>
            <el-dialog
              title="答题卡"
              :visible.sync="dialogVisible"
              width="50%"
              top="10vh"
              :modal="false"
              center
              class="datika"
            >
            <el-dialog title="答题卡" :visible.sync="dialogVisible" width="50%" top="10vh" :modal="false" center
              class="datika">
              <div class="answer-card-title">
                {{ exam.examinationName }}(共{{
                  subjectIds.length
@@ -135,13 +94,9 @@
                  :key="index"
                  @click="toSubject(value.everyID, value.type, index)"
                  >&nbsp;{{ index + 1 }}&nbsp;</el-button> -->
                <el-button
                  circle
                  v-for="(value, index) in subjectIds"
                  :style="{ background: value.color, color: value.fontColor }"
                  :key="index"
                  >&nbsp;{{ index + 1 }}&nbsp;</el-button
                >
                <el-button circle v-for="(value, index) in subjectIds"
                  :style="{ background: value.color, color: value.fontColor }" :key="index">&nbsp;{{ index + 1
                  }}&nbsp;</el-button>
                <!-- @click="toSubject(value.everyID, value.type, index)" -->
              </el-row>
            </el-dialog>
@@ -293,20 +248,20 @@
    }
  },
  methods: {
    countDownS_cb: function() {
    countDownS_cb: function () {
      // console.log(12456);
      messageSuccess(this, "考试开始");
      this.startTime = this.getCurrentTimes();
    },
    countDownE_cb: function() {
    countDownE_cb: function () {
      messageWarn(this, "考试结束");
      //   this.disableSubmit = true;
      // this.submitExam("over");
      this.submitExam("over");
    },
    bottonControl(time) {
      //倒计时循环
      let times = time * 60;
      var setTime = function(time) {
      var setTime = function (time) {
        let a, b, d;
        a = parseInt(time / 60);
        b = time - a * 60;
@@ -343,7 +298,6 @@
    validateExamTime() {
      getCurrentTime()
        .then(response => {
          // console.log(response, 7777);
          const currentTime = moment(response.data.data);
          if (currentTime.isAfter(this.exam.endTime)) {
            messageWarn(this, "考试已结束");
@@ -360,8 +314,8 @@
              this.startTime = current;
              this.subjectStartTime = current;
              //   // this.endTime = moment(this.exam.endTime).valueOf()
              this.endTime = current + 60 * 60 * 1000;
              this.bottonControl(60);
              this.endTime = current + 90 * 60 * 1000;
              this.bottonControl(90);
            }
            // this.disableSubmit = false;
          }
@@ -372,7 +326,7 @@
    },
    startExam(currentTime) {
      var scoreId = window.localStorage.getItem("scoreId");
      // console.log(scoreId, this.first, "scoreIdscoreIdscoreIdscoreId");
      console.log(scoreId, this.first, "scoreIdscoreIdscoreIdscoreId");
      this.subjectIds = [];
      // if (this.first) {
      //   const current = currentTime.valueOf();
@@ -455,38 +409,44 @@
            }
            //适应时间
            const datyTime = objs.examScore.examTime;
            // console.log(objs, "datyTimedatyTimedatyTime");
            var duibiTime = function(newTime, oldTime) {
              var newYear = newTime.split(" ")[0],
                newDat = newTime.split(" ")[1],
                oldYear = oldTime.split(" ")[0],
                oldDat = oldTime.split(" ")[1];
              if (newYear !== oldYear) {
                return false;
              } else {
                let newD = {
                  s: +newDat.split(":")[0],
                  f: +newDat.split(":")[1],
                  m: +newDat.split(":")[2]
                };
                let oldD = {
                  s: +oldDat.split(":")[0],
                  f: +oldDat.split(":")[1],
                  m: +oldDat.split(":")[2]
                };
                if (newD.s - oldD.s > 1) {
                  return false;
                } else if (newD.s - oldD.s == 1) {
                  if (newD.f < oldD.f) {
                    return oldD.f - newD.f;
                  } else {
                    return false;
                  }
                } else if (newD.s == oldD.s) {
                  return 60 - (newD.f - oldD.f);
                }
                return [newD, oldD];
              }
            var duibiTime = function (newTime, oldTime) {
              var newtimes = new Date(newTime.replace(/-/g, '/')).getTime();
              var oldtimes = new Date(oldTime.replace(/-/g, '/')).getTime();
              var dif = Math.ceil((newtimes - oldtimes) / (1000 * 60))
              return 90 - dif
              // var newYear = newTime.split(" ")[0],
              //   newDat = newTime.split(" ")[1],
              //   oldYear = oldTime.split(" ")[0],
              //   oldDat = oldTime.split(" ")[1];
              // if (newYear !== oldYear) {
              //   return false;
              // } else {
              //   let newD = {
              //     s: +newDat.split(":")[0],
              //     f: +newDat.split(":")[1],
              //     m: +newDat.split(":")[2]
              //   };
              //   let oldD = {
              //     s: +oldDat.split(":")[0],
              //     f: +oldDat.split(":")[1],
              //     m: +oldDat.split(":")[2]
              //   };
              //   if (newD.s - oldD.s > 1) {
              //     return false;
              //   } else if (newD.s - oldD.s == 1) {
              //     if (newD.f < oldD.f) {
              //       return oldD.f - newD.f;
              //     } else {
              //       return false;
              //     }
              //   } else if (newD.s == oldD.s) {
              //     return 90 - (newD.f - oldD.f);
              //   }
              //   return [newD, oldD];
              // }
              // return false;
            };
            var listTime = duibiTime(currentTime._i, datyTime);
@@ -703,7 +663,7 @@
            }
            this.setSubjectInfo(subject);
            console.log(subject);
            // console.log(subject);
            this.$store.commit("setWindowSizeHeightAdd");
            // store.dispatch('SetSubjectInfo', subject).then(() => { })
@@ -842,7 +802,7 @@
          this.disableSubmit = true;
          this.doSubmitExam();
        })
        .catch(() => {});
        .catch(() => { });
    },
    doSubmitExam() {
      var obj = {
@@ -859,9 +819,9 @@
        examResultVOS: null
      };
      var arr = [];
      console.log(this.subjectIds);
      // console.log(this.subjectIds);
      // debugger;
      console.log(this.subjectIds.length, 111);
      // console.log(this.subjectIds.length, 111);
      for (var i = 0; i < this.subjectIds.length; i++) {
        let item = this.subjectIds[i];
        // console.log(item.answer, i);
@@ -1061,34 +1021,41 @@
$fontSize1: 18px;
$fontSize2: 20px;
$fontSize3: 40px;
.subject-box {
  margin-top: 25px;
  margin-left: 20px;
  height: 100%;
}
.subject-box-card {
  font-size: 28px;
  width: 80%;
  margin-bottom: 30px;
  min-height: 400px;
}
.subject-buttons {
  text-align: left;
  position: relative;
  top: 70px;
  left: 390px;
  // top: 70%;
  // right: 30%;
  .buttons {
    // border: 1px solid green;
  }
}
.tool-bar {
  margin-left: 20px;
}
.time-remain_title {
  font-size: $fontSize2;
}
.time-remain .time {
  display: block;
  font-size: $fontSize3;
@@ -1098,18 +1065,23 @@
  position: relative;
  //   top: -20px;
}
.current-progress {
  font-size: $fontSize2;
}
.answer-card {
  margin: 15px 0;
}
.el-dates {
  font-size: $fontSize1;
}
.subject-exam-title {
  margin-bottom: 25px;
}
/* 答题卡 */
.answer-card-title {
  font-size: 24px;
@@ -1117,23 +1089,27 @@
  line-height: 17px;
  padding: 10px 0;
}
.answer-card-split {
  width: 100%;
  border-bottom: 1px solid #e6e6e6;
}
.answer-card-content {
  padding-bottom: 10px;
  font-size: 0;
  margin-right: -15px;
  > button {
  >button {
    margin-top: 5px;
  }
}
.answered {
  background-color: greenyellow;
}
#avue-view > .morpheus-box {
#avue-view>.morpheus-box {
  position: absolute;
  width: calc(100% - 100px);
  height: 85%;
@@ -1143,10 +1119,13 @@
  padding: 10px !important;
  box-sizing: border-box;
}
.exam-card-body {
  // border-top: 5px solid #ffa820 !important;
}
$sizeBut: 50px;
.el-button.is-circle {
  text-align: center;
  width: $sizeBut !important;