$(function(){
	$(".check_yes,.check_no").unbind("click");//移除click事件
	var caseSource = $("#caseSource").val();
	var isBpo = $("#isBpo").val();
	if(caseSource=="3" && isBpo=="N"){
	   $("#branchSource").hide();
	   $("#branchSourceId").hide();
		$("#branchIdSelect").show();
		
	}else{
		$("#branchIdSelect").hide();
		$("#branchSource").show();
		$("#branchSourceId").show();
	}
});

function selectShenType(flag){
	$(flag).attr("value")=='1'?$(flag).val('0'):$(flag).val('1');
	
}

function selectFuType(flag){

	$(flag).val()=='1'?$(flag).val('0'):$(flag).val('1');
	$(flag).val()=='1'?$("#quest").removeClass("check_no").addClass("check_yes"):$("#quest").removeClass("check_yes").addClass("check_no");
	
}

function skip2OtherPageByClaimNo(url,claimNo){
	var params = new Array();
	params["claimNo"] = claimNo;
	SkipByPost(url, params);
}
function skip2OtherPage(url,claimNo,pid,pageFrom,channelType){
	var params = new Array();
	params["claimNo"] = claimNo;
	params["pid"] = pid;
	params["pageFrom"] = pageFrom;
	params["channelType"] = channelType;
	
	SkipByPost(url, params);
}
function skip2NoticePage(url,claimNo,noticeType) {
	if (noticeType != "01" && noticeType != "02" && noticeType != "03" && noticeType != "04") {
		alert("通知书类型错误！");
		return;
	}
	var params = new Array();
	params["claimNo"] = claimNo;
	params["noticeType"] = noticeType;
	SkipByPost(url, params);
}
function waringInfo(information){
	if (null != information && "" != information) {
		alert(information);
	}
	return false;
}

function convertCaseSourceToChannelType(caseSource) {
	//caseSource:1产险\2寿险\3健康险
	//channelType:0健康险\1寿险\2产险
	var channelType = "0";
	if ("1" == caseSource) {
		channelType = "2";
	} else if ("2" == caseSource) {
		channelType = "1";
	}
	return channelType;
}

function reAuditOption(str){
	$("#reAuditOption").val(str);
}


function completeAuditInfo(inputUrl,claimNos) {
	
	var branchIdSelect=$("#branchIdSelect").val();
	var claimNoStr=$('#claimNoId').val();
	var conFlag=false;
	var errorEnd=false;
	 $.ajax({
		 async:false,
		 type:"POST",
		 url: "checkBranchId.do",
		 data:{"claimNo":claimNoStr},
		 error:function(){
			alert("服务器忙！"); 
			errorEnd=true;
		 },
		 success:function(data){
            if('N'==data){
            	 conFlag=true;
            }
		 }
	 });
	 if(errorEnd==true){
		 return false;
	 }
	 if(conFlag==true){
		 if(!confirm(" 赔案所属机构和保单所属机构不一致，是否继续 ? ")){
			 return false;
		 }
	 }
	$("#ok").css("color","#ccc");
	$("#ok").removeAttr("onclick");
	var isQuest=$("#quest").attr("value");
	var params = {};
	params["claimNo"] = claimNos;
	params["isQuest"]=isQuest;
	params["branchIdSelect"]=branchIdSelect;
	$.ajax({
		 type:"POST",
		 url: "checkRcptBillRepeat.do",
		 dataType:"json",
		 contentType:"application/json",
		 data:JSON.stringify(params),	
		 error:function(){
			 $("#ok").css("color","#007aff");
			 $("#ok").attr("onclick","completeAuditInfo("+inputUrl+","+claimNos+")");
			 alert("保存失败！");
			 return;
		 },
		 success:function(data){
			 
			 if(data.bankCode == 'Y'){
				 alert("领款人银行代码为空,请修改!");
				 return false;
			 }
			 if(data.accountNo == 'Y'){
				 alert("领款人银行账号为空,请修改!");
				 return false;
			 }
			 if(data.bankName == 'Y'){
				 alert("领款人银行名称为空,请修改!");
				 return false;
			 }
			 
			 if(data.isAllowEvent){
				 if(!confirm("无津贴险对应事件！是否继续？")){
					 $("#ok").css("color","#007aff");
					 $("#ok").attr("onclick","completeAuditInfo('"+inputUrl+"','"+claimNos+"')");
					 return;
				 }
			 }
			 if(data.invoiceNo){
				 if(!confirm("该发票号与"+data.claimNo+"的发票号重复，是否完成审核？")){
					 
					 $("#ok").css("color","#007aff");
					 $("#ok").attr("onclick","completeAuditInfo("+inputUrl+","+claimNos+")");
					 return;
				 }
				//AJAX提交
				 $.ajax({
					 type:"POST",
					 url: inputUrl,
					 dataType:"json",
					 contentType:"application/json",
					 data:JSON.stringify(params),	
					 error:function(){
						 $("#ok").css("color","#007aff");
						 $("#ok").attr("onclick","completeAuditInfo("+inputUrl+","+claimNos+")");
						 alert("保存失败！");
						 return;
					 },
					 success:function(data){
						 if (data.successFlag == 'Y') {
							
							var skipFlag = data.skipFlag;//1跳理算页面，2跳任务池页面
							
							if (skipFlag == '1') {
								var claimNo = data.claimNo;
								var claimAuditTaskNo = data.claimAuditTaskNo;
								var claimState = data.claimState;
								var claimSource = data.claimSource;
								var taskType = data.taskType;
								var customerno = data.customerno;
								var regDate = data.regDate;
								
								params = {};
								params["claimNo"] = claimNo;
								params["claimAuditTaskNo"] = claimAuditTaskNo;
								params["claimState"] = claimState;
								params["claimSource"] = claimSource;
								params["taskType"] = taskType;
								params["customerno"] = customerno;
								params["regDate"] = regDate;
								
								//判断是否寿组合贴牌
								var lifeClaimStatus = $("#lifeClaimStatus").val();
								var caseSource = $("#caseSource").val();
								var lifeFLag = $("#lifeFLag").val();
								if(caseSource=='2'&&lifeFLag=='1'){
									params["lifeClaimStatus"] = lifeClaimStatus;
								}else{
									params["lifeClaimStatus"] = '0';
								}
								
								SkipByPost("../adjustment/adjustmentInfo.do", params);
							} else {
								window.location.href = 'queryWorkbench.do';
							}
						 } else {
							 $("#ok").css("color","#007aff");
							 $("#ok").attr("onclick","completeAuditInfo('"+inputUrl+"','"+claimNos+"')");
							 alert(data.errorMsg);
						 }
					 }
				 });
				 
			 }
			 if(!data.invoiceNo){
				//AJAX提交
				 $.ajax({
					 type:"POST",
					 url: inputUrl,
					 dataType:"json",
					 contentType:"application/json",
					 data:JSON.stringify(params),	
					 error:function(){
						 $("#ok").css("color","#007aff");
						 $("#ok").attr("onclick","completeAuditInfo("+inputUrl+","+claimNos+")");
						 alert("保存失败！");
						 return;
					 },
					 success:function(data){
						 if (data.successFlag == 'Y') {
							
							var skipFlag = data.skipFlag;//1跳理算页面，2跳任务池页面
							
							if (skipFlag == '1') {
								var claimNo = data.claimNo;
								var claimAuditTaskNo = data.claimAuditTaskNo;
								var claimState = data.claimState;
								var claimSource = data.claimSource;
								var taskType = data.taskType;
								var customerno = data.customerno;
								var regDate = data.regDate;
								
								params = {};
								params["claimNo"] = claimNo;
								params["claimAuditTaskNo"] = claimAuditTaskNo;
								params["claimState"] = claimState;
								params["claimSource"] = claimSource;
								params["taskType"] = taskType;
								params["customerno"] = customerno;
								params["regDate"] = regDate;
								
								//判断是否寿组合贴牌
								var lifeClaimStatus = $("#lifeClaimStatus").val();
								var caseSource = $("#caseSource").val();
								var lifeFLag = $("#lifeFLag").val();
								if(caseSource=='2'&&lifeFLag=='1'){
									params["lifeClaimStatus"] = lifeClaimStatus;
								}else{
									params["lifeClaimStatus"] = '0';
								}
								
								SkipByPost("../adjustment/adjustmentInfo.do", params);
							} else {
								window.location.href = 'queryWorkbench.do';
							}
						 } else {
							 $("#ok").css("color","#007aff");
							 $("#ok").attr("onclick","completeAuditInfo('"+inputUrl+"','"+claimNos+"')");
							 alert(data.errorMsg);
						 }
					 }
				 });
			 }
		 }
	 });
	
	
}

function showDivs(){
	showDiv('open4');
	$('#reAuditOption').val('');
}
function showCommonInsurence(pid) {
//	http://localhost:8081/claimserver/management/pubAmount/personDetails.do?pid=53533650
	window.open('../management/pubAmount/personDetails.do?pid='+pid,"保单影像");

}

function openPersonCommonPage(policyNo, pid) {
	window.open('../management/pubAmount/authorize.do?policyNo='+policyNo+'&pid='+pid, "CommonInsurancePage");
}

function showUnderWritingInfo(claimNo,docuType) {
	 $.ajax({
        type: "POST",
        url:"showUnderWritingInfo.do",
        data:{"claimNo":claimNo,"docuType":docuType},	
		 error:function(){
			 alert("查询失败！");
			 return;
		 },
		 success:function(data){
		   var underwritings = data.underwritings;
		   if(docuType=="107"){
	   		   $("#tjxx tr:eq(0) + tr").remove();
	   		   $("#tjxx").append("<tr>" +
	   		   		"<td>" +data.pname+"</td>"+
		   		   	"<td>" +data.gender+"</td>"+
			   		 "<td>" +data.pid+"</td>"+
			   		 "<td>" +data.birthDate+"</td>"+
			   		 "<td>" +underwritings[0].opername+"</td>"+
			   		 "<td>" +underwritings[0].operdate+"</td>"+
	   		   	"</tr>");
	   		   $("#tjRequest").html(underwritings[0].describe);
	          showDiv('open5');
		   }else if(docuType=="108"){
			   $("#survivalInvestigateText tr:eq(0) + tr").remove();
	           $.each(underwritings, function(i, n){
	            	$("#survivalInvestigateText").append("<tr>" +
	            			"<td width=\"15%\">"+underwritings[i].operno+"</td>" + 
	            			"<td width=\"15%\">"+underwritings[i].opername+"</td>" +
	            			"<td width=\"15%\" >"+underwritings[i].operdate+" </td>" +
	            			"<td width=\"55%\">"+underwritings[i].describe+"</td>" + 
	            			"</tr>");
	            	
	           }); 
	           showDiv('survivalInvestigate');
		   }
		 }
	 });
}

//特别约定
function showPolicySpecialInfo(claimNo,docuType) {
	
	 $.ajax({
      type: "POST",
      url:"showPolicySpecialInfo.do",
      data:{"claimNo":claimNo},	
		 error:function(){
			 alert("查询失败！");
			 return;
		 },
		 success:function(data){
			
			 $("#policySpecialText").html("<tr><th>保单号 </th><th>险种名称</th><th>保险期间 </th><th>保单状态</th><th>保单来源</th><th>投保人</th></tr>");
			
			 $("#specialDescText").html("");
			 $.each(data, function(i, n){
    			$("#policySpecialText").append("<tr onclick=\"showCurrentDesc(this,'"+ data[i].policyNo +"','"+ data[i].classCode +"')\" >" +
	          			"<td width=\"20%\">"+data[i].policyNo+"</td>" + 
	          			"<td width=\"10%\">"+data[i].className+"</td>"+
	          			"<td width=\"20%\">"+data[i].insureDate_Str+"</td>" +
	          			"<td width=\"10%\" >"+data[i].policyStatus+" </td>" +
	          			"<td width=\"10%\">"+data[i].systemAttr+" </td>" +
	          			"<td width=\"30%\">"+data[i].appName+"" +
	          			//"<div class=\"displayN\" id=\""+data[i].classCode +"\">"+test+"</div>" + 
	          			"</td>" + 
	          			"</tr>");
    			 $("#specialDescText").append("<tr class=\"spec displayN\" id=\""+data[i].policyNo+"\"><th width=\"22%\">保单特约</th><td width=\"78%\"><textarea cols=90 rows=5 readonly>"+data[i].special+"</textarea></td></tr>");
    			 $("#specialDescText").append("<tr class=\"spec displayN\" id=\""+data[i].policyNo+"FM\"><th>层级特约(层级名称)</th><td>"+data[i].hierarchySpecial+data[i].hierarchyName+"</td></tr><tr  class=\"spec displayN\"  id=\""+data[i].policyNo+"XZ"+data[i].classCode+"\"><th>险种特约</th><td>"+data[i].kindSpecial+"</td></tr>");
         }); 

		 showDiv("policySpecialDesc");
         $("#policySpecialText tbody tr:eq(1)").click();
		 }
	 });
}
function showCurrentDesc(obj,id,xz){
	$(obj).parent().children().removeClass("list_tr1");
	$(obj).addClass("list_tr1");
	$(".spec").hide();
	$("#"+id).show();
	$("#"+id+"FM").show();
	$("#"+id+"XZ"+xz).show();
}

//告知和问卷
function showCommonHealthNoticeInfo(claimNo) {
	removeTrandSetTh('commonHealthNoticeInfoText');
	 $.ajax({
	      type: "POST",
	      url:"showCommonHealthNoticeInfo.do",
	      data:{"claimNo":claimNo},	
			 error:function(){
				 alert("查询失败！");
				 return;
			 },
			 success:function(data){
				$.each(data, function(i){
					var descString = data[i].desc.length>12?data[i].desc.substring(0,12)+"...":data[i].desc;
					var isBenPersonStr = data[i].isBenPerson=='1'?'是':'否';
				 $("#commonHealthNoticeInfoText").append("<tr style='height:30px'>" +
		          			/*"<td style=\"white-space:nowrap;\">"+isBenPersonStr+"</td>" + 
		          			"<td style=\"white-space:nowrap;\">"+data[i].code1+"</td>" +
		          			"<td style=\"white-space:nowrap;\">"+data[i].className+" </td>" +
		          			"<td style=\"white-space:nowrap;\">"+data[i].recordType+"</td>" +
		          			"<td style=\"white-space:nowrap;\"></td>" +
		          			"<td style=\"white-space:nowrap;\">"+data[i].mathValue+"</td>" +
		          			"<td style='cursor: pointer;' title='"+data[i].desc+"'>"+descString+" </td>" +
		          			"<td style=\"white-space:nowrap;\">"+data[i].policyNo+"</td>" + 
		          			"</tr>");*/
						 
						 "<td style=\"white-space:nowrap;\">"+isBenPersonStr+"</td>" + 
		          			"<td style=\"white-space:nowrap;\">"+data[i].code1+"</td>" +
		          			"<td style=\"white-space:nowrap;\">"+data[i].code2+"</td>" +
		          			"<td style=\"white-space:nowrap;\">"+data[i].mathValue+"</td>" +
		          			"<td style='cursor: pointer;' title='"+data[i].desc+"'>"+descString+" </td>" +
		          			"<td style=\"white-space:nowrap;\">"+data[i].policyNo+"</td>" + 
		          			"<td style=\"white-space:nowrap;\"></td>" +
		          			"</tr>");
			   });	
				showDiv('commonHealthNoticeInfo');
			 }
		 });
}

//核保结论
function showUnderWritingResultInfo(claimNo) {
	removeTrandSetTh('showUnderWritingResultInfoText');
	 $.ajax({
	      type: "POST",
	      url:"showUnderWritingResultInfo.do",
	      data:{"claimNo":claimNo},	
			 error:function(){
				 alert("查询失败！");
				 return;
			 },
			 success:function(data){
					$.each(data, function(i){
					 $("#showUnderWritingResultInfoText").append("<tr style='height:30px'>" +
			          			"<td style=\"white-space:nowrap;\">"+data[i].policyno+"</td>" + 
			          			"<td style=\"white-space:nowrap;\">"+data[i].classcode+"</td>" +
			          			"<td style=\"white-space:nowrap;\">"+data[i].sbmdm+" </td>" +
			          			"<td style=\"white-space:nowrap;\">"+data[i].flag+"</td>" +
			          			"<td style=\"white-space:nowrap;\">"+data[i].verstatn+" </td>" +
			          			"<td style=\"white-space:nowrap;\">"+data[i].audno+"</td>" +
			          			"<td style=\"white-space:nowrap;\">"+data[i].auddate+" </td>" +
			          			"</tr>");
				   });	
					$("#showUnderWritingResultInfo").show();
			 }
	});
}

function showlifeClaimMessageInfo() {
	$("#lifeClaimMessageInfo").show();
}



function closeDivs(id){
	$("#"+id).hide();
}


function removeTrandSetTh(id){
	$("#"+id+" tr").remove();
	if(id=="commonHealthNoticeInfoText"){
		$("#"+id).append('<tr style="height:30px">'+
				'<th width="11%">是否被保人</th>'+
				'<th width="9%">代码1 </th>'+
				'<th width="9%"> 代码2 </th>'+
				/*'<th width="10%">记录类型</th>'+
				'<th width="10%">告知类</th>'+*/
				'<th width="8%">数值</th>'+
				'<th width="21%">描述</th>'+
				'<th width="10%">保单号 </th>'+
				'<th width="12%">险种名称 </th>'+
				'</tr>');
	}else if(id=="showUnderWritingResultInfoText"){
		$("#"+id).append('<tr style="height:30px">'+
				'<th width="15%">保单号</th>'+
				'<th width="12%">险种代码</th>'+
				'<th width="20%">险种名称</th>'+
				'<th width="11%">是否有效</th>'+
				'<th width="20%">审核意见</th>'+
				'<th width="11%">核保员</th>'+
				'<th width="11%">审核时间 </th>'+
				'</tr>');
	}
}

function nullToEmpty(inStr){
	if (null == inStr) {
		return "";
	}
	return inStr;
}

function claimImage(claimNo){
	var isBpo = $("#isBpo").val();
	
	if("1"==$("#caseSource").val() && isBpo == "Y"){
		callEcm(claimNo,"");
	}else{
		window.open('../inspection/clmtask/imageInfo.do?claimNo='+claimNo,"影像");
	}
}

function policyImage(claimNo){
	if("1"==$("#caseSource").val()){
		callEcm(claimNo,"2");
	}else{
		window.open('../inspection/clmtask/imageInfo.do?claimNo='+claimNo+'&flag=2',"保单影像");
	}
}

function closeDiv_update(){
	$("#jbresult").hide();
	$("#popupLayerScreenLocker_1").hide();
}
function showDiv_update(){
	$("#jbresult").show();
	$("#popupLayerScreenLocker_1").show();
}
function skipTo(str){
	var params={};
	params['preno'] = str;
	SkipByPost("../dataenter/checkgrant.do",params);
}

/**
 * 生成撤案通知书
 * @param claimNo
 */
function revokeClaims(claimNo) {
	var isQuest=$("#quest").attr("value");
	
	var params = {};
	params["claimNo"] = claimNo;
	params["isQuest"]=isQuest;
	params["isXay"]=$("#isXay").val();
	if("挂起中"==$("#casestatestr").val().trim()){
		alert("该案已被挂起！");
		return;	
	}
	if("2"==$("#caseSource").val()){
			 if( "Y"==$("#isXay").val()){
				//chc 20160819要上线的坑死人的心安怡优化需求
				showDiv('revokeClaimDiv');
			 }else{
				alert("合作方暂不支持！");
				return;
			 }
	}else{
			if (window.confirm("是否确认撤案？")) {
				 $.ajax({
				      type: "POST",
				      url:"revokeTheClaim.do",
				      dataType:"json",
				      contentType:"application/json",
				      data:JSON.stringify(params),	
						 error:function(){
							 alert("撤案出现异常 ！");
						 },
						 success:function(data){
							 if (data.successFlag != "Y") {
								 alert(data.errorMsg);
							 } else {
								 if("1"==$("#caseSource").val()){
										alert("产险撤案成功！");
										return;
									}
								var noticeP0000011 = data.noticeP0000011;
								$("#noticeP0000011_claimNo").val(noticeP0000011.claimNo);
								$("#claimNoP0000011").val(noticeP0000011.claimNo);
								$("#noticeP0000011_applicantName").val(noticeP0000011.applicantName);
								$("#noticeP0000011_insuredName").val(noticeP0000011.insuredName);
								$("#noticeP0000011_insuredPid").val(noticeP0000011.insuredPid);
								$("#noticeP0000011_policyNo").html(noticeP0000011.policyNo);
								$("#noticeP0000011_accTypeName").html(noticeP0000011.accTypeName);
								$("#noticeP0000011_moveReasonDesc").val(noticeP0000011.moveReasonDesc);
								$("#noticeP0000011_phoneNo").val(noticeP0000011.infoTel);
								$("#notice_p000011_branchName").html(noticeP0000011.branchName);
								$("#noticeP0000011_printDate").val(noticeP0000011.printDate);
								$("#noticeP0000011_objId").val(noticeP0000011.objId);
								//REQHOP1-161014-1427 理赔通知书优化 lujibin 20161226 
								$("#name1").val(noticeP0000011.appName);
								$("#cDate1").val(noticeP0000011.applyDate);
								$("#iName1").val(noticeP0000011.insuredName);
								$("#pid1").val(noticeP0000011.insuredPid);
								$("#iName2").val(noticeP0000011.insuredName);
								$("#pid2").val(noticeP0000011.insuredPid);
								
								//REQHOP1-161014-1427 理赔通知书优化 lujibin 20161226 
								
								
								showDivrider('P0000011');
							 }
						 }
					 });
				}
		}
}

/**
 * 生成拒赔通知书
 * @param claimNo
 */

function rejectClaims(claimNo) {
	var isQuest=$("#quest").attr("value");
	if("挂起中"==$("#casestatestr").val().trim()){
		alert("该案已被挂起！");
		return;	
	}
	if (window.confirm("是否确认拒赔？")) {
		
		if("1"==$("#caseSource").val() || "2"==$("#caseSource").val()){
			alert("合作方暂不支持！");
			return;
		}
		
		 $.ajax({
		      type: "POST",
		      url:"generateRejectClaimNoticeInfo.do",
		      data:{"claimNo":claimNo,"isQuest":isQuest},	
				 error:function(){
					 alert("拒赔出现异常 ！");
				 },
				 success:function(data){
					 if (data.successFlag != "Y") {
						 alert(data.errorMsg);
					 } else {
						var noticeP0000006 = data.noticeP0000006;
						$("#noticeP0000006_claimNo").val(noticeP0000006.claimNo);
						$("#claimNoP0000006").val(noticeP0000006.claimNo);
						$("#noticeP0000006_applicantName").val(noticeP0000006.applicantName);
						$("#noticeP0000006_insuredName").val(noticeP0000006.insuredName);
						$("#noticeP0000006_insuredPid").val(noticeP0000006.insuredPid);
						$("#noticeP0000006_policyNo").html(noticeP0000006.policyNo);
						$("#noticeP0000006_accTypeName").html(noticeP0000006.accTypeName);
						$("#noticeP0000006_denying").val(noticeP0000006.denying);
						$("#p0000006InfoTel").val(noticeP0000006.infoTel);
						$("#noticeP0000006_branchName").html(noticeP0000006.branchName);
						$("#noticeP0000006_printDate").val(noticeP0000006.printDate);
						$("#noticeP0000006_objId").val(noticeP0000006.objId);
						$("#p0000006InfoTel").val(noticeP0000006.infoTel);
						$("#claimNo3").val(noticeP0000006.claimNo);
						$("#Name2").val(noticeP0000006.appName);
						$("#cDate2").val(noticeP0000006.applyDate);
						$("#iName3").val(noticeP0000006.insuredName);
						$("#pid3").val(noticeP0000006.insuredPid);
						$("#iName4").val(noticeP0000006.insuredName);
						$("#pid4").val(noticeP0000006.insuredPid);
						
						showDivrider('P0000006');
					 }
				 }
			 });
	}
}
function queryCheckReason(claimNo){
	$.ajax({
		type:"POST",
		url:"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{
				for(var i= 0; i < data.length; i++){
					var h = data[i];
					$("#checkReason").append("<tr>" +
					"<td>"+h.qctreason+"</td></tr>");
				}
			}
		}
	});
}
function selectErr(flag){

	$(flag).val()=='1'?$(flag).val('0'):$(flag).val('1');
	$(flag).val()=='1'?$("#isErrorVal").removeClass("check_no").addClass("check_yes"):$("#isErrorVal").removeClass("check_yes").addClass("check_no");
	
}

$(function(){
	
	var errCause="";
	var errFlag="";
	$("#isErrorVal").click(function(){
		var err=$("#isErrorVal").val();
		if('1'==err||'0'==err){
			selectErr("#isErrorVal");
		}
		
		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"; 
		}
		if('1'==err||'0'==err){
		selectErr("#isErrorVal");
	}
		$.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"){
					
				}
			}
		});
	});
	
	$("#error_commit").click(function(){
		
		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"){
				}
			}
		});
	});
	
	
});


function openWindowSourceUrl(url, claimNo) {
 	url = url + "?claimNo=" + claimNo ;
 	window.open(url,'newwindow','top=0,left=0,toolbar=no,menubar=no,scrollbars=yes, resizable=no,location=no, status=no');
 }


function selectReasonFn(flag){
	if($(flag).attr("code")=="06"){
		$("#otherReason").removeAttr("readonly");
	}else{
		$("#otherReason").val("");
		$("#otherReason").attr("readonly","readonly");
	}
}

function saveRevokeReasonFn(){
	if($("#revokeReason_Sel").attr("code")=="" ||$("#revokeReason_Sel").attr("code")==null){
		alert("请选择撤案原因！");
		return ;
	}
	 if(!confirm("确认保存？")){
		 closeDiv('revokeClaimDiv');
		 return;
	 }
	closeDiv('revokeClaimDiv');
	var isQuest=$("#quest").attr("value");
	var params = {};
	params["claimNo"] =$("#claimNo").text().replace(" ","");
	params["isQuest"]=isQuest;
	params["isXay"]=$("#isXay").val();
	params["revokeReason"]=$("#revokeReason_Sel").attr("code");
	params["otherReason"]=$("#otherReason").val();
	params["dieDate"]=$("#dieDate").val();
	$.ajax({
	      type: "POST",
	      url:"revokeTheClaim.do",
	      dataType:"json",
	      contentType:"application/json",
	      data:JSON.stringify(params),	
			 error:function(){
				 alert("保存异常 ！");
			 },
			 success:function(data){
				 if (data.successFlag != "Y") {
					 alert(data.errorMsg);
				 } else {
					 if("2"==$("#caseSource").val()){
						alert("保存成功！");
						return;
					}
				 }
			 }
		 });
}


