var cdid=null;
var cdycm=null;
var child=[];
var pageParam={};
var chart=null;
var utils=new Util();
var startTime=null;
var endTime=null;
var searchUtil = new SearchUtil();
$(function(){
pageParam.style=utils.resolveUrl()["style"]||"style1";
pageParam.title=utils.resolveUrl()["title"]||"广东电网";
pageParam.number=utils.resolveUrl()["number"]||warnningnumber;
pageParam.parentId=utils.resolveUrl()["dept_id"]||"11";
var date=allGetServerTime();
$("#beginTime").val(getDateC(-1,date));
startTime=$("#beginTime").val();
init();
//首页里面加载Iframe展开方法
// setIframe(iframModuleID);
});
function getDateC(digit,date){
date.setDate(date.getDate()+digit);
var m=(date.getMonth()+1)>10?((date.getMonth()+1)):('0'+(date.getMonth()+1))
return date.getFullYear()+"-"+(date.getMonth()+1)+"-"+date.getDate();
}
function init(){
queryCD();
if(null==cdid){
find();
}
}
function find(){
var shu=0;
$("#i_add").on("click",function(){
shu++;
if(shu>0&&shu<=2){
var $his_time = $('历史时间:');
$("#i_time").append($his_time);
var input = $('');
input.render();
$his_time.after(input);
}else{
top.Dialog.alert("最多可查询三个历史时间!");
}
});
$("#i_search").on("click",function(){
loadChart(cdid);
});
}
function onClickItem(){
$("#comp_id").bind("change",function(){
if(!$(this).attr("relValue")){
top.Dialog.alert("没有选择节点");
}else{
cdycm=$(this).attr("relText");
cdid=$(this).attr("relValue");
}
});
}
function queryCD(){
$.post("/nwyj/ws/ChartServiceImpl/ChartServiceImpl/getCSGRDBDeptInfo",{compId:pageParam.parentId},function(result){
if("FAILURE"==result.state){
$("#i_comp_con").hide();
zeroChartIntoParam("网络异常");
return
}
if(0==result.rows.length){
$("#i_comp_con").hidden();
zeroChartIntoParam("该单位目前尚未开放此项服务");
return
}
for(var index=0,len=result.rows.length;index1){
/*加载列表 */
var selData={"list":child};
$("#comp_id").data("data",selData)
$("#comp_id").render();
$(".selectbox-wrapper").css("width","239px");
$(".selectbox").css("width","210px");
onClickItem();
}
},"json");
}
function loadChart(id){
var time="";
$("input[name='time']").each(function(){
$(this).val();
time+=$(this).val()+",";
});
//[{"msecond":980,"value":12,"pt":3158815,"lsecond":1468311492,"dateStr":"2016-07-12 16:18:12"}]
$.post("/nwyj/ws/ChartServiceImpl/ChartServiceImpl/getCSGRDBDataInfo",{compId:cdid,startTime:time},function(result){
//alert(result.rows.length);
//console.log(JSON.stringify(result))
if("FAILURE"==result.state){
zeroChartIntoParam("网络异常");
return ;
}
if(result.rows.length==0){
zeroChartIntoParam("尚未查询到数据");
return;
}
veriColor();
removeNoData();
var sArr = [];
var xAxis = [];
var leArr = [];
for(var i=result.rows.length-1; i >=0; i--){
var sp = {type:"line",name:substringTimeName(result.rows[i][0].dateStr),data:[], symbolSize:0,
itemStyle: { normal: {color:pageStyle[pageParam.style]["chartColor"][i]}}};
var spdata = [];
for(var j = 0; j < result.rows[i].length; j++){
spdata.push(result.rows[i][j].value);
if(i==1){
xAxis.push(substringTime(result.rows[i][j].dateStr));
}
};
leArr.push(substringTimeName(result.rows[i][0].dateStr));
sp.data = spdata;
sArr.push(sp);
};
pageParam.opParams={
/* title:"截止时间:"+item["APPEAR_TIME"],//标题
subtext:"当前停运数:"+item["sum"]+" (条)", */
saveName:$("#i_page_head_title").find("h2").html()+searchUtil.getNowFormatDateTime(new Date),
unit:"",//单位
leArr:leArr,//图例
xAxis:xAxis,//x轴
yxf:"MW",//y轴格式化
sArr:sArr,//主数据
trigger:"axis",
legendColor:legendC,
value:"value",
xAxisColor:xAxisC,
yAxisColor:yAxisC
};
chart=getEchart($("#i_page_chart"),getOption,pageParam.opParams,null);
setTitle();
bindEvent();
},"json");
}
function substringTimeName(item){
//var str=item.substring(item.indexOf(" ")-2,item.indexOf(" "));
var str=item.substring(0,10);
return str;
}
function substringTime(item){
//var str=item.substring(item.indexOf(" ")-2,item.indexOf(" "));
var str=item.substring(item.indexOf(" ")+1,item.indexOf(" ")+6);
return str;
}
/**
*设置标题
*/
function setTitle(){
$("#i_page_head_title").find("h2").remove();
$("#i_page_head_title").append(""+cdycm+"
");
}
function bindEvent(){
$(window).resize(function(){
chart.resize();
});
}
//五分钟一个断面
setInterval(function(){
loadChart(cdid,startTime);
}, "300000");