优化新增本地打印交班小票
This commit is contained in:
parent
fde0ed0eaf
commit
1439f12ee5
|
|
@ -1 +1,129 @@
|
||||||
"use strict";const s=require("path"),e=require("electron");let t;e.app.whenReady().then(()=>{t=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?t.loadURL(process.env.VITE_DEV_SERVER_URL):t.loadFile(s.resolve(__dirname,"../dist/index.html")),e.app.on("activate",()=>{e.BrowserWindow.getAllWindows().length===0&&createWindow()}),e.ipcMain.on("quitHandler",(r,n)=>{e.app.quit()}),e.ipcMain.on("getPrintList",()=>{t.webContents.getPrintersAsync().then(r=>{t.webContents.send("printList",r)})});const i=new e.BrowserWindow({show:!1,width:464,height:1726,webPreferences:{nodeIntegration:!0,contextIsolation:!1}});process.env.VITE_DEV_SERVER_URL?i.loadFile(s.join(__dirname,"../public/print.html")):i.loadFile(s.resolve(__dirname,"../dist/print.html")),e.ipcMain.on("printerInfoSync",(r,n)=>{i.webContents.send("getParams",n)}),e.ipcMain.on("printStart",(r,n)=>{console.log(n);let o=JSON.parse(n).deviceName;i.webContents.print({silent:!0,deviceName:o,pageSize:{width:58e3,height:216e3},scaleFactor:80,landscape:!1,margins:{marginType:"none",top:0,bottom:0,left:0,right:0},dpi:{horizontal:203,vertical:203}})})});e.app.on("window-all-closed",()=>{process.platform!=="darwin"&&e.app.quit()});
|
"use strict";
|
||||||
|
const path = require("path");
|
||||||
|
const electron = require("electron");
|
||||||
|
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) => {
|
||||||
|
electron.app.quit();
|
||||||
|
});
|
||||||
|
electron.ipcMain.on("getPrintList", () => {
|
||||||
|
win.webContents.getPrintersAsync().then((res) => {
|
||||||
|
win.webContents.send("printList", res);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
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) => {
|
||||||
|
console.log(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
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
electron.app.on("window-all-closed", () => {
|
||||||
|
if (process.platform !== "darwin")
|
||||||
|
electron.app.quit();
|
||||||
|
});
|
||||||
|
|
|
||||||
102
electron/main.js
102
electron/main.js
|
|
@ -1,5 +1,11 @@
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import { app, BrowserWindow, ipcMain } from "electron";
|
import { app, BrowserWindow, ipcMain } from "electron";
|
||||||
|
// import SerialPort from "serialport";
|
||||||
|
|
||||||
|
// SerialPort.list().then(
|
||||||
|
// (ports) => ports.forEach(console.log),
|
||||||
|
// (err) => console.error(err)
|
||||||
|
// );
|
||||||
|
|
||||||
let win;
|
let win;
|
||||||
app.whenReady().then(() => {
|
app.whenReady().then(() => {
|
||||||
|
|
@ -100,58 +106,56 @@ app.whenReady().then(() => {
|
||||||
});
|
});
|
||||||
|
|
||||||
// 交班小票的窗口
|
// 交班小票的窗口
|
||||||
// const workPrintWin = new BrowserWindow({
|
const workPrintWin = new BrowserWindow({
|
||||||
// show: true,
|
show: false,
|
||||||
// width: 464,
|
width: 464,
|
||||||
// height: 1726,
|
height: 1726,
|
||||||
// webPreferences: {
|
webPreferences: {
|
||||||
// nodeIntegration: true,
|
nodeIntegration: true,
|
||||||
// contextIsolation: false,
|
contextIsolation: false,
|
||||||
// },
|
},
|
||||||
// });
|
});
|
||||||
|
|
||||||
// if (process.env.VITE_DEV_SERVER_URL) {
|
if (process.env.VITE_DEV_SERVER_URL) {
|
||||||
// // 加载打印的html文件
|
// 加载打印的html文件
|
||||||
// workPrintWin.loadFile(path.join(__dirname, "../public/work_print.html"));
|
workPrintWin.loadFile(path.join(__dirname, "../public/work_print.html"));
|
||||||
// } else {
|
} else {
|
||||||
// workPrintWin.loadFile(path.resolve(__dirname, "../dist/work_print.html")); // 打包后使用文件路径访问应用
|
workPrintWin.loadFile(path.resolve(__dirname, "../dist/work_print.html")); // 打包后使用文件路径访问应用
|
||||||
// }
|
}
|
||||||
|
|
||||||
// // 接收渲染进程发送的数据
|
|
||||||
// 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;
|
|
||||||
// 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("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,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
app.on("window-all-closed", () => {
|
app.on("window-all-closed", () => {
|
||||||
|
|
|
||||||
143
package.json
143
package.json
|
|
@ -1,72 +1,73 @@
|
||||||
{
|
{
|
||||||
"name": "vite-electron",
|
"name": "vite-electron",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "1.2.16",
|
"version": "1.2.16",
|
||||||
"main": "dist-electron/main.js",
|
"main": "dist-electron/main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "chcp 65001 && vite",
|
"dev": "chcp 65001 && vite",
|
||||||
"build": "node ./addVersion.js && vite build && electron-builder",
|
"build": "node ./addVersion.js && vite build && electron-builder",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
"build:win": "node ./addVersion.js && vite build && electron-builder --w"
|
"build:win": "node ./addVersion.js && vite build && electron-builder --w"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@element-plus/icons-vue": "^2.3.1",
|
"@element-plus/icons-vue": "^2.3.1",
|
||||||
"axios": "^1.6.2",
|
"axios": "^1.6.2",
|
||||||
"dayjs": "^1.11.10",
|
"dayjs": "^1.11.10",
|
||||||
"electron-pos-printer": "^1.3.6",
|
"electron-pos-printer": "^1.3.6",
|
||||||
"electron-pos-printer-vue": "^1.0.9",
|
"electron-pos-printer-vue": "^1.0.9",
|
||||||
"element-plus": "^2.4.3",
|
"element-plus": "^2.4.3",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"pinia": "^2.1.7",
|
"pinia": "^2.1.7",
|
||||||
"swiper": "^11.1.1",
|
"serialport": "^12.0.0",
|
||||||
"vue": "^3.3.8",
|
"swiper": "^11.1.1",
|
||||||
"vue-router": "^4.2.5"
|
"vue": "^3.3.8",
|
||||||
},
|
"vue-router": "^4.2.5"
|
||||||
"devDependencies": {
|
},
|
||||||
"@vitejs/plugin-vue": "^4.5.0",
|
"devDependencies": {
|
||||||
"electron": "^28.2.3",
|
"@vitejs/plugin-vue": "^4.5.0",
|
||||||
"electron-builder": "^24.13.3",
|
"electron": "^28.2.3",
|
||||||
"electron-rebuild": "^3.2.9",
|
"electron-builder": "^24.13.3",
|
||||||
"path": "^0.12.7",
|
"electron-rebuild": "^3.2.9",
|
||||||
"sass": "^1.69.5",
|
"path": "^0.12.7",
|
||||||
"sass-loader": "^13.3.2",
|
"sass": "^1.69.5",
|
||||||
"tree-kill": "^1.2.2",
|
"sass-loader": "^13.3.2",
|
||||||
"vite": "^5.0.0",
|
"tree-kill": "^1.2.2",
|
||||||
"vite-plugin-electron": "^0.15.4",
|
"vite": "^5.0.0",
|
||||||
"vite-plugin-electron-renderer": "^0.14.5"
|
"vite-plugin-electron": "^0.15.4",
|
||||||
},
|
"vite-plugin-electron-renderer": "^0.14.5"
|
||||||
"build": {
|
},
|
||||||
"appId": "com.cashierdesktop.app",
|
"build": {
|
||||||
"productName": "银收客",
|
"appId": "com.cashierdesktop.app",
|
||||||
"asar": true,
|
"productName": "银收客",
|
||||||
"files": [
|
"asar": true,
|
||||||
"./dist/**/*",
|
"files": [
|
||||||
"./dist-electron/**/*"
|
"./dist/**/*",
|
||||||
],
|
"./dist-electron/**/*"
|
||||||
"directories": {
|
],
|
||||||
"buildResources": "build",
|
"directories": {
|
||||||
"output": "release"
|
"buildResources": "build",
|
||||||
},
|
"output": "release"
|
||||||
"win": {
|
},
|
||||||
"icon": "./public/logo.ico",
|
"win": {
|
||||||
"target": [
|
"icon": "./public/logo.ico",
|
||||||
{
|
"target": [
|
||||||
"target": "nsis",
|
{
|
||||||
"arch": [
|
"target": "nsis",
|
||||||
"ia32"
|
"arch": [
|
||||||
]
|
"ia32"
|
||||||
}
|
]
|
||||||
]
|
}
|
||||||
},
|
]
|
||||||
"nsis": {
|
},
|
||||||
"oneClick": false,
|
"nsis": {
|
||||||
"allowElevation": true,
|
"oneClick": false,
|
||||||
"allowToChangeInstallationDirectory": true,
|
"allowElevation": true,
|
||||||
"installerIcon": "./public/logo.ico",
|
"allowToChangeInstallationDirectory": true,
|
||||||
"uninstallerIcon": "./public/logo.ico",
|
"installerIcon": "./public/logo.ico",
|
||||||
"installerHeaderIcon": "./public/logo.ico",
|
"uninstallerIcon": "./public/logo.ico",
|
||||||
"createDesktopShortcut": true,
|
"installerHeaderIcon": "./public/logo.ico",
|
||||||
"createStartMenuShortcut": true
|
"createDesktopShortcut": true,
|
||||||
}
|
"createStartMenuShortcut": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,10 @@ body {
|
||||||
padding: 0 8mm;
|
padding: 0 8mm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.empty {
|
||||||
|
height: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
.print_view {
|
.print_view {
|
||||||
padding: 20px 0;
|
padding: 20px 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,97 +1,80 @@
|
||||||
<!--
|
<!--
|
||||||
~ Copyright (c) 2023. Author Hubert Formin <2399270194@qq.com>
|
~ Copyright (c) 2023. Author Hubert Formin <2399270194@qq.com>
|
||||||
-->
|
-->
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<title>Print preview</title>
|
<title>Print preview</title>
|
||||||
<link rel="stylesheet" href="./work_print.css" />
|
<link rel="stylesheet" href="./work_print.css" />
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div id="app">
|
<div id="app">
|
||||||
<div class="print_view">
|
<div class="print_view">
|
||||||
<div class="title t1">{{data.shop_name}}</div>
|
<div class="title t1">{{data.merchantName}}</div>
|
||||||
<div class="title t2">
|
<div class="title t2">交班小票</div>
|
||||||
交班小票
|
<div class="row">交班时间:{{data.startTime}}</div>
|
||||||
</div>
|
<div class="row">收银员:{{data.staff}}</div>
|
||||||
<div class="row">
|
<div class="row">当班收入:{{data.totalAmount}}</div>
|
||||||
交班时间:{{data.orderInfo && data.orderInfo.orderNo}}
|
<div class="row" v-for="(item,index) in data.payInfos" :key="index">
|
||||||
</div>
|
  {{item.payType }}:{{item.amount}}
|
||||||
<div class="row">收银员:【POS-1】1</div>
|
|
||||||
<table class="table">
|
|
||||||
<tr>
|
|
||||||
<td>品名</td>
|
|
||||||
<td>单价</td>
|
|
||||||
<td>数量</td>
|
|
||||||
<td>小计</td>
|
|
||||||
</tr>
|
|
||||||
<tr v-for="item in data.carts" :key="item.id">
|
|
||||||
<td>
|
|
||||||
<div>{{item.name}}</div>
|
|
||||||
<div class="sku">{{item.skuName}}</div>
|
|
||||||
</td>
|
|
||||||
<td>{{item.salePrice}}</td>
|
|
||||||
<td>{{item.number}}</td>
|
|
||||||
<td>{{item.totalAmount}}</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
<div class="row between">
|
|
||||||
<span>合计:</span>
|
|
||||||
<span>{{data.amount}}</span>
|
|
||||||
</div>
|
|
||||||
<!-- <div class="row between">
|
|
||||||
<span>合计:</span>
|
|
||||||
<span>30.00</span>
|
|
||||||
</div> -->
|
|
||||||
<div class="row between">
|
|
||||||
<span>原价:{{data.amount}},节省了0</span>
|
|
||||||
</div>
|
|
||||||
<div class="row between">
|
|
||||||
<span>积分:</span>
|
|
||||||
<span>0</span>
|
|
||||||
</div>
|
|
||||||
<div class="row between">
|
|
||||||
<span>余额:</span>
|
|
||||||
<span>0.00</span>
|
|
||||||
</div>
|
|
||||||
<div class="row">备注:</div>
|
|
||||||
<div class="row">打印时间:{{data.printTime}}</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
<div class="row">会员数据</div>
|
||||||
|
<div class="row" v-for="(item,index) in data.memberData" :key="index">
|
||||||
|
  {{item.deposit }}:{{item.amount}}
|
||||||
|
</div>
|
||||||
|
<div class="row">分类数据</div>
|
||||||
|
<div
|
||||||
|
class="row"
|
||||||
|
v-for="(item,index) in data.productCategories"
|
||||||
|
:key="index"
|
||||||
|
>
|
||||||
|
  {{item.categoryName
|
||||||
|
}} {{item.num}} {{item.amount}}
|
||||||
|
</div>
|
||||||
|
<div class="row">快捷收款金额:{{data.quickAmount}}</div>
|
||||||
|
<div class="row">退款金额:{{data.returnAmount}}</div>
|
||||||
|
<div class="row">总收入:{{data.totalAmount}}</div>
|
||||||
|
<div class="row">备用金:{{data.imprest}}</div>
|
||||||
|
<div class="row">应交金额:{{data.payable}}</div>
|
||||||
|
<div class="row">上交金额:{{data.handIn}}</div>
|
||||||
|
<div class="empty"></div>
|
||||||
|
<div class="row">总订单数:{{data.orderNum}}</div>
|
||||||
|
<div class="row">打印时间:{{data.printTime}}</div>
|
||||||
</div>
|
</div>
|
||||||
<script type="module">
|
</div>
|
||||||
const { ipcRenderer } = require("electron");
|
<script type="module">
|
||||||
import {
|
const { ipcRenderer } = require("electron");
|
||||||
createApp,
|
import {
|
||||||
ref,
|
createApp,
|
||||||
onMounted,
|
ref,
|
||||||
} from "../node_modules/vue/dist/vue.esm-browser.js";
|
onMounted,
|
||||||
|
} from "../node_modules/vue/dist/vue.esm-browser.js";
|
||||||
createApp({
|
|
||||||
setup() {
|
createApp({
|
||||||
const data = ref({});
|
setup() {
|
||||||
|
const data = ref({});
|
||||||
onMounted(() => {
|
|
||||||
ipcRenderer.on("getParams", (event, arg) => {
|
onMounted(() => {
|
||||||
data.value = JSON.parse(arg);
|
ipcRenderer.on("getParams", (event, arg) => {
|
||||||
console.log(data.value);
|
data.value = JSON.parse(arg);
|
||||||
|
console.log(data.value);
|
||||||
setTimeout(() => {
|
|
||||||
ipcRenderer.send(
|
setTimeout(() => {
|
||||||
"printStart",
|
ipcRenderer.send(
|
||||||
JSON.stringify({ deviceName: data.value.deviceName })
|
"printWorkStart",
|
||||||
);
|
JSON.stringify({ deviceName: data.value.deviceName })
|
||||||
}, 500);
|
);
|
||||||
});
|
}, 500);
|
||||||
});
|
});
|
||||||
|
});
|
||||||
return {
|
|
||||||
data,
|
return {
|
||||||
};
|
data,
|
||||||
},
|
};
|
||||||
}).mount("#app");
|
},
|
||||||
</script>
|
}).mount("#app");
|
||||||
</body>
|
</script>
|
||||||
</html>
|
</body>
|
||||||
|
</html>
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,9 @@
|
||||||
body {
|
body {
|
||||||
padding: 0 8mm;
|
padding: 0 8mm;
|
||||||
}
|
}
|
||||||
|
.empty {
|
||||||
|
height: 20px;
|
||||||
|
}
|
||||||
.print_view {
|
.print_view {
|
||||||
padding: 20px 0;
|
padding: 20px 0;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,40 +1,53 @@
|
||||||
import request from "@/utils/request.js"
|
import request from "@/utils/request.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 当前用户交班详情
|
* 当前用户交班详情
|
||||||
* @param {*} params
|
* @param {*} params
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
export function shopInfoqueryDuty(params) {
|
export function shopInfoqueryDuty(params) {
|
||||||
return request({
|
return request({
|
||||||
method: "get",
|
method: "get",
|
||||||
url: "shopInfo/queryDuty",
|
url: "shopInfo/queryDuty",
|
||||||
params
|
params,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 交班记录
|
* 交班记录
|
||||||
* @param {*} params
|
* @param {*} params
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
export function shopinfoqueryDutyFlow(params) {
|
export function shopinfoqueryDutyFlow(params) {
|
||||||
return request({
|
return request({
|
||||||
method: "get",
|
method: "get",
|
||||||
url: "shopInfo/queryDutyFlow",
|
url: "shopInfo/queryDutyFlow",
|
||||||
params
|
params,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登出
|
* 登出
|
||||||
|
* @param {*} params
|
||||||
* @param {*} params
|
* @returns
|
||||||
* @returns
|
|
||||||
*/
|
*/
|
||||||
export function loginlogout(params) {
|
export function loginlogout(params) {
|
||||||
return request({
|
return request({
|
||||||
method: "post",
|
method: "post",
|
||||||
url: "login/logout",
|
url: "login/logout",
|
||||||
params
|
params,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取交班数据
|
||||||
|
* @param {*} params
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function handoverData(params) {
|
||||||
|
return request({
|
||||||
|
method: "get",
|
||||||
|
url: "/data/handoverData",
|
||||||
|
params,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
<div class="orderbox_left">
|
<div class="orderbox_left">
|
||||||
<div class="demo_tabs" v-if="props.membershow == '0'">
|
<div class="demo_tabs" v-if="props.membershow == '0'">
|
||||||
<div class="demo_tabs_div">
|
<div class="demo_tabs_div">
|
||||||
<el-input v-model="tableData.phone" placeholder="请输入手机号或编号" @input="inputChange" clearable />
|
<el-input v-model="tableData.phone" placeholder="请输入手机号" @input="inputChange" clearable />
|
||||||
<el-button style="margin-left: 10px;" type="primary" @click="memberaddshow = true">添加</el-button>
|
<el-button style="margin-left: 10px;" type="primary" @click="memberaddshow = true">添加</el-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,10 @@
|
||||||
<div class="box">
|
<div class="box">
|
||||||
<div class="box_top">
|
<div class="box_top">
|
||||||
<router-link to="/" class="box_top_left">
|
<router-link to="/" class="box_top_left">
|
||||||
<el-icon size="20">
|
<el-icon size="20">
|
||||||
<ArrowLeft />
|
<ArrowLeft />
|
||||||
</el-icon>
|
</el-icon>
|
||||||
<div style="margin-left: 10px;">返回</div>
|
<div style="margin-left: 10px;">返回</div>
|
||||||
</router-link>
|
</router-link>
|
||||||
<router-link to='/workrecord' class="box_top_right">
|
<router-link to='/workrecord' class="box_top_right">
|
||||||
交班记录
|
交班记录
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
<div class="box_content_left_top_item">
|
<div class="box_content_left_top_item">
|
||||||
<div class="box_content_left_top_item_top">
|
<div class="box_content_left_top_item_top">
|
||||||
<div style="color:#ff5252; font-size: 30px;">
|
<div style="color:#ff5252; font-size: 30px;">
|
||||||
{{ infoData.orderNum || 0}}
|
{{ infoData.orderNum || 0 }}
|
||||||
</div>
|
</div>
|
||||||
<div style="margin-top: 6px; color: #666;">
|
<div style="margin-top: 6px; color: #666;">
|
||||||
总订单
|
总订单
|
||||||
|
|
@ -26,7 +26,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="box_content_left_top_item_top">
|
<div class="box_content_left_top_item_top">
|
||||||
<div style="color:#ff5252; font-size: 30px;">
|
<div style="color:#ff5252; font-size: 30px;">
|
||||||
{{ infoData.amount || 0}}
|
{{ infoData.amount || 0 }}
|
||||||
</div>
|
</div>
|
||||||
<div style="margin-top: 6px; color: #666;">
|
<div style="margin-top: 6px; color: #666;">
|
||||||
营业额
|
营业额
|
||||||
|
|
@ -36,7 +36,7 @@
|
||||||
<div class="box_content_left_top_item">
|
<div class="box_content_left_top_item">
|
||||||
<div class="box_content_left_top_item_botton">
|
<div class="box_content_left_top_item_botton">
|
||||||
<div style=" font-size: 20px;">
|
<div style=" font-size: 20px;">
|
||||||
{{ infoData.cashAmount|| 0}}
|
{{ infoData.cashAmount || 0 }}
|
||||||
</div>
|
</div>
|
||||||
<div style="margin-top: 6px;">
|
<div style="margin-top: 6px;">
|
||||||
现金支付
|
现金支付
|
||||||
|
|
@ -47,7 +47,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="box_content_left_top_item_botton">
|
<div class="box_content_left_top_item_botton">
|
||||||
<div style=" font-size: 20px;">
|
<div style=" font-size: 20px;">
|
||||||
{{ infoData.returnAmount || 0}}
|
{{ infoData.returnAmount || 0 }}
|
||||||
</div>
|
</div>
|
||||||
<div style="margin-top: 6px;">
|
<div style="margin-top: 6px;">
|
||||||
退款金额
|
退款金额
|
||||||
|
|
@ -60,9 +60,9 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="box_content_left_bottom">
|
<div class="box_content_left_bottom">
|
||||||
<el-table :data="infoData.detailList" style="width: 100%;" height="400px">
|
<el-table :data="infoData.detailList" style="width: 100%;" height="400px">
|
||||||
<el-table-column prop="productName" label="商品名称"/>
|
<el-table-column prop="productName" label="商品名称" />
|
||||||
<el-table-column prop="skuName" label="规格名称"/>
|
<el-table-column prop="skuName" label="规格名称" />
|
||||||
<el-table-column prop="num" label="商品数量"/>
|
<el-table-column prop="num" label="商品数量" />
|
||||||
<el-table-column prop="amount" label="商品金额" />
|
<el-table-column prop="amount" label="商品金额" />
|
||||||
</el-table>
|
</el-table>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -89,7 +89,7 @@
|
||||||
终端名称:
|
终端名称:
|
||||||
</div>
|
</div>
|
||||||
<div class="box_content_right_tiemright">
|
<div class="box_content_right_tiemright">
|
||||||
{{ infoData.equipment || '无'}}
|
{{ infoData.equipment || '无' }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="box_content_right_tiem">
|
<div class="box_content_right_tiem">
|
||||||
|
|
@ -97,7 +97,7 @@
|
||||||
备用金:
|
备用金:
|
||||||
</div>
|
</div>
|
||||||
<div class="box_content_right_tiemright">
|
<div class="box_content_right_tiemright">
|
||||||
{{ infoData.pettyCash || '无'}}
|
{{ infoData.pettyCash || '无' }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="box_content_right_tiem">
|
<div class="box_content_right_tiem">
|
||||||
|
|
@ -105,7 +105,7 @@
|
||||||
收营员:
|
收营员:
|
||||||
</div>
|
</div>
|
||||||
<div class="box_content_right_tiemright">
|
<div class="box_content_right_tiemright">
|
||||||
{{ infoData.userName || '无'}}
|
{{ infoData.userName || '无' }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="box_content_right_tiembutton" :loading="loading" @click="exit">
|
<div class="box_content_right_tiembutton" :loading="loading" @click="exit">
|
||||||
|
|
@ -121,12 +121,18 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
|
import { ipcRenderer } from "electron";
|
||||||
|
|
||||||
import { ref, onMounted } from 'vue'
|
import { ref, onMounted } from 'vue'
|
||||||
import { useRoute } from 'vue-router'
|
import { useRoute } from 'vue-router'
|
||||||
import { ElMessage, dayjs } from 'element-plus'
|
import { ElMessage, dayjs } from 'element-plus'
|
||||||
import { shopInfoqueryDuty, loginlogout } from '@/api/work/index.js'
|
import { shopInfoqueryDuty, loginlogout, handoverData } from '@/api/work/index.js'
|
||||||
import useStorage from '@/utils/useStorage'
|
import useStorage from '@/utils/useStorage'
|
||||||
import { useRouter } from "vue-router";
|
import { useRouter } from "vue-router";
|
||||||
|
import { bySubType } from "@/api/device";
|
||||||
|
import { useUser } from "@/store/user.js";
|
||||||
|
|
||||||
|
const store = useUser();
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
|
|
@ -135,20 +141,85 @@ const dialogVisible = ref(true) //交班
|
||||||
const infoData = ref({})
|
const infoData = ref({})
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
|
|
||||||
|
const printList = ref([]);
|
||||||
|
const localPrintList = ref([])
|
||||||
|
|
||||||
|
// 获取打印机状态
|
||||||
|
async function bySubTypeAjax() {
|
||||||
|
try {
|
||||||
|
const res = await bySubType({
|
||||||
|
shopId: store.userInfo.shopId,
|
||||||
|
contentType: "local",
|
||||||
|
subType: "cash",
|
||||||
|
});
|
||||||
|
printList.value = res;
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取本地打印机列表
|
||||||
|
function getPrintList() {
|
||||||
|
ipcRenderer.send("getPrintList");
|
||||||
|
ipcRenderer.on("printList", (event, arg) => {
|
||||||
|
localPrintList.value = arg;
|
||||||
|
console.log(localPrintList.value);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查本地打印机是否能正常使用
|
||||||
|
function checkLocalPrint(deviceName) {
|
||||||
|
let print = ''
|
||||||
|
for (let item of localPrintList.value) {
|
||||||
|
if (item.name == deviceName) {
|
||||||
|
print = item
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!print.name) {
|
||||||
|
return false
|
||||||
|
} else {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const exit = async () => {
|
const exit = async () => {
|
||||||
try {
|
try {
|
||||||
loading.value = true;
|
if (printList.value.length) {
|
||||||
let res = await loginlogout({
|
if (!checkLocalPrint(printList.value[0].config.deviceName)) {
|
||||||
status:1
|
ElMessage.error("本地打印机无法使用,请检查打印机是否正确连接");
|
||||||
})
|
} else {
|
||||||
useStorage.clear()
|
// 获取交班打印小票数据
|
||||||
ElMessage.success("交班成功");
|
const data = await handoverData({
|
||||||
setTimeout(() => {
|
id: infoData.value.id
|
||||||
router.replace({
|
})
|
||||||
name: "login",
|
data.deviceName = printList.value[0].config.deviceName
|
||||||
});
|
data.printTime = dayjs().format('YYYY-MM-DD HH:mm:ss')
|
||||||
}, 1000);
|
ipcRenderer.send("printerWorkSync", JSON.stringify(data));
|
||||||
loading.value = false;
|
// return
|
||||||
|
useStorage.clear()
|
||||||
|
ElMessage.success("交班成功");
|
||||||
|
setTimeout(() => {
|
||||||
|
router.replace({
|
||||||
|
name: "login",
|
||||||
|
});
|
||||||
|
}, 1000);
|
||||||
|
loading.value = false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
loading.value = true;
|
||||||
|
let res = await loginlogout({
|
||||||
|
status: 1
|
||||||
|
})
|
||||||
|
useStorage.clear()
|
||||||
|
ElMessage.success("交班成功");
|
||||||
|
setTimeout(() => {
|
||||||
|
router.replace({
|
||||||
|
name: "login",
|
||||||
|
});
|
||||||
|
}, 1000);
|
||||||
|
loading.value = false;
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
}
|
}
|
||||||
|
|
@ -166,6 +237,8 @@ const infoshopInfoqueryDutys = async () => {
|
||||||
|
|
||||||
}
|
}
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
getPrintList()
|
||||||
|
bySubTypeAjax()
|
||||||
infoshopInfoqueryDutys()
|
infoshopInfoqueryDutys()
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue