
$(function() {

	$('button[node-qmk="tm"]').click(function(){
		var id=$(this).attr('data');
		$('#'+id).attr('value',$('#'+id).attr('data-tm'));

	});
	
	$('a[receiptWasteDetail]').click(function(){
		
		var ridKey=$(this).attr('data');
		var url="/ajaxGetReceiptDetailByJson";
		$.ajax({
			url:url,
			type: "post",
			cache: false,
			dataType: "json",
			data: {
				ridKey:ridKey
			},
			global: true,
			success: function(data){
				if(data.status==1){
					$('#ridKey').val(data.detail.ridKey);
					
					$("#receiptTrainType").hide();
					$("#receiptType").show();
					$("#receiptTrainPrice").hide();
					$("#receiptPrice").show();
					$("#paymentAuthCode").val('');
					$("#receiptPrice").html('￥'+data.detail.sum);
					
					if(data.detail.Rtype==0){
						$("#Rtype").html('报销单');
						$("#receiptType").html('<span class="colRed">支出</span>');
					}else if(data.detail.Rtype==1){
						if(data.detail.isBK==0){
							$("#Rtype").html('借款');
							$("#receiptType").html('<span class="colRed">支出</span>');
						}else if(data.detail.isBK==1){
							$("#Rtype").html('借款(报销)');
							var rsum =Math.abs((data.detail.sum-data.detail.loanSum));
							$("#receiptPrice").html('￥'+rsum);
							if(rsum>=0){
								$("#receiptType").html('<span class="colGreen">收入</span>');
							}else{
								$("#receiptType").html('<span class="colRed">支出</span>');
							}
						}
					}else if(data.detail.Rtype==2){
						$("#Rtype").html('对公汇款');
						$("#receiptType").html('<span class="colRed">支出</span>');
//-------------------------------------------------------------						
					}else if(data.detail.Rtype==3){
						$("#Rtype").html('培训班费用');
						if(data.detail.payment>=0){
							$("#receiptType").html('<span class="colGreen">收入</span>');
						}else{
							$("#receiptType").html('<span class="colRed">支出</span>');
						}
						$("#receiptPrice").html('￥'+Math.abs(data.detail.payment));
						$("#paymentAuthCode").val(data.detail.paymentAuthCode);
//						$("#receiptTrainType").show();
//						$("#receiptType").hide();
//						$("#receiptTrainPrice").show();
//						$("#receiptPrice").hide();
					}
					
					if(data.detail.status==2){
						$("#status").html('审批中');
					}else if(data.detail.status==1 || data.detail.status==6){
						$("#status").html('执行中');
					}
					
					data.detail.amount=Math.abs(data.detail.amount);
					$("#sum").html('￥'+data.detail.sum);
					if(data.detail.amount!=null){
						if(data.detail.isBK==1){
							$("#amount").html('￥'+rsum);
						}else{
							$("#amount").html('￥'+data.detail.amount);
						}
					}else{
						$("#amount").html('￥0');
					}
					
					
				}
			},
			error:function(err){
			}
			});
	});
	
	
	
	
	
})


