<template>
  <el-dialog
    class="page-dialog"
    :visible.sync="modalIsShow"
    :close-on-click-modal="false"
    :close-on-press-escape="false"
    append-to-body
    fullscreen
    @close="closeHandle"
    @open="visibleChange"
  >
    <div slot="title">{{ rowData.outlineName }}</div>
    <div class="mb-4 tab-btns">
      <el-button
        v-for="tab in tabs"
        :key="tab.val"
        size="medium"
        :type="curTab == tab.val ? 'primary' : 'default'"
        @click="selectMenu(tab.val)"
        >{{ tab.name }}
      </el-button>
    </div>

    <div v-if="modalIsShow">
      <component :is="curTab" :row-data="rowData"></component>
    </div>

    <div slot="footer"></div>
  </el-dialog>
</template>

<script>
import CourseExamineEvaluation from "./CourseExamineEvaluation.vue";
import CourseExamineWeight from "./CourseExamineWeight.vue";
import { mapActions } from "vuex";

export default {
  name: "detail-course-examine",
  components: {
    CourseExamineEvaluation,
    CourseExamineWeight,
  },
  props: {
    rowData: {
      type: Object,
      default() {
        return {};
      },
    },
  },
  data() {
    return {
      modalIsShow: false,
      curTab: "CourseExamineEvaluation",
      tabs: [
        {
          name: "评价方式管理",
          val: "CourseExamineEvaluation",
        },
        {
          name: "权重设置",
          val: "CourseExamineWeight",
        },
      ],
    };
  },
  methods: {
    ...mapActions("target", ["updateCwStatus"]),
    cancel() {
      this.modalIsShow = false;
    },
    open() {
      this.modalIsShow = true;
    },
    visibleChange() {
      this.updateCwStatus({
        obeCourseOutlineId: this.rowData.id,
      });
    },
    selectMenu(tab) {
      this.curTab = tab;
      this.updateCwStatus({
        obeCourseOutlineId: this.rowData.id,
      });
    },
    closeHandle() {
      this.curTab = "CourseExamineEvaluation";
    },
  },
};
</script>
