<template>
  <div id="month-sta" class="block h100">
    <div class="black-title">办件量月度统计</div>
    <div class="flex1 echarts" ref="echarts">

    </div>
  </div>
</template>

<script>
import {setTrendBtMonthOption} from "../../echarts/option";
import * as echarts from "echarts";
import {mapMutations} from "vuex";

export default {
  name: "MonthSta",
  data(){
    return{
      MonthSta_XZXK:[0,0,0,0,0,0,0,0,0,0,0,0],
      MonthSta_XZQR:[0,0,0,0,0,0,0,0,0,0,0,0],
      MonthSta_XZJL:[0,0,0,0,0,0,0,0,0,0,0,0],
      MonthSta_XZZS:[0,0,0,0,0,0,0,0,0,0,0,0],
      MonthSta_QTQL:[0,0,0,0,0,0,0,0,0,0,0,0],
      MonthSta_GGFW:[0,0,0,0,0,0,0,0,0,0,0,0],
    }

  },
  mounted() {
    let ele = this.$refs.echarts
    this.$nextTick(() => {
      setTrendBtMonthOption(this.$refs.echarts,this.MonthStaX_XZXK,this.MonthStaY_XZXK,this.MonthStaY_QTQL)
    })
    this.$request({
      url:'/ywtb/getMonthNumberList',

      method:'post',
      data:{
        "pageIndex":"1",
        "pageSize":"100"
      }
    }).then(response => {
      var dataArr = response.data.msg[0].Rows;
      let month = this.GetMonth().reverse();
      for(var j=0;j<dataArr.length;j++){
        if(dataArr[j].TYPE == '行政许可'){
          if(month.indexOf(dataArr[j].DATE_TIME) > -1){
            this.MonthSta_XZXK.splice(month.indexOf(dataArr[j].DATE_TIME),1,dataArr[j].DATA_COUNT)
          }
        }else if(dataArr[j].TYPE == '其他权利'){
          if(month.indexOf(dataArr[j].DATE_TIME) > -1){
            this.MonthSta_QTQL.splice(month.indexOf(dataArr[j].DATE_TIME),1,dataArr[j].DATA_COUNT)
          }
        }else if(dataArr[j].TYPE == '行政确认'){
          if(month.indexOf(dataArr[j].DATE_TIME) > -1){
            this.MonthSta_XZQR.splice(month.indexOf(dataArr[j].DATE_TIME),1,dataArr[j].DATA_COUNT)
          }
        }else if(dataArr[j].TYPE == '行政奖励'){
          if(month.indexOf(dataArr[j].DATE_TIME) > -1){
            this.MonthSta_XZJL.splice(month.indexOf(dataArr[j].DATE_TIME),1,dataArr[j].DATA_COUNT)
          }
        }else if(dataArr[j].TYPE == '行政征收'){
          if(month.indexOf(dataArr[j].DATE_TIME) > -1){
            this.MonthSta_XZZS.splice(month.indexOf(dataArr[j].DATE_TIME),1,dataArr[j].DATA_COUNT)
          }
        }else if(dataArr[j].TYPE == '公共服务'){
          if(month.indexOf(dataArr[j].DATE_TIME) > -1){
            this.MonthSta_GGFW.splice(month.indexOf(dataArr[j].DATE_TIME),1,dataArr[j].DATA_COUNT)
          }
        }

      }
      setTrendBtMonthOption(ele,month,this.MonthSta_XZXK,this.MonthSta_QTQL,this.MonthSta_XZQR,this.MonthSta_XZJL,this.MonthSta_XZZS,this.MonthSta_GGFW)
      echarts.init(ele).on('click',(params)=> {
        //console.log( this.HandleStaticCode[params.dataIndex])
        console.log(params.seriesName)
        this.$router.push('/origion/handleAnalysis');
        this.analysisRefresh(false);
        this.$nextTick(() => {
          this.analysisSingleChange([
            {
              name:'analysisThirdLevel',
              value:params.seriesName
            },
            {
              name:'analysisTimer',
              value:'365'
            },
            {
              name:'analysisUrgeType',
              value:'SL_TX'
            },
          ])
        // this.analysisThirdLevel(params.seriesName)
        // this.analysisTimer('365');
        //   this.analysisUrgeType('SL_TX');
        })
      })
    })
  },
  methods:{
    formatNumber(value) {
      return (value < 10 ? "0" : "") + value;
    },
    GetMonth() {
      let current = new Date();
      let year = current.getFullYear();
      let month = current.getMonth();
      let calendar = [];
      while (year > current.getFullYear() - 1 ||month > current.getMonth()) {
        calendar.push(year + "-" + this.formatNumber(month));
        month -= 1;
        if (month <= 0) {
          year -= 1;
          month = 12;
        }
      }
      return calendar;
    },
    ...mapMutations(['analysis','analysisRefresh','analysisSingleChange'])
  }
}
</script>

<style scoped lang="scss">
#month-sta{

}
</style>
