// import excelHelper from "@/utils/excelHelper";
export default {
    data() {
        return {
            formInline: {
                windfarm: "",
                project: "",
                line: "",
            },
            timedate: [],
            currentPage2: 1,
            pagesize: 10,
            gridData: [],
            options: [{
                value: 'fc',
                label: '风场'
            }, {
                value: 'gf',
                label: '光伏'
            }],
            options2: [],
            orderByColumn: '',
            isAsc: '',
            value: '风场',
            value2: 'MHS_FDC',
            updateTime: '',
            updateTime1: '',
        }
    },
    filters: {
        rounding(value) {
            return value.toFixed(2)
        }
    },
    created() {
        this.API.get('/powercompare/windfarmAjax').then((res) => {
            this.options2 = res.data;
        })
        this.loadRateData();
    },
    methods: {
        queryApData() {
            this.loadRateData();
        },

        headStyle() {
            return "text-align:center"
        },
        formatDatebeginDate(time) {
            let dateks = new Date(time.beginDate);
            return this.BASE.getBzDate(dateks, 0);
        },
        formatDateendDate(time) {
            let datejz = new Date(time.endDate);
            return this.BASE.getBzDate(datejz, 0);
        },
        changeTableSort(column) {
            this.orderByColumn = column.prop;
            if (column.order == "descending") {
                this.isAsc = 'desc';
            } else if (column.order == "ascending") {
                this.isAsc = "asc";
            }
            this.loadRateData();
        },
        loadRateData() {
            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 loadRateData = new URLSearchParams();
            loadRateData.append('pageNum', this.currentPage2);
            loadRateData.append('pageSize', this.pagesize);
            loadRateData.append('orderByColumn', this.orderByColumn);
            loadRateData.append('isAsc', this.isAsc);
            loadRateData.append('wpId', this.value2);
            loadRateData.append('beginDate', this.beginDate);
            loadRateData.append('endDate', this.endDate);
            this.API.post('/leaderboard/loadfactortoplist', loadRateData).then((res) => {
                this.gridData = res.data;
            })
        },
        toExcel() {
            excelHelper.exportExcel("loadratetable", "曲线偏差率排行榜", ".xls", true);
        }
    }
}