小票全部采用本地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

@@ -0,0 +1,30 @@
import getLodop from "./LodopFuncs.js";
/**
* 打印订单发票
*/
export default (data) => {
let LODOP = getLodop();
LODOP.PRINT_INIT("打印小票");
// 设置打印纸大小D
LODOP.SET_PRINT_PAGESIZE(3, "58mm", 20, "");
// 二维码控制大小;
LODOP.ADD_PRINT_BARCODE("", "40px", "150px", "150px", "QRCode", data.url);
//设置默认打印机(这里用的是打印机名称)
LODOP.SET_PRINTER_INDEX(data.deviceName);
// 文字内容
let html = `
<div style="padding-left: 20px;">
<div style="height: 100px;"></div>
<div style="width: 100%;font-size: 16px;display:flex;justify-content:center;">
请使用微信扫码下载发票二维码有效期30天超过自动失效
</div>
<div style="height: 50px;"></div>
</div>
`;
setTimeout(() => {
LODOP.ADD_PRINT_HTM("9mm", "0mm", "RightMargin:0mm", 20, html);
LODOP.SET_LICENSES("", "DCFF409304DFCEB3E2C644BF96CD0720", "", "");
LODOP.PRINT();
}, 800);
};

View File

@@ -0,0 +1,165 @@
import getLodop from "./LodopFuncs.js";
/**
* 打印交班小票
*/
export default (data) => {
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="margin-top: 30px;font-size: 12px;">
当班时间:${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:50%;">商品</td>
<td style="font-size: 12px;width:25%;">数量</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:50%;">
<div>${item.productName}</div>
</td>
<td style="font-size: 12px;width:25%;">${item.num}</td>
<td style="font-size: 12px;width:25%;">
${item.amount}
</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="font-size: 12px;">
<span>上交金额:</span>
<span>${data.handIn}</span>
</div>
<div style="margin-top: 20px; font-size: 12px;">
<span>总订单数:</span>
<span>${data.orderNum}</span>
</div>
<div style="padding-bottom: 50px;font-size: 12px;">
打印时间:${data.printTime}
</div>
<div style="height: 50px;"></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);
};

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>

View File

@@ -8,7 +8,7 @@
{{ store.userInfo.shopName }}
</div>
<div class="drawerbox_bo_top_left_tow" style="margin-top: 10px">
收银员{{ store.userInfo.loginName }}
收银员{{ store.userInfo.loginAccount }}
</div>
<div>
<span style="color: #666">{{ dayjs(store.userInfo.loginTime).format('YYYY-MM-DD HH:mm:ss') }}</span>
@@ -32,13 +32,21 @@
<div class="drawerbox_bo_box">
<div style="padding: 10px; color: #999; font-weight: bold">系统</div>
<div class="drawerbox_bo_box_itemb_felx">
<div class="drawerbox_bo_box_itembox">
<!-- <div class="drawerbox_bo_box_itembox">
<div class="drawerbox_bo_box_icon">
<el-icon size="40">
<Setting />
</el-icon>
</div>
<div class="drawerbox_bo_box_icontext">设置</div>
</div> -->
<div class="drawerbox_bo_box_itembox" @click="router.push({ name: 'device_list' })">
<div class="drawerbox_bo_box_icon">
<el-icon size="40">
<TurnOff />
</el-icon>
</div>
<div class="drawerbox_bo_box_icontext">设备管理</div>
</div>
<div class="drawerbox_bo_box_itembox" @click="openCallHandle">
<div class="drawerbox_bo_box_icon">
@@ -48,18 +56,10 @@
</div>
<div class="drawerbox_bo_box_icontext">叫号</div>
</div>
<div class="drawerbox_bo_box_itembox" @click="router.push({ name: 'device_list' })">
<div class="drawerbox_bo_box_icon">
<el-icon size="40">
<TurnOff />
</el-icon>
</div>
<div class="drawerbox_bo_box_icontext">设备管理</div>
</div>
<div class="drawerbox_bo_box_itembox" @click="screenref.shows()">
<div class="drawerbox_bo_box_icon">
<el-icon size="40">
<Switch />
<Lock />
</el-icon>
</div>
<div class="drawerbox_bo_box_icontext">锁屏</div>