<template>
  <div>
    <div class="top-card">
      <div class="top-card-content">
        <div class="content-left">
          <div class="content-left-title">
            <span>{{ title }}</span>
          </div>
          <div class="content-left-value">{{ value }}</div>
        </div>
        <div v-if="img" class="content-right">
          <img :src="img" alt=""/>
        </div>
        <div v-else class="content-right-echart">
          <slot></slot>
        </div>
      </div>
      <div class="top-card-footer" style="display: flex;gap: 10px;">
        <div v-for="(item, index) in footer" :key="index" style="width: 100%;">
          <div v-if="!item.status" class="flex-space">
            <span>{{ item.title }}</span>
            <div class="footer-item-value">{{ item.value }}</div>
          </div>
          <div v-else class="flex-gap10">
            <el-tag :type="item.status" effect="plain">{{ item.title }}</el-tag>
            <div class="footer-item-value">{{ item.value }}</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  name: 'TopCard',
  props: {
    title: {
      type: String,
      default: ''
    },
    img: {
      type: String,
      default: ''
    },
    footer: {
      type: Array,
      default: () => []
    },
    value: {
      type: Number,
      default: 0
    }
  }
}
</script>

<style lang="scss" scoped>
.top-card {
  display: flex;
  flex-direction: column;
  // height: 200px;
  padding: 24px;
  background-color: #fff;
  border: 1px solid #e0e4e8;
  border-radius: 2px;

  .top-card-content {
    display: flex;
    flex-direction: row;
    flex-grow: 1;
    justify-content: space-between;

    .content-left {
      height: 100%;
      width: 50%;

      &-title {
        color: rgba(0, 0, 0, 0.64);
      }

      &-value {
        padding: 12px 0;
        color: #323130;
        font-weight: 700;
        font-size: 36px;
      }
    }

    .content-right {
      width: 0;
      display: flex;
      flex-grow: 1;
      align-items: flex-end;
      justify-content: flex-end;

      img {
        width: 92px;
        height: 92px;
      }
    }

    .content-right-echart {
      height: 92px;
      display: flex;
      flex-grow: 1;
      align-items: flex-end;
      justify-content: flex-end;
    }
  }

  .top-card-footer {
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 16px;
    border-top: 1px solid #f0f0f0;

    .footer-item-value {
      color: #323130;
      font-weight: 700;
      font-size: 16px;
    }

    .flex-gap10 {
      display: flex;
      gap: 10px;
      align-items: center;
    }

    .flex-space {
      width: 100%;
      display: flex;
      justify-content: space-between;
      align-items: center;
    }
  }
}
</style>
