<template>
  <div style="margin-bottom: 12px">
    <el-row type="flex" justify="space-around">
      <el-col :span="6" v-for="(item, index) in cardList" :key="index">
        <div class="grid-content bg-purple">
          <div>
            <span>{{ cardData[item.card_num] || 0 }}</span>
            <span style="font-size: 14px">次</span>
          </div>

          <div>{{ item.card_title }}</div>
        </div>
      </el-col>
    </el-row>
  </div>
</template>

<script>
export default {
  data() {
    return {
      cardList: [
        {
          card_num: 'studyTaskCount',
          card_title: '学习任务',
        },
        {
          card_num: 'examTaskCount',
          card_title: '考试任务',
        },
        {
          card_num: 'trainingTaskCount',
          card_title: '培训任务',
        },
      ],
    }
  },
  // 接收父组件传递数据
  props: {
    cardData: {
      type: Object,
      default: () => {},
    },
  },
}
</script>

<style lang="scss" scoped>
.grid-content {
  min-height: 120px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  box-shadow: 0 1px 2px 1px rgba(0, 0, 0, 0.3);
  border-radius: 8px;

  & div:first-child span:first-child {
    font-size: 20px;
    font-weight: bold;
    letter-spacing: 2px;
  }

  & div:last-child {
    margin-top: 12px;
  }
}
</style>
