<template>
  <div class="page-container">
    <div class="header">
      <div class="title">设备预警</div>
    </div>
    <div class="stats-container">
      <div class="stat-card">
        <div class="stat-value">8056</div>
        <div class="stat-label">耳标预警</div>
      </div>
      <div class="stat-card">
        <div class="stat-value">1</div>
        <div class="stat-label">项圈预警</div>
      </div>
      <div class="stat-card">
        <div class="stat-value">61</div>
        <div class="stat-label">主机预警</div>
      </div>
    </div>

    <a-card :bordered="false">
      <div class="table-header">
        <a-tabs v-model:activeKey="activeTab">
          <a-tab-pane key="earTag" tab="智能耳标"></a-tab-pane>
          <a-tab-pane key="neckband" tab="智能项圈"></a-tab-pane>
          <a-tab-pane key="host" tab="智能主机"></a-tab-pane>
        </a-tabs>
        <a-input v-model:value="searchKeyword" placeholder="请输入养殖户" style="width: 200px;">
          <template #suffix>
            <span class="iconfont icon-sousuo"></span>
          </template>
        </a-input>
      </div>

      <a-table
        :columns="columns"
        :data-source="tableData"
        :pagination="pagination"
        row-key="id"
      >
      </a-table>
    </a-card>
  </div>
</template>

<script setup>
import { ref, reactive } from 'vue';

const activeTab = ref('earTag');
const searchKeyword = ref('');

const columns = [
  { title: '养殖场', dataIndex: 'farm', key: 'farm' },
  { title: '养殖户', dataIndex: 'farmer', key: 'farmer' },
  { title: '联系电话', dataIndex: 'phone', key: 'phone' },
  { title: '设备类型', dataIndex: 'deviceType', key: 'deviceType' },
  { title: '设备编号', dataIndex: 'deviceNumber', key: 'deviceNumber' },
  { title: '预警类型', dataIndex: 'alertType', key: 'alertType' },
];

const tableData = ref([
  { id: '1', farm: '扎旗大数据中心', farmer: '扎旗大数据中心', phone: '132****9345', deviceType: '智能耳标', deviceNumber: '2407100002', alertType: '设备离线' },
  { id: '2', farm: '扎旗大数据中心', farmer: '扎旗大数据中心', phone: '132****9345', deviceType: '智能耳标', deviceNumber: '2407100001', alertType: '设备离线' },
  { id: '3', farm: '扎旗大数据中心', farmer: '扎旗大数据中心', phone: '132****9345', deviceType: '智能耳标', deviceNumber: '2407402678', alertType: '设备离线' },
  { id: '4', farm: '扎旗大数据中心', farmer: '扎旗大数据中心', phone: '132****9345', deviceType: '智能耳标', deviceNumber: '2407402675', alertType: '设备离线' },
  { id: '5', farm: '扎旗大数据中心', farmer: '扎旗大数据中心', phone: '132****9345', deviceType: '智能耳标', deviceNumber: '2407402674', alertType: '设备离线' },
  { id: '6', farm: '139****8321_养殖场', farmer: '杜云鹏', phone: '139****8321', deviceType: '智能耳标', deviceNumber: '2404412397', alertType: '设备离线' },
  { id: '7', farm: '139****8321_养殖场', farmer: '杜云鹏', phone: '139****8321', deviceType: '智能耳标', deviceNumber: '2404412404', alertType: '设备离线' },
]);

const pagination = reactive({
  current: 1,
  pageSize: 10,
  total: tableData.value.length,
});

</script>

<style scoped>
.page-container {
  background-color: #f0f2f5;
  padding: 24px;
}

.header {
  margin-bottom: 24px;
}

.title {
  font-size: 24px;
  font-weight: bold;
}

.stats-container {
  display: flex;
  gap: 24px;
  margin-bottom: 24px;
}

.stat-card {
  background-color: #fff;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.09);
  text-align: center;
  flex: 1;
}

.stat-value {
  font-size: 28px;
  font-weight: bold;
  color: #1890ff;
}

.stat-label {
  font-size: 14px;
  color: #595959;
}

.table-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.important-messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.important-message-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border: 1px solid #ffccc7;
  border-radius: 6px;
  background-color: #fff2f0;
  cursor: pointer;
  transition: all 0.3s;
}

.important-message-item:hover {
  background-color: #ff4d4f10;
}

.important-icon {
  font-size: 24px;
  color: #ff4d4f;
}

.important-content {
  flex: 1;
}

.important-title {
  font-weight: bold;
  color: #ff4d4f;
  margin-bottom: 4px;
}

.important-time {
  font-size: 12px;
  color: #999;
}

.view-btn {
  margin-left: auto;
}

.no-data {
  text-align: center;
  color: #999;
  padding: 24px;
}

.unread-dot {
  width: 8px;
  height: 8px;
  background-color: #ff4d4f;
  border-radius: 50%;
  margin-right: 8px;
}

.message-title {
  cursor: pointer;
  transition: color 0.3s;
}

.message-title:hover {
  color: #1890ff;
}

.unread-title {
  font-weight: bold;
}

.important-title {
  color: #ff4d4f;
  font-weight: bold;
}

.top-icon {
  font-size: 14px;
  color: #faad14;
  margin-left: 8px;
}

.message-content {
  cursor: pointer;
  color: #666;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.message-content:hover {
  color: #1890ff;
}

.message-time {
  color: #999;
  font-size: 12px;
}

.detail-header {
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid #f0f0f0;
}

.detail-title {
  margin: 0 0 12px 0;
  color: #333;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 14px;
  color: #666;
}

.detail-content {
  line-height: 1.8;
  color: #333;
  margin-bottom: 24px;
}

.attachments h4 {
  margin: 0 0 12px 0;
  color: #333;
}

.attachment-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.attachment-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid #e8e8e8;
  border-radius: 4px;
  background-color: #f9f9f9;
}

.attachment-name {
  flex: 1;
}

.attachment-size {
  font-size: 12px;
  color: #999;
  margin-right: 8px;
}
</style>