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 = ` +
| 名称 | +数量 | +总计 | +
|
+ ${item.categoryName}
+ |
+ ${item.num} | ++ ${item.amount} + | +
| 商品 | +数量 | +总计 | +
|
+ ${item.productName}
+ |
+ ${item.num} | ++ ${item.amount} + | +
| 品名 | -单价 | -数量 | -小计 | +品名 | +单价 | +数量 | +小计 |
| + |
${item.name}
规格:${item.skuName || ""}
|
- ${item.salePrice} | -${item.number} | -+ | ${item.salePrice} | +${item.number} | +${item.totalAmount} |