// import {formatDate} from '../../utils/fomatDate';
export default {
    data(){
        return {
            pdfTitle: '因子评价报告',
            pdfSelector: '单机性能分析',
            formInline: {
                windfarm: "",
                project: "",
                line: "",
            },
            value:'',
            value2:'',
            options:[],
            options2:[],
            time:'',
            fanData:'',
            tableData: [],
            timedate: [
            // {beginDate:'2021-01-01'},
            // {endDate:'2021-01-04'}
            ],
            beginDate:'',
            endDate:'',
            updateTime:'',
            updateTime1:'',
            recodedate:'',
            
        }
    },
    filters: {　
        rounding (value) {
            return value.toFixed(2)
        } 
    },
    created(){
        this.API.get('/powercompare/windfarmAjax').then((res) => {
            this.options = res.data;
        })
        this.getHealthForm();
    },
    methods:{
        queryApData() {
             this.getHealthForm();
        },
        formatDate(time) {
            let date = new Date(time.recodedate);
            return this.BASE.getBzDate(date, 0);
        },
        handleEdit(a,b){
          let date = new Date(b.recodedate);
          this.recodedate = this.BASE.getBzDate(date, 0);
          this.$router.push({
            path:'/healthAssessmentDetailed',
            query:{
              wtid:b.wtid,
              recorddate: this.recodedate,
            }
          })
        },
        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.performance();
        },
        getFCData(){
            this.API.get('/powercompare/windturbineAjax?wpId=' + this.value).then((res) => {
                this.options2 = res.data;
            })
        },
        getHealthForm(){
            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 healthForm = new URLSearchParams();
            healthForm.append('wtId',this.value2);
            healthForm.append('beginDate',this.beginDate);
            healthForm.append('endDate',this.endDate);
            this.API.post('/report/getReportList',healthForm).then((res) =>{
                console.log(res)
                if(res.data == ''){

                }else{
                    this.tableData.push(res.data[0])
                    console.log(this.tableData)
                }
            })
        },
    }
}