<template>
  <div class="data-module">
    <div class="module-header">
      <h3>实时报警</h3>
      <span class="alarm-count">{{ alarmCount }}</span>
    </div>
    <div class="module-body">
      <div class="alarm-list">
        <div 
          v-for="(alarm, index) in alarmList" 
          :key="index" 
          class="alarm-item"
          :class="'level-' + alarm.level"
        >
          <span class="alarm-level">{{ alarm.levelText }}</span>
          <span class="alarm-content">{{ alarm.content }}</span>
          <span class="alarm-point">{{ alarm.point }}</span>
          <span class="alarm-time">{{ alarm.time }}</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'RealTimeAlarm',
  props: {
    alarmList: {
      type: Array,
      default: () => [
        {
          level: 1,
          levelText: '紧急',
          content: '温度异常',
          point: 'A-12区',
          time: '10:23'
        },
        {
          level: 2,
          levelText: '重要',
          content: '设备离线',
          point: 'B-05区',
          time: '09:45'
        },
        {
          level: 3,
          levelText: '一般',
          content: '数据异常',
          point: 'C-08区',
          time: '08:30'
        },
        {
          level: 3,
          levelText: '一般',
          content: '压力偏低',
          point: 'D-01区',
          time: '07:55'
        }
      ]
    }
  },
  computed: {
    alarmCount() {
      return this.alarmList.length;
    }
  }
}
</script>

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