
import { ref } from "vue";
import { defineStore } from "pinia";
// import { storeToRefs } from 'pinia';

export const useDataStore = defineStore("data", () => {
  const allData: Ref<any> = ref({
    degreeDto: [],
    forecast: {},
    forecastFill: {},
    nationStudent: [],
    payDto: {},
    provinceDto: [],
    rankingDto: [],
    sexDto: {},
    today: {},
    totalDto: {},
  });
  const degreeDto = computed(() => allData.value.degreeDto);
  const forecast = computed(() => allData.value.forecast);
  const forecastFill = computed(() => allData.value.forecastFill);
  const nationStudent = computed(() => allData.value.nationStudent);
  const payDto = computed(() => allData.value.payDto);
  const provinceDto = computed(() => allData.value.provinceDto);
  const rankingDto = computed(() => allData.value.rankingDto);
  const sexDto = computed(() => allData.value.sexDto);
  const today = computed(() => allData.value.today);
  const totalDto = computed(() => allData.value.totalDto);

  // 当日预报到报到率
  const forecastRate = computed(() => {
    (forecast.value.reported / forecast.value.total) * 100;
  });
  console.log('预报到=====>',forecastRate);

  // 当日预报到总人数报到率
  const totalRate = computed(() => {
    totalDto.value.reportNumber / totalDto.value.totalNumber;
  });

  // 选中的学院id
  const collageId = ref();
  // 切换选中的学院
  const setCollageId = (data: any) => {
    collageId.value = data;
  };
  // 学院对应的专业报到人数
  const professionRank = ref();
  const setProfessionRank = (data: any) => {
    professionRank.value = data;
  };

  const setData = (data: any) => {
    allData.value = data;
  };

  // 本科缴费人数
  const bkPay = ref();
  const setBkPay = (data: any) => {
    console.log("data", data);

    bkPay.value = data;
  };
  // 专科缴费人数
  const zkPay = ref();
  const setZkPay = (data: any) => {
    zkPay.value = data;
  };
  // 专升本缴费人数
  const zsbPay = ref();
  const setZsbPay = (data: any) => {
    zsbPay.value = data;
  };

  // 缴费总人数
  const totalPay = ref();
  const setTotalPay = (data: any) => {
    totalPay.value = data;
  };



  // 学历层次
  const batchData = ref();
  const setBatchData = (data: any) => {
    batchData.value = data;
  };

  return {
    allData,
    degreeDto,
    forecast,
    forecastFill,
    nationStudent,
    payDto,
    provinceDto,
    rankingDto,
    sexDto,
    today,
    totalDto,
    setData,
    bkPay,
    zkPay,
    zsbPay,
    setBkPay,
    setZkPay,
    setZsbPay,
    setCollageId,
    collageId,
    professionRank,
    setProfessionRank,
    forecastRate,
    totalRate,
    totalPay,
    setTotalPay,
    batchData,
    setBatchData
  };
});
