<template>
  <div class="risk-identification">
    <div class="title">
      <span class="line"></span>
      <span class="text">风险的识别与管控</span>
    </div>
    <div class="risk-identification__content">
      <div class="content-item" v-for="item in riskIdentificationContent" :key="item.name">
        <span class="name">{{ item.name }}</span>
        <span class="value">{{ item.value }}</span>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
  import { onMounted, ref } from 'vue';
  import { getRiskIdentification } from '@/api/institute-safety';

  interface RiskIdentificationContent {
    name: string;
    value: number;
  }

  const riskIdentificationContent = ref<RiskIdentificationContent[]>([]);

  onMounted(() => {
    getRiskIdentification().then((res) => {
      riskIdentificationContent.value = [
        { name: '今日危险作业数', value: res.dangerNum },
        { name: '今日施工作业数', value: res.constructionNum },
      ];
    });
  });
</script>

<style scoped lang="scss">
  .title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;

    .line {
      width: 3px;
      height: 16px;
      background: #1777ff;
    }

    .text {
      font-weight: 500;
      font-size: 16px;
      color: #000000;
      line-height: 22px;
    }
  }

  .risk-identification__content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;

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

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

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