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

const router = useRouter()

/** 上报类型列表 */
const reportTypes = [
  {
    text: '积淹点',
    icon: 'warning-o',
    route: '/reportFloodedPoints',
    desc: '积水、淹没点位上报',
  },
  {
    text: '巡检问题',
    icon: 'search',
    route: '/reportInspection',
    desc: '巡检发现的问题',
  },
  {
    text: '设备报修',
    icon: 'setting-o',
    route: '/reportEquipmentRepair',
    desc: '设备故障报修',
  },
  {
    text: '督办问题',
    icon: 'records',
    route: '/reportSupervise',
    desc: '督办项目问题',
  },
  {
    text: '项目问题',
    icon: 'bulb-o',
    route: '/reportProject',
    desc: '项目相关问题',
  },
  {
    text: '施工问题',
    icon: 'cluster-o',
    route: '/reportConstruction',
    desc: '施工现场问题',
  },
  {
    text: '积水调查',
    icon: 'water-o' as string,
    route: '/reportFloodedPoints',
    desc: '积水调查记录',
  },
  {
    text: '养护上报',
    icon: 'logistics',
    route: '/reportEquipmentRepair',
    desc: '养护问题上报',
  },
]

/** 跳转 */
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-title">选择上报类型</div>
      <div class="banner-desc">请根据实际情况选择对应的问题类型进行上报</div>
    </div>

    <van-grid :column-num="3" :border="false" :gutter="12" class="report-grid">
      <van-grid-item
        v-for="item in reportTypes"
        :key="item.text"
        :icon="item.icon"
        :text="item.text"
        @click="goReport(item.route)"
      >
        <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: var(--color-bg-page);

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

.report-banner {
  padding: 20px 16px 12px;
  background: #fff;
  margin-bottom: 12px;

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

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

.report-grid {
  padding: 0 4px;

  :deep(.van-grid-item__content) {
    padding: 16px 8px;
    background: var(--color-bg-card);
    border-radius: 10px;
  }

  :deep(.van-grid-item__text) {
    font-weight: 500;
    font-size: 14px;
    margin-top: 6px;
  }

  .grid-desc {
    font-size: 11px;
    color: #999;
    margin-top: 2px;
  }
}
</style>
