src/views/startexam/index.vue
@@ -100,12 +100,9 @@
                      "
                      >完成考试 {{ time }}</el-button
                    > -->
                      <el-button
                        type="success"
                        @click="submitExam"
                        :disabled="subjectIndex != 60"
                        >完成考试 {{ time }}</el-button
                      >
                      <el-button type="success" @click="submitExam"
                        >完成考试 {{ time }}
                      </el-button>
                    </div>
                  </div>
                </div>
@@ -140,9 +137,9 @@
                  v-for="(value, index) in subjectIds"
                  :style="{ background: value.color, color: value.fontColor }"
                  :key="index"
                  @click="toSubject(value.everyID, value.type, index)"
                  >&nbsp;{{ index + 1 }}&nbsp;</el-button
                >
                <!-- @click="toSubject(value.everyID, value.type, index)" -->
              </el-row>
            </el-dialog>
          </div>
@@ -164,7 +161,7 @@
  messageSuccess,
  messageFail,
  messageWarn,
  isNotEmpty,
  isNotEmpty
} from "@/util/util";
import Tinymce from "@/components/Tinymce";
import Choices from "@/components/Subjects/Choices";
@@ -184,7 +181,7 @@
    Choices,
    MultipleChoices,
    PracticalOperation,
    Judgement,
    Judgement
    // ShortAnswer,
  },
  data() {
@@ -203,7 +200,7 @@
        examRecordId: undefined,
        subjectId: undefined,
        userId: undefined,
        type: 0,
        type: 0
      },
      subject: {},
      answer: "",
@@ -230,7 +227,7 @@
        remark: "全国计算机统考练习题10道",
        newRecord: false,
        newRecord: false
      },
      firstFlag: true,
      times: ["30", "00"],
@@ -238,20 +235,20 @@
      timeOTiv: null,
      timesIT: true,
      timesITValue: 0,
      first: true,
      first: true
    };
  },
  computed: {
    ...mapState({
      userInfo: (state) => state.user.userInfo,
      scoreId: (state) =>
      userInfo: state => state.user.userInfo,
      scoreId: state =>
        state.exam.scoreId
          ? state.exam.scoreId
          : window.localStorage.getItem("scoreId"),
          : window.localStorage.getItem("scoreId")
    }),
    time() {
      var d = [+this.times[0], +this.times[1]];
    },
    }
  },
  created() {
    var useInfo = this.$store.state.exam.examUserData;
@@ -293,12 +290,12 @@
    }
  },
  methods: {
    countDownS_cb: function () {
    countDownS_cb: function() {
      // console.log(12456);
      messageSuccess(this, "考试开始");
      this.startTime = this.getCurrentTimes();
    },
    countDownE_cb: function () {
    countDownE_cb: function() {
      messageWarn(this, "考试结束");
      //   this.disableSubmit = true;
      // this.submitExam("over");
@@ -306,7 +303,7 @@
    bottonControl(time) {
      //倒计时循环
      let times = time * 60;
      var setTime = function (time) {
      var setTime = function(time) {
        let a, b, d;
        a = parseInt(time / 60);
        b = time - a * 60;
@@ -314,35 +311,35 @@
        return d;
      };
      if (this.timeOTiv == null) {
        this.timeOTiv = setInterval((res) => {
        this.timeOTiv = setInterval(res => {
          times--;
          this.timesITValue = setTime(times);
        }, 1000);
      } else {
        clearTimeout(this.timeOTiv);
        this.timeOTiv = null;
        this.timeOTiv = setInterval((res) => {
        this.timeOTiv = setInterval(res => {
          times--;
          this.timesITValue = setTime(times);
        }, 1000);
      }
      //倒计时定时
      if (this.timeOut == null) {
        this.timeOut = setTimeout((res) => {
        this.timeOut = setTimeout(res => {
          this.timesIT = false;
          this.timesITValue--;
        }, time * 3600);
      } else {
        clearTimeout(this.timeOut);
        this.timeOut = null;
        this.timeOut = setTimeout((res) => {
        this.timeOut = setTimeout(res => {
          this.timesIT = false;
        }, time * 3600);
      }
    },
    validateExamTime() {
      getCurrentTime()
        .then((response) => {
        .then(response => {
          // console.log(response, 7777);
          const currentTime = moment(response.data.data);
          if (currentTime.isAfter(this.exam.endTime)) {
@@ -384,7 +381,7 @@
      //   this.endTime = current + 60 * 60 * 1000;
      // }
      if (!this.first) {
        getSubjectRefresh(scoreId).then((obj) => {
        getSubjectRefresh(scoreId).then(obj => {
          const objs = obj.data.data;
          // console.log(objs, "objobjobjobjobjobj");
          const subjectData = objs.examSubjectChoicesVOSList;
@@ -401,7 +398,7 @@
                score: subjectData[i].score,
                color: "#fff",
                fontColor: "#000",
                title: subjectData[i].subjectName,
                title: subjectData[i].subjectName
              });
            }
@@ -441,7 +438,7 @@
                    for (var k = 0; k < ans.length; k++) {
                      anw.push({
                        key: k + 1,
                        value: ans[k],
                        value: ans[k]
                      });
                    }
                    this.subjectIds[i].answer = anw;
@@ -456,7 +453,7 @@
            //适应时间
            const datyTime = objs.examScore.examTime;
            // console.log(objs, "datyTimedatyTimedatyTime");
            var duibiTime = function (newTime, oldTime) {
            var duibiTime = function(newTime, oldTime) {
              var newYear = newTime.split(" ")[0],
                newDat = newTime.split(" ")[1],
                oldYear = oldTime.split(" ")[0],
@@ -467,12 +464,12 @@
                let newD = {
                  s: +newDat.split(":")[0],
                  f: +newDat.split(":")[1],
                  m: +newDat.split(":")[2],
                  m: +newDat.split(":")[2]
                };
                let oldD = {
                  s: +oldDat.split(":")[0],
                  f: +oldDat.split(":")[1],
                  m: +oldDat.split(":")[2],
                  m: +oldDat.split(":")[2]
                };
                if (newD.s - oldD.s > 1) {
                  return false;
@@ -512,7 +509,7 @@
      // 获取题目ID列表
      // console.log("subjectResponsesubjectResponsesubjectResponse");
      getSubjectIds(scoreId)
        .then((subjectResponse) => {
        .then(subjectResponse => {
          const subjectData = subjectResponse.data.data;
          // console.log(
          //   subjectResponse,
@@ -530,7 +527,7 @@
                answer: "",
                score: subjectData[i].score,
                color: "#fff",
                fontColor: "#000",
                fontColor: "#000"
              });
            }
@@ -542,9 +539,9 @@
            this.updateSubjectIndex();
            // 获取当前题目信息
            getSubjectResultInfo({
              id: this.subjectIds[0].everyID,
              id: this.subjectIds[0].everyID
            })
              .then((response) => {
              .then(response => {
                if (isNotEmpty(response.data.data)) {
                  response.data.data.answer = "";
                  this.setSubjectInfo(response.data.data);
@@ -592,7 +589,7 @@
          if (this.getAnswer() == "") {
            this.$message({
              message: "请选择答案",
              type: "warning",
              type: "warning"
            });
            return;
          }
@@ -615,7 +612,7 @@
            if (!goShiCao) {
              this.$message({
                message: "实操题目请选择完整顺序!",
                type: "warning",
                type: "warning"
              });
              return;
            }
@@ -655,7 +652,7 @@
      var str = "";
      if (Array.isArray(answerData)) {
        answerData.forEach((item) => {
        answerData.forEach(item => {
          str += item.value + ",";
        });
@@ -668,10 +665,10 @@
        id: nextSubjectId,
        preSubJectId: this.query.subjectId,
        preResult: answerData,
        scoreId: this.scoreId,
        scoreId: this.scoreId
      };
      getSubjectResultInfo(data)
        .then((response) => {
        .then(response => {
          if (response.data.data !== null) {
            // 保存成功后更新答题卡状态
            const subject = response.data.data;
@@ -703,17 +700,20 @@
            }
            this.setSubjectInfo(subject);
            // console.log(subject);
            console.log(subject);
            this.$store.commit("setWindowSizeHeightAdd");
            // store.dispatch('SetSubjectInfo', subject).then(() => { })
          }
          // 更新时间
          getCurrentTime().then((response) => {
          getCurrentTime().then(response => {
            this.subjectStartTime = moment(response.data.data);
          });
          this.endLoading(nextType);
        })
        .catch((error) => {
        .catch(error => {
          console.log(error);
          this.$store.commit("setWindowSizeHeightAdd");
          messageFail(this, "获取题目失败");
          this.endLoading(nextType);
        });
@@ -723,10 +723,10 @@
      this.startLoading(nextType);
      var data = {
        id: nextSubjectId,
        id: nextSubjectId
      };
      getSubjectResultInfo(data)
        .then((response) => {
        .then(response => {
          if (response.data.data !== null) {
            // 保存成功后更新答题卡状态
            const subject = response.data.data;
@@ -760,12 +760,12 @@
            // store.dispatch('SetSubjectInfo', subject).then(() => { })
          }
          // 更新时间
          getCurrentTime().then((response) => {
          getCurrentTime().then(response => {
            this.subjectStartTime = moment(response.data.data);
          });
          this.endLoading(nextType);
        })
        .catch((error) => {
        .catch(error => {
          console.log(error);
          messageFail(this, "获取题目失败");
          this.endLoading(nextType);
@@ -833,7 +833,7 @@
      this.$confirm("确定要提交吗?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
        type: "warning"
      })
        .then(() => {
          this.disableSubmit = true;
@@ -853,7 +853,7 @@
        examTime: this.startTime,
        papersId: this.$route.query.id,
        examEndTime: this.getCurrentTimes(),
        examResultVOS: null,
        examResultVOS: null
      };
      var arr = [];
      console.log(this.subjectIds);
@@ -867,7 +867,7 @@
          if (item.answer.length > 0) {
            //如果是数组
            if (item.answer instanceof Array) {
              item.answer.forEach((it) => {
              item.answer.forEach(it => {
                if (it.value != "") {
                  str += it.value + ",";
                }
@@ -878,13 +878,13 @@
              arr.push({
                subjectChoicesId: item.everyID,
                value: a,
                grade: item.score,
                grade: item.score
              });
            } else {
              arr.push({
                subjectChoicesId: item.everyID,
                value: item.answer,
                grade: item.score,
                grade: item.score
              });
            }
          }
@@ -892,7 +892,7 @@
          arr.push({
            subjectChoicesId: item.everyID,
            value: item.answer,
            grade: item.score,
            grade: item.score
          });
        }
      }
@@ -903,17 +903,17 @@
      // console.log(obj.examResultVOS, 789);
      saveAndNext(obj)
        .then((response) => {
        .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,
              examId: this.$route.query.id
            };
            this.$router.push({
              path: `/singleperformance/index`,
              query: obj,
              query: obj
            });
          }
        })
@@ -1048,8 +1048,8 @@
          console.error(error);
        }
      }
    },
  },
    }
  }
};
</script>