// import excelHelper from "@/utils/excelHelper";
import * as echarts from "echarts";
export default {
    data() {
      return {
        formInline: {
        windfarm: "",
        project: "",
        line: "",
        },
        timedate: [],
        currentPage2: 1,
		pagesize: 10,
        gridData:[],
        gridDataChart:[],
        charFreData:[],
        charNameData:[],
        options: [{
          id: '1',
          name: '按报警统计'
        }, {
          id: '2',
          name: '按报警分类统计'
        }, {
          id: '3',
          name: '按厂家统计'
        }],
        orderByColumn:'',
        isAsc: '',
        value: '1',
        updateTime:'',
        updateTime1:'',
      }
    },
   
    created(){
        this.callThePolicRateData();
        
    },
    methods:{
        queryApData() {
            this.callThePolicRateData();
            this.$nextTick(function() {
			    this.getChartDataImport('chartHistogram')
		    })
        },
        
        headStyle() {
			return "text-align:center"
		},
        
        changeTableSort(column){
			this.orderByColumn = column.prop;
			if(column.order == "descending"){
				this.isAsc = 'desc';
			}else if(column.order == "ascending"){
				this.isAsc = "asc";
			}
			this.callThePolicRateData();
		},
        callThePolicRateData(){
            this.charFreData = [];
            this.charNameData = [];
            var newData = new Date();
            this.updateTime = this.BASE.getBzDate(newData.getTime(), 0);
            this.updateTime1 = this.BASE.getBzDate(newData.getTime(), -1);
            if(this.timedate == ''){
                this.timedate[0] = this.updateTime1;
                this.timedate[1] = this.updateTime;
                this.beginDate = this.timedate[0];
                this.endDate = this.timedate[1];
            }else{
                this.beginDate = this.timedate[0];
                this.endDate = this.timedate[1];
            }
            var callThePolicRateData = new URLSearchParams();
            callThePolicRateData.append('pageNum',this.currentPage2);
			callThePolicRateData.append('pageSize',this.pagesize);
            callThePolicRateData.append('orderByColumn',this.orderByColumn);
            callThePolicRateData.append('isAsc',this.isAsc);
			callThePolicRateData.append('type',this.value);
			callThePolicRateData.append('beginDate',this.beginDate);
            callThePolicRateData.append('endDate',this.endDate);
            this.API.post('/leaderboard/querywarningStatistical',callThePolicRateData).then((res) => {
                this.gridData = res.data;
                this.gridDataChart = res.data;
                for(let i=0;i<this.gridDataChart.length;i++){
                    this.charFreData.push(this.gridDataChart[i].frequencyday);
                    this.charNameData.push(this.gridDataChart[i].name);
                }
                this.$nextTick(function() {
			        this.getChartDataImport('chartHistogram')
		        })
            })
            
        },
        toExcel(){
            excelHelper.exportExcel("callthepolicetable","负荷率排行榜",".xls",true);
        },
        getChartDataImport(){
            this.ECLZX.getcallThePoliceChart("chartHistogram",
            this.charNameData,this.charFreData);
        }
    }
}