优化打印标签逻辑
This commit is contained in:
@@ -314,9 +314,19 @@ function checkLabelPrint(props) {
|
||||
} else {
|
||||
let pids = printLabelList.value[0].config.categoryList.map(item => item.id)
|
||||
let labelList = []
|
||||
let count = 0
|
||||
let sum = 0
|
||||
|
||||
props.skuInfos.map(item => {
|
||||
for (let i = 0; i < item.num; i++) {
|
||||
sum++
|
||||
}
|
||||
})
|
||||
|
||||
props.skuInfos.map(item => {
|
||||
if (pids.some(el => el == item.categoryId)) {
|
||||
for (let i = 0; i < item.num; i++) {
|
||||
count++
|
||||
labelList.push(
|
||||
{
|
||||
outNumber: props.outNumber,
|
||||
@@ -324,7 +334,8 @@ function checkLabelPrint(props) {
|
||||
skuName: item.productSkuName,
|
||||
masterId: props.tableName,
|
||||
deviceName: printLabelList.value[0].config.deviceName,
|
||||
createdAt: dayjs(props.createAt).format('YYYY-MM-DD HH:mm:ss')
|
||||
createdAt: dayjs(props.createAt).format('YYYY-MM-DD HH:mm:ss'),
|
||||
count: `${count}/${sum}`
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -335,28 +346,13 @@ function checkLabelPrint(props) {
|
||||
}
|
||||
|
||||
// 打印标签
|
||||
let labelCount = ref(0)
|
||||
let labelPrintTimer = ref(null)
|
||||
const printLabel = lodash.throttle(function (list) {
|
||||
// console.log('printLabel===', list);
|
||||
if (!checkLocalPrint(printLabelList.value[0].config.deviceName)) {
|
||||
ElMessage.error("本地打印机无法使用,请检查打印机是否正确连接");
|
||||
} else {
|
||||
clearInterval(labelPrintTimer.value)
|
||||
labelPrintTimer.value = null
|
||||
labelCount.value = 0
|
||||
labelPrintTimer.value = setInterval(() => {
|
||||
// console.log('labelCount', labelCount.value);
|
||||
list[labelCount.value].count = `${list.length - labelCount.value}/${list.length}`
|
||||
ipcRenderer.send('printerTagSync', JSON.stringify(list[labelCount.value]))
|
||||
labelCount.value++
|
||||
console.log(labelCount.value);
|
||||
if (labelCount.value > list.length - 1) {
|
||||
clearInterval(labelPrintTimer.value)
|
||||
labelPrintTimer.value = null
|
||||
labelCount.value = 0
|
||||
}
|
||||
}, 1000)
|
||||
list.map(item => {
|
||||
ipcRenderer.send('printerTagSync', JSON.stringify(item))
|
||||
})
|
||||
}
|
||||
}, 1500, { leading: true, trailing: false })
|
||||
|
||||
|
||||
Reference in New Issue
Block a user