printTemplateSaleOrder.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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 }}销售订单</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: 10px;
  36. "
  37. >
  38. <span style="width: 25%">单据日期:{{ row.createTime }}</span>
  39. <span style="width: 50%">客户简称:{{ formData.customerName }}</span>
  40. <span style="width: 50%">客户经理:{{ formData.salesman }}</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: 10px;
  49. "
  50. >
  51. <span style="width: 45%">交货日期:{{ formData.deliveryTime }}</span>
  52. <span style="width: 45%">单据编码:{{ formData.code }}</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"> 存货名称 </td>
  68. <td style="padding: 5px"> 规格型号 </td>
  69. <td style="padding: 5px"> 型号 </td>
  70. <td style="padding: 5px"> 颜色 </td>
  71. <td style="padding: 5px; width: 60px"> 单位</td>
  72. <td style="padding: 5px; width: 110px"> 数量</td>
  73. <!-- <td style="padding: 5px; width: 110px"> 盘具</td>
  74. <td style="padding: 5px; width: 110px"> 分段</td> -->
  75. <td style="padding: 5px"> 备注</td>
  76. </tr>
  77. <tr align="center" v-for="(item, index) in formData.productInfoList">
  78. <td style="padding: 5px"> {{ item.productName }} </td>
  79. <td style="padding: 5px">
  80. {{ item.specification }}
  81. </td>
  82. <td style="padding: 5px"> {{ item.model }}</td>
  83. <td style="padding: 5px"> {{ item.colorKey.join(',') }}</td>
  84. <td style="padding: 5px"> {{ item.measuringUnit }}</td>
  85. <td style="padding: 5px"> {{ item.contractNum }}</td>
  86. <!-- <td style="padding: 5px"> {{ item.totalCount }}</td>
  87. <td style="padding: 5px"> {{ item.totalCount }}</td> -->
  88. <td style="padding: 5px"> {{ item.remark }}</td>
  89. </tr>
  90. </tbody>
  91. </table>
  92. <div
  93. style="
  94. width: 100%;
  95. font-size: 12px;
  96. display: flex;
  97. justify-content: space-between;
  98. margin-top: 10px;
  99. "
  100. >
  101. <div style="flex: 1">
  102. <div>制单人:{{ detail.salesOrderBasicInfo.createUserName }}</div>
  103. </div>
  104. <div style="flex: 1">
  105. <div>审核人:{{ formData.createUserName }}</div>
  106. </div>
  107. </div>
  108. </div>
  109. <div slot="footer">
  110. <el-button @click="print">打印预览</el-button>
  111. <el-button @click="close">关闭</el-button>
  112. </div>
  113. </ele-modal>
  114. </template>
  115. <script>
  116. import { getOrderDetail, getSalesDetail, enterprisePage } from '@/api/saleOrder';
  117. import { mapGetters } from 'vuex';
  118. export default {
  119. name: 'print',
  120. computed: {
  121. ...mapGetters(['user'])
  122. },
  123. props: {
  124. },
  125. data() {
  126. return {
  127. checked: '',
  128. QRvisible: false,
  129. isPrintPrice: false,
  130. formData: {},
  131. row: {},
  132. detail: {},
  133. groupName: ''
  134. };
  135. },
  136. methods: {
  137. async open(row) {
  138. this.row = row;
  139. enterprisePage({
  140. pageNum: 1,
  141. size: 200
  142. }).then((res) => {
  143. if (res.list?.length > 0) {
  144. this.groupName = res.list[0].name;
  145. }
  146. });
  147. this.formData = await getOrderDetail(row.code);
  148. this.detail = await getSalesDetail(row.id);
  149. console.log('formData~~~', this.formData, this.detail);
  150. this.QRvisible = true;
  151. //包装维度
  152. },
  153. close() {
  154. this.QRvisible = false;
  155. },
  156. getTotalValue(key, num) {
  157. let val = this.formData?.productList?.reduce((total, item) => {
  158. return (total += Number(item[key]));
  159. }, 0);
  160. return (
  161. (val &&
  162. parseFloat(val)
  163. .toFixed(num)
  164. .replace(/\.?0+$/, '')) ||
  165. 0
  166. );
  167. },
  168. print() {
  169. const printSection = document.getElementById('printSection');
  170. // 创建打印任务
  171. const printWindow = window.open('', '_blank');
  172. printWindow.document.open();
  173. printWindow.document.write('<html><head><title>打印预览</title>');
  174. printWindow.document.write(
  175. '<link rel="stylesheet" href="your-stylesheet-url.css" type="text/css" />'
  176. );
  177. printWindow.document.write('</head><body>');
  178. printWindow.document.write(printSection.innerHTML);
  179. printWindow.document.write('</body></html>');
  180. printWindow.document.close();
  181. printWindow.onload = function () {
  182. printWindow.print();
  183. };
  184. }
  185. }
  186. };
  187. </script>
  188. <style lang="scss"></style>