优化标签小票打印

This commit is contained in:
gyq
2024-06-24 16:43:54 +08:00
parent 408e0e44c4
commit 87627e7b35
13 changed files with 220 additions and 318 deletions

View File

@@ -169,27 +169,27 @@ function checkLocalPrint(deviceName) {
// 检测是否打印标签小票
function checkLabelPrint(props) {
console.log(props);
// console.log(props);
if (!checkLocalPrint(printLabelList.value[0].config.deviceName)) {
ElMessage.error("本地打印机无法使用请检查打印机是否正确连接1");
} else {
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,
@@ -198,7 +198,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}`
}
)
}
@@ -210,17 +210,18 @@ function checkLabelPrint(props) {
}
// 打印标签
const printLabel = (list) => {
const printLabel = _.throttle(function (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)
}
}
}
}, 1500, { leading: true, trailing: false })
// 打印操作
async function printHandle() {