From 4dfd11f526b7b4fe578561a9ea4c27a24a88acb4 Mon Sep 17 00:00:00 2001 From: zhangherong <571457620@qq.com> Date: 星期四, 21 八月 2025 09:06:00 +0800 Subject: [PATCH] art: 物料拉动增加发布时间 --- src/views/mes/modules/MesProductionWorkOrderReportModal.vue | 164 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 162 insertions(+), 2 deletions(-) diff --git a/src/views/mes/modules/MesProductionWorkOrderReportModal.vue b/src/views/mes/modules/MesProductionWorkOrderReportModal.vue index a26ef11..2aa862a 100644 --- a/src/views/mes/modules/MesProductionWorkOrderReportModal.vue +++ b/src/views/mes/modules/MesProductionWorkOrderReportModal.vue @@ -54,11 +54,69 @@ </a-form-model> </j-form-container> </a-spin> + + <!-- 鎵撳嵃鏍囩瀹瑰櫒 --> + <div id="printLabel" style="visibility: hidden; position: absolute; left: -9999px; width: 300px; height: 200px; border: 1px solid #000; font-family: 'Microsoft YaHei', sans-serif; padding: 8px; box-sizing: border-box;"> + <!-- 鏍囩瀹瑰櫒 --> + <div style="display: flex; flex-direction: column; height: 100%;"> + <!-- 澶撮儴锛氭爣棰� + Logo --> + <div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; width: 100%;"> + <h3 style="margin: 0; color: white; background-color: black; padding: 4px 8px; border-radius: 4px; font-size: 14px; font-weight: bold;">鎴愬搧鎵樻爣绛�</h3> + <img src="/logo.png" alt="鍏徃Logo" style="width: 40px; height: 40px;" /> + </div> + + <!-- 涓讳綋鍐呭锛氬乏渚ф枃鏈� + 鍙充晶浜岀淮鐮� --> + <div style="display: flex; flex: 1; gap: 20px;"> + <!-- 宸︿晶锛氭爣绛句俊鎭� --> + <div style="flex: 1; line-height: 1.4; font-size: 10px;"> + <table style="width: 100%; border-collapse: collapse;"> + <tr> + <td style="width: 60px; font-weight: bold; white-space: nowrap;">鎵规鍙凤細</td> + <td>{{ finishedProductLabel.batchNumber }}</td> + </tr> + <tr> + <td style="width: 60px; font-weight: bold; white-space: nowrap;">浜у搧鍨嬪彿锛�</td> + <td>{{ finishedProductLabel.materialName }}</td> + </tr> + <tr> + <td style="width: 60px; font-weight: bold; white-space: nowrap;">搴撳瓨鍦扮偣锛�</td> + <td>{{ finishedProductLabel.warehouseCode }}</td> + </tr> + <tr> + <td style="width: 60px; font-weight: bold; white-space: nowrap;">宸ュ崟鍙凤細</td> + <td>{{ finishedProductLabel.orderCode }}</td> + </tr> + <tr> + <td style="width: 60px; font-weight: bold; white-space: nowrap;">浠诲姟鍙凤細</td> + <td>{{ finishedProductLabel.workOrderCode }}</td> + </tr> + <tr> + <td style="width: 60px; font-weight: bold; white-space: nowrap;">鏁伴噺锛�</td> + <td>{{ finishedProductLabel.quantity }}</td> + </tr> + </table> + </div> + + <!-- 鍙充晶锛氫簩缁寸爜 --> + <div style="flex: 0 0 60px; text-align: center;"> + <canvas id="qrcodeCanvas" width="60" height="60"></canvas> + </div> + </div> + + <!-- 搴曢儴锛氭墭鍙� --> + <div style="text-align: center; margin-top: 8px; font-size: 10px; font-weight: bold;"> + {{ finishedProductLabel.palletNumber }} + </div> + </div> + + </div> </j-modal> </template> <script> import { postAction, getAction } from '@api/manage' +import printJS from 'print-js' +import QRCode from 'qrcode' export default { name: 'MesProductionWorkOrderReportModal', @@ -81,10 +139,11 @@ sm: { span: 18 }, }, url: { - report: '/mesworkreporting/mesWorkReporting/add', + report: '/mes/mesWorkReporting/add', selectReportWorkOrderList: '/mes/productionOrder/selectReportWorkOrderList' }, - workOrderOptions: [] + workOrderOptions: [], + finishedProductLabel: {} } }, computed: { @@ -93,6 +152,90 @@ }, }, methods: { + // 鐢熸垚浜岀淮鐮� + generateQRCode(text) { + const canvas = document.getElementById('qrcodeCanvas'); + // 娓呯┖鐢诲竷 + const ctx = canvas.getContext('2d'); + ctx.clearRect(0, 0, canvas.width, canvas.height); + + // 鐢熸垚浜岀淮鐮� + QRCode.toCanvas(canvas, text, { + width: 60, + margin: 1, + errorCorrectionLevel: 'M' + }, (error) => { + if (error) { + console.error('浜岀淮鐮佺敓鎴愬け璐�:', error); + } + }); + }, + // 鎵撳嵃鏍囩 + printLabel() { + this.generateQRCode('鎴愬搧鎵樻爣绛�'); // 鍏堢敓鎴愪簩缁寸爜 + setTimeout(() => { + printJS({ + printable: 'printLabel', + type: 'html', + targetStyles: ['*'], + style: ` @page { + margin: 0; + size: A4; + } + #printLabel { + visibility: visible !important; + position: static !important; + left: 0 !important; + top: 0 !important; + width: 300px !important; + height: 200px !important; + border: 1px solid #000; + font-family: 'Microsoft YaHei', sans-serif; + padding: 8px; + box-sizing: border-box; + margin: 0; + } + #printLabel h3 { + margin: 0; + color: white; + background-color: #000; + padding: 4px 8px; + border-radius: 4px; + font-size: 14px; + font-weight: bold; + } + #printLabel img { + width: 40px; + height: 40px; + } + #printLabel table { + width: 100%; + border-collapse: collapse; + } + #printLabel td { + padding: 2px 0; + } + #printLabel canvas { + width: 60px; + height: 60px; + } + @media print { + * { + background: inherit !important; + color: inherit !important; + filter: none !important; + -webkit-filter: none !important; + } + #printLabel h3 { + background-color: #000 !important; + color: white !important; + } + } + `, + scanStyles: false + }); + }, 100); + }, add (record) { // 閲嶇疆琛ㄥ崟 this.$refs.form && this.$refs.form.resetFields() @@ -119,9 +262,26 @@ factoryId: this.model.factoryId, quantity: this.model.quantity } + const workOrderOption = this.workOrderOptions.find(item => item.value === this.model.orderId) postAction(this.url.report, formData).then(res => { if (res.success) { this.$message.success(res.message) + const data = res.result + if (data.reportType === 'FINISHED') { + this.finishedProductLabel = { + batchNumber: data.batchNumber,//鎵规鍙� + materialName: this.model.materialName,//浜у搧鍨嬪彿锛堢墿鏂欏悕绉帮級 + warehouseCode: data.warehouseCode,//搴撳瓨鍦扮偣锛堢嚎杈逛粨缂栧彿锛� + orderCode: workOrderOption.label,//宸ュ崟鍙凤紙鐢熶骇璁㈠崟鍙凤級 + workOrderCode: data.workOrderCode,//浠诲姟鍙凤紙鎺掍骇宸ュ崟鍙凤級 + quantity: data.quantity,//鎶ュ伐鏁伴噺 + palletNumber: data.palletNumber//鎵樺彿 + } + //鎴愬搧鎵樻爣绛炬墦鍗� + this.$nextTick(() => { + this.printLabel() + }) + } this.submitCallback() } else { this.$message.warning(res.message) -- Gitblit v1.9.3