优化标签小票打印
This commit is contained in:
36
src/App.vue
36
src/App.vue
@@ -2,7 +2,7 @@
|
||||
<el-config-provider size="large">
|
||||
<div class="container">
|
||||
<div class="left" v-if="!hideLeftMenu">
|
||||
<left-menu ref="leftMenuRef" />
|
||||
<left-menu ref="leftMenuRef" @connectWsHandle="initWebSocket()" />
|
||||
</div>
|
||||
<div :class="{ view: !hideLeftMenu }">
|
||||
<!-- <div class="wrapper">
|
||||
@@ -33,8 +33,10 @@ import { dayjs, ElMessage } from "element-plus";
|
||||
import { ipcRenderer } from 'electron'
|
||||
import { scanSendMessage } from '@/api/order/index'
|
||||
import { useGlobal } from '@/store/global.js'
|
||||
import { useSocket } from '@/store/socket.js'
|
||||
|
||||
const global = useGlobal()
|
||||
const socketStore = useSocket()
|
||||
|
||||
const leftMenuRef = ref(null)
|
||||
|
||||
@@ -184,21 +186,21 @@ function checkLabelPrint(props) {
|
||||
let pids = printLabelList.value[0].config.categoryList.map(item => item.id)
|
||||
let labelList = []
|
||||
|
||||
let count = 0
|
||||
let sum = 0
|
||||
// let count = 0
|
||||
// let sum = 0
|
||||
|
||||
// props.carts.map(item => {
|
||||
// if (pids.some(el => el == item.categoryId)) {
|
||||
// for (let i = 0; i < item.number; i++) {
|
||||
// sum++
|
||||
// }
|
||||
// }
|
||||
// })
|
||||
|
||||
props.carts.map(item => {
|
||||
if (pids.some(el => el == item.categoryId)) {
|
||||
for (let i = 0; i < item.number; i++) {
|
||||
sum++
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
props.carts.map(item => {
|
||||
if (pids.some(el => el == item.categoryId)) {
|
||||
for (let i = 0; i < item.number; i++) {
|
||||
count++
|
||||
// count++
|
||||
labelList.push(
|
||||
{
|
||||
outNumber: props.outNumber,
|
||||
@@ -207,7 +209,7 @@ function checkLabelPrint(props) {
|
||||
masterId: props.orderInfo.tableName,
|
||||
deviceName: printLabelList.value[0].config.deviceName,
|
||||
createdAt: dayjs(props.createdAt).format('YYYY-MM-DD HH:mm:ss'),
|
||||
count: `${count}/${sum}`
|
||||
// count: `${count}/${sum}`
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -220,13 +222,15 @@ function checkLabelPrint(props) {
|
||||
|
||||
// 打印标签
|
||||
function printLabel(list) {
|
||||
// console.log(list);
|
||||
if (!checkLocalPrint(printLabelList.value[0].config.deviceName)) {
|
||||
ElMessage.error("本地打印机无法使用,请检查打印机是否正确连接");
|
||||
} else {
|
||||
for (let i = 0; i <= list.length - 1; i++) {
|
||||
// ipcRenderer.send('printerTagSync', JSON.stringify(list[i]))
|
||||
setTimeout(() => {
|
||||
ipcRenderer.send('printerTagSync', JSON.stringify(list[i]))
|
||||
}, i * 1000)
|
||||
}, i * 800)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -243,6 +247,8 @@ function initWebSocket(wsUrl = import.meta.env.VITE_API_WSS) {
|
||||
|
||||
ws.value.onopen = function () {
|
||||
console.log('wss连接成功');
|
||||
socketStore.changeOnline(true)
|
||||
|
||||
// 清除心跳
|
||||
clearInterval(heartbeatTimer.value)
|
||||
heartbeatTimer.value = null
|
||||
@@ -277,6 +283,7 @@ function initWebSocket(wsUrl = import.meta.env.VITE_API_WSS) {
|
||||
// 连接发生错误
|
||||
ws.value.onerror = function () {
|
||||
console.log("WebSocket连接发生错误");
|
||||
socketStore.changeOnline(false)
|
||||
|
||||
// 清除心跳
|
||||
clearInterval(heartbeatTimer.value)
|
||||
@@ -289,6 +296,7 @@ function initWebSocket(wsUrl = import.meta.env.VITE_API_WSS) {
|
||||
// 关闭
|
||||
ws.value.onclose = function (e) {
|
||||
console.log('ws关闭了', e);
|
||||
socketStore.changeOnline(false)
|
||||
|
||||
// 清除心跳
|
||||
clearInterval(heartbeatTimer.value)
|
||||
|
||||
Reference in New Issue
Block a user