feat(pos): print sale receipts over the network transport
This commit is contained in:
parent
aec8e50f54
commit
bee80d8ec8
1 changed files with 32 additions and 0 deletions
|
|
@ -506,6 +506,38 @@ let btDevice = null;
|
|||
let btChar = null;
|
||||
|
||||
async function printThermal(){
|
||||
const settings = window.EposPrint.getSettings();
|
||||
if(settings.type === 'network') return printThermalNetwork(settings);
|
||||
return printThermalBluetooth();
|
||||
}
|
||||
|
||||
async function printThermalNetwork(settings){
|
||||
const btn = document.getElementById('printBtn');
|
||||
const status = document.getElementById('statusText');
|
||||
const errBox = document.getElementById('status');
|
||||
errBox.classList.remove('err');
|
||||
btn.disabled = true;
|
||||
if(!settings.ip){
|
||||
status.textContent = 'Set the printer IP address in Printer settings first.';
|
||||
errBox.classList.add('err');
|
||||
btn.disabled = false;
|
||||
return;
|
||||
}
|
||||
status.textContent = 'Sending to ' + settings.ip + '…';
|
||||
try{
|
||||
const logo = await window.EposPrint.imageToRaster('/wfdash-logo.png', 384).catch(()=>null);
|
||||
const xml = window.EposPrint.buildEposXml(sale, logo);
|
||||
await window.EposPrint.printViaNetwork(settings.ip, xml);
|
||||
status.textContent = 'Printed · ' + settings.ip;
|
||||
}catch(e){
|
||||
status.textContent = 'Print failed: ' + e.message;
|
||||
errBox.classList.add('err');
|
||||
}finally{
|
||||
btn.disabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function printThermalBluetooth(){
|
||||
const btn = document.getElementById('printBtn');
|
||||
const status = document.getElementById('statusText');
|
||||
const errBox = document.getElementById('status');
|
||||
|
|
|
|||
Loading…
Reference in a new issue