<template>
  <div class="app-container" style="padding: 0 0 0 0">
    <el-tabs type="border-card" v-model="activeName" @tab-click="handleClick">
      <el-tab-pane label="进组前培训" name="first">
        <list item="1" typename="firstplan" v-if="isFirst"></list>
      </el-tab-pane>
      <el-tab-pane v-if="planType == 2" label="师徒培训计划(转岗)" name="second">
        <list2 item="1" typename="transferplan" v-if="isSecond"></list2>
      </el-tab-pane>
      <el-tab-pane v-else-if="planType == 1" label="师徒培训计划(校招)" name="third">
        <list3 item="1" typename="schoolplan" v-if="isThird"></list3>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>
import List from '@/views/training/newstaff/firstplan/index.vue'
import List2 from '@/views/training/newstaff/transferplan/index.vue'
import List3 from '@/views/training/newstaff/schoolplan/index.vue'
import {getTnNew} from "@/api/training/newstaff/tnNew";

export default {
  name: "palnList",
  components: {
    List,
    List2,
    List3,
  },
  data() {
    return {
      // 默认第一个Tab
      activeName: 'first',
      isFirst: true,
      isSecond: false,
      isThird: false,
      isFourth: false,
      isFifth: false,
      isSixth: false,
      planType: 1
    }
  },
  created() {
    //设置表格高度对应屏幕高度
    const newId = this.$route.params && this.$route.params.newId;
    getTnNew(newId).then(response => {
      this.planType = response.data.planType;
    });
  },
  methods: {
    handleClick(tab) {
      console.log(tab.name)
      if (tab.name === 'first') {
        this.isFirst = true
        this.isSecond = false
        this.isThird = false
        this.isFourth = false
        this.isFifth = false
        this.isSix1th = false
      } else if (tab.name === 'second') {
        this.isFirst = false
        this.isSecond = true
        this.isThird = false
        this.isFourth = false
        this.isFifth = false
        this.isSixth = false
      }else if (tab.name === 'third') {
        this.isFirst = false
        this.isSecond = false
        this.isThird = true
        this.isFourth = false
        this.isFifth = false
        this.isSixth = false
      }else if (tab.name === 'fourth') {
        this.isFirst = false
        this.isSecond = false
        this.isThird = false
        this.isFourth = true
        this.isFifth = false
        this.isSixth = false
      }else if (tab.name === 'fifth') {
        this.isFirst = false
        this.isSecond = false
        this.isThird = false
        this.isFourth = false
        this.isFifth = true
        this.isSixth = false
      }else if (tab.name === 'sixth') {
        this.isFirst = false
        this.isSecond = false
        this.isThird = false
        this.isFourth = false
        this.isFifth = false
        this.isSixth = true
      }
    }
  }
};
</script>
