$(function() {
	initData();
	initGrid();//加载列表
});
function initData(){		//初始化开始时间和结束时间
	var now = new Date();
	var d1 = new Date(now.getFullYear(), now.getMonth(), now.getDate()-7);
	var d2 = new Date();
	$("#startTime").datetimebox('setValue',$.formatDate(d1,"yyyy-MM-dd hh:mm:ss"));
	$("#endTime").datetimebox('setValue',$.formatDate(d2,"yyyy-MM-dd hh:mm:ss"));
};
 
function initGrid(){
	var toolbar = [{
        text:'查询',
        iconCls:'icon-search',
        handler:function(){doSearch();}
    }];
	$('#tableGrid').datagrid({
		toolbar: toolbar,
		rownumbers : true,
		queryParams: getQueryParam(),
		url : VpUserOpLogService.query_VpUserOpLog_userRole_list,
		columns : [ [ 
		 {
			title: "用户账号",
			field: "loginname",
			width: 90 
		}, {
			title: "用户名称",
			field: "username",
			width: 90
		}, {
			title: "所属机构",
			field: "roleName",
			width: 90
		},{
			title: "操作对象",
			field: "opobject",
			width: 120
		}, {
			title: "操作类型",
			field: "opcommand",
			width: 120,
			formatter:function(value,record,num){
				var text = "";
				if(value == 1) text = '登录';
				if(value == 2) text = '查询列表';
				if(value == 3) text = '增加';
				if(value == 4) text = '修改';
				if(value == 5) text = '删除';
				if(value == 6) text = '查询一个';
				if(value == 7) text = '查询列表总数';
				if(value == 8) text = '查询扩展';
				if(value == 9) text = '查询分页';
				if(value == 10) text = '查询总数';
				if(value == 11) text = '导出';
				if(value == 12) text = '导入';
				return text;
			}
		}, {
			title: "操作IP",
			field: "clientip",
			width: 90
		},{
			title: "时间",
			field: "optime",
			sortable: false,
			width: 150
		},{
			title: "描述",
			field: "opcontent",
			sortable: false,
			width: 360,
			formatter:function(value,record,num){
				return "<div id=opcontent title='" +  value + "'>" +value +"</div>"
			}
		}] ],
		onDblClickRow :function(rowIndex,rowData){
		        windowid = top.$.createWin({
                    title   : '显示详情',
                    width   :  550,
                    height  :  310,
                    url     :  top.sysUrl+'/frame/log/operationLog_show.jsp',
                    records :  rowData,
		        })
			}
		});
	
};

function getQueryParam(){
	return {
		LIKEloginname: $("#LIKEloginname").textbox('getValue'),
		LIKEopobject: $("#LIKEopobject").textbox('getValue'),
		opcommand: $("#opcommand").combobox('getValue'),
		LIKEclientip: $("#LIKEclientip").textbox('getValue'),
		opeStartTime: $("#startTime").datebox('getValue'),
		opeEndTime: $("#endTime").datebox('getValue')
	};
}

function doSearch(){
	$('#tableGrid').datagrid('load',getQueryParam());
}
