<template>
  <div class="data-module">
    <div class="module-header">
      <h3>数据总览</h3>
      <span class="refresh-icon" @click="handleRefresh"></span>
    </div>
    <div class="module-body">
      <div class="data-stats">
        <div class="stat-item">
          <span class="stat-label">监测点位</span>
          <span class="stat-value">{{ monitoringPoints }}</span>
        </div>
        <div class="stat-item">
          <span class="stat-label">在线设备</span>
          <span class="stat-value online">{{ onlineDevices }}</span>
        </div>
        <div class="stat-item">
          <span class="stat-label">数据采集量</span>
          <span class="stat-value">{{ dataCollectionVolume }}</span>
        </div>
      </div>
      <div class="progress-bars">
        <div class="progress-item">
          <span class="progress-label">设备在线率</span>
          <div class="progress-container">
            <div
              class="progress-bar"
              :style="{ width: deviceOnlineRate + '%' }"
            ></div>
          </div>
          <span class="progress-value">{{ deviceOnlineRate + "%" }}</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "DataOverview",
  props: {
    monitoringPoints: {
      type: Number,
      default: 256,
    },
    onlineDevices: {
      type: Number,
      default: 245,
    },
    dataCollectionVolume: {
      type: String,
      default: "1.2万",
    },
    deviceOnlineRate: {
      type: Number,
      default: 95.7,
    },
  },
  methods: {
    handleRefresh() {
      // 触发父组件的数据刷新事件
      this.$emit("refresh-data");
    },
  },
};
</script>

<style scoped>
/* 组件样式将从主页面继承 */
</style>