<template>
  <div class='set-container'>
    <div class="topWrap">
      <h2>
        <!-- <div class="squrt"></div> -->
        <el-page-header @back="goBack"
                        :content="name">
        </el-page-header>
      </h2>
      <div class="stepbox">
        <span class='stepspan'
              @click="activeIndex=0">
          <div class="step1 sptep"
               :class="activeIndex >= 0?'activestep':''">
            班级设置
          </div>
          <img :src="activeIndex >= 0?stepImgs.nol:stepImgs.active"
               alt=""
               class="arrow">
        </span>
        <span class='stepspan  stepspan2'
              @click="activeIndex=1">
          <div class="step2 sptep"
               :class="activeIndex >= 1?'activestep':''">
            老师设置
          </div>
          <img :src="activeIndex >= 1?stepImgs.nol:stepImgs.active"
               alt=""
               class="
               arrow">
        </span>
        <span class='stepspan  stepspan2'
              @click="activeIndex=2">
          <div class="step2 sptep"
               :class="activeIndex >= 2?'activestep':''">
            排课
          </div>
          <img :src="activeIndex >= 2?stepImgs.nol:stepImgs.active"
               alt=""
               class="
               arrow">
        </span>
        <span class='stepspan  stepspan2'
              @click="activeIndex=3">
          <div class="step2 sptep"
               :class="activeIndex >= 3?'activestep':''">
            基础技能班
          </div>
          <img :src="activeIndex >= 3?stepImgs.nol:stepImgs.active"
               alt=""
               class="
               arrow">
        </span>
        <span class='stepspan  stepspan2'
              v-permission="'/teamSetting/salarySet'"
              @click="activeIndex=4">
          <div class="step2 sptep"
               :class="activeIndex >= 4?'activestep':''">
            课酬
          </div>
          <img :src="activeIndex >= 4?stepImgs.nol:stepImgs.active"
               alt=""
               class="
               arrow">
        </span>
      </div>
    </div>

    <!-- 下面显示的内容 -->
    <div class="stepcontent">
      <div v-if='activeIndex==0'>
        <classSeting :teamid='id'
                     :isSetSalary='isSetSalary'
                     @gotoNav='gotoNav' />
      </div>
      <div v-if='activeIndex==1'>
        <teacherSeting :teamid='id'
                       :isSetSalary='isSetSalary'
                       @gotoNav='gotoNav' />
      </div>
      <div v-if='activeIndex==2'>
        <!-- <coursePlan :teamid='id' /> -->
        <div class="m-container">
          <lookCourse :isSetSalary='isSetSalary'
                      @gotoNav='gotoNav' />
        </div>
      </div>
      <div v-if='activeIndex==3'>
        <improvement :teamid='id'
                     :isSetSalary='isSetSalary'
                     @gotoNav='gotoNav' />
      </div>
      <div v-if='activeIndex==4'
           v-permission="'/teamSetting/salarySet'">
        <salarySet :teamid='id'
                   :isSetSalary='isSetSalary' />
      </div>
    </div>
  </div>
</template>
<script>
import classSeting from '@/views/teamBuild/teamSeting/components/setClass'
import teacherSeting from '@/views/teamBuild/teamSeting/components/setTeacher'
import coursePlan from '@/views/teamBuild/teamSeting/components/coursePlan'
import salarySet from '@/views/teamBuild/teamSeting/components/salarySet'
import improvement from '@/views/teamBuild/teamSeting/components/improvementClass'
import lookCourse from '@/views/teamBuild/teamSeting/components/lookCourse'
import { getTeamBaseInfo, checkSetSalary } from '@/api/buildTeam'
export default {
  name: 'teamSeting',
  components: {
    classSeting,
    teacherSeting,
    coursePlan,
    salarySet,
    improvement,
    lookCourse
  },
  data () {
    return {
      activeIndex: 0,
      stepImgs: {
        nol: require('@/assets/images/base/step-arrow-active.png'),
        active: require('@/assets/images/base/step-arrow.png')
      },
      id: '',
      chargeTypeId: '',
      name: '',
      isSetSalary: false,
      Fsearch: null,
      Frules: null
    }
  },
  created () {
    this.init()
  },
  activated () {
    this.init()
  },
  beforeDestroy () {
    sessionStorage.setItem('setStep', 0)
    sessionStorage.setItem('resetCode', 1)
  },

  mounted () {
    // 根据乐团id 获取乐团信息
  },
  methods: {
    init () {
      this.id = this.$route.query.id;
      // 判断是否带缓存参数
      if (this.$route.query.search) {
        this.Fsearch = this.$route.query.search;
      }
      if (this.$route.query.rules) {
        this.Frules = this.$route.query.rules
      }
      //sessionStorage.getItem('setStep') ||
      this.activeIndex = 0;
      getTeamBaseInfo({ musicGroupId: this.id }).then(res => {
        if (res.code == 200) {
          this.chargeTypeId = res.data.musicGroup.chargeTypeId;
          this.name = res.data.musicGroup.name;
          sessionStorage.setItem('chargeTypeId', this.chargeTypeId);
          sessionStorage.setItem('createTeamOrgnId', res.data.musicGroup.organId)
        }
      })
      // 获取是否设置课酬
      checkSetSalary({ musicGroupId: this.id }).then(res => {
        if (res.code == 200) {
          this.isSetSalary = res.data;
        }
      })
    },
    gotoNav (val) {
      this.activeIndex = val;
    },
    goBack () {
      this.$router.push({ path: '/business/teamDetail', query: { search: this.Fsearch, rules: this.Frules } })
    }
  },
}
</script>
<style lang="scss" scoped>
.set-container {
  margin-left: 12px;
  .topWrap {
    padding: 18px 58px 0;
    // height: 136px;
    background-color: #fff;
    // display: flex;
    // flex-direction: row;
    // justify-content: space-between;
    .msg {
      text-align: right;
      color: #f97215;
      font-size: 32px;
      font-weight: bold;
      padding-top: 30px;
      box-sizing: border-box;
      img {
        width: 36px;
        height: 36px;
        position: relative;
        top: 5px;
        margin-right: 8px;
        display: block;
      }
    }
    h2 {
      height: 48px;
      line-height: 48px;
      position: relative;
      // padding-left: 30px;
      font-size: 32px;
      font-weight: 600;
      margin-bottom: 10px;
      display: flex;
      flex-direction: row;
      justify-content: flex-start;
      align-items: center;
      .term {
        height: 32px;
        line-height: 32px;
        border-radius: 24px;
        width: 100px;
        color: #14928a;
        border: 1px solid rgba(20, 146, 138, 1);
        font-size: 14px;
        text-align: center;
        margin-right: 12px;
        &:nth-child(1) {
          margin-left: 47px;
        }
      }
      .term.active {
        color: #fff;
        background-color: #14928a;
      }
      .squrt {
        position: absolute;
        left: -25px;
        top: 8px;
        height: 34px;
        width: 8px;
        background-color: #14928a;
      }
    }
    .btnList {
      display: flex;
      flex-direction: row;
      justify-content: flex-start;
      align-items: center;
      div {
        margin-right: 15px;
      }
    }
    .newBand.close {
      background-color: #777;
      border: 1px solid #777;
    }
  }
  .stepbox {
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    margin-top: 30px;
    .stepspan {
      cursor: pointer;
      font-size: 14px;
      display: block;
      line-height: 40px;
      // position: relative;
      // z-index: 100;
      display: flex;
      flex-direction: row;
      // justify-content: space-between;
      margin-left: -17px !important;

      .sptep {
        width: 110px;
        height: 40px;
        border: 1px solid #dcdfe6;
        border-right: none;
        border-bottom: none;
        padding-left: 25px;
        border-radius: 4px 0 0 0;
        text-align: center;
      }
      .arrow {
        height: 40px;
        width: 17px;
        position: relative;
        top: 1px;
        z-index: 30;
      }
    }
    .stepspan.stepspan2 {
      position: relative;
      padding-right: 0;
      .sptep {
        padding-left: 12px !important;
        border-radius: 0 !important;
      }
    }
    .sptep.activestep {
      color: #fff;
      font-weight: bold;
      background-color: #4eada7;
    }
  }
  .stepcontent {
    border-top: 1px solid #dcdfe6;
    padding-top: 12px;
  }
}
</style>