<template>
  <div class="home-page">
    <div class="page-header">
      <h1>太湖流域水环境综合治理信息共享平台</h1>
      <p class="subtitle">汇聚八家单位监测数据，实现多方数据共享与决策支持</p>
    </div>

    <div class="stats-row">
      <div class="stat-card">
        <div class="stat-icon">
          <svg-icon icon-class="server" />
        </div>
        <div class="stat-content">
          <div class="stat-value">8</div>
          <div class="stat-label">合作单位</div>
        </div>
      </div>
      <div class="stat-card">
        <div class="stat-icon">
          <svg-icon icon-class="chart" />
        </div>
        <div class="stat-content">
          <div class="stat-value">40+</div>
          <div class="stat-label">业务类型</div>
        </div>
      </div>
      <div class="stat-card">
        <div class="stat-icon">
          <svg-icon icon-class="table" />
        </div>
        <div class="stat-content">
          <div class="stat-value">2000+</div>
          <div class="stat-label">监测站点</div>
        </div>
      </div>
      <div class="stat-card">
        <div class="stat-icon">
          <svg-icon icon-class="monitor" />
        </div>
        <div class="stat-content">
          <div class="stat-value">实时</div>
          <div class="stat-label">数据更新</div>
        </div>
      </div>
    </div>

    <div class="section">
      <h2>共享清单</h2>
      <div class="unit-grid">
        <div class="unit-card" v-for="unit in units" :key="unit.code">
          <div class="unit-header">
            <div class="unit-icon" :style="{ background: unit.color }">
              <svg-icon :icon-class="unit.icon" />
            </div>
            <div class="unit-info">
              <h3>{{ unit.name }}</h3>
              <p class="unit-code">{{ unit.code }}</p>
            </div>
          </div>
          <div class="unit-stats">
            <div class="unit-stat">
              <span class="stat-num">{{ unit.dataCount }}</span>
              <span class="stat-text">共享数据集</span>
            </div>
            <div class="unit-stat">
              <span class="stat-num">{{ unit.stationCount }}</span>
              <span class="stat-text">监测站点</span>
            </div>
          </div>
          <div class="unit-tags">
            <el-tag v-for="tag in unit.tags" :key="tag" size="small" :type="getTagType(tag)">{{ tag }}</el-tag>
          </div>
          <el-button type="primary" size="small" @click="viewUnit(unit.code)">查看详情</el-button>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'

const units = ref([
  {
    code: 'TBA',
    name: '水利部太湖流域管理局',
    icon: 'server',
    color: '#217ff4',
    dataCount: 12,
    stationCount: 156,
    tags: ['水文', '水质', '工情']
  },
  {
    code: 'THDH',
    name: '生态环境部太湖流域东海海域生态环境监督管理局',
    icon: 'chart',
    color: '#10b981',
    dataCount: 8,
    stationCount: 98,
    tags: ['水质', '生态']
  },
  {
    code: 'JS-SL',
    name: '江苏省水利厅',
    icon: 'table',
    color: '#f59e0b',
    dataCount: 15,
    stationCount: 420,
    tags: ['水文', '工情']
  },
  {
    code: 'JS-ST',
    name: '江苏省生态环境厅',
    icon: 'monitor',
    color: '#ef4444',
    dataCount: 10,
    stationCount: 280,
    tags: ['水质', '生态']
  },
  {
    code: 'ZJ-SL',
    name: '浙江省水利厅',
    icon: 'server',
    color: '#8b5cf6',
    dataCount: 11,
    stationCount: 350,
    tags: ['水文', '工情']
  },
  {
    code: 'ZJ-ST',
    name: '浙江省生态环境厅',
    icon: 'chart',
    color: '#ec4899',
    dataCount: 9,
    stationCount: 220,
    tags: ['水质', '生态']
  },
  {
    code: 'SH-SW',
    name: '上海市水务局',
    icon: 'table',
    color: '#06b6d4',
    dataCount: 6,
    stationCount: 180,
    tags: ['水文', '工情']
  },
  {
    code: 'SH-ST',
    name: '上海市生态环境局',
    icon: 'monitor',
    color: '#84cc16',
    dataCount: 7,
    stationCount: 150,
    tags: ['水质', '生态']
  }
])

function getTagType(tag) {
  const types = {
    '水文': 'primary',
    '水质': 'success',
    '工情': 'warning',
    '生态': 'danger'
  }
  return types[tag] || 'info'
}

function viewUnit(code) {
  console.log('查看单位:', code)
}
</script>

<style scoped>
.home-page {
  max-width: 1400px;
  margin: 0 auto;
}

.page-header {
  text-align: center;
  padding: 30px 0;
  margin-bottom: 30px;
  background: linear-gradient(135deg, #0066cc 0%, #0099ff 100%);
  border-radius: 12px;
  color: #fff;
}

.page-header h1 {
  font-size: 32px;
  font-weight: bold;
  margin: 0 0 10px 0;
}

.subtitle {
  font-size: 16px;
  opacity: 0.9;
  margin: 0;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 30px;
}

.stat-card {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.stat-icon {
  width: 60px;
  height: 60px;
  background: #e8f4ff;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-icon :deep(svg) {
  width: 30px;
  height: 30px;
  color: #0066cc;
}

.stat-content {
  flex: 1;
}

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

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

.section {
  margin-bottom: 30px;
}

.section h2 {
  font-size: 20px;
  font-weight: bold;
  margin: 0 0 20px 0;
  padding-left: 10px;
  border-left: 4px solid #0066cc;
}

.unit-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

.unit-card {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.unit-header {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-bottom: 15px;
}

.unit-icon {
  width: 50px;
  height: 50px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.unit-icon :deep(svg) {
  width: 25px;
  height: 25px;
  color: #fff;
}

.unit-info h3 {
  font-size: 15px;
  font-weight: bold;
  margin: 0 0 5px 0;
  color: #333;
}

.unit-code {
  font-size: 12px;
  color: #999;
  margin: 0;
}

.unit-stats {
  display: flex;
  gap: 20px;
  margin-bottom: 15px;
}

.unit-stat {
  text-align: center;
}

.stat-num {
  display: block;
  font-size: 20px;
  font-weight: bold;
  color: #0066cc;
}

.stat-text {
  font-size: 12px;
  color: #999;
}

.unit-tags {
  margin-bottom: 15px;
}

.data-overview {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.overview-card {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  border-top: 4px solid #0066cc;
}

.overview-card.water-quality {
  border-top-color: #10b981;
}

.overview-card.water-level {
  border-top-color: #3b82f6;
}

.overview-card.ecology {
  border-top-color: #f59e0b;
}

.overview-card h3 {
  font-size: 16px;
  font-weight: bold;
  margin: 0 0 15px 0;
}

.overview-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.indicator {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px;
  background: #f8fafc;
  border-radius: 8px;
}

.indicator .label {
  font-size: 14px;
  color: #666;
}

.indicator .value {
  font-size: 14px;
  font-weight: bold;
}

.value.normal {
  color: #10b981;
}

.value.warning {
  color: #f59e0b;
}

.value.danger {
  color: #ef4444;
}
</style>
