feat(pos/workshop): add 80mm thermal ticket printing for service orders
- Add generate_service_order_ticket() in thermal_printer.py with ESC/POS commands for 58mm and 80mm printers. - Add POST /pos/api/service-orders/:id/print endpoint returning raw bytes or JSON for browser rendering. - Extend printer.js with printServiceOrder() using WebUSB/Web Serial. - Add Imprimir orden button in workshop.js detail modal. - Update FASES_IMPLEMENTADAS.md.
This commit is contained in:
@@ -134,6 +134,31 @@ window.NexusPrinter = (function () {
|
||||
return sendRaw(new Uint8Array(buf));
|
||||
}
|
||||
|
||||
/**
|
||||
* Print a workshop service order ticket.
|
||||
* @param {number} soId
|
||||
* @param {number} [width=80] — 58 or 80 mm
|
||||
* @returns {Promise<boolean>}
|
||||
*/
|
||||
async function printServiceOrder(soId, width) {
|
||||
width = width || 80;
|
||||
const token = localStorage.getItem('pos_token');
|
||||
const resp = await fetch('/pos/api/service-orders/' + soId + '/print', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Authorization': 'Bearer ' + token,
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({ printer_type: 'escpos_raw', width: width })
|
||||
});
|
||||
if (!resp.ok) {
|
||||
console.error('[NexusPrinter] backend error', resp.status);
|
||||
return false;
|
||||
}
|
||||
const buf = await resp.arrayBuffer();
|
||||
return sendRaw(new Uint8Array(buf));
|
||||
}
|
||||
|
||||
// ── Persistence helpers ────────────────────────
|
||||
|
||||
function _save() {
|
||||
@@ -147,6 +172,7 @@ window.NexusPrinter = (function () {
|
||||
disconnect: disconnect,
|
||||
isConnected: isConnected,
|
||||
sendRaw: sendRaw,
|
||||
printSale: printSale
|
||||
printSale: printSale,
|
||||
printServiceOrder: printServiceOrder
|
||||
};
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user