wmswms白胚原材料采购打印修改,加条码

master
mengjiao 8 months ago
parent 78d11947aa
commit 96125dbc84

@ -176,7 +176,7 @@
<script> <script>
import { listBpprocure, getBpprocure, delBpprocure, addBpprocure, updateBpprocure } from "@/api/wms/bpprocure"; import { listBpprocure, getBpprocure, delBpprocure, addBpprocure, updateBpprocure } from "@/api/wms/bpprocure";
import JsBarcode from 'jsbarcode';
export default { export default {
name: "Bpprocure", name: "Bpprocure",
dicts: ['bp_raw'], dicts: ['bp_raw'],
@ -315,6 +315,7 @@ export default {
} }
}); });
}, },
handlePrint() { handlePrint() {
// //
const selectedData = this.bpprocureList.filter(item => this.ids.includes(item.id)); const selectedData = this.bpprocureList.filter(item => this.ids.includes(item.id));
@ -326,7 +327,6 @@ export default {
// //
this.printData = { this.printData = {
printDate: new Date().toLocaleString(), printDate: new Date().toLocaleString(),
workTable: selectedData.map(item => ({ workTable: selectedData.map(item => ({
procureCode: item.procureCode, procureCode: item.procureCode,
materialCode: item.materialCode, materialCode: item.materialCode,
@ -337,25 +337,55 @@ export default {
realityNumber: item.realityNumber || '', realityNumber: item.realityNumber || '',
})) }))
}; };
//
const barcodeCanvas = document.createElement('canvas');
console.log(" this.printData.workTable[0].procureCode: " + this.printData.workTable[0].procureCode);
JsBarcode(barcodeCanvas, this.printData.workTable[0].procureCode, {
format: "CODE128",
height: 35,
width: 1.5,
displayValue: true,
// background: "#FFFFFF", //
// lineColor: "#000000" //
});
// Data URL
const barcodeDataUrl = barcodeCanvas.toDataURL();
console.log(barcodeDataUrl); // Data URL
// //
let printContent = ` let printContent = `
<html>
<head>
<style>
body { font-family: Arial, sans-serif; }
table { width: 100%; border-collapse: collapse; }
th, td { border: 1px solid #000; text-align: center; padding: 8px; }
</style>
</head>
<body>
<div style="text-align: center;"> <div style="text-align: center;">
<h3>采购单</h3> <h3>采购单</h3>
<div style="float: right; margin-top: -50px; width: 200px; height: 100px;">
<img src="${barcodeDataUrl}" alt="条形码" />
</div>
</div> </div>
<div style="display: flex; justify-content: space-between; padding: 10px;"> <div style="display: flex; justify-content: space-between; padding: 10px;">
<div>打印日期: ${this.printData.printDate}</div> <div>打印日期: ${this.printData.printDate}</div>
</div> </div>
<table border="1" style="width: 100%; border-collapse: collapse;margin: 0 auto;"> <table>
<thead> <thead>
<tr> <tr>
<th style="text-align: center;">采购单</th> <th>采购单</th>
<th style="text-align: center;">物料编码</th> <th>物料编码</th>
<th style="text-align: center;">物料描述</th> <th>物料描述</th>
<th style="text-align: center;">供应商</th> <th>供应商</th>
<th style="text-align: center;">单位</th> <th>单位</th>
<th style="text-align: center;">计划数量</th> <th>计划数量</th>
<th style="text-align: center;">已入库数量</th> <th>已入库数量</th>
</tr> </tr>
</thead> </thead>
<tbody>`; <tbody>`;
@ -363,30 +393,30 @@ export default {
this.printData.workTable.forEach(item => { this.printData.workTable.forEach(item => {
printContent += ` printContent += `
<tr> <tr>
<td style="text-align: center;">${item.procureCode}</td> <td>${item.procureCode}</td>
<td style="text-align: center;">${item.materialCode}</td> <td>${item.materialCode}</td>
<td style="text-align: center;">${item.materialDesc}</td> <td>${item.materialDesc}</td>
<td style="text-align: center;">${item.supplyName}</td> <td>${item.supplyName}</td>
<td style="text-align: center;">${item.unit}</td> <td>${item.unit}</td>
<td style="text-align: center;">${item.planNumber}</td> <td>${item.planNumber}</td>
<td style="text-align: center;">${item.realityNumber}</td> <td>${item.realityNumber}</td>
</tr>`; </tr>`;
}); });
printContent += ` printContent += `
</tbody> </tbody>
</table> </table>
</body>
`; </html>`;
const printWindow = window.open('', '_blank'); const printWindow = window.open('', '_blank');
printWindow.document.write('<html><head><title>打印</title></head><body>');
printWindow.document.write(printContent); printWindow.document.write(printContent);
printWindow.document.write('</body></html>');
printWindow.document.close(); printWindow.document.close();
printWindow.print(); printWindow.print();
printWindow.close(); printWindow.close();
}, },
// handleQuery, resetQuery, etc. // handleQuery, resetQuery, etc.

Loading…
Cancel
Save