<template>
  <div class="data-module">
    <div class="module-header">
      <h3>设备运行状态</h3>
      <span class="view-more" @click="handleViewMore">查看全部</span>
    </div>
    <div class="module-body">
      <div class="device-status-list">
        <div 
          v-for="(device, index) in deviceList" 
          :key="index" 
          class="device-item"
        >
          <span class="device-name">{{ device.name }}</span>
          <span class="device-status" :class="device.status">{{ device.statusText }}</span>
          <span class="device-value">{{ device.value }}</span>
          <span class="device-time">{{ device.time }}</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'DeviceStatus',
  props: {
    deviceList: {
      type: Array,
      default: () => [
        {
          name: '传感器A-1',
          status: 'normal',
          statusText: '正常',
          value: '125.6',
          time: '3分钟前'
        },
        {
          name: '传感器B-3',
          status: 'normal',
          statusText: '正常',
          value: '89.2',
          time: '5分钟前'
        },
        {
          name: '传感器C-2',
          status: 'warning',
          statusText: '警告',
          value: '185.3',
          time: '1分钟前'
        },
        {
          name: '传感器D-5',
          status: 'offline',
          statusText: '离线',
          value: '--',
          time: '2小时前'
        }
      ]
    }
  },
  methods: {
    handleViewMore() {
      this.$emit('view-more');
    }
  }
}
</script>

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