var isSubmit = true;
$(document).ready(function(){
	laydate.render({
		  elem: '#day',
		  range: true,
		  done: function(value, date, endDate){
			    console.log(value); //得到日期生成的值，如：2017-08-18
			    console.log(date); //得到日期时间对象：{year: 2017, month: 8, date: 18, hours: 0, minutes: 0, seconds: 0}
			    console.log(endDate); //得结束的日期时间对象，开启范围选择（range: true）才会返回。对象成员同上。
			    user.startDay = date.year + "-" + date.month + "-" + date.date + " 00:00:00" ;
			    user.endDay = endDate.year + "-" + endDate.month + "-" + endDate.date + " 23:59:59" ;
		  }
		});

	
	
	
	$("#bloodIdselect").change(function(){
		if ($("#bloodIdselect").val() == "0"){
			$("#bloodIddiv").css("display","");
			$("#bloodIddivrange").css("display","none");
		} else {
			$("#bloodIddiv").css("display","none");
			$("#bloodIddivrange").css("display","");
		}
	})
	
	$("#day").val("")
	$("#bloodIddiv").css("display","");
	$("#bloodIdselect").val(0);
})

var user = {
	startDay : "",
	endDay : "",
	exportExcel : function(){

		if (isSubmit){
			isSubmit = false;
			var url = webPath + "/user/export";
			
			var name = $('#name').val();
			var paperId = $('#paperId').val();
			var start = user.startDay;
			var end = user.endDay;
			
			var bloodId = "";
			var startbloodId = "";
			var endbloodId = "";
			if ($("#bloodIdselect").val() == "0"){
				bloodId = $('#bloodId').val();
			} else {
				startbloodId = $('#startbloodId').val();
				endbloodId = $('#endbloodId').val();
			}
			
			

			if(name != "" || paperId != "" || start != "" || end != "" || bloodId != "" || startbloodId != "" || endbloodId != ""){
				var param = "?"
				if (name != ""){
					param = param + "name=" + name ;
				}
				
				if (paperId != ""){
					if (param == "?"){
						param = param + "paperId=" + paperId;
					} else {
						param = param + "&paperId=" + paperId;
					}
				}
				
				if (start != ""){
					if (param == "?"){
						param = param + "start=" + start;
					} else {
						param = param + "&start=" + start;
					}
				}
				
				if (end != ""){
					if (param == "?"){
						param = param + "end=" + end;
					} else {
						param = param + "&end=" + end;
					}
					
				}
				
				if (bloodId != ""){
					if (param == "?"){
						param = param + "bloodId=" + bloodId;
					} else {
						param = param + "&bloodId=" + bloodId;
					}
					
				}
				
				
				if (startbloodId != ""){
					if (param == "?"){
						param = param + "startbloodId=" + startbloodId;
					} else {
						param = param + "&startbloodId=" + startbloodId;
					}
					
				}
				
				if (endbloodId != ""){
					if (param == "?"){
						param = param + "endbloodId=" + endbloodId;
					} else {
						param = param + "&endbloodId=" + endbloodId;
					}
					
				}
				url = url + param;
			}
			window.open(url);
			
			isSubmit = true;
		}
		
	}
	
}


















