|
|
@ -1043,100 +1043,50 @@ export default { |
|
|
|
|
|
|
|
|
// 打印固定载具 |
|
|
// 打印固定载具 |
|
|
printCarrier(row) { |
|
|
printCarrier(row) { |
|
|
// 构造打印数据 |
|
|
|
|
|
const printData = { |
|
|
|
|
|
carrierNo: row.carrierNo, |
|
|
|
|
|
carrierTypeName: row.carrierTypeName, |
|
|
|
|
|
specification: row.specification, |
|
|
|
|
|
dimensions: row.dimensions, |
|
|
|
|
|
availableQty: row.availableQty || 0, |
|
|
|
|
|
site: this.scheduleData.site |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 调用打印功能 |
|
|
|
|
|
this.printCarrierLabel(printData) |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
const LODOP = getLodop() |
|
|
|
|
|
if (!LODOP) { |
|
|
|
|
|
this.$message.error('未检测到打印控件,请安装CLodop打印控件!') |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// 打印载具标签 |
|
|
|
|
|
printCarrierLabel(data) { |
|
|
|
|
|
try { |
|
|
try { |
|
|
// 生成二维码(使用 QRCode.js 或者使用在线二维码API) |
|
|
|
|
|
const qrCodeUrl = `https://api.qrserver.com/v1/create-qr-code/?size=120x120&data=${encodeURIComponent(data.carrierNo)}` |
|
|
|
|
|
|
|
|
|
|
|
// 打印HTML模板 |
|
|
|
|
|
const printContent = ` |
|
|
|
|
|
<div style="width: 100mm; font-family: Arial, sans-serif; padding: 10px; position: relative;"> |
|
|
|
|
|
<!-- 左上角二维码 --> |
|
|
|
|
|
<div style="position: absolute; top: 10px; left: 10px;"> |
|
|
|
|
|
<img src="${qrCodeUrl}" style="width: 80px; height: 80px; border: 1px solid #ddd;" alt="QR Code"/> |
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
// 初始化打印 |
|
|
|
|
|
LODOP.PRINT_INIT('固定载具标签打印') |
|
|
|
|
|
|
|
|
<!-- 标题 --> |
|
|
|
|
|
<div style="text-align: center; font-size: 20px; font-weight: bold; margin-bottom: 15px; padding-top: 5px;"> |
|
|
|
|
|
固定载具标签 |
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
// 设置纸张尺寸:70mm x 20mm |
|
|
|
|
|
LODOP.SET_PRINT_PAGESIZE(0, 700, 200, '') |
|
|
|
|
|
|
|
|
<!-- 信息表格 --> |
|
|
|
|
|
<table style="width: 100%; border-collapse: collapse; font-size: 14px; margin-top: 10px;"> |
|
|
|
|
|
<tr> |
|
|
|
|
|
<td style="padding: 8px; border: 1px solid #333; font-weight: bold; width: 35%; background-color: #f5f5f5;">标签条码:</td> |
|
|
|
|
|
<td style="padding: 8px; border: 1px solid #333; font-size: 15px; font-weight: bold;">${data.carrierNo || ''}</td> |
|
|
|
|
|
</tr> |
|
|
|
|
|
<tr> |
|
|
|
|
|
<td style="padding: 8px; border: 1px solid #333; font-weight: bold; background-color: #f5f5f5;">载具类型:</td> |
|
|
|
|
|
<td style="padding: 8px; border: 1px solid #333;">${data.carrierTypeName || ''}</td> |
|
|
|
|
|
</tr> |
|
|
|
|
|
<tr> |
|
|
|
|
|
<td style="padding: 8px; border: 1px solid #333; font-weight: bold; background-color: #f5f5f5;">规格描述:</td> |
|
|
|
|
|
<td style="padding: 8px; border: 1px solid #333;">${data.specification || ''}</td> |
|
|
|
|
|
</tr> |
|
|
|
|
|
<tr> |
|
|
|
|
|
<td style="padding: 8px; border: 1px solid #333; font-weight: bold; background-color: #f5f5f5;">尺寸:</td> |
|
|
|
|
|
<td style="padding: 8px; border: 1px solid #333;">${data.dimensions || ''}</td> |
|
|
|
|
|
</tr> |
|
|
|
|
|
<tr> |
|
|
|
|
|
<td style="padding: 8px; border: 1px solid #333; font-weight: bold; background-color: #f5f5f5;">可用数量:</td> |
|
|
|
|
|
<td style="padding: 8px; border: 1px solid #333; font-size: 18px; font-weight: bold; color: #e74c3c;">${data.availableQty}</td> |
|
|
|
|
|
</tr> |
|
|
|
|
|
</table> |
|
|
|
|
|
|
|
|
|
|
|
<!-- 打印时间 --> |
|
|
|
|
|
<div style="text-align: center; margin-top: 15px; font-size: 11px; color: #999; border-top: 1px dashed #ccc; padding-top: 10px;"> |
|
|
|
|
|
打印时间: ${this.dayjs(new Date()).format('YYYY-MM-DD HH:mm:ss')} |
|
|
|
|
|
</div> |
|
|
|
|
|
</div> |
|
|
|
|
|
` |
|
|
|
|
|
|
|
|
|
|
|
// 创建打印窗口 |
|
|
|
|
|
const printWindow = window.open('', '_blank') |
|
|
|
|
|
printWindow.document.write(` |
|
|
|
|
|
<html> |
|
|
|
|
|
<head> |
|
|
|
|
|
<title>打印固定载具标签</title> |
|
|
|
|
|
<meta charset="UTF-8"> |
|
|
|
|
|
<style> |
|
|
|
|
|
@page { size: auto; margin: 5mm; } |
|
|
|
|
|
body { margin: 0; padding: 0; } |
|
|
|
|
|
@media print { |
|
|
|
|
|
body { -webkit-print-color-adjust: exact; print-color-adjust: exact; } |
|
|
|
|
|
} |
|
|
|
|
|
</style> |
|
|
|
|
|
</head> |
|
|
|
|
|
<body> |
|
|
|
|
|
${printContent} |
|
|
|
|
|
</body> |
|
|
|
|
|
</html> |
|
|
|
|
|
`) |
|
|
|
|
|
printWindow.document.close() |
|
|
|
|
|
|
|
|
|
|
|
// 延迟打印,确保二维码图片加载完成 |
|
|
|
|
|
setTimeout(() => { |
|
|
|
|
|
printWindow.print() |
|
|
|
|
|
printWindow.close() |
|
|
|
|
|
}, 500) |
|
|
|
|
|
|
|
|
// 绘制外边框 |
|
|
|
|
|
LODOP.ADD_PRINT_RECT('1mm', '1mm', '68mm', '18mm', 0, 1) |
|
|
|
|
|
|
|
|
|
|
|
// 绘制中间竖线(左右分隔) |
|
|
|
|
|
LODOP.ADD_PRINT_LINE('1mm', '50mm', '19mm', '50mm', 0, 1) |
|
|
|
|
|
|
|
|
|
|
|
// 绘制左侧横线(标签条码和可用数量之间的分隔) |
|
|
|
|
|
LODOP.ADD_PRINT_LINE('10mm', '1mm', '10mm', '50mm', 0, 1) |
|
|
|
|
|
|
|
|
|
|
|
// 左侧文字信息 - 标签条码 |
|
|
|
|
|
const text1 = LODOP.ADD_PRINT_TEXT('4.5mm', '2mm', '46mm', '5mm', '标签条码: ' + (row.carrierNo || '')) |
|
|
|
|
|
LODOP.SET_PRINT_STYLEA(text1, "FontName", "Microsoft YaHei") |
|
|
|
|
|
LODOP.SET_PRINT_STYLEA(text1, "FontSize", 8) |
|
|
|
|
|
LODOP.SET_PRINT_STYLEA(text1, "Bold", 1) |
|
|
|
|
|
|
|
|
|
|
|
// 左侧文字信息 - 可用数量 |
|
|
|
|
|
const text2 = LODOP.ADD_PRINT_TEXT('13.5mm', '2mm', '46mm', '5mm', '可用数量: ' + (row.availableQty || 0)) |
|
|
|
|
|
LODOP.SET_PRINT_STYLEA(text2, "FontName", "Microsoft YaHei") |
|
|
|
|
|
LODOP.SET_PRINT_STYLEA(text2, "FontSize", 8) |
|
|
|
|
|
LODOP.SET_PRINT_STYLEA(text2, "Bold", 1) |
|
|
|
|
|
|
|
|
|
|
|
// 右侧二维码(使用 LODOP 原生二维码) |
|
|
|
|
|
const qrIndex = LODOP.ADD_PRINT_BARCODE('1.5mm', '51mm', '19mm', '19mm', 'QRCode', row.carrierNo || '') |
|
|
|
|
|
LODOP.SET_PRINT_STYLEA(qrIndex, "QRCodeVersion", 4) |
|
|
|
|
|
LODOP.SET_PRINT_STYLEA(qrIndex, "QRCodeErrorLevel", "M") |
|
|
|
|
|
|
|
|
|
|
|
// 执行打印 |
|
|
|
|
|
LODOP.PRINT() |
|
|
|
|
|
|
|
|
this.$message.success('正在打印载具标签...') |
|
|
|
|
|
} catch (error) { |
|
|
} catch (error) { |
|
|
|
|
|
console.error('打印失败:', error) |
|
|
this.$message.error('打印失败: ' + error.message) |
|
|
this.$message.error('打印失败: ' + error.message) |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
|