<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"
  >
    <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 CourseOutlineBase from "./CourseOutlineBase.vue";
import CourseOutlineTarget from "./CourseOutlineTarget.vue";
// import CourseOutlineKnowledge from "./CourseOutlineKnowledge.vue";
import { mapActions } from "vuex";

export default {
  name: "detail-course-outline",
  components: {
    CourseOutlineBase,
    CourseOutlineTarget,
    // CourseOutlineKnowledge,
  },
  props: {
    rowData: {
      type: Object,
      default() {
        return {};
      },
    },
  },
  data() {
    return {
      modalIsShow: false,
      curTab: "CourseOutlineBase",
      tabs: [
        {
          name: "基本信息",
          val: "CourseOutlineBase",
        },
        {
          name: "课程目标",
          val: "CourseOutlineTarget",
        },
        // {
        //   name: "知识点",
        //   val: "CourseOutlineKnowledge",
        // },
      ],
    };
  },
  methods: {
    ...mapActions("target", ["updateCwStatus"]),
    cancel() {
      this.modalIsShow = false;
    },
    open() {
      this.modalIsShow = true;
    },
    selectMenu(tab) {
      this.curTab = tab;
      if (tab === "CourseOutlineTarget") {
        this.updateCwStatus({
          obeCourseOutlineId: this.rowData.id,
        });
      }
    },
    closeHandle() {
      this.curTab = "CourseOutlineBase";
    },
  },
};
</script>
