diff --git a/.env.test b/.env.test index 794b5c8..48c66f1 100644 --- a/.env.test +++ b/.env.test @@ -2,10 +2,10 @@ ENV = test #测试ws -VITE_API_WSS = 'wss://wxcashiertest.sxczgkj.cn/client' +# VITE_API_WSS = 'wss://wxcashiertest.sxczgkj.cn/client' # 正式ws -# VITE_API_WSS = 'wss://cashier.sxczgkj.cn/client' +VITE_API_WSS = 'wss://cashier.sxczgkj.cn/client' # 正式 php VITE_API_PHP_URL = 'http://czgdoumei.sxczgkj.com/index.php/api' @@ -17,7 +17,7 @@ VITE_API_PHP_URL = 'http://czgdoumei.sxczgkj.com/index.php/api' VITE_API_KP_URL = 'https://invoice.sxczgkj.cn/api' # 测试 -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 eda7f33..05cae54 100644 --- a/dist-electron/main.js +++ b/dist-electron/main.js @@ -1,115 +1 @@ -"use strict"; -const path = require("path"); -const electron = require("electron"); -const os = require("os"); -let win; -electron.app.whenReady().then(() => { - win = new electron.BrowserWindow({ - title: "银收客", - width: 1024, - height: 768, - fullscreenable: true, - fullscreen: process.env.VITE_DEV_SERVER_URL ? false : true, - simpleFullscreen: true, - frame: process.env.VITE_DEV_SERVER_URL ? true : false, - webPreferences: { - // 集成网页和 Node.js,也就是在渲染进程中,可以调用 Node.js 方法 - nodeIntegration: true, - contextIsolation: false - } - }); - if (process.env.VITE_DEV_SERVER_URL) { - win.loadURL(process.env.VITE_DEV_SERVER_URL); - } else { - win.loadFile(path.resolve(__dirname, "../dist/index.html")); - } - electron.app.on("activate", () => { - if (electron.BrowserWindow.getAllWindows().length === 0) { - createWindow(); - } - }); - electron.ipcMain.on("quitHandler", (_, msg) => { - win = null; - electron.app.exit(); - }); - electron.ipcMain.on("getPrintList", () => { - win.webContents.getPrintersAsync().then((res) => { - win.webContents.send("printList", res); - }); - }); - electron.ipcMain.on("getOSmacSync", () => { - let mac = ""; - if (os.networkInterfaces().WLAN) { - mac = os.networkInterfaces().WLAN[0].mac; - console.log("wlan.mac===", mac); - } else { - mac = os.networkInterfaces()["以太网"][0].mac; - console.log("以太网.mac===", mac); - } - win.webContents.send("getOSmacRes", mac); - }); - const tagPrintWin = new electron.BrowserWindow({ - show: false, - width: 360, - height: 240, - webPreferences: { - nodeIntegration: true, - contextIsolation: false - } - }); - if (process.env.VITE_DEV_SERVER_URL) { - tagPrintWin.loadFile(path.join(__dirname, "../public/tag_print.html")); - } else { - tagPrintWin.loadFile(path.resolve(__dirname, "../dist/tag_print.html")); - } - electron.ipcMain.on("printerTagSync", (event, arg) => { - console.log(arg); - tagPrintWin.webContents.send("getParams", arg); - }); - electron.ipcMain.on("printTagStart", (event, arg) => { - const _parmas = JSON.parse(arg); - let name = _parmas.deviceName; - tagPrintWin.webContents.print({ - silent: true, - deviceName: name, - pageSize: { - width: 45e3, - height: 3e4 - }, - scaleFactor: 80, - landscape: false, - margins: { - marginType: "none", - top: 0, - bottom: 0, - left: 0, - right: 0 - }, - dpi: { - horizontal: 203, - vertical: 203 - } - }); - }); - const gotTheLock = electron.app.requestSingleInstanceLock(); - if (!gotTheLock) { - electron.app.quit(); - } else { - electron.app.on("second-instance", (event, commandLine, workingDirectory) => { - if (win) { - if (win.isMinimized()) - win.restore(); - win.focus(); - win.show(); - } - }); - } - win.on("close", (e) => { - e.preventDefault(); - win.webContents.send("showCloseDialog"); - }); -}); -electron.app.on("window-all-closed", () => { - if (process.platform !== "darwin") - electron.app.quit(); -}); +"use strict";const s=require("path"),e=require("electron"),a=require("os");let n;e.app.whenReady().then(()=>{n=new e.BrowserWindow({title:"银收客",width:1024,height:768,fullscreenable:!0,fullscreen:!process.env.VITE_DEV_SERVER_URL,simpleFullscreen:!0,frame:!!process.env.VITE_DEV_SERVER_URL,webPreferences:{nodeIntegration:!0,contextIsolation:!1}}),process.env.VITE_DEV_SERVER_URL?n.loadURL(process.env.VITE_DEV_SERVER_URL):n.loadFile(s.resolve(__dirname,"../dist/index.html")),e.app.on("activate",()=>{e.BrowserWindow.getAllWindows().length===0&&createWindow()}),e.ipcMain.on("quitHandler",(t,o)=>{n=null,e.app.exit()}),e.ipcMain.on("getPrintList",()=>{n.webContents.getPrintersAsync().then(t=>{n.webContents.send("printList",t)})}),e.ipcMain.on("getOSmacSync",()=>{let t="";a.networkInterfaces().WLAN?(t=a.networkInterfaces().WLAN[0].mac,console.log("wlan.mac===",t)):(t=a.networkInterfaces().以太网[0].mac,console.log("以太网.mac===",t)),n.webContents.send("getOSmacRes",t)});const i=new e.BrowserWindow({show:!1,width:360,height:240,webPreferences:{nodeIntegration:!0,contextIsolation:!1}});process.env.VITE_DEV_SERVER_URL?i.loadFile(s.join(__dirname,"../public/tag_print.html")):i.loadFile(s.resolve(__dirname,"../dist/tag_print.html")),e.ipcMain.on("printerTagSync",(t,o)=>{console.log(o),i.webContents.send("getParams",o)}),e.ipcMain.on("printTagStart",(t,o)=>{let l=JSON.parse(o).deviceName;i.webContents.print({silent:!0,deviceName:l,pageSize:{width:45e3,height:3e4},scaleFactor:80,landscape:!1,margins:{marginType:"none",top:0,bottom:0,left:0,right:0},dpi:{horizontal:203,vertical:203}})}),e.app.requestSingleInstanceLock()?e.app.on("second-instance",(t,o,r)=>{n&&(n.isMinimized()&&n.restore(),n.focus(),n.show())}):e.app.quit(),n.on("close",t=>{t.preventDefault(),n.webContents.send("showCloseDialog")})});e.app.on("window-all-closed",()=>{process.platform!=="darwin"&&e.app.quit()}); diff --git a/src/components/leftMenu.vue b/src/components/leftMenu.vue index 828b8c7..1b8a8e4 100644 --- a/src/components/leftMenu.vue +++ b/src/components/leftMenu.vue @@ -49,8 +49,6 @@ import more from '@/components/more.vue' import callNumber from './callNumber.vue' import work from '@/views/work/index.vue' -const emits = defineEmits(['connectWsHandle']) - const socketStore = useSocket() const route = useRoute() @@ -108,7 +106,7 @@ function openCall() { // 手动重新连接ws function connectWsHandle() { if (socketStore.online) return - emits('connectWsHandle') + window.onload() } defineExpose({ diff --git a/src/components/lodop/invoicePrint.js b/src/components/lodop/invoicePrint.js index 11fe827..1097b45 100644 --- a/src/components/lodop/invoicePrint.js +++ b/src/components/lodop/invoicePrint.js @@ -3,6 +3,7 @@ import getLodop from "./LodopFuncs.js"; * 打印订单发票 */ export default (data) => { + console.log("data.deviceName===", data.deviceName); let LODOP = getLodop(); LODOP.PRINT_INIT("打印小票"); // 设置打印纸大小D @@ -13,13 +14,14 @@ export default (data) => { LODOP.SET_PRINTER_INDEX(data.deviceName); // 文字内容 let html = ` -
请使用微信扫码下载发票,二维码有效期30天,超过自动失效
-
-
+
.
+
.
+
.
+
.
`; setTimeout(() => { diff --git a/src/components/lodop/lodopPrintWork.js b/src/components/lodop/lodopPrintWork.js index 1d4e7e3..1a2071f 100644 --- a/src/components/lodop/lodopPrintWork.js +++ b/src/components/lodop/lodopPrintWork.js @@ -3,6 +3,7 @@ import getLodop from "./LodopFuncs.js"; * 打印交班小票 */ export default (data) => { + console.log("data.deviceName===", data.deviceName); let LODOP = getLodop(); LODOP.PRINT_INIT("打印小票"); // 设置打印纸大小D @@ -17,7 +18,7 @@ export default (data) => {
交班小票
-
+
当班时间:${data.startTime}
@@ -91,9 +92,8 @@ export default (data) => {
商品数据
- + - `; @@ -102,13 +102,10 @@ export default (data) => { for (let item of data.productInfos) { tableBody += ` - - `; } @@ -141,18 +138,17 @@ export default (data) => { 应交金额:${data.payable} -
- 上交金额: - ${data.handIn} -
总订单数: ${data.orderNum}
-
+
打印时间:${data.printTime}
-
+
.
+
.
+
.
+
.
`; let lastHtml = `${html}${payInfos}${memberTitle}${memberData}${productCategoriesTabHead}${productCategoriesTableBody}${tabHead}${tableBody}${str}`; diff --git a/src/components/lodop/receiptPrint.js b/src/components/lodop/receiptPrint.js index fd72559..4502062 100644 --- a/src/components/lodop/receiptPrint.js +++ b/src/components/lodop/receiptPrint.js @@ -3,6 +3,8 @@ import getLodop from "./LodopFuncs.js"; * 打印订单小票 */ export default (data) => { + console.log(data); + console.log("data.deviceName===", data.deviceName); let LODOP = getLodop(); LODOP.PRINT_INIT("打印小票"); // 设置打印纸大小D @@ -14,12 +16,14 @@ export default (data) => { let t2 = (100 - t1) / 3; let html = `
- ${data.shop_name} + ${data.shop_name}
- 结算单【${data.orderInfo.masterId ? data.orderInfo.masterId : ""}】 + ${data.isBefore ? "预" : ""}结算单【${ + data.orderInfo.masterId ? data.orderInfo.masterId : "" + }】
-
+
${data.orderInfo.outNumber ? data.orderInfo.outNumber : ""}
@@ -31,7 +35,9 @@ export default (data) => {
收银员:${data.loginAccount}
-
+
+
+
商品商品 数量总计
+
${item.productName}
${item.num} - ${item.amount} -
@@ -47,7 +53,11 @@ export default (data) => { @@ -60,7 +70,9 @@ export default (data) => { let str = `
品名
${item.name}
-
规格:${item.skuName || ""}
+ ${ + item.skuName + ? `
规格:${item.skuName}
` + : "" + }
${item.salePrice} ${item.number}
-
+
+
+
应收 ¥${data.amount} @@ -69,12 +81,17 @@ export default (data) => { 余额: 0.00
-
-
备注:${data.remark}
-
+
+
+
+
备注:${data.remark}
+
打印时间:${data.printTime}
-
+
.
+
.
+
.
+
.
`; let lastHtml = `${html}${table}${str}`; diff --git a/src/store/print.js b/src/store/print.js index 6b392d7..89a851e 100644 --- a/src/store/print.js +++ b/src/store/print.js @@ -125,15 +125,11 @@ export const usePrint = defineStore({ }, 800); }, // 添加小票打印对列表数据 - pushReceiptData(props) { - if ( - this.deviceNoteList.length && - this.checkLocalPrint(this.deviceNoteList[0].config.deviceName) - ) { - console.log(props); - + pushReceiptData(props, isDevice = true) { + console.log("pushReceiptData===", props); + if (!isDevice) { + // 测试打印,无需校验本地打印机 const store = useUser(); - props.deviceName = this.deviceNoteList[0].config.deviceName; props.shop_name = store.userInfo.shopName; props.loginAccount = store.userInfo.loginAccount; props.createdAt = dayjs(props.createdAt).format("YYYY-MM-DD HH:mm:ss"); @@ -146,7 +142,28 @@ export const usePrint = defineStore({ this.receiptList.push(props); this.startReceiptPrint(); } else { - console.log("订单小票:没有小票打印机"); + if ( + this.deviceNoteList.length && + this.checkLocalPrint(this.deviceNoteList[0].config.deviceName) + ) { + const store = useUser(); + props.deviceName = this.deviceNoteList[0].config.deviceName; + props.shop_name = store.userInfo.shopName; + props.loginAccount = store.userInfo.loginAccount; + props.createdAt = dayjs(props.createdAt).format( + "YYYY-MM-DD HH:mm:ss" + ); + props.printTime = dayjs().format("YYYY-MM-DD HH:mm:ss"); + if (!props.orderInfo.masterId) { + props.orderInfo.masterId = props.orderInfo.tableName; + } + props.orderInfo.outNumber = props.outNumber; + + this.receiptList.push(props); + this.startReceiptPrint(); + } else { + console.log("订单小票:没有小票打印机"); + } } }, // 开始打印小票 diff --git a/src/store/socket.js b/src/store/socket.js index 0d9a4a8..31979ef 100644 --- a/src/store/socket.js +++ b/src/store/socket.js @@ -57,7 +57,14 @@ export const useSocket = defineStore({ if (this.ws == null) { console.log("创建新的ws连接"); - this.ws = new ReconnectingWebSocket(wsUrl); + + const protocols = []; // 可选的子协议数组 + const options = { + // 自动重新连接的选项(可选) + connectionTimeout: 1000, + maxRetries: 100, + }; + this.ws = new ReconnectingWebSocket(wsUrl, protocols, options); } else { console.log("重新连接ws"); this.wsReconnect(); diff --git a/src/views/device/add.vue b/src/views/device/add.vue index 3cad97e..d8e9255 100644 --- a/src/views/device/add.vue +++ b/src/views/device/add.vue @@ -178,12 +178,12 @@ const printData = reactive({ } ], amount: '30.00', - remark: '', + remark: '给我多放点辣椒,谢谢老板', orderInfo: { masterId: '#002', orderNo: '202404021023542223445' }, - deviceName: form.value.config.deviceName, + deviceName: '', createdAt: '2024-04-02 10:15', printTime: dayjs().format('YYYY-MM-DD HH:mm:ss'), }); @@ -203,8 +203,9 @@ function printHandle() { return; } printDataLoading.value = true + printData.deviceName = form.value.config.deviceName printData.printTime = dayjs().format('YYYY-MM-DD HH:mm:ss') - printStore.pushReceiptData(printData) + printStore.pushReceiptData(printData, false) setTimeout(() => { printDataLoading.value = false }, 1500) diff --git a/src/views/home/components/settleAccount.vue b/src/views/home/components/settleAccount.vue index 285bd46..52c580e 100644 --- a/src/views/home/components/settleAccount.vue +++ b/src/views/home/components/settleAccount.vue @@ -125,6 +125,7 @@ const printHandle = _.throttle(async function () { const data = { shop_name: store.userInfo.shopName, loginAccount: store.userInfo.loginAccount, + isBefore: true, carts: props.cart, amount: props.amount, remark: props.remark, diff --git a/src/views/work/index.vue b/src/views/work/index.vue index fd9095a..c97391f 100644 --- a/src/views/work/index.vue +++ b/src/views/work/index.vue @@ -212,10 +212,12 @@ const exit = async () => { data = await handoverData({ id: infoData.value.id }) + data.printTime = dayjs().format('YYYY-MM-DD HH:mm:ss') data.printShop = isPrint.value printStore.printWork(data) + // return await loginlogout({ status: 1 })