// import {formatDate} from '../../utils/fomatDate';
export default {
    data() {
        return {
            pdfTitle: '因子评价报告',
            pdfSelector: '单机性能分析',
            formInline: {
                windfarm: "",
                project: "",
                line: "",
            },
            title: '',
            year: '',
            month: '',
            getData: [],
            tableDataAll: [],
            text1: '',
            sbxxs: '',
            tbsbxxs: '',
            tbsbklly: '',
            sbklly: '',
            dxkyxs: '',
            tbdxkyxs: '',
            jfpl: '',
            tbjfpl: '',
            gltxyzx: '',
            tbglyzxxs: '',
            text2: '',
            fdlChart: '',
            wsChart: '',
            date: [],
            date2: [],
            date3: [],
            xdData: [],
            xnwdbData: [],
            jxssData: [],
            gzssData: [],
            fdldata: [],
            fsdata: [],
            jdChart: [],
            jfData: [],
            djData: [],
            slssData: [],
            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 弄'
            }]

        }
    },
    filters: {
        //方法一: yyyy-MM-dd hh:mm

    },
    created() {
        this.performance();
        this.$nextTick(function () {
            this.getChartDataImport('chartHistogram')
        })
    },
    methods: {
        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();
        },
        performance() {
            this.tableDataAll = [];
            this.getData = this.$route.query.data;
            this.year = this.$route.query.timeyear;
            this.month = this.$route.query.timemonth;
            this.title = this.getData.windturbineName + this.year + '年' + this.month + '月运行指标性能分析';
            var performance = new URLSearchParams();
            performance.append('wtId', this.getData.windturbineid);
            performance.append('year', this.year);
            performance.append('month', this.month);
            this.API.post('/singleanalysis/singleanalysisSub', performance).then((res) => {
                console.log(res)
                this.tableData = res.data;
                this.tableDataAll.push({ name: '实际发电量（万千瓦时）', byz: this.tableData.byzb.fdl, qntq: this.tableData.tqzb.fdl, tbzzl: this.tableData.tbzb.fdl, hb: this.tableData.hqzb.fdl, hq: this.tableData.hbzb.fdl });
                this.tableDataAll.push({ name: '理论发电量（万千瓦时）', byz: this.tableData.byzb.llfdl, qntq: this.tableData.tqzb.llfdl, tbzzl: this.tableData.tbzb.llfdl, hb: this.tableData.hqzb.llfdl, hq: this.tableData.hbzb.llfdl });
                this.tableDataAll.push({ name: '设备利用小时（小时）', byz: this.tableData.byzb.lyxs, qntq: this.tableData.tqzb.lyxs, tbzzl: this.tableData.tbzb.lyxs, hb: this.tableData.hqzb.lyxs, hq: this.tableData.hbzb.lyxs });
                this.tableDataAll.push({ name: '设备利用率（%）', byz: this.tableData.byzb.sbklyl, qntq: this.tableData.tqzb.sbklyl, tbzzl: this.tableData.tbzb.sbklyl, hb: this.tableData.hqzb.sbklyl, hq: this.tableData.hbzb.sbklyl });
                this.tableDataAll.push({ name: '等效可用系数（%）', byz: this.tableData.byzb.dxklyxs, qntq: this.tableData.tqzb.dxklyxs, tbzzl: this.tableData.tbzb.dxklyxs, hb: this.tableData.hqzb.dxklyxs, hq: this.tableData.hbzb.dxklyxs });
                this.tableDataAll.push({ name: '平均风速（m/s）', byz: this.tableData.byzb.fs, qntq: this.tableData.tqzb.fs, tbzzl: this.tableData.tbzb.fs, hb: this.tableData.hqzb.fs, hq: this.tableData.hbzb.fs });
                this.tableDataAll.push({ name: '小风切入风速（m/s）', byz: this.tableData.byzb.xfqr, qntq: this.tableData.tqzb.xfqr, tbzzl: this.tableData.tbzb.xfqr, hb: this.tableData.hqzb.xfqr, hq: this.tableData.hbzb.xfqr });
                this.tableDataAll.push({ name: '小风切入合格率（%）', byz: this.tableData.byzb.xfqrhgl, qntq: this.tableData.tqzb.xfqrhgl, tbzzl: this.tableData.tbzb.xfqrhgl, hb: this.tableData.hqzb.xfqrhgl, hq: this.tableData.hbzb.xfqrhgl });
                this.tableDataAll.push({ name: '有效风时数（小时）', byz: this.tableData.byzb.yxfss, qntq: this.tableData.tqzb.yxfss, tbzzl: this.tableData.tbzb.yxfss, hb: this.tableData.hqzb.yxfss, hq: this.tableData.hbzb.yxfss });
                this.tableDataAll.push({ name: '故障损失电量（万千瓦时）', byz: this.tableData.byzb.gzss, qntq: this.tableData.tqzb.gzss, tbzzl: this.tableData.tbzb.gzss, hb: this.tableData.hqzb.gzss, hq: this.tableData.hbzb.gzss });
                this.tableDataAll.push({ name: '调度限电损失电量（万千瓦时）', byz: this.tableData.byzb.xdss, qntq: this.tableData.tqzb.xdss, tbzzl: this.tableData.tbzb.xdss, hb: this.tableData.hqzb.xdss, hq: this.tableData.hbzb.xdss });
                this.tableDataAll.push({ name: '计划检修损失电量（万千瓦时）', byz: this.tableData.byzb.jxss, qntq: this.tableData.tqzb.jxss, tbzzl: this.tableData.tbzb.jxss, hb: this.tableData.hqzb.jxss, hq: this.tableData.hbzb.jxss });
                this.tableDataAll.push({ name: '性能未达标损失电量（万千瓦时）', byz: this.tableData.byzb.xnss, qntq: this.tableData.tqzb.xnss, tbzzl: this.tableData.tbzb.xnss, hb: this.tableData.hqzb.xnss, hq: this.tableData.hbzb.xnss });
                this.tableDataAll.push({ name: '故障停运时间（小时）', byz: this.tableData.byzb.gzxs, qntq: this.tableData.tqzb.gzxs, tbzzl: this.tableData.tbzb.gzxs, hb: this.tableData.hqzb.gzxs, hq: this.tableData.hbzb.gzxs });
                this.tableDataAll.push({ name: '检修停运时间（小时）', byz: this.tableData.byzb.jxxs, qntq: this.tableData.tqzb.jxxs, tbzzl: this.tableData.tbzb.jxxs, hb: this.tableData.hqzb.jxxs, hq: this.tableData.hbzb.jxxs });
                this.tableDataAll.push({ name: '并网时间（小时）', byz: this.tableData.byzb.rlxs, qntq: this.tableData.tqzb.rlxs, tbzzl: this.tableData.tbzb.rlxs, hb: this.tableData.hqzb.rlxs, hq: this.tableData.hbzb.rlxs });
                this.tableDataAll.push({ name: '待机时间（小时）', byz: this.tableData.byzb.tjxs, qntq: this.tableData.tqzb.tjxs, tbzzl: this.tableData.tbzb.tjxs, hb: this.tableData.hqzb.tjxs, hq: this.tableData.hbzb.tjxs });
                this.tableDataAll.push({ name: '通讯中断时间（小时）', byz: this.tableData.byzb.zdxs, qntq: this.tableData.tqzb.zdxs, tbzzl: this.tableData.tbzb.zdxs, hb: this.tableData.hqzb.zdxs, hq: this.tableData.hbzb.zdxs });
                this.tableDataAll.push({ name: '功率特性一致性系数（%）', byz: this.tableData.byzb.glyzxxs, qntq: this.tableData.tqzb.glyzxxs, tbzzl: this.tableData.tbzb.glyzxxs, hb: this.tableData.hqzb.glyzxxs, hq: this.tableData.hbzb.glyzxxs });
                this.tableDataAll.push({ name: '静风频率（%）', byz: this.tableData.byzb.jfpl, qntq: this.tableData.tqzb.jfpl, tbzzl: this.tableData.tbzb.jfpl, hb: this.tableData.hqzb.jfpl, hq: this.tableData.hbzb.jfpl });
                this.text1 = this.tableData.byzb.windturbineName;
                this.sbxxs = this.tableData.byzb.lyxs;
                this.tbsbxxs = this.tableData.tqzb.lyxs;
                this.sbklly = this.tableData.byzb.sbklyl;
                this.tbsbklly = this.tableData.tqzb.sbklyl;
                this.dxkyxs = this.tableData.byzb.dxklyxs;
                this.tbdxkyxs = this.tableData.tqzb.dxklyxs;
                this.jfpl = this.tableData.byzb.jfpl;
                this.tbjfpl = this.tableData.tqzb.jfpl;
                this.gltxyzx = this.tableData.byzb.glyzxxs;
                this.tbglyzxxs = this.tableData.tqzb.glyzxxs;
                this.text2 = this.tableData.byzb.windturbineName + this.year + '年' + this.month + '月平均风速' + this.tableData.byzb.fs + 'm/s、同比' +
                    this.tableData.tqzb.fs + 'm/s，有效风时数' + this.tableData.byzb.yxfss + '小时、同比' + this.tableData.tqzb.yxfss + '小时，实际发电电量' +
                    this.tableData.byzb.fdl + '万kwh、同比' + this.tableData.tqzb.fdl + '万kwh，同比增长率' + this.tableData.tbzb.fdl + '%，各项损失电量累计' +
                    this.tableData.byzb.xnss + '万kwh、同比' + this.tableData.tqzb.xnss + '万kwh，同比增长率' + this.tableData.tbzb.xnss + '%，理论发电量' +
                    this.tableData.byzb.llfdl + '万kwh、实际发电量与理论发电量相差' + this.tableData.tbzb.llfdl + '万kwh';
            })
            this.API.post('/singleanalysis/singleanalysisChart', performance).then((res) => {
                this.fdlChart = res.data.ff;
                for (let i = 0; i < this.fdlChart.length; i++) {
                    let date = this.BASE.getBzDate(new Date(this.fdlChart[i].recorddate),0);
                    this.date.push(date);
                    this.fdldata.push(this.fdlChart[i].fdl);
                    this.fsdata.push(this.fdlChart[i].fs);
                    this.$nextTick(function () {
                        this.getChartDataImport('chartHistogram')
                    })
                }
                this.wsChart = res.data.ws;
                console.log(this.wsChart)
                for (let i = 0; i < this.wsChart.length; i++) {
                    let wsdate = this.BASE.getBzDate(new Date(this.wsChart[i].recorddate),0);
                    this.date2.push(wsdate);
                    this.xdData.push(this.wsChart[i].xdss);
                    this.xnwdbData.push(this.wsChart[i].xnss);
                    this.jxssData.push(this.wsChart[i].jxss);
                    this.gzssData.push(this.wsChart[i].gzss);
                    this.slssData.push(this.wsChart[i].slss);
                    this.$nextTick(function () {
                        this.getLossChartDataImport('losschartHistogram')
                    })
                }
                this.jdChart = res.data.jd;
                // console.log(this.jdChart)
                for (let i = 0; i < this.jdChart.length; i++) {
                    let jddata = this.BASE.getBzDate(new Date(this.jdChart[i].recorddate),0);
                    this.date3.push(jddata);
                    this.jfData.push(this.jdChart[i].jfpl);
                    this.djData.push(this.jdChart[i].tjxs);
                    this.$nextTick(function () {
                        this.getWindChartDataImport('windchartHistogram')
                    })
                }
            })

        },
        getChartDataImport() {
            this.ECLZX.getSingleMachineAnalysisOperationChart("chartHistogram",
            this.fdldata,['发电量(万千瓦时)', '风速(m/s)'],this.date,this.fsdata);
        },
        getLossChartDataImport() {
            this.ECLZX.getSingleMachineAnalysisOperationChart2("losschartHistogram",
            ['限电损失电量(万千瓦时)', '性能未达标损失电量(万千瓦时)', '检修损失电量(万千瓦时)', '故障损失电量(万千瓦时)', '受累损失电量(万千瓦时)'],
            this.date2,this.xdData,this.xnwdbData,this.jxssData,this.gzssData,this.slssData);
        },
        getWindChartDataImport() {
            this.ECLZX.getSingleMachineAnalysisOperationChart3("windchartHistogram",
            ['静风频率（小时）', '待机时间（小时）'],this.date3,this.jfData,this.djData);
        },
        goReturn() {
            this.$router.push('/singleMachineAnalysis')
        },
    }
}