From d2183eec37d177268d91dfb5a11343e4137c2dfb Mon Sep 17 00:00:00 2001 From: gyq <875626088@qq.com> Date: Tue, 23 Jul 2024 10:25:20 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BA=A4=E7=8F=AD=E6=96=B0=E5=A2=9E=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E6=98=AF=E5=90=A6=E6=89=93=E5=8D=B0=E5=95=86=E5=93=81?= =?UTF-8?q?=E9=94=80=E5=94=AE=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development | 5 +- .env.production | 3 + .env.test | 3 + dist-electron/main.js | 202 +------------------------------ package.json | 2 +- src/App.vue | 2 +- src/api/invoice.js | 14 +++ src/api/work/index.js | 13 ++ src/components/leftMenu.vue | 21 +++- src/utils/index.js | 11 +- src/utils/request_kp.js | 61 ++++++++++ src/views/login.vue | 5 +- src/views/order/index.vue | 19 ++- src/views/work/index.vue | 211 +++++++++++++++++++++----------- src/views/work/record.vue | 235 +++++++++++++++++++----------------- vite.config.js | 5 + 16 files changed, 412 insertions(+), 400 deletions(-) create mode 100644 src/api/invoice.js create mode 100644 src/utils/request_kp.js diff --git a/.env.development b/.env.development index 652f58c..4b1e716 100644 --- a/.env.development +++ b/.env.development @@ -14,11 +14,14 @@ VITE_API_WSS = 'wss://cashier.sxczgkj.cn/client' # 正式 php VITE_API_PHP_URL = 'http://czgdoumei.sxczgkj.com/index.php/api' +# 正式 php 开票 +VITE_API_KP_URL = 'http://192.168.1.13:8888/api' + # 阿伟 # VITE_API_URL = 'http://192.168.2.96:10587/cashier-client' # 鹏辉 -# VITE_API_URL = 'http://192.168.2.41:10589/cashier-client' +# VITE_API_URL = 'http://192.168.1.106:10589/cashier-client' # 测试 # VITE_API_URL = 'https://cashier-client.sxczgkj.cn/cashier-client' diff --git a/.env.production b/.env.production index e77f3f0..6973557 100644 --- a/.env.production +++ b/.env.production @@ -7,5 +7,8 @@ VITE_API_WSS = 'wss://cashier.sxczgkj.cn/client' # 正式 php VITE_API_PHP_URL = 'http://czgdoumei.sxczgkj.com/index.php/api' +# 正式 php 开票 +VITE_API_KP_URL = 'http://192.168.1.13:8888/api' + # 线上环境接口地址 VITE_API_URL = 'https://cashierclient.sxczgkj.cn/cashier-client/' \ No newline at end of file diff --git a/.env.test b/.env.test index cdc791e..5041768 100644 --- a/.env.test +++ b/.env.test @@ -10,6 +10,9 @@ VITE_API_WSS = 'wss://wxcashiertest.sxczgkj.cn/client' # 正式 php VITE_API_PHP_URL = 'http://czgdoumei.sxczgkj.com/index.php/api' +# 正式 php 开票 +VITE_API_KP_URL = 'http://192.168.1.13:8888/api' + # 测试 VITE_API_URL = 'https://cashier-client.sxczgkj.cn/cashier-client' diff --git a/dist-electron/main.js b/dist-electron/main.js index 33bc60f..0b8ea67 100644 --- a/dist-electron/main.js +++ b/dist-electron/main.js @@ -1,201 +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 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, - 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 o=require("path"),e=require("electron"),p=require("os");let i;e.app.whenReady().then(()=>{i=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?i.loadURL(process.env.VITE_DEV_SERVER_URL):i.loadFile(o.resolve(__dirname,"../dist/index.html")),e.app.on("activate",()=>{e.BrowserWindow.getAllWindows().length===0&&createWindow()}),e.ipcMain.on("quitHandler",(n,t)=>{i=null,e.app.exit()}),e.ipcMain.on("getPrintList",()=>{i.webContents.getPrintersAsync().then(n=>{i.webContents.send("printList",n)})}),e.ipcMain.on("getOSmacSync",()=>{let n="";p.networkInterfaces().WLAN?(n=p.networkInterfaces().WLAN[0].mac,console.log("wlan.mac===",n)):(n=p.networkInterfaces().以太网[0].mac,console.log("以太网.mac===",n)),i.webContents.send("getOSmacRes",n)});const r=new e.BrowserWindow({show:!1,width:464,height:1726,webPreferences:{nodeIntegration:!0,contextIsolation:!1}});process.env.VITE_DEV_SERVER_URL?r.loadFile(o.join(__dirname,"../public/print.html")):r.loadFile(o.resolve(__dirname,"../dist/print.html")),e.ipcMain.on("printerInfoSync",(n,t)=>{r.webContents.send("getParams",t)}),e.ipcMain.on("printStart",(n,t)=>{console.log(t);let a=JSON.parse(t).deviceName;r.webContents.print({silent:!0,deviceName:a,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}})});const s=new e.BrowserWindow({show:!1,width:464,height:1726,webPreferences:{nodeIntegration:!0,contextIsolation:!1}});process.env.VITE_DEV_SERVER_URL?s.loadFile(o.join(__dirname,"../public/work_print.html")):s.loadFile(o.resolve(__dirname,"../dist/work_print.html")),e.ipcMain.on("printerWorkSync",(n,t)=>{s.webContents.send("getParams",t)}),e.ipcMain.on("printWorkStart",(n,t)=>{let a=JSON.parse(t).deviceName;s.webContents.print({silent:!0,deviceName:a,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}})});const l=new e.BrowserWindow({show:!1,width:360,height:240,webPreferences:{nodeIntegration:!0,contextIsolation:!1}});process.env.VITE_DEV_SERVER_URL?l.loadFile(o.join(__dirname,"../public/tag_print.html")):l.loadFile(o.resolve(__dirname,"../dist/tag_print.html")),e.ipcMain.on("printerTagSync",(n,t)=>{console.log(t),l.webContents.send("getParams",t)}),e.ipcMain.on("printTagStart",(n,t)=>{let a=JSON.parse(t).deviceName;l.webContents.print({silent:!0,deviceName:a,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",(n,t,c)=>{i&&(i.isMinimized()&&i.restore(),i.focus(),i.show())}):e.app.quit(),i.on("close",n=>{n.preventDefault(),i.webContents.send("showCloseDialog")})});e.app.on("window-all-closed",()=>{process.platform!=="darwin"&&e.app.quit()}); diff --git a/package.json b/package.json index a94c5a9..3e86c9e 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "vite-electron", "private": true, - "version": "1.4.7", + "version": "1.4.10", "main": "dist-electron/main.js", "scripts": { "dev": "chcp 65001 && vite", diff --git a/src/App.vue b/src/App.vue index d9a1d80..551daec 100644 --- a/src/App.vue +++ b/src/App.vue @@ -51,7 +51,7 @@ watch(route, (to) => { includeList.push(to.name); } // 需要全屏的路由 - let arr = ["/login", "/device_list", "/add_device", "/add_label", "/webview"]; + let arr = ["/login", "/device_list", "/add_device", "/add_label", "/webview", '/workrecord']; if (arr.includes(to.path)) { hideLeftMenu.value = true; } else { diff --git a/src/api/invoice.js b/src/api/invoice.js new file mode 100644 index 0000000..b3f1117 --- /dev/null +++ b/src/api/invoice.js @@ -0,0 +1,14 @@ +import request_kp from "@/utils/request_kp.js"; + +/** + * 开票人列表 + * @param {*} data + * @returns + */ +export function issuedby(data) { + return request_kp({ + method: "post", + url: "szzpy/issuedby", + data, + }); +} diff --git a/src/api/work/index.js b/src/api/work/index.js index 1dbd049..60154ec 100644 --- a/src/api/work/index.js +++ b/src/api/work/index.js @@ -51,3 +51,16 @@ export function handoverData(params) { params, }); } + +/** + * 打印交班数据 + * @param {*} params + * @returns + */ +export function handoverprint(params) { + return request({ + method: "get", + url: "data/handoverprint", + params, + }); +} diff --git a/src/components/leftMenu.vue b/src/components/leftMenu.vue index 7f2d750..828b8c7 100644 --- a/src/components/leftMenu.vue +++ b/src/components/leftMenu.vue @@ -20,6 +20,12 @@ {{ item.label }} +
+ + + + 交班 +
@@ -27,6 +33,8 @@ 更多
+ + @@ -39,6 +47,7 @@ import { useRoute } from 'vue-router' import { useSocket } from '@/store/socket.js' import more from '@/components/more.vue' import callNumber from './callNumber.vue' +import work from '@/views/work/index.vue' const emits = defineEmits(['connectWsHandle']) @@ -47,6 +56,8 @@ const socketStore = useSocket() const route = useRoute() const moreref = ref(null) const callNumberRef = ref(null) +const workRef = ref(null) + const menus = ref([ { label: '收银', @@ -78,11 +89,11 @@ const menus = ref([ path: '/member', icon: 'User' }, - { - label: '交班', - path: '/work', - icon: 'SwitchButton' - } + // { + // label: '交班', + // path: '/work', + // icon: 'SwitchButton' + // } ]) // 更新叫号记录 diff --git a/src/utils/index.js b/src/utils/index.js index ec37f7a..6ac3825 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -40,9 +40,10 @@ export function clearNoNum(obj) { * 保留小数n位,不进行四舍五入 * num你传递过来的数字, * decimal你保留的几位,默认保留小数后两位 + * isInt 是否保留0 */ -export function formatDecimal(num, decimal = 2) { - num = num.toString(); +export function formatDecimal(num, decimal = 2, isInt = false) { + num = num.toFixed(3).toString(); const index = num.indexOf("."); if (index !== -1) { num = num.substring(0, decimal + index + 1); @@ -50,5 +51,9 @@ export function formatDecimal(num, decimal = 2) { num = num.substring(0); } //截取后保留两位小数 - return parseFloat(num).toFixed(decimal); + if (isInt) { + return parseFloat(num); + } else { + return parseFloat(num).toFixed(decimal); + } } diff --git a/src/utils/request_kp.js b/src/utils/request_kp.js new file mode 100644 index 0000000..9279b87 --- /dev/null +++ b/src/utils/request_kp.js @@ -0,0 +1,61 @@ +import axios from "axios"; +import { ElMessage } from "element-plus"; +import useStorage from "@/utils/useStorage"; +import router from "@/router"; + +const service = axios.create({ + baseURL: + import.meta.env.MODE == "development" + ? "/kp/" + : import.meta.env.VITE_API_KP_URL, + // withCredentials: true, // 跨域请求时发送 cookies + timeout: 5000, // 请求超时 +}); + +// 请求拦截器 +service.interceptors.request.use( + (config) => { + // // 在发送请求之前做些什么 token + // if (useStorage.get("douyin") && useStorage.get("douyin").token) { + // config.headers["bausertoken"] = useStorage.get("douyin").token; + // // config.headers['Content-Type'] = 'application/json' + // } + config.headers["ispc"] = 1; + return config; + }, + (error) => { + // 处理请求错误 + return Promise.reject(error); + } +); + +// 响应拦截器 +service.interceptors.response.use( + (response) => { + // 对响应数据做点什么 + if (+response.status === 200) { + if (+response.data.code == 1) { + return response.data.data; + } else { + // 响应错误 + ElMessage.error(response.data.msg); + return Promise.reject(response.data); + } + } + }, + (error) => { + // 对响应错误做点什么 + if (error.message.indexOf("timeout") != -1) { + ElMessage.error("网络超时"); + } else if (error.message == "Network Error") { + ElMessage.error("网络连接错误"); + } else { + console.log(error); + if (error.response.data) ElMessage.error(error.response.statusText); + else ElMessage.error("接口路径找不到"); + } + return Promise.reject(error); + } +); + +export default service; diff --git a/src/views/login.vue b/src/views/login.vue index 60de3c3..2792464 100644 --- a/src/views/login.vue +++ b/src/views/login.vue @@ -72,6 +72,8 @@ import useStorage from "@/utils/useStorage"; import { douyincheckIn } from "@/api/group"; import { useUser } from "@/store/user.js"; import { useSocket } from "@/store/socket.js"; +import { useGlobal } from '@/store/global.js' +const global = useGlobal() const store = useUser(); const socket = useSocket(); @@ -134,6 +136,7 @@ const submitHandle = () => { clientType: 'pc' }) useStorage.set('douyin', douyin.userInfo) + global.updateData(true) }) .catch((err) => { loading.value = false; @@ -151,7 +154,7 @@ const logout = () => { }; onMounted(() => { - passwordType.icon = Hide + global.updateData(false) }) diff --git a/src/views/order/index.vue b/src/views/order/index.vue index 39ca5a8..71119ef 100644 --- a/src/views/order/index.vue +++ b/src/views/order/index.vue @@ -133,8 +133,9 @@ " type="primary" @click="recharge = true">退单
- 重打收银打票 - 重打标签小票 + + 重打小票 + 重打标签
@@ -277,6 +278,7 @@ @@ -311,7 +349,6 @@ onMounted(() => { .box_content_left_top { display: flex; flex-direction: column; - border-bottom: 1px solid #ccc; padding-bottom: 20px; .box_content_left_top_item { @@ -361,21 +398,17 @@ onMounted(() => { .box_content_right { width: 30%; height: 100%; - background: #fff; margin-left: 10px; - border-radius: 6px; - padding: 10px 12px; position: relative; - - .box_content_right_tiem:nth-child(1) { - margin-top: 0; - } + display: flex; + flex-direction: column; + gap: 10px; .box_content_right_tiem { - margin-top: 10px; display: flex; justify-content: space-between; align-items: center; + padding: 10px; .box_content_right_tiemleft { color: #9e9e9e; @@ -384,11 +417,7 @@ onMounted(() => { } .box_content_right_tiembutton { - position: absolute; - bottom: 10px; - left: 5%; background: #ba5050; - width: 90%; border-radius: 5px; color: #fff; text-align: center; @@ -399,4 +428,44 @@ onMounted(() => { } } } + +.top { + flex: 1; + background-color: #fff; + padding: 10px 0; + border-radius: 6px; +} + +.footer { + padding: 10px; + background: #fff; + border-radius: 6px; +} + +.is_shop { + .button { + flex: 1; + margin-bottom: 10px; + + :deep(.el-checkbox.el-checkbox--large) { + height: var(--el-component-size-large); + background-color: #fff; + } + + :deep(.el-checkbox__inner) { + width: 20px; + height: 20px; + + &::after { + border-width: 2px; + top: 0; + left: 4px; + } + } + + :deep(.el-checkbox__label) { + font-size: var(--el-font-size-base) !important; + } + } +} \ No newline at end of file diff --git a/src/views/work/record.vue b/src/views/work/record.vue index 7f918e0..1acfc94 100644 --- a/src/views/work/record.vue +++ b/src/views/work/record.vue @@ -1,130 +1,132 @@