<template>
  <div class="dashboard-container">
    <!-- 欢迎区域 -->
    <div class="welcome-section">
      <div class="welcome-content">
        <div class="welcome-text">
          <h1 class="welcome-title">
            <span class="greeting">{{ greeting }}</span>
            <span class="brand-name">欢迎使用喜颜看板系统</span>
          </h1>
          <p class="welcome-desc">智能化生产管理 · 数据可视化分析 · 高效协同办公</p>
        </div>
        <div class="welcome-icon">
          <i class="el-icon-data-analysis"></i>
        </div>
      </div>
      <div class="system-info">
        <div class="info-item">
          <i class="el-icon-time"></i>
          <span>{{ currentTime }}</span>
        </div>
        <div class="info-item">
          <i class="el-icon-location"></i>
          <span>系统版本：{{ version }}</span>
        </div>
      </div>
    </div>

    <!-- 快捷入口 -->
    <div class="quick-access-section">
      <h3 class="section-title">
        <i class="el-icon-s-grid"></i>
        快捷入口
      </h3>
      <el-row :gutter="20">
        <el-col :xs="12" :sm="8" :md="6" :lg="4" v-for="item in quickAccess" :key="item.name">
          <div class="quick-access-card" @click="handleQuickAccess(item.path)">
            <div class="card-icon" :style="{ background: item.color }">
              <i :class="item.icon"></i>
            </div>
            <div class="card-name">{{ item.name }}</div>
          </div>
        </el-col>
      </el-row>
    </div>

    <!-- 系统功能介绍 -->
    <div class="features-section">
      <h3 class="section-title">
        <i class="el-icon-medal"></i>
        核心功能
      </h3>
      <el-row :gutter="20">
        <el-col :xs="24" :sm="12" :md="8" v-for="feature in features" :key="feature.title">
          <el-card shadow="hover" class="feature-card">
            <div class="feature-icon" :style="{ background: feature.color }">
              <i :class="feature.icon"></i>
            </div>
            <h4 class="feature-title">{{ feature.title }}</h4>
            <p class="feature-desc">{{ feature.desc }}</p>
          </el-card>
        </el-col>
      </el-row>
    </div>

    <!-- 系统统计 -->
    <div class="stats-section">
      <h3 class="section-title">
        <i class="el-icon-data-line"></i>
        系统概览
      </h3>
      <el-row :gutter="20">
        <el-col :xs="24" :sm="12" :md="6" v-for="stat in stats" :key="stat.label">
          <div class="stat-card">
            <div class="stat-icon" :style="{ background: stat.color }">
              <i :class="stat.icon"></i>
            </div>
            <div class="stat-info">
              <div class="stat-value">{{ stat.value }}</div>
              <div class="stat-label">{{ stat.label }}</div>
            </div>
          </div>
        </el-col>
      </el-row>
    </div>
  </div>
</template>

<script>
export default {
  name: "Index",
  data() {
    return {
      version: "3.9.0",
      currentTime: "",
      greeting: "您好",
      quickAccess: [
        { name: "生产看板", path: "/board/kanban", icon: "el-icon-data-board", color: "linear-gradient(135deg, #667eea 0%, #764ba2 100%)" },
        { name: "销售订单", path: "/erp/saleOrder", icon: "el-icon-s-order", color: "linear-gradient(135deg, #f093fb 0%, #f5576c 100%)" },
        { name: "采购订单", path: "/erp/purchaseOrder", icon: "el-icon-shopping-cart-2", color: "linear-gradient(135deg, #4facfe 0%, #00f2fe 100%)" },
        { name: "生产工单", path: "/erp/productionOrder", icon: "el-icon-s-marketing", color: "linear-gradient(135deg, #43e97b 0%, #38f9d7 100%)" },
        { name: "质检单据", path: "/erp/inspectBill", icon: "el-icon-document-checked", color: "linear-gradient(135deg, #fa709a 0%, #fee140 100%)" },
        { name: "质检数据", path: "/qc/data", icon: "el-icon-data-analysis", color: "linear-gradient(135deg, #30cfd0 0%, #330867 100%)" }
      ],
      features: [
        { 
          title: "实时数据监控", 
          desc: "实时查看生产数据、销售数据、库存信息等关键指标，支持多维度数据分析", 
          icon: "el-icon-monitor", 
          color: "linear-gradient(135deg, #667eea 0%, #764ba2 100%)" 
        },
        { 
          title: "生产流程管理", 
          desc: "从订单到生产、质检、入库全流程管理，提升生产效率", 
          icon: "el-icon-s-cooperation", 
          color: "linear-gradient(135deg, #f093fb 0%, #f5576c 100%)" 
        },
        { 
          title: "质量追溯系统", 
          desc: "完整的质量检验记录，支持质量问题追溯和分析", 
          icon: "el-icon-search", 
          color: "linear-gradient(135deg, #4facfe 0%, #00f2fe 100%)" 
        },
        { 
          title: "数据可视化", 
          desc: "丰富的图表展示，让数据更直观，决策更科学", 
          icon: "el-icon-pie-chart", 
          color: "linear-gradient(135deg, #43e97b 0%, #38f9d7 100%)" 
        },
        { 
          title: "权限管理", 
          desc: "灵活的角色权限配置，保障系统安全", 
          icon: "el-icon-lock", 
          color: "linear-gradient(135deg, #fa709a 0%, #fee140 100%)" 
        },
        { 
          title: "移动端适配", 
          desc: "响应式设计，支持手机、平板等多种设备访问", 
          icon: "el-icon-mobile-phone", 
          color: "linear-gradient(135deg, #30cfd0 0%, #330867 100%)" 
        }
      ],
      stats: [
        { label: "在线用户", value: "12", icon: "el-icon-user", color: "linear-gradient(135deg, #667eea 0%, #764ba2 100%)" },
        { label: "今日订单", value: "28", icon: "el-icon-document", color: "linear-gradient(135deg, #f093fb 0%, #f5576c 100%)" },
        { label: "待处理", value: "5", icon: "el-icon-warning", color: "linear-gradient(135deg, #4facfe 0%, #00f2fe 100%)" },
        { label: "系统模块", value: "8", icon: "el-icon-s-grid", color: "linear-gradient(135deg, #43e97b 0%, #38f9d7 100%)" }
      ]
    }
  },
  mounted() {
    this.updateTime()
    this.updateGreeting()
    setInterval(this.updateTime, 1000)
  },
  methods: {
    updateTime() {
      const now = new Date()
      const year = now.getFullYear()
      const month = String(now.getMonth() + 1).padStart(2, '0')
      const day = String(now.getDate()).padStart(2, '0')
      const hours = String(now.getHours()).padStart(2, '0')
      const minutes = String(now.getMinutes()).padStart(2, '0')
      const seconds = String(now.getSeconds()).padStart(2, '0')
      this.currentTime = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`
    },
    updateGreeting() {
      const hour = new Date().getHours()
      if (hour < 6) {
        this.greeting = "凌晨好"
      } else if (hour < 9) {
        this.greeting = "早上好"
      } else if (hour < 12) {
        this.greeting = "上午好"
      } else if (hour < 14) {
        this.greeting = "中午好"
      } else if (hour < 18) {
        this.greeting = "下午好"
      } else if (hour < 24) {
        this.greeting = "晚上好"
      }
    },
    handleQuickAccess(path) {
      this.$router.push(path)
    },
    goTarget(href) {
      window.open(href, "_blank")
    }
  }
}
</script>

<style scoped lang="scss">
.dashboard-container {
  padding: 20px;
  background-color: #f0f2f5;
  min-height: calc(100vh - 84px);
}

// 欢迎区域
.welcome-section {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 12px;
  padding: 40px;
  margin-bottom: 30px;
  color: white;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);

  .welcome-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;

    .welcome-text {
      flex: 1;

      .welcome-title {
        font-size: 32px;
        font-weight: bold;
        margin-bottom: 12px;

        .greeting {
          display: block;
          font-size: 20px;
          font-weight: normal;
          opacity: 0.9;
          margin-bottom: 8px;
        }

        .brand-name {
          background: linear-gradient(to right, #fff, rgba(255, 255, 255, 0.8));
          -webkit-background-clip: text;
          -webkit-text-fill-color: transparent;
          background-clip: text;
        }
      }

      .welcome-desc {
        font-size: 15px;
        opacity: 0.9;
        letter-spacing: 1px;
      }
    }

    .welcome-icon {
      width: 100px;
      height: 100px;
      background: rgba(255, 255, 255, 0.2);
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;

      i {
        font-size: 50px;
      }
    }
  }

  .system-info {
    display: flex;
    gap: 30px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);

    .info-item {
      display: flex;
      align-items: center;
      gap: 8px;
      font-size: 14px;
      opacity: 0.95;

      i {
        font-size: 16px;
      }
    }
  }
}

// 区块标题
.section-title {
  font-size: 18px;
  font-weight: bold;
  color: #333;
  margin-bottom: 20px;
  padding-left: 12px;
  border-left: 4px solid #667eea;

  i {
    margin-right: 8px;
    color: #667eea;
  }
}

// 快捷入口
.quick-access-section {
  margin-bottom: 30px;

  .quick-access-card {
    background: white;
    border-radius: 12px;
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);

    &:hover {
      transform: translateY(-5px);
      box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    }

    .card-icon {
      width: 60px;
      height: 60px;
      margin: 0 auto 15px;
      border-radius: 12px;
      display: flex;
      align-items: center;
      justify-content: center;

      i {
        font-size: 30px;
        color: white;
      }
    }

    .card-name {
      font-size: 14px;
      color: #333;
      font-weight: 500;
    }
  }
}

// 功能介绍
.features-section {
  margin-bottom: 30px;

  .feature-card {
    height: 100%;
    border-radius: 12px;
    transition: all 0.3s;

    &:hover {
      transform: translateY(-5px);
    }

    ::v-deep .el-card__body {
      text-align: center;
      padding: 30px 20px;
    }

    .feature-icon {
      width: 70px;
      height: 70px;
      margin: 0 auto 20px;
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;

      i {
        font-size: 35px;
        color: white;
      }
    }

    .feature-title {
      font-size: 18px;
      color: #333;
      margin-bottom: 12px;
      font-weight: bold;
    }

    .feature-desc {
      font-size: 13px;
      color: #666;
      line-height: 1.8;
    }
  }
}

// 统计卡片
.stats-section {
  margin-bottom: 30px;

  .stat-card {
    background: white;
    border-radius: 12px;
    padding: 24px;
    display: flex;
    align-items: center;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    transition: all 0.3s;

    &:hover {
      transform: translateY(-3px);
      box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    }

    .stat-icon {
      width: 60px;
      height: 60px;
      border-radius: 12px;
      display: flex;
      align-items: center;
      justify-content: center;
      margin-right: 20px;

      i {
        font-size: 28px;
        color: white;
      }
    }

    .stat-info {
      flex: 1;

      .stat-value {
        font-size: 28px;
        font-weight: bold;
        color: #333;
        margin-bottom: 4px;
      }

      .stat-label {
        font-size: 13px;
        color: #999;
      }
    }
  }
}

// 响应式
@media (max-width: 768px) {
  .dashboard-container {
    padding: 15px;
  }

  .welcome-section {
    padding: 25px;

    .welcome-content {
      flex-direction: column;
      text-align: center;

      .welcome-text .welcome-title {
        font-size: 24px;
      }

      .welcome-icon {
        margin-top: 20px;
        width: 80px;
        height: 80px;

        i {
          font-size: 40px;
        }
      }
    }

    .system-info {
      flex-direction: column;
      gap: 10px;
      align-items: center;
    }
  }

  .section-title {
    font-size: 16px;
  }
}
</style>

