2025-06-20 00:45:21 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<Dialog
|
|
|
|
|
|
title="打印预览"
|
|
|
|
|
|
v-model="dialogVisible"
|
|
|
|
|
|
width="1000"
|
|
|
|
|
|
top="0%"
|
|
|
|
|
|
:before-close="(doClose) => beforeDialogClose(doClose)"
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-button @click="outopen" style="float: right;margin-right: 0.5%;">取消</el-button>
|
|
|
|
|
|
<el-button @click="onPrint" type="primary" style="float: right;margin-right: 1%;">打印</el-button>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 打印预览 -->
|
2025-07-07 23:04:40 +08:00
|
|
|
|
<div class="print-wrap page" ref="print">
|
|
|
|
|
|
<div id="qrCodeContainer"></div>
|
2025-06-20 00:45:21 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<template #footer>
|
|
|
|
|
|
<el-button @click="onPrint" type="primary">打印</el-button>
|
|
|
|
|
|
<el-button @click="outopen">取消</el-button>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</Dialog>
|
2025-07-07 23:04:40 +08:00
|
|
|
|
<printFinalDialog ref="printref" :minAmount="minAmount" :formData="formData" />
|
2025-06-20 00:45:21 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
2025-07-07 23:04:40 +08:00
|
|
|
|
import QRCode from 'qrcode'
|
2025-07-05 08:43:22 +08:00
|
|
|
|
import printFinalDialog from './printFinalDialog.vue';
|
2025-06-20 00:45:21 +08:00
|
|
|
|
const dialogVisible = ref(false)
|
|
|
|
|
|
let clauseId = null;
|
|
|
|
|
|
const startPageNum = ref(0);
|
|
|
|
|
|
const endPageNum = ref(0);
|
|
|
|
|
|
const printref = ref()
|
|
|
|
|
|
const onPrint = () => {
|
|
|
|
|
|
printref.value.open(cnenList.value)
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2025-07-07 23:04:40 +08:00
|
|
|
|
|
2025-06-20 00:45:21 +08:00
|
|
|
|
function beforeDialogClose(doClose: (shouldClose: boolean) => void): void {
|
|
|
|
|
|
outopen()
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const outopen = () => {
|
|
|
|
|
|
dialogVisible.value = false
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const printCodeName = ref([])
|
|
|
|
|
|
const datavals = ref([])
|
|
|
|
|
|
const cnenList = ref([])
|
2025-07-07 23:04:40 +08:00
|
|
|
|
const bomCodes = ref('')
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-06-20 00:45:21 +08:00
|
|
|
|
|
|
|
|
|
|
const open = async (vals) => {
|
2025-07-07 23:04:40 +08:00
|
|
|
|
const sortedVals = [...vals].sort((a, b) => {
|
|
|
|
|
|
return b.id - a.id;
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
cnenList.value = sortedVals;
|
2025-06-20 00:45:21 +08:00
|
|
|
|
datavals.value = []
|
|
|
|
|
|
printCodeName.value = []
|
|
|
|
|
|
|
2025-07-07 23:04:40 +08:00
|
|
|
|
sortedVals.forEach((item) => {
|
|
|
|
|
|
console.log(item.id)
|
2025-06-20 00:45:21 +08:00
|
|
|
|
const row1 = {
|
|
|
|
|
|
code: item.matCode,
|
|
|
|
|
|
name: item.matName == null ? '' : item.matName,
|
2025-07-07 23:04:40 +08:00
|
|
|
|
spec: item.matSpec == null ? '' : item.matSpec,
|
2025-06-20 00:45:21 +08:00
|
|
|
|
rg: item.rgName == null ? '' : item.rgName,
|
|
|
|
|
|
pg: item.pnName == null ? '' : item.pnName,
|
|
|
|
|
|
//amount: item.amount == null ? '' : item.amount
|
|
|
|
|
|
}
|
|
|
|
|
|
printCodeName.value.push(row1)
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
dialogVisible.value = true
|
2025-07-07 23:04:40 +08:00
|
|
|
|
|
2025-06-20 00:45:21 +08:00
|
|
|
|
var i = 0;
|
2025-07-07 23:04:40 +08:00
|
|
|
|
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'
|
|
|
|
|
|
})
|
|
|
|
|
|
const qrCodeElement = document.getElementById('qrCodeContainer')
|
|
|
|
|
|
if (qrCodeElement) {
|
|
|
|
|
|
(qrCodeElement.innerHTML +=
|
|
|
|
|
|
`<div style="width: 90mm; height: 60mm; padding: 2mm; box-sizing: border-box; font-family: monospace; position: relative; background-color: black; color: white;">
|
|
|
|
|
|
<div style="font-size: 11px; margin-bottom: 1mm;">
|
|
|
|
|
|
<span style="display: inline-block; width: 100%; border-bottom: 1px solid white; padding-bottom: 0.2mm;">物料编码:${item.code}</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div style="display: flex; align-items: center;">
|
|
|
|
|
|
<span style="white-space: nowrap; margin-right: 1mm;">简称:</span>
|
|
|
|
|
|
<span style="flex-grow: 1; border-bottom: 1px solid white; height: 2em; margin-left: 1mm;">${item.name}</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div style="display: flex; position: absolute; bottom: 2mm; left: 2mm; right: 2mm; height: 34mm;">
|
|
|
|
|
|
<div style="display: flex; flex-direction: column; justify-content: center; align-items: flex-start; width: 13mm; margin-right: 1mm;">
|
|
|
|
|
|
<span style="font-size: 11px; margin-bottom: 0.5mm; margin-top:2mm; white-space: nowrap;">规格: ${item.spec}</span>
|
|
|
|
|
|
<span style="font-size: 11px; margin-bottom: 0.5mm; margin-top:2mm; white-space: nowrap;">库区:${item.rg}</span>
|
|
|
|
|
|
<span style="font-size: 11px; margin-bottom: 0.5mm; margin-top:2mm; white-space: nowrap;">库位:${item.pg}</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div style="width: 34mm; height: 34mm; margin-left: auto; display: flex; align-items: flex-end; justify-content: flex-end;">
|
|
|
|
|
|
<img style="width: 100%; height: 100%;" src="${qrCodeData}" alt="QR Code">
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>`)
|
|
|
|
|
|
if(printCodeName.value.length > 1 && i < printCodeName.value.length - 1){
|
|
|
|
|
|
qrCodeElement.innerHTML +=
|
|
|
|
|
|
`<div style="height:3mm; background-color: white; color: white;width:103mm;margin-left:-3mm">
|
2025-06-20 00:45:21 +08:00
|
|
|
|
|
|
|
|
|
|
</div>`
|
2025-07-07 23:04:40 +08:00
|
|
|
|
}
|
2025-06-20 00:45:21 +08:00
|
|
|
|
}
|
2025-07-07 23:04:40 +08:00
|
|
|
|
})
|
|
|
|
|
|
)
|
2025-06-20 00:45:21 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
defineExpose({ open })
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
|
|
|
/* 预览样式 - 仅用于屏幕显示 */
|
|
|
|
|
|
.page {
|
2025-07-07 23:04:40 +08:00
|
|
|
|
width: 100mm;
|
|
|
|
|
|
min-height: 60mm;
|
2025-06-20 00:45:21 +08:00
|
|
|
|
margin: auto;
|
|
|
|
|
|
box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
|
|
|
|
|
|
background-color: black;
|
|
|
|
|
|
color: white;
|
|
|
|
|
|
padding: 2mm;
|
|
|
|
|
|
box-sizing: border-box;
|
|
|
|
|
|
|
|
|
|
|
|
/* 临时隐藏下划线,打印时会显示 */
|
2025-07-07 23:04:40 +08:00
|
|
|
|
.code-line span, .name-underline {
|
|
|
|
|
|
display: none;
|
2025-06-20 00:45:21 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* 确保打印样式优先 */
|
|
|
|
|
|
@media print {
|
|
|
|
|
|
.page {
|
|
|
|
|
|
background-color: black !important;
|
|
|
|
|
|
color: white !important;
|
|
|
|
|
|
|
2025-07-07 23:04:40 +08:00
|
|
|
|
.code-line span, .name-underline {
|
|
|
|
|
|
display: inline-block;
|
2025-06-20 00:45:21 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</style>
|