<template>
  <a-row>
    <a-col :xs="24" :sm="24" :md="12" :lg="12" :xl="6" v-for="(item, index) in growCardList" :key="item.title">
      <div class="item" :style="{ background: item.bgColor }">
        <div class="left">
          <img :src="item.imgUrl" alt="" />
          <div class="title">{{ item.title }}</div>
        </div>
        <div class="right">
          <div class="num-con">
            国家系统&nbsp;
            <CountTo :startVal="1" :endVal="item.nationSys" class="num"
          /></div>
          <div class="num-con">
            广东省系统&nbsp;
            <CountTo :startVal="1" :endVal="item.gdProvinceSys" class="num"
          /></div>
        </div>
      </div>
    </a-col>
  </a-row>
</template>
<script lang="ts" setup>
  import { ref, onMounted } from 'vue';
  import { CountTo } from '/@/components/CountTo/index';
  import { getIndexTop } from '@/api/dashboard/api';
  import img0 from '@/assets/images/gross_plot.png';
  import img1 from '@/assets/images/uninvestigated.png';
  import img2 from '@/assets/images/no_exceed.png';
  import img3 from '@/assets/images/exteed.png';
  const growCardList = ref([
    {
      title: '总地块',
      nationSys: 0,
      gdProvinceSys: 0,
      bgColor: 'linear-gradient(-90deg,rgba(252,190,0,1),rgba(252,196,0,1))',
      imgUrl: img0,
    },
    {
      title: '未调查地块',
      nationSys: 0,
      gdProvinceSys: 0,
      bgColor: 'linear-gradient(-90deg,rgba(23,166,98,1),rgba(27,199,116,1))',
      imgUrl: img1,
    },
    {
      title: '未超标地块',
      nationSys: 0,
      gdProvinceSys: 0,
      bgColor: 'linear-gradient(-90deg,rgba(22,117,218,1),rgba(54,151,255,1))',
      imgUrl: img2,
    },
    {
      title: '超标地块',
      nationSys: 0,
      gdProvinceSys: 0,
      bgColor: 'linear-gradient(-90deg,rgba(252,107,0,1),rgba(252,125,0,1))',
      imgUrl: img3,
    },
  ]);
  /**
   * 初始化数据
   */
  function init() {
    getIndexTop().then((res) => {
      if (res) {
        growCardList.value[0].nationSys = res.countryTotal; // 国家总地块数
        growCardList.value[0].gdProvinceSys = res.total; // 广东总地块数
        growCardList.value[1].nationSys = res.countrySuspected; // 国家未调查地块
        growCardList.value[1].gdProvinceSys = res.suspected; // 广东未调查地块
        growCardList.value[2].nationSys = res.countryNormal; // 国家未超标地块
        growCardList.value[2].gdProvinceSys = res.normal; // 广东未超标地块
        growCardList.value[3].nationSys = res.countryPolluted; // 国家超标地块
        growCardList.value[3].gdProvinceSys = res.polluted; // 广东超标地块
      }
    });
  }
  onMounted(() => {
    init();
  });
</script>
<style lang="less" scoped>
  .ant-col {
    padding: 5px;
    .item {
      padding: 20px;
      display: flex;
      justify-content: space-between;
      .left {
        flex-shrink: 0;
        margin-right: 15px;
        text-align: center;

        img {
          width: 86px;
        }
        .title {
          color: #fff;
          font-size: 24px;
          line-height: 36px;
        }
      }
      .right {
        flex-shrink: 0;
        display: flex;
        flex-direction: column;
        justify-content: space-around;
        .num-con {
          color: #fff;
          font-size: 22px;
          &:first-child {
            margin-bottom: 10px;
          }
          .num {
            font-size: 30px;
          }
        }
      }
    }
  }
</style>
