优化打印 订单新增桌号和时间筛选

This commit is contained in:
gyq 2024-07-16 09:13:02 +08:00
parent 38366601d4
commit 5e7935bb53
14 changed files with 355 additions and 67 deletions

View File

@ -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'
@ -22,7 +22,7 @@ VITE_API_PHP_URL = 'http://192.168.2.33:1666/index.php/api'
# VITE_API_URL = 'http://192.168.2.41: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'
# VITE_API_URL = 'https://cashierclient.sxczgkj.cn/cashier-client'

View File

@ -2,16 +2,16 @@
ENV = production
# 正式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'
# 测试 php
VITE_API_PHP_URL = 'http://192.168.2.33:1666/index.php/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/'
# VITE_API_URL = 'https://cashierclient.sxczgkj.cn/cashier-client/'

View File

@ -1 +1,201 @@
"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()});
"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();
});

View File

@ -1,7 +1,7 @@
{
"name": "vite-electron",
"private": true,
"version": "1.3.56",
"version": "1.3.60",
"main": "dist-electron/main.js",
"scripts": {
"dev": "chcp 65001 && vite",

View File

@ -171,8 +171,8 @@ const updateInfo = _.throttle(function () {
// let info = navigator.connection
console.log(isOnLine);
// console.log(info);
if (store.userInfo && store.userInfo.shopId) {
if (isOnLine) {
if (store.userInfo && store.userInfo.shopId) {
if (isOnLine) {
console.log('有网了重新连接ws~');
socket.init();
} else {

View File

@ -1,5 +1,5 @@
<template>
<el-dialog width="400" v-model="dialogVisible" style="padding: 0; " title="锁屏" :close-on-click-modal="false" :show-close="false">
<el-dialog width="400" v-model="dialogVisible" style="padding: 0; " title="锁屏" :close-on-click-modal="false" :show-close="false">
<div class="drawerbox_box">
<el-input v-model="loginName" placeholder="请输入登录账号" />
<el-button style="width: 100%; margin-top: 20px;" type="primary" @click="loginNameclick">确认</el-button>

View File

@ -58,7 +58,10 @@ export const usePrint = defineStore({
},
// 打印标签小票
labelPrint(props) {
if (this.checkLocalPrint(this.deviceLableList[0].config.deviceName)) {
if (
this.deviceLableList.length &&
this.checkLocalPrint(this.deviceLableList[0].config.deviceName)
) {
let pids = this.deviceLableList[0].config.categoryList.map(
(item) => item.id
);
@ -94,6 +97,8 @@ export const usePrint = defineStore({
});
// 执行打印操作
this.startLabelPrint();
} else {
console.log("没有打印机");
}
},
// 开始打印标签数据

View File

@ -14,6 +14,7 @@ export const useSocket = defineStore({
ws: null, // websocket实例
uuid: "", // 长连接唯一id
heartbeatTimer: null, // 心跳计时器
orderList: [],
}),
actions: {
// 创建uuid
@ -92,7 +93,14 @@ export const useSocket = defineStore({
// 接收订单消息,打印小票
// printBill(data)
// 打印标签小票
printStore.labelPrint(data);
if (!this.orderList.some((el) => el == data.orderInfo.orderNo)) {
console.log("打印", data);
printStore.labelPrint(data);
this.orderList.push(data.orderInfo.orderNo);
if (this.orderList.length > 30) {
this.orderList.splice(0, 1);
}
}
} else if (data.type == "heartbeat") {
console.log("接收心跳");
}

View File

@ -143,6 +143,9 @@ import { ElMessage } from "element-plus";
import { tbPrintMachinePost, tbPrintMachineDetail } from "@/api/device";
import { useUser } from "@/store/user.js";
import { Loading } from "element-plus/es/components/loading/src/service";
import { usePrint } from "@/store/print.js";
const printStore = usePrint();
const store = useUser();
const router = useRouter();
@ -236,6 +239,9 @@ async function submitHandle() {
await tbPrintMachinePost(form.value, form.value.id ? "put" : "post");
Loading.value = false;
ElMessage.success(form.value.id ? "编辑成功" : "添加成功");
printStore.init();
router.back();
} catch (error) {
console.log(error);

View File

@ -121,6 +121,9 @@ import { useUser } from "@/store/user.js";
import { Loading } from "element-plus/es/components/loading/src/service";
import classify from "@/components/classify/index.vue";
import QRCode from 'qrcode'
import { usePrint } from "@/store/print.js";
const printStore = usePrint();
const store = useUser();
@ -193,6 +196,7 @@ async function submitHandle() {
await tbPrintMachinePost(form.value, form.value.id ? "put" : "post");
Loading.value = false;
ElMessage.success(form.value.id ? "编辑成功" : "添加成功");
printStore.init();
router.back();
} catch (error) {
console.log(error);

View File

@ -1,10 +1,7 @@
<template>
<div class="device_container">
<div class="header" @click="router.back()">
<el-icon
style="position: relative; top: 2px; margin-right: 4px"
size="22"
>
<el-icon style="position: relative; top: 2px; margin-right: 4px" size="22">
<ArrowLeft />
</el-icon>
<el-text>设备管理</el-text>
@ -16,10 +13,7 @@
<div class="item" v-for="item in list" :key="item.id">
<div class="left">
<div class="icon">
<el-image
:src="icons[item.subType]"
style="width: 40px; height: 40px"
></el-image>
<el-image :src="icons[item.subType]" style="width: 40px; height: 40px"></el-image>
</div>
<div class="info">
<div class="name">{{ item.name }}</div>
@ -28,27 +22,16 @@
</div>
<div class="right">
<div class="switch">
<el-switch
v-model="item.status"
inline-prompt
active-text="开"
inactive-text="关"
:active-value="1"
:inactive-value="0"
width="90"
@change="statusChange($event, item)"
/>
<el-switch v-model="item.status" inline-prompt active-text="" inactive-text="" :active-value="1"
:inactive-value="0" width="90" @change="statusChange($event, item)" />
</div>
<div class="editor">
<el-text
type="primary"
@click="
router.push({
name: deviceRoute[item.subType],
query: { id: item.id },
})
"
>
<el-text type="primary" @click="
router.push({
name: deviceRoute[item.subType],
query: { id: item.id },
})
">
编辑
</el-text>
<el-text type="primary" @click="showDelete(item)">删除</el-text>
@ -89,10 +72,7 @@
<div class="menu_wrap">
<div class="row" @click="router.push({ name: 'add_device' })">
<div class="icon" style="background-color: var(--primary-color)">
<el-image
:src="icons.cash"
style="width: 36px; height: 36px"
></el-image>
<el-image :src="icons.cash" style="width: 36px; height: 36px"></el-image>
</div>
<div class="info">
<div class="name">添加小票打印机</div>
@ -101,10 +81,7 @@
</div>
<div class="row" @click="router.push({ name: 'add_label' })">
<div class="icon" style="background-color: #79c3d5">
<el-image
:src="icons.label"
style="width: 38px; height: 38px"
></el-image>
<el-image :src="icons.label" style="width: 38px; height: 38px"></el-image>
</div>
<div class="info">
<div class="name">添加标签打印机</div>
@ -113,10 +90,7 @@
</div>
<div class="row">
<div class="icon" style="background-color: #8fc783">
<el-image
:src="icons.kitchen"
style="width: 44px; height: 44px"
></el-image>
<el-image :src="icons.kitchen" style="width: 44px; height: 44px"></el-image>
</div>
<div class="info">
<div class="name">添加出品打印机</div>
@ -131,11 +105,7 @@
<template #footer>
<div class="dialog-footer">
<el-button @click="dialogVisible = false">取消</el-button>
<el-button
type="primary"
:loading="delLoading"
@click="tbPrintMachineDeleteAjax"
>
<el-button type="primary" :loading="delLoading" @click="tbPrintMachineDeleteAjax">
确定
</el-button>
</div>
@ -154,6 +124,9 @@ import { useRouter } from "vue-router";
import { useUser } from "@/store/user.js";
import { ElMessage } from "element-plus";
import icons from "./icons";
import { usePrint } from "@/store/print.js";
const printStore = usePrint();
const store = useUser();
const router = useRouter();
@ -192,6 +165,7 @@ async function tbPrintMachineDeleteAjax() {
dialogVisible.value = false;
ElMessage.success("删除成功");
tbPrintMachineGetAjax();
printStore.init();
} catch (error) {
console.log(error);
}
@ -220,9 +194,11 @@ onMounted(() => {
.dialog_content {
font-size: var(--el-font-size-base);
}
.dialog-footer {
padding: 0 var(--el-font-size-base) var(--el-font-size-base);
}
.device_container {
width: 100vw;
height: 100vh;

View File

@ -6,8 +6,8 @@
<div class="demo_tabs_boxitem_one">
<div class=""
style="width: 100px; height: 70px;border-radius: 10px; background:rgb(186 200 239); display: flex; justify-content: center; align-items: center;">
<div>{{ item.zdNo || "pos" }}</div>
style="width: 100px; height: 70px;border-radius: 4px; background:rgb(186 200 239); display: flex; justify-content: center; align-items: center;">
<div>{{ item.tableName || "pos" }}</div>
</div>
<!-- <el-image style="width: 100px; height: 70px;border-radius: 10px;" :src="item.imgUrl" fit="scale-down" /> -->
<div class="demo_tabs_boxitem_oneone">
@ -64,17 +64,15 @@ const clickitemboxshow = (e) => {
<style scoped lang="scss">
.demo_tabs_box {
width: 100%;
padding: 10px 20px;
height: 82%;
overflow: auto;
.demo_tabs_boxitem {
width: 100%;
padding: 6px 16px;
border-radius: 6px;
padding: 10px 0;
display: flex;
justify-content: space-between;
border-bottom: 1px solid #ccc;
border-bottom: 1px solid #ececec;
position: relative;
.demo_tabs_boxitem_oneyt {

View File

@ -0,0 +1,78 @@
<template>
<el-date-picker v-model="dateVlaue" type="daterange" :editable="false" :shortcuts="shortcuts" range-separator=""
start-placeholder="开始时间" end-placeholder="结束时间" :clearable="false" @change="dateConfirm" />
</template>
<script setup>
import { onMounted, ref } from 'vue'
import { dayjs } from 'element-plus'
const emits = defineEmits(['success'])
const shortcuts = [
{
text: '今天',
value: () => {
return [
dayjs()
.startOf("day"),
dayjs()
.endOf("day")
]
},
},
{
text: '本月',
value: () => {
return [
dayjs()
.startOf("month"),
dayjs()
.endOf("month")
]
},
},
{
text: '最近三个月',
value: () => {
return [
dayjs()
.add(-3, "M"),
dayjs()
.endOf("month")
]
},
},
{
text: '本年',
value: () => {
return [
dayjs()
.startOf("year"),
dayjs()
.endOf("year")
]
},
},
]
const dateVlaue = ref([dayjs(), dayjs()])
const format = ["YYYY-MM-DD 00:00:00", "YYYY-MM-DD 23:59:59"];
//
function dateConfirm(value) {
// console.log(value);
emits('success', [
dayjs(value[0]).format(format[0]),
dayjs(value[1]).format(format[1]),
])
}
onMounted(() => {
//
emits('success', [
dayjs(dateVlaue[0]).format(format[0]),
dayjs(dateVlaue[1]).format(format[1]),
])
})
</script>

View File

@ -5,8 +5,9 @@
<el-tab-pane label="全部" name="">
<div class="demo_tabs_div">
<el-input v-model="ordereData.orderNo" placeholder="请输入订单号查询" @input="inputChange" clearable
@focus="global.updateData(false)" @blur="global.updateData(true)" />
@focus="global.updateData(false)" @blur="global.updateData(true)" style="width: 50%;" />
<!-- <el-button style="margin-left: 10px;" type="primary" @click="onSubmit">搜索</el-button> -->
<dateRange @success="dateConfirm" />
</div>
<add :loading="loadingboxshow" :ordereData="ordereData" @emititemboxshow="emititemboxshow"
v-if="ordereData.list.length">
@ -279,6 +280,7 @@ import add from "@/views/order/components/add.vue";
import cashTable from "@/views/order/components/cashTable.vue";
import { clearNoNum } from "@/utils";
import md5 from "js-md5";
import dateRange from './components/dateRange.vue'
import { useGlobal } from "@/store/global.js";
@ -313,6 +315,13 @@ const handlerecharge = () => {
const buttonloading = ref(); //loading
//
function dateConfirm(time) {
ordereData.startTime = time[0]
ordereData.endTime = time[1]
asyncorderfindOrder();
}
//
async function passwordSuccess(pwd) {
try {
@ -533,6 +542,8 @@ const ordereData = reactive({
status: "",
total: "",
orderNo: "",
startTime: '',
endTime: ''
});
const asyncorderfindOrder = async () => {
//
@ -543,6 +554,8 @@ const asyncorderfindOrder = async () => {
size: ordereData.size,
page: ordereData.page,
orderNo: ordereData.orderNo,
startTime: ordereData.startTime,
endTime: ordereData.endTime
});
ordereData.total = res.total;
ordereData.list = res.list;
@ -582,7 +595,6 @@ const callNumberHandle = async () => {
onMounted(() => {
// resetMembrform.value = { ...membrform.value }
asyncorderfindOrder();
});
</script>
@ -643,6 +655,7 @@ onMounted(() => {
.demo_tabs_div {
padding: 0 20px;
display: flex;
gap: 10px;
}
.demo_tabs_box {