<template>

  <div id="analysis-total-notice"   class="block h100">
    <div class="black-title">提醒及督办趋势</div>
    <div  v-loading="loading"  element-loading-text="数据加载中"
          element-loading-spinner="el-icon-loading"
          element-loading-background="rgba(3, 30, 57, 0.8)">
      <div  class="flex3 echarts" ref="echarts"></div>
<!--      <div v-if="$store.state.analysisThirdLevel!=''&&$store.state.analysisForthLevel==''" :key="2" class="flex3 echarts" ref="echarts"></div>-->

<!--      <div v-if="$store.state.analysisForthLevel!=''" :key="3" class="flex3 echarts" ref="echarts"></div>-->
    </div>
  </div>
</template>

<script>
import {daysX, daysY} from "@/commomUse";
import {mapMutations, mapState} from 'vuex';
import {setAnalysisTotalNotice} from "@/echarts/option";
import * as echarts from "echarts";
export default {
  name: "AnalysisTotalNotice",
  computed:{
    ...mapState({
      analysisObject:'analysis',
      reFresh:'analysisRefresh',
    })
  },
  data(){
    return{
      loading: true,
      basicList:[],
      dataX:[],
      dataY_COUNT_SD:[],
      dataY_COUNT_ST:[],
      dataY_COUNT_BD:[],
      dataY_COUNT_BT:[],
      dataY_MONTH:[],
      dataY_YEAR:[],
      itemList:[],
      situationList:[],
    }
  },
  mounted() {
    this.typeShow()
  },
  methods:{
    typeShow(){
      if(this.analysisObject['analysisThirdLevel']==''&& this.analysisObject['analysisForthLevel']==''){
        this.basicShow()
      }else if(this.analysisObject['analysisThirdLevel']!=''&&this.analysisObject['analysisForthLevel']==''){
        this.basicShow()
      }else if(this.analysisObject['analysisForthLevel']!=''&&this.analysisObject['analysisFifthLevel']==''){
        this.itemShow();
      }else if(this.analysisObject['analysisFifthLevel']!=''){
        this.situationShow();
      }
    },
    basicShow(){
      this.loading=true;
      this.$request({
        url:'/YWTBApi/queryTimingRemindInfo',
        method:'post',
        data:{
          'TYPE':this.analysisObject['analysisThirdLevel'],
          "DATA_TYPE":this.analysisObject['analysisFirstLevel'],
          "ORGANIZATION":this.analysisObject['analysisSecondLevel'],
        }
      }).then(response => {
        let dataArr = response.data.msg[0].Rows;
        this.basicList = dataArr;
        this.dataX=daysX(30);
        this.dataY_COUNT_SD=daysY(30);
        this.dataY_COUNT_ST=daysY(30);
        this.dataY_COUNT_BD=daysY(30);
        this.dataY_COUNT_BT=daysY(30);
          for(let j=0;j<this.dataX.length;j++){
            for(let i=0;i<dataArr.length;i++){
            if(this.dataX[j] ==dataArr[i].DATE_TIME){
              this.dataY_COUNT_SD[j]=dataArr[i].SD!=undefined?dataArr[i].SD.toString():0;
              this.dataY_COUNT_ST[j]=dataArr[i].ST!=undefined?dataArr[i].ST.toString():0;
              this.dataY_COUNT_BD[j]=dataArr[i].BD!=undefined?dataArr[i].BD.toString():0;
              this.dataY_COUNT_BT[j]=dataArr[i].BT!=undefined?dataArr[i].BT.toString():0;
              console.log(dataArr[i].SD!=undefined?dataArr[i].SD:0,dataArr[i].ST!=undefined?dataArr[i].ST:0,dataArr[i].BD!=undefined?dataArr[i].BD:0,dataArr[i].BT!=undefined?dataArr[i].BT:0)
              console.log(dataArr[i],this.dataY_COUNT_SD[j],this.dataY_COUNT_ST[j],this.dataY_COUNT_BD[j],this.dataY_COUNT_BT[j])
            }
          }
        }
        this.$nextTick(() => {
          this.loading=false;
          let ele = this.$refs.echarts
          setAnalysisTotalNotice(ele,this.dataX,this.dataY_COUNT_SD,this.dataY_COUNT_ST,this.dataY_COUNT_BD,this.dataY_COUNT_BT)
          echarts.init(ele).on('click',(params)=> {
            console.log(params.seriesName)

            this.$router.push('/origion/handleSituation');
            this.handleSituationRefresh(false);
            this.$nextTick(() => {
             let index = this.getHandleSituationCode(params.seriesName);
              this.handleSituationSingleChange([
                {
                  name:'handleSituationThirdLevel',
                  value:index
                },
              ])
            })
          })
        })
      })
    },
    getHandleSituationCode(name){
      console.log(name)
      if(name =='受理提醒'||name =='办结提醒'){
        return '6'
      }else{
        return '7'
      }
    },
    itemShow(){
      this.loading=true;
      this.$request({
        url:'/YWTBApi/queryTimingRemindInfo',
        method:'post',
        data:{
          'TYPE':this.analysisObject['analysisThirdLevel'],
          "DATA_TYPE":this.analysisObject['analysisFirstLevel'],
          "ORGANIZATION":this.analysisObject['analysisSecondLevel'],
          "MATTER_CODE":this.analysisObject['analysisForthLevel'],
        }
      }).then(response => {
        let dataArr = response.data.msg[0].Rows;
        this.basicList = dataArr;
        this.dataX=daysX(30);
        this.dataY_COUNT_SD=daysY(30);
        this.dataY_COUNT_ST=daysY(30);
        this.dataY_COUNT_BD=daysY(30);
        this.dataY_COUNT_BT=daysY(30);
        for(let i=0;i<dataArr.length;i++){
          for(let j=0;j<this.dataX.length;j++){
            if(this.dataX[j] ==dataArr[i].DATE_TIME){
              this.dataY_COUNT_SD[j]=dataArr[i].SD!=undefined?dataArr[i].SD:0;
              this.dataY_COUNT_ST[j]=dataArr[i].ST!=undefined?dataArr[i].ST:0;
              this.dataY_COUNT_BD[j]=dataArr[i].BD!=undefined?dataArr[i].BD:0;
              this.dataY_COUNT_BT[j]=dataArr[i].BT!=undefined?dataArr[i].BT:0;
            }
          }
        }
        this.$nextTick(() => {
          this.loading=false;
          let ele = this.$refs.echarts
          setAnalysisTotalNotice(ele,this.dataX,this.dataY_COUNT_SD,this.dataY_COUNT_ST,this.dataY_COUNT_BD,this.dataY_COUNT_BT)
        })
      })
    },
    situationShow(){
      this.loading=true;
      this.$request({
        url:'/YWTBApi/queryTimingRemindInfo',
        method:'post',
        data:{
          'TYPE':this.analysisObject['analysisThirdLevel'],
          "DATA_TYPE":this.analysisObject['analysisFirstLevel'],
          "ORGANIZATION":this.analysisObject['analysisSecondLevel'],
          "SITUATION_CODE":this.analysisObject['analysisFifthLevel'],
        }
      }).then(response => {
        let dataArr = response.data.msg[0].Rows;
        this.basicList = dataArr;
        this.dataX=daysX(30);
        this.dataY_COUNT_SD=daysY(30);
        this.dataY_COUNT_ST=daysY(30);
        this.dataY_COUNT_BD=daysY(30);
        this.dataY_COUNT_BT=daysY(30);
        for(let i=0;i<dataArr.length;i++){
          for(let j=0;j<this.dataX.length;j++){
            if(this.dataX[j] ==dataArr[i].DATE_TIME){
              this.dataY_COUNT_SD[j]=dataArr[i].SD!=undefined?dataArr[i].SD:0;
              this.dataY_COUNT_ST[j]=dataArr[i].ST!=undefined?dataArr[i].ST:0;
              this.dataY_COUNT_BD[j]=dataArr[i].BD!=undefined?dataArr[i].BD:0;
              this.dataY_COUNT_BT[j]=dataArr[i].BT!=undefined?dataArr[i].BT:0;
            }
          }
        }
        this.$nextTick(() => {
          this.loading=false;
          let ele = this.$refs.echarts
          setAnalysisTotalNotice(ele,this.dataX,this.dataY_COUNT_SD,this.dataY_COUNT_ST,this.dataY_COUNT_BD,this.dataY_COUNT_BT)
        })
      })
    },
    ...mapMutations(['analysis','analysisRefresh','analysisSingleChange','handleSituationRefresh','handleSituation','handleSituationSingleChange'])
  },
  watch: {
    analysisObject(){
      this.typeShow()
    },
  }
}
</script>

<style scoped lang="scss">
#analysis-total-notice{
  .black-title{
    height: 32px;
    display: flex;
    color: #fff;
    font-size: 20px;
    font-weight: bold;
    justify-content: center;
    align-items: center;

  }
}
</style>
