From d9e402035b1e212419331c6acb21366d66aea555 Mon Sep 17 00:00:00 2001 From: Ledo Date: Mon, 4 Aug 2025 23:04:32 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=A1=E5=88=92=E3=80=81=E5=AE=9E=E6=97=B6?= =?UTF-8?q?=E5=BA=93=E5=AD=98=E3=80=81=E6=89=93=E5=8D=B0=E6=8E=92=E7=89=88?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/heli/plan/printDialog.vue | 36 +++---- .../src/views/heli/plan/printFinalDialog.vue | 77 ++++++++------- .../views/heli/processdesign/printDialog.vue | 6 +- .../heli/processdesign/printFinalDialog.vue | 75 ++++++++------- .../src/views/heli/storagelog/printDialog.vue | 61 ++++++++---- .../heli/storagelog/printFinalDialog.vue | 93 ++++++++++++------- 6 files changed, 205 insertions(+), 143 deletions(-) diff --git a/mes-ui/mes-ui-admin-vue3/src/views/heli/plan/printDialog.vue b/mes-ui/mes-ui-admin-vue3/src/views/heli/plan/printDialog.vue index 05e021ac..9997ec82 100644 --- a/mes-ui/mes-ui-admin-vue3/src/views/heli/plan/printDialog.vue +++ b/mes-ui/mes-ui-admin-vue3/src/views/heli/plan/printDialog.vue @@ -31,9 +31,9 @@ const endPageNum = ref(0); const printref = ref() const onPrint = () => { printref.value.open(cnenList.value) - + } - + function beforeDialogClose(doClose: (shouldClose: boolean) => void): void { outopen() } @@ -60,7 +60,7 @@ const open = async ( vals) => { console.log(vals) datavals.value = [] printCodeName.value = [] - + vals.forEach((item) => { const row1 = { @@ -76,25 +76,25 @@ const open = async ( vals) => { const formattedDate = `${currentDate.getFullYear()}-${String(currentDate.getMonth() + 1).padStart(2, '0')}-${String(currentDate.getDate()).padStart(2, '0')} ${String(currentDate.getHours()).padStart(2, '0')}:${String(currentDate.getMinutes()).padStart(2, '0')}:${String(currentDate.getSeconds()).padStart(2, '0')}` var i = 0; await Promise.all( - + printCodeName.value.map(async (item) => { const qrCodeData = await QRCode.toDataURL(item.name,{ - errorCorrectionLevel: 'H' + errorCorrectionLevel: 'H' }) const qrCodeElement = document.getElementById('qrCodeContainer') if (qrCodeElement) { (qrCodeElement.innerHTML += - `
+ `
- ${item.code} + ${item.code}
- 名称: - ${item.name} + 名 称: + ${item.name}
- 数量: ${item.amount} + 数 量:${item.amount} ${formattedDate}
@@ -103,9 +103,9 @@ const open = async ( vals) => {
`) if(printCodeName.value.length > 1 && i < printCodeName.value.length - 1){ - qrCodeElement.innerHTML += + qrCodeElement.innerHTML += `
- +
` } } @@ -123,11 +123,11 @@ defineExpose({ open }) min-height: 60mm; margin: auto; box-shadow: 0 0 5px rgba(0, 0, 0, 0.1); - background-color: black; - color: white; + background-color: white; + color: black; padding: 2mm; box-sizing: border-box; - + /* 临时隐藏下划线,打印时会显示 */ .code-line span, .name-underline { display: none; @@ -137,9 +137,9 @@ defineExpose({ open }) /* 确保打印样式优先 */ @media print { .page { - background-color: black !important; - color: white !important; - + background-color: white !important; + color: black !important; + .code-line span, .name-underline { display: inline-block; } diff --git a/mes-ui/mes-ui-admin-vue3/src/views/heli/plan/printFinalDialog.vue b/mes-ui/mes-ui-admin-vue3/src/views/heli/plan/printFinalDialog.vue index 67c6f2d9..c93f7cf1 100644 --- a/mes-ui/mes-ui-admin-vue3/src/views/heli/plan/printFinalDialog.vue +++ b/mes-ui/mes-ui-admin-vue3/src/views/heli/plan/printFinalDialog.vue @@ -31,14 +31,14 @@ const endPageNum = ref(0); const onPrint = () => { const printNode = document.querySelector('.print-wrap1') if (!printNode) return - + const newIframe: any = document.createElement('iframe') newIframe.setAttribute( 'style', 'width:0px;height:0px;position:absolute;left:-9999px;top:-9999px;' ) document.body.appendChild(newIframe) - + const doc = newIframe.contentWindow.document // 添加基础样式 doc.write(` @@ -47,38 +47,46 @@ const onPrint = () => { @@ -167,7 +176,7 @@ const open = async ( vals) => { console.log(vals) datavals.value = [] printCodeName.value = [] - + vals.forEach((item) => { const row1 = { @@ -185,7 +194,7 @@ const open = async ( vals) => { await Promise.all( printCodeName.value.map(async (item) => { const qrCodeData = await QRCode.toDataURL(item.name,{ - errorCorrectionLevel: 'H' + errorCorrectionLevel: 'H' }) const qrCodeElement = document.getElementById('qrCodeContainer1') if (qrCodeElement) { @@ -195,12 +204,12 @@ const open = async ( vals) => { ${item.code}
- 名称: + 名 称: ${item.name}
- 数量: ${item.amount} + 数 量:${item.amount} ${formattedDate}
@@ -221,15 +230,15 @@ defineExpose({ open }) \ No newline at end of file + diff --git a/mes-ui/mes-ui-admin-vue3/src/views/heli/processdesign/printDialog.vue b/mes-ui/mes-ui-admin-vue3/src/views/heli/processdesign/printDialog.vue index 562da8c8..f10a73aa 100644 --- a/mes-ui/mes-ui-admin-vue3/src/views/heli/processdesign/printDialog.vue +++ b/mes-ui/mes-ui-admin-vue3/src/views/heli/processdesign/printDialog.vue @@ -108,15 +108,15 @@ const open = async (bomCode, vals) => { (qrCodeElement.innerHTML += `
- ${item.code} + ${item.code}
- 名称: + 名 称: ${item.name}
- 数量: ${item.amount} + 数 量:${item.amount} ${formattedDate}
diff --git a/mes-ui/mes-ui-admin-vue3/src/views/heli/processdesign/printFinalDialog.vue b/mes-ui/mes-ui-admin-vue3/src/views/heli/processdesign/printFinalDialog.vue index c3d87750..497767be 100644 --- a/mes-ui/mes-ui-admin-vue3/src/views/heli/processdesign/printFinalDialog.vue +++ b/mes-ui/mes-ui-admin-vue3/src/views/heli/processdesign/printFinalDialog.vue @@ -27,20 +27,15 @@ const dialogVisible = ref(false) let clauseId = null; const startPageNum = ref(0); const endPageNum = ref(0); - const onPrint = () => { - const printNode = document.querySelector('.print-wrap1') - if (!printNode) return + const printNode = document.querySelector('.print-wrap1'); + if (!printNode) return; - const newIframe: any = document.createElement('iframe') - newIframe.setAttribute( - 'style', - 'width:0px;height:0px;position:absolute;left:-9999px;top:-9999px;' - ) - document.body.appendChild(newIframe) + const newIframe: any = document.createElement('iframe'); + newIframe.setAttribute('style', 'width:0; height:0; position:absolute; left:-9999px; top:-9999px;'); + document.body.appendChild(newIframe); - const doc = newIframe.contentWindow.document - // 添加基础样式 + const doc = newIframe.contentWindow.document; doc.write(` @@ -51,10 +46,11 @@ const onPrint = () => { margin: 0; } body { + margin: 0; padding: 0; - background-color: white !important; - color: black !important; + background-color: white; + color: black; -webkit-print-color-adjust: exact; print-color-adjust: exact; } @@ -65,21 +61,27 @@ const onPrint = () => { box-sizing: border-box; font-family: monospace; position: relative; - background-color: white !important; - color: black !important; + background-color: white; + color: black; } - .code-line, .name-line { + .code-line { font-size: 14px; - margin-bottom: 1mm; - + margin-bottom: 1.4mm; + margin-left: 0.8mm; } .code-line span { display: inline-block; width: 100%; + + font-family: "SimHei", "Microsoft YaHei", "PingFang SC", sans-serif; border-bottom: 1px solid black; padding-bottom: 0.2mm; + font-weight: bold !important; /* 仅此处加粗 item.code */ + color: black; } .name-line { + font-size: 14px; + margin-bottom: 1mm; display: flex; align-items: center; } @@ -91,7 +93,7 @@ const onPrint = () => { flex-grow: 1; border-bottom: 1px solid black; height: 1em; - margin-left: 1mm; + margin-left: -1mm; } .bottom-section { display: flex; @@ -124,14 +126,15 @@ const onPrint = () => { .quantity { font-size: 14px; margin-bottom: 0.5mm; - margin-top:2mm; - white-space: nowrap; + margin-top: 2mm; + white-space: nowrap; } .timestamp { - font-size: 6px; + font-size: 10px; line-height: 1; + margin-left: 0.5mm; margin-top: auto; - white-space: nowrap; + white-space: nowrap; } @@ -139,16 +142,16 @@ const onPrint = () => { ${printNode.innerHTML} - `) - doc.close() - dialogVisible.value = false + `); + doc.close(); + setTimeout(() => { - newIframe.contentWindow.focus() - newIframe.contentWindow.print() - document.body.removeChild(newIframe) - dialogVisible.value = false - }, 100) -} + newIframe.contentWindow.focus(); + newIframe.contentWindow.print(); + document.body.removeChild(newIframe); + dialogVisible.value = false; + }, 100); +}; function beforeDialogClose(doClose: (shouldClose: boolean) => void): void { outopen() @@ -197,15 +200,15 @@ const open = async (bomCode, vals) => { (qrCodeElement.innerHTML += `
- ${item.code} + ${item.code}
- 名称: + 名 称: ${item.name}
- 数量: ${item.amount} + 数 量:${item.amount} ${formattedDate}
@@ -246,10 +249,10 @@ defineExpose({ open }) .page { background-color: white !important; color: black !important; - .code-line span, .name-underline { display: inline-block; } + } } diff --git a/mes-ui/mes-ui-admin-vue3/src/views/heli/storagelog/printDialog.vue b/mes-ui/mes-ui-admin-vue3/src/views/heli/storagelog/printDialog.vue index f8a06065..4d86fef9 100644 --- a/mes-ui/mes-ui-admin-vue3/src/views/heli/storagelog/printDialog.vue +++ b/mes-ui/mes-ui-admin-vue3/src/views/heli/storagelog/printDialog.vue @@ -31,9 +31,9 @@ const endPageNum = ref(0); const printref = ref() const onPrint = () => { printref.value.open(cnenList.value) - + } - + function beforeDialogClose(doClose: (shouldClose: boolean) => void): void { outopen() } @@ -57,7 +57,7 @@ const open = async (vals) => { cnenList.value = sortedVals; datavals.value = [] printCodeName.value = [] - + sortedVals.forEach((item) => { console.log(item.id) const row1 = { @@ -76,27 +76,52 @@ const open = async (vals) => { var i = 0; await Promise.all( printCodeName.value.map(async (item) => { - + const formattedDate = `物料编码:${item.code},规格:${item.spec},简称:${item.name},库区:${item.rg},库位:${item.pg}`; const qrCodeData = await QRCode.toDataURL(formattedDate ,{ - errorCorrectionLevel: 'H' + errorCorrectionLevel: 'H' }) const qrCodeElement = document.getElementById('qrCodeContainer') if (qrCodeElement) { (qrCodeElement.innerHTML += - `
+ `
- 物料编码:${item.code} + 物料编码:${item.code}
- 简称: - ${item.name} + 简 称: + ${item.name}
- 规格: ${item.spec} - 库区:${item.rg} - 库位:${item.pg} + 规 格:${item.spec} + 库 区:${item.rg} + 库 位:${item.pg}
QR Code @@ -104,9 +129,9 @@ const open = async (vals) => {
`) if(printCodeName.value.length > 1 && i < printCodeName.value.length - 1){ - qrCodeElement.innerHTML += + qrCodeElement.innerHTML += `
- +
` } } @@ -124,11 +149,11 @@ defineExpose({ open }) min-height: 60mm; margin: auto; box-shadow: 0 0 5px rgba(0, 0, 0, 0.1); - background-color: black; + background-color: white; color: white; padding: 2mm; box-sizing: border-box; - + /* 临时隐藏下划线,打印时会显示 */ .code-line span, .name-underline { display: none; @@ -140,10 +165,10 @@ defineExpose({ open }) .page { background-color: black !important; color: white !important; - + .code-line span, .name-underline { display: inline-block; } } } - \ No newline at end of file + diff --git a/mes-ui/mes-ui-admin-vue3/src/views/heli/storagelog/printFinalDialog.vue b/mes-ui/mes-ui-admin-vue3/src/views/heli/storagelog/printFinalDialog.vue index a219e75a..dc8153d7 100644 --- a/mes-ui/mes-ui-admin-vue3/src/views/heli/storagelog/printFinalDialog.vue +++ b/mes-ui/mes-ui-admin-vue3/src/views/heli/storagelog/printFinalDialog.vue @@ -31,14 +31,14 @@ const endPageNum = ref(0); const onPrint = () => { const printNode = document.querySelector('.print-wrap1') if (!printNode) return - + const newIframe: any = document.createElement('iframe') newIframe.setAttribute( 'style', 'width:0px;height:0px;position:absolute;left:-9999px;top:-9999px;' ) document.body.appendChild(newIframe) - + const doc = newIframe.contentWindow.document // 添加基础样式 doc.write(` @@ -46,39 +46,47 @@ const onPrint = () => { @@ -166,7 +191,7 @@ const open = async (vals) => { cnenList.value = vals; datavals.value = [] printCodeName.value = [] - + vals.forEach((item) => { console.log(item) const row1 = { @@ -185,7 +210,7 @@ const open = async (vals) => { printCodeName.value.map(async (item) => { const formattedDate = `物料编码:${item.code},规格:${item.spec},简称:${item.name},库区:${item.rg},库位:${item.pg}`; const qrCodeData = await QRCode.toDataURL(formattedDate ,{ - errorCorrectionLevel: 'H' + errorCorrectionLevel: 'H' }) const qrCodeElement = document.getElementById('qrCodeContainer1') if (qrCodeElement) { @@ -195,14 +220,14 @@ const open = async (vals) => { 物料编码:${item.code}
- 简称: + 简 称: ${item.name}
- 规格: ${item.spec} - 库区: ${item.rg} - 库位: ${item.pg} +规 格: ${item.spec} + 库 区: ${item.rg} + 库 位: ${item.pg}
QR Code @@ -230,7 +255,7 @@ defineExpose({ open }) color: white; padding: 2mm; box-sizing: border-box; - + /* 临时隐藏下划线,打印时会显示 */ .code-line span, .name-underline { display: none; @@ -242,10 +267,10 @@ defineExpose({ open }) .page { background-color: black !important; color: white !important; - + .code-line span, .name-underline { display: inline-block; } } } - \ No newline at end of file +