<template>
  <el-dialog
    custom-class="side-dialog"
    :visible.sync="modalIsShow"
    title="安全设置"
    width="500px"
    :modal="false"
    :close-on-click-modal="false"
    :close-on-press-escape="false"
    append-to-body
    @open="visibleChange"
  >
    <el-form>
      <el-form-item label="加密“题库”，“卷库”">
        <el-switch v-model="modalForm.questionActionIsCrypto"></el-switch>
        <p class="tips-info">开启后，进入题库、卷库模块，需要进行密码验证！</p>
      </el-form-item>
    </el-form>

    <div slot="footer">
      <el-button type="primary" @click="confirm">确定</el-button>
      <el-button @click="cancel">取消</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { mapState, mapMutations } from "vuex";

export default {
  name: "QuestionSafetySetDialog",
  data() {
    return {
      modalIsShow: false,
      modalForm: {
        questionActionIsCrypto: false,
      },
    };
  },
  computed: {
    ...mapState("question", ["questionActionIsCrypto"]),
  },
  methods: {
    ...mapMutations("question", ["setQuestionActionIsCrypto"]),
    visibleChange() {
      this.modalForm.questionActionIsCrypto = this.questionActionIsCrypto;
    },
    cancel() {
      this.modalIsShow = false;
    },
    open() {
      this.modalIsShow = true;
    },
    confirm() {
      this.setQuestionActionIsCrypto(this.modalForm.questionActionIsCrypto);
      this.cancel();
    },
  },
};
</script>
