<template>
  <div class="outer-person-container">
    <div class="container-title">
      <span class="line"></span>
      <span class="title">车辆进入管理</span>
    </div>
    <div class="vehicle-flow">
      <img class="vehicle-flow-icon" src="@/assets/images/security-confidientiality/vehicle-flow.png" alt="" />
      <span class="vehicle-flow-label">今日车流量</span>
      <span class="vehicle-flow-value">{{ lastDayFlow }}</span>
    </div>
    <VehicleChart v-if="barData" class="chart-container" :data="barData" id="VehicleChart" />
  </div>
</template>

<script setup lang="ts">
  import { onMounted, ref } from 'vue';
  import VehicleChart from '../charts/VehicleChart.vue';
  import { getVehicleOverviewChartData } from '../hooks';
  import type { BarChartData } from '../types';

  const barData = ref<BarChartData>();
  const lastDayFlow = ref<number>(0);

  onMounted(async () => {
    barData.value = await getVehicleOverviewChartData();
    lastDayFlow.value = barData.value.value[barData.value.value.length - 1];
  });
</script>

<style scoped lang="scss">
  .container-title {
    height: 24px;
    display: flex;
    align-items: center;
    font-weight: 500;
    font-size: 16px;
    color: #000000;

    .line {
      width: 3px;
      height: 16px;
      background: #1777ff;
      margin-right: 10px;
    }

    .title {
      margin-right: 12px;
    }
  }

  .outer-person-container {
    width: 100%;
    height: 100%;
    padding-top: 14px;
  }

  .vehicle-flow {
    margin: 6px 0;
    height: 26px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
  }

  .vehicle-flow-icon {
    width: 20px;
    height: 20px;
  }

  .vehicle-flow-label {
    font-weight: 600;
    font-size: 16px;
    color: #303133;
  }

  .vehicle-flow-value {
    position: relative;
    bottom: 3px;
    font-weight: 600;
    font-size: 28px;
    color: #1777ff;
  }

  .chart-container {
    width: 100%;
    height: calc(100% - 62px);
  }
</style>
