123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247 |
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
- <title>打印单据</title>
- <style type="text/css">
- body {
- left: 0px;
- top: 0px;
- right: 0px;
- bottom: 0px;
- margin: 0px;
- font-family: Arial, Helvetica, sans-serif;
- font-size: 12px;
- overflow: hidden;
- white-space: nowrap;
- }
- </style>
- <script src="../../static/print/jquery-2.0.3.js" type="text/javascript"></script>
- <script src="../../static/print/jquery.jPrintArea.js" type="text/javascript"></script>
- <script src="../../static/sa.js"></script>
- </head>
- <body>
- <div>
- <input type="button" style="height: 30;" id="print_button" value="打印"/>
- <fieldset align="">
- <legend>打印区</legend>
- <div id="myPrintArea" style="height: 1500;">
- <div align="center">
- <SPAN style="TEXT-DECORATION: underline;font-size:25px">收费单据证明</SPAN>
- <br/><br/>
- </div>
- <div align="left">
- 单号: <span id="no"></span>
- </div>
- <div style="text-align:center; font-size:15px;">
- <table width="100%" style="border-collapse:collapse;border:none;">
- <tr height="40">
- <td style="border:solid #000 1px; width: 20%;">越南车牌</td>
- <td style="border:solid #000 1px;" colspan="2">
- <div id="cardNo"></div>
- </td>
- <td style="border:solid #000 1px; width: 20%;" rowspan="2">支付时间</td>
- <td style="border:solid #000 1px;" rowspan="2">
- <div id="payTime"></div>
- </td>
- </tr>
- <tr height="40">
- <td style="border:solid #000 1px; width: 20%;">中国车牌</td>
- <td style="border:solid #000 1px;" colspan="2">
- <div id="chinaCarNo"></div>
- </td>
- </tr>
- <tr height="40">
- <td style="border:solid #000 1px; width: 20%;">总金额大写(元)</td>
- <td style="border:solid #000 1px;" colspan="2">
- <div id="chinessMoney"></div>
- </td>
- <td style="border:solid #000 1px; width: 20%;">总金额小写(元)</td>
- <td style="border:solid #000 1px;">
- <div id="totalMoney"></div>
- </td>
- </tr>
- </table>
- <br/><br/>
- <table width="100%" style="border-collapse:collapse;border:none;">
- <tr height="40">
- <td style="border:solid #000 1px; width: 10%;">序号</td>
- <td style="border:solid #000 1px; width: 20%;">车牌</td>
- <td style="border:solid #000 1px; width: 20%;">类型</td>
- <td style="border:solid #000 1px; width: 30%;">项目</td>
- <td style="border:solid #000 1px; width: 20%;">金额(元)</td>
- <tr>
- <tbody id="items"></tbody>
- </table>
- <br/>
- <div align="center">
- 收费员:
- <span>  </span>
- 客户: <span id="customerName"></span>
- </div>
- </div>
- </div>
- </fieldset>
- </div>
- <script type="text/javascript">
- $(function () {
- $("#print_button").click(function () {
- $("#myPrintArea").printArea();
- });
- function getUrlParam(name) {
- var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
- var r = window.location.search.substr(1).match(reg); //匹配目标参数
- if (r != null) return unescape(r[2]);
- return null; //返回参数值
- }
- var id = getUrlParam('id');
- $.ajax({
- url: sa.cfg.api_url + '/TbBusiness/getById?id=' + id,
- type: 'post',
- success: function (data) {
- $("#no").html(data.data.no);
- $("#payTime").html(data.data.payTime);
- $("#cardNo").html(data.data.cardNo);
- $("#chinaCarNo").html(data.data.chinaCarNo);
- $("#totalMoney").html(data.data.totalMoney);
- $("#customerName").html(data.data.customerName);
- var chinessMoney = changeNumMoneyToChinese(data.data.totalMoney);
- $("#chinessMoney").html(chinessMoney);
- var itemList = data.data.items;
- var itemStr = '';
- $.each(itemList, function (index, item) {
- var i = index + 1;
- var carNo = data.data.cardNo;
- var itemTypeName = item.itemTypeName;
- var itemName = item.itemName;
- var itemPrice = item.itemPrice;
- itemStr += "<tr height=\"40\">"
- + "<td style=\"border:solid #000 1px; width: 10%;\">" + i + "</td>"
- + "<td style=\"border:solid #000 1px; width: 20%;\">" + carNo + "</td>"
- + "<td style=\"border:solid #000 1px; width: 20%;\">" + itemTypeName + "</td>"
- + "<td style=\"border:solid #000 1px; width: 30%;\">" + itemName + "</td>"
- + "<td style=\"border:solid #000 1px; width: 20%;\">" + itemPrice + "</td>"
- + "<tr>";
- })
- var carList = data.data.cars;
- $.each(carList, function (index, item) {
- var i = index + 1;
- var carNo = item.carNo;
- var itemTypeName = "停车费";
- var itemName = "停车费";
- var itemPrice = item.pay == 0 ? item.basePartMoney : item.money;
- itemStr += "<tr height=\"40\">"
- + "<td style=\"border:solid #000 1px; width: 10%;\">" + i + "</td>"
- + "<td style=\"border:solid #000 1px; width: 20%;\">" + carNo + "</td>"
- + "<td style=\"border:solid #000 1px; width: 20%;\">" + itemTypeName + "</td>"
- + "<td style=\"border:solid #000 1px; width: 30%;\">" + itemName + "</td>"
- + "<td style=\"border:solid #000 1px; width: 20%;\">" + itemPrice + "</td>"
- + "<tr>";
- })
- $('#items').html(itemStr);
- $("#myPrintArea").printArea();
- }
- });
- });
- function changeNumMoneyToChinese(money) {
- var cnNums = new Array("零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"); //汉字的数字
- var cnIntRadice = new Array("", "拾", "佰", "仟"); //基本单位
- var cnIntUnits = new Array("", "万", "亿", "兆"); //对应整数部分扩展单位
- var cnDecUnits = new Array("角", "分", "毫", "厘"); //对应小数部分单位
- var cnInteger = "整"; //整数金额时后面跟的字符
- var cnIntLast = "元"; //整型完以后的单位
- var maxNum = 999999999999999.9999; //最大处理的数字
- var IntegerNum; //金额整数部分
- var DecimalNum; //金额小数部分
- var ChineseStr = ""; //输出的中文金额字符串
- var parts; //分离金额后用的数组,预定义
- var Symbol = "";//正负值标记
- if (money == "") {
- return "";
- }
- money = parseFloat(money);
- if (money >= maxNum) {
- alert('超出最大处理数字');
- return "";
- }
- if (money == 0) {
- ChineseStr = cnNums[0] + cnIntLast + cnInteger;
- return ChineseStr;
- }
- if (money < 0) {
- money = -money;
- Symbol = "负 ";
- }
- money = money.toString(); //转换为字符串
- if (money.indexOf(".") == -1) {
- IntegerNum = money;
- DecimalNum = '';
- } else {
- parts = money.split(".");
- IntegerNum = parts[0];
- DecimalNum = parts[1].substr(0, 4);
- }
- if (parseInt(IntegerNum, 10) > 0) { //获取整型部分转换
- var zeroCount = 0;
- var IntLen = IntegerNum.length;
- for (var i = 0; i < IntLen; i++) {
- var n = IntegerNum.substr(i, 1);
- var p = IntLen - i - 1;
- var q = p / 4;
- var m = p % 4;
- if (n == "0") {
- zeroCount++;
- } else {
- if (zeroCount > 0) {
- ChineseStr += cnNums[0];
- }
- zeroCount = 0; //归零
- ChineseStr += cnNums[parseInt(n)] + cnIntRadice[m];
- }
- if (m == 0 && zeroCount < 4) {
- ChineseStr += cnIntUnits[q];
- }
- }
- ChineseStr += cnIntLast;
- //整型部分处理完毕
- }
- if (DecimalNum != '') { //小数部分
- var decLen = DecimalNum.length;
- for (var i = 0; i < decLen; i++) {
- var n = DecimalNum.substr(i, 1);
- if (n != '0') {
- ChineseStr += cnNums[Number(n)] + cnDecUnits[i];
- }
- }
- }
- if (ChineseStr == '') {
- ChineseStr += cnNums[0] + cnIntLast + cnInteger;
- } else if (DecimalNum == '') {
- ChineseStr += cnInteger;
- }
- ChineseStr = Symbol + ChineseStr;
- return ChineseStr;
- }
- </script>
- </body>
- </html>
|