<script setup lang="ts">
/**
 * 问题上报入口页
 *
 * 通过 van-grid 展示可上报的问题类型，
 * 点击卡片跳转到对应的上报表单页。
 */
import { useRouter } from 'vue-router'

const router = useRouter()

/** 上报类型列表 */
const reportTypes = [
  {
    text: '积淹点',
    icon: 'warning-o',
    route: '/reportFloodedPoints',
    desc: '积水、淹没点位上报',
    color: '#FF6B6B',
  },
  {
    text: '巡检问题',
    icon: 'search',
    route: '/reportInspection',
    desc: '巡检发现的问题',
    color: '#4ECDC4',
  },
  {
    text: '设备报修',
    icon: 'setting-o',
    route: '/reportEquipmentRepair',
    desc: '设备故障报修',
    color: '#FF976A',
  },
  {
    text: '督办问题',
    icon: 'records',
    route: '/reportSupervise',
    desc: '督办项目问题',
    color: '#9B59B6',
  },
  {
    text: '项目问题',
    icon: 'bulb-o',
    route: '/reportProject',
    desc: '项目相关问题',
    color: '#F39C12',
  },
  {
    text: '施工问题',
    icon: 'cluster-o',
    route: '/reportConstruction',
    desc: '施工现场问题',
    color: '#1ABC9C',
  },
]

/** 跳转 */
function goReport(route: string) {
  router.push(route)
}
</script>

<template>
  <div class="report-index-page">
    <van-nav-bar
      title="问题上报"
      left-arrow
      fixed
      placeholder
      @click-left="router.back()"
    />

    <div class="report-banner">
      <div class="banner-icon">
        <van-icon name="warning-o" size="28" color="#FF6B6B" />
      </div>
      <div class="banner-text">
        <div class="banner-title">问题上报</div>
        <div class="banner-desc">请根据实际情况选择对应的问题类型</div>
      </div>
    </div>

    <div class="section-header">
      <span class="section-title">上报类型</span>
    </div>

    <van-grid :column-num="3" :border="false" :gutter="12" class="report-grid">
      <van-grid-item
        v-for="item in reportTypes"
        :key="item.text"
        :text="item.text"
        @click="goReport(item.route)"
      >
        <template #icon>
          <div class="grid-icon-wrap" :style="{ background: item.color + '15' }">
            <van-icon :name="item.icon" :color="item.color" size="24" />
          </div>
        </template>
        <template #text>
          <span class="grid-text">{{ item.text }}</span>
        </template>
        <template #description>
          <span class="grid-desc">{{ item.desc }}</span>
        </template>
      </van-grid-item>
    </van-grid>
  </div>
</template>

<style lang="scss" scoped>
.report-index-page {
  min-height: 100vh;
  background: #F4F7F8;

  :deep(.van-nav-bar) {
    background: #1E74FF;
    --van-nav-bar-title-text-color: #fff;
    --van-nav-bar-text-color: #fff;
    --van-nav-bar-icon-color: #fff;
  }
}

.report-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 12px 16px;
  padding: 18px 16px;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);

  .banner-icon {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: #FF6B6B15;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .banner-text {
    .banner-title {
      font-size: 18px;
      font-weight: 600;
      color: #323233;
    }

    .banner-desc {
      margin-top: 4px;
      font-size: 13px;
      color: #969799;
    }
  }
}

.section-header {
  padding: 8px 20px 4px;

  .section-title {
    font-size: 13px;
    font-weight: 500;
    color: #969799;
  }
}

.report-grid {
  padding: 0 4px;

  :deep(.van-grid-item__content) {
    padding: 16px 8px 12px;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  }

  :deep(.van-grid-item__text) {
    margin-top: 8px;
  }

  .grid-icon-wrap {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .grid-text {
    font-weight: 500;
    font-size: 14px;
    color: #323233;
  }

  .grid-desc {
    font-size: 11px;
    color: #969799;
    margin-top: 2px;
    line-height: 1.3;
    text-align: center;
    display: block;
    max-width: 90px;
  }
}
</style>
