廖井涛
2025-12-02 fd2ec4214c6f8456b957c3545e7d67bcdbbb9985
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/**
 * Queue hook
 * 打印队列方法
 */
export default function QueuePrinter(list,hiprintTemplate,columnsNum,printer){
    const queue = JSON.parse(JSON.stringify(list));
    // 添加打印任务
    this.printJob = function(job) {
        queue.push(job);
    };
 
    // 模拟打印
    this.tick = setInterval(()=>{
 
                if(typeof queue === 'object' && Array.isArray(queue)){
                    if (queue.length > 0) {hiprintTemplate.value.print2(queue[0],{printer:printer})
                        queue.shift(); // 打印任务,并从队列中移除
                    }else{
                        clearInterval(this.tick)
                    }
                }else{
                    if (queue.table.length > 0) {
                        hiprintTemplate.value.print2({table:queue.table.slice(0, columnsNum)})
                        queue.table.splice(0, columnsNum);
                    }else{
                        clearInterval(this.tick)
                    }
                }
 
        },
        500)
};