var printnoticeNo;
function checkDataAjax(claimNo,noticeNo,reqUrl){
	printnoticeNo=noticeNo;
	var dataVal='{"claimNo":"'+claimNo+'","noticeNo":"'+noticeNo+'"}';
	$.ajax({
		type:"POST",
		url:reqUrl,
		contentType:"application/json; charset=UTF-8",
		data:dataVal,
		error :function(){
			alert("查询通知书信息失败，请稍后再试！");
			return ;
		},
		success :function(data){
			if(data ==""){
				alert("查询通知书信息失败，请稍后再试！");
				return ;
			}else{
				if(data.companyName!=null && data.companyName!="null" && data.companyName!=undefined){
					var companyName=$("#"+noticeNo+"companyNameTitle").html();
					companyName=companyName.replace("太保安联健康保险股份有限公司",data.companyName);
					$("#"+noticeNo+"companyNameTitle").html(companyName);
				
					var companyNametwo=$("#"+noticeNo+"noticeContentFourth").html();
					companyNametwo=companyNametwo.replace("太保安联健康保险股份有限公司",data.companyName);
					$("#"+noticeNo+"noticeContentFourth").html(companyNametwo);
				}
				
				$("#"+noticeNo+"InfoTel").val(data.infoTel);
				$("#"+noticeNo+"noticeContentFirst").find("#claimNo").text(data.claimNo);
				$("#"+noticeNo+"noticeContentFirst").find("#claimNoText").val(data.claimNo);
				$("#"+noticeNo+"noticeContentFirst").find("#applicantName").text(data.applicantName);
				$("#"+noticeNo+"noticeContentFirst").find("#insuredName").text(data.insuredName);
				$("#"+noticeNo+"noticeContentFirst").find("#insuredPid").text(data.insuredPid);
				$("#"+noticeNo+"noticeContentFirst").find("#cnClaimAmt").text(data.cnClaimAmt);
				$("#"+noticeNo+"noticeContentFirst").find("#enClaimAmt").text(data.enClaimAmt);
				if(data.cnClassLiabAmt==""||data.cnClassLiabAmt=="null"){
					$("#"+noticeNo+"noticeContentSecond").find("#showOrHidd").css('display','none');
				}else{
					$("#"+noticeNo+"noticeContentSecond").find("#cnClassLiabAmt").text(data.cnClassLiabAmt);
					$("#"+noticeNo+"noticeContentSecond").find("#enClassLiabAmt").text(data.enClassLiabAmt);
				}
				$("#"+noticeNo+"noticeContentSecond").find("#cnTotalPayAmt").text(data.cnTotalPayAmt);
				$("#"+noticeNo+"noticeContentSecond").find("#enTotalPayAmt").text(data.enTotalPayAmt);
				$("#"+noticeNo+"noticeContentFourth").find("#branchName").text(checkNull(data.branchName));
				$("#"+noticeNo+"noticeContentFourth").find("#endCaseDate").text(data.endCaseDate);
				$("#"+noticeNo+"clmPayeeListTbl tr").remove();
				$("#"+noticeNo+"auditPolicyAndPolLibListTbl tr").remove();
				var auditPolicyAndPolLibListTr;
				var payeeTr=$("<tr><th>领款人姓名</th><th>身份证号</th><th>给付金额（人民币元）</th><th>备注</th></tr>");
				if('P0000015'==noticeNo || 'P0000017'==noticeNo){
					$("#changeSpan2").hide();
					$("#changeSpan1").show();
					auditPolicyAndPolLibListTr=$("<tr><th>保险单号</th><th>险种名称</th><th>给付金额</th></tr>");
				}else{
					$("#changeSpan1").hide();
					$("#changeSpan2").show();
					auditPolicyAndPolLibListTr=$("<tr><th>保险单号</th><th>险种名称</th><th>给付金额</th><th>险种状态后续处理</th></tr>");
				}
				$("#"+noticeNo+"auditPolicyAndPolLibListTbl").append(auditPolicyAndPolLibListTr);
				for ( var i = 0; i < data.auditPolicyAndPolLibVo.length; i++) {
					var apaps=data.auditPolicyAndPolLibVo[i];
					var tr=$("<tr></tr>");
					var td;
					
					if('P0000015'==noticeNo || 'P0000017'==noticeNo){
						td=$("<td>"+checkNull(apaps.policyNo)+"</td><td>"+checkNull(apaps.className)+"</td><td>"+checkNull(apaps.realClmAmt)+"</td>");
					}else {
						var classStatusOper= checkNull(apaps.classStatusOper);
						//需求UC00032 产险公共保额
						if(apaps.className.indexOf("公共保额")!=-1){
							classStatusOper="";
						}
						
						td=$("<td>"+checkNull(apaps.policyNo)+"</td><td>"+checkNull(apaps.className)+"</td><td>"+checkNull(apaps.realClmAmt)+"</td><td>"+classStatusOper+"</td>");
					}
					$(tr).append(td);
					$("#"+noticeNo+"auditPolicyAndPolLibListTbl").append(tr);
				}
				$("#"+noticeNo+"clmPayeeListTbl").append(payeeTr);
				for ( var i = 0; i < data.clmPayee.length; i++) {
					var clmPayees=data.clmPayee[i];
					var tr=$("<tr id="+clmPayees.objId+"></tr>");
					var claimPayeeIds=clmPayees.claimPayeeId;
//					if(checkNull(clmPayees.claimPayeeIdType)!="1"){
//						claimPayeeIds="";
//					}
					var td=$("<td>"+checkNull(clmPayees.claimPayeeName)+"</td><td>"+checkNull(claimPayeeIds)+"</td><td>"+checkNull(clmPayees.drawMoney)+"</td><td>"+checkNull(clmPayees.remark)+"</td>");
					if($("#claimState")!=null&&$("#claimState").val()=='06'){
						td=$("<td>"+checkNull(clmPayees.claimPayeeName)+"</td><td>"+checkNull(claimPayeeIds)+"</td><td>"+checkNull(clmPayees.drawMoney)+"</td><td><input maxlength=\"200\" id=\"remark\" name=\"remark\" type=\"text\" class=\"input i_s_180 input_bot_line\" value=\""+checkNull(clmPayees.remark)+"\" /></td>");
					}
					$(tr).append(td);
					$("#"+noticeNo+"clmPayeeListTbl").append(tr);
				}
			}
		}
	});
}
function checkNull(flag){
	if(flag==null || flag=="" || flag=="null"|| flag==undefined){
		return "";
	}else{
		return flag;
	}
}

function printNoticeP15_P18(){
	
//	var haveEmail = $("#haveEmail").val();
//	if(haveEmail == 'Y'){
//		if(!confirm("客户选择电子邮件方式接收，是否继续打印？")){
//			return ;
//		}
//	}else if(haveEmail == 'N'){
//		if(!confirm("客户选择电子邮件方式接收，但邮箱地址为空，是否继续打印？")){
//			return ;
//		}
//	}
   var haveEmail = $("#haveEmail").val();
   var isMail=$("#isMail").val();
   if(isMail=='Y'){
	if(haveEmail == 'Y'){
		if(!confirm("客户选择电子邮件方式接收，是否继续打印？")){
			return ;
		}
	}else if(haveEmail == 'N'){
		if(!confirm("客户选择电子邮件方式接收，但邮箱地址为空，是否继续打印？")){
			return ;
		}
	}
   }
	var claimNo=$("#SHcon1").find("table tr:eq(0)").find("td:eq(0)").text();
	var dataVal='{"claimNo":"'+claimNo+'","noticeNo":"'+printnoticeNo+'","infoTel":"'+$("#"+printnoticeNo+"InfoTel").val()+'"}';
	var strPath=window.document.location.pathname;
	var context = strPath.substring(0, strPath.substr(1).indexOf('/') + 1);
	$.ajax({
		type:"POST",
		url:context+"/claim/notice/printNoticeP15P18.do",
		contentType:"application/json; charset=UTF-8",
		data:dataVal,
		error :function(){
			alert("系统错误，请稍后再试。");
		},
		success :function(data){
			if(data){
				alert("打印通知单成功。");
			}else{
				alert("打印通知单失败。");
			}
		}
	});
	
}

function saveNoticeP15_P18(flag,flag2){
	var trList = $("#"+flag+"clmPayeeListTbl").find("tr");
	var jsonStr = "";
	for ( var int = 0; int < trList.length; int++) {
		if(int > 0){
			var tr = $(trList[int]);
			var trId=tr.attr("id");
			var remark = tr.find("INPUT[id='remark']").val();
			jsonStr+='{"objId":"' + trId + '","remark":"' + remark +'"},';
		}
	}
	var claimNo=$("#"+flag+"noticeContentFirst").find("#claimNo").text();
	jsonStr = '{"clmPayee":['+jsonStr.substring(0,jsonStr.length-1)+'],"infoTel":"'+$("#"+flag2).val()+'","noticeNo":"'+flag+'","claimNo":"'+claimNo+'"}';
	if(jsonStr==""){
		return;
	}
	$.ajax({
		type:"POST",
		contentType:"application/json; charset=UTF-8",
		url:"/claimserver/claim/notice/saveLplkNotice14Info.do",
		data:jsonStr,
		error :function(){
			alert("系统错误，请稍后再试。");
		},
		success :function(data){
			if(data=="00"){
				alert("理赔领款通知书保存成功。");
			}else{
				alert("理赔领款通知书保存失败。");
			}
		}
	});
}
