var provinceCodeStr="";//省代码字符串
var cityCodeStr="";
$(function(){
	//当页面载入完成时获取所有省级地区
	$.ajax({

		type : "POST",
		url : "/claimserver/epiboly/findProvinces.do",
		data : "",
		async : false,
		error : function() {
			alert("获取省份失败");
			return;
		},
		success : function(data) {
			for ( var i = 0; i < data.length; i++) {
				var province = data[i];
				provinceCodeStr+=province.areaCode+":"+province.areaName+",";
			}
			
		}

	});
	//初始化省
	initProvinceCode();
	//初始化按钮
	initMenuBtn();
	//初始化被保人信息
	initCustomerInfo();
	
});
//初始化按钮显示
function initMenuBtn(){
	var hclaimState=$("#hclaimState").val();
	var endpdf=$("#endpdf").val();
	var claimSubState=$("#hclaimSubState").val();
	if(endpdf=='1'){
		$("#noticeDownload").show();
	}else{
		$("#noticeDownload").hide();
	}
	if(hclaimState=='11'){
		$("#smsbuttom").hide();//短信按钮隐藏
		if(claimSubState=='07'){//报案成功
			$("#endCasebtn").hide();
		}else if(claimSubState=='08'){//立案成功
			$("#reportCasebtn").hide();
			$("#submitFiledCase").hide();
			$("#endCasebtn").hide();
		}else if(claimSubState=='09'){//待结案
			$("#reportCasebtn").hide();
			$("#submitFiledCase").hide();
			$("#smsbuttom").show();
			$("#endCasebtn").show();
		}else{
			$("#submitFiledCase").hide();
			$("#endCasebtn").hide();
		}
		var bpoDataDate=$("#hbpoDataDate").val();
		if(bpoDataDate==''){//结案回传日期为空
			$("#saveInfo").hide();
			$("#delBtn6").hide();//资料情况
			$("#addBtn6").hide();
			$("#delBtn7").hide();//第三方投保信息
			$("#addBtn7").hide();
			$("#delBtn8").hide();//第三方赔付情况
			$("#addBtn8").hide();
			$("#delBtn9").hide();//事件信息
			$("#addBtn9").hide();
			$("#saveBtn4").hide();//领款人信息保存 
			$("#delBtn4").hide();
			$("#addBtn4").hide();
			$("#reportCasebtn").hide();//报案按钮
			$("#submitFiledCase").hide();//立案按钮
//			$("#endCasebtn").hide();
		}
		
	}else{
		$("#reportCasebtn").hide();
		$("#submitFiledCase").hide();
		$("#endCasebtn").hide();
	}
}
function initCustomerInfo(){
	var hclaimState=$("#hclaimState").val();
	var claimSubState=$("#hclaimSubState").val();
	if(hclaimState=='11'){
		//报案成功，立案成功，待结案
		if(claimSubState=='07'||claimSubState=='08'||claimSubState=='09'){
			$("#name").attr("readonly","readonly");
			$("#customerInfoPid").attr("readonly","readonly");
			$("#customerInfojob").attr("readonly","readonly");
			$("#customerInfoCaddr").attr("readonly","readonly");
			$("#divsex").html("&nbsp"+$("#spansex").html());
			$("#divIdtype").html("&nbsp"+$("#divIdtypespan").html());
		}
	}
}
var str="";//json字符串
var surgeryTrid="";//手术代码行id
var hospitalTrid="";//医院代码行id
var payeeLibDrayMoney={};//赔付责任信息支付金额
var payeeRate={};//赔付责任支付比例
function getSaveDataJson(){
	var jsonstr="";
	var chmIlls = $("#hcxclaimIlls").val();
	var insurance_person=getCustomerInfoJson();
	//领款人信息
	var benefit_persons=getBenefit_personJson();
	//出险信息 
	var clmReport=getClmReportJson();
	//赔案信息
	var claimTask=getClaimTaskJson();
	var notification_person=getNotification_person();
	//第三方投保信息
	var clmInsuranceComs=getClmInsuranceComs();
	//第三方赔付信息
	var clmDisnormalRecords=getClmDisnormalRecords();
	//事件信息
	var clmEndCaseEventVos=getEventInfoJson();
	if(clmEndCaseEventVos=="01"){
		return "01";
	}
	//资料信息
	var clmResources=getClmResources();
	//理赔预估信息
	var clmEstimates=getClmEstimatesJson();
	//赔付责任理赔结论
	var auditPolLiabInfos=getAuditPolLiabInfosJson();
	//赔付保单后续处理
	var auditPolicys=getAuditPolicysJson();
	//协谈
	var auditConsults=getAuditConsultsJson();
	//调查
	var auditInvTasks=getAuditInvTasksJson();
	//补充资料
	var auditConsultResources=getAuditConsultResourcesJson();
	//超额件
	var auditConsults2=getAuditConsults2Json();
	var accTypesBy=$("#accTypesBy_").val();
	
	var receiptDate=getValById('receiptDate');//快递签收时间
	//差错件
	var isError=$("#isErrorVal").attr("class")=='check_yes'?'Y':'N';
	//收单单位
	var companyNo=getValById('companyNo');
//	getDrawMoney();//获取支付比例，金额
	//领款人信息，ClmPayeeLiab
//	var clmPayeeLiabs=getClmPayeeLiabsJson();
//	savePayeeInfo('0');//保存领款人信息
	var clmPayeeLiabs=getClmPayeeInfo();
	jsonstr='{"chmIlls":"'+chmIlls+'","clmTask":'+claimTask+',"insurance_person":'+insurance_person+',"clmReport":'+clmReport+',"benefit_persons":['+benefit_persons+'],"notification_person":'+notification_person
			+',"claimAccType":"'+accTypesBy+'","clmInsuranceComs":['+clmInsuranceComs+'],"clmDisnormalRecords":['+clmDisnormalRecords+'],"clmEndCaseEventVos":['+clmEndCaseEventVos
			+'],"clmResources":['+clmResources+'],"clmEstimates":['+clmEstimates+'],"auditPolLiabInfos":['+auditPolLiabInfos+'],"auditPolicys":['+auditPolicys+'],"auditConsults":['+auditConsults+'],"auditInvTasks":['+auditInvTasks
			+'],"auditConsultResourceVos":['+auditConsultResources+'],"auditOption":"'+getValById('auditOption')+'","reAuditOption":"'+getValById('reAuditOption')+'","receiptDate":"'+receiptDate+'","companyNo":"'+companyNo
			+'","auditConsults2":['+auditConsults2+'],"hangUpSign":"'+getValById('hangUpSign')+'","isError":"'+isError+'","clmPayeeLiabs":['+clmPayeeLiabs+']}';
	return jsonstr;
}
//保存数据
function saveEndCaseData(){
	var claimNo=getValById('hclaimNo');
	var flag=checkEndCaseData('1');
	if(flag){
		var jsonstr=getSaveDataJson();
		if(jsonstr=="01"){
			alert('事件信息：入院日期不能早于出院日期');
			return;
		}
		$.ajax({
			type:"POST",
			url:"/claimserver/epiboly/saveEpibolyData.do",
			contentType:"application/json; charset=UTF-8",
			data:jsonstr,
			success:function(){
				alert("保存成功");
				location="/claimserver/epiboly/findEpibolyData.do?claimNo="+claimNo;
			},error:function(e){
				alert('保存失败');
			}
		});
	}
	
	
}


//ClaimTask
function getClaimTaskJson(){
	var isMail=getValById('clmTaskIsMail');
	isMail=isMail=="-1"?"":isMail;
	str='{"claimNo":"'+getValById('hclaimNo')+'","companyNo":"'+getValById('companyName')+'","isMail":"'+isMail+'"}';
	return str;
	
}
//report信息
function getClmReportJson(){
	var repInsRelationship=$("#repInsRelationship").val();
	if(repInsRelationship==""){
		repInsRelationship=$("#hrepInsRelationship").val();
	}
	repInsRelationship=repInsRelationship=="请选择类型"?"":repInsRelationship;
	str='{"repInsRelationship":"'+repInsRelationship+'","reportDate":"'+$("#reportDate").val()
		+'","accidentDate":"'+$("#accidentDate").val()+'","firstDiagnoseDate":"'+$("#firstDiagnoseDate").val()
		+'","accidentaddrtype":"'+$("#accidentaddrtype").val()+'","accidentCode":"'+$("#accidentCode").val()
		+'","accidentDesc":"'+$("#accidentDesc").val()+'","claimDate":"'+getValById('claimDate')+'"}';
	return str;
}
//资料信息
function getClmResources(){
	var materialTbltr=$("#materialTbl tr");
	str="";
	for(var i=1;i<materialTbltr.length;i++){
		var tr=$(materialTbltr[i]);
		var id=tr.attr("id");
		var resourceNo=tr.find("input[name='resourceNo']").val();
		var resourceName=tr.find("input[name='resourceName']").val();
		var resourceOriginal=tr.find("select[name='resourceOriginal']").val();
		id=id==undefined?"":id;
		str+='{"id":"'+id+'","resourceNo":"'+resourceNo+'","resourceName":"'+resourceName+'","original":"'+resourceOriginal+'"},';
	}
	if(str!=""){
		return str.substring(0,str.length-1);
	}else{
		return "";
	}
	
}
//CustomerInfo被保人信息
function getCustomerInfoJson(){
	var sflag=$("#isButtonFlag").val();
	if(sflag=="Y"){
		str='{"customerno":"'+getValById('customerno')+'","name":"'+$("#name").val()+'","sex":"'+getValById('customerInfosex')+'","idtype":"'+$("#customerInfoIdtype").val()
		+'","pid":"'+$("#customerInfoPid").val()+'","job":"'+$("#customerInfojob").val()
		+'","caddr":"'+$("#customerInfoCaddr").val()+'","bthdate":"'+$("#customerInfobthdate").val()+'"}';
	}else{
		str='{"customerno":"'+getValById('customerno')+'","name":"'+$("#name").val()+'","sex":"'+getValById('customerInfosex')+'","idtype":"'+$("#customerInfoIdtype").val()
		+'","pid":"'+$("#customerInfoPid").val()+'","job":"'+$("#customerInfojob").val()
		+'","caddr":"'+$("#customerInfoCaddr").val()+'"}';
	}
	
	/*str='{"customerno":"'+getValById('customerno')+'","name":"'+$("#name").val()+'","sex":"'+getValById('customerInfosex')+'","idtype":"'+$("#customerInfoIdtype").val()
	+'","pid":"'+$("#customerInfoPid").val()+'","job":"'+$("#customerInfojob").val()
	+'","caddr":"'+$("#customerInfoCaddr").val()+'"}';*/
	
	return str;
}
//事件信息
function getEventInfoJson(){
	str="";
	var eventInfoTbltr=$("#eventInfoTbl tr");
	for(var i=1;i<eventInfoTbltr.length;i++){
		var tr=$(eventInfoTbltr[i]);
		var id=tr.attr("id");
		var claimEventNo=tr.find("input[name='claimEventNo']").val();//事件号
		var eventClaimAccType=tr.find("select[name='eventClaimAccType']").val();//索赔事故性质
		var claimIllsBy_=tr.find("input[name='claimIllsBy_']").val();//疾病代码str
		var visitDate=tr.find("input[name='visitDate']").val();//就诊日期
		var admissionDate=tr.find("input[name='admissionDate']").val();//入院日期
		var dischargeDate=tr.find("input[name='dischargeDate']").val();//出院日期
		var hospitalizedDays=tr.find("input[name='hospitalizedDays']").val();//住院天数
		var deadDate=tr.find("input[name='deadDate']").val();//身故日期
		var maimDate=tr.find("input[name='maimDate']").val();//伤残鉴定日期
		var hospitalCode=tr.find("input[name='hospitalCode']").val();//就诊医院代码
		var hospitalName=tr.find("input[name='hospitalName']").val();//就诊医院名称
		var doctorName=tr.find("input[name='doctorName']").val();//主治医生姓名
		var surgeryCode=tr.find("input[name='surgeryCode']").val();//手术代码
		var zjIllsBy_=tr.find("input[name='zjIllsBy_']").val();//重疾代码
		var socialMedicalType=tr.find("select[name='socialMedicalType']").val();//医保类型
		var isChangeHospital=tr.find("select[name='isChangeHospital']").val();//是否转诊
		var fromHospitalName=tr.find("input[name='fromHospitalName']").val();//转来医院名称
		var fromHospitalDeptName=tr.find("input[name='fromHospitalDeptName']").val();//科室名称
		var fromHospitalDoctorName=tr.find("input[name='fromHospitalDoctorName']").val();//医生姓名
		var expectedDate=tr.find("input[name='expectedDate']").val();//预产期
		var isSingleEmbryo=tr.find("select[name='isSingleEmbryo']").val();//预期是否单胎
		var isUseAssistMedical=tr.find("select[name='isUseAssistMedical']").val();//是否使用妊娠辅助医疗或人工授精
		var pregnancyMemo=tr.find("input[name='pregnancyMemo']").val();//具体情况
		var auditConclusion=tr.find("input[name='auditConclusion']").val();//事件审核结论
		var auditOption=tr.find("input[name='auditOption']").val();//事件审核意见
		
		var illnessCode='';//疾病诊断
		
		var comein = parseInt(admissionDate.replace("-", "").replace("-", ""));
		var goout = parseInt(dischargeDate.replace("-", "").replace("-", ""));
		
		if( comein > goout){
			return "01";
		}
		
		id=id==undefined?"":id;
		if(id.indexOf("tr")>-1){
			id="";
		}
		if(claimIllsBy_!=''){
			var array=claimIllsBy_.split("_");
			illnessCode=array[0];//取第一个疾病诊断代码
		}
		str+='{"evntMedicalEvent":{"objId":"'+id+'","claimEventNo":"'+claimEventNo+'","visitDate":"'+visitDate+'","admissionDate":"'+admissionDate+'","dischargeDate":"'+dischargeDate
				+'","hospitalizedDays":"'+hospitalizedDays+'","hospitalizedDays":"'+hospitalizedDays+'","deadDate":"'+deadDate
				+'","maimDate":"'+maimDate+'","hospitalCode":"'+hospitalCode+'","hospitalName":"'+hospitalName+'","doctorName":"'+doctorName
				+'","surgeryCode":"'+surgeryCode+'","illnessCode":"'+illnessCode+'","socialMedicalType":"'+socialMedicalType+'","isChangeHospital":"'+isChangeHospital
				+'","fromHospitalName":"'+fromHospitalName+'","fromHospitalDeptName":"'+fromHospitalDeptName+'","fromHospitalDoctorName":"'+fromHospitalDoctorName
				+'","expectedDate":"'+expectedDate+'","isSingleEmbryo":"'+isSingleEmbryo+'","isUseAssistMedical":"'+isUseAssistMedical
				+'","pregnancyMemo":"'+pregnancyMemo+'","auditConclusion":"'+auditConclusion+'","auditOption":"'+auditOption+'"},"claimAccType":"'+eventClaimAccType+'","claimIllsBy_":"'+claimIllsBy_+'","zjIllsBy":"'+getVal(zjIllsBy_)+'"},';
		
	}
	if(str!=""){
		return str.substring(0,str.length-1);
	}else{
		return "";
	}
}
function onclickIdtype(obj){
	var idtype=$(obj).attr("code");
	$("#customerInfoIdtype").val(idtype);
}
function selCode(obj,id){
	var code=$(obj).attr("code");
	$("#"+id).val(code);
}
function selRepInsRelationship(obj){
	var repInsRelationship=$(obj).attr("code");
	$("#repInsRelationship").val(repInsRelationship);
}
//报案
function reportCase(){
	var flag=checkEndCaseData('2');
	if(flag){
		$("#reportCasebtn").removeAttr("onclick");
		var jsonStr=getSaveDataJson();
//		var hclaimNo=$("#hclaimNo").val();
		$.ajax({
			type:"POST",
			contentType:"application/json; charset=UTF-8",
			url:"/claimserver/epiboly/reportCase.do",
			data:jsonStr,
			error :function(){
				alert("报案失败！");
				$("#reportCasebtn").attr("onclick","reportCase()");
			},
			success :function(data){
				if(data.errorCode=='00'){
					alert('报案成功');
//					SkipByPost("/claimserver/epiboly/findEpibolyData.do",{claimNo:hclaimNo});
					$("#hclaimSubState").val("07");
					//初始化按钮
					initMenuBtn();
					
				}else{
					alert('报案失败！');
					$("#reportCasebtn").attr("onclick","reportCase()");
				}
				
			}
		});
	}
	
}
//立案
function submitFiledCase(){
//	var hclaimNo=$("#hclaimNo").val();
	var flag=checkEndCaseData('3');
	if(flag){
		$("#submitFiledCase").removeAttr("onclick");
		var jsonstr=getSaveDataJson();
		$.ajax({
			type:"POST",
			url:"/claimserver/epiboly/submitFiledCase.do",
			contentType:"application/json; charset=UTF-8",
			data:jsonstr,
			success:function(data){
				if(eval(data.isBool)){
					alert("立案完成！");
//					SkipByPost("/claimserver/epiboly/findEpibolyData.do",{claimNo:hclaimNo});
					if(data.claimSubState=='09'){//待结案
						$("#hclaimSubState").val("09");
					}else{
						$("#hclaimSubState").val("08");
					}
					//初始化按钮
					initMenuBtn();
				}else{
					alert(data.errMsg);
					$("#submitFiledCase").attr("onclick","submitFiledCase()");
					
				}
			},error:function(e){
				alert('立案失败');
				$("#submitFiledCase").attr("onclick","submitFiledCase()");
				
			}
		});
	}
	
	
}
//结案
function submitEndCase(){
	var flag=checkEndCaseData('4');
	if(flag){
		$("#endCasebtn").removeAttr("onclick");
		var jsonstr=getSaveDataJson();
		$.ajax({
			type:"POST",
			url:"/claimserver/epiboly/submitEndCase.do",
			contentType:"application/json; charset=UTF-8",
			data:jsonstr,
			success:function(data){
				if(data.error=="2"){//结案成功
					alert('结案成功');
					location="/claimserver/epibolyModify/queryEpibolyPage.do";
				}else{
					alert(data.error);
					$("#endCasebtn").attr("onclick","submitEndCase()");
				}
			},error:function(e){
				$("#endCasebtn").attr("onclick","submitEndCase()");
				alert('结案失败');
			}
		});
	}
	
	
}
//通知书下载
function noticeDownload(){
	$("#noticeDownload").removeAttr("onclick");
	var ipAddress=$("#ipAddress").val();
	$.ajax({
		type:"post",
		url:"/claimserver/epiboly/hasFileOfClaimNo.do",
		data:{"claimNo":$("#hclaimNo").val()},
		error:function(){
		},
		success:function(data){
			if(data=="1"){
//				SkipByPost("http://localhost:8081/claimserver/epiboly/noticeDownload.do",{claimNo:$("#hclaimNo").val()});	
				SkipByPost(ipAddress+"/claimserver/epiboly/noticeDownload.do",{claimNo:$("#hclaimNo").val()});	
			}else{
				alert("通知书已上传到影像系统");
			}
		}
	});
	
}
//失败原因
function queryCheckReason(claimNo){
	$.ajax({
		type:"POST",
		url:"/claimserver/inspection/clmtask/queryCheckReason.do",
		data:{"claimNo":claimNo},
		error:function(){
			alert("查询失败原因失败！");
			return;
		},
		success:function(data){
			$("#checkReason").html('');
			
			if(data==null || data==""){				
				$("#checkReason").append("<tr><td colspan=\"7\">没有失败原因！</td></tr>");
			}else{
				var tr='';
				for(var i= 0; i < data.length; i++){
					var h = data[i];
					var qctreason=h.qctreason==null?"":h.qctreason;
					tr+="<tr><td>"+qctreason+"</td></tr>";
				}
				$("#checkReason").append(tr);
			}
		}
	});
}
//报案人信息
function getNotification_person(){
	str='{"personId":"'+getValById('personId')+'","idtype":"'+$("#clmPersonidtype").val()+'","pid":"'+$("#reportPersonpid").val()+'","name":"'+$("#clmPersonname").val()
			+'","sex":"'+$("#clmPersonsex").val()+'","phone":"'+$("#clmPersonPhone").val()+'","tel":"'+$("#clmPersonTel").val()
			+'","email":"'+$("#clmPersonEmail").val()+'","contractAddr":"'+$("#contractAddr").val()+'","postCode":"'+$("#clmPersonPostCode").val()+'"}';
	return str;
}
//领款人信息
function getBenefit_personJson(){
	var objid="";
	var benefit_personTbl_trs=$("#benefit_personTbl tr");//领款人信息
	str="";
//	var idMap={};
	var pidMap={};
	var claimNo=$("#hclaimNo").val();
	if(benefit_personTbl_trs.length>1){
		for(var i=1;i<benefit_personTbl_trs.length;i++){
			var tr=$(benefit_personTbl_trs[i]);
			objid=tr.attr("id");
			var claimPayeeType=tr.find("select[name='selclaimPayeeType']").val();//领款人类型
			var payeeInsRelationship=tr.find("select[name='payeeInsRelationship']").val();//与被保人关系
			var claimPayeeIdType=tr.find("select[name='claimPayeeIdType']").val();//证件类型
			var claimPayeeId=tr.find("input[name='claimPayeeId']").val();//证件号码
			var claimPayeeName=tr.find("input[name='claimPayeeName']").val();//姓名
			var claimPayeeGenderCode=tr.find("select[name='claimPayeeGenderCode']").val();//性别
			var payeePhone=tr.find("input[name='payeePhone']").val();//移动电话
			var payeeTel=tr.find("input[name='payeeTel']").val();//固定电话
			var payeeEmail=tr.find("input[name='payeeEmail']").val();//邮箱地址
			var payeeContractAddr=tr.find("input[name='payeeContractAddr']").val();//联系地址
			var payeePostCode=tr.find("input[name='payeePostCode']").val();//邮政编码
			var payMode=tr.find("select[name='payMode']").val();//支付方式
			var bankName=tr.find("input[name='bankName']").val();//银行名称
//			var bankSubName=tr.find("input[name='bankSubName']").val();//开户行
			var payeeProvince=tr.find("select[name='payeeProvince']").val();//银行所在省代码
			var payeeCityCode=tr.find("select[name='payeeCityCode']").val();//银行所在市代码
//			var bankAccountName=tr.find("input[name='bankAccountName']").val();//公司账户名称
			var bankAccountNo=tr.find("input[name='bankAccountNo']").val();//银行账号
			var bankCode=tr.find("input[name='bankCode']").val();//银行代码
			var bankAccountName=tr.find("input[name='bankAccountName']").val();//银行账户名称
//			var payRate=tr.find("input[name='payRate']").val();//支付比例
//			objid=objid==undefined?"":objid;
			objid="";
			bankAccountName=bankAccountName==undefined?"":bankAccountName;
			if(pidMap[claimPayeeId]==undefined){
				pidMap[claimPayeeId]=claimPayeeId;
				str+='{"objid":"'+objid+'","claimNo":"'+claimNo+'","claimPayeeType":"'+claimPayeeType+'","payeeInsRelationship":"'+payeeInsRelationship
				+'","claimPayeeIdType":"'+claimPayeeIdType+'","claimPayeeId":"'+claimPayeeId+'","claimPayeeName":"'+claimPayeeName
				+'","claimPayeeGenderCode":"'+claimPayeeGenderCode+'","payeePhone":"'+payeePhone+'","payeeTel":"'+payeeTel+'","payeeEmail":"'+payeeEmail
				+'","payeeContractAddr":"'+payeeContractAddr+'","payeePostCode":"'+payeePostCode+'","payMode":"'+payMode
				+'","bankName":"'+bankName+'","payeeProvince":"'+payeeProvince
				+'","payeeCityCode":"'+payeeCityCode+'","bankAccountNo":"'+bankAccountNo+'","bankCode":"'+bankCode+'","bankType":"'+bankCode
				+'","bankSubName":"'+payeeCityCode+'","bankAccountName":"'+bankAccountName+'"}';
				if(i!=benefit_personTbl_trs.length-1){
					str+=',';
				}
			}
			/*if(objid==""){//新增
				str+='{"objid":"'+objid+'","claimPayeeType":"'+claimPayeeType+'","payeeInsRelationship":"'+payeeInsRelationship
				+'","claimPayeeIdType":"'+claimPayeeIdType+'","claimPayeeId":"'+claimPayeeId+'","claimPayeeName":"'+claimPayeeName
				+'","claimPayeeGenderCode":"'+claimPayeeGenderCode+'","payeePhone":"'+payeePhone+'","payeeTel":"'+payeeTel+'","payeeEmail":"'+payeeEmail
				+'","payeeContractAddr":"'+payeeContractAddr+'","payeePostCode":"'+payeePostCode+'","payMode":"'+payMode
				+'","bankName":"'+bankName+'","payeeProvince":"'+payeeProvince
				+'","payeeCityCode":"'+payeeCityCode+'","bankAccountNo":"'+bankAccountNo+'","bankCode":"'+bankCode+'","bankType":"'+bankCode+'"}';
			}else{
				if(idMap[objid]==undefined){
					str+='{"objid":"'+objid+'","claimPayeeType":"'+claimPayeeType+'","payeeInsRelationship":"'+payeeInsRelationship
					+'","claimPayeeIdType":"'+claimPayeeIdType+'","claimPayeeId":"'+claimPayeeId+'","claimPayeeName":"'+claimPayeeName
					+'","claimPayeeGenderCode":"'+claimPayeeGenderCode+'","payeePhone":"'+payeePhone+'","payeeTel":"'+payeeTel+'","payeeEmail":"'+payeeEmail
					+'","payeeContractAddr":"'+payeeContractAddr+'","payeePostCode":"'+payeePostCode+'","payMode":"'+payMode
					+'","bankName":"'+bankName+'","payeeProvince":"'+payeeProvince
					+'","payeeCityCode":"'+payeeCityCode+'","bankAccountNo":"'+bankAccountNo+'","bankCode":"'+bankCode+'","bankType":"'+bankCode+'"}';
					idMap[objid]=objid;
				}
			}*/
			
			
		}
	}
	return str;
}
function getClmEstimatesJson(){
	var clmEstimatesTbltr=$("#clmEstimatesTbl tr");
	str="";
	for(var i=1;i<clmEstimatesTbltr.length;i++){
		var tr=$(clmEstimatesTbltr[i]);
		var id=tr.attr("id");
		var policyNo=tr.find("td[name='policyNo']").html();
//		var classCode=tr.find("input[name='classCode']").val();
		var estamt=tr.find("input[name='estamt']").val();
		str+='{"id":"'+id+'","policyNo":"'+policyNo+'","estamt":"'+estamt+'"},';
	}
	if(str!=""){
		return str.substring(0,str.length-1);
	}else{
		return "";
	}
}
//第三方投保 信息
function getClmInsuranceComs(){
	str="";
	var third_insuranceTbltr=$("#third_insuranceTbl tr");
	for(var i=1;i<third_insuranceTbltr.length;i++){
		var tr=$(third_insuranceTbltr[i]);
		var id=tr.attr("id");
		var insuranceComName=tr.find("input[name='insuranceComName']").val();
		var policyName=tr.find("input[name='policyName']").val();
		var policyNo=tr.find("input[name='policyNo']").val();
		id=id==undefined?"":id;
		str+='{"id":"'+id+'","insuranceComName":"'+insuranceComName+'","policyName":"'+policyName+'","policyNo":"'+policyNo+'"},';
	}
	if(str==""){
		return "";
	}else{
		return str.substring(0,str.length-1);
	}
	
}
//第三方赔付信息
function getClmDisnormalRecords(){
	str="";
	var third_payTbltr=$("#third_payTbl tr");
	for(var i=1;i<third_payTbltr.length;i++){
		var tr=$(third_payTbltr[i]);
		var id=tr.attr("id");
		var companyName=tr.find("input[name='companyName']").val();
		var claimAmt=tr.find("input[name='claimAmt']").val();
		id=id==undefined?"":id;
		str+='{"id":"'+id+'","companyName":"'+companyName+'","claimAmt":"'+claimAmt+'"},';
	}
	if(str==""){
		return "";
	}else{
		return str.substring(0,str.length-1);
	}
}
//赔付责任理赔结论
function getAuditPolLiabInfosJson(){
	var polLiabInfosTbltrs=$("#polLiabInfosTbl tr");
	str="";
	for(var i=1;i<polLiabInfosTbltrs.length;i++){
		var tr=$(polLiabInfosTbltrs[i]);
		var id=tr.attr("id");
		id=id==undefined?'':id;
		var policyNo=tr.find("td[name='policyNo']").html();
		policyNo=policyNo==undefined?'':policyNo;
//		var classCode=tr.find("input[name='classCode']").val();//险种代码
//		var delCode=tr.find("input[name='delCode']").val();//责任代码
//		var typeNo=tr.find("input[name='typeNo']").val();//责任代码
		var realClmAmt=tr.find("input[name='realClmAmt']").val();
		var resCode=tr.find("select[name='resCode']").val();
		resCode=resCode==undefined?'':resCode;
		var resReason;
		if(tr.find("input[name='resReason']").val()==undefined){
			resReason=tr.find("select[name='resReason']").val();
		}else{
			resReason=tr.find("input[name='resReason']").val();
		}
//		var resReason=tr.find("input[name='resReason']").val()==undefined?tr.find("input[name='resReason']").val():("select[name='resReason']").val();
		str+='{"objId":"'+id+'","policyNo":"'+policyNo+'","realClmAmt":"'+realClmAmt+'","resReason":"'+resReason+'","resCode":"'+resCode+'"},';
	}
	if(str!=""){
		return str.substring(0, str.length-1);
	}else{
		return  "";
	}
}
//赔付保单后续处理
function getAuditPolicysJson(){
	var auditPolicysTbltrs=$("#auditPolicysTbl tr");
	str="";
	for(var i=1;i<auditPolicysTbltrs.length;i++){
		var tr=$(auditPolicysTbltrs[i]);
		var id=tr.attr("id");
//		var policyNo=tr.find("input[name='policyNo']").val();//保单号
		var isTerminationPol=tr.find("select[name='isTerminationPol']").val();//是否终止
		var isClause=tr.find("select[name='isClause']").val();//是否解约
		var isRefund=tr.find("select[name='isRefund']").val();//是否退费
		var isRenewal=tr.find("select[name='isRenewal']").val();//是否续保
		str+='{"id":"'+id+'","isTerminationPol":"'+isTerminationPol+'","isClause":"'
			+isClause+'","isRefund":"'+isRefund+'","isRenewal":"'+isRenewal+'"},';
	}
	if(str!=""){
		return str.substring(0, str.length-1);
	}else{
		return  "";
	}
}
//调查
function getAuditInvTasksJson(){
	var auditInvTasksTbltrs=$("#auditInvTasksTbl tr");
	str="";
	for(var i=1;i<auditInvTasksTbltrs.length;i++){
		var tr=$(auditInvTasksTbltrs[i]);
		var clmAuditInvNo=tr.attr("id");
		var invNature=tr.find("select[name='invNature']").val();//任务性质
		var taskSubType=tr.find("select[name='taskSubType']").val();//任务子类型
		var invType=tr.find("select[name='invType']").val();//调查方式
		var invContent=tr.find("input[name='invContent']").val();//调查要求
		var invFeedbackContent=tr.find("input[name='invFeedbackContent']").val();//调查结果
		var invAppDate=tr.find("input[name='invAppDate']").val();//申请日期
		var invFeedbackDate=tr.find("input[name='invFeedbackDate']").val();//反馈日期
		var invgrpman=tr.find("input[name='invgrpman']").val();//调查员 
		str+='{"clmAuditInvNo":"'+clmAuditInvNo+'","invNature":"'+invNature+'","taskSubType":"'+taskSubType+'","invType":"'+invType+'","invFeedbackContent":"'+invFeedbackContent
			+'","invContent":"'+invContent+'","invAppDate":"'+invAppDate+'","invFeedbackDate":"'+invFeedbackDate+'","invgrpman":"'+invgrpman+'"},';
	}
	if(str!=""){
		return str.substring(0, str.length-1);
	}else{
		return "";
	}
}
//协谈
function getAuditConsultsJson(){
	str="";
	var auditConsultsTbltrs=$("#auditConsultsTbl tr");
	for(var i=1;i<auditConsultsTbltrs.length;i++){
		var tr=$(auditConsultsTbltrs[i]);
		var clmConsultNo=tr.attr("id");
		var consultClaimResult=tr.find("input[name='consultClaimResult']").val();//协查理赔结论
		var consultContent=tr.find("input[name='consultContent']").val();//协谈申请
		var feedbackContent=tr.find("input[name='feedbackContent']").val();//协查结果
		var applyDate=tr.find("input[name='applyDate']").val();//申请日期
		var feedbackDate=tr.find("input[name='feedbackDate']").val();//反馈日期
		var feedbackEmpName=tr.find("input[name='feedbackEmpName']").val();//协谈员
		str+='{"clmConsultNo":"'+clmConsultNo+'","consultClaimResult":"'+consultClaimResult+'","consultContent":"'+consultContent+'","feedbackContent":"'
			+feedbackContent+'","applyDate":"'+applyDate+'","feedbackDate":"'+feedbackDate+'","feedbackEmpName":"'+feedbackEmpName+'"},';
	}
	if(str!=""){
		return  str.substring(0, str.length-1);
	}else{
		return "";
	}
	
}
//补充资料
function getAuditConsultResourcesJson(){
	str="";
	var auditConsultResourcesTbltrs=$("#auditConsultResourcesTbl tr");
	for(var i=1;i<auditConsultResourcesTbltrs.length;i++){
		var tr=$(auditConsultResourcesTbltrs[i]);
		var objId=tr.attr("id");
		var resourceNo=tr.find("select[name='resourceName']").val();//
		var resourceName=tr.find("select[name='resourceName'] option:selected").text();//资料名称
		var applyDate=tr.find("input[name='applyDate']").val();//申请日期
		var feedbackDate=tr.find("input[name='feedbackDate']").val();//反馈日期
		var consultEmpNo=tr.find("input[name='consultEmpNo']").val();//审核员
		objId=objId==undefined?"":objId;
		str+='{"objId":"'+objId+'","resourceNo":"'+resourceNo+'","resourceName":"'+resourceName+'","applyDate":"'+applyDate+'","feedbackDate":"'+feedbackDate+'","consultEmpNo":"'+consultEmpNo+'"},';
	}
	if(str!=""){
		return str.substring(0, str.length-1);
	}else{
		return "";
	}
}
//超额件
function getAuditConsults2Json(){
	str="";
	var auditConsults2Tbltrs=$("#auditConsults2Tbl tr");
	for(var i=1;i<auditConsults2Tbltrs.length;i++){
		var tr=$(auditConsults2Tbltrs[i]);
		var clmConsultNo=tr.attr("id");
		var consultClaimResult=tr.find("input[name='consultClaimResult']").val();//超额件 审核 结论
		var applyDate=tr.find("input[name='applyDate']").val();//申请日期
		var feedbackDate=tr.find("input[name='feedbackDate']").val();//申请日期
		var feedbackEmpName=tr.find("input[name='feedbackEmpName']").val();//审核员
		clmConsultNo=clmConsultNo==undefined?"":clmConsultNo;
		str+='{"clmConsultNo":"'+clmConsultNo+'","consultClaimResult":"'+consultClaimResult+'","applyDate":"'+applyDate+'","feedbackDate":"'+feedbackDate
			+'","feedbackEmpName":"'+feedbackEmpName+'"},';
	}
	if(str!=""){
		return str.substring(0, str.length-1);
	}else{
		return "";
	}
}
//删除事件信息
function delEventTblTr(){
	var index=-1;
	var tbl=$("#eventInfoTbl");
	index=tbl.find("input[name='deltrIndex']").val();
	if(index>0){
		tbl.find("input[name='deltrIndex']").val("-1");
		var claimNo=$("#hclaimNo").val();
		var eventNo=tbl.find("tr:eq("+index+") input[name='claimEventNo']").val();
		if(confirm("确定要删除当前行吗？")){
			$.ajax({
				type:"POST",
				url:"/claimserver/epiboly/delEventInfo.do",
				data:{claimNo:claimNo,eventNo:eventNo},
				success:function(){
					tbl.find("tr:eq("+index+")").remove();
					alert("删除成功！");
				},
				error:function(){
					alert("删除失败！");
				}
			});
		}
	}else{
		alert("请选择数据行!");
	}
}
//删除领款人信息行
function delBenefitPersonTr(){
	var tbl=$("#benefit_personTbl");
	var index=tbl.find("input[name='deltrIndex']").val();
	if(index>-1){
		if(confirm("确定要删除当前行吗？")){
			tbl.find("tr:eq("+index+")").remove();
		}
	}else{
		alert("请选择一行！");
	}
	
}
//添加领款人信息
function addBenefitPersonTr(){
	var claimPayeeOption='<option value="">请选择领款人类型</option><option value="1">个人</option><option value="2">单位</option>';
	var claimPayeeIdType='<option value="">请选择</option><option value="a">身份证</option><option value="c">护照</option><option value="d">军官证</option><option value="j">港澳台护照</option><option value="l">台湾居民通行证</option><option value="z">其他</option>';
	var payeeInsRelationship='<option value="">请选择</option><option value="401">本人</option><option value="402">配偶</option><option value="403">父子</option><option value="404">父女</option>'
		+'<option value="405">受益人</option><option value="406">被保人</option><option value="407">投保人</option><option value="408">其他</option><option value="409">母子</option><option value="410">母女</option>'
		+'<option value="411">兄弟</option><option value="412">姊妹</option><option value="413">兄妹</option><option value="414">姐弟</option><option value="415">祖孙</option><option value="416">雇佣</option><option value="417">业务员</option>';
	var classCodeOption=$("#hclassCodes").html();
	var payeeProvince='';
	if(provinceCodeStr!=''){
		var provinces=provinceCodeStr.split(",");
		for(var i=0;i<provinces.length;i++){
			var array=provinces[i].split(":");
			payeeProvince+='<option value="'+array[0]+'">'+array[1]+'</option>';
		}
	}
	
	var trStr='<tr onclick="selTblTr(this,\'benefit_personTbl\')"><td><select name="selclaimPayeeType" onchange="claimPayeeTypeFn(this)">'+claimPayeeOption+'</select></td><td><select name="payeeInsRelationship">'+payeeInsRelationship+'</select></td><td><select name="claimPayeeIdType">'+claimPayeeIdType+'</select></td>'
				+'<td><input name="claimPayeeId" type="text" maxlength="30" /></td><td><input name="claimPayeeName" maxlength="30"  type="text" /></td><td><select name="claimPayeeGenderCode"><option value="">请选择</option><option value="1">男</option><option value="2">女</option></select></td>'
				+'<td><input name="payeePhone" type="text" maxlength="11" /></td><td><input name="payeeTel" type="text" maxlength="30"/></td><td><input name="payeeEmail" type="text" maxlength="50"/></td><td><input name="payeeContractAddr" type="text" maxlength="200"/></td><td><input name="payeePostCode" type="text" maxlength="6"/></td>'
				+'<td><select name="payMode"><option value="">请选择</option><option value="1">现金</option><option value="2">支票</option><option value="3">转账</option></select></td><td><input name="bankName" type="text" onfocus="selBankName(this)"	onkeydown="tipSearch(1,'+($("#benefit_personTbl tr").length-1)+')" onkeyup="tipSearch(1,'+($("#benefit_personTbl tr").length-1)+')" autocomplete="off" id="propertyBankName_'+($("#benefit_personTbl tr").length-1)+'" /><input id="bankCode_'+($("#benefit_personTbl tr").length-1)+'" name="bankCode" type="hidden" /></td>'
				+'<td><input type="hidden" name="hpayeeProvince" /><select name="payeeProvince" onchange="getPayeeCity(\'\',this)"><option value="">请选择</option>'+payeeProvince+'</select></td><td><input type="hidden" name="hpayeeCityCode" /><select name="payeeCityCode"><option value="">请选择</option></select></td>'
				+'<td><input maxlength="25" name="bankAccountNo" type="text" maxlength="25" /></td></tr>';	
	//<td><input name="policyNo" type="text"/><input name="hPayeeLiabId" type="hidden"/></td><td><select name="classCode">'+classCodeOption+'</select></td>'
	//+'<td><input name="delCode" type="text" /></td><td><input name="payLiabDrawMoney" type="text" /></td>
	$("#benefit_personTbl").append(trStr);
}

//添加资料清单行
function addClmResourcesTr(){
	var trStr='<tr onclick="selTblTr(this,\'materialTbl\')"><td><input type="text" name="resourceNo" maxlength="6"/></td><td><input type="text" name="resourceName" maxlength="300"/></td>'+
			'<td><select name="resourceOriginal"><option value="">请选择</option><option value="1" >是</option><option value="0" >否</option></select></td></tr>';
	$("#materialTbl").append(trStr);
}
//删除资料清单行
function delClmResourcesTr(){
	var tbl=$("#materialTbl");
	var index=tbl.find("input[name='deltrIndex']").val();
	tbl.find("tr:eq("+index+")").remove();
}
//添加第三方投保信息
function addThird_insuranceTr(){
	var trStr='<tr onclick="selTblTr(this,\'third_insuranceTbl\')"><td><input type="text" name="insuranceComName" maxlength="300"/></td><td><input type="text" name="policyName" maxlength="180" /></td><td><input type="text" name="policyNo" maxlength="30" /></td></tr>';
	$("#third_insuranceTbl").append(trStr);
}
//添加第三方赔付
function addthird_payTblTr(){
	var trStr='<tr id="" onclick="selTblTr(this,\'third_payTbl\')"><td><input type="text" name="companyName" /></td><td><input type="text" name="claimAmt" /></td></tr>';
	$("#third_payTbl").append(trStr);
}
//添加事件信息
function addEventInfoTblTr(){
	var claimAccType='<option value="">请选择</option><option  value="01">身故</option><option  value="02">伤残</option><option  value="03">重大疾病</option><option  value="04">门诊医疗</option>'
					+'<option  value="05">住院医疗</option><option  value="06">住院补贴</option><option  value="07">女性生育</option><option value="08">牙科</option><option  value="09">眼科</option>'
					+'<option  value="10">门诊大病</option><option  value="11">紧急牙科</option><option  value="12">药房购药</option><option  value="13">体检</option><option  value="14">女性疾病</option>';
	var str='<option value="">请选择</option><option value="Y">是</option><option value="N">否</option>';
	var socialMedicalType='<option value="">请选择</option><option value="1" >有医保</option><option value="2">无医保</option>';
	var isChangeHospital='<option value="">请选择</option><option value="Y">是</option><option value="N">否</option>';
	var tbl=$("#eventInfoTbl");
	var id=tbl.find("tr:last").attr("id");
	var index=-1;
	if(id!=undefined&&id.indexOf("tr")>-1){//新增的行
		index=parseInt(id.replace("tr",""));
		index++;
	}else{
		index=1;
	}
	var trStr='<tr id="tr'+index+'" onclick="selTblTr(this,\'eventInfoTbl\')"><td>	<input type="hidden" name="claimEventNo"/><select name="eventClaimAccType">'+claimAccType+'</select></td>'
			+'<td width="40%"><div style="width: 180px;"><input type="text" name="clmIll"  readonly="readonly" style="width: 90px;"   ondblclick="showjbresult(\'tr'+index+'\')"/>'
			+'<a style="cursor: pointer;" class="icon_sea2" onclick="showjbDiv(\'tr'+index+'\')"></a><input type="hidden"  name="claimIllsBy_"  /><input type="hidden"  name="hclaimIllsMap"  /></div>'
			+' </td><td><input type="text" name="visitDate" readonly="readonly" onclick="WdatePicker({maxDate:\'%y-%M-%d\'})"/></td><td><input type="text" name="admissionDate" readonly="readonly" onclick="WdatePicker({maxDate:\'%y-%M-%d\',onpicked:pickedFunc})" /></td>'
			+'<td><input type="text" name="dischargeDate" readonly="readonly" onclick="WdatePicker({maxDate:\'%y-%M-%d\',onpicked:pickedFunc})" /></td><td><input type="text" name="hospitalizedDays" /></td>'
			+'<td><input type="text" name="deadDate" readonly="readonly" onclick="WdatePicker({maxDate:\'%y-%M-%d\'})" /></td><td><input type="text" name="maimDate" readonly="readonly" onclick="WdatePicker({maxDate:\'%y-%M-%d\'})" /></td>'
			+'<td><input type="text" name="hospitalCode" readonly="readonly" /></td><td><div style="width: 220px;"><input type="text" name="hospitalName" /><a style="cursor: pointer;" class="icon_sea2" onclick="hospitalDiv(\'open2\',\'tr'+index+'\')"></a>'
			+'</div></td><td><input type="text" name="doctorName" /></td><td><div style="width: 180px;"><input type="hidden"  name="surgeryCode" readonly class="input i_s_240"  /><input type="text"  name="surgeryName"  readonly="readonly" style="width: 90px;" />'
			+'<a style="cursor: pointer;" class="icon_sea2" onclick="surgeryDiv(\'open3\',\'tr'+index+'\')"></a></div></td><td><div style="width: 220px;"><input type="text" readonly="readonly"  name="zjClmIll"  ondblclick="showzjresult(\'zjresult\',\'tr'+index+'\')" />'
			+'<a style="cursor: pointer;" class="icon_sea2" onclick="showzjDiv(\'tr'+index+'\')"></a><input type="hidden"  name="zjIllsBy_"  /><input type="hidden"  name="zjIllsMap" /></div></td><td><select name="socialMedicalType">'+socialMedicalType+'</select></td>'
			+'<td><select name="isChangeHospital">'+isChangeHospital+'</select></td><td><input type="text" name="fromHospitalName" /></td><td><input type="text" name="fromHospitalDeptName" /></td>'
			+'<td><input type="text" name="fromHospitalDoctorName" /></td><td><input type="text" onclick="WdatePicker({maxDate:\'%y-%M-%d\'})" name="expectedDate" /></td><td ><select name="isSingleEmbryo">'+str+'</select></td><td><select name="isUseAssistMedical">'+str+'</select></td>'
			+'<td><input type="text" name="pregnancyMemo" /></td><td><input type="text" name="receiptCount"  /></td><td></td><td><input type="text" name="auditConclusion" /></td><td><input type="text" name="auditOption" /></td></tr>';
	$("#eventInfoTbl").append(trStr);
}
//添加理赔预估信息
function addClmEstimatesTblTr(){
	var trStr='<tr id="" onclick="selTblTr(this,\'clmEstimatesTbl\')"><td><input class="input i_s_240"  name="policyNo" /></td><td><input class="input i_s_240"  name="classCode" /></td><td><input class="input i_s_240"  name="estamt" /></td></tr>';
	$("#clmEstimatesTbl").append(trStr);
}
//添加赔付责任理赔结论
function addPolLiabInfosTblTr(){
	var option='<option value="">请选择</option><option value="01" >赔付</option><option value="02" >通融赔付</option><option value="03" >拒赔</option><option value="04" >撤案</option><option value="05" >和解</option>';
	var trStr='<tr id=""  onclick="selTblTr(this,\'polLiabInfosTbl\')"><td><input  type="text" class="i_s_240"  name="policyNo" /></td><td><input  type="text" class="i_s_240"  name="classCode" /></td>'
			+'<td><input  type="text" class="i_s_240"  /><td><input  type="text" class="i_s_240"  name="realClmAmt" /></td><td><select onchange="changeResCode(this)" name="resCode" class="i_s_240">'+ option
			+'<td><input  type="text" class="i_s_240" name="resReason" /></td></tr>';
	$("#polLiabInfosTbl").append(trStr);
}
function changeResCode(v){
	var tr = $(v).parent().parent();
	if(v.value=="01"){
		tr.find("td:eq(5)").html("");
		tr.find("td:last").append('<input  type="text" class="i_s_240"  name="resReason" />');
		tr.find("input[name='resReason']").val('符合条款约定赔付');
	}else if(v.value=="03"){
		tr.find("input[name='resReason']").remove();
		var option='<option value="非保期内出险">非保期内出险</option>'+
			'<option value="等待期出险" >等待期出险</option>'+
			'<option value="超索赔期限" >超索赔期限</option>'+
			'<option value="非保险责任(既往症)" >非保险责任(既往症)</option>'+
			'<option value="非保险责任(重大既往症)" >非保险责任(重大既往症)</option>'+
			'<option value="非保险责任(先天性疾病)" >非保险责任(先天性疾病)</option>'+
			'<option value="非保险责任(遗传性疾病)" >非保险责任(遗传性疾病)</option>'+
			'<option value="非保险责任(妊娠、生育相关)" >非保险责任(妊娠、生育相关)</option>'+
			'<option value="非保险责任(代诊)" >非保险责任(代诊)</option>'+
			'<option value="非保险责任(无症状单纯检查、配药)" >非保险责任(无症状单纯检查、配药)</option>'+
			'<option value="非保险责任(其他)" >非保险责任(其他)</option>'+
			'<option value="未投保相关险种" >未投保相关险种责任</option>'+
			'<option value="保额已满" >保额已满</option>'+
			'<option value="本收据已经理赔,不再重复处理" >本收据已经理赔,不再重复处理</option>'+
			'<option value="发票姓名与投保人不符" >发票姓名与投保人不符</option>'+
			'<option value="社保规定的自费、分类自负费用" >社保规定的自费、分类自负费用</option>'+
			'<option value="非指定医院" >非指定医院</option>'+
			'<option value="本次申请的合理费用已通过其他途径获得赔付" >本次申请的合理费用已通过其他途径获得赔付</option>'+
			'<option value="医务室配药超限" >医务室配药超限</option>'+
			'<option value="其他" >其他</option>';
		tr.find("td:eq(5)").html("");
		tr.find("td:last").append('<select name="resReason" onchange=changeResReason(this) class="i_s_240">'+option+'</select>');
	}else if(v.value=="04"){
		tr.find("td:eq(5)").html("");
		var option='<option value="理赔资料不全">理赔资料不全</option>'+
		'<option value="该收据非有效发票" >该收据非有效发票</option>'+
		'<option value="本次因生育就诊，请在分娩后一次性申请相关费用" >本次因生育就诊，请在分娩后一次性申请相关费用</option>'+
		'<option value="其他" >其他</option>';
		tr.find("td:last").append('<select name="resReason" onchange=changeResReason(this) class="i_s_240">'+option+'</select>');
	}else{
		tr.find("td:eq(5)").html("");
		tr.find("td:last").append('<input type="text" class="i_s_240" name="resReason"/>');
		tr.find("input[name='resReason']").val("");
	}
}
function changeResReason(v){
	var tr = $(v).parent().parent();
	if(v.value=="其他"){
		tr.find("td:eq(5)").html("");
		tr.find("td:last").append('<input  type="text" class="i_s_240"  name="resReason" value="其他" />');
	}
}
//添加保单赔付后续处理
function addAuditPolicysTblTr(){
	var option='<option value="">请选择</option><option value="Y" >是</option><option value="N" >否</option>';
	var trStr='<tr id=""  onclick="selTblTr(this,\'auditPolicysTbl\')"><td><input maxlength="60" type="text" class="input i_s_240"  name="policyNo" /></td>'
				+'<td><select name="isTerminationPol">'+option+'</select></td><td><select name="isClause">'+option+'</select>	</td>'
				+'<td><input maxlength="60" type="text" class="input i_s_240"  name="isRefund" /></td><td><select name="isRenewal">'+option+'</select></td></tr>';
	$("#auditPolicysTbl").append(trStr);
}
//添加问题件处理
function addAudits_infoTblTr(){
	var trStr='<tr id="" onclick="selTblTr(this,\'audits_infoTbl\')"><td><input maxlength="60" type="text" class="input i_s_240"  name="isRenewal" /></td></tr>';
	$("#audits_infoTbl").append(trStr);
}
//添加调查
function addAuditInvTasksTblTr(){
	var option='<option value="">请选择</option>';
	var invNature=option+$("#hselinvNature").html();//任务性质
	var taskSubType=option+ $("#hseltaskSubType").html();//任务子类型
	var invType=option+$("#hselinvType").html();//调查方式
	var trStr='<tr id="" onclick="selTblTr(this,\'auditInvTasksTbl\')"><td><select name="invNature" class="input i_s_240">'+invNature+'</select></td><td><select name="taskSubType" class="input i_s_240">'+taskSubType+'</select></td>'
			+'<td><select name="invType" class="input i_s_240">'+invType+'</select></td><td><input  type="text" class="input i_s_240"  name="invContent" /></td><td><input type="text" class="input i_s_240"  name="invFeedbackContent" /></td>'
			+'<td><input  type="text" class="input i_s_240" readonly="readonly" onclick="WdatePicker({maxDate:\'%y-%M-%d\'})"  name="invAppDate" /></td><td><input type="text" class="input i_s_240" readonly="readonly" onclick="WdatePicker({maxDate:\'%y-%M-%d\'})"  name="invFeedbackDate" /></td><td><input  type="text" class="input i_s_240" name="invgrpman" /></td></tr>';
	$("#auditInvTasksTbl").append(trStr);
}
//添加协谈信息
function addAuditConsultsTblTr(){
	var trStr='<tr id="" onclick="selTblTr(this,\'auditConsultsTbl\')"><td><input type="text" class="input i_s_240"  name="consultClaimResult" /></td><td><input type="text" class="input i_s_240"  name="consultContent" /></td>'
			+'<td><input type="text" class="input i_s_240"  name="feedbackContent" /></td><td><input type="text" class="input i_s_240"  name="applyDate" readonly="readonly" onclick="WdatePicker({maxDate:\'%y-%M-%d\'})" /></td>'
			+'<td><input type="text" class="input i_s_240"  name="feedbackDate" readonly="readonly" onclick="WdatePicker({maxDate:\'%y-%M-%d\'})" /></td><td><input type="text" class="input i_s_240"  name="feedbackEmpName" /></td></tr>';
	$("#auditConsultsTbl").append(trStr);
}
//添加补充资料
function addAuditConsultResourcesTblTr(){
	var resourceConfigs=$("#hResourceConfigs").val();
	var resourceOption='<option value="">请选择</option>';
	if(resourceConfigs!=''){
		var  resourceConfigArray=resourceConfigs.split(",");
		for(var i=0;i<resourceConfigArray.length;i++){
			var resourceArray=resourceConfigArray[i].split(":");
			resourceOption+='<option value="'+resourceArray[0]+'">'+resourceArray[1]+'</option>';
		}
	}
	var trStr='<tr id="" onclick="selTblTr(this,\'auditConsultResourcesTbl\')"><td><select name="resourceName">'+resourceOption+'</select></td><td><input  type="text" class="input i_s_240" readonly="readonly" onclick="WdatePicker({maxDate:\'%y-%M-%d\'})"  name="applyDate" /></td>'
			+'<td><input type="text" class="input i_s_240" readonly="readonly" onclick="WdatePicker({maxDate:\'%y-%M-%d\'})"  name="feedbackDate" /></td><td><input  type="text" class="input i_s_240"  name="consultEmpNo" /></td>'
			+'</tr>';
	$("#auditConsultResourcesTbl").append(trStr);
}
//删除行
function delTblTr(id){
	var tbl=$("#"+id);
	var index=tbl.find("input[name='deltrIndex']").val();
	if(index==""){
		alert("请选择操作行！");
		return;
	}
	tbl.find("tr:eq("+index+")").remove();
	tbl.find("input[name='deltrIndex']").val("");
}
//疾病代码
function showjbDiv(trid){
	  $("#jbzd").html("");
	  $("#jbcontent").val("");
	  showDiv('open1');
	  $("#hTrid").val(trid);
}
function checksp(id){
	if($("#"+id).is(".check_no")){
		$("#"+id).attr("class","check_yes");
	}else{
		$("#"+id).attr("class","check_no");
	}
}
//重疾代码
function showzjDiv(trid){
	  $("#zjdm").html("");
	  $("#zjcontent").val("");
	  $("#hzjllTrid").val(trid);
	  showDiv('open4');
}
//手术代码
function surgeryDiv(id,trid){
	showDiv(id);
	surgeryTrid=trid;
}
//手术代码保存
function saveSurgery(id) {
	var surgery = 0;
	var surgeryCode="";
	$("#surgeryInfoList").find("span").each(function() {
		if ($(this).is(".check_yes")){
			if(surgery==0){
				surgeryCode = $(this).attr("title");
				surgeryName = $(this).attr("name");
				var tr=$("#"+surgeryTrid);
				tr.find("td div input[name='surgeryCode']").val(surgeryCode);
				tr.find("td div input[name='surgeryName']").val(surgeryName);
				surgery=1;
			}
			else {
				alert("只允许选择一个手术");
				$(this).attr("class","check_no");
			}
		}
	});

	$.closePopupLayer(id);
}
/**重疾代码保存*/
function saveZJDiv(id) {
	var jibing = 0;
	var jbname="";
	$("#zjresultData").html("");
	//重疾代码以“_”分隔
	var tr=$("#"+$("#hzjllTrid").val());
	var zjIllsBy_=tr.find("input[name='zjIllsBy_']");
	var zjIllsMap=tr.find("input[name='zjIllsMap']");
	var zjIllsStr="";
	var selspans=$("#zjdm").find("span");
	for(var i=0;i<selspans.length;i++){
		var span=$(selspans[i]);
		if (span.is(".check_yes")){
			zjIllsStr+=span.attr("title")+":"+span.attr("name")+",";
			if(jibing==0){
				jbname = span.attr("title")+" "+span.attr("name");
				if(zjIllsBy_.val().length!=0){
					if(zjIllsBy_.val().indexOf(span.attr("title")<0)){
						zjIllsBy_.val(zjIllsBy_.val()+"_"+span.attr("title"));
					}
				}else{
					zjIllsBy_.val(span.attr("title"));
				}
				
			}else{
				if(zjIllsBy_.val().indexOf(span.attr("title")<0)){
					zjIllsBy_.val(zjIllsBy_.val()+"_"+span.attr("title"));
				}
				
			}
			jibing = jibing+1;
		}
	}
	
	tr.find("input[name='zjClmIll']").val(jbname);
	if(jibing>1)
		tr.find("input[name='zjClmIll']").val(jbname+"....");
	if(zjIllsStr!=""){
		zjIllsStr=zjIllsStr.substring(0,zjIllsStr.length-1);
	}
	if(zjIllsMap.val().length!=0){
		zjIllsMap.val(zjIllsMap.val()+","+zjIllsStr);
	}else{
		zjIllsMap.val(zjIllsStr);
	}
	$.closePopupLayer(id);
}
function showzjresult(id,trid){
	showDiv(id);
	$("#hzjllTrid").val(trid);
	var zjIllsMap=$("#"+trid).find("input[name='zjIllsMap']").val();
	var trs="";
	if(zjIllsMap.length>0){
		var array=zjIllsMap.split(",");
		for(var i=0;i<array.length;i++){
			var ill=array[i].split(":");
			trs+='<tr id="'+ill[0]+'"><td ><input type="hidden" name="code" value="'+ill[0]+':'+ill[1]+'"/>'+ill[0]+'</td><td>'+ill[1]+'</td><td><a  style=\"cursor: pointer;\" class=\"icon_del\" onclick=\"delzjresultData(this,\''+trid+'\')\"></a></td></tr>';
		}
	}
	$("#zjresultData tr").remove();
	$("#zjresultData").append(trs);
}
//重疾代码删除
function delzjresultData(data,trid){
	if(confirm("是否删除当前行！")){
		var trcurrent = $(data).parent().parent();
		trcurrent.remove();
		var zjtr=$("#"+trid);
		var zjIllsBy_=zjtr.find("input[name='zjIllsBy_']");
		var zjIllsMap="";
		var zjresultDatatrs=$("#zjresultData tr");
		var zjcode="";
		if(zjIllsMap!=""){
			zjIllsMap=zjIllsMap.substring(0,zjIllsMap.length-1);
		}
		for(var i=0;i<zjresultDatatrs.length;i++){
			var zjresultDatatr=$(zjresultDatatrs[i]);
			var code=zjresultDatatr.find("td:eq(0)").text();
			var name=zjresultDatatr.find("td:eq(1)").text();
			zjIllsMap+=code+":"+name+",";
			zjcode+=code+"_";
		}
		if(zjcode!=""){
			zjcode=zjcode.substring(0,zjcode.length-1);
		}
		if(zjIllsMap!=""){
			zjIllsMap=zjIllsMap.substring(0,zjIllsMap.length-1);
		}
		zjIllsBy_.val(zjcode);
		zjtr.find("input[name='zjIllsMap']").val(zjIllsMap);
		var tr = $("#zjresultData").find("tr");
		if(tr.length>1){
			var code = $(tr[0]).find("td:eq(0)");
			var name = $(tr[0]).find("td:eq(1)");
			zjtr.find("input[name='zjClmIll']").val(code.text()+" "+name.text()+"....");
		}else if(tr.length==1){
			var code = $(tr[0]).find("td:eq(0)");
			var name = $(tr[0]).find("td:eq(1)");
			zjtr.find("input[name='zjClmIll']").val(code.text()+" "+name.text());
		}else{
			zjtr.find("input[name='zjClmIll']").val("");
		}
	}
}

//医院信息div
function hospitalDiv(id,trid){
	showDiv(id);
	hospitalTrid=trid;
}
//医院信息
function saveHospital(id) {
	var hospital = 0;
	var hospitalName="";
	var hospitalCode="";
	$("#hospitalInfoList").find("span").each(function() {
		if ($(this).is(".check_yes")){
			if(hospital==0){
				hospitalName = $(this).attr("name");
				hospitalCode = $(this).attr("title");
				var tr=$("#"+hospitalTrid);
				tr.find("input[name='hospitalCode']").val(hospitalCode);
				tr.find("input[name='hospitalName']").val(hospitalName);
				hospital=1;
			}
			else {
				alert("只允许选择一个医院");
				$(this).attr("class","check_no");
			}
		}
	});

	$.closePopupLayer(id);
}
/**疾病诊断保存*/
function saveDiv(id) {
	var jibing = 0;
	var jbname="";
	var claimillstr="";
//	$("#jbresultData").html("");
//	$("#claimIllsBy_").val("");
	$("#jbzd").find("span").each(function() {
		if ($(this).is(".check_yes")){
			var claimIllsBy_=$("#"+$("#hTrid").val()).find("td div input[name='claimIllsBy_']");
			claimillstr+=$(this).attr("title")+":"+$(this).attr("name")+",";
			if(jibing==0){
				jbname = $(this).attr("title")+$(this).attr("name");
				if(claimIllsBy_.val().length!=0){
					if(claimIllsBy_.val().indexOf($(this).attr("title"))<0){
						claimIllsBy_.val(claimIllsBy_.val()+'_'+$(this).attr("title"));
					}
				}else{
					claimIllsBy_.val($(this).attr("title"));
				}
			}else{
				if(claimIllsBy_.val().indexOf($(this).attr("title"))<0){
					claimIllsBy_.val(claimIllsBy_.val()+'_'+$(this).attr("title"));
				}
				
			}
			jibing = jibing+1;
			
		}
	});
	if(claimillstr!=""){
		claimillstr=claimillstr.substring(0,claimillstr.length-1);
	}
	var tr=$("#"+$("#hTrid").val());
	var clmIll=tr.find("input[name='clmIll']");
	var hclaimIllsMap=tr.find("input[name='hclaimIllsMap']");
	clmIll.val(jbname);
	if(hclaimIllsMap.val().length!=0){
		hclaimIllsMap.val(hclaimIllsMap.val()+","+claimillstr);
	}else{
		hclaimIllsMap.val(claimillstr);
	}
	if(jibing>1)
		clmIll.val(jbname+"....");
	$.closePopupLayer(id);
}
//计算住院天数
function calculateDays(obj){
	alert(obj.value);
}
//短信显示
function showSmsContent(claimNo){
	   var sms_clmPerson;
	   var sms_salesman;
	   if($('#clmPerson').attr('class')=="check_yes"){
		   sms_clmPerson = 1;

	   }else{
			sms_clmPerson = 0;
	   }
	   
	   if($('#salesman').attr('class')=="check_yes"){
		   sms_salesman = 1;
		  
	   }else{
			sms_salesman = 0;
	   }
	   var operator = $("#operator").val();
	   
		$.ajax({
	        cache: true,
	        type: "POST",
	        url:"/claimserver/claim/showsmscontent.do",
	        data:{"claimNo":claimNo,"sms_clmPerson":sms_clmPerson,"sms_salesman":sms_salesman,"operator":operator},
	        async: false,
	        error: function(request) {
	            alert("展示短信失败！");
	            $("#endcasebutton").disabled=false;
	        },
	        success: function(data) {
	        	 /* alert(data[0]); */
	        	$("#end1").html('');
	        	for(var i = 0;i<data[0].length;i++){
	        		var a = data[0][i];
	        		var b = data[2][i];
	     
	        		$("#end1").append(a+"<br><br>"+"领款人手机号码："+b+"<br><br>"); 
	        	}
	        	
	        	var end1_html = $("#end1").html();
	        	if (end1_html != '') {
	        		end1_html = end1_html.replace("12312312312","<input type=\"text\" id=\"phone1\" name=\"phone1\" class=\"input input_bot_line i_s_100\" />");

	        	}
	        	$("#end1").html(end1_html);
	        	
	        	 /* $("#end1").html(data[0]);  */
	        	$("#end2").html(data[1]);
	        	/* $("#phoneno").html(data[2]); */
	        	
	        	var end2_html = $("#end2").html();
	        	if (end2_html != '') {
	        		end2_html = end2_html.replace("尊敬的","尊敬的<input type=\"text\" id=\"yname\" name=\"yname\" class=\"input input_bot_line i_s_100\" />");
	        		end2_html = end2_html.replace("12312312312","<input type=\"text\" id=\"phone\" name=\"phone\" class=\"input input_bot_line i_s_100\" />");

	        	}
	        	$("#end2").html(end2_html);
	        	
	        	$("#end_02").html('');
	        	$("#end_03").html('');
	        	$("#end_04").html('');
	        	$("#end_05").html('');
	        	var a02 = data[3];
	    		var a03 = data[4];
	    		var a04 = data[5];
	    		var a05 = data[6];
	    		var a06 = data[7];
	    		var endCaseType = data[8];
	    		if(endCaseType=="04"){
	    			$("#finishCaseMassage_1").hide();$("#finishCaseLine_1").hide();
	    			$("#finishCaseMassage_4").hide();$("#finishCaseLine_3").hide();
	    			$("#finishCaseMassage_5").hide();$("#finishCaseLine_4").hide();
	    		}else if(endCaseType=="03"){
	    			$("#finishCaseMassage_1").hide();$("#finishCaseLine_1").hide();
	    			$("#finishCaseMassage_2").hide();$("#finishCaseLine_2").hide();
	    			$("#finishCaseMassage_3").hide();$("#finishCaseLine_3").hide();
	    		}else{
	    			$("#finishCaseLine_1").hide();
	    			$("#finishCaseMassage_2").hide();$("#finishCaseLine_2").hide();
	    			$("#finishCaseMassage_3").hide();$("#finishCaseLine_3").hide();
	    			$("#finishCaseMassage_4").hide();$("#finishCaseLine_4").hide();
	    			$("#finishCaseMassage_5").hide();
	    		}
	        	$("#end_02").append(a02);
	        	$("#end_03").append(a03);
	        	$("#end_04").append(a04);
	        	$("#end_05").append(a05);
	        	
	        	var end02_html = $("#end_02").html();
	        	if (end02_html != '') {
	        		if(a06=="endCaseReasonIsNull")
	        			end02_html = end02_html.replace(a06,"<input type=\"text\" id=\"auditOption02\" name=\"auditOption02\" class=\"input input_bot_line i_s_100\" style=\"width:auto;\" value='' />");
	        		else
	        			end02_html = end02_html.replace(a06,"<input type=\"text\" id=\"auditOption02\" name=\"auditOption02\" class=\"input input_bot_line i_s_100\" style=\"width:auto;\" value='"+ a06 +"' />");
	        		$("#end_02").html(end02_html);
	        	}
	        	
	        	var end03_html = $("#end_03").html();
	        	if (end03_html != '') {
	        		end03_html = end03_html.replace('businessManName',"<input id=\"businessManName03\" type=\"text\" class=\"input input_bot_line i_s_100\" value=' ' />");
	        		if(a06=="endCaseReasonIsNull")
	        			end03_html = end03_html.replace(a06,"<input type=\"text\" id=\"auditOption03\" name=\"auditOption03\" class=\"input input_bot_line i_s_100\"  style=\"width:auto;\" value='' /> ");
	        		else
	        			end03_html = end03_html.replace(a06,"<input type=\"text\" id=\"auditOption03\" name=\"auditOption03\" class=\"input input_bot_line i_s_100\"  style=\"width:auto;\" value='"+ a06 +"' /> ");
	        		$("#end_03").html(end03_html + "<br><br> 业务员手机号码： <input type=\"text\" id=\"businesManPhone1\" name=\"businesManPhone1\" class=\"input input_bot_line i_s_100\" /> <br>");
	        	}
	        	
	        	var end04_html = $("#end_04").html();
	        	if (end04_html != '') {
	        		if(a06=="endCaseReasonIsNull")
	        			end04_html = end04_html.replace(a06,"<input type=\"text\" id=\"auditOption04\" name=\"auditOption04\" class=\"input input_bot_line i_s_100\" style=\"width:auto;\" value='' />");
	        		else
	        			end04_html = end04_html.replace(a06,"<input type=\"text\" id=\"auditOption04\" name=\"auditOption04\" class=\"input input_bot_line i_s_100\" style=\"width:auto;\" value='"+ a06 +"' />");
	        		$("#end_04").html(end04_html);
	        	}
	        	
	        	var end05_html = $("#end_05").html();
	        	if (end05_html != '') {
	        		end05_html = end05_html.replace('businessManName',"<input type=\"text\" id=\"businessManName05\" class=\"input input_bot_line i_s_100\" value=' ' />");
	        		if(a06=="endCaseReasonIsNull")
	        			end05_html = end05_html.replace(a06,"<input type=\"text\" id=\"auditOption05\" name=\"auditOption05\" class=\"input input_bot_line i_s_100\" style=\"width:auto;\" value='' />");
	        		else
	        			end05_html = end05_html.replace(a06,"<input type=\"text\" id=\"auditOption05\" name=\"auditOption05\" class=\"input input_bot_line i_s_100\" style=\"width:auto;\" value='"+ a06 +"' />");
	        		$("#end_05").html(end05_html +"<br><br> 业务员手机号码： <input type=\"text\" id=\"businesManPhone2\" name=\"businesManPhone2\" class=\"input input_bot_line i_s_100\" /> <br>");
	        	}
	        	
	        	showDiv('openMse'); 
	         }
	    });
}
//产险短信展示
function showCXSmsContent(claimNo){
	var sms_clmPerson;
	if($('#clmPerson1').attr('class')=="check_yes"){
		sms_clmPerson = 1;

	} else {
		sms_clmPerson = 0;
	}
	   
	$.ajax({
        cache: true,
        type: "POST",
        url:"/claimserver/claim/showsmscontent.do",
        data:{"claimNo":claimNo,"sms_clmPerson":sms_clmPerson,"sms_salesman":"","operator":""},
        async: false,
        error: function(request) {
            alert("展示短信失败！");
            $("#endcasebutton").disabled=false;
        },
        success: function(data) {
        	$("#end3").html('');
        	$("#end02").html('');
        	$("#end03").html('');
        	$("#end04").html('');
        	$("#end05").html('');
        	var a02 = data[2];
    		var a03 = data[3];
    		var a04 = data[4];
    		var a05 = data[5];
    		var a06 = data[6];
    		var endCaseType = data[7];
    		if(endCaseType=="04"){
    			$("#finishCaseMassage1").hide();$("#finishCaseLine1").hide();
    			$("#finishCaseMassage4").hide();$("#finishCaseLine3").hide();
    			$("#finishCaseMassage5").hide();$("#finishCaseLine4").hide();
    		}else if(endCaseType=="03"){
    			$("#finishCaseMassage1").hide();$("#finishCaseLine1").hide();
    			$("#finishCaseMassage2").hide();$("#finishCaseLine2").hide();
    			$("#finishCaseMassage3").hide();$("#finishCaseLine3").hide();
    		}else{
    			$("#finishCaseLine1").hide();
    			$("#finishCaseMassage2").hide();$("#finishCaseLine2").hide();
    			$("#finishCaseMassage3").hide();$("#finishCaseLine3").hide();
    			$("#finishCaseMassage4").hide();$("#finishCaseLine4").hide();
    			$("#finishCaseMassage5").hide();
    		}
    		
        	for(var i = 0;i<data[0].length;i++){
        		var a = data[0][i];
        		var b = data[1][i];
        		$("#end3").append(a+"<br><br>"+"领款人手机号码："+b+"<br><br>");
        	}
        	$("#end02").append(a02);
        	$("#end03").append(a03);
        	$("#end04").append(a04);
        	$("#end05").append(a05);
        	
        	var end02_html = $("#end02").html();
        	if (end02_html != '') {
        		if(a06=="endCaseReasonIsNull")
        			end02_html = end02_html.replace(a06,"<input type=\"text\" id=\"auditOption02\" name=\"auditOption02\" class=\"input input_bot_line i_s_100\" style=\"width:auto;\" value='' />");
        		else
        			end02_html = end02_html.replace(a06,"<input type=\"text\" id=\"auditOption02\" name=\"auditOption02\" class=\"input input_bot_line i_s_100\" style=\"width:auto;\" value='"+ a06 +"' />");
        		$("#end02").html(end02_html);
        	}
        	
        	var end03_html = $("#end03").html();
        	if (end03_html != '') {
        		end03_html = end03_html.replace('businessManName',"<input id=\"businessManName03\" type=\"text\" class=\"input input_bot_line i_s_100\" value='' />");
        		if(a06=="endCaseReasonIsNull")
        			end03_html = end03_html.replace(a06,"<input type=\"text\" id=\"auditOption03\" name=\"auditOption03\" class=\"input input_bot_line i_s_100\"  style=\"width:auto;\" value='' /> ");
        		else
        			end03_html = end03_html.replace(a06,"<input type=\"text\" id=\"auditOption03\" name=\"auditOption03\" class=\"input input_bot_line i_s_100\"  style=\"width:auto;\" value='"+ a06 +"' /> ");
        		$("#end03").html(end03_html + "<br><br> 业务员手机号码： <input type=\"text\" id=\"businesManPhone1\" name=\"businesManPhone1\" class=\"input input_bot_line i_s_100\" /> <br>");
        	}
        	
        	var end04_html = $("#end04").html();
        	if (end04_html != '') {
        		if(a06=="endCaseReasonIsNull")
        			end04_html = end04_html.replace(a06,"<input type=\"text\" id=\"auditOption04\" name=\"auditOption04\" class=\"input input_bot_line i_s_100\" style=\"width:auto;\" value='' />");
        		else
        			end04_html = end04_html.replace(a06,"<input type=\"text\" id=\"auditOption04\" name=\"auditOption04\" class=\"input input_bot_line i_s_100\" style=\"width:auto;\" value='"+ a06 +"' />");
        		$("#end04").html(end04_html);
        	}
        	
        	var end05_html = $("#end05").html();
        	if (end05_html != '') {
        		end05_html = end05_html.replace('businessManName',"<input type=\"text\" id=\"businessManName05\" class=\"input input_bot_line i_s_100\" value='' />");
        		if(a06=="endCaseReasonIsNull")
        			end05_html = end05_html.replace(a06,"<input type=\"text\" id=\"auditOption05\" name=\"auditOption05\" class=\"input input_bot_line i_s_100\" style=\"width:auto;\" value='' />");
        		else
        			end05_html = end05_html.replace(a06,"<input type=\"text\" id=\"auditOption05\" name=\"auditOption05\" class=\"input input_bot_line i_s_100\" style=\"width:auto;\" value='"+ a06 +"' />");
        		$("#end05").html(end05_html +"<br><br> 业务员手机号码： <input type=\"text\" id=\"businesManPhone2\" name=\"businesManPhone2\" class=\"input input_bot_line i_s_100\" /> <br>");
        	}
        	
        	showDiv('cxOpenMse'); 
	        }
        });
}

function sendSmsContent(claimNo){
	   var sms_clmPerson;
	   var sms_salesman;
	   var sms_clmPerson02;
	   var sms_clmPerson03;
	   var sms_clmPerson04;
	   var sms_clmPerson05;
	   var auditOption02=$("#auditOption02").val();
	   var auditOption03=$("#auditOption03").val();
	   var auditOption04=$("#auditOption04").val();
	   var auditOption05=$("#auditOption05").val();
	   var businessManName03=$("#businessManName03").val();
	   var businessManName05=$("#businessManName05").val();
	   var businesManPhone1 = $("#businesManPhone1").val();
	   var businesManPhone2 = $("#businesManPhone2").val();
	   if($('#clmPerson').attr('class')=="check_yes"){
		   sms_clmPerson = 1;

	   }else{
			sms_clmPerson = 0;
	   }
	   
	   if($('#salesman').attr('class')=="check_yes"){
		   sms_salesman = 1;
		  
	   }else{
			sms_salesman = 0;
	   }
	   if($('#clmPerson_02').attr('class')=="check_yes"){
		   sms_clmPerson02 = 1;
//		   if($("#auditOption02").val()==null || $("#auditOption02").val()==""){
//				alert("请填写撤案原因");
//				return;
//		   }

	   }else{
			sms_clmPerson02 = 0;
	   }
	   if($('#clmPerson_03').attr('class')=="check_yes"){
		   sms_clmPerson03 = 1;
//		   if($("#auditOption03").val()==null || $("#auditOption03").val()==""){
//				alert("请填写撤案原因");
//				return;
//		   }
	   }else{
			sms_clmPerson03 = 0;
	   }
	   if($('#clmPerson_04').attr('class')=="check_yes"){
		   sms_clmPerson04 = 1;
//		   if($("#auditOption04").val()==null || $("#auditOption04").val()==""){
//				alert("请填写拒赔原因");
//				return;
//		   }
	   }else{
			sms_clmPerson04 = 0;
	   }
	   if($('#clmPerson_05').attr('class')=="check_yes"){
		   sms_clmPerson05 = 1;
//		   if($("#auditOption05").val()==null || $("#auditOption05").val()==""){
//				alert("请填写拒赔原因");
//				return;
//		   }

	   }else{
			sms_clmPerson05 = 0;
	   }
	   var operator = $("#operator").val();
	   var yname = $("#yname").val();
	   var phone = $("#phone").val();
	   var phone1 = $("#phone1").val();
	   if(sms_salesman=='1'){
			 if(operator.length!=11){
   			   alert("请输入11位手机号码");
   			   return ;
   		   }
		     }
	   
	   $.ajax({
	        cache: true,
	        type: "POST",
	        url:"/claimserver/claim/showsmscontent.do",
	        data:{"claimNo":claimNo,
	        	"sms_clmPerson":sms_clmPerson,
	        	"sms_salesman":sms_salesman,
	        	"operator":operator,
	        	"yname":yname,
	        	"phone":phone,
	        	"phone1":phone1,
	        	"sms_clmPerson02" : sms_clmPerson02,
				"sms_clmPerson03" : sms_clmPerson03,
				"sms_clmPerson04" : sms_clmPerson04,
				"sms_clmPerson05" : sms_clmPerson05 ,
				"businesManPhone1" : businesManPhone1,
				"businesManPhone2" : businesManPhone2,
				"auditOption02" : auditOption02,
				"auditOption03" : auditOption03 ,
				"auditOption04" : auditOption04,
				"auditOption05" : auditOption05,
				"businessManName03" : businessManName03,
				"businessManName05" : businessManName05
	        	},
	        async: false,
	        error: function(request) {
	            alert("短信发送失败！");
	          
	        },
	        success: function(data) {
	        	
	        	if(sms_clmPerson=='1' || sms_salesman=='1'||sms_clmPerson02=='1'||sms_clmPerson03=='1'||sms_clmPerson04=='1'||sms_clmPerson05=='1'){
		        	closeDiv('cxOpenMse'); 
	        		 alert("发送成功！");
	        		 $('#clmPerson').attr('class',"check_no");
	        		 $('#salesman').attr('class',"check_no");
	        		 $("#operator").val('');
	        		 $('#clmPerson02').attr('class',"check_no");
	        		 $('#clmPerson03').attr('class',"check_no");
	        		 $('#clmPerson04').attr('class',"check_no");
	        		 $('#clmPerson05').attr('class',"check_no");
	        	}	        		  	
	        }
	    });
	   $("#smsbuttom").removeAttr("onclick");
	   
}

function CXSendSmsContent(claimNo){
	
	   var sms_clmPerson;
	   var sms_clmPerson02;
	   var sms_clmPerson03;
	   var sms_clmPerson04;
	   var sms_clmPerson05;
	   var auditOption02=$("#auditOption02").val();
	   var auditOption03=$("#auditOption03").val();
	   var auditOption04=$("#auditOption04").val();
	   var auditOption05=$("#auditOption05").val();
	   var businessManName03=$("#businessManName03").val();
	   var businessManName05=$("#businessManName05").val();
	   var businesManPhone1 = $("#businesManPhone1").val();
	   var businesManPhone2 = $("#businesManPhone2").val();
	   if($('#clmPerson1').attr('class')=="check_yes"){
		   sms_clmPerson = 1;

	   }else{
			sms_clmPerson = 0;
	   }
	   if($('#clmPerson02').attr('class')=="check_yes"){
		   sms_clmPerson02 = 1;
//		   if($("#auditOption02").val()==null || $("#auditOption02").val()==""){
//				alert("请填写撤案原因");
//				return;
//		   }

	   }else{
			sms_clmPerson02 = 0;
	   }
	   if($('#clmPerson03').attr('class')=="check_yes"){
		   sms_clmPerson03 = 1;
//		   if($("#auditOption03").val()==null || $("#auditOption03").val()==""){
//				alert("请填写撤案原因");
//				return;
//		   }
	   }else{
			sms_clmPerson03 = 0;
	   }
	   if($('#clmPerson04').attr('class')=="check_yes"){
		   sms_clmPerson04 = 1;
//		   if($("#auditOption04").val()==null || $("#auditOption04").val()==""){
//				alert("请填写拒赔原因");
//				return;
//		   }
	   }else{
			sms_clmPerson04 = 0;
	   }
	   if($('#clmPerson05').attr('class')=="check_yes"){
		   sms_clmPerson05 = 1;
//		   if($("#auditOption05").val()==null || $("#auditOption05").val()==""){
//				alert("请填写拒赔原因");
//				return;
//		   }

	   }else{
			sms_clmPerson05 = 0;
	   }
	   
	   $.ajax({
	        cache: true,
	        type: "POST",
	        url:"/claimserver/claim/showsmscontent.do",
		    data : {
				"claimNo" : claimNo,
				"sms_clmPerson" : sms_clmPerson,
				"sms_salesman" : "",
				"operator" : "",
				"yname" : "",
				"phone" : "",
				"phone1" : "",
				"sms_clmPerson02" : sms_clmPerson02,
				"sms_clmPerson03" : sms_clmPerson03,
				"sms_clmPerson04" : sms_clmPerson04,
				"sms_clmPerson05" : sms_clmPerson05 ,
				"businesManPhone1" : businesManPhone1,
				"businesManPhone2" : businesManPhone2,
				"auditOption02" : auditOption02,
				"auditOption03" : auditOption03 ,
				"auditOption04" : auditOption04,
				"auditOption05" : auditOption05,
				"businessManName03" : businessManName03,
				"businessManName05" : businessManName05
				
		    },
	        async: false,
	        error: function(request) {
	            alert("短信发送失败！");
	          
	        },
	        success: function(data) {
	        	
	        	if(sms_clmPerson=='1'||sms_clmPerson02=='1'||sms_clmPerson03=='1'||sms_clmPerson04=='1'||sms_clmPerson05=='1'){
		        	closeDiv('cxOpenMse'); 
	        		 alert("发送成功！");
	        		 $('#clmPerson').attr('class',"check_no");
	        		 $('#clmPerson02').attr('class',"check_no");
	        		 $('#clmPerson03').attr('class',"check_no");
	        		 $('#clmPerson04').attr('class',"check_no");
	        		 $('#clmPerson05').attr('class',"check_no");
	        	}
	        		  	
	        }
	    });
	   $("#smsbuttom").removeAttr("onclick");
	   
}

function showjbresult(trid){
	var hclaimIllsMap=$("#"+trid).find("input[name='hclaimIllsMap']").val();
	var trs="";
	if(hclaimIllsMap.length>0){
		var array=hclaimIllsMap.split(",");
		for(var i=0;i<array.length;i++){
			var ill=array[i].split(":");
			trs+='<tr id="'+ill[0]+'"><td ><input type="hidden" name="code" value="'+ill[0]+':'+ill[1]+'"/>'+ill[0]+'</td><td>'+ill[1]+'</td><td><a  style=\"cursor: pointer;\" class=\"icon_del\" onclick=\"deljbresultData(this,\''+trid+'\')\"></a></td></tr>';
		}
	}
	$("#illTblList tr:gt(0)").remove();
	$("#illTblList").append(trs);
	showDiv('jbresult');
}
//打开影像
function openImage(flag){
		var caseSource = $("#caseSource").val();
		var claimNo = $("#hclaimNo").val();
		var iscommon= $("#hisBpo").val();
		if(flag=="1"){//赔案影像
			if("1"==caseSource && iscommon=="Y"){
				callEcm(claimNo,"");
			}else{
				window.open('../inspection/clmtask/imageInfo.do?claimNo='+claimNo,"影像");
			}
		}
		if(flag=="2"){
			if("1"==$("#caseSource").val()){
				callEcm(claimNo,"2");
			}else{
				window.open('../inspection/clmtask/imageInfo.do?claimNo='+claimNo+'&flag=2',"保单影像");
			}
		}
}
//疾病代码删除行
function deljbresultData(obj,evntTrId){
	if(confirm("确定要删除当前行吗？")){
		var hclaimIllsMap="";
		var tr=$("#"+evntTrId);
		$(obj).parent().parent().remove();
		var illTblListtrs=$("#illTblList tr");
		var nameStr="";
		var illCode="";
		for(var i=1;i<illTblListtrs.length;i++){
			var illTblListtr=$(illTblListtrs[i]);
			var code=illTblListtr.find("input[name='code']").val();
			if(code!=undefined&&code!=""){
				hclaimIllsMap+=code+",";
				illCode+=illTblListtr.attr("id")+"_";
			}
			nameStr+=illTblListtr.find("td:eq(1)").html()+",";
		}
		if(hclaimIllsMap!=""){
			hclaimIllsMap=hclaimIllsMap.substring(0,hclaimIllsMap.length-1);
		}
		tr.find("input[name='hclaimIllsMap']").val(hclaimIllsMap);
		tr.find("input[name='clmIll']").val(nameStr);
		if(illCode!=""){
			illCode=illCode.substring(0, illCode.length-1);
		}
		tr.find("input[name='claimIllsBy_']").val(illCode);
	}
}
function  getValById(id){
	var obj=$("#"+id);
	if(obj.val()!=undefined&&obj.val()!=""){
		return obj.val();
	}else{
		return "";
	}
}
function getVal(val){
	if(val!=undefined&&val!=null&&val!=""){
		return val;
	}else{
		return "";
	}
}
function openEventWindow(url, claimNo,eventNo) {
 	url = url + "?eventNo=" + eventNo+"&claimNo="+claimNo;
 	window.open (url,'newwindow','');
// 	window.open (url,'newwindow','top=0,left=0,toolbar=no,menubar=no,scrollbars=yes, resizable=no,location=no, status=no');
 }

/**出险类型选择 疾病02  意外01*/	
function cxlxCheckBox(dataId){
	//alert($("#"+dataId).is(".check_yes"));
	if($("#"+dataId).is(".check_yes")){
		$("#accidentCode").val("");
	}else{
		if(dataId=="cxlxYw"){
			$("#cxlxJB").removeClass().addClass("check_no");
			$("#cxlxQT").removeClass().addClass("check_no");
			$("#accidentCode").val("1");
		}
		if(dataId=="cxlxJB"){
			$("#cxlxYw").removeClass().addClass("check_no");
			$("#cxlxQT").removeClass().addClass("check_no");
			$("#accidentCode").val("2");
		}
		if(dataId=="cxlxQT"){
			$("#cxlxYw").removeClass().addClass("check_no");
			$("#cxlxJB").removeClass().addClass("check_no");
			$("#accidentCode").val("3");
		}
	}
}
function initclaimacc(){
	//accTypesBy_
	var accTypesStr = $("#accTypesBy_").val();
	var accTypes = accTypesStr.split("_");
	var i = 0 ;
	for(; accTypes != '' && i < accTypes.length ; i++ ){
		if(accTypes[i]=="01"){
			$('#shenggu').attr('class','re_icon1 re_icon1_cur');
			$("#clmIllred").html("*");
			$("#deadDatered").html("*");
		}
		if(accTypes[i]=="02"){
			$('#shangchang').attr('class','re_icon2 re_icon2_cur'); 
			$("#clmIllred").html("*");
			$("#visitDatered").html("*");
			$("#hospitalNamered").html("*");
			if($("#isBpo").val()=='N'){
				$("#haveSocialMedicalred").html("");
			}else{
				$("#haveSocialMedicalred").html("*");
			}
			$("#maimDatered").html("*");
			$("#hospitalNamered").html("*");
		}
		if(accTypes[i]=="03"){
			$('#zhongda').attr('class','re_icon3 re_icon3_cur');
			$("#clmIllred").html("*");
			$("#visitDatered").html("*");
			$("#hospitalNamered").html("*");
			if($("#isBpo").val()=='N'){
				$("#haveSocialMedicalred").html("");
			}else{
				$("#haveSocialMedicalred").html("*");
			}
			$("#hospitalNamered").html("*");
			$("#zjClmIllred").html("*");
		}
		if(accTypes[i]=="04"){
			$('#menzhen').attr('class','re_icon4 re_icon4_cur');
			$("#clmIllred").html("*");
			$("#visitDatered").html("*");
			$("#hospitalNamered").html("*");
			if($("#isBpo").val()=='N'){
				$("#haveSocialMedicalred").html("");
			}else{
				$("#haveSocialMedicalred").html("*");
			}
		}
		if(accTypes[i]=="05"){
			$('#zhuyuanyiliao').attr('class','re_icon5 re_icon5_cur');
			$("#clmIllred").html("*");
			$("#visitDatered").html("*");
			$("#hospitalNamered").html("*");
			if($("#isBpo").val()=='N'){
				$("#haveSocialMedicalred").html("");
			}else{
				$("#haveSocialMedicalred").html("*");
			}
			$("#admissionDatered").html("*");
			$("#dischargeDatered").html("*");
			$("#hospitalizedDaysred").html("*");
		}
		if(accTypes[i]=="06"){
			$('#zhuyuanbutie').attr('class','re_icon6 re_icon6_cur');
			$("#clmIllred").html("*");
			$("#visitDatered").html("*");
			$("#hospitalNamered").html("*");
			if($("#isBpo").val()=='N'){
				$("#haveSocialMedicalred").html("");
			}else{
				$("#haveSocialMedicalred").html("*");
			}
			$("#admissionDatered").html("*");
			$("#dischargeDatered").html("*");
			$("#hospitalizedDaysred").html("*");
		}
		if(accTypes[i]=="07"){
			$('#nvxingshengyu').attr('class','re_icon7 re_icon7_cur');
			$("#clmIllred").html("*");
			$("#visitDatered").html("*");
			$("#hospitalNamered").html("*");
			if($("#isBpo").val()=='N'){
				$("#haveSocialMedicalred").html("");
			}else{
				$("#haveSocialMedicalred").html("*");
			}
			$("#admissionDatered").html("");
			$("#dischargeDatered").html("");
			$("#hospitalizedDaysred").html("");
		}
		if(accTypes[i]=="08"){
			$('#dentisty').attr('class','re_icon8 re_icon8_cur');
			$("#clmIllred").html("*");
			$("#visitDatered").html("*");
			$("#hospitalNamered").html("*");
			if($("#isBpo").val()=='N'){
				$("#haveSocialMedicalred").html("");
			}else{
				$("#haveSocialMedicalred").html("*");
			}
			$("#admissionDatered").html("");
			$("#dischargeDatered").html("");
			$("#hospitalizedDaysred").html("");
		}
		if(accTypes[i]=="09"){
			$('#onculist').attr('class','re_icon9 re_icon9_cur');
			$("#clmIllred").html("*");
			$("#visitDatered").html("*");
			if($("#isBpo").val()=='N'){
				$("#hospitalNamered").html("");
				$("#haveSocialMedicalred").html("");
			}else{
				$("#hospitalNamered").html("*");
				$("#haveSocialMedicalred").html("*");
			}
			$("#admissionDatered").html("");
			$("#dischargeDatered").html("");
			$("#hospitalizedDaysred").html("");
		}
		if(accTypes[i]=="10"){
			$('#menzhendabing').attr('class','re_icon11 re_icon11_cur');
			$("#clmIllred").html("*");
			$("#visitDatered").html("*");
			$("#hospitalNamered").html("*");
			if($("#isBpo").val()=='N'){
				$("#haveSocialMedicalred").html("");
			}else{
				$("#haveSocialMedicalred").html("*");
			}
		}
		if(accTypes[i]=="11"){
			$('#jinjiyake').attr('class','re_icon10 re_icon10_cur');
			$("#clmIllred").html("*");
			$("#visitDatered").html("*");
			$("#hospitalNamered").html("*");
			if($("#isBpo").val()=='N'){
				$("#haveSocialMedicalred").html("");
			}else{
				$("#haveSocialMedicalred").html("*");
			}
			$("#admissionDatered").html("");
			$("#dischargeDatered").html("");
			$("#hospitalizedDaysred").html("");
		}
		if(accTypes[i]=="12"){
			$('#buymedicine').attr('class','re_icon12 re_icon12_cur');
			$("#clmIllred").html("*");
			$("#visitDatered").html("");
			$("#hospitalNamered").html("");
			$("#haveSocialMedicalred").html("");
			$("#admissionDatered").html("");
			$("#dischargeDatered").html("");
			$("#hospitalizedDaysred").html("");
		}
		if(accTypes[i]=="13"){
			$('#medical').attr('class','re_icon13 re_icon13_cur');
			$("#clmIllred").html("*");
			$("#visitDatered").html("");
			$("#hospitalNamered").html("");
			$("#haveSocialMedicalred").html("");
			$("#admissionDatered").html("");
			$("#dischargeDatered").html("");
			$("#hospitalizedDaysred").html("");
		}
		if(accTypes[i]=="14"){
			$('#girlDisease').attr('class','re_icon14 re_icon14_cur');
			$("#clmIllred").html("*");
			$("#visitDatered").html("");
			$("#hospitalNamered").html("");
			$("#haveSocialMedicalred").html("");
			$("#admissionDatered").html("");
			$("#dischargeDatered").html("");
			$("#hospitalizedDaysred").html("");
		}
		if(accTypes[i]=="15"){
			$('#aids').attr('class','re_icon15 re_icon15_cur');
			$("#clmIllred").html("*");
			$("#visitDatered").html("");
			$("#hospitalNamered").html("");
			$("#haveSocialMedicalred").html("");
			$("#admissionDatered").html("");
			$("#dischargeDatered").html("");
			$("#hospitalizedDaysred").html("");
		}
		if(accTypes[i]=="16"){
			$('#emergencymedical').attr('class','re_icon16 re_icon16_cur');
			$("#clmIllred").html("*");
			$("#visitDatered").html("*");
			$("#hospitalNamered").html("*");
			$("#haveSocialMedicalred").html("");
			$("#admissionDatered").html("");
			$("#dischargeDatered").html("");
			$("#hospitalizedDaysred").html("");
		
		}
		if(accTypes[i]=="17"){
			$('#medicalvaccine').attr('class','re_icon17 re_icon17_cur');
			$("#clmIllred").html("*");
			$("#visitDatered").html("*");
			$("#hospitalNamered").html("*");
			$("#haveSocialMedicalred").html("");
			$("#admissionDatered").html("");
			$("#dischargeDatered").html("");
			$("#hospitalizedDaysred").html("");
		}
		if(accTypes[i]=="18"){
			$('#congenitaldisease').attr('class','re_icon18 re_icon18_cur');
			$("#clmIllred").html("*");
			$("#visitDatered").html("*");
			$("#hospitalNamered").html("*");
			$("#haveSocialMedicalred").html("");
			$("#admissionDatered").html("");
			$("#dischargeDatered").html("");
			$("#hospitalizedDaysred").html("");
		}
		if(accTypes[i]=="19"){
			$('#xinxueguan').attr('class','re_icon19 re_icon19_cur');
			$("#clmIllred").html("*");
			$("#visitDatered").html("*");
			$("#hospitalNamered").html("*");
			$("#haveSocialMedicalred").html("");
			$("#admissionDatered").html("");
			$("#dischargeDatered").html("");
			$("#hospitalizedDaysred").html("");
		}
		if(accTypes[i]=="20"){
			$('#guzhe').attr('class','re_icon20 re_icon20_cur');
			$("#clmIllred").html("*");
			$("#visitDatered").html("*");
			$("#hospitalNamered").html("*");
			$("#haveSocialMedicalred").html("");
			$("#admissionDatered").html("");
			$("#dischargeDatered").html("");
			$("#hospitalizedDaysred").html("");
		}
	}
	
}
//身故
function shenggu(a){
	if($('#shenggu').attr('class')=="re_icon1"){
		$('#shenggu').attr('class','re_icon1 re_icon1_cur');
		saveClaimAcc('add','01');
	}else{
		$('#shenggu').attr('class','re_icon1');
		saveClaimAcc('del','01');
	}
}
//伤残
function shangchang(a){
	if($('#shangchang').attr('class')=="re_icon2"){
		$('#shangchang').attr('class','re_icon2 re_icon2_cur');
		saveClaimAcc('add','02');
	}else{
		$('#shangchang').attr('class','re_icon2');
		saveClaimAcc('del','02');
	}
}
//重大疾病
function zhongda(a){
	if($('#zhongda').attr('class')=="re_icon3"){
		$('#zhongda').attr('class','re_icon3 re_icon3_cur');
		saveClaimAcc('add','03');
	}else{
		saveClaimAcc('del','03');
		$('#zhongda').attr('class','re_icon3');
	}
}
//门争论医疗
function menzhen(a){
	if($('#menzhen').attr('class')=="re_icon4"){
		$('#menzhen').attr('class','re_icon4 re_icon4_cur');
		saveClaimAcc('add','04');
	}else{
		$('#menzhen').attr('class','re_icon4');
		saveClaimAcc('del','04');
	}
	
}
//住院医疗
function zhuyuanyiliao(a){
	if($('#zhuyuanyiliao').attr('class')=="re_icon5"){
		$('#zhuyuanyiliao').attr('class','re_icon5 re_icon5_cur');
		saveClaimAcc('add','05');
	}else{
		$('#zhuyuanyiliao').attr('class','re_icon5');
		saveClaimAcc('del','05');
	}
}
//住院补贴
function zhuyuanbutie(a){
	if($('#zhuyuanbutie').attr('class')=="re_icon6"){
		$('#zhuyuanbutie').attr('class','re_icon6 re_icon6_cur');
		saveClaimAcc('add','06');
	}else{
		$('#zhuyuanbutie').attr('class','re_icon6');
		saveClaimAcc('del','06');
	}
}
function nvxingshengyu(a){
	if($('#nvxingshengyu').attr('class')=="re_icon7"){
		$('#nvxingshengyu').attr('class','re_icon7 re_icon7_cur');
		saveClaimAcc('add','07');
	}else{
		$('#nvxingshengyu').attr('class','re_icon7');
		saveClaimAcc('del','07');
	}
}
function dentisty(a){
	if($('#dentisty').attr('class')=="re_icon8"){
		$('#dentisty').attr('class','re_icon8 re_icon8_cur');
		saveClaimAcc('add','08');
	}else{
		$('#dentisty').attr('class','re_icon8');
		saveClaimAcc('del','08');
	}
}
function onculist(a){
	if($('#onculist').attr('class')=="re_icon9"){
		$('#onculist').attr('class','re_icon9 re_icon9_cur');
		$("#clmIllred").html("");
		$("#visitDatered").html("");
		saveClaimAcc('add','09');
		blg=false;
	}else{
		$('#onculist').attr('class','re_icon9');
		saveClaimAcc('del','09');
		$("#clmIllred").html("*");
		$("#visitDatered").html("*");
		blg=true;
	}
}
function menzhendabing(a){
	if($('#menzhendabing').attr('class')=="re_icon11"){
		$('#menzhendabing').attr('class','re_icon11 re_icon11_cur');
		saveClaimAcc('add','10');
	}else{
		$('#menzhendabing').attr('class','re_icon11');
		saveClaimAcc('del','10');
	}
}
function jinjiyake(a){
	if($('#jinjiyake').attr('class')=="re_icon10"){
		$('#jinjiyake').attr('class','re_icon10 re_icon10_cur');
		saveClaimAcc('add','11');
	}else{
		$('#jinjiyake').attr('class','re_icon10');
		saveClaimAcc('del','11');
	}
}
function buymedicine(a){
	if($('#buymedicine').attr('class')=="re_icon12"){
		$('#buymedicine').attr('class','re_icon12 re_icon12_cur');
		saveClaimAcc('add','12');
	}else{
		$('#buymedicine').attr('class','re_icon12');
		saveClaimAcc('del','12');
	}
}
function medical(a){
	if($('#medical').attr('class')=="re_icon13"){
		$('#medical').attr('class','re_icon13 re_icon13_cur');
		saveClaimAcc('add','13');
	}else{
		$('#medical').attr('class','re_icon13');
		saveClaimAcc('del','13');
	}
}
function girlDisease(a){
	if($('#girlDisease').attr('class')=="re_icon14"){
		$('#girlDisease').attr('class','re_icon14 re_icon14_cur');
		saveClaimAcc('add','14');
	}else{
		$('#girlDisease').attr('class','re_icon14');
		saveClaimAcc('del','14');
	}
}
function aids(a){
	if($('#aids').attr('class')=="re_icon15"){
		$('#aids').attr('class','re_icon15 re_icon15_cur');
		saveClaimAcc('add','15');
	}else{
		$('#aids').attr('class','re_icon15');
		saveClaimAcc('del','15');
	}
}

function emergencymedical(a){
	if($('#emergencymedical').attr('class')=="re_icon16"){
		$('#emergencymedical').attr('class','re_icon16 re_icon16_cur');
		saveClaimAcc('add','16');
	}else{
		$('#emergencymedical').attr('class','re_icon16');
		saveClaimAcc('del','16');
	}
}

function medicalvaccine(a){
	if($('#medicalvaccine').attr('class')=="re_icon17"){
		$('#medicalvaccine').attr('class','re_icon17 re_icon17_cur');
		saveClaimAcc('add','17');
	}else{
		$('#medicalvaccine').attr('class','re_icon17');
		saveClaimAcc('del','17');
	}
}

function congenitaldisease(a){
	if($('#congenitaldisease').attr('class')=="re_icon18"){
		$('#congenitaldisease').attr('class','re_icon18 re_icon18_cur');
		saveClaimAcc('add','18');
	}else{
		$('#congenitaldisease').attr('class','re_icon18');
		saveClaimAcc('del','18');
	}
}
function saveClaimAcc(method, value) {
	if (method == 'add') {
		var accTypesStr = $("#accTypesBy_").val();
		var accTypes = accTypesStr.split("_");
		var i = 0;
		// 判断是否已经保存了这个 索赔事故性质
		var flag = 0;
		for (; accTypes != '' && i < accTypes.length; i++) {
			if (accTypes[i] == value) {
				flag = 1;
				break;
			}
		}
		if (flag == 0) {
			if ($("#accTypesBy_").val() == '') {
				$("#accTypesBy_").val(value);
			} else {
				$("#accTypesBy_").val($("#accTypesBy_").val() + "_" + value);
			}
		}
	}

	if (method == 'del') {
		var accTypesStr = $("#accTypesBy_").val();
		var accTypes = accTypesStr.split("_");
		var i = 0;
		// 判断是否已经保存了这个 索赔事故性质
		var flag = 0;
		for (; accTypes != '' && i < accTypes.length; i++) {
			if (accTypes[i] == value) {
				accTypes[i] = '00';
				flag = 1;
				break;
			}
		}
		if (flag == 1) {
			var accTypesNew = '';
			i = 0;
			var position = 0;
			for (; accTypes != '' && i < accTypes.length; i++) {
				if (accTypes[i] != '00') {
					if (position == 0) {
						accTypesNew = accTypes[i];
					} else {
						accTypesNew = accTypesNew + '_' + accTypes[i];
					}
					position++;
				}
			}

			$("#accTypesBy_").val(accTypesNew);
		}
	}

}




//初始化省
function initProvinceCode(){
	if(provinceCodeStr!=""){
		provinceCodeStr=provinceCodeStr.substring(0, provinceCodeStr.length-1);
		var benefit_personTbltrs=$("#benefit_personTbl tr");
		var opeationStr="";
		for(var i=1;i<benefit_personTbltrs.length;i++){
			var tr=$(benefit_personTbltrs[i]);
			var payeeCityCode=tr.find("select[name='payeeCityCode']");
			var payeeProvince=tr.find("select[name='payeeProvince']");
			var hpayeeProvince=tr.find("input[name='hpayeeProvince']").val();//隐藏域省code
			var hpayeeCityCode=tr.find("input[name='hpayeeCityCode']").val();//市代码
			var array=provinceCodeStr.split(",");
			opeationStr="";
			for(var j=0;j<array.length;j++){
				var str=array[j].split(":");
				opeationStr+="<option value=\""+str[0]+"\">"+str[1]+"</option>";
			}
			payeeProvince.append(opeationStr);
			payeeProvince.val(hpayeeProvince);
			getPayeeCity(tr.attr("id"),'');
			payeeCityCode.val(hpayeeCityCode);
		}
	}
}
//获取领款人信息城市 
function getPayeeCity(id,obj){
	var tr;
	var payeeProvince="";
	var payeeCityCode;
	if(obj){//添加一行时
		payeeProvince=$(obj).val();
		payeeCityCode=$(obj).parent().next().find("select[name='payeeCityCode']");
	}else{
		 tr=$("#"+id);
		 payeeProvince=tr.find("select[name='payeeProvince']").val();
		 payeeCityCode=tr.find("select[name='payeeCityCode']");
	}
	if(payeeProvince!=undefined&&payeeProvince!=""){
		$.ajax({
			type : "POST",
			url : "/claimserver/epiboly/findCity.do",
			data : "provinceCode="+payeeProvince,
			async : false,
			error : function() {
				alert("获取城市失败");
				return;
			},
			success : function(data) {
				payeeCityCode.children("option:gt(0)").remove();
				for ( var i = 0; i < data.length; i++) {
					var city = data[i];
					payeeCityCode.append('<option value="'+city.areaCode+'">'+city.areaName+'</option>');
				}
			}

		});
	}
}
function selTblTr(obj,id){
	var index=$(obj).index();
	var tab=$("#"+id);
	tab.find("tr").css("background","");
	$(obj).css("background","lightblue");
	tab.find("input[name='deltrIndex']").val(index);
}
//产险银行名称模糊查询
function tipSearch(flag,index) {
	var bankname = null;
	if (flag == '1') {
		bankname = $("#propertyBankName_"+index).val();
	} 
	$.ajax({
			type : "POST",
			url : "../virementoperation/queryPropertyBank.do",
			data : {
				"bankname" : bankname
			},
			error : function() {
			},
			success : function(data) {
				if (flag == '1') {
					var ul = $("<ul id=\"tip\"></ul>");
					if (data.length > 0) {
						for ( var i = 0; i < data.length; i++) {
							$(ul).append(
											"<li style=\"background-color:#FFFFFF\" onmouseover=\"changbackclrFn(this)\" onblur=\"displayNone('1')\" onclick=\"selectedCompanyInfoFn('"
													+ data[i].bankName
													+ "','"
													+ data[i].bankGroupCode
													+ "','1','"+index+"')\">"
													+ data[i].bankName
													+ "</li>");
						}
						$("#tip-div").html(ul);
						$("#tip-div").css("display", "");
					} else {
						$("#tip-div").css("display", "none");
					}
				}

			}
		});
}
function changbackclrFn(flag) {
	$(flag).css("background-color", "#e5e5e5").siblings().css(
			"background-color", "#FFFFFF");
}
function displayNone(flag) {
	if (flag == '1') {
		$("#tip").css("display", "none");
	} else if (flag == '2') {
		$("#top").css("display", "none");
	}

}
function selBankName(obj){
	$("#tip-div").remove();
	
//	var left = obj.getBoundingClientRect().left - 50;
//	var top = obj.getBoundingClientRect().top + 125;
	
	var left = obj.getBoundingClientRect().left + document.documentElement.scrollLeft - 54;
	var top = obj.getBoundingClientRect().top + document.documentElement.scrollTop + 120;
	left=$(obj).position().left;
	top =$(obj).position().top;
	//position:absolute;
//	var html = "<div class=\"\" id=\"tip-div\" style=\"display:block;left:"+left+"px;top:"+top+"px; margin:0 0 0 53px; width:164px; z-index: 999;position:absolute\"></div>";
	var html = "<div class=\"\" id=\"tip-div\" style=\"display:block; margin:0 0 0 53px;left:"+left+"px;top:"+top+"px; width:164px; z-index: 9;position:absolute;\"></div>";
//	alert($(obj).parent("td:eq(0)").html());
//	$(obj).parent("td:eq(0)").append(html);
	$(obj).parent().append(html);
}

function selectedCompanyInfoFn(bankName, bankGroupCode, flag, index) {
	if (flag == '1') {
		$("#isnoPropertyBankName").val(bankName);
		$("#propertyBankName_"+index).val(bankName);
		$("#bankCode_"+index).val(bankGroupCode);
		$("#tip-div").css("display", "none");
	}

}	
function pickedFunc(e){
	var admissionDate = $("#admissionDate_"+$(this).attr("code")).val();
	var dischargeDate = $("#dischargeDate_"+$(this).attr("code")).val();
	
	var tr=$(this).parent().parent();
	admissionDate=tr.find("input[name='admissionDate']").val();
	dischargeDate=tr.find("input[name='dischargeDate']").val();
	var date1 = new Date(Date.parse(admissionDate.replace(/-/g,"/")));
	var date2 = new Date(Date.parse(dischargeDate.replace(/-/g,"/")));
	
	var days = (date2.getTime() - date1.getTime())/(24 * 60 * 60 * 1000);
	if(admissionDate!=''&&dischargeDate!=''){
//		$("#hospitalizedDays_"+$(this).attr("code")).val(days);
		tr.find("input[name='hospitalizedDays']").val(days+1);
	}
	
}
//选择领款人类型
function claimPayeeTypeFn(obj){
	var sel=$(obj);
	var tr=sel.parent().parent();
	var val=sel.find("option:selected").val();
	var option='';
	if(val=='2'){//单位
		option='<option value="01">雇主</option><option value="99">其他</option>';
		tr.find("select[name='payeeInsRelationship'] option:gt(0)").remove();
		tr.find("select[name='payeeInsRelationship']").append(option);
	}else if(val=="1"){//个人
		var relationshipOption='<option value="">请选择</option><option value="401">本人</option><option value="402">配偶</option><option value="403">父子</option><option value="404">父女</option>'
			+'<option value="405">受益人</option><option value="406">被保人</option><option value="407">投保人</option><option value="408">其他</option><option value="409">母子</option><option value="410">母女</option>'
			+'<option value="411">兄弟</option><option value="412">姊妹</option><option value="413">兄妹</option><option value="414">姐弟</option><option value="415">祖孙</option><option value="416">雇佣</option><option value="417">业务员</option>';
		tr.find("select[name='payeeInsRelationship']").html('').append(relationshipOption);
	}else{
		tr.find("select[name='payeeInsRelationship']").html('<option value="">请选择</option>');
	}
}
function validateRules(){
	var claimNo=$("#hclaimNo").val();
	$.ajax({
		type : "POST",
		url : "/claimserver/epiboly/filedValidateRules.do",
		data : "claimNo="+claimNo,
		error : function() {
			alert("校验失败！");
			return;
		},
		success : function(data) {
			alert("校验完成");
		}

	});
}
//校验数据
function checkEndCaseData(state){
	var result=true;
	var benefit_personTblTrs=$("#benefit_personTbl tr");
	var reg=/^\d{1,3}$/;
	var sum=0;
	var payeeFlag=checkPayeeInfo();//校验领款人信息
	var rateFlag=false;
	var accidentDesc=$("#accidentDesc").val();//出险经过
	var auditOption=$("#auditOption").val();//审核意见 
	var reAuditOption=$("#reAuditOption").val();//复核意见
	if(!payeeFlag){
		return false;
	}
	getDrawMoney();//获取金额，支付比例
	savePayeeInfo('0');//保存领款人信息
	rateFlag=checkRate();//支付金额，比例
	if(state=='4'){//结案
		if(rateFlag=='0'){
			alert('没有对应责任');
			return false;
		}
	}else{
		/*if(rateFlag=='0'){
//			alert('没有对应责任');
			return true;
		}else */if(rateFlag=='2'){//
			return false;
		}
	}
	
	if(accidentDesc.length>400){
		alert('出险信息：出险经过内容过长！');
		return false;
	}
	if(auditOption.length>750){
		alert("审核意见内容过长！");
		return false;
	}
	if(reAuditOption.length>250){
		alert("复核意见内容过长！");
		return false;
	}
	if(state!='4'&&rateFlag=='0'){
		return true;
	}
	/*for(var i=1;i<benefit_personTblTrs.length;i++){
		var tr=$(benefit_personTblTrs[i]);
		var payRate=tr.find("input[name='payRate']").val();
		if(!reg.test(payRate)){
			alert('支付比例不符合规范！');
			result=false;
			break;
		}else{
			sum+=parseFloat(payRate);
		}
	}
	if(result){
		if(sum!=100){
			alert('支付比例和应为100');
			result=false;
		}
	}*/
	return result;
}
//领款人信息，责任
function getClmPayeeLiabsJson(){
	var str="";
	var benefit_personTbltrs=$("#benefit_personTbl tr");
	for(var i=1;i<benefit_personTbltrs.length;i++){
		var tr=$(benefit_personTbltrs[i]);
		var id=tr.find("input[name='hPayeeLiabId']").val();//liab，主键
		var policyNo=tr.find("input[name='policyNo']").val();//保单号
		var claimPayeeId=tr.find("input[name='claimPayeeId']").val();//liab，证件号码
		var claimPayeeName=tr.find("input[name='claimPayeeName']").val();//liab，名称
		var classCode=tr.find("select[name='classCode']").val();//险种代码
		var delCode=tr.find("input[name='delCode']").val();//责任编码
		var payLiabDrawMoney=tr.find("input[name='payLiabDrawMoney']").val();//支付金额
		var bankAccountNo=tr.find("input[name='bankAccountNo']").val();//银行账号
		var bankCode=tr.find("input[name='bankCode']").val();//银行代码
		var idType=tr.find("select[name='claimPayeeIdType']").val();//证件类型
		id=id==undefined?"":id;
		str+='{"objId":"'+id+'","policyNo":"'+policyNo+'","pid":"'+claimPayeeId+'","payeeName":"'+claimPayeeName+'","classCode":"'+classCode+'","delCode":"'+delCode+'","drawMoney":"'+payLiabDrawMoney
				+'","bankCode":"'+bankCode+'","bankAccountNo":"'+bankAccountNo+'","idType":"'+idType+'"},';
	}
	if(str!=""){
		return str.substring(0, str.length-1);
	}else{
		return "";
	}
}
function rateBlur(flag){
	var rate=0;
	var c_n=$(flag).attr("class").split(' ')[2];
	var val=$(flag).val();
	if(isDecimal(val)==false){
		alert("输入项必须为数字，请重新输入");
		return;
	}
	if(eval(val)==undefined){
		val=0;
	} 
    rate=rate+eval(val);
	/*$("#clmPayeeTbl ."+c_n).each(function(){
		var val=$(this).val();
		if(isDecimal(val)==false){
			alert("输入项必须为数字，请重新输入");
			return;
		}
		if(eval(val)==undefined){
			val=0;
		} 
	    rate=rate+eval(val);
	  });*/
	if(rate>100){
		 alert("该责任总支付比率已超过100%，请重新设置");
		 $(flag).val("");
		 $(flag).parent().parent().children('td').eq(8).find("input").val("");
		 return;
	}
	
	var payRate = $(flag).val();
	var drawMoney = $(flag).parent().parent().children('td').eq(3).find("input").val()*payRate/100;
	$(flag).parent().parent().children('td').eq(8).find("input").val(drawMoney.toFixed(2));
	
	
}
function drawBlur(flag){
	var drawMoney = $(flag).parent().parent().children('td').eq(8).find("input").val();
	var realClaimAmt = $(flag).parent().parent().children('td').eq(3).find("input").val();
	var payRate;
	if(realClaimAmt==0){
		payRate=0;
	}else{
		payRate = drawMoney/realClaimAmt*100;
	}
	$(flag).parent().parent().children('td').eq(7).find("input").val(payRate.toFixed(2));
}
//保存领款人信息
function savePayeeInfo(flag){
	var payeeFlag=checkPayeeInfo();
	if(payeeFlag){
		var jsonStr=getBenefit_personJson();
		if(jsonStr!=''){
			var str='{"benefit_persons":['+jsonStr+']}';
			var payeeTypeMap={};
			payeeTypeMap['a']='身份证';
			payeeTypeMap['c']='护照';
			payeeTypeMap['d']='军官证';
			payeeTypeMap['j']='港澳台护照';
			payeeTypeMap['l']='台湾居民通行证';
			payeeTypeMap['z']='其他';
			$.ajax({
				type : "POST",
				url : "/claimserver/epiboly/savePayeeInfo.do",
				contentType:"application/json; charset=UTF-8",
				data : str,
				async : false,
				error : function() {
					alert("保存领款人信息失败");
					return;
				},
				success : function(data) {
					if(flag=="1"){
						alert("保存领款人信息成功");
					}
					var payeeVos=data.payeeVos;
					var trStr='';
					for(var i=0;i<payeeVos.length;i++){
						var vo=payeeVos[i];
						var rate=payeeRate[getVal(vo.policyNo)+getVal(vo.classCode)+getVal(vo.delCode)+getVal(vo.typeNo)+getVal(vo.claimPayeeId)];
						var money=payeeLibDrayMoney[getVal(vo.policyNo)+getVal(vo.classCode)+getVal(vo.delCode)+getVal(vo.typeNo)+getVal(vo.claimPayeeId)];
						if(rate==undefined){
							rate=getVal(vo.payRate);
						}
						if(money==undefined){
							money=getVal(vo.drawMoney);
						}
						trStr+='<tr><td>'+getVal(vo.policyNo)+'</td><td>'+getVal(vo.classname)+'<input type="hidden" value="'+getVal(vo.classCode)+'" name="classCode"/></td><td>'+getVal(vo.delName)+'<input type="hidden" value="'+getVal(vo.delCode)+'" name="delCode"/>'
	              		+'<input type="hidden" value="'+getVal(vo.typeNo)+'" name="typeNo"/>'
	              		+'<input type="hidden" value="'+getVal(vo.bankCode)+'" name="bankCodeLiab" />'
	              		+'<input type="hidden" value="'+getVal(vo.bankAccountNo)+'" name="bankAccountNoLiab" />'
	              		+'</td>'
						+'<td>'+getVal(vo.remainPrem)+'<input type="hidden" value="'+vo.realClmAmt+'" /></td><td>'+getVal(vo.claimPayeeName)+'</td><td>'+getVal(payeeTypeMap[vo.claimPayeeIdType])+'<input type="hidden" name="claimPayeeIdType" value="'+getVal(vo.claimPayeeIdType)+'" /></td>'
						+'<td>'+getVal(vo.claimPayeeId)+'<input type="hidden" name="claimPayeeId" value="'+vo.claimPayeeId+'"/><input type="hidden" name="polId" value="'+vo.polId+'"/><input type="hidden" name="dutytype" value="'+vo.dutytype+'"><input type="hidden" name="payeeId" value="'+getVal(vo.payeeId)+'"></td><td><input type="text" class="input i_s_60 '+getVal(vo.dutytype)+'" name="payRate" onblur="rateBlur(this)" value="'+rate+'"  />%</td>'
						+'<td><input type="text" class="input i_s_60" name="drawMoney" onblur="drawBlur(this)" value="'+money+'" /></td></tr>';
					}
					$("#clmPayeeTbl tr:gt(0)").remove();
					$("#clmPayeeTbl").append(trStr);
				}

			});
		}
	}
	
}
function getClmPayeeInfo(){
	str="";
	var clmPayeeTbltrs=$("#clmPayeeTbl tr");
	var claimNo=$("#hclaimNo").val();
	var payeeMap={};
	for(var i=1;i<clmPayeeTbltrs.length;i++){
		var tr=$(clmPayeeTbltrs[i]);
		var policyNo=tr.find("td:eq(0)").html();//保单号
		var bankCode=tr.find("input[name='bankCodeLiab']").val();//银行代码
		var bankAccountNo=tr.find("input[name='bankAccountNoLiab']").val();//银行账号
		var classCode=tr.find("input[name='classCode']").val();//险种代码
		var delCode=tr.find("input[name='delCode']").val();//责任代码
		var typeNo=tr.find("input[name='typeNo']").val();//责任子码
		var claimPayeeIdType=tr.find("input[name='claimPayeeIdType']").val();//证件类型id
		var claimPayeeId=tr.find("input[name='claimPayeeId']").val();//证件号码
		var claimPayeeName=tr.find("td:eq(4)").html();//领款人姓名
		var payRate=tr.find("input[name='payRate']").val();//支付比例
		var drawMoney=tr.find("input[name='drawMoney']").val();//支付金额
		claimPayeeIdType=claimPayeeIdType==undefined?"":claimPayeeIdType;
		claimPayeeId=claimPayeeId==undefined?"":claimPayeeId;
		if(policyNo!=""&&policyNo!=undefined){
			payeeMap['policyNo']=policyNo;
		}
		if(classCode!=""&&classCode!=undefined){
			payeeMap['classCode']=classCode;
		}
		if(delCode!=""&&delCode!=undefined){
			payeeMap['delCode']=delCode;
		}
		if(typeNo!=""&&typeNo!=undefined){
			payeeMap['typeNo']=typeNo;
		}
		policyNo=policyNo==""?payeeMap['policyNo']:policyNo;
		classCode=classCode==""?payeeMap['classCode']:classCode;
		delCode=delCode==""?payeeMap['delCode']:delCode;
		typeNo=typeNo==""?payeeMap['typeNo']:typeNo;
		if(policyNo!=""&&classCode!=""&&delCode!=""&&typeNo!=""&&claimPayeeId!=""){
			drawMoney=payeeLibDrayMoney[policyNo+classCode+delCode+typeNo+claimPayeeId];
			payRate=payeeRate[policyNo+classCode+delCode+typeNo+claimPayeeId];
		}
		str+='{"claimNo":"'+claimNo+'","policyNo":"'+policyNo+'","classCode":"'+classCode+'","delCode":"'+delCode+'","typeNo":"'+typeNo+'","idType":"'+claimPayeeIdType+'","pid":"'+claimPayeeId
		+'","payeeName":"'+claimPayeeName+'","ffRate":"'+payRate+'","drawMoney":"'+drawMoney+'","bankCode":"'+bankCode+'","bankAccountNo":"'+bankAccountNo+'"},';
	}
		if(str!=""){
			return str.substring(0, str.length-1);
		}else{
			return "";
		}
}
function getClmPayeeLiabs(){
	str="";
	var clmPayeeTbltrs=$("#clmPayeeTbl tr");
	var claimNo=$("#hclaimNo").val();
	var payeeMap={};
	var benefit_personTbl_trs=$("#benefit_personTbl tr");//领款人信息
	for(var i=1;i<clmPayeeTbltrs.length;i++){
		var tr=$(clmPayeeTbltrs[i]);
		var policyNo=tr.find("td:eq(0)").html();//保单号
		var classCode=tr.find("input[name='classCode']").val();//险种代码
		var delCode=tr.find("input[name='delCode']").val();//责任代码
		var typeNo=tr.find("input[name='typeNo']").val();//责任子码
		var claimPayeeIdType=tr.find("input[name='claimPayeeIdType']").val();//证件类型id
		var claimPayeeId=tr.find("input[name='claimPayeeId']").val();//证件号码
		var claimPayeeName=tr.find("td:eq(4)").html();//领款人姓名
		var payRate=tr.find("input[name='payRate']").val();//支付比例
		var drawMoney=tr.find("input[name='drawMoney']").val();//支付金额
		if(policyNo!=""&&policyNo!=undefined){
			payeeMap['policyNo']=policyNo;
		}
		if(classCode!=""&&classCode!=undefined){
			payeeMap['classCode']=classCode;
		}
		if(delCode!=""&&delCode!=undefined){
			payeeMap['delCode']=delCode;
		}
		if(typeNo!=""&&typeNo!=undefined){
			payeeMap['typeNo']=typeNo;
		}
		policyNo=policyNo==""?payeeMap['policyNo']:policyNo;
		classCode=classCode==""?payeeMap['classCode']:classCode;
		delCode=delCode==""?payeeMap['delCode']:delCode;
		typeNo=typeNo==""?payeeMap['typeNo']:typeNo;
		str+='{"claimNo":"'+claimNo+'","policyNo":"'+policyNo+'","classCode":"'+classCode+'","delCode":"'+delCode+'","typeNo":"'+typeNo+'","idType":"'+claimPayeeIdType+'","pid":"'+claimPayeeId
			+'","payeeName":"'+claimPayeeName+'","ffRate":"'+payRate+'","drawMoney":"'+drawMoney+'"},';
	}
	if(str!=""){
		return str.substring(0, str.length-1);
	}else{
		return "";
	}
}

function getDrawMoney(){
	var clmPayeeTbltrs=$("#clmPayeeTbl tr");
	var payeeMap={};
	for(var i=1;i<clmPayeeTbltrs.length;i++){
		var tr=$(clmPayeeTbltrs[i]);
		var policyNo=tr.find("td:eq(0)").html();//保单号
		var classCode=tr.find("input[name='classCode']").val();//险种代码
		var delCode=tr.find("input[name='delCode']").val();//责任代码
		var typeNo=tr.find("input[name='typeNo']").val();//责任子码
		var claimPayeeId=tr.find("input[name='claimPayeeId']").val();//证件号码
		var payRate=tr.find("input[name='payRate']").val();
		var drawMoney=tr.find("input[name='drawMoney']").val();
		claimPayeeId=claimPayeeId==undefined?"":claimPayeeId;
		if(policyNo!=""&&policyNo!=undefined){
			payeeMap['policyNo']=policyNo;
		}
		if(classCode!=""&&classCode!=undefined){
			payeeMap['classCode']=classCode;
		}
		if(delCode!=""&&delCode!=undefined){
			payeeMap['delCode']=delCode;
		}
		if(typeNo!=""&&typeNo!=undefined){
			payeeMap['typeNo']=typeNo;
		}
		policyNo=policyNo==""?payeeMap['policyNo']:policyNo;
		classCode=classCode==""?payeeMap['classCode']:classCode;
		delCode=delCode==""?payeeMap['delCode']:delCode;
		typeNo=typeNo==""?payeeMap['typeNo']:typeNo;
		if(policyNo!=""&&classCode!=""&&delCode!=""&&typeNo!=""&&claimPayeeId!=""){
			payeeLibDrayMoney[policyNo+classCode+delCode+typeNo+claimPayeeId]=drawMoney;
			payeeRate[policyNo+classCode+delCode+typeNo+claimPayeeId]=payRate;
		}
		
	}
}
//校验领款人信息
function checkPayeeInfo(){
	var benefit_personTbltrs=$("#benefit_personTbl tr");
	var flag=true;
	for(var i=1;i<benefit_personTbltrs.length;i++){
		var tr=$(benefit_personTbltrs[i]);
		var claimPayeeId=tr.find("input[name='claimPayeeId']").val();//证件号码
		var claimPayeeName=tr.find("input[name='claimPayeeName']").val();//名称
		var payeePostCode=tr.find("input[name='payeePostCode']").val();//邮政编码
		var payMode=tr.find("select[name='payMode']").val();//支付方式
		if(claimPayeeId==""||$.trim(claimPayeeId)==""){
			alert('证件号码为空！');
			flag=false;
			break;
		}
		if(claimPayeeName==""||$.trim(claimPayeeName)==""){
			alert('领款人名称为空！');
			flag=false;
			break;
		}
		if(payeePostCode!=""&&payeePostCode.length>6){
			alert('邮政编码不能超过6位！');
			flag=false;
			break;
		}
		if(payMode==""){
			alert("请选择支付方式!");
			flag=false;
			break;
		}
		
	}
	return flag;
}
//校验比例
function checkRate(){
	var clmPayeeTbltrs=$("#clmPayeeTbl tr");
	var payeeMap={};
	var flag='0';
	var rateMap={};
	var keyStr='';
	var index=0;
	for(var i=1;i<clmPayeeTbltrs.length;i++){
		var tr=$(clmPayeeTbltrs[i]);
		var policyNo=tr.find("td:eq(0)").html();//保单号
		var classCode=tr.find("input[name='classCode']").val();//险种代码
		var delCode=tr.find("input[name='delCode']").val();//责任代码
		var typeNo=tr.find("input[name='typeNo']").val();//责任子码
//		var payRate=tr.find("input[name='payRate']").val();
		var claimPayeeId=tr.find("input[name='claimPayeeId']").val();
		if(policyNo!=""&&policyNo!=undefined){
			payeeMap['policyNo']=policyNo;
		}
		if(classCode!=""&&classCode!=undefined){
			payeeMap['classCode']=classCode;
		}
		if(delCode!=""&&delCode!=undefined){
			payeeMap['delCode']=delCode;
		}
		if(typeNo!=""&&typeNo!=undefined){
			payeeMap['typeNo']=typeNo;
		}
		policyNo=policyNo==""?payeeMap['policyNo']:policyNo;
		classCode=classCode==""?payeeMap['classCode']:classCode;
		delCode=delCode==""?payeeMap['delCode']:delCode;
		typeNo=typeNo==""?payeeMap['typeNo']:typeNo;
		//根据保单号+险种代码+责任编码+责任子码+证件号码取支付比例
		if(payeeRate[policyNo+classCode+delCode+typeNo+claimPayeeId]!=undefined){
			if(rateMap[policyNo+classCode+delCode+typeNo]!=undefined){
				var temp=parseFloat(rateMap[policyNo+classCode+delCode+typeNo]);
				rateMap[policyNo+classCode+delCode+typeNo]=parseFloat(payeeRate[policyNo+classCode+delCode+typeNo+claimPayeeId])+temp;
			}else{
				rateMap[policyNo+classCode+delCode+typeNo]=payeeRate[policyNo+classCode+delCode+typeNo+claimPayeeId];
				keyStr+=policyNo+classCode+delCode+typeNo+",";
			}
		}
	}
	//判断领款人列表，保单号+险种代码+责任编码+责任子码的支付比例和为100
	if(keyStr!=''){
		keyStr=keyStr.substring(0, keyStr.length-1);
		var array=keyStr.split(",");
		for(var j=0;j<array.length;j++){
			if(rateMap[array[j]]!=100){
				alert('支付比例和不等于100！');
				flag='2';
				break;
			}else{
				if(rateMap[array[j]]==100){
					index++;
					if(index==array.length){
						flag='1';
					}
				}
			}
		}
	}
	return flag;
}

function shoCxJbDiv(){
	if($("#accidentCode").val()==null || $("#accidentCode").val()==""){
		alert("请选择出险类型！");
		return false;
	}
	$("#jbzd1").html("");
	$("#jbcontent1").val("");
	showDiv('opencx1');
}
/**疾病诊断保存*/
function saveCxDiv(id) {
	var jibing = 0;
	var jbname="";
	$("#jbzd1").find("span").each(function() {
		if ($(this).is(".check_yes")){
			if(jibing==0){
				jbname = $(this).attr("code")+$(this).attr("name");
				if($("#hcxclaimIlls").val()==""){
					$("#hcxclaimIlls").val($(this).attr("code"));
					$("#jbresultData1").append("<tr>" +
							"<td width=\"23%\">"+$(this).attr("code")+"</td>" +
							"<td width=\"45%\">"+$(this).attr("name")+"</td>" +
							"<td width=\"21%\"><a  style=\"cursor: pointer;\" class=\"icon_del\" onclick=\"deljbresultData1(this,'"+$(this).attr("code")+"')\"></a></td>" +
							"</tr>");
				}else{
					if($("#hcxclaimIlls").val().indexOf($(this).attr("code"))<0){
						$("#hcxclaimIlls").val($("#hcxclaimIlls").val()+'_'+$(this).attr("code"));
						$("#jbresultData1").append("<tr>" +
								"<td width=\"23%\">"+$(this).attr("code")+"</td>" +
								"<td width=\"45%\">"+$(this).attr("name")+"</td>" +
								"<td width=\"21%\"><a  style=\"cursor: pointer;\" class=\"icon_del\" onclick=\"deljbresultData1(this,'"+$(this).attr("code")+"')\"></a></td>" +
								"</tr>");
					}
				}
			}else{
				if($("#hcxclaimIlls").val().indexOf($(this).attr("code"))<0){
					$("#hcxclaimIlls").val($("#hcxclaimIlls").val()+'_'+$(this).attr("code"));
					$("#jbresultData1").append("<tr>" +
							"<td width=\"23%\">"+$(this).attr("code")+"</td>" +
							"<td width=\"45%\">"+$(this).attr("name")+"</td>" +
							"<td width=\"21%\"><a  style=\"cursor: pointer;\" class=\"icon_del\" onclick=\"deljbresultData1(this,'"+$(this).attr("code")+"')\"></a></td>" +
							"</tr>");
				}
			}
			jibing = jibing+1;
			
		}
	});

	$("#clmIll").val(jbname);
	
	if(jibing>1)
		$("#clmIll").val(jbname+"....");
	$.closePopupLayer(id);
}
/**疾病列表查询删除当前*/
function deljbresultData1(data,illCode){
	if(confirm("确认删除当前行？")){
		var trcurrent = $(data).parent().parent();
		trcurrent.remove();
		delClaimIll(illCode); 
	}
}


function delClaimIll(value){
	var claimIllsBy_ = $("#hcxclaimIlls").val();
	var illTypes = claimIllsBy_.split("_");
	var i = 0 ;
	//判断是否已经保存了这个 索赔事故性质
	var flag = 0;
	for(; illTypes != '' && i < illTypes.length ; i++ ){
		if(illTypes[i]==value){
			illTypes[i] = '00';
			flag = 1;
			break;
		}
	}
	if(flag==1){
		var illTypesNew = '';
		i = 0;
		var position = 0;
		for(; illTypes != '' && i < illTypes.length ; i++ ){
			if(illTypes[i]!='00'){
				if(position==0){
					illTypesNew = illTypes[i];
				}else{
					illTypesNew = illTypesNew + '_' + illTypes[i];
				}
				position++; 
			}
		}
		$("#hcxclaimIlls").val(illTypesNew);
		var tr = $("#illTblList1").find("tr");
		var bodytr = $("#jbresultData1").find("tr");
		if(tr.length+bodytr.length>2){
			if(tr.length>1){
				var code = $(tr[1]).find("td:eq(0)");
				var name = $(tr[1]).find("td:eq(1)");
				$("#clmIll").val(code.text()+" "+name.text()+"....");
			}else{
				var code = $(bodytr[0]).find("td:eq(0)");
				var name = $(bodytr[0]).find("td:eq(1)");
				$("#clmIll").val(code.text()+" "+name.text()+"....");
			}
		}else if(tr.length+bodytr.length>1){
			if(tr.length>1){
				var code = $(tr[1]).find("td:eq(0)");
				var name = $(tr[1]).find("td:eq(1)");
				$("#clmIll").val(code.text()+" "+name.text());
			}else{
				var code = $(bodytr[0]).find("td:eq(0)");
				var name = $(bodytr[0]).find("td:eq(1)");
				$("#clmIll").val(code.text()+" "+name.text());
			}
		}else{
			$("#clmIll").val("");
		}
	} 

}

function errorButton(){

	var errCause="";
	var errFlag="";
	if($("#isErrorVal").attr("class")=='check_yes'){
		errFlag="no";
		
	}else if($("#isErrorVal").attr("class")=='check_no'){
		var errCauseStr=$("#errorCauseStr").val();
		for(var i=1;i<8;i++){
			if(errCauseStr.charAt(i-1)=='1'){
				$("#cause"+i).attr("checked","checked");
			}
			
		}
		showDiv('error_cause');
		errFlag="yes"; 
	}
	//alert($("#errClaimNo").val());
	$.ajax({
		type:"post",
		url:"/claimserver/inspection/clmtask/isErrorButton.do",
		data:{"claimNo":$("#errClaimNo").val(),"flag":errFlag ,"isErrorCause":errCause,"isErrorInfo":$("#error_cause_info").val()},
		error:function(){
			
		},
		success:function(data){
			
			if(data.errMassage=="success"){
				//alert("成功！");
			}
		}
	});
	
}

function errorButton_save(){
	errCause="";
	for(var i=1;i<8;i++){
		if($("#cause"+i).prop("checked")){
			errCause=errCause+"1";
		}else{
			errCause=errCause+"0";
		}
		
	}
	
	errFlag="yescommit";
	$.ajax({
		type:"post",
		url:"/claimserver/inspection/clmtask/isErrorButton.do",
		data:{"claimNo":$("#errClaimNo").val(),"flag":errFlag ,"isErrorCause":errCause,"isErrorInfo":$("#error_cause_info").val()},
		success:function(data){
			
			if(data.errMassage=="success"){
			}
		}
	});
	closeDiv('error_cause');
}