js 打印

js web页面打印
//关键的就下面两行 会用就行了
<style type="text/css" media=print>  
.noprint{display : none }  

//下面的不用看
</style>

onclick="window.print()";


//写的一个例子
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="../css/style.css" rel="stylesheet" type="text/css">
<title>_______________________________________________________________________________________________________________________</title>
<script src="/bjproduct/js/jquery-latest.js"></script>
<style type="text/css" media=print>  
.noprint{display : none }  
</style>
<style type="text/css">
.printtable TD{
padding: 1px 5px 1px 5px;
border: 1px #000000 solid;
font-size: 13px;
font-family: Arial, Helvetica, sans-serif;
line-height: 140%;
text-align: center;
}
.printtable TR{
	height:25px;
}
.printtable .title{
background-color: #DFDFDF;
min-width: 80px;
}
</style>
</head>
<body topmargin="0" leftmargin="0">
<table border="0" cellpadding="0" cellspacing="0" width="100%" align="center">
<tr class="noprint">
	<td>
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
		<tr><td height=5></td></tr>
		<tr><td width=35>&nbsp;&nbsp;<img src="/bjproduct/images/icon_winpop.gif"></td>
		<td style="font-size:13px; font-weight:bold">
         	 财务管理 &gt;&gt;打款申请查询&gt;&gt;
				打印申请单
		</td>
		</tr>
		<tr><td colspan=2 >
		<table border=0 width=99% align=center cellpadding=0 cellspacing=0><tr><td height=1 bgcolor=#cccccc></td></tr></table>
		</td></tr></table>	
	</td>
</tr>
<tr><td valign="top" align="center" height="100%">
	<div class="noprint" align="left" style="padding:20 0 5 100px"><input id="biuuu_button"  class="button_blue" onclick="window.print();" type="button" value="打印"></input>  </div>
	<div id="printConent">
	
	
		 
			<table width="80%" bordercolorlight="#cccccc" align="center" bordercolordark="#cccccc" cellspacing="0">
				<thead align="center">
				<tr style="height: 55px;">
					<td colspan="6" style="padding-top:10px; margin:0px;"><h1>打款申请单</h1></td>
				</tr>
				</thead>
				<tr>
					<td style="min-width: 80px;">申请单号:</td>
					<td>PAY20130820161727</td>
					<td>申请日期:</td>
					<td>2013/08/20 16:18</td>
					<td>申请人:</td>
		 			<td>luobb</td>	
				</tr>
			</table>
			<table border="1" class="printtable" width="80%" bordercolorlight="#cccccc" align="center" bordercolordark="#cccccc" cellspacing="0">	
				<tbody cellspacing="0">
				<tr>
					<td class="title">收款单位</td>
					<td colspan="2">我的招商</td>	
					<td class="title">收款单位</td>
					<td colspan="2">21065461</td>
				</tr>
				<tr>
					<td class="title">付款账户</td>
					<td colspan="2">63369006345682234</td>	
					<td class="title">付款时间</td>
					<td colspan="2">&nbsp;</td>
				</tr>
				<tr>
					<td class="title">金额(小写)</td>
					<td colspan="2">&yen;1,000.00</td>	
					<td class="title">金额(大写)</td>
					<td style="text-align: left;" colspan="2" name="uppercase" id="com.bjdata.bjproduct.persistence.finance.model.BiFinancePay@59b30ac0" money="1000.0"></td>
				</tr>
				<tr style="height:40px;">
					<td class="title" >打款用途</td>
					<td colspan="5" style="text-align: left;">&nbsp;买棉花糖</td>	
				</tr>
				<tr>
					<td rowspan="4" class="title">审批记录</td>
					<td class="title">审批人</td>
					<td class="title">审批结果</td>
					<td colspan="2" class="title">审批意见</td>
					<td class="title">审批时间</td>
				</tr>
				 
					<tr>
					<td>陈ll</td>
					<td>
						
							
								同意
							
							
							
						
					</td>
					<td colspan="2" style="text-align: left;">&nbsp;行啊</td>
					<td>
					2013/08/20 16:19
					</td>
					</tr>
				 
					<tr>
					<td>余xx</td>
					<td>
						
							
								同意
							
							
							
						
					</td>
					<td colspan="2" style="text-align: left;">&nbsp;打款好了</td>
					<td>
					2013/08/20 16:20
					</td>
					</tr>
				 
					<tr>
					<td>肖qq</td>
					<td>
						
							
								同意
							
							
							
						
					</td>
					<td colspan="2" style="text-align: left;">&nbsp;通过</td>
					<td>
					2013/08/20 16:21
					</td>
					</tr>
				
			</table>
			
				<br/>
				<hr style="border: 1px dotted #000000;"/>
			
		 
			<table width="80%" bordercolorlight="#cccccc" align="center" bordercolordark="#cccccc" cellspacing="0">
				<thead align="center">
				<tr style="height: 55px;">
					<td colspan="6" style="padding-top:10px; margin:0px;"><h1>打款申请单</h1></td>
				</tr>
				</thead>
				<tr>
					<td style="min-width: 80px;">申请单号:</td>
					<td>PAY20130820153935</td>
					<td>申请日期:</td>
					<td>2013/08/20 15:40</td>
					<td>申请人:</td>
		 			<td>luobb</td>	
				</tr>
			</table>
			<table border="1" class="printtable" width="80%" bordercolorlight="#cccccc" align="center" bordercolordark="#cccccc" cellspacing="0">	
				<tbody cellspacing="0">
				<tr>
					<td class="title">收款单位</td>
					<td colspan="2">是非得失</td>	
					<td class="title">收款单位</td>
					<td colspan="2">阿飞斯蒂芬</td>
				</tr>
				<tr>
					<td class="title">付款账户</td>
					<td colspan="2">[email protected]</td>	
					<td class="title">付款时间</td>
					<td colspan="2">&nbsp;</td>
				</tr>
				<tr>
					<td class="title">金额(小写)</td>
					<td colspan="2">&yen;300.00</td>	
					<td class="title">金额(大写)</td>
					<td style="text-align: left;" colspan="2" name="uppercase" id="com.bjdata.bjproduct.persistence.finance.model.BiFinancePay@7986f141" money="300.0"></td>
				</tr>
				<tr style="height:40px;">
					<td class="title" >打款用途</td>
					<td colspan="5" style="text-align: left;">&nbsp;收复失地</td>	
				</tr>
				<tr>
					<td rowspan="4" class="title">审批记录</td>
					<td class="title">审批人</td>
					<td class="title">审批结果</td>
					<td colspan="2" class="title">审批意见</td>
					<td class="title">审批时间</td>
				</tr>
				 
					<tr>
					<td>陈吕祥</td>
					<td>
						
							
								同意
							
							
							
						
					</td>
					<td colspan="2" style="text-align: left;">&nbsp;统一</td>
					<td>
					2013/08/20 15:40
					</td>
					</tr>
				 
					<tr>
					<td>余秀丽</td>
					<td>
						
							
								同意
							
							
							
						
					</td>
					<td colspan="2" style="text-align: left;">&nbsp;统一</td>
					<td>
					2013/08/20 15:41
					</td>
					</tr>
				 
					<tr>
					<td>肖秋霞</td>
					<td>
						
							
								同意
							
							
							
						
					</td>
					<td colspan="2" style="text-align: left;">&nbsp;统一</td>
					<td>
					2013/08/20 15:43
					</td>
					</tr>
				
			</table>
			
				<br/>
				<hr style="border: 1px dotted #000000;"/>
			
		 
			<table width="80%" bordercolorlight="#cccccc" align="center" bordercolordark="#cccccc" cellspacing="0">
				<thead align="center">
				<tr style="height: 55px;">
					<td colspan="6" style="padding-top:10px; margin:0px;"><h1>打款申请单</h1></td>
				</tr>
				</thead>
				<tr>
					<td style="min-width: 80px;">申请单号:</td>
					<td>PAY20130820110938</td>
					<td>申请日期:</td>
					<td>2013/08/20 11:10</td>
					<td>申请人:</td>
		 			<td>luobb</td>	
				</tr>
			</table>
			<table border="1" class="printtable" width="80%" bordercolorlight="#cccccc" align="center" bordercolordark="#cccccc" cellspacing="0">	
				<tbody cellspacing="0">
				<tr>
					<td class="title">收款单位</td>
					<td colspan="2">161231</td>	
					<td class="title">收款单位</td>
					<td colspan="2">admin</td>
				</tr>
				<tr>
					<td class="title">付款账户</td>
					<td colspan="2">63369006345682234</td>	
					<td class="title">付款时间</td>
					<td colspan="2">&nbsp;</td>
				</tr>
				<tr>
					<td class="title">金额(小写)</td>
					<td colspan="2">&yen;200.00</td>	
					<td class="title">金额(大写)</td>
					<td style="text-align: left;" colspan="2" name="uppercase" id="com.bjdata.bjproduct.persistence.finance.model.BiFinancePay@a4920bc" money="200.0"></td>
				</tr>
				<tr style="height:40px;">
					<td class="title" >打款用途</td>
					<td colspan="5" style="text-align: left;">&nbsp;高温补贴</td>	
				</tr>
				<tr>
					<td rowspan="4" class="title">审批记录</td>
					<td class="title">审批人</td>
					<td class="title">审批结果</td>
					<td colspan="2" class="title">审批意见</td>
					<td class="title">审批时间</td>
				</tr>
				 
					<tr>
					<td>陈吕祥</td>
					<td>
						
							
								同意
							
							
							
						
					</td>
					<td colspan="2" style="text-align: left;">&nbsp;同意</td>
					<td>
					2013/08/20 11:11
					</td>
					</tr>
				 
					<tr>
					<td>余秀丽</td>
					<td>
						
							
								同意
							
							
							
						
					</td>
					<td colspan="2" style="text-align: left;">&nbsp;打款了</td>
					<td>
					2013/08/20 14:02
					</td>
					</tr>
				 
					<tr>
					<td>肖秋霞</td>
					<td>
						
							
								同意
							
							
							
						
					</td>
					<td colspan="2" style="text-align: left;">&nbsp;通过</td>
					<td>
					2013/08/20 14:03
					</td>
					</tr>
				
			</table>
			
		
		</div>
	</td></tr>
</table>
<script type="text/javascript"> 
$(function(){
	$(".printtable td:[name='uppercase']").each(function(index,ele){
		var money=$(ele).attr("money");
		money=chineseNumber(money);
		$(ele).text(money);
	});
});

function chineseNumber(num)
{
	if (isNaN(num) || num > Math.pow(10, 12)) return ""
	var cn = "零壹贰叁肆伍陆柒捌玖"
	var unit = new Array("拾百千", "分角")
	var unit1= new Array("万亿", "")
	var numArray = num.toString().split(".")
	var start = new Array(numArray[0].length-1, 2)
	function toChinese(num, index)
	{
		var num = num.replace(/\d/g, function ($1)
		{
			return cn.charAt($1)+unit[index].charAt(start--%4 ? start%4 : -1)
		})
		return num
	}
	for (var i=0; i<numArray.length; i++)
	{
		var tmp = ""
		for (var j=0; j*4<numArray[i].length; j++)
		{
		var strIndex = numArray[i].length-(j+1)*4
		var str = numArray[i].substring(strIndex, strIndex+4)
		var start = i ? 2 : str.length-1
		var tmp1 = toChinese(str, i)
		tmp1 = tmp1.replace(/(零.)+/g, "零").replace(/零+$/, "")
		tmp1 = tmp1.replace(/^壹拾/, "拾")
		tmp = (tmp1+unit1[i].charAt(j-1)) + tmp
		}
		numArray[i] = tmp
	}
	numArray[1] = numArray[1] ? numArray[1] : ""
	numArray[0] = numArray[0] ? numArray[0]+"元" : numArray[0], numArray[1] = numArray[1].replace(/^零+/, "")
	numArray[1] = numArray[1].match(/分/) ? numArray[1] : numArray[1]+"整"
	return numArray[0]+numArray[1]
}


</script>
</body>
</html>


你可能感兴趣的:(window.print(),转大写金额)