<template>
  <div>
    <el-card>
      <div slot="header" class="clearfix">
        <div class="box">
          <span class="shape"></span>
          <span>在读学员</span>
        </div>
      </div>
      <!-- <div
        class="wall"
        style="height: 68px"
        v-if="JSON.stringify(items) == '{}'&&!data['CHARGE_STUDENT_CHANGE_RATE']&&!data['ACTIVATION_RATE']"
      >
        暂无数据
      </div> -->
      <statistic :col="6" class="statistic" :cols="0">
        <statistic-item
          v-for="(item, key) in items"
          :key="key"
          :class="{ active: active === key }"
          @click="active = key"
        >
          <span>
            {{ item.text }}
          </span>
          <span> <count-to :endVal="item.value" /> </span>
        </statistic-item>
      </statistic>
    </el-card>
  </div>
</template>
<script>
import countTo from "vue-count-to";
export default {
  props: ["data","groupType"],
  components: {
    "count-to": countTo,
  },
  data() {
    return {
      active: "",
    };
  },
  computed: {
    dataEmpty() {
      return !this.chartData.rows.length;
    },
    items() {
      if(this.groupType == 'PRACTICE'){
            let tempArr = [{
        text: '在读学员总数',
        value: 0,
        id: 'normalStudentNum'
      }, {
        text: '进行中',
        value: 0,
        id: 'normalStudentHasNormalGroupNum'
      },{
        text: '假期上课',
        value: 0,
        id: 'holidayCourseStudentNum'
      }, {
        text: '未排课',
        value: 0,
        id: 'normalStudentHasNoScheduleNum'
      }]

      tempArr.forEach(item => {
        if(this.data[item.id]) {
          item.value = this.data[item.id]
        }
      })
      return tempArr
      }else {
            let tempArr = [{
        text: '在册学员总数',
        value: 0,
        id: 'registerNum'
      },{
        text: '在读学员总数',
        value: 0,
        id: 'normalStudentNum'
      }, {
        text: '进行中',
        value: 0,
        id: 'normalStudentHasNormalGroupNum'
      },
      {
        text: '假期上课',
        value: 0,
        id: 'holidayCourseStudentNum'
      },
      {
        text: '暂停',
        value: 0,
        id: 'hasCourseBalanceAndNotSubCourseNum'
      }, {
        text: '未排课',
        value: 0,
        id: 'normalStudentHasNoScheduleNum'
      }]
      tempArr.forEach(item => {
        if(this.data[item.id]) {
          item.value = this.data[item.id]
        }
      })
      return tempArr
      }

    },
  },
};
</script>

<style lang="scss" scoped>
::v-deep  .el-card__body .statistic {
    margin-bottom: 15px;
    padding: 0;
  }
::v-deep .el-card__header {
    padding: 0 20px!important;
}
.box {
  display: flex;
  flex-direction: row;
  align-items: center;
  height: 55px;
  line-height: 55px;
  .shape {
    margin-right: 10px;
    height: 18px;
    width: 4px;
    background-color: var(--color-primary);
  }
}
</style>

