<template>
  <el-dialog
    title="完成情况"
    :visible.sync="dialogVisibleENScore"
    width="1000px"
    :before-close="handleClose"
    class="dialog_diy"
    :show-close="false"
    :class="{ fullStyle: full }"
  >
    <div slot="title" class="header-title">
      <div>完成情况</div>
      <div style="position: absolute; top: 19px; right: 10px">
        <img
          src="../../assets/icon/full.png"
          style="height: 16px; margin-right: 10px; cursor: pointer"
          alt=""
          @click="fullTools"
        />
        <img
          src="../../assets/icon/close1.png"
          style="height: 16px; cursor: pointer"
          alt=""
          @click="close"
        />
      </div>
    </div>
    <div class="evaBox">
      <div class="left" v-if="showBtn == true">
        <teacherEva @setNotice="setNotice"></teacherEva>
        <studentWorkList></studentWorkList>
        <div class="showImg" @click="showBtn = !showBtn">
          <img src="../../assets/mlBtn1.png" alt="" />
        </div>
      </div>
      <div v-else class="noCLeft">
        <div class="noShowImg" @click="showBtn = !showBtn">
          <img src="../../assets/mlBtn1.png" alt="" />
        </div>
      </div>
      <div :class="showBtn == false ? 'allRight' : 'right'">
        <studentDetail></studentDetail>
      </div>
      <div v-if="sNotice == true" class="noticeBox">
        <div class="top">
          <div class="sucLeft">
            <div class="successImg">
              <img src="../../assets/icon/englishVoice/success.png" alt="" />
            </div>
            <div>成功通知</div>
          </div>
          <div style="font-size: 16px">2024.02.02</div>
        </div>
        <div style="margin: 10px 0 0 35px">评价内容已自动保存成功</div>
      </div>
    </div>
  </el-dialog>
</template>

<script>
import studentDetail from "./component/studentDetail";
import studentWorkList from "./component/studentWorkList";
import teacherEva from "./component/teacherEva";
export default {
  components: {
    studentDetail,
    studentWorkList,
    teacherEva,
  },
  props: {
    dialogVisibleENScore: {
      type: Boolean,
      default: false,
    },
    englishVoiceJson: {
      type: Object,
    },
    userid: {
      type: String,
    },
    commentDetail: {
      type: Object,
    },
    courseDetail: {
      type: Object,
    },
    wScore: {
      type: Number,
    },
    scoreDetail: {
      type: String,
    },
  },
  data() {
    return {
      checkJson: [],
      checkJson2: {},
      title: "",
      detail: "",
      checkType: 0,
      work: [],
      wScore2: 0,
      scoreDetail2: "",
      dataDialog: false,
      full: false,
      showBtn: true,
      sNotice: false,
    };
  },
  methods: {
    handleClose(done) {
      this.close();
      done();
    },
    setNotice(val) {
      this.sNotice = val;
      setTimeout(() => {
        this.sNotice = false;
      }, 3000);
    },
    fullTools() {
      this.full = !this.full;
    },
    close() {
      this.$emit("update:dialogVisibleENScore", false);
    },
    close2() {
      this.$emit("update:dialogVisibleENScore", false);
    },
    confirm() {
      this.close2();
    },
    setJson(val) {
      this.checkJson = val;
      this.$forceUpdate();
    },
    setVoiceJson(val) {
      let a = JSON.parse(JSON.stringify(val));
      this.checkJson2 = JSON.parse(JSON.stringify(a));
      this.title = a.title;
      this.detail = a.detail;
      this.checkJson = a.array;
      this.checkType = 0;
      this.work.length = a.array.length;
      this.wScore2 = JSON.parse(JSON.stringify(this.wScore));
      this.scoreDetail2 = JSON.parse(JSON.stringify(this.scoreDetail));
      let works = JSON.parse(
        JSON.parse(JSON.stringify(this.commentDetail.works))
      );
      for (var i = 0; i < this.work.length; i++) {
        if (i > works.length - 1) {
          break;
        }
        this.work[i] = works[i];
      }
    },
  },
  watch: {
    dialogVisibleENScore: {
      handler: function (newVal, oldVal) {
        if (newVal) {
          this.setVoiceJson(this.englishVoiceJson);
        }
      },
      deep: true,
    },
  },
  mounted() {
    this.setVoiceJson(this.englishVoiceJson);
  },
};
</script>

<style scoped>
.dialog_diy >>> .el-dialog__header {
  background: #fff !important;
  padding: 15px 20px;
  border-radius: 10px 10px 0 0;
  border-bottom: 1px solid #e7e7e7;
}

.dialog_diy >>> .el-dialog__headerbtn {
  top: 19px;
}

.dialog_diy >>> .el-dialog__headerbtn .el-dialog__close {
  color: #fff;
}

.dialog_diy >>> .el-dialog__headerbtn .el-dialog__close:hover {
  color: #fff;
}

.dialog_diy >>> .el-dialog__body,
.dialog_diy >>> .el-dialog__footer {
  background: #fafafa;
}
.dialog_diy >>> .el-dialog__body {
  height: 100%;
  border-radius: 10px;
  background: #fff;
  padding: 0 !important;
}
.dialog_diy >>> .el-dialog {
  height: 600px !important;
  border-radius: 10px;
}
.fullStyle >>> .el-dialog__body {
  height: 100% !important;
}

.fullStyle >>> .el-dialog,
.fullStyle {
  width: 100% !important;
  max-width: 100% !important;
  height: 100% !important;
  margin: 0 !important;
}
.header-title {
  display: flex;
  align-items: center;
}

.evaBox {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: flex-start;
  position: relative;
}

.evaBox > .left,
.evaBox > .noCLeft {
  width: 30%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  flex-wrap: nowrap;
  border-right: 1px solid #e7e7e7;
  padding: 15px;
  box-sizing: border-box;
  position: relative;
}

.evaBox > .noCLeft {
  width: 10%;
}

.evaBox > .right,
.evaBox > .allRight {
  width: calc(100% - 30%);
  height: 100%;
}
.evaBox > .allRight {
  width: calc(100% - 10%);
}
.showImg,
.noShowImg {
  position: absolute;
  top: 15px;
  right: 0;
  width: 25px;
  height: 25px;
  cursor: pointer;
  border: 1px solid #f0f2f5;
  border-radius: 45% 0 0 45%;
  padding: 8px 10px;
}

.noShowImg {
  top: 20px;
  right: 25px;
  border: none;
}

.showImg > img,
.noShowImg > img {
  width: 100%;
  height: 100%;
}

.noticeBox {
  position: absolute;
  top: 40%;
  left: 30%;
  width: 400px;
  height: 50px;
  background: #fff;
  padding: 30px;
  border-radius: 10px;
  border: 1px solid #e6e6e6;
  z-index: 99;
  box-shadow: 0px 1px 5px 2px #e6e6e6;
}

.top {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
}

.sucLeft {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  font-size: 18px;
  font-weight: bold;
}

.successImg {
  width: 25px;
  height: 25px;
  margin: 0 10px 0 0;
}

.successImg > img {
  width: 100%;
  height: 100%;
}
</style>
