printTemplateSaleOrder.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. <template>
  2. <ele-modal
  3. title="销售订单"
  4. :visible.sync="QRvisible"
  5. v-if="QRvisible"
  6. width="90%"
  7. >
  8. <div id="printSection">
  9. <div
  10. v-for="(item, idx) in printList"
  11. :key="idx"
  12. :style="{
  13. display: 'flex',
  14. alignItems: 'center',
  15. justifyContent: 'center',
  16. flexDirection: 'column',
  17. pageBreakInside: 'avoid',
  18. marginBottom: idx < printList.length - 1 ? '40px' : '0'
  19. }"
  20. >
  21. <div>
  22. <div
  23. style="
  24. font-size: 20px;
  25. font-weight: 800;
  26. padding-right: 20px;
  27. width: 400px;
  28. margin: 0 auto;
  29. margin-bottom: 20px;
  30. "
  31. >{{ groupName }}销售订单</div
  32. >
  33. </div>
  34. <div
  35. style="
  36. width: 100%;
  37. font-size: 12px;
  38. display: flex;
  39. justify-content: space-between;
  40. margin-bottom: 10px;
  41. "
  42. >
  43. <span style="width: 25%">单据日期:{{ item.row.createTime }}</span>
  44. <span style="width: 40%"
  45. >客户简称:{{ item.formData.customerName }}</span
  46. >
  47. <span style="width: 35%"
  48. >客户经理:{{ item.formData.salesman }}</span
  49. >
  50. </div>
  51. <div
  52. style="
  53. width: 100%;
  54. font-size: 12px;
  55. display: flex;
  56. justify-content: space-between;
  57. margin-bottom: 10px;
  58. "
  59. >
  60. <span style="width: 65%"
  61. >交货日期:{{ item.formData.deliveryTime }}</span
  62. >
  63. <span style="width: 35%">单据编码:{{ item.formData.code }}</span>
  64. </div>
  65. <table
  66. cellspacing="0"
  67. border
  68. style="
  69. width: 100%;
  70. table-layout: fixed;
  71. word-break: break-all;
  72. word-wrap: break-word;
  73. font-size: 12px;
  74. "
  75. >
  76. <tbody>
  77. <tr align="center">
  78. <td style="padding: 5px; width: 25%"> 名称 </td>
  79. <td style="padding: 5px; width: 25%"> 型号规格 </td>
  80. <td style="padding: 5px; width: 8%"> 颜色 </td>
  81. <td style="padding: 5px; width: 10%"> 数量</td>
  82. <td style="padding: 5px; width: 8%"> 单位</td>
  83. <td style="padding: 5px; width: 20%"> 生产要求</td>
  84. </tr>
  85. <tr
  86. align="center"
  87. v-for="(p, pIndex) in item.formData.productInfoList"
  88. :key="pIndex"
  89. >
  90. <td style="padding: 5px"> {{ p.productName }} </td>
  91. <td style="padding: 5px">
  92. {{ p.model }}/{{ p.specification }}</td
  93. >
  94. <td style="padding: 5px"> {{ p.colorKey }}</td>
  95. <td style="padding: 5px"> {{ p.contractNum }}</td>
  96. <td style="padding: 5px"> {{ p.measuringUnit }}</td>
  97. <td style="padding: 5px"> {{ p.productionRequirements }}</td>
  98. </tr>
  99. </tbody>
  100. </table>
  101. <div
  102. style="
  103. width: 100%;
  104. font-size: 12px;
  105. display: flex;
  106. justify-content: space-between;
  107. margin-top: 10px;
  108. "
  109. >
  110. <div style="flex: 1">
  111. <div
  112. >制单人:{{
  113. item.detail.salesOrderBasicInfo.createUserName
  114. }}</div
  115. >
  116. </div>
  117. <div style="flex: 1">
  118. <div
  119. >审核人:{{ item.detail.salesOrderBasicInfo.reviewerName }}</div
  120. >
  121. </div>
  122. </div>
  123. </div>
  124. </div>
  125. <div slot="footer">
  126. <el-button @click="print">打印预览</el-button>
  127. <el-button @click="close">关闭</el-button>
  128. </div>
  129. </ele-modal>
  130. </template>
  131. <script>
  132. import {
  133. getOrderDetail,
  134. getSalesDetail,
  135. enterprisePage
  136. } from '@/api/saleOrder';
  137. import { mapGetters } from 'vuex';
  138. export default {
  139. name: 'print',
  140. computed: {
  141. ...mapGetters(['user'])
  142. },
  143. props: {},
  144. data() {
  145. return {
  146. checked: '',
  147. QRvisible: false,
  148. isPrintPrice: false,
  149. printList: [],
  150. groupName: ''
  151. };
  152. },
  153. methods: {
  154. async open(rows) {
  155. const list = Array.isArray(rows) ? rows : [rows];
  156. if (!list.length) return;
  157. enterprisePage({
  158. pageNum: 1,
  159. size: 200
  160. }).then((res) => {
  161. if (res.list?.length > 0) {
  162. this.groupName = res.list[0].name;
  163. }
  164. });
  165. const results = await Promise.all(
  166. list.map(async (row) => {
  167. const formData = await getOrderDetail(row.code);
  168. const detail = await getSalesDetail(row.id);
  169. return { row, formData, detail };
  170. })
  171. );
  172. this.printList = results;
  173. this.QRvisible = true;
  174. },
  175. close() {
  176. this.QRvisible = false;
  177. },
  178. print() {
  179. const printSection = document.getElementById('printSection');
  180. const printWindow = window.open('', '_blank');
  181. printWindow.document.open();
  182. printWindow.document.write('<html><head><title>打印预览</title>');
  183. printWindow.document.write(
  184. '<link rel="stylesheet" href="your-stylesheet-url.css" type="text/css" />'
  185. );
  186. printWindow.document.write('</head><body>');
  187. printWindow.document.write(printSection.innerHTML);
  188. printWindow.document.write('</body></html>');
  189. printWindow.document.close();
  190. printWindow.onload = function () {
  191. printWindow.print();
  192. };
  193. }
  194. }
  195. };
  196. </script>
  197. <style lang="scss"></style>