var jsonId=getQueryVariable("JSONID");
$(function(){
	loadYears("selectYear");
	$("#selectYear").find("option").eq(0).prop("selected",true) 
	reloadInfo();
	setTimeout(function() {
		$("#btninfo").bootstrapDropdownOnHover({
	        mouseOutDelay: 50
	    });
	}, 2500)
})
function reloadInfo(){//重新加载数据
	getNcjjInfo();//农业技术
	getNckjInfo();//农村科技
	getNyzbInfo();//农业装备
	getZzyInfo();//种植业
	getXmyInfo();//畜牧业
	getYyInfo();//渔业
}
function getNcjjInfo(){//农村与农村经济
	$("#ncjj").html('');
	$.ajax({
		type:"Post",
		url:"../home/getNcjjInfo.service",
		data:{
			year:$("#selectYear").val()
		},
		dataType:"json",
		success:function(data){
			if(data.success=='true'){
				var str='';
				var s;
				$.each(data.list,function(index,item){
					str+='<div class="col-md-6 " id="btndiv">'+
							'<button type="button" class="form-control" style="color:#66B3FF;">'+item.name+'</button>'+
						 '</div>';
					str+='<div class="col-md-6 " id="btndiv">';
					if(item.bj=='1'){//市级登录需要显示各个完成的县
						str+='<button type="button" class="form-control dropdown-toggle" style="color:#66B3FF;" id="dropdownMenu1" data-toggle="dropdown">已上报'+item.count+'</button>';
						str+='<ul class="dropdown-menu" aria-labelledby="dropdownMenu1" role="menu">';
						$.each(item.info,function(ind,itemC){
							str+='<li><a href="#">'+itemC.name+'</a></li>';
						});
						str+='</ul>';
					}else{//县级登录
						if(item.count==0){
							str+='<button type="button" class="form-control"  id="find_btn" onclick="gohref(\''+item.url+'\')">未完成</button>';
						}else{
							str+='<button type="button" class="form-control"  id="find_btn">已完成</button>';
						}
					}
					str+='</div>'
				})
				$("#ncjj").append(str);
			}
		}
	});
}
function getNckjInfo(){
	$("#nckj").html('');
	$.ajax({
		type:"Post",
		url:"../home/getNckjInfo.service",
		data:{
			year:$("#selectYear").val()
		},
		dataType:"json",
		success:function(data){
			if(data.success=='true'){
				var str='';
				var s;
				$.each(data.list,function(index,item){
					str+='<div class="col-md-6 " id="btndiv">'+
							'<button type="button" class="form-control" style="color:green;">'+item.name+'</button>'+
						 '</div>';
					str+='<div class="col-md-6 " id="btndiv">';
					if(item.bj=='1'){//市级登录需要显示各个完成的县
						str+='<button type="button" class="form-control dropdown-toggle" style="color:green;" id="dropdownMenu1" data-toggle="dropdown">已上报'+item.count+'</button>';
						str+='<ul class="dropdown-menu" aria-labelledby="dropdownMenu1" role="menu">';
						$.each(item.info,function(ind,itemC){
							str+='<li><a href="#">'+itemC.name+'</a></li>';
						});
						str+='</ul>';
					}else{//县级登录
						if(item.count==0){
							str+='<button type="button" class="form-control"  id="find_btn" onclick="gohref(\''+item.url+'\')">未完成</button>';
						}else{
							str+='<button type="button" class="form-control"  id="find_btn">已完成</button>';
						}
					}
					str+='</div>'
				})
				$("#nckj").append(str);
			}
		}
	});
}
function getNyzbInfo(){
	$("#nyzb").html('');
	$.ajax({
		type:"Post",
		url:"../home/getNyzbInfo.service",
		data:{
			year:$("#selectYear").val()
		},
		dataType:"json",
		success:function(data){
			if(data.success=='true'){
				var str='';
				var s;
				$.each(data.list,function(index,item){
					str+='<div class="col-md-6 " id="btndiv">'+
							'<button type="button" class="form-control" style="color:#5bc0de;">'+item.name+'</button>'+
						 '</div>';
					str+='<div class="col-md-6 " id="btndiv">';
					if(item.bj=='1'){//市级登录需要显示各个完成的县
						str+='<button type="button" class="form-control dropdown-toggle" style="color:#5bc0de;" id="dropdownMenu1" data-toggle="dropdown">已上报'+item.count+'</button>';
						str+='<ul class="dropdown-menu" aria-labelledby="dropdownMenu1" role="menu">';
						$.each(item.info,function(ind,itemC){
							str+='<li><a href="#">'+itemC.name+'</a></li>';
						});
						str+='</ul>';
					}else{//县级登录
						if(item.count==0){
							str+='<button type="button" class="form-control"  id="find_btn" onclick="gohref(\''+item.url+'\')">未完成</button>';
						}else{
							str+='<button type="button" class="form-control"  id="find_btn">已完成</button>';
						}
					}
					str+='</div>'
				})
				$("#nyzb").append(str);
			}
		}
	});
}
function getZzyInfo(){
	$("#zzy").html('');
	$.ajax({
		type:"Post",
		url:"../home/getZzyInfo.service",
		data:{
			year:$("#selectYear").val()
		},
		dataType:"json",
		success:function(data){
			if(data.success=='true'){
				var str='';
				var s;
				$.each(data.list,function(index,item){
					str+='<div class="col-md-6 " id="btndiv">'+
							'<button type="button" class="form-control" style="color:#5cb85c;">'+item.name+'</button>'+
						 '</div>';
					str+='<div class="col-md-6 " id="btndiv">';
					if(item.bj=='1'){//市级登录需要显示各个完成的县
						str+='<button type="button" class="form-control dropdown-toggle" style="color:#5cb85c;" id="dropdownMenu1" data-toggle="dropdown">已上报'+item.count+'</button>';
						str+='<ul class="dropdown-menu" aria-labelledby="dropdownMenu1" role="menu">';
						$.each(item.info,function(ind,itemC){
							str+='<li><a href="#">'+itemC.name+'</a></li>';
						});
						str+='</ul>';
					}else{//县级登录
						if(item.count==0){
							str+='<button type="button" class="form-control"  id="find_btn" onclick="gohref(\''+item.url+'\')">未完成</button>';
						}else{
							str+='<button type="button" class="form-control"  id="find_btn">已完成</button>';
						}
					}
					str+='</div>'
				})
				$("#zzy").append(str);
			}
		}
	});
}
function getXmyInfo(){
	$("#xmy").html('');
	$.ajax({
		type:"Post",
		url:"../home/getXmyInfo.service",
		data:{
			year:$("#selectYear").val()
		},
		dataType:"json",
		success:function(data){
			if(data.success=='true'){
				var str='';
				var s;
				$.each(data.list,function(index,item){
					str+='<div class="col-md-6 " id="btndiv">'+
							'<button type="button" class="form-control" style="color:#f0ad4e;">'+item.name+'</button>'+
						 '</div>';
					str+='<div class="col-md-6 " id="btndiv">';
					if(item.bj=='1'){//市级登录需要显示各个完成的县
						str+='<button type="button" class="form-control dropdown-toggle" style="color:#f0ad4e;" id="dropdownMenu1" data-toggle="dropdown">已上报'+item.count+'</button>';
						str+='<ul class="dropdown-menu" aria-labelledby="dropdownMenu1" role="menu">';
						$.each(item.info,function(ind,itemC){
							str+='<li><a href="#">'+itemC.name+'</a></li>';
						});
						str+='</ul>';
					}else{//县级登录
						if(item.count==0){
							str+='<button type="button" class="form-control"  id="find_btn" onclick="gohref(\''+item.url+'\')">未完成</button>';
						}else{
							str+='<button type="button" class="form-control"  id="find_btn">已完成</button>';
						}
						
					}
					str+='</div>'
				})
				$("#xmy").append(str);
			}
		}
	});
}
function gohref(dataurl){
	location.href=dataurl+"?JSONID="+jsonId+"&year="+$("#selectYear").val();
}
function getYyInfo(){//农村与农村经济
	$("#yy").html('');
	$.ajax({
		type:"Post",
		url:"../home/getYyInfo.service",
		data:{
			year:$("#selectYear").val()
		},
		dataType:"json",
		success:function(data){
			if(data.success=='true'){
				var str='';
				var s;
				$.each(data.list,function(index,item){
					str+='<div class="col-md-6 " id="btndiv">'+
							'<button type="button" class="form-control" style="color:#428bca;">'+item.name+'</button>'+
						 '</div>';
					str+='<div class="col-md-6 " id="btndiv">';
					if(item.bj=='1'){//市级登录需要显示各个完成的县
						str+='<button type="button" class="form-control dropdown-toggle" style="color:#428bca;" id="dropdownMenu1" data-toggle="dropdown">已上报'+item.count+'</button>';
						str+='<ul class="dropdown-menu" aria-labelledby="dropdownMenu1" role="menu">';
						$.each(item.info,function(ind,itemC){
							str+='<li><a href="#">'+itemC.name+'</a></li>';
						});
						str+='</ul>';
					}else{//县级登录
						if(item.count==0){
							str+='<button type="button" class="form-control"  id="find_btn" onclick="gohref(\''+item.url+'\')">未完成</button>';
						}else{
							str+='<button type="button" class="form-control"  id="find_btn">已完成</button>';
						}
					}
					str+='</div>'
				})
				$("#yy").append(str);
			}
		}
	});
}