// import excelHelper from "@/utils/excelHelper";
import * as echarts from "echarts";
export default {
    data() {
      return {
        formInline: {
        windfarm: "",
        project: "",
        line: "",
        },
        month:'',
        year:'',
        timeyear:'',
        timemonth:'',
        currentPage2: 1,
	      pagesize: 10,
        gridData:[],
        gridDataChart:[],
        charFreData:[],
        charNameData:[],
        options: [],
        options2: [],
        orderByColumn:'',
        isAsc: '',
        value: 'MHS_FDC',
        value2:'',
        fanData:'',
        title:'',
        updateTime:'',
      }
    },
   
    created(){
        this.API.get('/powercompare/windfarmAjax').then((res) => {
            this.options = res.data;
        })
        this.callAndSpeedData();
    },
    methods:{
        queryApData() {
            this.callAndSpeedData();
        },
        headStyle() {
          return "text-align:center,background-color:red"
        },
        tableDatawindturbineName(val){
          this.fanData = val;
          console.log(this.fanData)
          this.timemonth = this.month.toString(); 
          this.timeyear = this.year.toString();
          this.timemonth = this.timemonth.slice(5,7);
          this.$router.push({
            path:'/singleMachineAnalysisOperation',
            query:{
              data:this.fanData,
              timeyear: this.year,
              timemonth: this.timemonth
            }
          })
        },
        changeTableSort(column){
          this.orderByColumn = column.prop;
          if(column.order == "descending"){
            this.isAsc = 'desc';
          }else if(column.order == "ascending"){
            this.isAsc = "asc";
          }
          this.callAndSpeedData();
        },
        projectData(){
            this.API.get('/powercompare/projectAjax?wpIds=' + this.value).then((res) =>{
                this.options2 = res.data;
            })
        },
        callAndSpeedData(){
            const nowDate = new Date();
            const date = {
                year: nowDate.getFullYear(),
                month: nowDate.getMonth() + 1,
                date: nowDate.getDate(),
            }
            const newmonth = date.month>10?date.month:'0'+date.month
            const day = date.date>10?date.date - 1:'0'+date.date
            this.updateTime = date.year + '-' + newmonth + '-' + day
            if(this.month == ''){
              this.month = this.updateTime;
              this.timemonth = this.month.slice(5,7);
            }else{
              this.month = this.month.toString(); 
              this.timemonth = this.month.slice(5,7);
            }
            if(this.year == ''){
              this.year = this.updateTime;
              this.year = this.year.slice(0,4);
            }else{
              this.year = this.year.toString();
            }
            var performanceAnalysis = new URLSearchParams();
            performanceAnalysis.append('pageNum',this.currentPage2);
		      	performanceAnalysis.append('pageSize',this.pagesize);
            performanceAnalysis.append('orderByColumn',this.orderByColumn);
            performanceAnalysis.append('isAsc',this.isAsc);
		  	    performanceAnalysis.append('wpId',this.value);
            performanceAnalysis.append('year',this.year);
            performanceAnalysis.append('month',this.timemonth);
            this.API.post('/singleanalysis/singleanalysisMain',performanceAnalysis).then((res) => {
                this.gridData = res.data;
                this.title = this.gridData[0].windPowerStationName + this.timeyear + '年' + this.timemonth + '月单台机组运行指标性能分析';
            })
        },
        toExcel(){
            excelHelper.exportExcel("callthepolicetable","负荷率排行榜",".xls",true);
        },
    }
}