<template>
  <div class="card-item">
    <div class="left">
      <p class="title">{{ title }}</p>
      <span class="count" @click="$emit('toDetail', data, index)">
        {{ formatCount }}
        <span>人</span>
      </span>
    </div>
    <div class="right">
      <i class="iconfont icon-jinzitakehu icon"></i>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    title: String,
    count: Number,
    data: Object,
    index: Number
  },
  computed: {
    formatCount() {
      return Number(this.count).toLocaleString();
    }
  }
};
</script>

<style scoped lang="scss">
.card-item {
  padding: 12px;
  width: 250px;
  height: 80px;
  box-sizing: border-box;
  background: rgba(47, 84, 235, 0.04);
  border-radius: 4px;
  border: 1px solid rgba(47, 84, 235, 0.16);
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-width: 0;
  .count {
    font-weight: bold;
    color: #2f54eb;
    font-size: 22px;
    white-space: nowrap;
    cursor: pointer;
    span {
      font-size: 14px;
      color: #303133;
    }
  }
  .title {
    color: #303133;
    font-size: 14px;
    margin-bottom: 10px;
  }
  .icon {
    font-size: 40px;
    color: #2f54eb;
    opacity: .14;
  }
}
</style>
