print-template-ht.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. <template>
  2. <ele-modal
  3. title="出库单"
  4. :visible.sync="QRvisible"
  5. v-if="QRvisible"
  6. width="90%"
  7. >
  8. <div
  9. id="printSection"
  10. style="
  11. display: flex;
  12. align-items: center;
  13. justify-content: center;
  14. flex-direction: column;
  15. "
  16. >
  17. <div>
  18. <div
  19. style="
  20. font-size: 20px;
  21. font-weight: 800;
  22. padding-right: 20px;
  23. width: 400px;
  24. margin: 0 auto;
  25. "
  26. >{{ groupName }}{{ isPrintPrice ? '货物销售单' : '货物签收单' }}</div
  27. >
  28. </div>
  29. <div
  30. style="
  31. width: 100%;
  32. font-size: 12px;
  33. display: flex;
  34. justify-content: space-between;
  35. margin-bottom: 5px;
  36. margin-top: 5px;
  37. "
  38. >
  39. <span style="width: 55%">客户:{{ formData.contactName }}</span>
  40. <span style="width: 25%; text-align: right;">单据编码:{{ formData.docNo }}</span>
  41. </div>
  42. <div
  43. style="
  44. width: 100%;
  45. font-size: 12px;
  46. display: flex;
  47. justify-content: space-between;
  48. margin-bottom: 5px;
  49. "
  50. >
  51. <span style="width: 55%">项目:{{ formData.projectName }}</span>
  52. <span style="width: 25%; text-align: right;">单据日期:{{ formData.createTime ? formData.createTime.split(' ')[0] : '' }}</span>
  53. </div>
  54. <table
  55. cellspacing="0"
  56. border
  57. style="
  58. width: 100%;
  59. table-layout: fixed;
  60. word-break: break-all;
  61. word-wrap: break-word;
  62. font-size: 12px;
  63. "
  64. >
  65. <tbody>
  66. <tr align="center">
  67. <!-- <td style="padding: 5px; width: 15%"> 名称 </td> -->
  68. <td style="padding: 2px; width: 5%"> 序号 </td>
  69. <td style="padding: 2px; width: 24%"> 规格型号 </td>
  70. <td style="padding: 2px; width: 6%"> 单位</td>
  71. <td style="padding: 2px; width: 8%"> 数量</td>
  72. <td style="padding: 2px; width: 10%" v-if="isPrintPrice"> 单价</td>
  73. <td style="padding: 2px; width: 6%" v-if="isPrintPrice"> 税率</td>
  74. <td style="padding: 2px; width: 10%" v-if="isPrintPrice"> 金额</td>
  75. <td style="padding: 2px; width: 10%"> 颜色 </td>
  76. <!-- <td style="padding: 5px; width: 10%"> 机型 </td> -->
  77. <td style="padding: 2px; width: 12%"> 备注</td>
  78. </tr>
  79. <tr align="center" v-for="(item, index) in formData.productList">
  80. <!-- <td style="padding: 5px"> {{ item.productName }} </td> -->
  81. <td style="padding: 2px"> {{ index + 1 }}</td>
  82. <td style="padding: 2px">
  83. <!-- {{ item.specification }}/ -->
  84. {{ item.modelType }}
  85. </td>
  86. <td style="padding: 2px"> {{ item.saleUnit }}</td>
  87. <td style="padding: 2px"> {{ item.saleCount }}</td>
  88. <td style="padding: 2px;" v-if="isPrintPrice"> {{ item.singlePrice }}</td>
  89. <td style="padding: 2px;" v-if="isPrintPrice"> {{ item.taxRate }}{{ item.taxRate ? '%' : '0%' }}</td>
  90. <td style="padding: 2px;" v-if="isPrintPrice"> {{ item.totalPrice }}</td>
  91. <td style="padding: 2px"> {{ item.colorKey }}</td>
  92. <!-- <td style="padding: 5px"> {{ item.modelKey }}</td> -->
  93. <td style="padding: 2px"> {{ item.remark }}</td>
  94. </tr>
  95. <tr align="center">
  96. <td style="padding: 2px"> 合计 </td>
  97. <td style="padding: 2px"> </td>
  98. <td style="padding: 2px">{{ getTotalValue('totalCount', 2) }} </td>
  99. <td style="padding: 2px" v-if="isPrintPrice"> </td>
  100. <td style="padding: 2px" v-if="isPrintPrice"> </td>
  101. <td style="padding: 2px" v-if="isPrintPrice"> {{ getTotalValue('totalPrice', 2) }} </td>
  102. <td style="padding: 2px" colspan="2"> {{ isPrintPrice ? convertToChinese(getTotalValue('totalPrice', 2)) : '' }} </td>
  103. <td style="padding: 2px"> </td>
  104. </tr>
  105. </tbody>
  106. </table>
  107. <div
  108. style="
  109. width: 100%;
  110. font-size: 12px;
  111. display: flex;
  112. justify-content: space-between;
  113. margin-top: 5px;
  114. "
  115. >
  116. <div style="flex: 1">
  117. <div>业务员:{{ formData.saleOrderList[0]?.salesmanName }}</div>
  118. </div>
  119. <div style="flex: 1">
  120. <div>制单人:{{ formData.makerName }}</div>
  121. </div>
  122. <div style="flex: 1"> 核对人: </div>
  123. <div style="flex: 1"> 发货人: </div>
  124. </div>
  125. <div
  126. style="
  127. width: 100%;
  128. font-size: 12px;
  129. display: flex;
  130. justify-content: space-between;
  131. margin-top: 5px;
  132. "
  133. >
  134. <div style="width: 75%">
  135. <!-- <div>地址:{{ formData.receiveAddress }}</div> -->
  136. <div>地址:湖南湘江新区宁乡夏铎铺机械工业园</div>
  137. </div>
  138. <div style="width: 25%">
  139. <div>客户签字:</div>
  140. </div>
  141. </div>
  142. </div>
  143. <div slot="footer">
  144. <el-button @click="print">打印预览</el-button>
  145. <el-button @click="close">关闭</el-button>
  146. </div>
  147. </ele-modal>
  148. </template>
  149. <script>
  150. import { getSendSaleOrderrecordDetailSplit } from '@/api/saleManage/saleordersendrecord';
  151. import { mapGetters } from 'vuex';
  152. import { convertToChinese } from '@/utils/util';
  153. export default {
  154. name: 'print',
  155. computed: {
  156. ...mapGetters(['user'])
  157. },
  158. props: {
  159. groupName: ''
  160. },
  161. data() {
  162. return {
  163. checked: '',
  164. QRvisible: false,
  165. isPrintPrice: false,
  166. formData: {},
  167. convertToChinese
  168. };
  169. },
  170. methods: {
  171. async open(id, isPrintPrice) {
  172. this.formData = await getSendSaleOrderrecordDetailSplit(id);
  173. this.QRvisible = true;
  174. this.isPrintPrice = isPrintPrice;
  175. //包装维度
  176. },
  177. close() {
  178. this.QRvisible = false;
  179. },
  180. getTotalValue(key, num) {
  181. let val = this.formData?.productList?.reduce((total, item) => {
  182. return (total += Number(item[key]));
  183. }, 0);
  184. return (
  185. (val &&
  186. parseFloat(val)
  187. .toFixed(num)
  188. .replace(/\.?0+$/, '')) ||
  189. 0
  190. );
  191. },
  192. print() {
  193. const printSection = document.getElementById('printSection');
  194. // 创建打印任务
  195. const printWindow = window.open('', '_blank');
  196. printWindow.document.open();
  197. printWindow.document.write('<html><head><title>打印预览</title>');
  198. printWindow.document.write(
  199. '<link rel="stylesheet" href="your-stylesheet-url.css" type="text/css" />'
  200. );
  201. printWindow.document.write('</head><body>');
  202. printWindow.document.write(printSection.innerHTML);
  203. printWindow.document.write('</body></html>');
  204. printWindow.document.close();
  205. printWindow.onload = function () {
  206. printWindow.print();
  207. };
  208. }
  209. }
  210. };
  211. </script>
  212. <style lang="scss"></style>