
//获取跟目录
function getRootPath(){
    return window.document.location.href.substring(
    		0,window.document.location.href.indexOf(
    		window.document.location.pathname));
}

//跟目录全局变量
var rootPath = getRootPath();
//当前目录前缀
var currPath = "/claimserver/management/pubAmount/";


//查询
function query(){
	$("#context").empty();
	var pid = $.trim($("#pid").val());
	$("#person-id").val(pid);
	
	if(pid == "") {
		alert("请输入查询条件");
		return;
	}
	
	$.ajax({
		type:"POST",
		url:"queryPersonAuthorized.do",
		data:{"pid":pid},
		async:true,
		error:function(){
			alert("查询出错！");
		},
		success:function(data){
			
			//被保人信息
			$("#insuredName").html(data.insuredName);       //姓名
			$("#sex").html(data.sex);                       //性别
			$("#idType").html(data.idType);                 //证件类型
			$("#person-id").html(data.pid);                 //证件号码
			$("#phone").html(data.phone);                   //移动电话
			$("#telephone").html(data.telephone);           //固定电话
			$("#address").html(data.address);               //联系地址
			$("#postCode").html(data.postCode);             //邮政编码
			$("#email").html(data.email);                   //邮箱地址
			
			//公共保额个人授权信息
			var aus = data.auList;
			//<a onclick=\"daaaa(this)\" style=\"color:#0000FF; cursor:pointer;\" title=\"点击查看赔案详情\">"+comp.claimNo+"</a>
			for ( var i = 0; i < aus.length; i++) {
				var au = aus[i];
				
				if(au.useDate!="" && au.useDate!=null){
				$("#context").append("<tr>" +
							"<td>"+au.useDate+"</td>" +
							"<td><a  data-use-date=\""+au.useDate+"\" style=\"color:#0000FF; cursor:pointer;\" title=\"打开赔案详情\" href=\""+rootPath+"/claimserver/claim/commonsearch/clmtaskdetailQuery.do?claimNo="+au.claimNo+"&claimState="+au.claimState+"&claimSubState="+au.claimSubState+"&gohistory=close\" target=\"_blank\" >"+au.claimNo+"</a></td>" +
							"<td>"+au.policyNo+"</td>" +
							"<td>"+au.insuranceDuration+"</td>" +
							"<td>"+au.authorizedNo+"</td>" +
							"<td>"+au.authorizedType+"</td>" +
							"<td>"+au.authorizedAmt+"</td>" +
							"<td>"+au.authorizedBegdate+"</td>" +
							"<td>"+au.authorizedStopdate+"</td>" +
							"<td>"+au.useAmt+"</td>" +
							"<td>"+au.remindAuthredAmt+"</td>" +
						  "</tr>");
				}else{
					$("#context").append("<tr>" +
							"<td></td>" +
							"<td class=\"no-end-case\" title=\"未结案\">"+au.claimNo+"</td>" +
							"<td>"+au.policyNo+"</td>" +
							"<td>"+au.insuranceDuration+"</td>" +
							"<td>"+au.authorizedNo+"</td>" +
							"<td>"+au.authorizedType+"</td>" +
							"<td>"+au.authorizedAmt+"</td>" +
							"<td>"+au.authorizedBegdate+"</td>" +
							"<td>"+au.authorizedStopdate+"</td>" +
							"<td>"+au.useAmt+"</td>" +
							"<td>"+au.remindAuthredAmt+"</td>" +
						  "</tr>");
			}
			

			}
			
		}
		
	});
}//onclick=\"daaaa(this)\"

//跳转赔案详情页面
//function daaaa(obj){
//	if($(obj).attr("data-use-date")==""||$(obj).attr("data-use-date")==null){
//		return;
//	}
//	SkipByPost(rootPath+"/claimserver/claim/commonsearch/clmtaskdetailQuery.do",{claimNo:$(obj).html()});
//}