105 lines
3.5 KiB
JavaScript
105 lines
3.5 KiB
JavaScript
import getLodop from "./LodopFuncs.js";
|
|
/**
|
|
* 打印订单小票
|
|
*/
|
|
export default (data) => {
|
|
console.log(data);
|
|
console.log("data.deviceName===", data.deviceName);
|
|
let LODOP = getLodop();
|
|
LODOP.PRINT_INIT("打印小票");
|
|
// 设置打印纸大小D
|
|
LODOP.SET_PRINT_PAGESIZE(3, "58mm", 20, "");
|
|
//设置默认打印机(这里用的是打印机名称)
|
|
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.isBefore ? "预" : ""}结算单【${
|
|
data.orderInfo.masterId ? data.orderInfo.masterId : ""
|
|
}】
|
|
</div>
|
|
<div style="font-size: 16px;display: flex; justify-content:center;margin-top:20px;">
|
|
${data.orderInfo.outNumber ? data.orderInfo.outNumber : ""}
|
|
</div>
|
|
<div style="margin-top: 30px;font-size: 12px;">
|
|
订单号:${data.orderInfo && data.orderInfo.orderNo}
|
|
</div>
|
|
<div style="margin-top: 4px;font-size: 12px;">
|
|
交易时间:${data.createdAt}
|
|
</div>
|
|
<div style="margin-top: 4px;font-size: 12px;">
|
|
收银员:${data.loginAccount}
|
|
</div>
|
|
<div style="margin-top: 6px;margin-bottom: 6px;width: 100%">
|
|
<hr/>
|
|
</div>
|
|
<table class="table" style="width: 100%;">
|
|
<tr>
|
|
<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>
|
|
`;
|
|
|
|
let table = "";
|
|
for (let item of data.carts) {
|
|
table += `
|
|
<tr>
|
|
<td style="font-size: 12px;width:${t1}%;">
|
|
<div>${item.name}</div>
|
|
${
|
|
item.skuName
|
|
? `<div class="sku">规格:${item.skuName}</div>`
|
|
: ""
|
|
}
|
|
</td>
|
|
<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>
|
|
`;
|
|
}
|
|
|
|
let str = `
|
|
</table>
|
|
<div style="margin-top: 6px;margin-bottom: 6px;width: 100%">
|
|
<hr/>
|
|
</div>
|
|
<div style="margin-top: 6px; font-size: 22px;display:flex;justify-content: space-between;">
|
|
<span>应收</span>
|
|
<span>¥${data.amount}</span>
|
|
</div>
|
|
<div style="margin-top: 4px; font-size: 12px;">
|
|
<span>余额:</span>
|
|
<span>0.00</span>
|
|
</div>
|
|
<div style="margin-top: 6px;margin-bottom: 6px;width: 100%">
|
|
<hr/>
|
|
</div>
|
|
<div style="margin-top: 4px; font-size: 16px;font-weight: bold;">备注:${data.remark}</div>
|
|
<div style="margin-top: 4px; font-size: 12px;">
|
|
打印时间:${data.printTime}
|
|
</div>
|
|
<div>.</div>
|
|
<div>.</div>
|
|
<div>.</div>
|
|
<div>.</div>
|
|
`;
|
|
|
|
let lastHtml = `${html}${table}${str}`;
|
|
|
|
setTimeout(() => {
|
|
LODOP.ADD_PRINT_HTM("9mm", "0mm", "RightMargin:0mm", 20, lastHtml);
|
|
LODOP.SET_LICENSES("", "DCFF409304DFCEB3E2C644BF96CD0720", "", "");
|
|
LODOP.PRINT();
|
|
}, 800);
|
|
};
|