export default {
    data(){
        return {
            formInline: {
                windfarm: "",
                project: "",
                line: "",
            },
            tjdiv:'',
            tableDataAll:[],
            fdjtable:[],
            clxtable:[],
            zktable:[],
            bjtable:[],
            wtid:'',
            textData:'',
            recorddate:'',
            qxpclChart:'',
            qxpclData:[],
            qxpcljzzData:[],
            xqxpcldata:[],
            fdlChart:[],
            clxChart:[],
            bjChart:[],
            zkChart:[],
            fdlData:[],
            clxData:[],
            bjData:[],
            zkData:[],
            xfdldata:[],
            xclxdata:[],
            xbjdata:[],
            xzkdata:[],
            //推荐检修风速
            windspeed:'',
            //结论
            conclusion:'',
            //高频
            highfrequency:'',
            //中频
            intermediatefrequency:'',
            //低频
            lowfrequency:'',
            //推荐工具器
            tools:'',
            //平均消缺时长
            mainhour:'',
            //推荐检修方法
            mainmethod:'',
            //推荐检修日期
            maindate:'',
            //报告出具时间
            bgcjdate:'',
            //风机
            wtName:'',
            //评级操作
            djpgjb:'',
            //推荐处理方法
            approach:'',
            // 推荐检修理由
            mainreason:'',
            //echart数值大小
            max:'',
            pdfTitle: '因子评价报告',
            pdfSelector: '单机性能分析',
            

        }
    },
    created(){
        this.getData();
        this.KeyparameterData();
    },
    methods:{
      // 导出pdf
      getPdf(name){
        this.Get_PDF.downloadPDF( document.querySelector('#pdfDom'),name)
      },
        headStyle() {
          return "text-align:center"
        },
        KeyparameterData(){
            this.fdjtable.push({name:'发电机轴A温度',edz:'76',yxfw:'0-95',qz:'0.035'});
            this.fdjtable.push({name:'发电机轴B温度',edz:'76',yxfw:'0-95',qz:'0.035'});
            this.fdjtable.push({name:'发电机U相绕组温度',edz:'120',yxfw:'0-150',qz:'0.038'});
            this.fdjtable.push({name:'发电机V相绕组温度',edz:'120',yxfw:'0-150',qz:'0.427'});
            this.fdjtable.push({name:'发电机W相绕组温度',edz:'120',yxfw:'0-150',qz:'0.465'});
            this.fdjtable.push({name:'发电机冷却风',edz:'56',yxfw:'0-70',qz:'0'});
            this.clxtable.push({name:'齿轮箱输入轴1油温',edz:'76',yxfw:'0-95',qz:'0.0114'});
            this.clxtable.push({name:'齿轮箱输入轴2油温',edz:'76',yxfw:'0-95',qz:'0.4537'});
            this.clxtable.push({name:'齿轮箱入口油温',edz:'64',yxfw:'0-80',qz:'0.0218'});
            this.clxtable.push({name:'齿轮箱油温',edz:'31',yxfw:'10-14-76-80',qz:'0.5131'});
            this.bjtable.push({name:'变浆电容器温度1',edz:'52',yxfw:'0-65',qz:'0.0069'});
            this.bjtable.push({name:'变浆电容器温度2',edz:'52',yxfw:'0-65',qz:'0.0069'});
            this.bjtable.push({name:'变浆电容器温度3',edz:'52',yxfw:'0-65',qz:'0.0069'});
            this.bjtable.push({name:'变浆电容电压1',edz:'58',yxfw:'53-56-60-63',qz:'0.2724'});
            this.bjtable.push({name:'变浆电容电压2',edz:'58',yxfw:'53-56-60-63',qz:'0.2724'});
            this.bjtable.push({name:'变浆电容电压3',edz:'58',yxfw:'53-56-60-63',qz:'0.2724'});
            this.bjtable.push({name:'变浆电流器温度1',edz:'60',yxfw:'0-75',qz:'0.0128'});
            this.bjtable.push({name:'变浆电流器温度2',edz:'60',yxfw:'0-75',qz:'0.0128'});
            this.bjtable.push({name:'变浆电流器温度3',edz:'60',yxfw:'0-75',qz:'0.0128'});
            this.bjtable.push({name:'电机温度1',edz:'110',yxfw:'0-135',qz:'0.0083'});
            this.bjtable.push({name:'电机温度2',edz:'110',yxfw:'0-135',qz:'0.0083'});
            this.bjtable.push({name:'电机温度3',edz:'110',yxfw:'0-135',qz:'0.0083'});
            this.bjtable.push({name:'变浆控制柜温度1',edz:'52',yxfw:'0-65',qz:'0.0033'});
            this.bjtable.push({name:'变浆控制柜温度2',edz:'52',yxfw:'0-65',qz:'0.0033'});
            this.bjtable.push({name:'变浆控制柜温度3',edz:'52',yxfw:'0-65',qz:'0.0033'});
            this.zktable.push({name:'塔底柜温度',edz:'40',yxfw:'0-50',qz:'0.75'});
            this.zktable.push({name:'塔顶机舱柜温度',edz:'60',yxfw:'0-75',qz:'0.25'});
            

        },
        changeTableSort(column){
          this.orderByColumn = column.prop;
          if(column.order == "descending"){
            this.isAsc = 'desc';
          }else if(column.order == "ascending"){
            this.isAsc = "asc";
          }
        }, 
        getData(){
            this.qxpclData = [];
            this.qxpcljzzData = [];
            this.fdlData = [];
            this.wtid = this.$route.query.wtid;
            this.recorddate = this.$route.query.recorddate;
            console.log(this.recorddate)
            var healthForm = new URLSearchParams();
            healthForm.append('wtId',this.wtid);
            healthForm.append('recorddate',this.recorddate);
            this.API.post('/report/healthReport',healthForm).then((res) =>{
                console.log(res.data)
                this.qxpclChart = res.data.sub;
                if(res.data.main.gztop3name == '健康指标未达到推荐级别，故不在推荐范围之内'){
                    this.tjdiv = false;
                }else{
                    this.tjdiv = true;
                }
                for(let i=0;i<this.qxpclChart.length;i++){
                    this.djpgjb = this.qxpclChart[0].djpgjb;
                    this.qxpclData.push(this.qxpclChart[i].qxpcl);
                    this.qxpcljzzData.push(this.qxpclChart[i].qxpcljzz);
                    let datechart = new Date(this.qxpclChart[i].recodedate);
                    this.xqxpcldata.push(this.BASE.getBzDate(datechart, 0));
                    this.$nextTick(function() {
                        this.getChartDataImport('chartHistogram')
                    })
                }
                this.conclusion = res.data.main.gztop3name;
                this.highfrequency = res.data.main.top1type;
                this.intermediatefrequency = res.data.main.top2type;
                this.lowfrequency = res.data.main.top3type;
                this.windspeed = res.data.main.speed;
                this.tools = res.data.main.tools;
                this.mainhour = res.data.main.mainhour;
                this.mainmethod = res.data.main.mainmethod;
                this.maindate = res.data.main.maindate;
                let date = new Date(this.maindate);
                this.maindate = this.BASE.getBzDate(date, 0);
                this.bgcjdate = res.data.main.recodedate;
                let datebg = new Date(this.bgcjdate);
                this.bgcjdate = this.BASE.getBzDate(datebg, 0);
                this.approach = res.data.main.approach;
                this.mainreason = res.data.main.mainreason;
            })
            var healthFormCharts = new URLSearchParams();
            healthFormCharts.append('wtId',this.wtid);
            healthFormCharts.append('partId','fdj');
            healthFormCharts.append('recorddate',this.recorddate);
            this.API.post('/report/healthReportChart',healthFormCharts).then((res) =>{
                this.fdlChart = res.data;
                for(let i=0;i<this.fdlChart.length;i++){
                    this.fdlData.push(this.fdlChart[i].value);
                    let datefdlchart = new Date(this.fdlChart[i].recorddate);
                    this.xfdldata.push(this.BASE.getBzDate(datefdlchart, 0));
                    this.$nextTick(function() {
                        this.getChartDataImport2('chartHistogram2')
                    })
                }
            })
            var gearboxCharts = new URLSearchParams();
            gearboxCharts.append('wtId',this.wtid);
            gearboxCharts.append('partId','clx');
            gearboxCharts.append('recorddate',this.recorddate);
            this.API.post('/report/healthReportChart',gearboxCharts).then((res) =>{
                this.clxChart = res.data;
                for(let i=0;i<this.clxChart.length;i++){
                    this.clxData.push(this.clxChart[i].value);
                    let dateclxchart = new Date(this.clxChart[i].recorddate);
                    this.xclxdata.push(this.BASE.getBzDate(dateclxchart, 0));
                    this.$nextTick(function() {
                        this.getChartDataImport3('chartHistogram3')
                    })
                }
            })
            var PitchCharts = new URLSearchParams();
            PitchCharts.append('wtId',this.wtid);
            PitchCharts.append('partId','bj');
            PitchCharts.append('recorddate',this.recorddate);
            this.API.post('/report/healthReportChart',PitchCharts).then((res) =>{
                this.bjChart = res.data;
                for(let i=0;i<this.bjChart.length;i++){
                    this.bjData.push(this.bjChart[i].value);
                    let datebjchart = new Date(this.bjChart[i].recorddate);
                    this.xbjdata.push(this.BASE.getBzDate(datebjchart, 0));
                    this.$nextTick(function() {
                        this.getChartDataImport4('chartHistogram4')
                    })
                }
            })
            var mastercontrolCharts = new URLSearchParams();
            mastercontrolCharts.append('wtId',this.wtid);
            mastercontrolCharts.append('partId','zk');
            mastercontrolCharts.append('recorddate',this.recorddate);
            this.API.post('/report/healthReportChart',mastercontrolCharts).then((res) =>{
                this.zkChart = res.data;
                console.log(this.zkChart)
                for(let i=0;i<this.zkChart.length;i++){
                    this.wtName = this.zkChart[0].wtname;
                    this.zkData.push(this.zkChart[i].value);
                    let datezkchart = new Date(this.zkChart[i].recorddate);
                    this.xzkdata.push(this.BASE.getBzDate(datezkchart, 0))
                    this.$nextTick(function() {
                        this.getChartDataImport5('chartHistogram5')
                    })
                }
            })
        },
        getChartDataImport(){
            this.ECLZX.getHealthCurve("chartHistogram",['曲线偏差率', '基准值'],
            this.xqxpcldata,this.qxpclData,this.qxpcljzzData);
        },
        getChartDataImport2(){
            this.max = 5;
            this.ECLZX.getHealthTrendChart("chartHistogram2",['发电量健康走势'],
            this.xfdldata,this.max,this.fdlData);
        },
         getChartDataImport3(){
            this.max = 1;
            this.ECLZX.getHealthTrendChart("chartHistogram3",['齿轮箱健康走势'],
            this.xclxdata,this.max,this.clxData);
        },
        getChartDataImport4(){
            this.max = 5;
            this.ECLZX.getHealthTrendChart("chartHistogram4",['变桨健康走势'],
            this.xbjdata,this.max,this.bjData);
        },
        getChartDataImport5(){
            this.max = 5;
            this.ECLZX.getHealthTrendChart("chartHistogram5",['主控健康走势'],
            this.xzkdata,this.max,this.zkData);
        },
        goReturn(){
            this.$router.push('/healthAssessment')
        },
    }
}