智慧保安考试系统
shuishen
2023-11-06 c2481e77ae13eb6db48847499381dde001a4921e
规则更改
3 files modified
2447 ■■■■ changed files
.eslintrc.js 24 ●●●●● patch | view | raw | blame | history
src/views/singleperformance/index.vue 369 ●●●● patch | view | raw | blame | history
src/views/startexam/index.vue 2054 ●●●● patch | view | raw | blame | history
.eslintrc.js
@@ -1,17 +1,25 @@
/*
 * @Author: shuishen 1109946754@qq.com
 * @Date: 2021-09-22 10:57:16
 * @LastEditors: shuishen 1109946754@qq.com
 * @LastEditTime: 2023-11-06 14:34:21
 * @FilePath: \zhba_exam\.eslintrc.js
 * @Description:
 *
 * Copyright (c) 2023 by shuishen, All Rights Reserved.
 */
module.exports = {
  root: true,
  env: {
    node: true
  },
  'extends': [
    'plugin:vue/essential',
    'eslint:recommended'
  ],
  extends: ["plugin:vue/essential", "eslint:recommended"],
  rules: {
    'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
    'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off'
    "no-console": process.env.NODE_ENV === "production" ? "error" : "off",
    "no-debugger": process.env.NODE_ENV === "production" ? "error" : "off",
    "no-unused-vars": "off"
  },
  parserOptions: {
    parser: 'babel-eslint'
    parser: "babel-eslint"
  }
}
};
src/views/singleperformance/index.vue
@@ -1,8 +1,8 @@
/* * @Author: Morpheus * @Date: 2021-08-02 09:31:54 * @Last Modified by: liu *
@Last Modified time: 2021-10-09 17:13:00 * menu-name 成绩管理 */
<template>
  <div class="exam-end">
    <!-- <button class="logout"
    <div class="exam-end">
        <!-- <button class="logout"
          onmouseover="this.style.backgroundColor='red';" 
          onmouseout="this.style.backgroundColor='';"
          @click="handleLogout">退出系统</button>
@@ -15,213 +15,210 @@
                <span>本次考试得分:&nbsp;{{score}}&nbsp;分</span>
            </div>
        </div> -->
    <div class="startexam_heard">
      {{ UserData.title }}
    </div>
    <div class="startexam_main">
      <div class="s_m_img">
        <img src="/img/exam/startbg.jpg" alt="" />
      </div>
      <div class="s_m_value">
        <!-- <div class="s_m_value" v-if="examUserData.list.length != 0"> -->
        <div v-for="(item, index) in UserData.list" :key="index">
          <span class="s_m_v_title">{{ item.title }}</span>
          <span>{{ item.value }}</span>
        <div class="startexam_heard">
            {{ UserData.title }}
        </div>
        <div>
          <span class="s_m_v_title" style="font-size: 24px">成绩 :</span>
          <span style="font-size: 24px; color: red">
            <span style="font-size: 32px">{{ score }}</span> &nbsp;分</span
          >
        </div>
        <div>
        <div class="startexam_main">
            <div class="s_m_img">
                <img src="/img/exam/startbg.jpg" alt="" />
            </div>
            <div class="s_m_value">
                <!-- <div class="s_m_value" v-if="examUserData.list.length != 0"> -->
                <div v-for="(item, index) in UserData.list" :key="index">
                    <span class="s_m_v_title">{{ item.title }}</span>
                    <span>{{ item.value }}</span>
                </div>
                <div>
                    <span class="s_m_v_title" style="font-size: 24px">成绩 :</span>
                    <span style="font-size: 24px; color: red">
                        <span style="font-size: 32px">{{ score }}</span> &nbsp;分</span>
                </div>
                <!-- <div>
          <el-button type="primary" round v-if="score <= 60" @click="reself"
            >重新考试</el-button
          >
        </div> -->
            </div>
        </div>
      </div>
        <el-dialog title="提示" :visible.sync="dialogVisible" width="90%" :modal-append-to-body="false">
            <el-form ref="form" :model="form" label-width="400px">
                <el-form-item label="请联系管理员,输入重新考试密码:">
                    <el-input v-model="paddWord" placeholder="请输入密码" show-password></el-input>
                </el-form-item>
            </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button @click="dialogVisible = false">取 消</el-button>
                <el-button type="primary" @click="reself(1)">开始重考</el-button>
            </span>
        </el-dialog>
    </div>
    <el-dialog
      title="提示"
      :visible.sync="dialogVisible"
      width="90%"
      :modal-append-to-body="false"
    >
      <el-form ref="form" :model="form" label-width="400px">
        <el-form-item label="请联系管理员,输入重新考试密码:">
          <el-input
            v-model="paddWord"
            placeholder="请输入密码"
            show-password
          ></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="reself(1)">开始重考</el-button>
      </span>
    </el-dialog>
  </div>
</template>
<script>
import { getExamScore, reselfExamScore } from "@/api/exam/examscore";
import { mapState } from "vuex";
import { getExamScore, reselfExamScore } from "@/api/exam/examscore"
import { mapState } from "vuex"
export default {
  data() {
    return {
      score: 0,
      dialogVisible: false,
      paddWord: "",
      UserData: window.localStorage.getItem("useInfo")
        ? JSON.parse(window.localStorage.getItem("useInfo"))
        : ""
    };
  },
  created() {
    console.log(this.UserData, "UserDataUserDataUserData");
  },
  computed: {
    ...mapState({
      examUserData: state => state.exam.examUserData,
      scoreId: state =>
        state.exam.scoreId
          ? state.exam.scoreId
          : window.localStorage.getItem("scoreId")
    })
  },
  mounted() {
    //获取考试成绩
    this.getExamScore();
    console.log(this.examUserData);
  },
  methods: {
    //退出登录
    handleLogout() {
      this.$confirm("是否退出系统, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(() => {
        this.$store.dispatch("LogOut").then(() => {
          this.$router.push({ path: "/login" });
        });
      });
    },
    getExamScore() {
      var data = {
        // userId: this.$route.query.userId,
        // examId: this.$route.query.examId,
        id: this.scoreId
      };
      getExamScore(data).then(res => {
        if (res.data.data.theoryGrade != undefined) {
          this.score = res.data.data.theoryGrade;
    data () {
        return {
            score: 0,
            dialogVisible: false,
            paddWord: "",
            UserData: window.localStorage.getItem("useInfo")
                ? JSON.parse(window.localStorage.getItem("useInfo"))
                : ""
        }
        // console.log(this.score);
      });
    },
    reself(val) {
      //重新考试
      console.log(this.scoreId);
      // return;
      if (val == 1) {
        if (this.paddWord != "zhba123") {
          //重置密码
          this.$message({
            showClose: true,
            message: "密码错误!请联系管理员",
            type: "warning"
          });
          return;
    created () {
        console.log(this.UserData, "UserDataUserDataUserData")
    },
    computed: {
        ...mapState({
            examUserData: state => state.exam.examUserData,
            scoreId: state =>
                state.exam.scoreId
                    ? state.exam.scoreId
                    : window.localStorage.getItem("scoreId")
        })
    },
    mounted () {
        //获取考试成绩
        this.getExamScore()
        console.log(this.examUserData)
    },
    methods: {
        //退出登录
        handleLogout () {
            this.$confirm("是否退出系统, 是否继续?", "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning"
            }).then(() => {
                this.$store.dispatch("LogOut").then(() => {
                    this.$router.push({ path: "/login" })
                })
            })
        },
        getExamScore () {
            var data = {
                // userId: this.$route.query.userId,
                // examId: this.$route.query.examId,
                id: this.scoreId
            }
            getExamScore(data).then(res => {
                if (res.data.data.theoryGrade != undefined) {
                    this.score = res.data.data.theoryGrade
                }
                // console.log(this.score);
            })
        },
        reself (val) {
            //重新考试
            console.log(this.scoreId)
            // return;
            if (val == 1) {
                if (this.paddWord != "zhba123") {
                    //重置密码
                    this.$message({
                        showClose: true,
                        message: "密码错误!请联系管理员",
                        type: "warning"
                    })
                    return
                }
                reselfExamScore(this.scoreId).then(res => {
                    if ((res.data.success == true)) {
                        this.$message({
                            showClose: true,
                            message: "重置成功,返回主页重新点击开始考试!",
                            type: "success"
                        })
                        this.paddWord = ""
                        this.$router.push({
                            path: `/exam/startexam`
                        })
                    } else {
                        this.$message({
                            showClose: true,
                            message: "重置错误!请联系管理员",
                            type: "warning"
                        })
                    }
                })
            } else {
                this.dialogVisible = true
            }
        }
        reselfExamScore(this.scoreId).then(res => {
          if ((res.data.success = true)) {
            this.$message({
              showClose: true,
              message: "重置成功,返回主页重新点击开始考试!",
              type: "success"
            });
            this.paddWord = "";
            this.$router.push({
              path: `/exam/startexam`
            });
          } else {
            this.$message({
              showClose: true,
              message: "重置错误!请联系管理员",
              type: "warning"
            });
          }
        });
      } else {
        this.dialogVisible = true;
      }
    }
  }
};
}
</script>
<style lang="scss" scoped>
.exam-end {
  // width: calc(100% - 100px);
  // height: 89%;
  // margin: 2.5% 50px;
  // background-color: rgba($color: #fff, $alpha: 1);
  // display: flex;
  // align-items: center;
  // justify-content: center;
  // flex-direction: column;
  width: calc(100% - 100px);
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  .startexam_heard {
    font-size: 34px;
    color: rgb(240, 114, 29);
    position: relative;
    top: -10%;
  }
  .startexam_main {
    width: 960px;
    height: 300px;
    // border: 1px solid red;
    background-color: #fff;
    // width: calc(100% - 100px);
    // height: 89%;
    // margin: 2.5% 50px;
    // background-color: rgba($color: #fff, $alpha: 1);
    // display: flex;
    // align-items: center;
    // justify-content: center;
    // flex-direction: column;
    width: calc(100% - 100px);
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0px 0px 5px 3px rgba($color: #797979, $alpha: 0.2);
    .s_m_img {
      width: 50%;
      height: 100%;
      display: flex;
      align-items: center;
      justify-content: center;
      img {
        width: 90%;
        height: 90%;
      }
    justify-content: center;
    flex-direction: column;
    .startexam_heard {
        font-size: 34px;
        color: rgb(240, 114, 29);
        position: relative;
        top: -10%;
    }
    .s_m_value {
      width: 50%;
      height: 100%;
      display: flex;
      align-items: center;
      justify-content: center;
      flex-direction: column;
      div {
        width: 90%;
        height: 15%;
        font-size: 17px;
        .s_m_v_title {
          display: inline-block;
          width: 100px;
    .startexam_main {
        width: 960px;
        height: 300px;
        // border: 1px solid red;
        background-color: #fff;
        display: flex;
        align-items: center;
        justify-content: space-between;
        box-shadow: 0px 0px 5px 3px rgba($color: #797979, $alpha: 0.2);
        .s_m_img {
            width: 50%;
            height: 100%;
            display: flex;
            align-items: center;
            justify-content: center;
            img {
                width: 90%;
                height: 90%;
            }
        }
      }
        .s_m_value {
            width: 50%;
            height: 100%;
            display: flex;
            align-items: center;
            justify-content: center;
            flex-direction: column;
            div {
                width: 90%;
                height: 15%;
                font-size: 17px;
                .s_m_v_title {
                    display: inline-block;
                    width: 100px;
                }
            }
        }
    }
  }
}
// .logout {
src/views/startexam/index.vue
@@ -1,63 +1,64 @@
<template>
  <el-row class="morpheus-box">
    <el-col :span="24">
      <el-card>
        <div class="exam-card-body">
          <div class="subject-box">
            <el-row :gutter="30">
              <el-col :span="5">
                <div class="tool-bar">
                  <div class="time-remain">
                    <div class="time-remain_title">剩余时间 :</div>
    <el-row class="morpheus-box">
        <el-col :span="24">
            <el-card>
                <div class="exam-card-body">
                    <div class="subject-box">
                        <el-row :gutter="30">
                            <el-col :span="5">
                                <div class="tool-bar">
                                    <div class="time-remain">
                                        <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>
                    </div>
                  </div>
                  <div class="current-progress">
                    当前进度: {{ 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>
                  </div>
                  <!-- <el-button
                                        <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>
                                        </div>
                                    </div>
                                    <div class="current-progress">
                                        当前进度: {{ 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>
                                    </div>
                                    <!-- <el-button
                    type="success"
                    icon="el-icon-date"
                    @click="submitExam"
                    v-bind:disabled="disableSubmit"
                    >提交</el-button
                  > -->
                </div>
              </el-col>
              <el-col :span="18">
                <div class="subject-box-card">
                  <div class="subject-exam-title">
                    {{ exam.examinationName }}(共{{
                      subjectIds.length
                    }}题,合计100分)
                  </div>
                  <div class="subject_main">
                    <!-- 题目内容 -->
                    <choices ref="choices" v-show="this.query.type === 0" />
                                </div>
                            </el-col>
                            <el-col :span="18">
                                <div class="subject-box-card">
                                    <div class="subject-exam-title">
                                        {{ exam.examinationName }}(共{{
                                            subjectIds.length
                                        }}题,合计100分)
                                    </div>
                                    <div class="subject_main">
                                        <!-- 题目内容 -->
                                        <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" />
                                        <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
                                        <div class="subject-buttons" v-if="query.subjectId !== ''">
                                            <el-button type="primary" @click="last" :loading="loadingLast">上一题</el-button>
                                            <el-button type="primary" @click="next" class="buttons"
                                                :loading="loadingNext">下一题</el-button>
                                            <!-- <el-button
                      :disabled="timesIT"
                      type="success"
                      @click="submitExam"
@@ -70,956 +71,955 @@
                      "
                      >完成考试 {{ time }}</el-button
                    > -->
                      <el-button type="success" @click="submitExam" :disabled="subjectIndex != 100">完成考试 {{ time }}
                      </el-button>
                                            <el-button type="success" @click="submitExam" :disabled="completeTest">完成考试 {{
                                                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">
                            <div class="answer-card-title">
                                {{ exam.examinationName }}(共{{
                                    subjectIds.length
                                }}题,合计100分)
                            </div>
                            <div class="answer-card-split"></div>
                            <el-row class="answer-card-content">
                                <el-button :class="{ answered: subjectIds[index].answered }" circle
                                    v-for="(value, index) in subjectIds" :style="{ background: value.color }" :key="index"
                                    @click="toSubject(value.everyID, value.type, index)">&nbsp;{{ index + 1
                                    }}&nbsp;</el-button>
                                <!-- @click="toSubject(value.everyID, value.type, index)" -->
                                <!-- <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-row>
                        </el-dialog>
                    </div>
                  </div>
                </div>
              </el-col>
            </el-row>
            <el-dialog title="答题卡" :visible.sync="dialogVisible" width="50%" top="10vh" :modal="false" center
              class="datika">
              <div class="answer-card-title">
                {{ exam.examinationName }}(共{{
                  subjectIds.length
                }}题,合计100分)
              </div>
              <div class="answer-card-split"></div>
              <el-row class="answer-card-content">
                <!-- <el-button
                  :class="{ answered: subjectIds[index].answered }"
                  circle
                  v-for="(value, index) in subjectIds"
                  :style="{ background: value.color }"
                  :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>
                <!-- @click="toSubject(value.everyID, value.type, index)" -->
              </el-row>
            </el-dialog>
          </div>
        </div>
      </el-card>
    </el-col>
  </el-row>
            </el-card>
        </el-col>
    </el-row>
</template>
<script>
import { mapState } from "vuex";
import CountDown from "vue2-countdown";
import { saveAndNext } from "@/api/exam/answer";
import { getSubjectIds, getSubjectRefresh } from "@/api/exam/exam";
import { getCurrentTime } from "@/api/exam/examRecord";
import { getSubjectResultInfo } from "@/api/exam/subject";
import { mapState } from "vuex"
import CountDown from "vue2-countdown"
import { saveAndNext } from "@/api/exam/answer"
import { getSubjectIds, getSubjectRefresh } from "@/api/exam/exam"
import { getCurrentTime } from "@/api/exam/examRecord"
import { getSubjectResultInfo } from "@/api/exam/subject"
import moment from "moment";
import moment from "moment"
import {
  messageSuccess,
  messageFail,
  messageWarn,
  isNotEmpty
} from "@/util/util";
import Tinymce from "@/components/Tinymce";
import Choices from "@/components/Subjects/Choices";
    messageSuccess,
    messageFail,
    messageWarn,
    isNotEmpty
} from "@/util/util"
import Tinymce from "@/components/Tinymce"
import Choices from "@/components/Subjects/Choices"
import MultipleChoices from "@/components/Subjects/MultipleChoices";
import PracticalOperation from "@/components/Subjects/PracticalOperation";
import MultipleChoices from "@/components/Subjects/MultipleChoices"
import PracticalOperation from "@/components/Subjects/PracticalOperation"
// import ShortAnswer from '@/components/Subjects/ShortAnswer'
import Judgement from "@/components/Subjects/Judgement";
import Judgement from "@/components/Subjects/Judgement"
import { nextSubjectType } from "@/const/constant";
import { nextSubjectType } from "@/const/constant"
export default {
  components: {
    CountDown,
    Tinymce,
    Choices,
    MultipleChoices,
    PracticalOperation,
    Judgement
    // ShortAnswer,
  },
  data() {
    return {
      loadingLast: false,
      loadingNext: false,
      //1:绿色 2:红色  3:无色
      result: 3,
      currentTime: 0,
      startTime: 0,
      endTime: 0,
      disableSubmit: true,
      subjectIndex: 1,
      query: {
        examinationId: undefined,
        examRecordId: undefined,
        subjectId: undefined,
        userId: undefined,
        type: 0
      },
      subject: {},
      answer: "",
      dialogVisible: false,
      subjectIds: [],
      subjectStartTime: undefined,
      exam: {
        id: "590969316204220416",
        creator: "admin",
        createDate: 1560939664000,
        modifier: "preview",
        modifyDate: 1609835214000,
        delFlag: 0,
        examinationName: "",
        startTime: null,
        endTime: null,
        totalScore: 50,
        status: 0,
        remark: "全国计算机统考练习题10道",
        newRecord: false
      },
      firstFlag: true,
      times: ["30", "00"],
      timeOut: null,
      timeOTiv: null,
      timesIT: true,
      timesITValue: 0,
      first: true
    };
  },
  computed: {
    ...mapState({
      userInfo: state => state.user.userInfo,
      scoreId: state =>
        state.exam.scoreId
          ? state.exam.scoreId
          : window.localStorage.getItem("scoreId")
    }),
    time() {
      var d = [+this.times[0], +this.times[1]];
    }
  },
  created() {
    var useInfo = this.$store.state.exam.examUserData;
    var scoreType = this.$store.state.exam.scoreType
    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;
      }
    }
    if(scoreType==1){
      this.first = false;
    }
    const examInfo = this.$route.params.id;
    if (isNotEmpty(examInfo)) {
      // 试卷ID
      this.query.examinationId = this.$route.params.id;
      // 考场ID
      this.query.examRecordId = this.userInfo.user_id;
      this.query.userId = this.userInfo.user_id;
      this.exam.id = this.userInfo.user_id + "" + this.$route.params.id;
      this.exam.examinationName = this.$route.query.examName;
      // this.exam.startTime = this.$route.query.startTime
      // this.exam.endTime = this.$route.query.endTime
      // 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();
    components: {
        CountDown,
        Tinymce,
        Choices,
        MultipleChoices,
        PracticalOperation,
        Judgement
        // ShortAnswer,
    },
    countDownE_cb: function () {
      messageWarn(this, "考试结束");
      //   this.disableSubmit = true;
      this.submitExam("over");
    },
    bottonControl(time) {
      //倒计时循环
      let times = time * 60;
      var setTime = function (time) {
        let a, b, d;
        a = parseInt(time / 60);
        b = time - a * 60;
        d = a + ":" + b;
        return d;
      };
      if (this.timeOTiv == null) {
        this.timeOTiv = setInterval(res => {
          times--;
          this.timesITValue = setTime(times);
        }, 1000);
      } else {
        clearTimeout(this.timeOTiv);
        this.timeOTiv = null;
        this.timeOTiv = setInterval(res => {
          times--;
          this.timesITValue = setTime(times);
        }, 1000);
      }
      //倒计时定时
      if (this.timeOut == null) {
        this.timeOut = setTimeout(res => {
          this.timesIT = false;
          this.timesITValue--;
        }, time * 3600);
      } else {
        clearTimeout(this.timeOut);
        this.timeOut = null;
        this.timeOut = setTimeout(res => {
          this.timesIT = false;
        }, time * 3600);
      }
    },
    validateExamTime() {
      getCurrentTime()
        .then(response => {
          const currentTime = moment(response.data.data);
          if (currentTime.isAfter(this.exam.endTime)) {
            messageWarn(this, "考试已结束");
          } else if (currentTime.isBefore(this.exam.startTime)) {
            messageWarn(this, "考试未开始");
          } else {
            //判断是否是答过题
            this.startExam(currentTime);
            //判断是否是答过题
            if (this.first) {
              const current = currentTime.valueOf();
              // console.log(current, "首次");
              this.currentTime = current;
              this.startTime = current;
              this.subjectStartTime = current;
              //   // this.endTime = moment(this.exam.endTime).valueOf()
              this.endTime = current + 90 * 60 * 1000;
              this.bottonControl(90);
            }
            // this.disableSubmit = false;
          }
        })
        .catch(() => {
          messageFail(this, "开始考试失败!15");
        });
    },
    startExam(currentTime) {
      var scoreId = window.localStorage.getItem("scoreId");
      console.log(scoreId, this.first, "scoreIdscoreIdscoreIdscoreId");
      this.subjectIds = [];
      // if (this.first) {
      //   const current = currentTime.valueOf();
      //   console.log(current, "首次");
      //   this.currentTime = current;
      //   this.startTime = current;
      //   this.subjectStartTime = current;
      //   //   // this.endTime = moment(this.exam.endTime).valueOf()
      //   this.endTime = current + 60 * 60 * 1000;
      // }
      if (!this.first) {
        getSubjectRefresh(scoreId).then(obj => {
          const objs = obj.data.data;
          // console.log(objs, "objobjobjobjobjobj");
          const subjectData = objs.examSubjectChoicesVOSList;
          if (subjectData.length > 0) {
            //重载题目
            for (let i = 0; i < subjectData.length; i++) {
              this.subjectIds.push({
                subjectId: 1,
                everyID: subjectData[i].id,
                type: subjectData[i].choicesType,
                index: i + 1,
                answered: false,
                answer: "",
                score: subjectData[i].score,
                color: "#fff",
                fontColor: "#000",
                title: subjectData[i].subjectName
              });
            }
    data () {
        return {
            loadingLast: false,
            loadingNext: false,
            //1:绿色 2:红色  3:无色
            result: 3,
            currentTime: 0,
            startTime: 0,
            endTime: 0,
            disableSubmit: true,
            subjectIndex: 1,
            query: {
                examinationId: undefined,
                examRecordId: undefined,
                subjectId: undefined,
                userId: undefined,
                type: 0
            },
            subject: {},
            answer: "",
            dialogVisible: false,
            subjectIds: [],
            subjectStartTime: undefined,
            exam: {
                id: "590969316204220416",
                creator: "admin",
                createDate: 1560939664000,
                modifier: "preview",
                modifyDate: 1609835214000,
            //重载到当前题目
            let nowObj = objs.examSubjectChoicesVO;
            nowObj.answer = ""; //清除答案
            // console.log(nowObj, "nowObj");
            for (var i = 0; i < this.subjectIds.length; i++) {
              if (nowObj.id == this.subjectIds[i].everyID) {
                //定位显示题目
                this.subjectIndex = i + 1;
                //题目类型
                this.query.type = parseInt(this.subjectIds[i].type);
                // 题目id
                this.query.subjectId = this.subjectIds[i].everyID;
                this.setSubjectInfo(nowObj);
              }
            }
            // 添加到答题卡
            const anSwer = objs.examAnswerRecordList;
            for (var i = 0; i < this.subjectIds.length; i++) {
              for (var n = 0; n < anSwer.length; n++) {
                // console.log(anSwer[i].subjectChoicesId);
                if (anSwer[n].subjectChoicesId == this.subjectIds[i].everyID) {
                  if (anSwer[n].answerResult == 1) {
                    this.subjectIds[i].color = "#67C23A";
                    this.subjectIds[i].fontColor = "#fff";
                  }
                  if (anSwer[n].answerResult == 2) {
                    this.subjectIds[i].color = "red";
                    this.subjectIds[i].fontColor = "#fff";
                  }
                  var test = /,/g;
                  if (test.test(anSwer[n].answerOption)) {
                    let ans = anSwer[n].answerOption.split(","),
                      anw = [];
                    for (var k = 0; k < ans.length; k++) {
                      anw.push({
                        key: k + 1,
                        value: ans[k]
                      });
                    }
                    this.subjectIds[i].answer = anw;
                  } else {
                    this.subjectIds[i].answer = anSwer[n].answerOption;
                  }
                  // console.log(anSwer[n].answerOption, 1);
                  // console.log(this.subjectIds[i].answer, 2);
                }
              }
            }
            //适应时间
            const datyTime = objs.examScore.examTime;
                delFlag: 0,
            // console.log(objs, "datyTimedatyTimedatyTime");
            var duibiTime = function (newTime, oldTime) {
              var newtimes = new Date(newTime.replace(/-/g, '/')).getTime();
              var oldtimes = new Date(oldTime.replace(/-/g, '/')).getTime();
                examinationName: "",
              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);
            const current = currentTime.valueOf();
            this.currentTime = current;
            this.startTime = current;
            this.subjectStartTime = current;
            // // this.endTime = moment(this.exam.endTime).valueOf()
            if (listTime) {
              this.endTime = current + listTime * 60 * 1000;
              this.bottonControl(listTime - 30);
            } else {
              this.endTime = current + 0 * 60 * 1000;
              this.bottonControl(0);
            }
            // console.log(datyTime, currentTime, "刷新");
          }
        });
        // this.first = true;
        return;
      }
      // console.log(this.subjectIds);
      // 获取题目ID列表
      // console.log("subjectResponsesubjectResponsesubjectResponse");
      getSubjectIds(scoreId)
        .then(subjectResponse => {
          const subjectData = subjectResponse.data.data;
          // console.log(
          //   subjectResponse,
          //   "subjectResponsesubjectResponsesubjectResponse"
          // );
          // console.log(subjectData, "subjectDatasubjectDatasubjectData");
          if (subjectData.length > 0) {
            for (let i = 0; i < subjectData.length; i++) {
              this.subjectIds.push({
                subjectId: 1,
                everyID: subjectData[i].id,
                type: subjectData[i].choicesType,
                index: i + 1,
                answered: false,
                answer: "",
                score: subjectData[i].score,
                color: "#fff",
                fontColor: "#000"
              });
            }
                startTime: null,
                endTime: null,
            this.query.type = parseInt(this.subjectIds[0].type);
                totalScore: 50,
            // 准考证号
            this.query.subjectId = this.subjectIds[0].everyID;
                status: 0,
            this.updateSubjectIndex();
            // 获取当前题目信息
            getSubjectResultInfo({
              id: this.subjectIds[0].everyID
            })
              .then(response => {
                if (isNotEmpty(response.data.data)) {
                  response.data.data.answer = "";
                  this.setSubjectInfo(response.data.data);
                }
              })
              .catch(() => {
                messageFail(this, "获取题目失败!");
              });
          }
        })
        .catch(() => {
          messageFail(this, "开始考试失败!4646549888*8*");
        });
    },
                remark: "全国计算机统考练习题10道",
    last() {
      for (let i = 0; i < this.subjectIds.length; i++) {
        if (this.subjectIds[i].everyID == this.query.subjectId) {
          this.subjectIds[i].answer = this.getAnswer();
          this.markAnswered(this.subjectIds[i].answer, i);
          if (i === 0) {
            messageSuccess(this, "已经是第一题了");
            break;
          }
          let { everyID, type, index } = this.subjectIds[--i];
          this.subjectIndex = index;
          this.saveCurrentSubjectAndGetNextSubjectLast(
            nextSubjectType.last,
            everyID,
            type
          );
          break;
                newRecord: false
            },
            firstFlag: true,
            times: ["30", "00"],
            timeOut: null,
            timeOTiv: null,
            timesIT: true,
            timesITValue: 0,
            first: true
        }
      }
    },
    next() {
      for (let i = 0; i < this.subjectIds.length; i++) {
        if (this.subjectIds[i].everyID == this.query.subjectId) {
          if (this.getAnswer() == "") {
            this.$message({
              message: "请选择答案",
              type: "warning"
            });
            return;
          }
          //  if (this.getAnswer() == "") {
          //   this.$message({
          //     message: "请选择答案",
          //     type: "warning",
          //   });
          //   return;
          // }
          // console.log(this.getAnswer(), this.query.type);
          if (this.query.type == 3) {
            let goShiCao = true;
            const answer = this.getAnswer();
            for (let k in answer) {
              if (answer[k].value == "") {
                goShiCao = false;
              }
            }
            if (!goShiCao) {
              this.$message({
                message: "实操题目请选择完整顺序!",
                type: "warning"
              });
              return;
            }
          }
    computed: {
        ...mapState({
            userInfo: state => state.user.userInfo,
            scoreId: state =>
                state.exam.scoreId
                    ? state.exam.scoreId
                    : window.localStorage.getItem("scoreId")
        }),
          this.subjectIds[i].answer = this.getAnswer();
          this.markAnswered(this.subjectIds[i].answer, i);
          if (i === this.subjectIds.length - 1) {
            messageSuccess(this, "已经是最后一题了");
            break;
          }
          let { everyID, index } = this.subjectIds[++i];
          this.subjectIndex = index;
          this.saveCurrentSubjectAndGetNextSubject(
            nextSubjectType.next,
            everyID,
            this.subjectIds[i - 1]
          );
          break;
        completeTest () {
            return this.subjectIds.find(item => item.answer == "")
        }
      }
    },
    // 保存当前题目,同时根据序号加载下一题
    saveCurrentSubjectAndGetNextSubject(nextType, nextSubjectId, subjectIds) {
      this.startLoading(nextType);
      // console.log();
      var answerData = this.getAnswer();
      var str = "";
      if (Array.isArray(answerData)) {
        answerData.forEach(item => {
          str += item.value + ",";
        });
        str = str.substr(0, str.length - 1);
        answerData = str;
      }
      var data = {
        id: nextSubjectId,
        preSubJectId: this.query.subjectId,
        preResult: answerData,
        scoreId: this.scoreId
      };
      getSubjectResultInfo(data)
        .then(response => {
          if (response.data.data !== null) {
            // 保存成功后更新答题卡状态
            const subject = response.data.data;
            // console.log(subject.answer, 123456);
            //结果
            this.result = response.data.data.result;
            if (this.result == 1) {
              subjectIds.color = "#67C23A";
              subjectIds.fontColor = "#fff";
            }
            if (this.result == 2) {
              subjectIds.color = "red";
              subjectIds.fontColor = "#fff";
            }
            const { id, choicesType } = subject;
            this.query.subjectId = id;
            this.query.type = choicesType;
            for (let i = 0; i < this.subjectIds.length; i++) {
              if (this.subjectIds[i].everyID == nextSubjectId) {
                subject.answer = this.subjectIds[i].answer;
                break;
              }
            }
            this.setSubjectInfo(subject);
            // console.log(subject);
            this.$store.commit("setWindowSizeHeightAdd");
            // store.dispatch('SetSubjectInfo', subject).then(() => { })
          }
          // 更新时间
          getCurrentTime().then(response => {
            this.subjectStartTime = moment(response.data.data);
          });
          this.endLoading(nextType);
        })
        .catch(error => {
          console.log(error);
          this.$store.commit("setWindowSizeHeightAdd");
          messageFail(this, "获取题目失败");
          this.endLoading(nextType);
        });
    },
    // 保存当前题目,同时根据序号加载上一题
    saveCurrentSubjectAndGetNextSubjectLast(nextType, nextSubjectId) {
      this.startLoading(nextType);
      var data = {
        id: nextSubjectId
      };
      getSubjectResultInfo(data)
        .then(response => {
          if (response.data.data !== null) {
            // 保存成功后更新答题卡状态
            const subject = response.data.data;
            //结果
            this.result = response.data.data.result;
            // if(this.result==1){
            //      subjectIds.color = "#67C23A"
            // }
            // if(this.result==2){
            //     subjectIds.color = "red"
            // }
            const { id, choicesType } = subject;
            this.query.subjectId = id;
            this.query.type = choicesType;
            for (let i = 0; i < this.subjectIds.length; i++) {
              if (this.subjectIds[i].everyID == nextSubjectId) {
                subject.answer = this.subjectIds[i].answer;
                break;
              }
            }
            this.setSubjectInfo(subject);
            // store.dispatch('SetSubjectInfo', subject).then(() => { })
          }
          // 更新时间
          getCurrentTime().then(response => {
            this.subjectStartTime = moment(response.data.data);
          });
          this.endLoading(nextType);
        })
        .catch(error => {
          console.log(error);
          messageFail(this, "获取题目失败");
          this.endLoading(nextType);
        });
    },
    markAnswered(answer, index) {
      if (answer && answer !== null) {
        this.subjectIds[index].answered = true;
      }
    },
    // 答题卡
    answerCard() {
      this.dialogVisible = true;
    },
    // 跳转题目
    toSubject(everyID, type, index) {
      var ind = this.subjectIndex;
      if (this.firstFlag == false) {
        ind = this.subjectIndex;
      } else {
        ind = this.subjectIndex - 1;
      }
      this.subjectIds[ind].answer = this.getAnswer();
      this.markAnswered(this.subjectIds[ind].answer, ind);
      this.subjectIndex = index + 1;
      this.firstFlag = true;
      // 保存当前题目,同时加载下一题
      // console.log(nextSubjectType.next, 111);
      // console.log(everyID, 222);
      // console.log(type, 333);
      this.saveCurrentSubjectAndGetNextSubject(
        nextSubjectType.next,
        everyID,
        type
      );
      this.dialogVisible = false;
    },
    // 提交
    submitExam(val) {
      // console.log(val);
      var ind = this.subjectIndex;
      if (this.firstFlag == false) {
        ind = this.subjectIndex;
      } else {
        ind = this.subjectIndex - 1;
      }
      this.subjectIds[ind].answer = this.getAnswer();
      this.markAnswered(this.subjectIds[ind].answer, ind);
      if (val == "over") {
        //时间到了情况  自动提交
        this.disableSubmit = true;
        this.doSubmitExam();
        return;
      }
      this.$confirm("确定要提交吗?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          this.disableSubmit = true;
          this.doSubmitExam();
        })
        .catch(() => { });
    },
    doSubmitExam() {
      var obj = {
        id: this.$route.query.examScoreId,
        examName: this.$route.query.examName,
        candidateNo: this.$route.query.candidateNo,
        securityName: this.userInfo.user_name,
        userId: this.userInfo.user_id,
        allScore: this.$route.query.totalScore,
        company: this.userInfo.dept_id,
        examTime: this.startTime,
        papersId: this.$route.query.id,
        examEndTime: this.getCurrentTimes(),
        examResultVOS: null
      };
      var arr = [];
      // console.log(this.subjectIds);
      // debugger;
      // 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);
        if (item.type == 3 || item.type == 1) {
          var str = "";
          if (item.answer.length > 0) {
            //如果是数组
            if (item.answer instanceof Array) {
              item.answer.forEach(it => {
                if (it.value != "") {
                  str += it.value + ",";
                }
              });
              var a = str.substr(0, str.length - 1);
              arr.push({
                subjectChoicesId: item.everyID,
                value: a,
                grade: item.score
              });
            } else {
              arr.push({
                subjectChoicesId: item.everyID,
                value: item.answer,
                grade: item.score
              });
            }
          }
        } else {
          arr.push({
            subjectChoicesId: item.everyID,
            value: item.answer,
            grade: item.score
          });
        }
      }
      // console.log(arr, 123);
      // return;
      obj.examResultVOS = arr;
      // console.log(this.subjectIds, 456);
      // console.log(obj.examResultVOS, 789);
      saveAndNext(obj)
        .then(response => {
          messageSuccess(this, "提交成功");
          if (response) {
            this.$store.commit("DEL_TAG", this.$store.state.tags.tag);
            var obj = {
              userId: this.userInfo.user_id,
              examId: this.$route.query.id
            };
            this.$router.push({
              path: `/singleperformance/index`,
              query: obj
            });
          }
        })
        .catch(() => {
          this.disableSubmit = false;
          messageFail(this, "提交题目失败");
        });
    },
    // 选中选项
    toggleOption(answer) {
      this.answer = answer;
    },
    // 根据题目类型返回填写的答案
    getAnswer() {
      const ref = this.getSubjectRef();
      if (isNotEmpty(ref)) {
        const answer = ref.getAnswer();
        this.answer = answer;
        return answer;
        // {
        //     id: answerId,
        //     userId: this.userInfo.id,
        //     examinationId: this.query.examinationId,
        //     examRecordId: this.query.examRecordId,
        //     subjectId: this.query.subjectId,
        //     answer: answer,
        //     type: this.query.type,
        //     startTime: this.subjectStartTime
        // time() {
        //   var d = [+this.times[0], +this.times[1]];
        // }
      }
      return {};
    },
    // 获取题目索引
    getSubjectIndex(targetId) {
      for (let subject of this.subjectIds) {
        let { subjectId, index } = subject;
        if (subjectId === targetId) {
          return index;
    created () {
        var useInfo = this.$store.state.exam.examUserData
        var scoreType = this.$store.state.exam.scoreType
        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
            }
        }
      }
      return 1;
    },
    // 更新题目索引
    updateSubjectIndex() {
      this.subjectIndex = this.getSubjectIndex(this.query.subjectId);
    },
    startLoading(nextType) {
      if (nextType === nextSubjectType.next) {
        this.loadingNext = true;
      } else if (nextType === nextSubjectType.last) {
        this.loadingLast = true;
      } else {
        this.loadingNext = true;
      }
    },
    endLoading(nextType) {
      if (nextType === nextSubjectType.next) {
        this.loadingNext = false;
      } else if (nextType === nextSubjectType.last) {
        this.loadingLast = false;
      } else {
        this.loadingNext = false;
      }
    },
    //获取当前时间
    getCurrentTimes() {
      let date = new Date();
      let dateYear = date.getFullYear(); //获取年
      let dateMonth =
        date.getMonth() + 1 < 10
          ? "0" + (date.getMonth() + 1)
          : date.getMonth() + 1; //获取月
      let dateDate =
        date.getDate() < 10 ? "0" + date.getDate() : date.getDate(); //获取当日
      let dateDay = date.getDay(); //获取当日星期数
      let dateHours =
        date.getHours() < 10 ? "0" + date.getHours() : date.getHours(); //获取小时
      let dateMinutes =
        date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes(); //获取分钟
      let dateSeconds =
        date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds(); //获取秒
      return (
        dateYear +
        "-" +
        dateMonth +
        "-" +
        dateDate +
        " " +
        dateHours +
        ":" +
        dateMinutes +
        ":" +
        dateSeconds
      );
    },
    getSubjectRef() {
      let ref;
      switch (this.query.type) {
        case 0:
          ref = this.$refs.choices;
          break;
        case 1:
          ref = this.$refs.multipleChoices;
          break;
        case 2:
          ref = this.$refs.judgement;
          break;
        case 3:
          ref = this.$refs.practicalOperation;
          break;
        case 4:
          ref = this.$refs.shortAnswer;
          break;
      }
      return ref;
    },
    setSubjectInfo(subject) {
      const ref = this.getSubjectRef();
      // console.log(subject, "subject");
      if (isNotEmpty(ref)) {
        try {
          ref.setSubjectInfo(
            subject,
            this.subjectIds.length,
            this.subjectIndex
          );
        } catch (error) {
          console.error(error);
        if (scoreType == 1) {
            this.first = false
        }
      }
        const examInfo = this.$route.params.id
        if (isNotEmpty(examInfo)) {
            // 试卷ID
            this.query.examinationId = this.$route.params.id
            // 考场ID
            this.query.examRecordId = this.userInfo.user_id
            this.query.userId = this.userInfo.user_id
            this.exam.id = this.userInfo.user_id + "" + this.$route.params.id
            this.exam.examinationName = this.$route.query.examName
            // this.exam.startTime = this.$route.query.startTime
            // this.exam.endTime = this.$route.query.endTime
            // 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) {
            //倒计时循环
            let times = time * 60
            var setTime = function (time) {
                let a, b, d
                a = parseInt(time / 60)
                b = time - a * 60
                d = a + ":" + b
                return d
            }
            if (this.timeOTiv == null) {
                this.timeOTiv = setInterval(res => {
                    times--
                    this.timesITValue = setTime(times)
                }, 1000)
            } else {
                clearTimeout(this.timeOTiv)
                this.timeOTiv = null
                this.timeOTiv = setInterval(res => {
                    times--
                    this.timesITValue = setTime(times)
                }, 1000)
            }
            //倒计时定时
            if (this.timeOut == null) {
                this.timeOut = setTimeout(res => {
                    this.timesIT = false
                    this.timesITValue--
                }, time * 3600)
            } else {
                clearTimeout(this.timeOut)
                this.timeOut = null
                this.timeOut = setTimeout(res => {
                    this.timesIT = false
                }, time * 3600)
            }
        },
        validateExamTime () {
            getCurrentTime()
                .then(response => {
                    const currentTime = moment(response.data.data)
                    if (currentTime.isAfter(this.exam.endTime)) {
                        messageWarn(this, "考试已结束")
                    } else if (currentTime.isBefore(this.exam.startTime)) {
                        messageWarn(this, "考试未开始")
                    } else {
                        //判断是否是答过题
                        this.startExam(currentTime)
                        //判断是否是答过题
                        if (this.first) {
                            const current = currentTime.valueOf()
                            // console.log(current, "首次");
                            this.currentTime = current
                            this.startTime = current
                            this.subjectStartTime = current
                            //   // this.endTime = moment(this.exam.endTime).valueOf()
                            this.endTime = current + 90 * 60 * 1000
                            this.bottonControl(90)
                        }
                        // this.disableSubmit = false;
                    }
                })
                .catch(() => {
                    messageFail(this, "开始考试失败!15")
                })
        },
        startExam (currentTime) {
            var scoreId = window.localStorage.getItem("scoreId")
            // console.log(scoreId, this.first, "scoreIdscoreIdscoreIdscoreId")
            this.subjectIds = []
            // if (this.first) {
            //   const current = currentTime.valueOf();
            //   console.log(current, "首次");
            //   this.currentTime = current;
            //   this.startTime = current;
            //   this.subjectStartTime = current;
            //   //   // this.endTime = moment(this.exam.endTime).valueOf()
            //   this.endTime = current + 60 * 60 * 1000;
            // }
            if (!this.first) {
                getSubjectRefresh(scoreId).then(obj => {
                    const objs = obj.data.data
                    // console.log(objs, "objobjobjobjobjobj");
                    const subjectData = objs.examSubjectChoicesVOSList
                    if (subjectData.length > 0) {
                        //重载题目
                        for (let i = 0; i < subjectData.length; i++) {
                            this.subjectIds.push({
                                subjectId: 1,
                                everyID: subjectData[i].id,
                                type: subjectData[i].choicesType,
                                index: i + 1,
                                answered: false,
                                answer: "",
                                score: subjectData[i].score,
                                color: "#fff",
                                fontColor: "#000",
                                title: subjectData[i].subjectName
                            })
                        }
                        //重载到当前题目
                        let nowObj = objs.examSubjectChoicesVO
                        nowObj.answer = "" //清除答案
                        // console.log(nowObj, "nowObj");
                        for (var i = 0; i < this.subjectIds.length; i++) {
                            if (nowObj.id == this.subjectIds[i].everyID) {
                                //定位显示题目
                                this.subjectIndex = i + 1
                                //题目类型
                                this.query.type = parseInt(this.subjectIds[i].type)
                                // 题目id
                                this.query.subjectId = this.subjectIds[i].everyID
                                this.setSubjectInfo(nowObj)
                            }
                        }
                        // 添加到答题卡
                        const anSwer = objs.examAnswerRecordList
                        for (let i = 0; i < this.subjectIds.length; i++) {
                            for (var n = 0; n < anSwer.length; n++) {
                                // console.log(anSwer[i].subjectChoicesId);
                                if (anSwer[n].subjectChoicesId == this.subjectIds[i].everyID) {
                                    if (anSwer[n].answerResult == 1) {
                                        this.subjectIds[i].color = "#67C23A"
                                        this.subjectIds[i].fontColor = "#fff"
                                    }
                                    if (anSwer[n].answerResult == 2) {
                                        this.subjectIds[i].color = "red"
                                        this.subjectIds[i].fontColor = "#fff"
                                    }
                                    var test = /,/g
                                    if (test.test(anSwer[n].answerOption)) {
                                        let ans = anSwer[n].answerOption.split(","),
                                            anw = []
                                        for (var k = 0; k < ans.length; k++) {
                                            anw.push({
                                                key: k + 1,
                                                value: ans[k]
                                            })
                                        }
                                        this.subjectIds[i].answer = anw
                                    } else {
                                        this.subjectIds[i].answer = anSwer[n].answerOption
                                    }
                                    // console.log(anSwer[n].answerOption, 1);
                                    // console.log(this.subjectIds[i].answer, 2);
                                }
                            }
                        }
                        //适应时间
                        const datyTime = objs.examScore.examTime
                        // console.log(objs, "datyTimedatyTimedatyTime");
                        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)
                        const current = currentTime.valueOf()
                        this.currentTime = current
                        this.startTime = current
                        this.subjectStartTime = current
                        // // this.endTime = moment(this.exam.endTime).valueOf()
                        if (listTime) {
                            this.endTime = current + listTime * 60 * 1000
                            this.bottonControl(listTime - 30)
                        } else {
                            this.endTime = current + 0 * 60 * 1000
                            this.bottonControl(0)
                        }
                        // console.log(datyTime, currentTime, "刷新");
                    }
                })
                // this.first = true;
                return
            }
            // console.log(this.subjectIds);
            // 获取题目ID列表
            // console.log("subjectResponsesubjectResponsesubjectResponse");
            getSubjectIds(scoreId)
                .then(subjectResponse => {
                    const subjectData = subjectResponse.data.data
                    // console.log(
                    //   subjectResponse,
                    //   "subjectResponsesubjectResponsesubjectResponse"
                    // );
                    // console.log(subjectData, "subjectDatasubjectDatasubjectData");
                    if (subjectData.length > 0) {
                        for (let i = 0; i < subjectData.length; i++) {
                            this.subjectIds.push({
                                subjectId: 1,
                                everyID: subjectData[i].id,
                                type: subjectData[i].choicesType,
                                index: i + 1,
                                answered: false,
                                answer: "",
                                score: subjectData[i].score,
                                color: "#fff",
                                fontColor: "#000"
                            })
                        }
                        this.query.type = parseInt(this.subjectIds[0].type)
                        // 准考证号
                        this.query.subjectId = this.subjectIds[0].everyID
                        this.updateSubjectIndex()
                        // 获取当前题目信息
                        getSubjectResultInfo({
                            id: this.subjectIds[0].everyID
                        })
                            .then(response => {
                                if (isNotEmpty(response.data.data)) {
                                    response.data.data.answer = ""
                                    this.setSubjectInfo(response.data.data)
                                }
                            })
                            .catch(() => {
                                messageFail(this, "获取题目失败!")
                            })
                    }
                })
                .catch(() => {
                    messageFail(this, "开始考试失败!4646549888*8*")
                })
        },
        last () {
            for (let i = 0; i < this.subjectIds.length; i++) {
                if (this.subjectIds[i].everyID == this.query.subjectId) {
                    this.subjectIds[i].answer = this.getAnswer()
                    this.markAnswered(this.subjectIds[i].answer, i)
                    if (i === 0) {
                        messageSuccess(this, "已经是第一题了")
                        break
                    }
                    let { everyID, type, index } = this.subjectIds[--i]
                    this.subjectIndex = index
                    this.saveCurrentSubjectAndGetNextSubjectLast(
                        nextSubjectType.last,
                        everyID,
                        type
                    )
                    break
                }
            }
        },
        next () {
            for (let i = 0; i < this.subjectIds.length; i++) {
                if (this.subjectIds[i].everyID == this.query.subjectId) {
                    //  if (this.getAnswer() == "") {
                    //   this.$message({
                    //     message: "请选择答案",
                    //     type: "warning",
                    //   });
                    //   return;
                    // }
                    // console.log(this.getAnswer(), this.query.type);
                    if (this.query.type == 3) {
                        let goShiCao = true
                        const answer = this.getAnswer()
                        for (let k in answer) {
                            if (answer[k].value == "") {
                                goShiCao = false
                            }
                        }
                        if (!goShiCao) {
                            this.$message({
                                message: "实操题目请选择完整顺序!",
                                type: "warning"
                            })
                            return
                        }
                    }
                    this.subjectIds[i].answer = this.getAnswer()
                    this.markAnswered(this.subjectIds[i].answer, i)
                    if (i === this.subjectIds.length - 1) {
                        messageSuccess(this, "已经是最后一题了")
                        break
                    }
                    let { everyID, index } = this.subjectIds[++i]
                    this.subjectIndex = index
                    this.saveCurrentSubjectAndGetNextSubject(
                        nextSubjectType.next,
                        everyID,
                        this.subjectIds[i - 1]
                    )
                    break
                }
            }
        },
        // 保存当前题目,同时根据序号加载下一题
        saveCurrentSubjectAndGetNextSubject (nextType, nextSubjectId, subjectIds) {
            // console.log(nextType, nextSubjectId, subjectIds, '2222222')
            this.startLoading(nextType)
            var answerData = this.getAnswer()
            var str = ""
            if (Array.isArray(answerData)) {
                answerData.forEach(item => {
                    str += item.value + ","
                })
                str = str.substr(0, str.length - 1)
                answerData = str
            }
            var data = {
                id: nextSubjectId,
                preSubJectId: this.query.subjectId,
                preResult: answerData,
                scoreId: this.scoreId
            }
            getSubjectResultInfo(data)
                .then(response => {
                    if (response.data.data !== null) {
                        // 保存成功后更新答题卡状态
                        const subject = response.data.data
                        // console.log(subject.answer, 123456);
                        //结果
                        this.result = response.data.data.result
                        // console.log(response.data.data.result, subjectIds, '----1----1----')
                        if (this.result == 1) {
                            subjectIds.color = "#67C23A"
                            subjectIds.fontColor = "#fff"
                        }
                        if (this.result == 2) {
                            subjectIds.color = "red"
                            subjectIds.fontColor = "#fff"
                        }
                        const { id, choicesType } = subject
                        this.query.subjectId = id
                        this.query.type = choicesType
                        for (let i = 0; i < this.subjectIds.length; i++) {
                            if (this.subjectIds[i].everyID == nextSubjectId) {
                                subject.answer = this.subjectIds[i].answer
                                break
                            }
                        }
                        this.setSubjectInfo(subject)
                        // console.log(subject);
                        this.$store.commit("setWindowSizeHeightAdd")
                        // store.dispatch('SetSubjectInfo', subject).then(() => { })
                    }
                    // 更新时间
                    getCurrentTime().then(response => {
                        this.subjectStartTime = moment(response.data.data)
                    })
                    this.endLoading(nextType)
                })
                .catch(error => {
                    console.log(error)
                    this.$store.commit("setWindowSizeHeightAdd")
                    messageFail(this, "获取题目失败!")
                    this.endLoading(nextType)
                })
        },
        // 保存当前题目,同时根据序号加载上一题
        saveCurrentSubjectAndGetNextSubjectLast (nextType, nextSubjectId) {
            this.startLoading(nextType)
            var data = {
                id: nextSubjectId
            }
            getSubjectResultInfo(data)
                .then(response => {
                    if (response.data.data !== null) {
                        // 保存成功后更新答题卡状态
                        const subject = response.data.data
                        //结果
                        this.result = response.data.data.result
                        // if(this.result==1){
                        //      subjectIds.color = "#67C23A"
                        // }
                        // if(this.result==2){
                        //     subjectIds.color = "red"
                        // }
                        const { id, choicesType } = subject
                        this.query.subjectId = id
                        this.query.type = choicesType
                        for (let i = 0; i < this.subjectIds.length; i++) {
                            if (this.subjectIds[i].everyID == nextSubjectId) {
                                subject.answer = this.subjectIds[i].answer
                                break
                            }
                        }
                        this.setSubjectInfo(subject)
                        // store.dispatch('SetSubjectInfo', subject).then(() => { })
                    }
                    // 更新时间
                    getCurrentTime().then(response => {
                        this.subjectStartTime = moment(response.data.data)
                    })
                    this.endLoading(nextType)
                })
                .catch(error => {
                    console.log(error)
                    messageFail(this, "获取题目失败!")
                    this.endLoading(nextType)
                })
        },
        markAnswered (answer, index) {
            if (answer && answer !== null) {
                this.subjectIds[index].answered = true
            }
        },
        // 答题卡
        answerCard () {
            this.dialogVisible = true
        },
        // 跳转题目
        toSubject (everyID, type, index) {
            var ind = this.subjectIndex
            if (this.firstFlag == false) {
                ind = this.subjectIndex
            } else {
                ind = this.subjectIndex - 1
            }
            this.subjectIds[ind].answer = this.getAnswer()
            this.markAnswered(this.subjectIds[ind].answer, ind)
            this.subjectIndex = index + 1
            this.firstFlag = true
            // 保存当前题目,同时加载下一题
            // console.log(nextSubjectType.next, 111);
            // console.log(everyID, 222);
            // console.log(type, 333);
            this.saveCurrentSubjectAndGetNextSubject(
                nextSubjectType.next,
                everyID,
                this.subjectIds[ind]
            )
            this.dialogVisible = false
        },
        // 提交
        submitExam (val) {
            // console.log(val);
            var ind = this.subjectIndex
            if (this.firstFlag == false) {
                ind = this.subjectIndex
            } else {
                ind = this.subjectIndex - 1
            }
            this.subjectIds[ind].answer = this.getAnswer()
            this.markAnswered(this.subjectIds[ind].answer, ind)
            if (val == "over") {
                //时间到了情况  自动提交
                this.disableSubmit = true
                this.doSubmitExam()
                return
            }
            this.$confirm("确定要提交吗?", "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning"
            })
                .then(() => {
                    this.disableSubmit = true
                    this.doSubmitExam()
                })
                .catch(() => { })
        },
        doSubmitExam () {
            var obj = {
                id: this.$route.query.examScoreId,
                examName: this.$route.query.examName,
                candidateNo: this.$route.query.candidateNo,
                securityName: this.userInfo.user_name,
                userId: this.userInfo.user_id,
                allScore: this.$route.query.totalScore,
                company: this.userInfo.dept_id,
                examTime: this.startTime,
                papersId: this.$route.query.id,
                examEndTime: this.getCurrentTimes(),
                examResultVOS: null
            }
            var arr = []
            // console.log(this.subjectIds);
            // debugger;
            // 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);
                if (item.type == 3 || item.type == 1) {
                    var str = ""
                    if (item.answer.length > 0) {
                        //如果是数组
                        if (item.answer instanceof Array) {
                            item.answer.forEach(it => {
                                if (it.value != "") {
                                    str += it.value + ","
                                }
                            })
                            var a = str.substr(0, str.length - 1)
                            arr.push({
                                subjectChoicesId: item.everyID,
                                value: a,
                                grade: item.score
                            })
                        } else {
                            arr.push({
                                subjectChoicesId: item.everyID,
                                value: item.answer,
                                grade: item.score
                            })
                        }
                    }
                } else {
                    arr.push({
                        subjectChoicesId: item.everyID,
                        value: item.answer,
                        grade: item.score
                    })
                }
            }
            // console.log(arr, 123);
            // return;
            obj.examResultVOS = arr
            // console.log(this.subjectIds, 456);
            // console.log(obj.examResultVOS, 789);
            saveAndNext(obj)
                .then(response => {
                    messageSuccess(this, "提交成功")
                    if (response) {
                        this.$store.commit("DEL_TAG", this.$store.state.tags.tag)
                        var obj = {
                            userId: this.userInfo.user_id,
                            examId: this.$route.query.id
                        }
                        this.$router.push({
                            path: `/singleperformance/index`,
                            query: obj
                        })
                    }
                })
                .catch(() => {
                    this.disableSubmit = false
                    messageFail(this, "提交题目失败")
                })
        },
        // 选中选项
        toggleOption (answer) {
            this.answer = answer
        },
        // 根据题目类型返回填写的答案
        getAnswer () {
            const ref = this.getSubjectRef()
            if (isNotEmpty(ref)) {
                const answer = ref.getAnswer()
                this.answer = answer
                return answer
                // {
                //     id: answerId,
                //     userId: this.userInfo.id,
                //     examinationId: this.query.examinationId,
                //     examRecordId: this.query.examRecordId,
                //     subjectId: this.query.subjectId,
                //     answer: answer,
                //     type: this.query.type,
                //     startTime: this.subjectStartTime
                // }
            }
            return {}
        },
        // 获取题目索引
        getSubjectIndex (targetId) {
            for (let subject of this.subjectIds) {
                let { subjectId, index } = subject
                if (subjectId === targetId) {
                    return index
                }
            }
            return 1
        },
        // 更新题目索引
        updateSubjectIndex () {
            this.subjectIndex = this.getSubjectIndex(this.query.subjectId)
        },
        startLoading (nextType) {
            if (nextType === nextSubjectType.next) {
                this.loadingNext = true
            } else if (nextType === nextSubjectType.last) {
                this.loadingLast = true
            } else {
                this.loadingNext = true
            }
        },
        endLoading (nextType) {
            if (nextType === nextSubjectType.next) {
                this.loadingNext = false
            } else if (nextType === nextSubjectType.last) {
                this.loadingLast = false
            } else {
                this.loadingNext = false
            }
        },
        //获取当前时间
        getCurrentTimes () {
            let date = new Date()
            let dateYear = date.getFullYear() //获取年
            let dateMonth =
                date.getMonth() + 1 < 10
                    ? "0" + (date.getMonth() + 1)
                    : date.getMonth() + 1 //获取月
            let dateDate =
                date.getDate() < 10 ? "0" + date.getDate() : date.getDate() //获取当日
            let dateDay = date.getDay() //获取当日星期数
            let dateHours =
                date.getHours() < 10 ? "0" + date.getHours() : date.getHours() //获取小时
            let dateMinutes =
                date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes() //获取分钟
            let dateSeconds =
                date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds() //获取秒
            return (
                dateYear +
                "-" +
                dateMonth +
                "-" +
                dateDate +
                " " +
                dateHours +
                ":" +
                dateMinutes +
                ":" +
                dateSeconds
            )
        },
        getSubjectRef () {
            let ref
            switch (this.query.type) {
                case 0:
                    ref = this.$refs.choices
                    break
                case 1:
                    ref = this.$refs.multipleChoices
                    break
                case 2:
                    ref = this.$refs.judgement
                    break
                case 3:
                    ref = this.$refs.practicalOperation
                    break
                case 4:
                    ref = this.$refs.shortAnswer
                    break
            }
            return ref
        },
        setSubjectInfo (subject) {
            const ref = this.getSubjectRef()
            // console.log(subject, "subject");
            if (isNotEmpty(ref)) {
                try {
                    ref.setSubjectInfo(
                        subject,
                        this.subjectIds.length,
                        this.subjectIndex
                    )
                } catch (error) {
                    console.error(error)
                }
            }
        }
    }
  }
};
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
@@ -1029,118 +1029,118 @@
$fontSize3: 40px;
.subject-box {
  margin-top: 25px;
  margin-left: 20px;
  height: 100%;
    margin-top: 25px;
    margin-left: 20px;
    height: 100%;
}
.subject-box-card {
  font-size: 28px;
  width: 80%;
  margin-bottom: 30px;
  min-height: 400px;
    font-size: 28px;
    width: 80%;
    margin-bottom: 30px;
    min-height: 400px;
}
.subject-buttons {
  text-align: left;
  position: relative;
  top: 70px;
  left: 390px;
    text-align: left;
    position: relative;
    top: 70px;
    left: 390px;
  // top: 70%;
  // right: 30%;
  .buttons {
    // border: 1px solid green;
  }
    // top: 70%;
    // right: 30%;
    .buttons {
        // border: 1px solid green;
    }
}
.tool-bar {
  margin-left: 20px;
    margin-left: 20px;
}
.time-remain_title {
  font-size: $fontSize2;
    font-size: $fontSize2;
}
.time-remain .time {
  display: block;
  font-size: $fontSize3;
  line-height: $fontSize3;
  color: #ff0000;
  font-weight: 400;
  position: relative;
  //   top: -20px;
    display: block;
    font-size: $fontSize3;
    line-height: $fontSize3;
    color: #ff0000;
    font-weight: 400;
    position: relative;
    //   top: -20px;
}
.current-progress {
  font-size: $fontSize2;
    font-size: $fontSize2;
}
.answer-card {
  margin: 15px 0;
    margin: 15px 0;
}
.el-dates {
  font-size: $fontSize1;
    font-size: $fontSize1;
}
.subject-exam-title {
  margin-bottom: 25px;
    margin-bottom: 25px;
}
/* 答题卡 */
.answer-card-title {
  font-size: 24px;
  color: #3a3e51;
  line-height: 17px;
  padding: 10px 0;
    font-size: 24px;
    color: #3a3e51;
    line-height: 17px;
    padding: 10px 0;
}
.answer-card-split {
  width: 100%;
  border-bottom: 1px solid #e6e6e6;
    width: 100%;
    border-bottom: 1px solid #e6e6e6;
}
.answer-card-content {
  padding-bottom: 10px;
  font-size: 0;
  margin-right: -15px;
    padding-bottom: 10px;
    font-size: 0;
    margin-right: -15px;
  >button {
    margin-top: 5px;
  }
    >button {
        margin-top: 5px;
    }
}
.answered {
  background-color: greenyellow;
    background-color: greenyellow;
}
#avue-view>.morpheus-box {
  position: absolute;
  width: calc(100% - 100px);
  height: 85%;
  border-radius: 4px;
  top: 10%;
  left: 50px;
  padding: 10px !important;
  box-sizing: border-box;
    position: absolute;
    width: calc(100% - 100px);
    height: 85%;
    border-radius: 4px;
    top: 10%;
    left: 50px;
    padding: 10px !important;
    box-sizing: border-box;
}
.exam-card-body {
  // border-top: 5px solid #ffa820 !important;
    // border-top: 5px solid #ffa820 !important;
}
$sizeBut: 50px;
.el-button.is-circle {
  text-align: center;
  width: $sizeBut !important;
  height: $sizeBut !important;
  border-radius: $sizeBut !important;
  margin-left: 0 !important;
  margin-right: 10px !important;
  margin-top: 10px !important;
  //   display: flex;
  //   justify-content: center;
    text-align: center;
    width: $sizeBut !important;
    height: $sizeBut !important;
    border-radius: $sizeBut !important;
    margin-left: 0 !important;
    margin-right: 10px !important;
    margin-top: 10px !important;
    //   display: flex;
    //   justify-content: center;
}
</style>