Files
cashierdesktop/src/components/lodop/lodopPrintWork.js
2024-07-31 18:14:23 +08:00

162 lines
4.7 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import getLodop from "./LodopFuncs.js";
/**
* 打印交班小票
*/
export default (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 html = `
<div style="font-size: 30px;display:flex;justify-content:center;">
${data.merchantName}
</div>
<div style="font-size: 16px;display: flex; justify-content:center;margin-top:6px;">
交班小票
</div>
<div style="font-size: 12px;margin-top:50px;">
当班时间:${data.startTime}
</div>
<div style="font-size: 12px;">
交班时间:${data.endTime}
</div>
<div style="font-size: 12px;">
收银员:${data.staff}
</div>
<div style="font-size: 12px;margin-top: 4px;">
当班收入:${data.totalAmount}
</div>
`;
let payInfos = "";
if (data.payInfos && data.payInfos.length) {
for (let item of data.payInfos) {
payInfos += `
<div style="font-size: 12px;padding-left:20px;">
${item.payType}${item.amount}
</div>
`;
}
}
let memberTitle = `
<div style="font-size: 12px;margin-top: 4px;">
会员数据
</div>
`;
let memberData = "";
if (data.memberData && data.memberData.length) {
for (let item of data.memberData) {
memberData += `
<div style="font-size: 12px;padding-left:20px;">
${item.deposit}${item.amount}
</div>
`;
}
}
let productCategoriesTabHead = `
<div style="font-size: 12px;margin-top: 4px;">分类数据</div>
<table class="table" style="width: 100%;">
<tr>
<td style="font-size: 12px;width:50%;">名称</td>
<td style="font-size: 12px;width:25%;">数量</td>
<td style="font-size: 12px;width:25%;">总计</td>
</tr>
`;
let productCategoriesTableBody = "";
if (data.productCategories && data.productCategories.length) {
for (let item of data.productCategories) {
productCategoriesTableBody += `
<tr>
<td style="font-size: 12px;width:50%;">
<div>${item.categoryName}</div>
</td>
<td style="font-size: 12px;width:25%;">${item.num}</td>
<td style="font-size: 12px;width:25%;">
${item.amount}
</td>
</tr>
`;
}
}
let tabHead = `
</table>
<div style="font-size: 12px;margin-top: 4px;">商品数据</div>
<table class="table" style="width: 100%;">
<tr>
<td style="font-size: 12px;width:75%;">商品</td>
<td style="font-size: 12px;width:25%;">数量</td>
</tr>
`;
let tableBody = "";
if (data.productInfos && data.productInfos.length) {
for (let item of data.productInfos) {
tableBody += `
<tr>
<td style="font-size: 12px;width:75%;">
<div>${item.productName}</div>
</td>
<td style="font-size: 12px;width:25%;">${item.num}</td>
</tr>
`;
}
}
if (!data.printShop) {
tabHead = "";
tableBody = "";
}
let str = `
</table>
<div style="font-size: 12px;margin-top: 4px;">
<span>快捷收款金额:</span>
<span>${data.quickAmount}</span>
</div>
<div style="font-size: 12px;">
<span>退款金额:</span>
<span>${data.returnAmount}</span>
</div>
<div style="font-size: 12px;">
<span>总收入:</span>
<span>${data.totalAmount}</span>
</div>
<div style="font-size: 12px;">
<span>备用金:</span>
<span>${data.imprest}</span>
</div>
<div style="font-size: 12px;">
<span>应交金额:</span>
<span>${data.payable}</span>
</div>
<div style="margin-top: 20px; font-size: 12px;">
<span>总订单数:</span>
<span>${data.orderNum}</span>
</div>
<div style="font-size: 12px;">
打印时间:${data.printTime}
</div>
<div>.</div>
<div>.</div>
<div>.</div>
<div>.</div>
`;
let lastHtml = `${html}${payInfos}${memberTitle}${memberData}${productCategoriesTabHead}${productCategoriesTableBody}${tabHead}${tableBody}${str}`;
setTimeout(() => {
LODOP.ADD_PRINT_HTM("9mm", "0mm", "RightMargin:0mm", 20, lastHtml);
LODOP.SET_LICENSES("", "DCFF409304DFCEB3E2C644BF96CD0720", "", "");
LODOP.PRINT();
}, 800);
};