print.html 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  6. <title>打印单据</title>
  7. <style type="text/css">
  8. body {
  9. left: 0px;
  10. top: 0px;
  11. right: 0px;
  12. bottom: 0px;
  13. margin: 0px;
  14. font-family: Arial, Helvetica, sans-serif;
  15. font-size: 12px;
  16. overflow: hidden;
  17. white-space: nowrap;
  18. }
  19. </style>
  20. <script src="../../static/print/jquery-2.0.3.js" type="text/javascript"></script>
  21. <script src="../../static/print/jquery.jPrintArea.js" type="text/javascript"></script>
  22. <script src="../../static/sa.js"></script>
  23. </head>
  24. <body>
  25. <div>
  26. <input type="button" style="height: 30;" id="print_button" value="打印"/>
  27. <fieldset align="">
  28. <legend>打印区</legend>
  29. <div id="myPrintArea" style="height: 1500;">
  30. <div align="center">
  31. <SPAN style="TEXT-DECORATION: underline;font-size:25px">收费单据证明</SPAN>
  32. <br/><br/>
  33. </div>
  34. <div align="left">
  35. 单号: <span id="no"></span>
  36. </div>
  37. <div style="text-align:center; font-size:15px;">
  38. <table width="100%" style="border-collapse:collapse;border:none;">
  39. <tr height="40">
  40. <td style="border:solid #000 1px; width: 20%;">越南车牌</td>
  41. <td style="border:solid #000 1px;" colspan="2">
  42. <div id="cardNo"></div>
  43. </td>
  44. <td style="border:solid #000 1px; width: 20%;" rowspan="2">支付时间</td>
  45. <td style="border:solid #000 1px;" rowspan="2">
  46. <div id="payTime"></div>
  47. </td>
  48. </tr>
  49. <tr height="40">
  50. <td style="border:solid #000 1px; width: 20%;">中国车牌</td>
  51. <td style="border:solid #000 1px;" colspan="2">
  52. <div id="chinaCarNo"></div>
  53. </td>
  54. </tr>
  55. <tr height="40">
  56. <td style="border:solid #000 1px; width: 20%;">总金额大写(元)</td>
  57. <td style="border:solid #000 1px;" colspan="2">
  58. <div id="chinessMoney"></div>
  59. </td>
  60. <td style="border:solid #000 1px; width: 20%;">总金额小写(元)</td>
  61. <td style="border:solid #000 1px;">
  62. <div id="totalMoney"></div>
  63. </td>
  64. </tr>
  65. </table>
  66. <br/><br/>
  67. <table width="100%" style="border-collapse:collapse;border:none;">
  68. <tr height="40">
  69. <td style="border:solid #000 1px; width: 10%;">序号</td>
  70. <td style="border:solid #000 1px; width: 20%;">车牌</td>
  71. <td style="border:solid #000 1px; width: 20%;">类型</td>
  72. <td style="border:solid #000 1px; width: 30%;">项目</td>
  73. <td style="border:solid #000 1px; width: 20%;">金额(元)</td>
  74. <tr>
  75. <tbody id="items"></tbody>
  76. </table>
  77. <br/>
  78. <div align="center">
  79. 收费员:
  80. <span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp</span>
  81. 客户: <span id="customerName"></span>
  82. </div>
  83. </div>
  84. </div>
  85. </fieldset>
  86. </div>
  87. <script type="text/javascript">
  88. $(function () {
  89. $("#print_button").click(function () {
  90. $("#myPrintArea").printArea();
  91. });
  92. function getUrlParam(name) {
  93. var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
  94. var r = window.location.search.substr(1).match(reg); //匹配目标参数
  95. if (r != null) return unescape(r[2]);
  96. return null; //返回参数值
  97. }
  98. var id = getUrlParam('id');
  99. $.ajax({
  100. url: sa.cfg.api_url + '/TbBusiness/getById?id=' + id,
  101. type: 'post',
  102. success: function (data) {
  103. $("#no").html(data.data.no);
  104. $("#payTime").html(data.data.payTime);
  105. $("#cardNo").html(data.data.cardNo);
  106. $("#chinaCarNo").html(data.data.chinaCarNo);
  107. $("#totalMoney").html(data.data.totalMoney);
  108. $("#customerName").html(data.data.customerName);
  109. var chinessMoney = changeNumMoneyToChinese(data.data.totalMoney);
  110. $("#chinessMoney").html(chinessMoney);
  111. var itemList = data.data.items;
  112. var itemStr = '';
  113. $.each(itemList, function (index, item) {
  114. var i = index + 1;
  115. var carNo = data.data.cardNo;
  116. var itemTypeName = item.itemTypeName;
  117. var itemName = item.itemName;
  118. var itemPrice = item.itemPrice;
  119. itemStr += "<tr height=\"40\">"
  120. + "<td style=\"border:solid #000 1px; width: 10%;\">" + i + "</td>"
  121. + "<td style=\"border:solid #000 1px; width: 20%;\">" + carNo + "</td>"
  122. + "<td style=\"border:solid #000 1px; width: 20%;\">" + itemTypeName + "</td>"
  123. + "<td style=\"border:solid #000 1px; width: 30%;\">" + itemName + "</td>"
  124. + "<td style=\"border:solid #000 1px; width: 20%;\">" + itemPrice + "</td>"
  125. + "<tr>";
  126. })
  127. var carList = data.data.cars;
  128. $.each(carList, function (index, item) {
  129. var i = index + 1;
  130. var carNo = item.carNo;
  131. var itemTypeName = "停车费";
  132. var itemName = "停车费";
  133. var itemPrice = item.pay == 0 ? item.basePartMoney : item.money;
  134. itemStr += "<tr height=\"40\">"
  135. + "<td style=\"border:solid #000 1px; width: 10%;\">" + i + "</td>"
  136. + "<td style=\"border:solid #000 1px; width: 20%;\">" + carNo + "</td>"
  137. + "<td style=\"border:solid #000 1px; width: 20%;\">" + itemTypeName + "</td>"
  138. + "<td style=\"border:solid #000 1px; width: 30%;\">" + itemName + "</td>"
  139. + "<td style=\"border:solid #000 1px; width: 20%;\">" + itemPrice + "</td>"
  140. + "<tr>";
  141. })
  142. $('#items').html(itemStr);
  143. $("#myPrintArea").printArea();
  144. }
  145. });
  146. });
  147. function changeNumMoneyToChinese(money) {
  148. var cnNums = new Array("零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"); //汉字的数字
  149. var cnIntRadice = new Array("", "拾", "佰", "仟"); //基本单位
  150. var cnIntUnits = new Array("", "万", "亿", "兆"); //对应整数部分扩展单位
  151. var cnDecUnits = new Array("角", "分", "毫", "厘"); //对应小数部分单位
  152. var cnInteger = "整"; //整数金额时后面跟的字符
  153. var cnIntLast = "元"; //整型完以后的单位
  154. var maxNum = 999999999999999.9999; //最大处理的数字
  155. var IntegerNum; //金额整数部分
  156. var DecimalNum; //金额小数部分
  157. var ChineseStr = ""; //输出的中文金额字符串
  158. var parts; //分离金额后用的数组,预定义
  159. var Symbol = "";//正负值标记
  160. if (money == "") {
  161. return "";
  162. }
  163. money = parseFloat(money);
  164. if (money >= maxNum) {
  165. alert('超出最大处理数字');
  166. return "";
  167. }
  168. if (money == 0) {
  169. ChineseStr = cnNums[0] + cnIntLast + cnInteger;
  170. return ChineseStr;
  171. }
  172. if (money < 0) {
  173. money = -money;
  174. Symbol = "负 ";
  175. }
  176. money = money.toString(); //转换为字符串
  177. if (money.indexOf(".") == -1) {
  178. IntegerNum = money;
  179. DecimalNum = '';
  180. } else {
  181. parts = money.split(".");
  182. IntegerNum = parts[0];
  183. DecimalNum = parts[1].substr(0, 4);
  184. }
  185. if (parseInt(IntegerNum, 10) > 0) { //获取整型部分转换
  186. var zeroCount = 0;
  187. var IntLen = IntegerNum.length;
  188. for (var i = 0; i < IntLen; i++) {
  189. var n = IntegerNum.substr(i, 1);
  190. var p = IntLen - i - 1;
  191. var q = p / 4;
  192. var m = p % 4;
  193. if (n == "0") {
  194. zeroCount++;
  195. } else {
  196. if (zeroCount > 0) {
  197. ChineseStr += cnNums[0];
  198. }
  199. zeroCount = 0; //归零
  200. ChineseStr += cnNums[parseInt(n)] + cnIntRadice[m];
  201. }
  202. if (m == 0 && zeroCount < 4) {
  203. ChineseStr += cnIntUnits[q];
  204. }
  205. }
  206. ChineseStr += cnIntLast;
  207. //整型部分处理完毕
  208. }
  209. if (DecimalNum != '') { //小数部分
  210. var decLen = DecimalNum.length;
  211. for (var i = 0; i < decLen; i++) {
  212. var n = DecimalNum.substr(i, 1);
  213. if (n != '0') {
  214. ChineseStr += cnNums[Number(n)] + cnDecUnits[i];
  215. }
  216. }
  217. }
  218. if (ChineseStr == '') {
  219. ChineseStr += cnNums[0] + cnIntLast + cnInteger;
  220. } else if (DecimalNum == '') {
  221. ChineseStr += cnInteger;
  222. }
  223. ChineseStr = Symbol + ChineseStr;
  224. return ChineseStr;
  225. }
  226. </script>
  227. </body>
  228. </html>