<script setup lang="ts">
import { useDataStore,useTimeStore } from "@/stores/index";
const dataStore = useDataStore();
const { degreeDto } = storeToRefs(dataStore)
const timeStore = useTimeStore()
const { nowTitle } = storeToRefs(timeStore)
const rate = (total: any, registers: any) => {
  return ((registers / total) * 100).toFixed(1)
}
const bkRate = computed(() => {
  if (degreeDto.value?.length ) {
    const datas = degreeDto.value.filter((item:any) => item.degree === "统招本科")[0];
    return rate(datas.studentNumber, datas.reportNumber)
  } else {
    return 0
  }
})
const zkRate = computed(() => {
  if (degreeDto.value?.length) {
    const datas = degreeDto.value.filter((item:any) => item.degree === "统招专科")[0];
    return rate(datas.studentNumber, datas.reportNumber)
  } else {
    return 0
  }
})

const zsbRate = computed(() => {
  if (degreeDto.value?.length) {
    const datas = degreeDto.value.filter((item:any) => item.degree === "统招专升本")[0];
    return rate(datas.studentNumber, datas.reportNumber)
  } else {
    return 0
  }
})
</script>

<template>
  <div class="left-center">
    <div class="items">
      <div class="title-bg">
        <img class="line" src="@/assets/img/zheke/title_line1.png">
        <img class="icons" src="@/assets/img/zheke/left_center1.png">
      </div>
      <div class="content">
        <div class="content-left">
          <div class="content-title title-top">统招本科</div>
          <p class="item-title">统招本科总人数</p>
          <p class="item-content">{{ degreeDto[2]?degreeDto[2].studentNumber:'0' }}</p>
        </div>
        <div class="content-right">
          <div class="right-title title-top item-title">报到率
            <span class="title-num numBlue">{{ isNaN(bkRate) ? '0' : bkRate }}%</span>
          </div>
          <p class="item-title">{{nowTitle}}报到人数</p>
          <p class="item-content numBlue">{{ degreeDto[2]?degreeDto[2].reportNumber:'0' }}</p>
        </div>
      </div>
    </div>
    <div class="items">
      <div class="title-bg">
        <img class="line" src="@/assets/img/zheke/title_line2.png">
        <img class="icons" src="@/assets/img/zheke/left_center2.png">
      </div>
      <div class="content">
        <div class="content-left">
          <div class="content-title title-top tGreen">统招专科</div>
          <p class="item-title">统招专科总人数</p>
          <p class="item-content">{{ degreeDto[0]?degreeDto[0].studentNumber:'0' }}</p>
        </div>
        <div class="content-right">
          <div class="right-title title-top item-title">报到率
            <span class="title-num numGreen">{{ isNaN(zkRate) ? '0' : zkRate }}%</span>
          </div>
          <p class="item-title">{{nowTitle}}报到人数</p>
          <p class="item-content numGreen">{{ degreeDto[0]?degreeDto[0].reportNumber:'0' }}</p>
        </div>
      </div>
    </div>
    <div class="items">
      <div class="title-bg">
        <img class="line" src="@/assets/img/zheke/title_line3.png">
        <img class="icons" src="@/assets/img/zheke/left_center3.png">
      </div>
      <div class="content">
        <div class="content-left">
          <div class="content-title title-top tGray">统招专升本</div>
          <p class="item-title">统招专升本总人数</p>
          <p class="item-content">{{ degreeDto[1]?degreeDto[1].studentNumber:'0' }}</p>
        </div>
        <div class="content-right">
          <div class="right-title title-top item-title">报到率
            <span class="title-num numGrey">{{ isNaN(zsbRate) ? '0' : zsbRate }}%</span>
          </div>
          <p class="item-title">{{nowTitle}}报到人数</p>
          <p class="item-content numGrey">{{ degreeDto[1]?degreeDto[1].reportNumber:'0' }}</p>
        </div>
      </div>
    </div>
  </div>
</template>

<style scoped lang="scss">
.items {
  position: relative;
  display: flex;
  margin-bottom: 20px;

  .line {
    position: absolute;
    top: 0;
    left: 80px;
  }

  .content {
    padding: 10px 0 0 15px;
    display: flex;

    .content-left {
      width: 140px;
      margin-right: 20px;
    }

    .content-title {
      font-weight: bold;
      font-size: 18px;
      color: #AFCAE1;
      font-style: italic;
    }

    .title-top {
      height: 40px;

      .title-num {
        font-family: YouSheBiaoTiHei;
        font-weight: 400;
        font-size: 24px;
      }
    }

    .item-title {
      font-weight: 400;
      font-size: 14px;
      color: #BCD3DF;
      line-height: 25px;
      font-style: italic;
      opacity: 0.89;
    }

    .item-content {
      font-family: YouSheBiaoTiHei;
      font-weight: 400;
      font-size: 24px;
      color: #F1F6FB;
    }

    .numBlue {
      color: #69cbff;
    }

    .numGreen {
      color: #73eba8;
    }

    .numGrey {
      color: #84baef;
    }

    .tGreen {
      color: #a9d9c7;
    }

    .tGray {
      color: #9499b9;
    }
  }
}
</style>
