<template>
  <div>
    <TopTitle title="灾害防范" />
    <div class="content">
      <div class="content-item">
        <span class="title">本月气象灾害预警数</span>
        <span class="value">{{ weatherWarningCount }}</span>
      </div>
      <div class="content-item">
        <span class="title">预防检查覆盖</span>
        <span class="value">{{ preventionCheckCoverage }}</span>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
  import { onMounted, ref } from 'vue';
  import TopTitle from './TopTitle.vue';
  import { getDisasterPreventionInfo } from '@/api/disaster-overview';

  const weatherWarningCount = ref<number>(0);
  const preventionCheckCoverage = ref<string>('');

  onMounted(async () => {
    const disasterPreventionRes = await getDisasterPreventionInfo();
    weatherWarningCount.value = disasterPreventionRes.monthDisasterCount;
    preventionCheckCoverage.value = disasterPreventionRes.preventiveInspectRatio || '0%';
  });
</script>

<style scoped lang="scss">
  .content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 12px 10px 24px 10px;
  }

  .content-item {
    width: 150px;
    height: 76px;
    background: linear-gradient(180deg, #eaefff 0%, #ffffff 100%);
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 12px 12px 16px 12px;
  }

  .title {
    font-weight: 400;
    font-size: 14px;
    color: #666666;
    line-height: 20px;
  }

  .value {
    font-family: DINAlternate;
    font-weight: bold;
    font-size: 22px;
    color: #333333;
    line-height: 26px;
  }
</style>
