diff --git a/.env.development b/.env.development index 5e62c37..18a046a 100644 --- a/.env.development +++ b/.env.development @@ -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' \ No newline at end of file +VITE_API_URL = 'https://cashierclient.sxczgkj.cn/cashier-client' \ No newline at end of file diff --git a/dist-electron/main.js b/dist-electron/main.js index 33bc60f..eda7f33 100644 --- a/dist-electron/main.js +++ b/dist-electron/main.js @@ -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, diff --git a/electron/main.js b/electron/main.js index d241039..297c152 100644 --- a/electron/main.js +++ b/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({ diff --git a/src/components/lodop/invoicePrint.js b/src/components/lodop/invoicePrint.js new file mode 100644 index 0000000..11fe827 --- /dev/null +++ b/src/components/lodop/invoicePrint.js @@ -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 = ` +
+
+
+ 请使用微信扫码下载发票,二维码有效期30天,超过自动失效 +
+
+
+ `; + + setTimeout(() => { + LODOP.ADD_PRINT_HTM("9mm", "0mm", "RightMargin:0mm", 20, html); + LODOP.SET_LICENSES("", "DCFF409304DFCEB3E2C644BF96CD0720", "", ""); + LODOP.PRINT(); + }, 800); +}; diff --git a/src/components/lodop/lodopPrintWork.js b/src/components/lodop/lodopPrintWork.js new file mode 100644 index 0000000..1d4e7e3 --- /dev/null +++ b/src/components/lodop/lodopPrintWork.js @@ -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 = ` +
+ ${data.merchantName} +
+
+ 交班小票 +
+
+ 当班时间:${data.startTime} +
+
+ 交班时间:${data.endTime} +
+
+ 收银员:${data.staff} +
+
+ 当班收入:${data.totalAmount} +
+ `; + + let payInfos = ""; + if (data.payInfos && data.payInfos.length) { + for (let item of data.payInfos) { + payInfos += ` +
+ ${item.payType}:${item.amount} +
+ `; + } + } + + let memberTitle = ` +
+ 会员数据 +
+ `; + + let memberData = ""; + if (data.memberData && data.memberData.length) { + for (let item of data.memberData) { + memberData += ` +
+ ${item.deposit}:${item.amount} +
+ `; + } + } + + let productCategoriesTabHead = ` +
分类数据
+ + + + + + + `; + + let productCategoriesTableBody = ""; + if (data.productCategories && data.productCategories.length) { + for (let item of data.productCategories) { + productCategoriesTableBody += ` + + + + + + `; + } + } + + let tabHead = ` +
名称数量总计
+
${item.categoryName}
+
${item.num} + ${item.amount} +
+
商品数据
+ + + + + + + `; + + let tableBody = ""; + if (data.productInfos && data.productInfos.length) { + for (let item of data.productInfos) { + tableBody += ` + + + + + + `; + } + } + + if (!data.printShop) { + tabHead = ""; + tableBody = ""; + } + + let str = ` +
商品数量总计
+
${item.productName}
+
${item.num} + ${item.amount} +
+
+ 快捷收款金额: + ${data.quickAmount} +
+
+ 退款金额: + ${data.returnAmount} +
+
+ 总收入: + ${data.totalAmount} +
+
+ 备用金: + ${data.imprest} +
+
+ 应交金额: + ${data.payable} +
+
+ 上交金额: + ${data.handIn} +
+
+ 总订单数: + ${data.orderNum} +
+
+ 打印时间:${data.printTime} +
+
+ `; + + 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); +}; diff --git a/src/components/lodop/receiptPrint.js b/src/components/lodop/receiptPrint.js index 95d6e94..fd72559 100644 --- a/src/components/lodop/receiptPrint.js +++ b/src/components/lodop/receiptPrint.js @@ -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 = `
${data.shop_name}
- 预结算单【${data.orderInfo.masterId ? data.orderInfo.masterId : ""}】 + 结算单【${data.orderInfo.masterId ? data.orderInfo.masterId : ""}】
${data.orderInfo.outNumber ? data.orderInfo.outNumber : ""} @@ -28,12 +32,12 @@ export default (data) => { 收银员:${data.loginAccount}
- +
- - - - + + + + `; @@ -41,13 +45,13 @@ export default (data) => { for (let item of data.carts) { table += ` - - - - + + diff --git a/src/components/more.vue b/src/components/more.vue index 2015972..901dd8d 100644 --- a/src/components/more.vue +++ b/src/components/more.vue @@ -8,7 +8,7 @@ {{ store.userInfo.shopName }}
- 收银员:{{ store.userInfo.loginName }} + 收银员:{{ store.userInfo.loginAccount }}
{{ dayjs(store.userInfo.loginTime).format('YYYY-MM-DD HH:mm:ss') }} @@ -32,13 +32,21 @@
系统
-
+ +
+
+ + + +
+
设备管理
@@ -48,18 +56,10 @@
叫号
-
-
- - - -
-
设备管理
-
- +
锁屏
diff --git a/src/store/print.js b/src/store/print.js index 208e020..6b392d7 100644 --- a/src/store/print.js +++ b/src/store/print.js @@ -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("订单发票:没有小票打印机"); + } + }, }, }); diff --git a/src/views/device/add.vue b/src/views/device/add.vue index 00af7df..3cad97e 100644 --- a/src/views/device/add.vue +++ b/src/views/device/add.vue @@ -61,11 +61,11 @@
品名单价数量小计品名单价数量小计
+
${item.name}
规格:${item.skuName || ""}
${item.salePrice}${item.number} + ${item.salePrice}${item.number} ${item.totalAmount}
@@ -74,51 +74,31 @@ - + - - - - - - - - - + + +
数量 小计
-
娃哈哈矿泉水
-
500ml
+
{{ item.name }}
+
{{ item.skuName }}
1.01010
-
柠檬奶茶
-
加冰、加珍珠
-
10.0220{{ item.salePrice }}{{ item.number }}{{ item.totalAmount }}
- 合计: - 30.00 + 合计: + {{ printData.amount }}
- 合计: - 30.00 -
-
- 原价:20.00,节省了0 -
-
- 积分: - 0 -
-
- 余额: + 余额: 0.00
-
备注:
-
打印时间:2024-04-02 10:15
+
备注:{{ printData.remark }}
+
打印时间:{{ printData.printTime }}
- + 打印测试小票
@@ -137,7 +117,7 @@