sendOrderPrint.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. function getRandomNum(num = 8) {
  2. let str = "";
  3. for (var i = 0; i < num; i++) {
  4. str += parseInt(Math.random() * 10);
  5. }
  6. return str;
  7. }
  8. function receiptDocuments(data, domId) {
  9. let yy = new Date().getFullYear();
  10. let mm = new Date().getMonth() + 1;
  11. if (mm < 10) {
  12. mm = "0" + mm;
  13. }
  14. let dd = new Date().getDate();
  15. if (dd < 10) {
  16. dd = "0" + dd;
  17. }
  18. let { customerName, customName, productCodeListVOList, noticeNumber, printUser, drawer, salesman } = data;
  19. let printContent = `<div class="table" style="display: flex;flex-direction: column;align-items: center;width: 1000px;">
  20. <div class="tableName" style="margin: 0 auto;font-size: 30px;font-weight: bold;">
  21. 诸暨市新丝维纤维有限公司送货单
  22. </div>
  23. <div class="title" style="width: 100%; padding: 0 10px;position: relative;">
  24. <div style="display: flex;justify-content: space-between;width: 100%;padding: 0 10px;box-sizing: border-box;">
  25. <span>通知单号&nbsp;&nbsp;${noticeNumber}</span>
  26. <span>单号&nbsp;&nbsp;${getRandomNum()}</span>
  27. </div>
  28. <div
  29. style="display: flex;justify-content: space-between;width: 100%; padding: 0 10px;box-sizing: border-box;margin-bottom: 5px;">
  30. <span>客户名称&nbsp;&nbsp;<span class="name" style="display: inline-block;
  31. width: 300px;
  32. border-bottom: 2px solid black;
  33. padding-bottom: 3px;">${customerName || customName}</span>
  34. </span>
  35. <span>时间&nbsp;&nbsp;${yy} 年 ${mm} 月 ${dd} 日</span>
  36. </div>
  37. <div class="aside" style="position: absolute;right: -40px;top: 1px;">
  38. <span style="writing-mode: vertical-lr;">白联财务联,红联仓库联,黄联客户联</span>
  39. </div>
  40. <div class="tableContext" style="width: 100%;">
  41. <table style="width:100%; border-collapse:collapse;" border="1" cellpadding="10" align="center">
  42. <tbody>
  43. <tr align="center">
  44. <td width="200px">品名</td>
  45. <td width="200px">规格</td>
  46. <td width="50px">等级</td>
  47. <td width="150px">色泽</td>
  48. <td width="60px">批号</td>
  49. <td width="90px">实发箱数</td>
  50. <td width="120px">数量(公斤)</td>
  51. <td width="50px">单价</td>
  52. <td width="100px">金额</td>
  53. </tr>`;
  54. let myTotalBoxNum = 0, totalWeight = 0, totalPrice = 0;
  55. for (let i = 0; i < productCodeListVOList.length; i++) {
  56. let item = productCodeListVOList[i];
  57. if (item.totalBoxNum) {
  58. myTotalBoxNum += Number(item.totalBoxNum);
  59. }
  60. if (item.totalSuttle) {
  61. totalWeight += Number(item.totalSuttle);
  62. }
  63. let price = 0
  64. if (item.totalSuttle && item.productUnitPrice) {
  65. price = Number(item.totalSuttle) * Number(item.productUnitPrice);
  66. totalPrice += price
  67. }
  68. price = price.toFixed(2);
  69. printContent += `<tr align="center">
  70. <td>${item.productName}</td>
  71. <td>${item.productSpecifications}</td>
  72. <td>${item.levels}</td>
  73. <td>${item.productColor}</td>
  74. <td>${item.lotNum}</td>
  75. <td>${item.totalBoxNum}</td>
  76. <td>${item.totalSuttle}</td>
  77. <td>${item.productUnitPrice}</td>
  78. <td>${price}</td>
  79. </tr>`
  80. }
  81. totalWeight = totalWeight.toFixed(2);
  82. totalPrice = totalPrice.toFixed(2);
  83. printContent += `<tr align="center">
  84. <td colspan="5">合计</td>
  85. <td>${myTotalBoxNum}</td>
  86. <td>${totalWeight}</td>
  87. <td></td>
  88. <td>${totalPrice}</td>
  89. </tr>`
  90. printContent += `</tbody>
  91. </table>
  92. </div>
  93. <div class="tableBottom" style='width: 100%;
  94. padding: 0 10px;
  95. margin: 0 auto;
  96. position: relative;
  97. top: 200px;
  98. display: flex;
  99. flex-direction: row;
  100. flex-wrap: wrap;
  101. justify-content: space-between;'>
  102. <span style="width: 100%;">备注:</span>
  103. <span>制单员&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;${printUser}</span>
  104. <span>销货员&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;${salesman}</span>
  105. <span>提货人</span>
  106. <span>收货单位签名或盖章:</span>
  107. <span style="width: 100%;">客户收货员签名,即视为已收到本单货物和对欠款金额的确认。则该送货单上的期末欠款金额作为欠款法律凭证。</span>
  108. <span style="width: 100%">不同批号,不得混用。发现质量问题请在10天内提告本公司。如有后道编织物品,恕不负责退还及赔偿</span>
  109. </div>
  110. </div>`
  111. document.body.innerHTML = document.getElementById(domId).innerHTML = printContent;
  112. window.print(); //打印
  113. window.location.reload();
  114. return false;
  115. }
  116. export default receiptDocuments