export default {
    data() {
        return {
            formInline: {
                windfarm: "",
                project: "",
                line: "",
            },
            tableData: [{
                date: '2016-05-02',
                name: '王小虎',
                address: '上海市普陀区金沙江路 1518 弄'
            }, {
                date: '2016-05-04',
                name: '王小虎',
                address: '上海市普陀区金沙江路 1517 弄'
            }, {
                date: '2016-05-01',
                name: '王小虎',
                address: '上海市普陀区金沙江路 1519 弄'
            }, {
                date: '2016-05-03',
                name: '王小虎',
                address: '上海市普陀区金沙江路 1516 弄'
            }],
            fdcLineData2: [],
            options: [{
                value: 'MHS_FDC',
                label: '麻黄山风电场'
            }, {
                value: 'NSS_FDC',
                label: '牛首山风电场'
            },
            {
                value: 'SBQ_FDC',
                label: '石板泉风电场'
            },
            {
                value: 'QS_FDC',
                label: '青山风电场'
            },
            {
                value: 'XS_FDC',
                label: '香山风电场'
            }],
            value: '',
            value2: '',
            valueAll: '',
            timedate: [],
            timedate2: [],
            multipleSelection: [],
            multipleSelection1: [],
            multipleSelection2: [],
            orderByColumn: '',
            isAsc: 'asc',
            fdcLineData: [],
            currentPage2: 1,
            pagesize: 10,
            tableSwitch: false,
            wpId: '',
            beginDate: '',
            beginDate2: '',
            endDate: '',
            endDate2: '',
            dialogTableVisible: false,
            sortInOrder: [],
            sortInOrderTop: [],
            fdcName1: '',
            fdcName2: '',
            sortInOrde2: [],
            getTableData: [],
        }
    },
    filters: {
        rounding(value) {
            return value.toFixed(2)
        }
    },
    created() {
        this.FiveLossTableData();
    },
    methods: {
        queryApData() {
            this.FiveLossTableData();
        },
        queryApDataMx() {
            this.dialogTableVisible = true;
            if (this.multipleSelection1.length + this.multipleSelection2.length == 2) {
                this.multipleSelection = this.multipleSelection1.concat(this.multipleSelection2);
            } else {
                this.$message.error("请选两个风场！");
                return;
            }
            console.log(this.multipleSelection)
            if (this.multipleSelection.length == 2) {
                this.fdcName1 = this.multipleSelection[0].wtName;
                this.fdcName2 = this.multipleSelection[1].wtName;
                this.sortInOrder.push(this.multipleSelection[0].fnlyl, this.multipleSelection[0].xqjsl,
                    this.multipleSelection[0].ztzhjsl, this.multipleSelection[0].fwjsl, this.multipleSelection[0].slssl,
                    this.multipleSelection[0].xnssl, this.multipleSelection[0].qfl, this.multipleSelection[0].jxssl,
                    this.multipleSelection[0].gzssl);
                this.sortInOrderTop.push(this.multipleSelection[1].fnlyl, this.multipleSelection[1].xqjsl,
                    this.multipleSelection[1].ztzhjsl, this.multipleSelection[1].fwjsl, this.multipleSelection[1].slssl,
                    this.multipleSelection[1].xnssl, this.multipleSelection[1].qfl, this.multipleSelection[1].jxssl,
                    this.multipleSelection[1].gzssl);
                for (let i = 0; i < this.multipleSelection.length; i++) {
                    this.sortInOrde2.push({
                        product: this.multipleSelection[i].wtName, '限电损失电量单位:万KWh': this.multipleSelection[i].xdss,
                        '故障损失电量单位:万KWh': this.multipleSelection[i].gzss, '检修损失电量单位:万KWh': this.multipleSelection[i].jxssl,
                        '性能损失电量单位:万KWh': this.multipleSelection[i].xnssl, '受累损失电量单位:万KWh': this.multipleSelection[i].slss
                    });
                }
                this.getTableData.push({ index: '发电量', data1: this.multipleSelection[0].scadafdl, data2: this.multipleSelection[1].scadafdl });
                this.getTableData.push({ index: '故障损失电量', data1: this.multipleSelection[0].gzss, data2: this.multipleSelection[1].gzss });
                this.getTableData.push({ index: '检修损失电量', data1: this.multipleSelection[0].jxssl, data2: this.multipleSelection[1].jxssl });
                this.getTableData.push({ index: '性能未达标损失电量', data1: this.multipleSelection[0].xnsslfraction, data2: this.multipleSelection[1].xnsslfraction });
                this.getTableData.push({ index: '受累损失电量', data1: this.multipleSelection[0].slss, data2: this.multipleSelection[1].slss });
                this.getTableData.push({ index: '风能利用率', data1: this.multipleSelection[0].fnlyl, data2: this.multipleSelection[1].fnlyl });
                this.getTableData.push({ index: '故障损失率', data1: this.multipleSelection[0].gzssl, data2: this.multipleSelection[1].gzssl });
                this.getTableData.push({ index: '检修损失率', data1: this.multipleSelection[0].jxssl, data2: this.multipleSelection[1].jxssl });
                this.getTableData.push({ index: '弃风率', data1: this.multipleSelection[0].qfl, data2: this.multipleSelection[1].qfl });
                this.getTableData.push({ index: '性能损失率', data1: this.multipleSelection[0].xnssl, data2: this.multipleSelection[1].xnssl });
                this.getTableData.push({ index: '受累损失率', data1: this.multipleSelection[0].slssl, data2: this.multipleSelection[1].slssl });
                this.getTableData.push({ index: '复位及时率', data1: this.multipleSelection[0].fwjsl, data2: this.multipleSelection[1].fwjsl });
                this.getTableData.push({ index: '消缺及时率', data1: this.multipleSelection[0].xqjsl, data2: this.multipleSelection[1].xqjsl });
                this.getTableData.push({ index: '状态转换率', data1: this.multipleSelection[0].ztzhjsl, data2: this.multipleSelection[1].ztzhjsl });
            }
            this.$nextTick(function () {
                this.drawPie('leiDaTu3')
            })
            this.$nextTick(function () {
                this.drawPie2('leiDaTu4')
            })
        },
        FiveLossTableData() {
            this.API.get('/powercompare/windfarmAjax').then((res) => {
                this.options = res.data;
            })
            this.wpId = this.$route.query.wpId;
            if (this.value == '') {
                if (this.wpId.length == 2) {
                    this.tableSwitch = true;
                    this.value = this.wpId[0];
                    this.value2 = this.wpId[1];
                    this.FiveLossTableDataTable1();
                } else {
                    this.value = this.wpId;
                    this.FiveLossTableDataTable1();
                }
            } else {
                this.FiveLossTableDataTable1();
            }
        },
        FiveLossTableDataTable1() {
            if (this.timedate == '') {
                this.timedate[0] = this.$route.query.beginDate;
                this.timedate[1] = this.$route.query.endDate;
                this.beginDate = this.$route.query.beginDate;
                this.endDate = this.$route.query.endDate;
            } else {
                this.beginDate = this.timedate[0];
                this.endDate = this.timedate[1];
            }
            var fiveLossLineDatatable1 = new URLSearchParams();
            fiveLossLineDatatable1.append('pageNum', this.currentPage2);
            fiveLossLineDatatable1.append('pageSize', this.pagesize);
            fiveLossLineDatatable1.append('orderByColumn', this.orderByColumn);
            fiveLossLineDatatable1.append('isAsc', this.isAsc);
            fiveLossLineDatatable1.append('wpId', this.value);
            fiveLossLineDatatable1.append('beginDate', this.beginDate);
            fiveLossLineDatatable1.append('endDate', this.endDate);
            this.API.post('/contrast/benchmarkWtList', fiveLossLineDatatable1).then((res) => {
                this.fdcLineData = res.data;
            })
            this.FiveLossTableDataTable2();
        },
        FiveLossTableDataTable2() {
            if (this.timedate == '') {
                this.beginDate = this.$route.query.beginDate;
                this.endDate = this.$route.query.endDate;
            } else {
                this.beginDate = this.timedate[0];
                this.endDate = this.timedate[1];
            }
            console.log(this.value2.length)
            if (this.value2.length > 0) {
                this.tableSwitch = true;
            } else {
                this.tableSwitch = false;
            }
            var fiveLossLineDatatable2 = new URLSearchParams();
            fiveLossLineDatatable2.append('pageNum', this.currentPage2);
            fiveLossLineDatatable2.append('pageSize', this.pagesize);
            fiveLossLineDatatable2.append('orderByColumn', this.orderByColumn);
            fiveLossLineDatatable2.append('isAsc', this.isAsc);
            fiveLossLineDatatable2.append('wpId', this.value2);
            fiveLossLineDatatable2.append('beginDate', this.beginDate);
            fiveLossLineDatatable2.append('endDate', this.endDate);
            this.API.post('/contrast/benchmarkWtList', fiveLossLineDatatable2).then((res) => {
                this.fdcLineData2 = res.data;
            })
        },
        headStyle() {
            return "text-align:center"
        },
        handleSelectionChange(val) {
            this.sortInOrder = [];
            this.sortInOrderTop = [];
            this.getTableData = [];
            this.sortInOrde2 = [];
            this.multipleSelection1 = [];
            this.multipleSelection1 = val;
        },
        handleSelectionChange2(val) {
            this.sortInOrder = [];
            this.sortInOrderTop = [];
            this.getTableData = [];
            this.sortInOrde2 = [];
            this.multipleSelection2 = [];
            this.multipleSelection2 = val;
        },
        changeTableSort(column) {
            this.orderByColumn = column.prop;
            if (column.order == "descending") {
                this.isAsc = 'desc';
            } else if (column.order == "ascending") {
                this.isAsc = "asc";
            }
            this.FiveLossTableData();
        },
        drawPie() {
            this.ECLZX.getFiveLossRadarMap("leiDaTu3",[
                {
                    value: this.sortInOrder,
                    name: this.fdcName1
                },
                {
                    value: this.sortInOrderTop,
                    name: this.fdcName2
                }
            ]);
        },
        drawPie2() {
            this.ECLZX.getFiveLossRadarHistogram("leiDaTu4",['product', '限电损失电量单位:万KWh', '故障损失电量单位:万KWh', '检修损失电量单位:万KWh', '性能损失电量单位:万KWh', '受累损失电量单位:万KWh'],this.sortInOrde2);
        },
        goReturn() {
            this.$router.push('/fiveLossRates')
        },
        toExcel() { }
    }

}