/**
 * 用户登录记录
 */
$(document).ready(function() {
		var endTime = getEndTime();
		var startTime = getStartTime("年份", endTime);
			load(startTime,endTime);
		$("#querry").click(function(){
			var startTime=$("#startTime").val();
			var endTime=$("#endTime").val();
			load(startTime,endTime);
		})
	});
	function load(startTime,endTime){
		var i;
		$.ajax({
			type : "POST",
			url : "/pqs9900/login/getUserLogin",
			data :{
				startTime:startTime,
				endTime:endTime
			},
			beforeSend: function () {  
	            i = ityzl_SHOW_LOAD_LAYER();  
	        },
			success : function(data) {
				//没有权限的请求
				if(data==300){
					location.href='/pqs9900/auth/unauthorized';
				//没有登陆的请求
				}else if(data==301){
					location.href='/pqs9900';
				}else{
					if (data.code == 500) {
						initTable(null);
					} else {
						initTable(data.body);
					}
				}
				//***********关闭loading
	        	ityzl_CLOSE_LOAD_LAYER(i);
			}
	})
	}
	function initTable(data){
		var p=$("#roleJ").val();
		var oTable= $('#vdlist').dataTable().fnClearTable(); 
		if(p=="Npro"){
			$('#vdlist').DataTable({
				columnDefs : [ {
					orderable : false,
					targets : 2
				} ],
				destroy : true,
				data : data,
				lengthMenu : [ 12 ],
		        language : {
					url:'/pqs9900/json/chine.json'
				},
				'fnDrawCallback': function(oTable) {    
				    $("#vdlist_paginate").append("<div style='float:right;padding-top:4px;padding-left:10px'>到第 <input type='text' id='changePage' class='input-text' style='width:50px;height:28px;'> 页  <button class='btn btn-primary' id='dataTable-btn'>确定</button></div>");    
				    var table = $("#vdlist").dataTable();    
				    $('#dataTable-btn').click(function(e) {
				        if($("#changePage").val() && $("#changePage").val() > 0) {    
				            var redirectpage = $("#changePage").val() - 1;    
				        } else {    
				            var redirectpage = 0;    
				        }    
				        table.fnPageChange(redirectpage);
				    });    
				}
			});
		}else{
			var oTable=$('#vdlist').DataTable({
				columnDefs : [ 
				{
					orderable : false,
					targets : 2
				} ],
				destroy : true,
				data : data,
				lengthMenu : [ 12 ],
		        language : {
					url:'/pqs9900/json/chine.json'
				},
				'fnDrawCallback': function(oTable) {    
				    $("#vdlist_paginate").append("<div style='float:right;padding-top:4px;padding-left:10px'>到第 <input type='text' id='changePage' class='input-text' style='width:50px;height:28px;'> 页  <button class='btn btn-primary' id='dataTable-btn'>确定</button></div>");    
				    var table = $("#vdlist").dataTable();    
				    $('#dataTable-btn').click(function(e) {
				        if($("#changePage").val() && $("#changePage").val() > 0) {    
				            var redirectpage = $("#changePage").val() - 1;    
				        } else {    
				            var redirectpage = 0;    
				        }    
				        table.fnPageChange(redirectpage);
				    });    
				}
			});
		}
	}