智慧保安考试系统
shuishen
2023-11-06 c2481e77ae13eb6db48847499381dde001a4921e
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 {