var windowId,proName = window.location.pathname.split("/")[1],sysUrl = "http://"+window.location.host+"/"+proName,toEdit;
var jobid = $.getUrlParam("jobid");
console.log("jonid: ",jobid);
$(function(){
	initDefault();	
	initLogList();
});
//默认
function initDefault(){
	
	initGrid();
}
//查询条件
function getQueryParams(){
	var sParam = {};
	/*
	sParam.LIKElogId = $('#LIKElogId').textbox("getValue");
	sParam.LIKEjobid = $('#LIKEjobid').textbox("getValue");
	sParam.LIKEprocessstate = $('#LIKEprocessstate').textbox("getValue");
	sParam.LIKEprocesstime = $('#LIKEprocesstime').textbox("getValue");
	sParam.LIKEprocesscompany = $('#LIKEprocesscompany').textbox("getValue");
	sParam.LIKEprocesspeople = $('#LIKEprocesspeople').textbox("getValue");
	sParam.LIKEprocessphone = $('#LIKEprocessphone').textbox("getValue");
	sParam.LIKEprocessdescription = $('#LIKEprocessdescription').textbox("getValue");
	sParam.LIKEcreateaccount = $('#LIKEcreateaccount').textbox("getValue");
	sParam.LIKEcreatetime2 = $('#LIKEcreatetime2').textbox("getValue");
	sParam.LIKEmodifyaccount = $('#LIKEmodifyaccount').textbox("getValue");
	sParam.LIKEmodifytime = $('#LIKEmodifytime').textbox("getValue");
	sParam.LIKEremarks = $('#LIKEremarks').textbox("getValue");
	sParam.LIKEextend1 = $('#LIKEextend1').textbox("getValue");
	sParam.LIKEextend2 = $('#LIKEextend2').textbox("getValue");
	sParam.LIKEextend3 = $('#LIKEextend3').textbox("getValue");
	sParam.LIKEextend4 = $('#LIKEextend4').textbox("getValue");

	*/
	/*
	var xx1 = $("#xx1").textbox("getValue");//文本
	var xx2 = $("#xx2").combobox("getValue");//下拉
	var xx3 = $("#xx3").datetimebox("getValue");//日期
	var xx4 = $("#xx4").numberbox("getValue");//数字
	var LIKEtime1 = $('#LIKEtime1').datetimebox("getValue");	
	var LIKEtime2 = $('#LIKEtime1').datetimebox("getValue");	
	var tableparam = "";
	if(!(LIKEtime1==null||LIKEtime1==""||LIKEtime1==undefined)){
		tableparam += " AND time > '" +LIKEtime1 + "'";
	}
	if(!(LIKEtime2==null||LIKEtime2==""||LIKEtime2==undefined)){
		tableparam += " AND time < '" +LIKEtime2 + "'";
	}
	sParam.tableparam = tableparam;
	sParam.order = "order by time desc ";
	*/
	sParam.jobid = jobid;
	sParam.order = "order by createtime desc ";
	return sParam;
}
function initLogList(){
	$.ajax({
			type:"post",
			url : 'ywrepairjoboplogAction!listYwrepairjoboplogByPage.do',
			dataType:"json",
			data:getQueryParams(),
			success:function(res){
				$("#ywrepairjoboplogList").html("");
				if(res){
					for(var i=0,len=res.rows.length;i<len;i++){
						var li="<li><span>"+res.rows[i].processtime+"</span><span>"+res.rows[i].processpeople+"</span><span>"+CommonData.jobprocessstate[res.rows[i].processstate]+"</span></li>"
						$("#ywrepairjoboplogList").append(li);
					}
				}
			}
	});
	
}
//加载列表
function initGrid(){	
	var toolbar = [{
    	text    :	'刷新',
        iconCls : 	'icon-refresh',
        handler : 	function(){location.reload(true);}
    },{
    	text	:	'查询',
        iconCls	:	'icon-search',
        handler	:	doSearch
    }];
	$('#tableGrid').datagrid({
		toolbar : toolbar,
		singleSelect:true,
		rownumbers:true,
		queryParams:getQueryParams(),
		url : 'ywrepairjoboplogAction!listYwrepairjoboplogByPage.do',
		columns : [[
		    {
				field: 'A',
				checkbox:'true',
				width:30
			},
		    {field:'logId',title:'logId',hidden:true,width:120, 
				formatter:function showClick(value,record,num){ 
					return "<a  href='javascript:void(0);' class='ahref' onclick='doUpdate("+num+")'>"+value+"</a>";
				}
 			},
			{field:'jobid',title:'工单编号',hidden:false,width:120},
			{field:'processstate',title:'处理状态',hidden:false,width:120,
				formatter:function showClick(value,record,num){ 
					return CommonData.jobprocessstate[value];
				}
			},
			{field:'processtime',title:'处理时间',hidden:false,width:120},
			{field:'processcompanyname',title:'处理单位',hidden:false,width:120},
			{field:'processpeople',title:'处理人',hidden:false,width:120},
			{field:'processphone',title:'处理人电话',hidden:false,width:120},
			{field:'processdescription',title:'处理描述',hidden:false,width:120},
			 
		]]
	});
}

//查询
function doSearch(){	
	$('#tableGrid').datagrid('load',getQueryParams());
}

