fix: capabilities Tauri 2 dialog; imprimir_recibo {data}; cartoes.map guard; debug logs
This commit is contained in:
@@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"identifier": "default",
|
||||||
|
"description": "Default capabilities for Fechamento de Caixa",
|
||||||
|
"windows": ["main"],
|
||||||
|
"permissions": [
|
||||||
|
"core:default",
|
||||||
|
"shell:allow-open",
|
||||||
|
"dialog:allow-message",
|
||||||
|
"dialog:allow-confirm",
|
||||||
|
"dialog:allow-ask",
|
||||||
|
"dialog:allow-save",
|
||||||
|
"dialog:allow-open",
|
||||||
|
"fs:default",
|
||||||
|
"fs:allow-app-read",
|
||||||
|
"fs:allow-app-write",
|
||||||
|
"fs:allow-appdata-read",
|
||||||
|
"fs:allow-appdata-write",
|
||||||
|
"fs:allow-appconfig-read",
|
||||||
|
"fs:allow-appconfig-write",
|
||||||
|
"fs:allow-applocaldata-read",
|
||||||
|
"fs:allow-applocaldata-write"
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
"app": {
|
"app": {
|
||||||
"windows": [
|
"windows": [
|
||||||
{
|
{
|
||||||
"title": "Fechamento de Caixa — O Frangão",
|
"title": "Fechamento de Caixa \u2014 O Frang\u00e3o",
|
||||||
"width": 1100,
|
"width": 1100,
|
||||||
"height": 780,
|
"height": 780,
|
||||||
"minWidth": 900,
|
"minWidth": 900,
|
||||||
@@ -22,13 +22,18 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"security": {
|
"security": {
|
||||||
"csp": null
|
"csp": null,
|
||||||
|
"capabilities": [
|
||||||
|
"default"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"withGlobalTauri": true
|
"withGlobalTauri": true
|
||||||
},
|
},
|
||||||
"bundle": {
|
"bundle": {
|
||||||
"active": true,
|
"active": true,
|
||||||
"targets": ["nsis"],
|
"targets": [
|
||||||
|
"nsis"
|
||||||
|
],
|
||||||
"icon": [
|
"icon": [
|
||||||
"icons/32x32.png",
|
"icons/32x32.png",
|
||||||
"icons/128x128.png",
|
"icons/128x128.png",
|
||||||
@@ -37,7 +42,9 @@
|
|||||||
"icons/icon.ico"
|
"icons/icon.ico"
|
||||||
],
|
],
|
||||||
"windows": {
|
"windows": {
|
||||||
"webviewInstallMode": { "type": "embedBootstrapper" }
|
"webviewInstallMode": {
|
||||||
|
"type": "embedBootstrapper"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"resources": {
|
"resources": {
|
||||||
"../src/*": "./"
|
"../src/*": "./"
|
||||||
|
|||||||
+11
-5
@@ -1520,7 +1520,7 @@ async function tauriRecibo() {
|
|||||||
|
|
||||||
// Tenta ESC/POS via Tauri primeiro; se falhar, abre preview
|
// Tenta ESC/POS via Tauri primeiro; se falhar, abre preview
|
||||||
try {
|
try {
|
||||||
return await window.__TAURI__.core.invoke('imprimir_recibo', { estado: JSON.stringify(data) });
|
return await window.__TAURI__.core.invoke('imprimir_recibo', { data: JSON.stringify(data) });
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
console.warn('ESC/POS falhou, abrindo preview:', e);
|
console.warn('ESC/POS falhou, abrindo preview:', e);
|
||||||
openPrintPreview(data);
|
openPrintPreview(data);
|
||||||
@@ -1539,13 +1539,17 @@ async function tauriCarregarRascunho() {
|
|||||||
|
|
||||||
// ─── Confirm Modal ────────────────────────────────────────────────────────
|
// ─── Confirm Modal ────────────────────────────────────────────────────────
|
||||||
function openConfirmModal() {
|
function openConfirmModal() {
|
||||||
|
console.log('[DEBUG] openConfirmModal chamado');
|
||||||
const operador = val('f-operador').trim();
|
const operador = val('f-operador').trim();
|
||||||
const turno = val('f-turno').trim();
|
const turno = val('f-turno').trim();
|
||||||
const loja = val('f-loja').trim();
|
const loja = val('f-loja').trim();
|
||||||
|
console.log('[DEBUG] openConfirmModal campos:', {operador, turno, loja});
|
||||||
if (!operador || !turno || !loja) {
|
if (!operador || !turno || !loja) {
|
||||||
|
console.log('[DEBUG] openConfirmModal: campos faltando, alert');
|
||||||
alert('⚠️ Preencha Operador, Turno e Loja antes de enviar.');
|
alert('⚠️ Preencha Operador, Turno e Loja antes de enviar.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
console.log('[DEBUG] openConfirmModal: campos OK, montando modal');
|
||||||
// Build summary
|
// Build summary
|
||||||
const cartCred = estado.cartoes.credito.reduce((s,r) => s+(r.valor||0), 0);
|
const cartCred = estado.cartoes.credito.reduce((s,r) => s+(r.valor||0), 0);
|
||||||
const cartDeb = estado.cartoes.debito.reduce((s,r) => s+(r.valor||0), 0);
|
const cartDeb = estado.cartoes.debito.reduce((s,r) => s+(r.valor||0), 0);
|
||||||
@@ -1580,6 +1584,7 @@ function openConfirmModal() {
|
|||||||
<div>🎯 Saldo Esperado (contado): <strong>${fmt(saldoEsp)}</strong></div>
|
<div>🎯 Saldo Esperado (contado): <strong>${fmt(saldoEsp)}</strong></div>
|
||||||
<div style="margin-top:4px">📐 Diferença: <strong style="color:${diffClass}">${fmt(diferenca)}</strong></div>
|
<div style="margin-top:4px">📐 Diferença: <strong style="color:${diffClass}">${fmt(diferenca)}</strong></div>
|
||||||
<div style="margin-top:4px;font-size:10px;color:#888">ID: ${estado.loja}_${estado.data}_${estado.operador}</div>`;
|
<div style="margin-top:4px;font-size:10px;color:#888">ID: ${estado.loja}_${estado.data}_${estado.operador}</div>`;
|
||||||
|
console.log('[DEBUG] openConfirmModal: tentando abrir modal');
|
||||||
document.getElementById('modal-confirm').classList.add('open');
|
document.getElementById('modal-confirm').classList.add('open');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1791,10 +1796,11 @@ document.getElementById('btn-anterior').addEventListener('click', async () => {
|
|||||||
estado.cancelamentos = rascunho.cancelamentos.map(c => ({ numero: c.numero || '', valor: parseNum(c.valor) || 0, motivo: c.motivo || '' }));
|
estado.cancelamentos = rascunho.cancelamentos.map(c => ({ numero: c.numero || '', valor: parseNum(c.valor) || 0, motivo: c.motivo || '' }));
|
||||||
}
|
}
|
||||||
if (rascunho.cartoes) {
|
if (rascunho.cartoes) {
|
||||||
estado.cartoes.credito = (rascunho.cartoes.credito || []).map(v => ({ valor: parseNum(v) || 0 }));
|
const norm = (arr) => Array.isArray(arr) ? arr.map(v => ({ valor: (typeof v === 'object' && v !== null) ? (parseNum(v.valor) || 0) : (parseNum(v) || 0) })) : [];
|
||||||
estado.cartoes.debito = (rascunho.cartoes.debito || []).map(v => ({ valor: parseNum(v) || 0 }));
|
estado.cartoes.credito = norm(rascunho.cartoes.credito);
|
||||||
estado.cartoes.alimentacao = (rascunho.cartoes.alimentacao || []).map(v => ({ valor: parseNum(v) || 0 }));
|
estado.cartoes.debito = norm(rascunho.cartoes.debito);
|
||||||
estado.cartoes.pix = (rascunho.cartoes.pix || []).map(v => ({ valor: parseNum(v) || 0 }));
|
estado.cartoes.alimentacao = norm(rascunho.cartoes.alimentacao);
|
||||||
|
estado.cartoes.pix = norm(rascunho.cartoes.pix);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
estado.despesas = []; estado.sangrias = []; estado.pixcnpj = [];
|
estado.despesas = []; estado.sangrias = []; estado.pixcnpj = [];
|
||||||
|
|||||||
Reference in New Issue
Block a user