
function calcAdjCost() {
	
	if($("#resCode").val()=='02'||$("#resCode").val()=='05'){
		
		if($("#assRate").val()=='' && $("#assAmt").val()==''){
			alert("请填写通融给付率或通融给付金额！");
			return;
		}
		//给付结果=账单金额合计*通融给付率
		if($("#assRate").val()!=''){
			$("#calcClmAmt").val($("#billAmt").val());
		}
		
	}else{
		if(adjCostForm.reqVisitDate.value==""){
			alert("就诊日期为空！");
			return;
		}
		//住院医疗性质
		if($("#accType").val()=='05'){
			if(adjCostForm.reqAdmissionDate.value==""){
				alert("入院日期为空！");
				return;
			}
			if(adjCostForm.reqDischargeDate.value==""){
				alert("出院日期为空！");
				return;
			}
		}
		if(adjCostForm.remainDeductible.value==""){
			alert("剩余免赔额为空！");
			return;
		}
		if(adjCostForm.payRate.value==""){
			alert("给付比例为空！");
			return;
		}
		if(adjCostForm.unauthorizedOwnRate.value==""){
			alert("未经认可自负比例为空！");
			return;
		}
		var css4 = $("#type4").attr("class");
		var css5 = $("#type5").attr("class");
		if($("#accType").val()=='' || ("check_no"==css4 && "check_no"==css5)){
			alert("请勾选赔付类型！");
			return;
		}
		var left = ($("#billAmt").val()-$("#ownAmt").val()-$("#deductionsAmt").val()-$("#remainDeductible").val())*$("#payRate").val()/100;
		var right = $("#billAmt").val()-$("#otherPayment").val();
		if(left>right){
			left = right;
		}
		var remainPrem = $("#remainPrem").val();
		if(left>remainPrem){
			left = remainPrem;
		}
		$("#calcClmAmt").val(left<0?0:left);
	}

	var request=getFormJson("adjCostForm");
//	alert(JSON.stringify(request));

	$.ajax({
		type : "POST",
		url : "calcAdjCost.do",
		contentType:"application/json; charset=UTF-8",
		data : JSON.stringify(request),
		success : function(data) {
//			alert(data.inWaitingPeriod);
			$("#calcClmAmt").val(data.calcClmAmt);
			$("#realClmAmt").val(data.calcClmAmt);
			$("#afterPayRemainPrem").val(data.afterPayRemainPrem);
			$("#usedPremPublic").val(data.usedPremPublic);
			$("#usedDeductible").val(data.usedDeductible);
			$("#usedPreyearLmt").val(data.usedPreyearLmt);//年限额、限额
			$("#inWaitingPeriod").val(data.inWaitingPeriod);
			$("#inBackPeriod").val(data.inBackPeriod);
			$("#usedDeductibleMjz").val(data.usedDeductibleMjz);//门(急)诊次免赔额
			$("#usedPreyearLmtMjz").val(data.usedPreyearLmtMjz);//门(急)诊限额
			
			$("#usedHlyshLmt").val(data.usedHlyshLmt);
			$("#usedZhiliaoLmt").val(data.usedZhiliaoLmt);
			$("#usedFlypLmt").val(data.usedFlypLmt);
			$("#usedShoushuLmt").val(data.usedShoushuLmt);
			$("#usedZhirutiLmt").val(data.usedZhirutiLmt);
			$("#usedQgyizhiLmt").val(data.usedQgyizhiLmt);
			var usedJianchaLmt = data.usedJianchaLmt;
			$("#usedJianchaLmt").val(usedJianchaLmt);
			$("#usedWulizhlLmt").val(data.usedWulizhlLmt);
			$("#usedJiuhucheLmt").val(data.usedJiuhucheLmt);
			$("#usedMzshshLmt").val(data.usedMzshshLmt);
			
			$("#usedBedshshDays").val(data.usedBedshshDays);
			$("#usedAddbedDays").val(data.usedAddbedDays);
			$("#usedIcuHospDays").val(data.usedIcuHospDays);
			$("#usedJshxlDays").val(data.usedJshxlDays);
			$("#usedJshxlLmt").val(data.usedJshxlLmt);
			$("#usedHomecareDays").val(data.usedHomecareDays);
			$("#usedHomecareLmt").val(data.usedHomecareLmt);
			$("#usedLzhghDays").val(data.usedLzhghDays);
			$("#usedLzhghLmt").val(data.usedLzhghLmt);
			$("#usedNyylshbLmt").val(data.usedNyylshbLmt);
			$("#usedJxgzshshLmt").val(data.usedJxgzshshLmt);
			$("#usedTnbzhlypLmt").val(data.usedTnbzhlypLmt);
			$("#usedHemtdzhlLmt").val(data.usedHemtdzhlLmt);
			$("#usedJjykLmt").val(data.usedJjykLmt);
			$("#usedJktjLmt").val(data.usedJktjLmt);
			$("#usedYmjzhLmt").val(data.usedYmjzhLmt);
			$("#usedLxymLmt").val(data.usedLxymLmt);
			//弹出层赋值
			$("#inputHlyshLmt").val(data.usedHlyshLmt);
			$("#inputZhiliaoLmt").val(data.usedZhiliaoLmt);
			$("#inputFlypLmt").val(data.usedFlypLmt);
			$("#inputShoushuLmt").val(data.usedShoushuLmt);
			$("#inputZhirutiLmt").val(data.usedZhirutiLmt);
			$("#inputQgyizhiLmt").val(data.usedQgyizhiLmt);
			$("#inputJianchaLmt").val(data.usedJianchaLmt);
			$("#inputWulizhlLmt").val(data.usedWulizhlLmt);
			$("#inputJiuhucheLmt").val(data.usedJiuhucheLmt);
			$("#inputMzshshLmt").val(data.usedMzshshLmt);
			$("#inputChwshshLmt").val(data.usedChwshshLmt);//日限额
			$("#inputZhzhchwLmt").val(data.usedZhzhchwLmt);
			$("#inputZhlghLmt").val(data.usedZhlghLmt);//次限额
			$("#inputWltdzhlLmt").val(data.usedWltdzhlLmt);
			$("#treatmentTime").val(data.treatmentTime);//录入次数
			$("#inputHlyshLmt").parents("tr").children('td').eq(1).html(data.usedHlyshLmt);
			$("#inputZhiliaoLmt").parents("tr").children('td').eq(1).html(data.usedZhiliaoLmt);
			$("#inputFlypLmt").parents("tr").children('td').eq(1).html(data.usedFlypLmt);
			$("#inputShoushuLmt").parents("tr").children('td').eq(1).html(data.usedShoushuLmt);
			$("#inputZhirutiLmt").parents("tr").children('td').eq(1).html(data.usedZhirutiLmt);
			$("#inputQgyizhiLmt").parents("tr").children('td').eq(1).html(data.usedQgyizhiLmt);
			$("#inputJianchaLmt").parents("tr").children('td').eq(1).html(data.usedJianchaLmt);
			$("#inputWulizhlLmt").parents("tr").children('td').eq(1).html(data.usedWulizhlLmt);
			$("#inputJiuhucheLmt").parents("tr").children('td').eq(1).html(data.usedJiuhucheLmt);
			$("#inputMzshshLmt").parents("tr").children('td').eq(1).html(data.usedMzshshLmt);
			$("#inputChwshshLmt").parents("tr").children('td').eq(1).html(data.usedChwshshLmt);//日限额
			$("#inputZhzhchwLmt").parents("tr").children('td').eq(1).html(data.usedZhzhchwLmt);
			$("#inputZhlghLmt").parents("tr").children('td').eq(1).html(data.usedZhlghLmt);//次限额
			$("#inputWltdzhlLmt").parents("tr").children('td').eq(1).html(data.usedWltdzhlLmt);
			//合计
			totalInputAmt(1);
		},
		error : function() {
			alert("费用类计算出错！");
			return;
		}
	});
}

function completeAdjCost(){
	if(adjCostForm.reqVisitDate.value==""){
		alert("就诊日期为空！");
		return;
	}
	//住院医疗性质
	if($("#accType").val()=='05'){
		if(adjCostForm.reqAdmissionDate.value==""){
			alert("入院日期为空！");
			return;
		}
		if(adjCostForm.reqDischargeDate.value==""){
			alert("出院日期为空！");
			return;
		}
	}
	if(adjCostForm.remainDeductible.value==""){
		alert("剩余免赔额为空！");
		return;
	}
	if(adjCostForm.payRate.value==""){
		alert("给付比例为空！");
		return;
	}
	if(adjCostForm.unauthorizedOwnRate.value==""){
		alert("未经认可自负比例为空！");
		return;
	}
	var css4 = $("#type4").attr("class");
	var css5 = $("#type5").attr("class");
	if($("#accType").val()=='' || ("check_no"==css4 && "check_no"==css5)){
		alert("请勾选赔付类型！");
		return;
	}
	var realClmAmt = $("#realClmAmt").val();
	if(realClmAmt=='' || $("#afterPayRemainPrem").val()==''){
		alert("计算结果为空！");
		return;
	}
	//1、费用类理算完成时，判断是否为高端赔案，若为高端赔案，判断理赔结论为“赔付”的情况下，若理赔金额或应付金额超过账单总金额，给予提示，并控制不能通过。
	var isBpo = $("#isBpo").val();
	var resCode = $("#resCode").val();
	var billAmt = parseFloat($("#billAmt").val());
	if(isBpo=='N' && resCode=='01' && realClmAmt>billAmt){
		alert("给付结果不能超过账单总金额！");
		return;
	}
	var inWaitingPeriod = $("#inWaitingPeriod").val();
	if(inWaitingPeriod=='1' && !confirm("事故发生于等待期内，是否完成理算？")){
		return;
	}
	var inBackPeriod = $("#inBackPeriod").val();
	if(inBackPeriod=='1' && !confirm("事故发生于追溯期内，是否完成理算？")){
		return;
	}
	var remainPrem = parseFloat($("#remainPrem").val());
	if(realClmAmt>remainPrem){
		alert("给付结果不能大于剩余保额！");
		return;
	}
	adjCostForm.submit();
}

var index = 0;
var otherIndex=0;

function choosEd(flag){
	$(flag).css("background-color", "#e5e5e5").siblings().css("background-color", "#FFFFFF");
	index=$(flag).index();
}

function choosOtherEd(flag){
	 
	$(flag).css("background-color", "#e5e5e5").siblings().css("background-color", "#FFFFFF");
	otherIndex=$(flag).index();
}

function delTr(){
	if(index!=0){
		$("#rcptDrugsTbl tr:eq("+index+")").remove();
	}
	index=0;
}

function delOtherTr(){
	if(otherIndex!=0){
		$("#rcptOtherCostInfoTbl tr:eq("+otherIndex+")").remove();
	}
	otherIndex=0;
}


function addTr(){
	var tr = "<tr id=\"addnewtr\" onclick=\"choosEd(this)\">"+
	"<td><input id=\"receiptNo\" name=\"receiptNo\" type=\"text\" class=\"input i_s_60\" /></td>"+
	"<td><input id=\"drugsCode\" name=\"drugsCode\" type=\"text\" class=\"input i_s_60\" /></td>"+
    "<td><input id=\"drugsName\" name=\"drugsName\" type=\"text\" class=\"input i_s_60\" /></td>"+
    "<td><input id=\"specifications\" name=\"specifications\" type=\"text\" class=\"input i_s_60\"  /></td>"+
    "<td><input id=\"dosageForm\" name=\"dosageForm\" type=\"text\" class=\"input i_s_60\" /></td>"+
    "<td><input id=\"units\" name=\"units\" type=\"text\" class=\"input i_s_60\"  /></td>"+
    "<td><input id=\"unitPrice\" onblur=\"checkMoney(this);\" name=\"unitPrice\" type=\"text\" class=\"input i_s_60\"  /></td>"+
    "<td><input id=\"quantity\"  onblur=\"checkMoney(this);\" name=\"quantity\" type=\"text\" class=\"input i_s_60\" /></td>"+
    "<td><input id=\"actualPayment\"  onblur=\"checkMoney(this);\" name=\"actualPayment\" type=\"text\" class=\"input i_s_60\" /></td>"+
    "<td><input id=\"medicalInsType\" name=\"medicalInsType\" type=\"text\" class=\"input i_s_60\" /></td>"+
    "<td><input id=\"ownCostAmt\" onblur=\"checkMoney(this);\" name=\"ownCostAmt\" type=\"text\" class=\"input i_s_60\" /></td>"+
    "<td><span  class=\"check_no\" onclick=\"cvtCheck(this)\"></span></td>"+
    "<td><input type=\"text\" class=\" input i_s_100\" id=\"excludeReason\" name=\"excludeReason\"  /></td>"+
    "</tr>";
	
//	$("#rcptDrugsTbl").append(tr);
}

function addOtherTr(){
	var tr = "<tr id=\"addnewtr\" onclick=\"choosOtherEd(this)\">"+
			"<td><input id=\"receiptNo\" name=\"receiptNo\" type=\"text\" class=\"input i_s_60\"  /></td>"+
            "<td><input id=\"otherproductName\" name=\"otherproductName\" type=\"text\" class=\"input i_s_60\"  /></td>"+
            "<td><input id=\"otherexpenseName\" name=\"otherexpenseName\" type=\"text\" class=\"input i_s_60\" /></td>"+
            "<td><input id=\"othermedicalInsType\" name=\"othermedicalInsType\" type=\"text\" class=\"input i_s_60\" /></td>"+
            "<td><input id=\"otherdrugsCode\" name=\"otherdrugsCode\" type=\"text\" class=\"input i_s_60\"  /></td>"+
            "<td><input id=\"otheractualPayment\" onblur=\"checkMoney(this);\" name=\"otheractualPayment\" type=\"text\" class=\"input i_s_60\" /></td>"+
            "<td><input id=\"otherownCostRate\" onblur=\"checkMoney(this);\" name=\"otherownCostRate\" type=\"text\" class=\"input i_s_60\"  />%</td>"+
            "<td><input id=\"otherownCostSAmt\" onblur=\"checkMoney(this);\" name=\"otherownCostSAmt\" type=\"text\" class=\"input i_s_60\" /></td>"+
            "<td><input id=\"otherunitPrice\"  onblur=\"checkMoney(this);\" name=\"otherunitPrice\" type=\"text\" class=\"input i_s_60\" /></td>"+
            "<td><span class=\"check_no\" onclick=\"cvtCheck(this)\"></span></td>"+
            "<td><input type=\"text\" class=\" input i_s_100\" id=\"excludeReason\" name=\"excludeReason\" /></td>"+
            "</tr>";
	
//	$("#rcptOtherCostInfoTbl").append(tr);
}

function cvtCheck(check){
	if($(check).attr("class")=="check_no"){
		$(check).attr("class","check_yes");
	}else{
		$(check).attr("class","check_no");
	}
}

function checkMoney(moneyInput){
	if($(moneyInput).val()!=""){
		var mny = /^([1-9][\d]{0,7}|0)(\.[\d]{1,2})?$/;
		if(!mny.test($(moneyInput).val())){
			$(moneyInput).val("");
		}
	}
}

//剔除项目
var excludeCosts="";
function rejectOnclick(check){
	//清单行
	var rtds = $(check).parents("tr").children('td');
	//发生金额
	var actualPayment = parseFloat(rtds.eq(5).text());
	//自付金额
	var ownCostSAmt = parseFloat(rtds.eq(7).text());
	//账单项目代码
	var billItemCode = rtds.eq(0).find("input").val();
	//清单id
	var id = rtds.eq(2).find("input").val();
	//剔除原因
	var excludeReason = rtds.eq(11).find("input").val();
//	alert(actualPayment+"+"+ownCostSAmt+"+"+billItemCode);
	var css = $(check).attr("class");
	if("check_no"==css){
		$("#rcptBillDetails").find("input").each(function() {
			if ($(this).val()==billItemCode) {
				var tds = $(this).parents("tr").children('td');
				//免责扣款
				var deductionsAmt = parseFloat(tds.eq(6).text());
				//自费金额
				var ownAmt = parseFloat(tds.eq(2).text());
				//分类自负
				var divAmt = parseFloat(tds.eq(3).text());
				//若自付金额=发生金额，自费金额=自费金额-剔除记录的自付金额
				if(ownCostSAmt==actualPayment){
					ownAmt -= ownCostSAmt;
				}
				//若自付金额<发生金额，分类自付=分类自付-剔除记录的自付金额
				if(ownCostSAmt<actualPayment){
					divAmt -= ownCostSAmt;
					//更新计算所需账单金额
					var billFee = parseFloat($("#billFee").val());
					billFee -= actualPayment;
					$("#billFee").val(billFee);
//					alert(billFee);
				}
				deductionsAmt+=actualPayment;
				tds.eq(6).html(deductionsAmt);
				tds.eq(2).html(ownAmt);
				tds.eq(3).html(divAmt);
				//记录剔除信息用于后台更新账单和清单数据
				excludeCosts += id+"/Y/"+excludeReason+",";
			}
			//找到总计一行
			if($(this).attr("id")=="billAmt"){
				var ftds = $(this).parents("tr").children('td');
				//免责扣款
				var t_deductionsAmt = parseFloat(ftds.eq(6).text());
				//自费金额
				var t_ownAmt = parseFloat(ftds.eq(2).text());
				//分类自负
				var t_divAmt = parseFloat(ftds.eq(3).text());
				//若自付金额=发生金额，自费金额=自费金额-剔除记录的自付金额
				if(ownCostSAmt==actualPayment){
					t_ownAmt -= ownCostSAmt;
				}
				//若自付金额<发生金额，分类自付=分类自付-剔除记录的自付金额
				if(ownCostSAmt<actualPayment){
					t_divAmt -= ownCostSAmt;
				}
				t_deductionsAmt+=actualPayment;
				ftds.eq(6).html(t_deductionsAmt);
				$("#deductionsAmt").val(t_deductionsAmt);
				ftds.eq(2).html(t_ownAmt);
				$("#ownAmt").val(t_ownAmt);
				ftds.eq(3).html(t_divAmt);
			}
		});
	}
	if("check_yes"==css){
		$("#rcptBillDetails").find("input").each(function() {
			if ($(this).val()==billItemCode) {
				var tds = $(this).parents("tr").children('td');
				//免责扣款
				var deductionsAmt = parseFloat(tds.eq(6).text());
				//自费金额
				var ownAmt = parseFloat(tds.eq(2).text());
				//分类自负
				var divAmt = parseFloat(tds.eq(3).text());
				//若自付金额=发生金额，自费金额=自费金额-剔除记录的自付金额
				if(ownCostSAmt==actualPayment){
					ownAmt += ownCostSAmt;
				}
				//若自付金额<发生金额，分类自付=分类自付-剔除记录的自付金额
				if(ownCostSAmt<actualPayment){
					divAmt += ownCostSAmt;
					//更新计算所需账单金额
					var billFee = parseFloat($("#billFee").val());
					billFee += actualPayment;
					$("#billFee").val(billFee);
//					alert(billFee);
				}
				deductionsAmt-=actualPayment;
				tds.eq(6).html(deductionsAmt);
				tds.eq(2).html(ownAmt);
				tds.eq(3).html(divAmt);
				//记录剔除信息用于后台更新账单和清单数据
				excludeCosts += id+"/N/"+excludeReason+",";
			}
			//找到总计一行
			if($(this).attr("id")=="billAmt"){
				var ftds = $(this).parents("tr").children('td');
				//免责扣款
				var t_deductionsAmt = parseFloat(ftds.eq(6).text());
				//自费金额
				var t_ownAmt = parseFloat(ftds.eq(2).text());
				//分类自负
				var t_divAmt = parseFloat(ftds.eq(3).text());
				//若自付金额=发生金额，自费金额=自费金额-剔除记录的自付金额
				if(ownCostSAmt==actualPayment){
					t_ownAmt += ownCostSAmt;
				}
				//若自付金额<发生金额，分类自付=分类自付-剔除记录的自付金额
				if(ownCostSAmt<actualPayment){
					t_divAmt += ownCostSAmt;
				}
				t_deductionsAmt-=actualPayment;
				ftds.eq(6).html(t_deductionsAmt);
				$("#deductionsAmt").val(t_deductionsAmt);
				ftds.eq(2).html(t_ownAmt);
				$("#ownAmt").val(t_ownAmt);
				ftds.eq(3).html(t_divAmt);
			}
		});
	}
	$("#excludeCosts").val(excludeCosts);
//	alert(excludeCosts);
}

function lmtCheck(input){
	checkMoney(input);
	var inputLmt = parseFloat($(input).val());
	var totalLmt = $(input).parents("tr").children('td').eq(4).text();
	if(inputLmt>totalLmt){
		alert("超出剩余年限额！");
	}
	totalInputAmt();
}
function rilmtCheck(input){
	checkMoney(input);
	var inputLmt = parseFloat($(input).val());
//	var totalLmt = $(input).parents("tr").children('td').eq(3).text();
	var chwshshLmt = $("#chwshshLmt").val();
	var hospitalizedDays = parseFloat($("#hospitalizedDays").val());
	var remainPayDays = $("#remainPayDays").val();
	if(hospitalizedDays>remainPayDays){
		hospitalizedDays = remainPayDays;
	}
	chwshshLmt = chwshshLmt * hospitalizedDays;
	//min（剩余住院、录入住院）*日限额
	if(inputLmt > chwshshLmt){
		alert("超出日限额！");
	}
	totalInputAmt();
}
function rilmtCheck1(input){
	checkMoney(input);
	var inputLmt = parseFloat($(input).val());
//	var totalLmt = $(input).parents("tr").children('td').eq(3).text();
	var zhzhchwLmt = $("#zhzhchwLmt").val();
	var severeHospDays = parseFloat($("#severeHospDays").val());
	var remainHospDays = $("#remainHospDays").val();
	if(severeHospDays > remainHospDays){
		severeHospDays = remainHospDays;
	}
	zhzhchwLmt = zhzhchwLmt * severeHospDays;
	//min（剩余重症赔付天数、重症监护天数）*日限额
	if(inputLmt>zhzhchwLmt){
		alert("超出日限额！");
	}
	totalInputAmt();
}
function cilmtCheck(input){
	checkMoney(input);
	var inputLmt = parseFloat($(input).val());
	var zhlghLmt = $("#zhlghLmt").val();
	if(inputLmt>zhlghLmt){
		alert("超出次限额！");
	}
	totalInputAmt();
}
function cilmtCheck1(input){
	checkMoney(input);
	var inputLmt = parseFloat($(input).val());
	var wltdzhlLmt = $("#wltdzhlLmt").val();
	var treatmentTime = $("#treatmentTime").val();
	wltdzhlLmt = wltdzhlLmt * treatmentTime;
	if(inputLmt>wltdzhlLmt){
		alert("超出次限额！");
	}
	totalInputAmt();
}

function adjustModify(){
	var realClmAmt = parseFloat($("#realClmAmt").val());
	var inpTotalAmt = parseFloat($("#inpTotalAmt").text());
	if(inpTotalAmt!=realClmAmt){
		alert("实际赔付金额合计与给付结果不符，请重新修改实际赔付金额！");
		return;
	}else{
		$("#usedHlyshLmt").val($("#inputHlyshLmt").val());
		$("#usedZhiliaoLmt").val($("#inputZhiliaoLmt").val());
		$("#usedFlypLmt").val($("#inputFlypLmt").val());
		$("#usedShoushuLmt").val($("#inputShoushuLmt").val());
		$("#usedZhirutiLmt").val($("#inputZhirutiLmt").val());
		$("#usedQgyizhiLmt").val($("#inputQgyizhiLmt").val());
		$("#usedJianchaLmt").val($("#inputJianchaLmt").val());
		$("#usedWulizhlLmt").val($("#inputWulizhlLmt").val());
		$("#usedJiuhucheLmt").val($("#inputJiuhucheLmt").val());
		$("#usedMzshshLmt").val($("#inputMzshshLmt").val());
		//门急诊总年限额冲减值
		$("#usedPreyearLmt").val(inpTotalAmt);
		alert("修改成功！");
		closeDiv('lsresult');
	}
}

function totalInputAmt(flag){
	var totalAmt = 0;
	$("#adjustDetails").find("input").each(function() {
		var inputAmt = $(this).val();
		if(inputAmt != ''){
			totalAmt = totalAmt + parseFloat(inputAmt);
		}
	});
	if(flag==1){
		$("#iniTotalAmt").html(totalAmt.toFixed(2));
	}
	$("#inpTotalAmt").html(totalAmt.toFixed(2));
}

function calcAfterPay(){
	var remainPrem = $("#remainPrem").val();
	var realClmAmt = $("#realClmAmt").val();
	var afterPayRemainPrem = remainPrem-realClmAmt;
	if(afterPayRemainPrem<0)afterPayRemainPrem=0;
	$("#afterPayRemainPrem").val(afterPayRemainPrem.toFixed(2));
}

function excludeCost(check,flag){
	//清单行
	var rtds = $(check).parents("tr").children('td');
	//账单项目代码
	var billItemCode = rtds.eq(0).find("input").val();
	//清单id
	var id = rtds.eq(2).find("input").val();
	//剔除原因
	var excludeReason = "";
	if(flag==1){
		excludeReason = rtds.eq(10).find("input").val();
	}else if(flag==0){//药品清单
		excludeReason = rtds.eq(14).find("input").val();
	}
	var css = $(check).attr("class");
	var excludeCost="";
	var excludeAmt = 0;
	$("#rcptBillDetails").find("input").each(function() {
		if ($(this).val()==billItemCode) {
			if("check_no"==css){
				excludeCost = id+"/Y/"+excludeReason+"/"+flag+",";
			}else
			if("check_yes"==css){
				excludeCost = id+"/N/"+excludeReason+"/"+flag+",";
			}
			$("#excludeCosts").val(excludeCost);
//			alert(excludeCost);
			var tds = $(this).parents("tr").children('td');
			var request=getFormJson("adjCostForm");
			//alert(JSON.stringify(request));
			$.ajax({
				type : "POST",
				url : "excludeCost.do",
				contentType:"application/json; charset=UTF-8",
				data : JSON.stringify(request),
				success : function(data) {
//					alert(data);
					excludeAmt = data;
					//免责扣款
					var deductionsAmt = tds.eq(6).text();
					if(deductionsAmt!=""){
						deductionsAmt = parseFloat(deductionsAmt);
					}else{
						deductionsAmt = 0;
					}
					//更新计算所需账单金额
					var billFee = parseFloat($("#billFee").val());
					var t_deductionsAmt = parseFloat($("#deductionsTotal").text());
					if("check_no"==css){
						billFee -= excludeAmt;
						deductionsAmt+=excludeAmt;
						t_deductionsAmt+=excludeAmt;
					}else
					if("check_yes"==css){
						billFee += excludeAmt;
						deductionsAmt-=excludeAmt;
						t_deductionsAmt-=excludeAmt;
					}
					$("#billFee").val(billFee.toFixed(2));
					tds.eq(6).html(deductionsAmt.toFixed(2));
					//合计行
					$("#deductionsTotal").html(t_deductionsAmt.toFixed(2));
					$("#deductionsAmt").val(t_deductionsAmt.toFixed(2));
				},
				error : function() {
					alert("剔除操作异常！");
					return;
				}
			});	
		}
	});
}

function paymentTypeClick(type){
	var css4 = $("#type4").attr("class");
	var css5 = $("#type5").attr("class");
	if("check_yes"==css4 && "check_yes"==css5){
		if(type==4){
//			alert("住院");
			$("#accType").val("05");
		}else if(type==5){
//			alert("门急诊");
			$("#accType").val("04");
		}
	}else if("check_yes"==css4 && "check_no"==css5){
		if(type==4){
//			alert("都没");
			$("#accType").val("");
		}else if(type==5){
//			alert("都有");
			$("#accType").val("04,05");
		}
	}else if("check_no"==css4 && "check_yes"==css5){
		if(type==4){
//			alert("都有");
			$("#accType").val("04,05");
		}else if(type==5){
//			alert("都没");
			$("#accType").val("");
		}
	}else if("check_no"==css4 && "check_no"==css5){
		if(type==4){
//			alert("门急诊");
			$("#accType").val("04");
		}else if(type==5){
//			alert("住院");
			$("#accType").val("05");
		}
	}
}

function payRateSelect(ownRate){
	//1、	费用类理算界面“未经认可自负比例”字段改为下拉框样式，枚举值：0%、40%，默认显示0%；
	$("#unauthorizedOwnRate").val(ownRate);
}

