<template>
  <div class="info-cards">
    <div class="info-title">
      数据简报
    </div>
    <div class="custom-line"></div>
    <div class="card-grid">
      
      <div
        v-for="(item, index) in infoList"
        :key="index"
        class="card"
        @click="handleClick(item)"
      >
      <el-icon :size="40" class="card-icon">
        <component :is="item.icon" />
      </el-icon>

        <div class="card-value">{{ item.value }}</div>
        <div class="card-label">{{ item.label }}</div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts"  name="InfoCards">
import {
  Coin, Box, Document, Avatar, Folder,
  Monitor, ShoppingCart, User, Setting, Tools
} from '@element-plus/icons-vue'
import { defineProps,computed } from 'vue'

const props = defineProps({
  summaryData: {
    type: Object,
    required: true
  }
})

const infoList = computed(()=>[
  { label: '设备总数', value: props.summaryData.total_devices, icon: Coin },
  { label: '在借数', value: props.summaryData.total_borrows, icon: Box },
  { label: '在库数', value: props.summaryData.total_warehouses, icon: Document },
  { label: '维修中', value: props.summaryData.total_maintenances, icon: Avatar },
  { label: '用户数', value: props.summaryData.total_students, icon: Folder },
  { label: '借用件次数', value: props.summaryData.total_applications, icon: Monitor },
]);
function handleClick(item: any) {
  console.log('点击信息卡片:', item.label);
}
</script>

<style scoped>
.custom-line {
  height: 1px;
  background-color: #ccc;
  width: 100%;
  margin: 10px 0;
}

.info-title{
  padding-left: 10%;
  padding-top:10px;
  font-size: 30px;
}
.info-cards{
  background: #fff;
  height: 400px;
}
.card-grid {
  padding:30px;
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
}
.card {
  width: calc(20% - 12px); 
  align-items: center;
  text-align: center;
  padding: 10px;
  cursor: pointer;
  box-sizing: border-box;
}
.card-icon {
  width: 40px;
  height: 40px;
  margin-bottom: 8px;
}
.card-value {
  font-size: 20px;
  font-weight: bold;
  color: #67C23A;
}
.card-label {
  font-size: 14px;
  color: #666;
  margin-top: 4px;
}
</style>
