<template>
<div id="unit-event-center" class="h100 block">
  <div class="black-title">单位办件量(top 10)</div>
  <div class="echarts flex1" ref="echarts"></div>
</div>
</template>

<script>
//import {setHandleStaticOption, setUnitEventOption} from "../../echarts/option";
import {setUnitEventOption} from "../../echarts/option";
import * as echarts from "echarts";
import {mapMutations} from "vuex";
export default {
  name: "UnitEventCenter",
  data(){
    return{
      UnitEventCenterX:[
      ],
      UnitEventCenterXTotal:[
      ],
      UnitEventCenterY:[
      ],
      UnitEventCode:[
      ]
    }

  },
  mounted() {
    let ele = this.$refs.echarts
    this.$nextTick(() => {
      setUnitEventOption(this.$refs.echarts,this.UnitEventCenterX,this.UnitEventCenterY)
    })
    this.$request({
      url:'/YWTBApi/queryUnitDataCount',

      method:'post',
      data:{
        "pageIndex":"1",
        "pageSize":"10"
      }
    }).then(response => {
      var dataArr = response.data.msg[0].Rows.reverse();
      // let op = ['燃气中心','房地产交易中心', '局人才中心','市场管理总站', '质安处', '城管执法局','房屋状况信息中心','修缮中心']
      // for(var i=0;i<op.length;i++){
      //   this.UnitEventCenterX.push(op[i]);
      //   this.UnitEventCenterY.push('0');
      // }
      for(var j=0;j<dataArr.length;j++){
        this.UnitEventCenterX.push(dataArr[j].NAME.length>8?dataArr[j].NAME.substr(0,8)+"...":dataArr[j].NAME);
        this.UnitEventCenterXTotal.push(dataArr[j].NAME);
        this.UnitEventCenterY.push(dataArr[j].DATA_COUNT);
        this.UnitEventCode.push(dataArr[j].NAME);
      }
      // for(var k=0;k<dataArr.length;k++){
      //   if(dataArr[k].DATA_SOURCE=='行政服务中心'){
      //     let location = this.UnitEventCenterX.indexOf("行政服务中心")
      //     this.UnitEventCenterX[location] = '委建管处';
      //   }
      // }
     // console.log(this.HandleStaticData);
      setUnitEventOption(ele,this.UnitEventCenterX,this.UnitEventCenterXTotal,this.UnitEventCenterY)
      echarts.init(ele).on('click',(params)=> {
        console.log( this.UnitEventCode[params.dataIndex])
        this.$router.push('/origion/handleAnalysis');
        this.analysisRefresh(false);
        this.$nextTick(() => {

          this.analysisSingleChange([
            {
              name:'analysisUnit',
              value:this.UnitEventCode[params.dataIndex]
            },
            {
              name:'analysisTimer',
              value:'365'
            },
            {
              name:'analysisUrgeType',
              value:'SL_TX'
            },
          ])
        })
      })
    })
  },
  methods:{
    ...mapMutations(['analysis','analysisRefresh','analysisSingleChange'])
  }
}
</script>

<style scoped lang="scss">

</style>
