liuyg
2021-12-13 8768efaf973cb6d59a15e8bc60b6af9e68a232c8
+加入退出后继续考试
5 files modified
317 ■■■■ changed files
src/api/examapi/examination.js 10 ●●●●● patch | view | raw | blame | history
src/store/modules/exam.js 4 ●●● patch | view | raw | blame | history
src/views/exam/startexam.vue 266 ●●●● patch | view | raw | blame | history
src/views/qiandao/index.vue 2 ●●● patch | view | raw | blame | history
src/views/startexam/index.vue 35 ●●●●● patch | view | raw | blame | history
src/api/examapi/examination.js
@@ -56,3 +56,13 @@
        method: 'get',
    })
}
//首页到时间计算成绩
export const calculations = (id) => {
    return request({
        url: '/api/examScore/getExamScore/',
        method: 'get',
        params: {
            id
        }
    })
}
src/store/modules/exam.js
@@ -19,7 +19,9 @@
    incorrectRecord: getStore({
      name: 'incorrectRecord'
    }) || {},
    examUserData: {},
    examUserData: getStore({
      name: 'useInfo'
    }) || {},
    // 签到
    scoreId: '',
    isClears: false,
src/views/exam/startexam.vue
@@ -2,7 +2,7 @@
 * @Author: Morpheus
 * @Date: 2021-07-31 16:31:54
 * @Last Modified by: liu
 * @Last Modified time: 2021-11-22 11:59:02
 * @Last Modified time: 2021-12-13 11:48:44
 * menu-name 考试管理
 */
<template>
@@ -29,10 +29,32 @@
          <span class="s_m_v_title">{{ item.title }}</span>
          <span>{{ item.value }}</span>
        </div>
        <div>
          <el-button type="primary" round @click="startExam"
            >开始考试</el-button
          >
        <div class="startButs">
          <el-button :type="option.data[0].color" round @click="startExam">{{
            option.data[0].subtext
          }}</el-button>
          <div class="time-remain startButsdown">
            <div class="time-remain_title" v-show="option.data[0].isExam == 3">
              剩余时间 :
            </div>
            <div class="time" v-show="option.data[0].isExam == 3">
              <count-down
                v-on:start_callback="countDownS_c(1)"
                v-on:end_callback="countDownE_c(1)"
                :current-time="currentTime"
                :start-time="startTime"
                :end-time="endTime"
                :tip-text="'距离考试开始'"
                :tip-text-end="'距离考试结束'"
                :end-text="'考试结束'"
                :hourTxt="':'"
                :minutesTxt="':'"
                :secondsTxt="''"
              >
              </count-down>
            </div>
          </div>
        </div>
      </div>
      <div class="s_m_value" v-else>没有找到相应的考试信息</div>
@@ -42,12 +64,33 @@
<script>
import CountDown from "vue2-countdown";
import { getCurrentTime } from "@/api/exam/examRecord";
import { mapState } from "vuex";
import { getExamDetail, getNowTime } from "@/api/examapi/examination";
import {
  getExamDetail,
  getNowTime,
  calculations,
} from "@/api/examapi/examination";
import { updateApplyStatus } from "@/api/examapi/applyexam";
import moment from "moment";
import {
  messageSuccess,
  messageFail,
  messageWarn,
  isNotEmpty,
} from "@/util/util";
export default {
  components: {
    CountDown,
  },
  data() {
    return {
      //继续考试时间
      currentTime: 0,
      startTime: 0,
      endTime: 0,
      //继续考试时间
      resData: null,
      sex: "",
      pageDisable: false,
@@ -73,6 +116,18 @@
    window.startExam = this.startExam;
  },
  methods: {
    //继续考试时间
    countDownS_c: function () {
      // console.log(12112);
      messageSuccess(this, "请继续考试");
      // this.startTime = this.getCurrentTimes();
    },
    countDownE_c: function () {
      messageWarn(this, "考试结束123");
      this.overExam();
      //   this.disableSubmit = true;
      // this.submitExam("over");
    },
    //退出登录
    handleLogout() {
      this.$confirm("是否退出系统, 是否继续?", "提示", {
@@ -87,6 +142,15 @@
    },
    //开始考试跳转
    startExam() {
      var that = this;
      if (that.option.data[0].isExam == 3) {
        // console.log(that.resData);
        that.$router.push({
          path: `/startexam/${that.resData.scoreId}`,
          query: that.resData,
        });
        return;
      }
      //判断是否到了考试时间
      if (this.isTime == 3) {
        this.$message({
@@ -103,7 +167,7 @@
        });
        return;
      }
      var that = this;
      //去修改考试状态
      var data = {
        id: that.resData.applyId,
@@ -124,7 +188,7 @@
      updateApplyStatus(data).then((res) => {
        that.resData["examScoreId"] = res.data.id;
        this.$store.commit("SetScoreId", res.data.id);
        console.log(res.data.id, "ididididiidididididid");
        // console.log(res.data.id, "ididididiidididididid");
        window.name = "";
        this.$notify({
          message:
@@ -142,6 +206,77 @@
    },
    getUserInfoBYExam() {
      var that = this;
      let setData = ({ color, subtext, isExam }) => {
        that.option.data = [
          {
            title: that.resData.examName,
            color: color,
            isExam: isExam,
            subtext: subtext,
            click: function () {
              window.parent.startExam();
            },
            list: [
              {
                title: "姓名:     ",
                value: that.resData.realName,
                check: true,
              },
              {
                title: "准考证号:    ",
                value: that.resData.candidateNo,
                check: true,
              },
              {
                title: "身份证号:     ",
                value: that.resData.idCardNo,
                check: true,
              },
              {
                title: "性别:     ",
                value: that.sex,
                check: true,
              },
            ],
          },
        ];
        that.$store.commit("SetexamUserData", that.option.data[0]);
      };
      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];
          return false;
        }
        // return false;
      };
      getExamDetail(this.userInfo.user_id).then(
        (res) => {
          that.resData = res.data.data[0];
@@ -174,39 +309,35 @@
              if (data.sex == 2) {
                that.sex = "女";
              }
              that.option.data = [
                {
                  title: that.resData.examName,
                  color: "#ffa820",
                  subtext: "开始考试",
                  click: function () {
                    window.parent.startExam();
                  },
                  list: [
                    {
                      title: "姓名:     ",
                      value: that.resData.realName,
                      check: true,
                    },
                    {
                      title: "准考证号:    ",
                      value: that.resData.candidateNo,
                      check: true,
                    },
                    {
                      title: "身份证号:     ",
                      value: that.resData.idCardNo,
                      check: true,
                    },
                    {
                      title: "性别:     ",
                      value: that.sex,
                      check: true,
                    },
                  ],
                },
              ];
              that.$store.commit("SetexamUserData", that.option.data[0]);
            }
            // console.log(data, 123456);
            if (data.isExam == 3) {
              setData({ color: "success", subtext: "继续考试", isExam: 3 });
              const currentTimeSTART = moment(data.examStartTime);
              const currentSTART = currentTimeSTART.valueOf();
              getCurrentTime().then((response) => {
                that.currentTime = currentSTART;
                that.startTime = currentSTART;
                var listTime = duibiTime(
                  response.data.data,
                  currentTimeSTART._i
                );
                // console.log(listTime, 4564444);
                if (listTime) {
                  that.endTime = currentSTART + listTime * 60 * 1000;
                } else {
                  that.overExam();
                }
                return;
              });
              // if (FZtime(data.examStartTime) > 60) {
              //   that.overExam();
              // }
              // that.endTime =
              //   current + (60 - FZtime(data.examStartTime)) * 60 * 1000;
            } else {
              setData({ color: "primary", subtext: "开始考试" });
            }
          });
        },
@@ -216,10 +347,63 @@
        }
      );
    },
    overExam() {
      let that = this;
      let scoreId = window.localStorage.getItem("scoreId");
      this.$alert("该考试已结束!", "提示", {
        confirmButtonText: "确定",
        callback: () => {
          calculations(scoreId)
            .then((response) => {
              messageSuccess(that, "提交成功");
              if (response) {
                that.$store.commit("DEL_TAG", that.$store.state.tags.tag);
                var obj = {
                  userId: that.userInfo.user_id,
                  examId: that.$route.query.id,
                };
                that.$router.push({
                  path: `/singleperformance/index`,
                  query: obj,
                });
              }
            })
            .catch(() => {
              that.disableSubmit = false;
              messageFail(that, "提交题目失败");
            });
        },
      });
    },
  },
};
</script>
<style lang="scss">
.startButs {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-around;
}
.startButsdown {
  position: relative;
  top: -25px;
  left: 45px;
}
$fontSize3: 40px;
$fontSize2: 20px;
.time-remain_title {
  font-size: $fontSize2;
}
.time-remain .time {
  display: block;
  font-size: $fontSize3;
  line-height: $fontSize3;
  color: #ff0000;
  font-weight: 400;
  position: relative;
  //   top: -20px;
}
//最终
.startexam {
  // width: 100%;
src/views/qiandao/index.vue
@@ -64,7 +64,7 @@
  },
  methods: {
    handleClick(tab, event) {
      console.log(tab.name, 77777);
      // console.log(tab.name, 77777);
    },
    logout() {
      this.$confirm(this.$t("logoutTip"), this.$t("tip"), {
src/views/startexam/index.vue
@@ -254,13 +254,20 @@
    },
  },
  created() {
    if (window.name == "") {
      // console.log("首次被加载");
      window.name = "first"; // 在首次进入页面时我们可以给window.name设置一个固定值
      this.first = true;
    } else if (window.name == "first") {
      // console.log("页面被刷新");
    var useInfo = this.$store.state.exam.examUserData;
    if (useInfo.isExam == 3) {
      window.name = "first";
      this.first = false;
    } else {
      if (window.name == "") {
        // console.log("首次被加载");
        window.name = "first"; // 在首次进入页面时我们可以给window.name设置一个固定值
        this.first = true;
      } else if (window.name == "first") {
        // console.log("页面被刷新");
        this.first = false;
      }
    }
    const examInfo = this.$route.params.id;
@@ -282,14 +289,19 @@
      // this.exam.totalScore = this.$route.query.totalScore
      // this.exam.status = this.$route.query.examStatus
      // this.exam.remark = this.$route.query.remark
      this.validateExamTime();
    }
  },
  methods: {
    countDownS_cb: function () {
      // console.log(12456);
      messageSuccess(this, "考试开始");
      this.startTime = this.getCurrentTimes();
    },
    countDownE_cb: function () {
      messageWarn(this, "考试结束");
      //   this.disableSubmit = true;
      // this.submitExam("over");
    },
    bottonControl(time) {
      //倒计时循环
@@ -331,6 +343,7 @@
    validateExamTime() {
      getCurrentTime()
        .then((response) => {
          // console.log(response, 7777);
          const currentTime = moment(response.data.data);
          if (currentTime.isAfter(this.exam.endTime)) {
            messageWarn(this, "考试已结束");
@@ -442,6 +455,7 @@
            }
            //适应时间
            const datyTime = objs.examScore.examTime;
            // console.log(objs, "datyTimedatyTimedatyTime");
            var duibiTime = function (newTime, oldTime) {
              var newYear = newTime.split(" ")[0],
                newDat = newTime.split(" ")[1],
@@ -476,7 +490,6 @@
              // return false;
            };
            var listTime = duibiTime(currentTime._i, datyTime);
            // console.log(listTime, "listTimelistTimelistTime");
            const current = currentTime.valueOf();
            this.currentTime = current;
            this.startTime = current;
@@ -546,11 +559,7 @@
          messageFail(this, "开始考试失败!4646549888*8*");
        });
    },
    countDownE_cb: function () {
      messageWarn(this, "考试结束");
      //   this.disableSubmit = true;
      this.submitExam("over");
    },
    last() {
      for (let i = 0; i < this.subjectIds.length; i++) {
        if (this.subjectIds[i].everyID == this.query.subjectId) {