//	选择需要查看的行
	function selectDeceitReason(flag){ 
		$(flag).css("background-color", "#e5e5e5").siblings().css("background-color", "#FFFFFF");
		var claimNo=$(flag).find("td:eq(0)").find("input:eq(0)").val();
		var pid=$(flag).find("td:eq(1)").find("input:eq(0)").val();
		var caseSource=$(flag).find("td:eq(1)").find("input:eq(1)").val();
		//caseSource:1产险\2寿险\3健康险
		//channelType:0健康险\1寿险\2产险
		var channelType = "0";
		if ("1" == caseSource) {
			channelType = "2";
		} else if ("2" == caseSource) {
			channelType = "1";
		}
		$("#claimNo").text("赔案号："+claimNo);
		$(".top_nav_se a").css("color","#007aff");
		$("#pa").bind("click",function(){
//			skip2OtherPage("../humanaudit/humanAuditMain.do",claimNo,pid,"02");
			skip2OtherPage('../humanaudit/humanAuditClaim.do',claimNo,pid,"02",channelType);
		});
		$("#bd").bind("click",function(){
			skip2OtherPage("../claim/commonsearch/policyListQuery.do",claimNo,pid,"02",channelType);
		});
		$("#hmd").bind("click",function(){
			skip2OtherPage("../humanaudit/queryClaimBlacklist.do",claimNo,pid,"02",channelType);
		});
		$("#ls").bind("click",function(){
			skip2OtherPage("../claim/commonsearch/clmhistoryQuery.do",claimNo,pid,"02",channelType);
		});
		$("#dc").bind("click",function(){
			skip2OtherPage("../humanaudit/queryInvTask.do",claimNo,pid,"02",channelType);
		});
		$("#hq").bind("click",function(){
			skip2OtherPage("../humanaudit/queryCoopTask.do",claimNo,pid,"02",channelType);
		});
		selectDeceitReasonInfo(claimNo);
	}
//	选择查看
	function selectDeceitReasonInfo(claimNo){
		addDeceitReason();
		$.ajax({
			type:"POST",
			url:"requestQueryDeceitReasonInfo.do",
			contentType:"application/json; charset=UTF-8",
			data:'{"claimNo":"'+claimNo+'"}',
			error:function(){
			},
			success:function(data){
				for ( var i = 0; i < data.clmDeceitInfoList.length; i++) {
					if(data.clmDeceitInfoList[i].deceitState=="2"|| data.clmDeceitInfoList[i].deceitState=="3"){
						var createDate=data.clmDeceitInfoList[i].createDate;
						var applyDate=data.clmDeceitInfoList[i].applyDate;
						var feedbackDate=data.clmDeceitInfoList[i].feedbackDate;
						var feedbackUser=data.clmDeceitInfoList[i].feedbackUser==null?"":data.clmDeceitInfoList[i].feedbackUser;
	//					jsonDateFormat
						var tr=$("<tr id="+data.clmDeceitInfoList[i].objId+"><th><span class=\"radio_no\" onclick=\"selectDeceitDetailInfo(this)\">" +
								"<input type=\"hidden\" value='"+data.clmDeceitInfoList[i].objId+"'/></span></th></tr>");
						var td=$("<td>录入日期："+jsonDateFormat(createDate,10)+"</td><td>申请日期："+jsonDateFormat(applyDate,10)+"</td>");
						$(tr).append(td);
						if(feedbackDate!=null && feedbackDate!=""){
							$(tr).append("<td>反馈日期："+jsonDateFormat(feedbackDate,10)+"</td><td>调查员："+feedbackUser+"</td>");
						}
						$("#table_con").append(tr);
					}
				}
			}
		});
	}
//	新增
	function addDeceitReason(){
		$("#table_con tr").remove();
		btnBindEventFn('2');
		$("#othDeceitDesc").val("");
		$("#deceitMemo").val("");
		$("#feedbackContent").val("");
		$("#feedbackContent").attr("readonly","readonly");

	}
//	时间显示工具
	function jsonDateFormat(date,length){
		if(date==null || date==""){
			return "";
		}
		if(isNaN(date)){
			return date;
		}
	    var datetime = new Date();
	    datetime.setTime(date);
	    var year = datetime.getFullYear();
	    var month = datetime.getMonth() + 1 < 10 ? "0" + (datetime.getMonth() + 1) : datetime.getMonth() + 1;
	    var date = datetime.getDate() < 10 ? "0" + datetime.getDate() : datetime.getDate();
	    var hour = datetime.getHours()< 10 ? "0" + datetime.getHours() : datetime.getHours();
	    var minute = datetime.getMinutes()< 10 ? "0" + datetime.getMinutes() : datetime.getMinutes();
	    var second = datetime.getSeconds()< 10 ? "0" + datetime.getSeconds() : datetime.getSeconds();
	    if(length==10){
	    	return year + "-" + month + "-" + date;
	    }else{
	    	return year + "-" + month + "-" + date+" "+hour+":"+minute+":"+second;
	    }
	}
	function selectDeceitDetailInfo(flag){
		btnBindEventFn('1');
		$("#table_con tr").each(function(i) {
			$("#table_con tr").find("span").attr("class", "radio_no");
		});
		$(flag).attr("class", "radio_yes");
		$("#objId").val($(flag).find("input:eq(0)").val());
		$.ajax({
			type:"POST",
			url:"requestQueryDeceitDetailInfo.do",
			contentType:"application/json; charset=UTF-8",
			data:'{"objId":"'+$("#objId").val()+'"}',
			error:function(){
			},
			success:function(data){
				$("#tblList tr").remove();
				var tr=$("<tr><th width=\"30%\">分类 </th><th width=\"70%\">欺诈嫌疑描述</th></tr>");
				$("#tblList").append(tr);
				$("#othDeceitDesc").val(data.clmDeceitInfoList[0].othDeceitDesc);
				$("#deceitMemo").val(data.clmDeceitInfoList[0].deceitMemo);
				var feedback=data.clmDeceitInfoList[0].feedbackContent;
				$("#feedbackContent").val(feedback);
				$("#feedbackContent").removeAttr("readonly");
				for ( var i = 0; i < data.deceitReasons.length; i++) {
					var d=data.deceitReasons[i];
					var datatr=$("<tr></tr>");
					var td=$("<td width=\"30%\"><input type=\"hidden\" value='"+d.deceitType+"'/>"+d.deceitTypeDesc+"</td>" +
							"<td width=\"70%\"><input type=\"hidden\" value='"+d.deceitReasonCode+"'/>"+d.deceitReasonDesc+"</td>");
					$(datatr).append(td);
					$("#tblList").append(datatr);
				}
			}
		});
	}
	function btnBindEventFn(flag){
		if(flag=='1'){
			$("#bot_btn_main a").css("color","#007aff");
			$("#bot_btn_main").find("a:eq(0)").attr("onclick","eventFn('1')");
			$("#bot_btn_main").find("a:eq(1)").attr("onclick","eventFn('2')");
			$("#bot_btn_main").find("a:eq(2)").attr("onclick","eventFn('3')");
			$("#bot_btn_main").find("a:eq(3)").attr("onclick","eventFn('4')");
		}else{
			$("#bot_btn_main a").css("color","#ccc");
			$("#bot_btn_main a").removeAttr("onclick");
		}
	}
	function eventFn(flag){
		var url="";
		var claimNo=$("#claimNo").text().split("：")[1];
		var feedbackContent=$("#feedbackContent").val();
		if(flag=="1"){
			skip2OtherPage("../humanaudit/queryInvTask.do",claimNo,'','02');
		}
		if(flag=="2"){
			if(feedbackContent.length>200){
				alert("反欺诈结果不能大于200个字符！");
				return ;
			}
			url="	requestDeceitSaveFeedBack.do";
			ajaxEventFn(url, "保存",claimNo);
		}
		if(flag=="3"){
			if(feedbackContent.length>200){
				alert("反欺诈结果不能大于200个字符！");
				return ;
			}
			if(feedbackContent==null || feedbackContent==""){
				alert("反欺诈结果不能为空！");
				return ;
			}else{
				url="	requestDeceitApplyFeedBack.do";
				ajaxEventFn(url, "审核",claimNo);
			}
		}
		if(flag=="4"){
			if(confirm("确认取消吗？")){
				return ;
			}
		}
	}
	function ajaxEventFn(url,alt,claimNo){
		$.ajax({
			type:"POST",
			url:url,
			contentType:"application/json; charset=UTF-8",
			data:'{"objId":"'+$("#objId").val()+'","feedBackContent":"'+$("#feedbackContent").val()+'","claimNo":"'+claimNo+'"}',
			error:function(){
			},
			success:function(data){
				if(eval(data)){
					alert(alt+"成功！");
					selectDeceitReasonInfo(claimNo);
				}else{
					alert(alt+"失败！");
				}
			}
		});
	}