function saveP0000014(flag,flag2){
	var trList = $("#payeeListP0000014").find("tr");
	var jsonStr = "";
	for ( var int = 0; int < trList.length; int++) {
		var tr = $(trList[int]);
		var trId=tr.attr("id");
		var remark = tr.find("INPUT[id='remark']").val();
		
		jsonStr+='{"objId":"' + trId + '","remark":"' + remark +'"},';
	}
//	jsonStr = "["+jsonStr.substring(0,jsonStr.length-1)+"]";
	jsonStr = '{"clmPayee":['+jsonStr.substring(0,jsonStr.length-1)+'],"infoTel":"'+$("#"+flag2).val()+'","noticeNo":"'+flag+'","claimNo":"'+$("#claimNoP0000014").val()+'"}';
	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("理赔领款通知书保存失败。");
			}
		}
	});
}


function printP0000014Info(){
//	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 noticeP0000014 = "";
	var auditPolicyAndPolLibVo = "";
	var clmPayeeList = "";
	var jsonStr = "";
	var objId = $("#objId").val();
	var claimNoP0000014 = $("#claimNoP0000014").val();
	var applicantNameP0000014 = $("#applicantNameP0000014").val();
	var insuredNameP0000014 = $("#insuredNameP0000014").val();
	var insuredPidP0000014 = $("#insuredPidP0000014").val();
	var payAmtUpperP0000014 = $("#payAmtUpperP0000014").val();
	var payAmtP0000014 = $("#payAmtP0000014").val();
	var repayAmtUpperP0000014 = $("#repayAmtUpperP0000014").val();
	var repayAmtP0000014 = $("#repayAmtP0000014").val();
	var sumAmtUpperP0000014 = $("#sumAmtUpperP0000014").val();
	var sumAmtP0000014 = $("#sumAmtP0000014").val();
	var weburlP0000014 = $("#weburlP0000014").html();
	var branchNameP0000014 = $("#branchNameP0000014").html();
	var printDateP0000014 = $("#printDateP0000014").val();
	var policyListTr = $("#policyListP0000014").find("tr");
	var payeeListTr = $("#payeeListP0000014").find("tr");
	var infoTel=$("#P0000014InfoTel").val();
	noticeP0000014+='{"claimNo":"' + claimNoP0000014 + '","applicantName":"' + applicantNameP0000014
	+ '","insuredName":"' + insuredNameP0000014  +  '","insuredPid":"' + insuredPidP0000014
	+'","payAmt":"' + payAmtP0000014+'","branchName":"'+branchNameP0000014+'","printDate":"'+printDateP0000014+'"}';
	
	for ( var i = 0; i < policyListTr.length; i++) {
		var policyNo = $(policyListTr[i]).find("td:eq(0)").html();
		var className = $(policyListTr[i]).find("td:eq(1)").html();
		var realClmAmt = $(policyListTr[i]).find("td:eq(2)").html();
		var classStatusOper = $(policyListTr[i]).find("td:eq(3)").html();
		auditPolicyAndPolLibVo += '{"policyNo":"' + policyNo + '","className":"' + className
		+ '","realClmAmt":"' + realClmAmt  +  '","classStatusOper":"' + classStatusOper+'"},';
	}
	if(auditPolicyAndPolLibVo.length!=0){
		auditPolicyAndPolLibVo = "["+auditPolicyAndPolLibVo.substring(0,auditPolicyAndPolLibVo.length-1)+"]";
	}
	for ( var i = 0; i < payeeListTr.length; i++) {
		var claimPayeeName = $(payeeListTr[i]).find("td:eq(0)").html();
		var claimPayeeId = $(payeeListTr[i]).find("td:eq(1)").html();
		var drawMoney = $(payeeListTr[i]).find("td:eq(2)").html();
		var remark = $(payeeListTr[i]).find("INPUT[id='remark']").val();
		if(remark == undefined){
			remark = $(payeeListTr[i]).find("td:eq(3)").html();
		}
		clmPayeeList += '{"claimPayeeName":"' + claimPayeeName + '","claimPayeeId":"' + claimPayeeId
		+ '","drawMoney":"' + drawMoney  +  '","remark":"' + remark+'"},';
	}
	if(clmPayeeList.length!=0){
		clmPayeeList = "["+clmPayeeList.substring(0,clmPayeeList.length-1)+"]";
	}
	
	jsonStr = '{"noticeP0000014":' + noticeP0000014 +',"repayAmt":"' + repayAmtP0000014+'","repayAmtUpper":"' + repayAmtUpperP0000014+
	'","payAmtUpper":"' + payAmtUpperP0000014+'","auditPolicyAndPolLibVo":' + auditPolicyAndPolLibVo+',"clmPayeeList":' + clmPayeeList+',"infoTel":"'+infoTel+'"}';
	$.ajax({
		type:"POST",
		contentType:"application/json; charset=UTF-8",
		url:"/claimserver/claim/notice/printP0000014Info.do",
		data:jsonStr,
		error :function(){
			alert("系统错误，请稍后再试。");
		},
		success :function(data){
			if(data=="00"){
				alert("打印通知单成功。");
			}else{
				alert("打印通知单失败。");
			}
		}
	});
	
}


function showP0000014(url,claimNo){
	$.ajax({
		type:"POST",
		data:{"claimNo":claimNo},
		url:url,
		error :function(){
			alert("系统错误，请稍后再试。");
		},
		success :function(data){
			
			
			var companyName=$("#P0000014companyNameTitle").html();
			if(companyName.indexOf("太保安联健康保险股份有限公司")!=-1){
				companyName=companyName.replace("太保安联健康保险股份有限公司",data.companyName);
				$("#P0000014companyNameTitle").html(companyName);
			
				var companyNametwo=$("#P0000014companyNamebottom").html();
				companyNametwo=companyNametwo.replace("太保安联健康保险股份有限公司",data.companyName);
				$("#P0000014companyNamebottom").html(companyNametwo);
			}
			
			
			
			
			var payAmt = 0;//总共金额 by lirui
			$("#P0000014InfoTel").val(data.noticeInfo.noticeP0000014.infoTel);
			$("#objIdP0000014").val(data.noticeInfo.noticeP0000014.objId);
			$("#claimNoP0000014").val(data.noticeInfo.noticeP0000014.claimNo);
			$("#applicantNameP0000014").val(data.noticeInfo.noticeP0000014.applicantName);
			$("#insuredNameP0000014").val(data.noticeInfo.noticeP0000014.insuredName);
			$("#insuredPidP0000014").val(data.noticeInfo.noticeP0000014.insuredPid);
			/*$("#payAmtUpperP0000014").val(convertRMB(data.noticeInfo.noticeP0000014.payAmt));
			$("#payAmtP0000014").val(data.noticeInfo.noticeP0000014.payAmt);*/
			
			if(parseInt(data.noticeInfo.repayAmt)<0){

				$("#repayAmtUpperP0000014").val("负"+convertRMB(Math.abs(parseInt(data.noticeInfo.repayAmt))));
			}else{
				$("#repayAmtUpperP0000014").val(convertRMB(data.noticeInfo.repayAmt));
			}
			$("#repayAmtP0000014").val(data.noticeInfo.repayAmt);
			/*$("#sumAmtUpperP0000014").val(convertRMB(data.noticeInfo.noticeP0000014.payAmt));
			$("#sumAmtP0000014").val(data.noticeInfo.noticeP0000014.payAmt);*/
			$("#branchNameP0000014").html(data.noticeInfo.noticeP0000014.branchName);
			$("#printDateP0000014").val(data.noticeInfo.noticeP0000014.printDate);
			var policyTr ="";
			var payeeTr = "";
			
			for ( var int = 0; int < data.noticeInfo.auditPolicyAndPolLibVo.length; int++) {
				var policyNo = data.noticeInfo.auditPolicyAndPolLibVo[int].policyNo;
				var className = data.noticeInfo.auditPolicyAndPolLibVo[int].className;
				var realClmAmt = data.noticeInfo.auditPolicyAndPolLibVo[int].realClmAmt;
				var classStatusOper = data.noticeInfo.auditPolicyAndPolLibVo[int].classStatusOper;
				//需求UC00032 产险公共保额
				if(className.indexOf("公共保额")!=-1){
					classStatusOper="";
				}
				
				policyTr = policyTr + "<tr><td>"+policyNo+"</td><td>"+className+"</td><td>"+realClmAmt+"</td><td>"+classStatusOper+"</td></tr>";
				payAmt =realClmAmt*1+payAmt*1;//因为在理算未完成前总共金额还未存到clmTask/clmHistory表中，所以将每个保单的金额加起来即为总共金额 by lirui
			}
			$("#payAmtUpperP0000014").val(convertRMB(payAmt));
			$("#payAmtP0000014").val(payAmt);
			$("#sumAmtUpperP0000014").val(convertRMB(payAmt));
			$("#sumAmtP0000014").val(payAmt);
			for ( var i = 0; i < data.noticeInfo.clmPayeeList.length; i++) {
				var objId = data.noticeInfo.clmPayeeList[i].objId;
				var claimPayeeName = data.noticeInfo.clmPayeeList[i].claimPayeeName;
				var claimPayeeId =data.noticeInfo.clmPayeeList[i].claimPayeeId==null?"":data.noticeInfo.clmPayeeList[i].claimPayeeId;
				var drawMoney = data.noticeInfo.clmPayeeList[i].drawMoney==null?"":data.noticeInfo.clmPayeeList[i].drawMoney;
				var remark = data.noticeInfo.clmPayeeList[i].remark==null?"":data.noticeInfo.clmPayeeList[i].remark;
				if($("#claimState")!=null&&$("#claimState").val()=='06'){
					payeeTr = payeeTr + "<tr id="+objId+"><td>"+claimPayeeName+"</td><td>"+claimPayeeId+"</td><td>"+drawMoney+"</td>" +
					"<td><input maxlength=\"200\" id=\"remark\" name=\"remark\" type=\"text\" class=\"input i_s_180 input_bot_line\" value=\""+remark+"\" /></td></tr>";
				}else{
				payeeTr = payeeTr + "<tr id="+objId+"><td>"+claimPayeeName+"</td><td>"+claimPayeeId+"</td><td>"+drawMoney+"</td>" +
				        "<td>"+remark+"</td></tr>";
				}
			}
			$("#policyListP0000014 tr").remove();
			$("#payeeListP0000014 tr").remove();
			$("#policyListP0000014").append(policyTr);
			$("#payeeListP0000014").append(payeeTr);
			if(data.noticeInfo.repayAmt==""){
				$("#repayAmtSpan").css("display","none");
			}
			showDiv("P0000014");
			
		}
	});
}



//数字转大写
function convertRMB(num){ 
    if(!/^\d*(\.\d*)?$/.test(num))throw(new Error(-1, "Number is wrong!"));     
    var AA = new Array("零","壹","贰","叁","肆","伍","陆","柒","捌","玖");     
    var BB = new Array("","拾","佰","仟","萬","億","圆","");     
    var CC = new Array("角", "分", "厘");     
    var a = (""+ num).replace(/(^0*)/g, "").split("."), k = 0, re = "";     
    for(var i=a[0].length-1; i>=0; i--){     
        switch(k){     
            case 0 : re = BB[7] + re; break;     
            case 4 : if(!new RegExp("0{4}\\d{"+ (a[0].length-i-1) +"}$").test(a[0]))     
                         re = BB[4] + re; break;     
            case 8 : re = BB[5] + re; BB[7] = BB[5]; k = 0; break;     
        }     
        if(k%4 == 2 && a[0].charAt(i)=="0" && a[0].charAt(i+2) != "0") re = AA[0] + re;     
        if(a[0].charAt(i) != 0) re = AA[a[0].charAt(i)] + BB[k%4] + re; k++;     
    }     
    if(a.length>1){     
        re += BB[6];     
        for(var i=0; i<a[1].length; i++){     
            re += AA[a[1].charAt(i)] + CC[i];     
            if(i==2) break;     
        }   
//        if(a[1].charAt(0)=="0" && a[1].charAt(1)=="0"){  
//          re+="圆整";  
//        }    
    }
    else{  
        re+="圆";  
    }     
    return re;     
} 