小票全部采用本地usb打印
This commit is contained in:
parent
b2e450fd52
commit
49cabfed21
|
|
@ -3,10 +3,10 @@ ENV = development
|
|||
|
||||
|
||||
# 正式ws
|
||||
# VITE_API_WSS = 'wss://cashier.sxczgkj.cn/client'
|
||||
VITE_API_WSS = 'wss://cashier.sxczgkj.cn/client'
|
||||
|
||||
#测试ws
|
||||
VITE_API_WSS = 'wss://wxcashiertest.sxczgkj.cn/client'
|
||||
# VITE_API_WSS = 'wss://wxcashiertest.sxczgkj.cn/client'
|
||||
|
||||
# 阿伟本地ws
|
||||
# VITE_API_WSS = 'ws://192.168.2.17:9998/client'
|
||||
|
|
@ -27,7 +27,7 @@ VITE_API_KP_URL = 'https://invoice.sxczgkj.cn/api'
|
|||
# VITE_API_URL = 'http://192.168.1.106:10589/cashier-client'
|
||||
|
||||
# 测试
|
||||
VITE_API_URL = 'https://cashier-client.sxczgkj.cn/cashier-client'
|
||||
# VITE_API_URL = 'https://cashier-client.sxczgkj.cn/cashier-client'
|
||||
|
||||
# 正式
|
||||
# VITE_API_URL = 'https://cashierclient.sxczgkj.cn/cashier-client'
|
||||
VITE_API_URL = 'https://cashierclient.sxczgkj.cn/cashier-client'
|
||||
|
|
@ -48,92 +48,6 @@ electron.app.whenReady().then(() => {
|
|||
}
|
||||
win.webContents.send("getOSmacRes", mac);
|
||||
});
|
||||
const printWin = new electron.BrowserWindow({
|
||||
show: false,
|
||||
width: 464,
|
||||
height: 1726,
|
||||
webPreferences: {
|
||||
// 集成网页和 Node.js,也就是在渲染进程中,可以调用 Node.js 方法
|
||||
nodeIntegration: true,
|
||||
contextIsolation: false
|
||||
}
|
||||
});
|
||||
if (process.env.VITE_DEV_SERVER_URL) {
|
||||
printWin.loadFile(path.join(__dirname, "../public/print.html"));
|
||||
} else {
|
||||
printWin.loadFile(path.resolve(__dirname, "../dist/print.html"));
|
||||
}
|
||||
electron.ipcMain.on("printerInfoSync", (event, arg) => {
|
||||
printWin.webContents.send("getParams", arg);
|
||||
});
|
||||
electron.ipcMain.on("printStart", (event, arg) => {
|
||||
console.log(arg);
|
||||
const _parmas = JSON.parse(arg);
|
||||
let name = _parmas.deviceName;
|
||||
printWin.webContents.print({
|
||||
silent: true,
|
||||
deviceName: name,
|
||||
pageSize: {
|
||||
width: 58e3,
|
||||
height: 216e3
|
||||
},
|
||||
scaleFactor: 80,
|
||||
landscape: false,
|
||||
margins: {
|
||||
marginType: "none",
|
||||
top: 0,
|
||||
bottom: 0,
|
||||
left: 0,
|
||||
right: 0
|
||||
},
|
||||
dpi: {
|
||||
horizontal: 203,
|
||||
vertical: 203
|
||||
}
|
||||
});
|
||||
});
|
||||
const workPrintWin = new electron.BrowserWindow({
|
||||
show: false,
|
||||
width: 464,
|
||||
height: 1726,
|
||||
webPreferences: {
|
||||
nodeIntegration: true,
|
||||
contextIsolation: false
|
||||
}
|
||||
});
|
||||
if (process.env.VITE_DEV_SERVER_URL) {
|
||||
workPrintWin.loadFile(path.join(__dirname, "../public/work_print.html"));
|
||||
} else {
|
||||
workPrintWin.loadFile(path.resolve(__dirname, "../dist/work_print.html"));
|
||||
}
|
||||
electron.ipcMain.on("printerWorkSync", (event, arg) => {
|
||||
workPrintWin.webContents.send("getParams", arg);
|
||||
});
|
||||
electron.ipcMain.on("printWorkStart", (event, arg) => {
|
||||
const _parmas = JSON.parse(arg);
|
||||
let name = _parmas.deviceName;
|
||||
workPrintWin.webContents.print({
|
||||
silent: true,
|
||||
deviceName: name,
|
||||
pageSize: {
|
||||
width: 58e3,
|
||||
height: 216e3
|
||||
},
|
||||
scaleFactor: 80,
|
||||
landscape: false,
|
||||
margins: {
|
||||
marginType: "none",
|
||||
top: 0,
|
||||
bottom: 0,
|
||||
left: 0,
|
||||
right: 0
|
||||
},
|
||||
dpi: {
|
||||
horizontal: 203,
|
||||
vertical: 203
|
||||
}
|
||||
});
|
||||
});
|
||||
const tagPrintWin = new electron.BrowserWindow({
|
||||
show: false,
|
||||
width: 360,
|
||||
|
|
|
|||
192
electron/main.js
192
electron/main.js
|
|
@ -73,109 +73,109 @@ app.whenReady().then(() => {
|
|||
// });
|
||||
|
||||
// 创建打印小票子窗口
|
||||
const printWin = new BrowserWindow({
|
||||
show: false,
|
||||
width: 464,
|
||||
height: 1726,
|
||||
webPreferences: {
|
||||
// 集成网页和 Node.js,也就是在渲染进程中,可以调用 Node.js 方法
|
||||
nodeIntegration: true,
|
||||
contextIsolation: false,
|
||||
},
|
||||
});
|
||||
// const printWin = new BrowserWindow({
|
||||
// show: false,
|
||||
// width: 464,
|
||||
// height: 1726,
|
||||
// webPreferences: {
|
||||
// // 集成网页和 Node.js,也就是在渲染进程中,可以调用 Node.js 方法
|
||||
// nodeIntegration: true,
|
||||
// contextIsolation: false,
|
||||
// },
|
||||
// });
|
||||
|
||||
if (process.env.VITE_DEV_SERVER_URL) {
|
||||
// 加载打印的html文件
|
||||
printWin.loadFile(path.join(__dirname, "../public/print.html"));
|
||||
} else {
|
||||
printWin.loadFile(path.resolve(__dirname, "../dist/print.html")); // 打包后使用文件路径访问应用
|
||||
}
|
||||
// if (process.env.VITE_DEV_SERVER_URL) {
|
||||
// // 加载打印的html文件
|
||||
// printWin.loadFile(path.join(__dirname, "../public/print.html"));
|
||||
// } else {
|
||||
// printWin.loadFile(path.resolve(__dirname, "../dist/print.html")); // 打包后使用文件路径访问应用
|
||||
// }
|
||||
|
||||
// 接收订单页面发过来的参数发送给打印页
|
||||
ipcMain.on("printerInfoSync", (event, arg) => {
|
||||
printWin.webContents.send("getParams", arg);
|
||||
});
|
||||
// // 接收订单页面发过来的参数发送给打印页
|
||||
// ipcMain.on("printerInfoSync", (event, arg) => {
|
||||
// printWin.webContents.send("getParams", arg);
|
||||
// });
|
||||
|
||||
// 执行打印操作
|
||||
ipcMain.on("printStart", (event, arg) => {
|
||||
console.log(arg);
|
||||
const _parmas = JSON.parse(arg);
|
||||
// console.log(_parmas)
|
||||
let name = _parmas.deviceName;
|
||||
printWin.webContents.print({
|
||||
silent: true,
|
||||
deviceName: name,
|
||||
pageSize: {
|
||||
width: 58000,
|
||||
height: 216000,
|
||||
},
|
||||
scaleFactor: 80,
|
||||
landscape: false,
|
||||
margins: {
|
||||
marginType: "none",
|
||||
top: 0,
|
||||
bottom: 0,
|
||||
left: 0,
|
||||
right: 0,
|
||||
},
|
||||
dpi: {
|
||||
horizontal: 203,
|
||||
vertical: 203,
|
||||
},
|
||||
});
|
||||
});
|
||||
// // 执行打印操作
|
||||
// ipcMain.on("printStart", (event, arg) => {
|
||||
// console.log(arg);
|
||||
// const _parmas = JSON.parse(arg);
|
||||
// // console.log(_parmas)
|
||||
// let name = _parmas.deviceName;
|
||||
// printWin.webContents.print({
|
||||
// silent: true,
|
||||
// deviceName: name,
|
||||
// pageSize: {
|
||||
// width: 58000,
|
||||
// height: 216000,
|
||||
// },
|
||||
// scaleFactor: 80,
|
||||
// landscape: false,
|
||||
// margins: {
|
||||
// marginType: "none",
|
||||
// top: 0,
|
||||
// bottom: 0,
|
||||
// left: 0,
|
||||
// right: 0,
|
||||
// },
|
||||
// dpi: {
|
||||
// horizontal: 203,
|
||||
// vertical: 203,
|
||||
// },
|
||||
// });
|
||||
// });
|
||||
|
||||
// 交班小票的窗口
|
||||
const workPrintWin = new BrowserWindow({
|
||||
show: false,
|
||||
width: 464,
|
||||
height: 1726,
|
||||
webPreferences: {
|
||||
nodeIntegration: true,
|
||||
contextIsolation: false,
|
||||
},
|
||||
});
|
||||
// // 交班小票的窗口
|
||||
// const workPrintWin = new BrowserWindow({
|
||||
// show: false,
|
||||
// width: 464,
|
||||
// height: 1726,
|
||||
// webPreferences: {
|
||||
// nodeIntegration: true,
|
||||
// contextIsolation: false,
|
||||
// },
|
||||
// });
|
||||
|
||||
if (process.env.VITE_DEV_SERVER_URL) {
|
||||
// 加载打印的html文件
|
||||
workPrintWin.loadFile(path.join(__dirname, "../public/work_print.html"));
|
||||
} else {
|
||||
workPrintWin.loadFile(path.resolve(__dirname, "../dist/work_print.html")); // 打包后使用文件路径访问应用
|
||||
}
|
||||
// if (process.env.VITE_DEV_SERVER_URL) {
|
||||
// // 加载打印的html文件
|
||||
// workPrintWin.loadFile(path.join(__dirname, "../public/work_print.html"));
|
||||
// } else {
|
||||
// workPrintWin.loadFile(path.resolve(__dirname, "../dist/work_print.html")); // 打包后使用文件路径访问应用
|
||||
// }
|
||||
|
||||
// 接收渲染进程发送的数据
|
||||
ipcMain.on("printerWorkSync", (event, arg) => {
|
||||
workPrintWin.webContents.send("getParams", arg);
|
||||
});
|
||||
// // 接收渲染进程发送的数据
|
||||
// ipcMain.on("printerWorkSync", (event, arg) => {
|
||||
// workPrintWin.webContents.send("getParams", arg);
|
||||
// });
|
||||
|
||||
// 执行交班小票的打印操作
|
||||
ipcMain.on("printWorkStart", (event, arg) => {
|
||||
// console.log(arg);
|
||||
const _parmas = JSON.parse(arg);
|
||||
// console.log(_parmas)
|
||||
let name = _parmas.deviceName;
|
||||
workPrintWin.webContents.print({
|
||||
silent: true,
|
||||
deviceName: name,
|
||||
pageSize: {
|
||||
width: 58000,
|
||||
height: 216000,
|
||||
},
|
||||
scaleFactor: 80,
|
||||
landscape: false,
|
||||
margins: {
|
||||
marginType: "none",
|
||||
top: 0,
|
||||
bottom: 0,
|
||||
left: 0,
|
||||
right: 0,
|
||||
},
|
||||
dpi: {
|
||||
horizontal: 203,
|
||||
vertical: 203,
|
||||
},
|
||||
});
|
||||
});
|
||||
// // 执行交班小票的打印操作
|
||||
// ipcMain.on("printWorkStart", (event, arg) => {
|
||||
// // console.log(arg);
|
||||
// const _parmas = JSON.parse(arg);
|
||||
// // console.log(_parmas)
|
||||
// let name = _parmas.deviceName;
|
||||
// workPrintWin.webContents.print({
|
||||
// silent: true,
|
||||
// deviceName: name,
|
||||
// pageSize: {
|
||||
// width: 58000,
|
||||
// height: 216000,
|
||||
// },
|
||||
// scaleFactor: 80,
|
||||
// landscape: false,
|
||||
// margins: {
|
||||
// marginType: "none",
|
||||
// top: 0,
|
||||
// bottom: 0,
|
||||
// left: 0,
|
||||
// right: 0,
|
||||
// },
|
||||
// dpi: {
|
||||
// horizontal: 203,
|
||||
// vertical: 203,
|
||||
// },
|
||||
// });
|
||||
// });
|
||||
|
||||
// 标签小票的窗口
|
||||
const tagPrintWin = new BrowserWindow({
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
};
|
||||
|
|
@ -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);
|
||||
};
|
||||
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ import { bySubType } from "@/api/device";
|
|||
import { useUser } from "@/store/user.js";
|
||||
import dayjs from "dayjs";
|
||||
import receiptPrint from "@/components/lodop/receiptPrint.js";
|
||||
import lodopPrintWork from "@/components/lodop/lodopPrintWork.js";
|
||||
import invoicePrint from "@/components/lodop/invoicePrint.js";
|
||||
|
||||
export const usePrint = defineStore({
|
||||
id: "print",
|
||||
|
|
@ -144,7 +146,7 @@ export const usePrint = defineStore({
|
|||
this.receiptList.push(props);
|
||||
this.startReceiptPrint();
|
||||
} else {
|
||||
console.log("没有小票打印机");
|
||||
console.log("订单小票:没有小票打印机");
|
||||
}
|
||||
},
|
||||
// 开始打印小票
|
||||
|
|
@ -160,5 +162,29 @@ export const usePrint = defineStore({
|
|||
}
|
||||
}, 800);
|
||||
},
|
||||
// 打印交班小票
|
||||
printWork(data) {
|
||||
if (
|
||||
this.deviceNoteList.length &&
|
||||
this.checkLocalPrint(this.deviceNoteList[0].config.deviceName)
|
||||
) {
|
||||
data.deviceName = this.deviceNoteList[0].config.deviceName;
|
||||
lodopPrintWork(data);
|
||||
} else {
|
||||
console.log("交班小票:没有小票打印机");
|
||||
}
|
||||
},
|
||||
// 打印订单发票
|
||||
printInvoice(data) {
|
||||
if (
|
||||
this.deviceNoteList.length &&
|
||||
this.checkLocalPrint(this.deviceNoteList[0].config.deviceName)
|
||||
) {
|
||||
data.deviceName = this.deviceNoteList[0].config.deviceName;
|
||||
invoicePrint(data);
|
||||
} else {
|
||||
console.log("订单发票:没有小票打印机");
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
|
|||
|
|
@ -61,11 +61,11 @@
|
|||
</div>
|
||||
<div class="menu_wrap">
|
||||
<div class="print_view">
|
||||
<div class="title t1">溜溜</div>
|
||||
<div class="title t2">结算单【#002】</div>
|
||||
<div class="row">订单号:202404021023542223445</div>
|
||||
<div class="row">交易时间:2024-04-02 10:15</div>
|
||||
<div class="row">收银员:【POS-1】1</div>
|
||||
<div class="title t1">{{ printData.shop_name }}</div>
|
||||
<div class="title t2">预结算单【{{ printData.orderInfo.masterId }}】</div>
|
||||
<div class="row">订单号:{{ printData.orderInfo.orderNo }}</div>
|
||||
<div class="row">交易时间:{{ printData.createdAt }}</div>
|
||||
<div class="row">收银员:{{ printData.loginAccount }}</div>
|
||||
<div class="line"></div>
|
||||
<table class="table">
|
||||
<tr>
|
||||
|
|
@ -74,51 +74,31 @@
|
|||
<td>数量</td>
|
||||
<td>小计</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<tr v-for="(item, index) in printData.carts" :key="index">
|
||||
<td>
|
||||
<div>娃哈哈矿泉水</div>
|
||||
<div class="sku">500ml</div>
|
||||
<div>{{ item.name }}</div>
|
||||
<div class="sku">{{ item.skuName }}</div>
|
||||
</td>
|
||||
<td>1.0</td>
|
||||
<td>10</td>
|
||||
<td>10</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<div>柠檬奶茶</div>
|
||||
<div class="sku">加冰、加珍珠</div>
|
||||
</td>
|
||||
<td>10.0</td>
|
||||
<td>2</td>
|
||||
<td>20</td>
|
||||
<td>{{ item.salePrice }}</td>
|
||||
<td>{{ item.number }}</td>
|
||||
<td>{{ item.totalAmount }}</td>
|
||||
</tr>
|
||||
</table>
|
||||
<div class="line"></div>
|
||||
<div class="row between">
|
||||
<span>合计:</span>
|
||||
<span>30.00</span>
|
||||
<span>合计:</span>
|
||||
<span>{{ printData.amount }}</span>
|
||||
</div>
|
||||
<div class="row between">
|
||||
<span>合计:</span>
|
||||
<span>30.00</span>
|
||||
</div>
|
||||
<div class="row between">
|
||||
<span>原价:20.00,节省了0</span>
|
||||
</div>
|
||||
<div class="row between">
|
||||
<span>积分:</span>
|
||||
<span>0</span>
|
||||
</div>
|
||||
<div class="row between">
|
||||
<span>余额:</span>
|
||||
<span>余额:</span>
|
||||
<span>0.00</span>
|
||||
</div>
|
||||
<div class="line"></div>
|
||||
<div class="row">备注:</div>
|
||||
<div class="row">打印时间:2024-04-02 10:15</div>
|
||||
<div class="row">备注:{{ printData.remark }}</div>
|
||||
<div class="row">打印时间:{{ printData.printTime }}</div>
|
||||
<div class="btn_wrap">
|
||||
<div class="btn">
|
||||
<el-button plain style="width: 100%" @click="printHandle">
|
||||
<el-button plain style="width: 100%" :loading="printDataLoading" @click="printHandle">
|
||||
打印测试小票
|
||||
</el-button>
|
||||
</div>
|
||||
|
|
@ -137,7 +117,7 @@
|
|||
<script setup>
|
||||
import dayjs from 'dayjs'
|
||||
import { ipcRenderer } from "electron";
|
||||
import { onMounted, ref } from "vue";
|
||||
import { onMounted, reactive, ref } from "vue";
|
||||
import { useRouter, useRoute } from "vue-router";
|
||||
import { ElMessage } from "element-plus";
|
||||
import { tbPrintMachinePost, tbPrintMachineDetail } from "@/api/device";
|
||||
|
|
@ -175,6 +155,39 @@ const form = ref({
|
|||
shopId: store.userInfo.shopId,
|
||||
});
|
||||
|
||||
const printDataLoading = ref(false)
|
||||
const printData = reactive({
|
||||
shop_name: store.userInfo.shopName,
|
||||
loginAccount: store.userInfo.loginAccount,
|
||||
carts: [
|
||||
{
|
||||
id: 1,
|
||||
name: '【测试】娃哈哈矿泉水',
|
||||
skuName: '500ml',
|
||||
salePrice: '1.0',
|
||||
number: '10',
|
||||
totalAmount: '10'
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: '【测试】柠檬奶茶',
|
||||
skuName: '加冰、加珍珠',
|
||||
salePrice: '10',
|
||||
number: '2',
|
||||
totalAmount: '20'
|
||||
}
|
||||
],
|
||||
amount: '30.00',
|
||||
remark: '',
|
||||
orderInfo: {
|
||||
masterId: '#002',
|
||||
orderNo: '202404021023542223445'
|
||||
},
|
||||
deviceName: form.value.config.deviceName,
|
||||
createdAt: '2024-04-02 10:15',
|
||||
printTime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
||||
});
|
||||
|
||||
// 获取打印机列表
|
||||
function getPrintList() {
|
||||
ipcRenderer.send("getPrintList");
|
||||
|
|
@ -189,43 +202,12 @@ function printHandle() {
|
|||
ElMessage.warning("请选择打印设备");
|
||||
return;
|
||||
}
|
||||
|
||||
// ipcRenderer.send(
|
||||
// "printStart",
|
||||
// JSON.stringify({ deviceName: form.value.config.deviceName })
|
||||
// );
|
||||
|
||||
const data = {
|
||||
shop_name: '溜溜',
|
||||
carts: [
|
||||
{
|
||||
id: 1,
|
||||
name: '娃哈哈矿泉水',
|
||||
skuName: '500ml',
|
||||
salePrice: '1.0',
|
||||
number: '10',
|
||||
totalAmount: '10'
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: '柠檬奶茶',
|
||||
skuName: '加冰、加珍珠',
|
||||
salePrice: '10',
|
||||
number: '2',
|
||||
totalAmount: '20'
|
||||
}
|
||||
],
|
||||
amount: '30.00',
|
||||
remark: '',
|
||||
orderInfo: {
|
||||
masterId: '#002',
|
||||
orderNo: '202404021023542223445'
|
||||
},
|
||||
deviceName: form.value.config.deviceName,
|
||||
createdAt: '2024-04-02 10:15',
|
||||
printTime: '2024-04-02 10:15',
|
||||
};
|
||||
ipcRenderer.send("printerInfoSync", JSON.stringify(data));
|
||||
printDataLoading.value = true
|
||||
printData.printTime = dayjs().format('YYYY-MM-DD HH:mm:ss')
|
||||
printStore.pushReceiptData(printData)
|
||||
setTimeout(() => {
|
||||
printDataLoading.value = false
|
||||
}, 1500)
|
||||
}
|
||||
|
||||
// 提交打印机
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@
|
|||
<div class="intro">用来打印商品标签的打印机。</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<!-- <div class="row">
|
||||
<div class="icon" style="background-color: #8fc783">
|
||||
<el-image :src="icons.kitchen" style="width: 44px; height: 44px"></el-image>
|
||||
</div>
|
||||
|
|
@ -96,7 +96,7 @@
|
|||
<div class="name">添加出品打印机</div>
|
||||
<div class="intro">用来打印商品至厨房或出品台的打印机。</div>
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
<span class="member_info" v-if="memberInfo.telephone">会员:{{ memberInfo.telephone }}</span>
|
||||
</div>
|
||||
<div class="btm">
|
||||
<span class="p">服务员:{{ store.userInfo.shopName || "暂无" }}</span>
|
||||
<span class="p">服务员:{{ store.userInfo.loginAccount || "暂无" }}</span>
|
||||
<span class="t">{{
|
||||
props.orderInfo.createdAt &&
|
||||
dayjs(props.orderInfo.createdAt).format("MM-DD HH:mm")
|
||||
|
|
@ -155,6 +155,7 @@ const printHandle = _.throttle(async function () {
|
|||
// 打印订单标签
|
||||
async function printOrderLable() {
|
||||
try {
|
||||
if (!isPrint.value) return
|
||||
const res = await orderfindOrder({
|
||||
shopId: store.userInfo.shopId,
|
||||
status: '',
|
||||
|
|
@ -298,6 +299,10 @@ onMounted(() => {
|
|||
|
||||
.p {
|
||||
color: #999;
|
||||
width: 160px;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@ import { ElMessage } from 'element-plus'
|
|||
import { reactive, ref } from 'vue'
|
||||
import { issuedby, carsubinvoicing, syjprintqrcode } from '@/api/invoice.js'
|
||||
import { useUser } from "@/store/user.js";
|
||||
import { usePrint } from "@/store/print.js";
|
||||
const printStore = usePrint();
|
||||
const store = useUser();
|
||||
|
||||
const emits = defineEmits(['loadComplete', 'success'])
|
||||
|
|
@ -44,12 +46,17 @@ const orderInfo = ref({})
|
|||
async function printEwmHandle() {
|
||||
try {
|
||||
printEwmLoading.value = true
|
||||
const res = await syjprintqrcode({
|
||||
id: ewmInfo.value.id
|
||||
printStore.printInvoice({
|
||||
url: ewmInfo.value.wechat_url
|
||||
})
|
||||
// const res = await syjprintqrcode({
|
||||
// id: ewmInfo.value.id
|
||||
// })
|
||||
ElMessage.success('打印成功')
|
||||
showEwmDialog.value = false
|
||||
printEwmLoading.value = false
|
||||
setTimeout(() => {
|
||||
printEwmLoading.value = false
|
||||
}, 1000)
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
printEwmLoading.value = false
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
<el-icon size="20">
|
||||
<ArrowLeft />
|
||||
</el-icon>
|
||||
<div style="margin-left: 10px;">返回</div>
|
||||
<div style="margin-left: 4px;">返回</div>
|
||||
</div>
|
||||
<router-link to='/workrecord' class="box_top_right">
|
||||
交班记录
|
||||
|
|
@ -145,6 +145,9 @@ import { bySubType } from "@/api/device";
|
|||
import { useUser } from "@/store/user.js";
|
||||
import { useSocket } from "@/store/socket.js";
|
||||
import { formatDecimal } from '@/utils/index.js'
|
||||
import { usePrint } from "@/store/print.js";
|
||||
const printStore = usePrint();
|
||||
|
||||
const socket = useSocket();
|
||||
|
||||
const store = useUser();
|
||||
|
|
@ -200,8 +203,36 @@ function checkLocalPrint(deviceName) {
|
|||
}
|
||||
}
|
||||
|
||||
// 开始交班
|
||||
const exit = async () => {
|
||||
try {
|
||||
loading.value = true;
|
||||
let data = {}
|
||||
// 获取交班打印小票数据
|
||||
data = await handoverData({
|
||||
id: infoData.value.id
|
||||
})
|
||||
data.printTime = dayjs().format('YYYY-MM-DD HH:mm:ss')
|
||||
data.printShop = isPrint.value
|
||||
printStore.printWork(data)
|
||||
|
||||
await loginlogout({
|
||||
status: 1
|
||||
})
|
||||
|
||||
useStorage.del('userInfo')
|
||||
useStorage.del('token')
|
||||
useStorage.del('douyin')
|
||||
useStorage.del('categorysActive')
|
||||
|
||||
ElMessage.success("交班成功");
|
||||
setTimeout(() => {
|
||||
router.replace({
|
||||
name: "login",
|
||||
});
|
||||
}, 1000);
|
||||
loading.value = false;
|
||||
return
|
||||
if (printList.value.length) {
|
||||
console.log('本地打印');
|
||||
if (!checkLocalPrint(printList.value[0].config.deviceName)) {
|
||||
|
|
@ -213,6 +244,7 @@ const exit = async () => {
|
|||
useStorage.del('userInfo')
|
||||
useStorage.del('token')
|
||||
useStorage.del('douyin')
|
||||
useStorage.del('categorysActive')
|
||||
ElMessage.success("交班成功");
|
||||
setTimeout(() => {
|
||||
router.replace({
|
||||
|
|
@ -233,6 +265,7 @@ const exit = async () => {
|
|||
useStorage.del('userInfo')
|
||||
useStorage.del('token')
|
||||
useStorage.del('douyin')
|
||||
useStorage.del('categorysActive')
|
||||
ElMessage.success("交班成功");
|
||||
setTimeout(() => {
|
||||
router.replace({
|
||||
|
|
@ -262,6 +295,7 @@ const exit = async () => {
|
|||
useStorage.del('userInfo')
|
||||
useStorage.del('token')
|
||||
useStorage.del('douyin')
|
||||
useStorage.del('categorysActive')
|
||||
ElMessage.success("交班成功");
|
||||
setTimeout(() => {
|
||||
router.replace({
|
||||
|
|
@ -272,6 +306,7 @@ const exit = async () => {
|
|||
}
|
||||
socket.close()
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue