jQuery(document).ready(function() {
	
	var grid_selector = "#businessReport-table";
	var pager_selector = "#businessReport-pager";
	
	sxUtil.jqGrid(grid_selector,{
		mtype:'get',
		url: '/businessReport/do_list',
		postData:{},
		datatype: "json",
		colNames:['企业名称','业务类型','开始时间', '结束时间','处理人'],
		colModel:[
//		    {name:'id',index:'id', width:60, sorttype:"int",hidden:true,hidedlg:true},
			{name:'enterpriseName',index:'enterpriseName', width:120},
			{name:'businessType',index:'businessType', width:100},
			{name:'beginTime',index:'beginTime', width:100},
			{name:'endTime',index:'endTime', width:100, sortable:false},
			{name:'handler',index:'handler', width:100, sortable:false}
		], 
		viewrecords : true,
		rowNum:10,
		rowList:[10,20,30],
		pagerpos: 'left',
		pager : pager_selector,
		multiselect: true
	},true);
	
	
	$('#refreshBusinessReport').click(function(){
		$("#handlers option").attr("selected",false);
		$("#applyEnterprise option").attr("selected",false);
		ref();
	});
	
	function ref(){
		jQuery(grid_selector).jqGrid('setGridParam',{
			  url:'/businessReport/do_list',
			  postData:{'basicIds':null,'handler':null},
			  page:1 
		}).trigger("reloadGrid"); //重新载入
	}
	
	$("#handlers").change(function(){
		var handler=$("#handlers option:selected").val();
		var ids=$("#applyEnterprise option:selected").val();
		refChange(ids,handler);
	});
	$("#applyEnterprise").change(function(){
		var handler=$("#handlers option:selected").val();
		var ids=$("#applyEnterprise option:selected").val();
		refChange(ids,handler);
	});
		
	function refChange(Ids,handler){
		jQuery(grid_selector).jqGrid('setGridParam',{
			  url:'/businessReport/do_list',
			  postData:{'basicIds':Ids,'handler':handler},
			  page:1 
		}).trigger("reloadGrid"); //重新载入
	}
});