<template>
  <div class="chapBox">
    <div class="chapTop">
      <div :class="{ isStepCss: isStep == 0 }" @click="isStep = 0">任务阶段</div>
      <div :class="{ isStepCss: isStep == 1 }" @click="isStep = 1">项目详情</div>
    </div>
    <div v-if="isStep == 1" class="briefCss">
      {{ brief ? brief : '暂无详情' }}
    </div>
    <div v-if="isStep == 0" class="courseJdBox">
      <div class="blue_box_one" v-for="(item, index) in chInfo" :key="index" @click="goCourse(index)">
        <div>第{{ index + 1 }}阶段</div>
        <div :title="item.dyName">{{ item.dyName }}</div>
        <div>{{ item.chapterInfo[0].taskJson.length }}个任务</div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    chInfo: {
      type: Array
    },
    brief: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      isStep: 0
    }
  },
  methods: {
    goCourse(val) {
      this.$emit('goCourse', val)
    }
  }
}
</script>

<style lang="scss" scoped>
.chapBox {
  min-height: calc(100% - 350px - 50px - 20px);
  border-top: 20px solid #e8ebf2;
  .chapTop {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    font-size: 16px;
    padding: 10px 0 10px 15px;
    > div {
      color: #afafaf;
      padding: 0 0 5px 0;
      margin-right: 30px;
    }
    .isStepCss {
      color: #000;
      font-weight: bold;
      border-bottom: 3px solid #4f86d6;
    }
  }
  .briefCss {
    width: 90%;
    text-indent: 30px;
    font-size: 16px;
    margin: 10px auto;
    height: 300px;
    overflow: auto;
    line-height: 30px;
  }
  .courseJdBox {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: flex-start;
    padding: 0 0 0 30px;
    .blue_box_one {
      width: 150px;
      height: 150px;
      background-image: linear-gradient(90deg, #477cd7, #65b9fc);
      display: flex;
      flex-direction: column;
      flex-wrap: nowrap;
      align-items: center;
      justify-content: center;
      color: #fff;
      border-radius: 12px;
      margin: 0 15px 10px 0;
      > div {
        margin: 3px 0;
        font-size: 14px;
      }
      > div:nth-child(1) {
        font-size: 16px;
        font-weight: bold;
      }
      > div:nth-child(2) {
        max-width: 100px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        word-break: break-word;
      }
    }
  }
}
</style>
