小票全部采用本地usb打印

This commit is contained in:
gyq
2024-07-30 18:04:53 +08:00
parent b2e450fd52
commit 49cabfed21
13 changed files with 459 additions and 291 deletions

View File

@@ -1,5 +1,7 @@
import getLodop from "./LodopFuncs.js";
/**
* 打印订单小票
*/
export default (data) => {
let LODOP = getLodop();
LODOP.PRINT_INIT("打印小票");
@@ -8,12 +10,14 @@ export default (data) => {
//设置默认打印机(这里用的是打印机名称)
LODOP.SET_PRINTER_INDEX(data.deviceName);
// 文字内容
let t1 = 40;
let t2 = (100 - t1) / 3;
let html = `
<div style="font-size: 30px;display:flex;justify-content:center;">
${data.shop_name}
</div>
<div style="font-size: 16px;display: flex; justify-content:center;margin-top:6px;">
结算单【${data.orderInfo.masterId ? data.orderInfo.masterId : ""}
结算单【${data.orderInfo.masterId ? data.orderInfo.masterId : ""}
</div>
<div style="font-size: 16px;display: flex; justify-content:center;margin-top:6px;">
${data.orderInfo.outNumber ? data.orderInfo.outNumber : ""}
@@ -28,12 +32,12 @@ export default (data) => {
收银员:${data.loginAccount}
</div>
<div style="margin-top: 6px;margin-bottom: 6px;border-bottom:1px dashed #000;"></div>
<table class="table">
<table class="table" style="width: 100%;">
<tr>
<td style="font-size: 12px;width:50%;">品名</td>
<td style="font-size: 12px;width:16.66%;">单价</td>
<td style="font-size: 12px;width:16.66%;">数量</td>
<td style="font-size: 12px;width:16.66%;">小计</td>
<td style="font-size: 12px;width:${t1}%;">品名</td>
<td style="font-size: 12px;width:${t2}%;">单价</td>
<td style="font-size: 12px;width:${t2}%;">数量</td>
<td style="font-size: 12px;width:${t2}%;">小计</td>
</tr>
`;
@@ -41,13 +45,13 @@ export default (data) => {
for (let item of data.carts) {
table += `
<tr>
<td style="font-size: 12px;width:50%;">
<td style="font-size: 12px;width:${t1}%;">
<div>${item.name}</div>
<div class="sku">规格:${item.skuName || ""}</div>
</td>
<td style="font-size: 12px;width:16.66%;">${item.salePrice}</td>
<td style="font-size: 12px;width:16.66%;">${item.number}</td>
<td style="font-size: 12px;width:16.66%;">
<td style="font-size: 12px;width:${t2}%;">${item.salePrice}</td>
<td style="font-size: 12px;width:${t2}%;">${item.number}</td>
<td style="font-size: 12px;width:${t2}%;">
${item.totalAmount}
</td>
</tr>