printQRCode.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. <template>
  2. <ele-modal
  3. title="入库物品"
  4. :visible.sync="QRvisible"
  5. v-if="QRvisible"
  6. width="50%"
  7. @close="close"
  8. >
  9. <div
  10. id="printSection"
  11. style="
  12. display: flex;
  13. align-items: center;
  14. justify-content: center;
  15. flex-wrap: wrap;
  16. "
  17. >
  18. <table
  19. border
  20. cellspacing="0"
  21. style="
  22. table-layout: auto;
  23. word-break: break-all;
  24. word-wrap: break-word;
  25. font-size: 12px;
  26. margin-bottom: 20px;
  27. "
  28. v-for="row in rowList"
  29. :key="row.packageNo"
  30. >
  31. <tbody>
  32. <tr align="center">
  33. <template v-if="row.packageNo">
  34. <td>编码</td>
  35. <td colspan="3">{{ row?.packageNo ?? '' }}</td>
  36. </template>
  37. <template v-else>
  38. <td>编码</td>
  39. <td colspan="3">{{ row?.categoryCode ?? '' }}</td>
  40. </template>
  41. </tr>
  42. <tr align="center">
  43. <td>物料名称</td>
  44. <td colspan="3">{{ row?.categoryName ?? '' }}</td>
  45. </tr>
  46. <tr align="center">
  47. <td>批次号</td>
  48. <td>{{ row?.batchNo ?? '' }}</td>
  49. <td colspan="2" rowspan="4" class="qrcode">
  50. <ele-qr-code-svg :value="setCode(row)" :size="120" />
  51. </td>
  52. </tr>
  53. <tr align="center">
  54. <td>规格</td>
  55. <td>{{ row?.specification ?? '' }}</td>
  56. </tr>
  57. <tr align="center">
  58. <td>单件数量</td>
  59. <td
  60. >{{ row?.measureQuantity ?? '' }}{{ row?.measureUnit ?? '' }}
  61. /
  62. {{ row?.packingQuantity ?? '' }}{{ row?.packingUnit ?? '' }}</td
  63. >
  64. </tr>
  65. <tr align="center">
  66. <td>重量</td>
  67. <td>{{ row?.weight ? row?.weight + row?.weightUnit : '' }}</td>
  68. </tr>
  69. <tr align="center">
  70. <td>生产日期</td>
  71. <td>{{ row?.productionDate ?? '' }}</td>
  72. <td>序号</td>
  73. <td></td>
  74. </tr>
  75. <tr align="center">
  76. <td>供应商</td>
  77. <td colspan="3">{{ row?.supplierName ?? '' }}</td>
  78. </tr>
  79. <tr align="center">
  80. <td>到货时间</td>
  81. <td></td>
  82. <td>制单人</td>
  83. <td>{{ user?.info?.name ?? '' }}</td>
  84. </tr>
  85. </tbody>
  86. </table>
  87. </div>
  88. <div slot="footer">
  89. <el-button @click="print">打印预览</el-button>
  90. <el-button @click="close">关闭</el-button>
  91. </div>
  92. </ele-modal>
  93. </template>
  94. <script>
  95. import { mapGetters } from 'vuex';
  96. import EleQrCodeSvg from 'ele-admin/es/ele-qr-code-svg';
  97. import { getOutInRecordsPage } from '@/api/warehouseManagement';
  98. export default {
  99. name: 'print',
  100. components: {
  101. EleQrCodeSvg
  102. },
  103. computed: {
  104. ...mapGetters(['user']),
  105. setCode() {
  106. return (row) => {
  107. //二维码类型是入库单in,入库单id,每个包装的编码,入库的物品类型
  108. const params = new URLSearchParams({
  109. inoutType: 'in',
  110. inId: this.$route.query.id,
  111. packageNo: row?.packageNo ?? '',
  112. assetType: this._props.assetType,
  113. batchNo: row?.batchNo ?? ''
  114. });
  115. return params.toString();
  116. };
  117. }
  118. },
  119. props: {
  120. assetType: {
  121. type: String,
  122. default: ''
  123. }
  124. },
  125. data() {
  126. return {
  127. QRvisible: false,
  128. codeList: [],
  129. formData: {},
  130. rowList: [],
  131. row: {},
  132. text: '',
  133. type: '',
  134. inId: ''
  135. };
  136. },
  137. methods: {
  138. // 二维码有两种,可拆分包装层面的,不可拆分的
  139. open(row, type) {
  140. // row里有packageNo,则是包装的二维码,没有就是产品的二维码
  141. console.log(row);
  142. console.log(this.$route.query.id);
  143. this.rowList.push(row);
  144. // getSendSaleOrderrecordDetailSplit(id).then((data) => {
  145. // if (JSON.stringify(data) != '{}') {
  146. // this.formData = data;
  147. // this.formData['carName'] = data.carList
  148. // .map((item) => item.name)
  149. // .toString();
  150. // this.formData.projectName = data.saleOrderList?.[0]?.projectName;
  151. // this.formData.driverNames = data.logisticTrakListNoteVOList
  152. // .map((item) => item.driverName)
  153. // .join(','); // 承运人
  154. // this.codeList = data.productList;
  155. // this.formData.markerName = this.user.info.name;
  156. // }
  157. // });
  158. this.QRvisible = true;
  159. },
  160. async init(id) {
  161. console.log(id);
  162. const res = await getOutInRecordsPage({
  163. pageNum: 1,
  164. size: -1,
  165. outInId: id
  166. });
  167. this.rowList = res.list;
  168. this.QRvisible = true;
  169. },
  170. close() {
  171. this.rowList = [];
  172. this.QRvisible = false;
  173. },
  174. //获取当前日期函数
  175. getNowFormatDate() {
  176. let date = new Date(),
  177. obj = {
  178. year: date.getFullYear(), //获取完整的年份(4位)
  179. month: date.getMonth() + 1, //获取当前月份(0-11,0代表1月)
  180. strDate: date.getDate(), // 获取当前日(1-31)
  181. week: '星期' + '日一二三四五六'.charAt(date.getDay()), //获取当前星期几(0 ~ 6,0代表星期天)
  182. hour: date.getHours(), //获取当前小时(0 ~ 23)
  183. minute: date.getMinutes(), //获取当前分钟(0 ~ 59)
  184. second: date.getSeconds() //获取当前秒数(0 ~ 59)
  185. };
  186. Object.keys(obj).forEach((key) => {
  187. if (obj[key] < 10) obj[key] = `0${obj[key]}`;
  188. });
  189. // return `${obj.year}年${obj.month}月${obj.strDate}日 ${obj.hour}:${obj.minute}:${obj.second}`;
  190. return `${obj.year}-${obj.month}-${obj.strDate}`;
  191. },
  192. print() {
  193. const printSection = document.getElementById('printSection');
  194. console.log(printSection);
  195. // 创建打印任务
  196. const printWindow = window.open('', '_blank');
  197. printWindow.document.open();
  198. printWindow.document.write('<html><head><title>打印预览</title>');
  199. printWindow.document.write(
  200. '<link rel="stylesheet" href="your-stylesheet-url.css" type="text/css" />'
  201. );
  202. printWindow.document.write('</head><body>');
  203. printWindow.document.write(printSection.innerHTML);
  204. printWindow.document.write('</body></html>');
  205. printWindow.document.close();
  206. printWindow.onload = function () {
  207. printWindow.print();
  208. };
  209. }
  210. }
  211. };
  212. </script>
  213. <style lang="scss">
  214. #printSection {
  215. display: flex;
  216. align-items: center;
  217. justify-content: center;
  218. flex-direction: column;
  219. .table_box {
  220. width: 70%;
  221. table-layout: auto;
  222. word-break: break-all;
  223. word-wrap: break-word;
  224. }
  225. th,
  226. td {
  227. padding: 4px;
  228. vertical-align: bottom;
  229. position: relative;
  230. }
  231. .barCode {
  232. position: absolute;
  233. right: 10px;
  234. top: 50%;
  235. transform: translateY(-50%);
  236. }
  237. .person {
  238. width: 70%;
  239. display: flex;
  240. align-items: center;
  241. justify-content: center;
  242. margin-bottom: 10px;
  243. > div {
  244. flex: 1;
  245. }
  246. }
  247. }
  248. </style>
  249. <style scoped lang="scss">
  250. @media print {
  251. .no-print {
  252. display: none;
  253. }
  254. }
  255. .qrcode {
  256. padding: 8px !important;
  257. }
  258. </style>