// import excelHelper from "@/utils/excelHelper";
import * as echarts from "echarts";
export default {
    data() {
      return {
        formInline: {
        windfarm: "",
        project: "",
        line: "",
        },
        timeyear:'',
        currentPage2: 1,
	    pagesize: 10,
        gridData:[],
        gridDataChart:[],
        charFreData:[],
        charNameData:[],
        options: [],
        options2: [],
        options3: [],
        orderByColumn:'',
        isAsc: '',
        value: '',
        value2:'',
        value3:'',
        value4:'',
        dialogFormVisible: false,
        dialogFormVisible2: false,
        form: {
          gc01: '',
          gc02: '',
          gc03: '',
          gc04: '',
          gc05: '',
          gc06: '',
          gc07: '',
          gc08: '',
          gc09: '',
          gc10: '',
          gc11: '',
          gc12: '',
          generatingcapacity: '',
        },
        form2: {
          gc01: '',
          gc02: '',
          gc03: '',
          gc04: '',
          gc05: '',
          gc06: '',
          gc07: '',
          gc08: '',
          gc09: '',
          gc10: '',
          gc11: '',
          gc12: '',
          generatingcapacity: '',
        },
        formLabelWidth: '200px',
        fcdialog:'',
        fc:'',
        xm:'',
        nf:'',
        modifyid:'',
        modifyprojectid:'',
        updateTime:'',
      }
    },
   
    created(){
        this.API.get('/powercompare/windfarmAllAjax').then((res) => {
            this.options = res.data;
        })
        var newData = new Date();
        this.updateTime = this.BASE.getBzDate(newData.getTime(), -1);
        this.callAndSpeedData();
    },
    methods:{
        queryApData() {
            this.callAndSpeedData();
        },
        handleEdit(a,b){
          this.wtId = b.windturbineid;
          console.log(this.wtId)
          this.$router.push({
          path:'/cutAndSpeedHistory',
          query:{
            wpId:this.value,
            wtId:this.wtId,
            beginDate:this.time,
            endDate:this.endDate,
          }
        })
        },
        tableDatawindturbineName(val){
          this.dialogFormVisible2 = true;
          this.fanData = val;
          console.log(this.fanData)
          var modifyData = new URLSearchParams();
          modifyData.append('projectid',this.fanData.projectid);
          modifyData.append('year',this.fanData.year);
          this.API.post('/projectplan/getSingleProjectPlan',modifyData).then((res) => {
                this.modifyid = res.data.id;
                this.modifyprojectid = res.data.projectid;
                this.fc = res.data.windpowerName;
                this.xm = res.data.projectName;
                this.nf = res.data.year;
                this.form2.gc01 = res.data.gc01;
                this.form2.gc02 = res.data.gc02;
                this.form2.gc03 = res.data.gc03;
                this.form2.gc04 = res.data.gc04;
                this.form2.gc05 = res.data.gc05;
                this.form2.gc06 = res.data.gc06;
                this.form2.gc07 = res.data.gc07;
                this.form2.gc08 = res.data.gc08;
                this.form2.gc09 = res.data.gc09;
                this.form2.gc10 = res.data.gc10;
                this.form2.gc11 = res.data.gc11;
                this.form2.gc12 = res.data.gc12;
                this.form2.generatingcapacity = res.data.generatingcapacity;
            })
        },
        saveData(){
            var addSaveData = new URLSearchParams();
            addSaveData.append('id',this.modifyid);
            addSaveData.append('projectid',this.modifyprojectid);
            addSaveData.append('generatingcapacity',this.form2.generatingcapacity);
            addSaveData.append('year',this.nf);
            addSaveData.append('gc01',this.form2.gc01);
            addSaveData.append('gc02',this.form2.gc02);
            addSaveData.append('gc03',this.form2.gc03);
            addSaveData.append('gc04',this.form2.gc04);
            addSaveData.append('gc05',this.form2.gc05);
            addSaveData.append('gc06',this.form2.gc06);
            addSaveData.append('gc07',this.form2.gc07);
            addSaveData.append('gc08',this.form2.gc08);
            addSaveData.append('gc09',this.form2.gc09);
            addSaveData.append('gc10',this.form2.gc10);
            addSaveData.append('gc11',this.form2.gc11);
            addSaveData.append('gc12',this.form2.gc12);
            this.API.post('/projectplan/saveData',addSaveData).then((res) => {
                console.log(res.data)
            })
            this.dialogFormVisible2 = false;
        },
        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.callAndSpeedData();
        },
        projectData(){
            this.API.get('/powercompare/projectAjax?wpIds=' + this.value).then((res) =>{
                this.options2 = res.data;
            })
        },
        projectData2(){
            this.API.get('/powercompare/projectAjax?wpIds=' + this.value3).then((res) =>{
                this.options3 = res.data;
            })
        },
        callAndSpeedData(){
            var plannedGenerationData = new URLSearchParams();
		  	plannedGenerationData.append('wpId',this.value);
		    plannedGenerationData.append('pjId',this.value2);
            if(this.timeyear == ''){
                this.timeyear = this.updateTime.substring(0,4);
            }
            plannedGenerationData.append('year',this.timeyear);
            this.API.post('/projectplan/getProjectPlanVo',plannedGenerationData).then((res) => {
                this.gridData = res.data
                console.log(this.gridData)
            })
        },
        modifyData(){
            

        },
        addSaveData(){
            console.log(this.value3)
            var addSaveData = new URLSearchParams();
            addSaveData.append('id',this.value3);
            addSaveData.append('projectid',this.value4);
            addSaveData.append('generatingcapacity',this.form.generatingcapacity);
            addSaveData.append('year',this.timeyear);
            addSaveData.append('gc01',this.form.gc01);
            addSaveData.append('gc02',this.form.gc02);
            addSaveData.append('gc03',this.form.gc03);
            addSaveData.append('gc04',this.form.gc04);
            addSaveData.append('gc05',this.form.gc05);
            addSaveData.append('gc06',this.form.gc06);
            addSaveData.append('gc07',this.form.gc07);
            addSaveData.append('gc08',this.form.gc08);
            addSaveData.append('gc09',this.form.gc09);
            addSaveData.append('gc10',this.form.gc10);
            addSaveData.append('gc11',this.form.gc11);
            addSaveData.append('gc12',this.form.gc12);
            this.API.post('/projectplan/saveData',addSaveData).then((res) => {
                console.log(res.data)
            })
            this.dialogFormVisible = false;
        },
        // modifyData(a,b,c){
        //     this.dialogFormVisible2 = true;
        //     console.log(a,b,c)
        // },
        toExcel(){
            excelHelper.exportExcel("callthepolicetable","负荷率排行榜",".xls",true);
        },
    }
}