var lineIndex = window.parent.document.getElementById("lineIndex").value; var allstime = window.parent.document.getElementById("allstime").value; var alletime = window.parent.document.getElementById("alletime").value; var checkpieces = window.parent.document.getElementById("checkpieces").value; var checkpiecee = window.parent.document.getElementById("checkpiecee").value; var allstartTime,allendTime; var tltName; $(document).ready(function (){ if(lineIndex==null || lineIndex == ""){ return; } $(".form-control[disabled], fieldset[disabled] .form-control").removeAttr("disabled"); createTime(); }) var dateSilderObj; //创建时间横轴提供用户选择时间节点 //月份定义 var Months = ["1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"]; function createTime(){ $.ajax({ type:'post', async : false, url:'/pqs9000/device/getSETime', data:{ lineIndex:lineIndex }, success:function(data){ if(data.code === 500){ layer.msg(data.message, { icon : 2, time : 2000 }, function() { $("#point").attr("style","display:true;"); $("#main").attr("style","display:none;"); }); }else{ $("#main").attr("style","display:true;"); $(".container-fluid").attr("style","display:true;"); $("#point").attr("style","display:none;"); var Sliderwidth = $("body").width()-436; $("#container0").css("width", Sliderwidth); var times = data.body; var timeseries = []; if(times.length>1){ for(var i = 0;i").appendTo($("#dateSlider"));//渲染日期组件 var step = 100/((allendTime-allstartTime)/(24*60*60*1000)); dateSilderObj=date.dateRangeSlider({ arrows:false,//是否显示左右箭头 bounds: {min: new Date(allstartTime), max: new Date(allendTime)},//最大 最少日期 defaultValues: {min: new Date(astime), max: new Date(aetime)}//默认选中区域 ,scales:[{ first: function(value){return value; }, end: function(value) {return value; }, next: function(val){ var next = new Date(val); return new Date(next.setMonth(next.getMonth() + 1)); }, label: function(val){ return Months[val.getMonth()]; }, format: function(tickContainer, tickStart, tickEnd){ tickContainer.addClass("myCustomClass"); } }] });//日期控件 //重新赋值(整个时间轴) dateSilderObj.dateRangeSlider("bounds", new Date(allstartTime), new Date(allendTime)); laydate.render({ elem: '#startTime' ,min: timestampToTime(allstartTime) ,max: timestampToTime(allendTime) ,type: 'datetime' ,done: function(value, date, endDate){ var chas = new Date(value); var chae = new Date($('#endTime').val()); dateSilderObj.dateRangeSlider("values", chas,chae); } }); laydate.render({ elem: '#endTime' ,min: timestampToTime(allstartTime) ,max: timestampToTime(allendTime) ,type: 'datetime' ,done: function(value, date, endDate){ var chae = new Date(value); var chas = new Date($('#startTime').val()); dateSilderObj.dateRangeSlider("values", chas,chae); } }); //重新赋值(选中区域) dateSilderObj.dateRangeSlider("values", new Date(astime), new Date(aetime)); $("#startTime").val(timestampToTime(astime)); $("#endTime").val(timestampToTime(aetime)); var startdate = new Date(allstartTime);// 时间戳为10位需*1000,时间戳为13位的话不需乘1000 var enddate = new Date(allendTime);// 时间戳为10位需*1000,时间戳为13位的话不需乘1000 //拖动完毕后的事件 dateSilderObj.bind("valuesChanged", function(e, data){ var val=data.values; var min = val.min.getTime(); var max = val.max.getTime(); var stime=val.min.getFullYear()+"-"+change(val.min.getMonth()+1)+"-"+change(val.min.getDate())+' '+change(val.min.getHours())+':'+ change(val.min.getMinutes())+':'+change(val.min.getSeconds()); var etime=val.max.getFullYear()+"-"+change(val.max.getMonth()+1)+"-"+change(val.max.getDate())+' '+change(val.max.getHours())+':'+ change(val.max.getMinutes())+':'+change(val.max.getSeconds()); $("#startTime").val(stime); $("#endTime").val(etime); window.parent.document.getElementById("allstime").value=min; window.parent.document.getElementById("alletime").value=max; }); } function timestampToTime(timestamp) { var date = new Date(timestamp);// 时间戳为10位需*1000,时间戳为13位的话不需乘1000 var Y = date.getFullYear() + '-'; var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date .getMonth() + 1) + '-'; var D = change(date.getDate()); var H = change(date.getHours()); var m = change(date.getMinutes()); var S = change(date.getSeconds()); return Y + M + D + ' ' + H + ':' + m + ':' + S; } function change(t) { if (t < 10) { return "0" + t; } else { return t; } } /** * 获取选中的监测点信息 */ var num=1; var idea; var height=$(window).height()-180; $("#interval").val("周"); var Uarry = $("#qualifiedTab li");//获取所有的li元素 $("#qualifiedTab li").click(function () {//点击事件 //测试直接获取值 var v=$(this).text(); alert(v); var count = $(this).index();//获取li的下标 var Tresult = Uarry.eq(count).text(); tltName = Tresult; queryData(tltName); }) $("#query").click(function () { queryData(tltName); }) //谐波电压含有率 function getXbDy(startTime,endTime,lineId) { var type = '1'; $.ajax({ type : 'POST', async: false, url : '/pqs9000/device/getHarmonic', data : { startTime:startTime, endTime:endTime, lineId:lineId, type:type }, beforeSend: function () { idea = ityzl_SHOW_LOAD_LAYER(); }, error:function(data) { layer.msg("暂无历史谐波含有率", { icon : 5, time : 3000 }) // ***********关闭loading ityzl_CLOSE_LOAD_LAYER(idea); }, success : function(data) { var serName=[]; var gb=[]; var number=[]; //没有权限的请求 if(data==300){ location.href='/pqs9000/auth/unauthorized'; //没有登陆的请求 }else if(data==301){ location.href='/pqs9000'; }else { if (data.code == 500) { parent.layer.msg("没有获取到该监测点的谐波电压含有率", { icon : 5, time : 3000 }); $('#example').text("") var oTable = $('#example').DataTable({ info:false, paging:false, ScrollY:height*0.3, lengthChange: false, columns: [ {"width": "122px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"} ], bDestroy: true, ordering: false, autoWidth:true, scrollX:false, data: data.body, destroy: true, language: { url: '/pqs9000/json/chine.json', "sEmptyTable": "没有内容" }, }) for(i=1;i<50;i++){ serName.push([parseFloat(null)]); gb.push([parseFloat(null)]); number.push([i+1]) } $("#container").css("height",height*0.6); //画图 var chart = Highcharts.chart('container', { credits: { enabled: false }, chart: { type: 'column' }, title: { text: '' }, xAxis: { categories: number }, yAxis: [{ min: 0, title: { text: '谐波电压含有率(%)' } }, { title: { text: '国标限值(%)' }, opposite: true }], legend: { shadow: false }, tooltip: { shared: true, formatter:function () { var x,y1,y2; if(this.points.length==1){ x="谐波次数:"+this.points[0].x y2=this.points[0].series.name+":"+this.points[0].y+"%" return x+'
'+y2; }else{ x="谐波次数:"+this.points[0].x y1="国标限值(%):"+this.points[0].y+"%" y2="谐波电压含有率(%):"+this.points[1].y+"%" return x+'
'+y1+'
'+y2; } } }, plotOptions: { column: { grouping: false, shadow: false, borderWidth: 0 } }, series: [{ name: '谐波电压含有率(%)', color: yellow, data: gb, tooltip: { valueSuffix: '%' }, pointPadding: 0.3, pointPlacement: -0.2 }, { name: '国标限值(%)', color: green, data: serName, tooltip: { valueSuffix: '%' }, pointPadding: 0.4, // 通过 pointPadding 和 pointPlacement 控制柱子位置 pointPlacement: -0.2 }] }); } else { var oTable = $('#example').DataTable({ info:false, paging:false, scrollY:false, lengthChange: false, // columnDefs: [ { width: "122px", "targets": 0 } ], columns: [ {"width": "122px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"} ], ordering: false, // autoWidth:true, scrollX: true, data: data.body, destroy: true, language: { url: '/pqs9000/json/chine.json', "sEmptyTable": "没有内容" }, }) for(i=1;i<50;i++){ serName.push([parseFloat(data.body[0][i])]); gb.push([parseFloat(data.body[1][i])]); number.push([i+1]) } $("#container").css("height",height*0.8); //画图 var chart = Highcharts.chart('container', { credits: { enabled: false }, chart: { type: 'column' }, title: { text: '' }, xAxis: { categories: number, }, yAxis: [{ min: 0, title: { text: data.body[0][0] } }, { title: { text: data.body[1][0] }, opposite: true }], legend: { shadow: false }, tooltip: { shared: true, formatter:function () { var x,y1,y2; if(this.points.length==1){ x="谐波次数:"+this.points[0].x y2=this.points[0].series.name+":"+this.points[0].y+"%" return x+'
'+y2; }else{ x="谐波次数:"+this.points[0].x y1="国标限值(%):"+this.points[0].y+"%" y2="谐波电压含有率(%):"+this.points[1].y+"%" return x+'
'+y1+'
'+y2; } } }, plotOptions: { column: { grouping: false, shadow: false, borderWidth: 0 } }, series: [{ name: data.body[1][0], color: yellow, data: gb, tooltip: { valueSuffix: '%' }, pointPadding: 0.3, pointPlacement: -0.2 }, { name: data.body[0][0], color: green, data: serName, tooltip: { valueSuffix: '%' }, pointPadding: 0.4, // 通过 pointPadding 和 pointPlacement 控制柱子位置 pointPlacement: -0.2 }] }); } } // ***********关闭loading ityzl_CLOSE_LOAD_LAYER(idea); } }) } //谐波电流幅值 function getXbDl(startTime,endTime,lineId) { var type = '1'; $.ajax({ type : 'POST', async: false, url : '/pqs9000/device/getHarmI', data : { startTime:startTime, endTime:endTime, lineId:lineId, type:type }, beforeSend: function () { idea = ityzl_SHOW_LOAD_LAYER(); }, error:function(data) { layer.msg("暂无历史谐波电流幅值", { icon : 5, time : 3000 }) // ***********关闭loading ityzl_CLOSE_LOAD_LAYER(idea); }, success : function(data) { var serName=[]; var gb=[]; var number=[]; //没有权限的请求 if(data==300){ location.href='/pqs9000/auth/unauthorized'; //没有登陆的请求 }else if(data==301){ location.href='/pqs9000'; }else { if (data.code == 500) { parent.layer.msg("没有获取到该监测点的谐波电流幅值", { icon : 5, time : 3000 }); $('#example').text("") var oTable = $('#example').DataTable({ info:false, paging:false, lengthChange: false, columns: [ {"width": "122px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"} ], bDestroy: true, ordering: false, autoWidth:true, scrollX:false, data: data.body, destroy: true, language: { url: '/pqs9000/json/chine.json', "sEmptyTable": "没有内容" }, }) for(i=1;i<50;i++){ serName.push([parseFloat(null)]); gb.push([parseFloat(null)]); number.push([i+1]) } $("#container").css("height",parent.picHeight*0.6); //画图 var chart = Highcharts.chart('container', { credits: { enabled: false }, chart: { type: 'column' }, title: { text: '' }, xAxis: { categories: number }, yAxis: [{ min: 0, title: { text: '谐波电流幅值(A)' } }, { title: { text: '国标限值(A)' }, opposite: true }], legend: { shadow: false }, tooltip: { shared: true, formatter:function () { var x,y1,y2; if(this.points.length==1){ x="谐波次数:"+this.points[0].x y2=this.points[0].series.name+":"+this.points[0].y+"A" return x+'
'+y2; }else{ x="谐波次数:"+this.points[0].x y1="国标限值(A):"+this.points[0].y+"A" y2="谐波电流幅值(A):"+this.points[1].y+"A" return x+'
'+y1+'
'+y2; } } }, plotOptions: { column: { grouping: false, shadow: false, borderWidth: 0 } }, series: [{ name: '谐波电流幅值(A)', color: yellow, data: gb, tooltip: { valueSuffix: 'A' }, pointPadding: 0.3, pointPlacement: -0.2 }, { name: '国标限值(A)', color: green, data: serName, tooltip: { valueSuffix: 'A' }, pointPadding: 0.4, // 通过 pointPadding 和 pointPlacement 控制柱子位置 pointPlacement: -0.2 }] }); } else { var oTable = $('#example').DataTable({ info:false, paging:false, scrollY:false, lengthChange: false, // columnDefs: [ { width: "122px", "targets": 0 } ], columns: [ {"width": "122px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"}, {"width": "41px"} ], ordering: false, // autoWidth:true, scrollX: true, data: data.body, destroy: true, language: { url: '/pqs9000/json/chine.json', "sEmptyTable": "没有内容" }, }) for(i=1;i<50;i++){ serName.push([parseFloat(data.body[0][i])]); gb.push([parseFloat(data.body[1][i])]); number.push([i+1]) } $("#container").css("height",height*0.6); //画图 var chart = Highcharts.chart('container', { credits: { enabled: false }, chart: { type: 'column' }, title: { text: '' }, xAxis: { categories: number, }, yAxis: [{ min: 0, title: { text: '谐波电流幅值(A)' } }, { title: { text: '国标限值(A)' }, opposite: true }], legend: { shadow: false }, tooltip: { shared: true, formatter:function () { var x,y1,y2; if(this.points.length==1){ x="谐波次数:"+this.points[0].x y2=this.points[0].series.name+":"+this.points[0].y+"A" return x+'
'+y2; }else{ x="谐波次数:"+this.points[0].x y1="国标限值(A):"+this.points[0].y+"A" y2="谐波电流幅值(A):"+this.points[1].y+"A" return x+'
'+y1+'
'+y2; } } }, plotOptions: { column: { grouping: false, shadow: false, borderWidth: 0 } }, series: [{ name: '谐波电流幅值(A)', color: yellow, data: gb, tooltip: { valueSuffix: 'A' }, pointPadding: 0.3, pointPlacement: -0.2 }, { name: '国标限值(A)', color: green, data: serName, tooltip: { valueSuffix: 'A' }, pointPadding: 0.4, // 通过 pointPadding 和 pointPlacement 控制柱子位置 pointPlacement: -0.2 }] }); } } // ***********关闭loading ityzl_CLOSE_LOAD_LAYER(idea); } }) } function queryData(tltName){ var lineId=window.parent.document.getElementById("lineIndex").value; var startTime = $("#startTime").val(); var endTime = $("#endTime").val(); if(tltName=="谐波电压含有率"){ getXbDy(startTime,endTime,lineId); }else if(tltName=="谐波电流幅值"){ getXbDl(startTime,endTime,lineId); } }