<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>统计模块</title>
</head>
<body>
	
<div class="base-extend">
	<!-- <div class="addHeader">
		<ol class="breadcrumb">
		  	<li>统计</li>
		</ol>
	</div> -->
	<div class="detailContentBox" style="top:0.15rem;">
		<p class="detailContentBox-title">银行卡余额统计
			<select class="currencyId form-control" tag:option="currencyType" style="float:right;width:1.8rem;margin-top:0.03rem;"></select>
		</p>
		<div id="bankCardBalanceStatistics" style="display:none;">银行卡余额统计权限</div>
		
		
		<div class="newTabAddUpdateBox" style="bottom:0;">
			<div class="row">
				<table class="bankCardBalanceTable">
					<tr>
						<td width="15%"></td>
						<td width="18%">开户行</td>
						<td width="20%">银行卡号</td>
						<td width="23%">余额</td>
						<td width="24%">合计</td>
					</tr>
				</table>
			</div>
		</div>
		
	</div>
</div>
</body>
<script>
$(function(){
	$('.currencyId option:first').remove();
	function getBankCardBalance(){
		$('.bankCardBalanceTable .bankCardBalanceTbody,.bankCardBalanceTable .bankCardBalanceTotalTbody').remove();
		$.ajax({
			url:'/billingRecordBasic/do_statisticsBankCardBalance',
			type:'get',
			data:{
				'currencyId':$('.currencyId').val()
			},
			success:function(data){
				if( data.success ){
					if( data.data.bankCardOwnershipList!=undefined && data.data.bankCardOwnershipList.length>0 ){
						for( var i=0;i<data.data.bankCardOwnershipList.length;i++ ){
							var bankCardBalanceTbodyStr = '<tbody class="bankCardBalanceTbody">';
							for( var j=0;j<data.data.bankCardOwnershipList[i].bankCardList.length;j++ ){
								bankCardBalanceTbodyStr += '<tr><td class="rowspantd">'+data.data.bankCardOwnershipList[i].companyOwnership.name+'</td>'
														+'<td style="background:#fff;">'+data.data.bankCardOwnershipList[i].bankCardList[j].bankName+'</td>'
														+'<td style="background:#fff;">'+data.data.bankCardOwnershipList[i].bankCardList[j].bankCardNo+'</td>'
														+'<td style="background:#fff;">'+(data.data.bankCardOwnershipList[i].bankCardList[j].balance!=undefined?commaDelimiter(data.data.bankCardOwnershipList[i].bankCardList[j].balance.toString()):'')+' '+$('.currencyId option:selected').attr('code')+'</td>'
														+'<td class="rowspantd" style="background:#fff;">'+(data.data.bankCardOwnershipList[i].partBalanceTotal!=undefined?commaDelimiter(data.data.bankCardOwnershipList[i].partBalanceTotal.toString()):'')+' '+$('.currencyId option:selected').attr('code')+'</td></tr>'
							};
							j = null;
							bankCardBalanceTbodyStr += '</tbody>';
							$('.bankCardBalanceTable').append(bankCardBalanceTbodyStr);
						};
						i = null;
						$('.bankCardBalanceTbody').each(function(i,ele){
							$(ele).find('tr:first .rowspantd').attr('rowspan',$(ele).find('tr').length);
							$(ele).find('tr:not(:first) .rowspantd').remove();
						});
					};
					$('.bankCardBalanceTable').append('<tbody class="bankCardBalanceTotalTbody"><tr><td>合计</td><td style="background:#fff;"></td><td style="background:#fff;"></td></td><td style="background:#fff;"></td><td style="background:#fff;">'+(data.data.balanceTotal!=undefined?commaDelimiter(data.data.balanceTotal.toString()):'')+' '+$('.currencyId option:selected').attr('code')+'</td></tr></tbody>')					
				}else{
					new $.zui.Messager('查询银行卡余额统计数据失败:'+data.msg, {
					    type: 'danger'
					}).show();
				}
			},
			error:function(status){
				new $.zui.Messager('查询银行卡余额统计数据时出错:'+status, {
				    type: 'danger'
				}).show();
			}
		})
	};
	if( $('#bankCardBalanceStatistics').length<=0 ){// 没有银行卡余额统计的权限
		$('.bankCardBalanceTable').append('<tr><td colspan="5" style="background:#fff;text-align:center;">无银行卡余额统计权限, 请联系管理员开通</td></tr>')
	}else{
		getBankCardBalance();
	};
	$('.currencyId').change(function(){
		if( $('#bankCardBalanceStatistics').length > 0 ){
			getBankCardBalance();	
		};
	})
})
</script>
</html>