<template>
  <div>

    <el-row :gutter="20">
      <el-col :span="12">
        <Map :chartData="chartData" />
      </el-col>
      <el-col :span="12">
        <DoughnutChart :chart-data="homeData.rate_list"></DoughnutChart>
      </el-col>
    </el-row>

    <el-row>
      <el-col :span="24">
        <AreaChat :chart-data="homeData.year_list"></AreaChat>
      </el-col>
    </el-row>
  </div>
</template>

<script>
  import Map from './components/Map'
  import DoughnutChart from "./components/DoughnutChart.vue";
  import AreaChat from "./components/AreaChat.vue";
  import {
    getChartsHome
  } from "@/api/dashboard.js"

  import {
    index as indexprogress
  } from "@/api/unifiedRecruitment/progress"
  export default {
    components: {
      DoughnutChart,
      Map,
      AreaChat
    },
    data() {
      return {
        homeData:{
          rate_list:[],
          year_list:[]
        },
        chartData: {},
        colorArr: {
          "1": "#8297a3",
          "2": "#3191cb",
          "3": "#f26200",
          "4": "#35a973"
        }
      }
    },
    watch: {

    },
    methods: {
      async loadData() {
        this.loadPress()
        this.loadHomeData()
      },
      loadHomeData(){
        getChartsHome().then(res => this.homeData = res)
      },
      loadPress() {
        indexprogress({
          year: this.year,
          page_size: 999
        }).then(res => {
          var arr = [];
          for (var mod of res.data) {
            arr.push({
              name: mod.province.name,
              itemStyle: {
                areaColor: this.colorArr[mod.status_id],
                status:mod.status_id
              }
            })
          }

          this.chartData = arr;
        })
      },
      init() {}
    },
    created() {

      this.loadData();
    },
    mounted() {



    },
    destroyed() {
      window.onresize = null
    }
  }
</script>

<style lang="scss" scoped>
  .statistics {
    display: flex;

    margin-top: 20px;

    &-title {

      padding-left: 6px;
    }

    &-content {
      text-align: center;
      font-size: 13px;

      &-top {

        &__num {
          font-weight: 600;
        }

        &__name {
          font-size: 10px;
          color: rgb(140, 140, 140);
        }
      }

      &-bottom {
        display: flex;
        justify-content: space-between;

        &-left {

          &__num {
            font-weight: 600;
          }

          &__name {
            font-size: 10px;
            color: rgb(140, 140, 140);
          }
        }

        &-right {

          &__num {
            font-weight: 600;
          }

          &__name {
            font-size: 10px;
            color: rgb(140, 140, 140);
          }
        }
      }
    }

    &>div {
      flex: 1;
      margin-right: 20px;

      &:last-child {
        margin-right: 0;
      }
    }
  }

  .chart {
    display: flex;

    margin-top: 20px;


    .chartItem {

      width: 49%;

      .chartItemTitle {
        font-size: 16px;
        margin-bottom: 20px;
      }

      #col-chart {
        background: #fff;
        border-radius: 10px;
        flex: 1;
        margin-right: 20px;
        padding: 20px;
        box-sizing: border-box;
        min-height: 400px;
        width: 100%;
      }

      #line-chart {
        background: #fff;
        border-radius: 10px;
        flex: 1;
        padding: 20px;
        box-sizing: border-box;
        min-height: 400px;
      }
    }


  }
</style>
