refactor:alteração modal de obs do pedido na tela viewcomanda

This commit is contained in:
2025-06-28 18:54:44 -03:00
parent 8cb63832e5
commit 7dd76db5ba
4 changed files with 58 additions and 43 deletions

View File

@@ -197,21 +197,6 @@ Detalhes {{comanda.name}}
<dialog id="modal-obs" style="display: none;">
<article>
<h2>Observação do Pedido</h2>
<p>Observações do pedido que serão enviadas para o preparo na cozinha.</p>
<textarea placeholder="Ex.: pedido sem cebola. para viagem." name="obs" id="obs"></textarea>
<div>
<div style="display: flex;gap: 10px;">
<button type="submit" class="btn-primary" onclick="addOrder()" >OK</button>
<button type="button" class="btn-cancel" onclick="closeModalObs()">Cancela</button>
</div>
</article>
</dialog>
<dialog id="payment-comanda" style="display: none;" > <dialog id="payment-comanda" style="display: none;" >
<article> <article>
<form action="{% url 'paymentComanda' comanda.id %}" method="post"> <form action="{% url 'paymentComanda' comanda.id %}" method="post">

Binary file not shown.

View File

@@ -182,6 +182,8 @@ function openFullscreen() {
var feedbackMsg = Swal.fire({ var feedbackMsg = Swal.fire({
color: 'white', color: 'white',
title: message, title: message,
// toast: true,
// position: 'top',
text: subMessage || '', text: subMessage || '',
icon: icon || 'info', icon: icon || 'info',
background: 'rgb(23, 38, 54)', background: 'rgb(23, 38, 54)',

View File

@@ -6,7 +6,7 @@ function openModal() {
if (textField) { if (textField) {
setTimeout(() => { setTimeout(() => {
textField.focus(); textField.focus();
}, 500); // 50ms de delay (ajuste conforme necessário) }, 500);
} }
textField.value = ''; textField.value = '';
} }
@@ -22,9 +22,6 @@ function openModalAlter() {
document.getElementById('Modal-alter-comanda').style.display = 'block'; document.getElementById('Modal-alter-comanda').style.display = 'block';
var name = document.getElementById('name-comanda').innerText.replace('Nome: ','').replace(' | ', '') var name = document.getElementById('name-comanda').innerText.replace('Nome: ','').replace(' | ', '')
var mesa = document.getElementById('h-mesaId').value var mesa = document.getElementById('h-mesaId').value
console.log(name)
console.log(mesa)
var fildName = document.getElementById('nameComanda') var fildName = document.getElementById('nameComanda')
fildName.value = name fildName.value = name
var fildMesa = document.getElementById('select-mesa') var fildMesa = document.getElementById('select-mesa')
@@ -34,12 +31,56 @@ function openModalAlter() {
function closeModalAlter() { function closeModalAlter() {
document.getElementById('Modal-alter-comanda').style.display = 'none'; document.getElementById('Modal-alter-comanda').style.display = 'none';
} }
function openModalObs(id) { async function openModalObs(id) {
document.getElementById('modal-obs').style.display = 'block'; var obsPrint = document.getElementById(id+'-obsOrder')
idd = document.getElementById('id-temp').value = id; var order = obsPrint.value.split('|');
obs = document.getElementById('obs').value; const inputOptions = new Promise((resolve) => {
textField = document.getElementById('obs')
textField.focus() resolve({
"Para viagem": "Para Viagem",
"Meia Porção": "Meia Porção",
"Com Leite": "Com Leite",
"Sem Cebola": "Sem Cebola",
"Com Ovo": "Com Ovo",
});
});
const { value: obs } = await Swal.fire({
title: "Observações rápidas",
input: "radio",
color: 'white',
confirmButtonText: "Enviar ou Digitar Outra",
showCancelButton: true,
cancelButtonText: "Cancelar",
inputOptions,
theme: "dark",
inputValidator: async (value) => {
if (!value) {
const { value: text } = await Swal.fire({
input: "textarea",
title: "Observação do Pedido",
inputValue:order[1],
theme: "dark",
background: 'rgb(23, 38, 54)',
confirmButtonColor: 'linear-gradient(145deg, #1E2A3B, #2C3E50)',
color: 'white',
showCancelButton: true,
inputAttributes: {
"aria-label": "Type your message here"
}});
if (text) {
addOrder(id, text)
}
}
}
});
if (obs) {
addOrder(id, obs)
}
} }
@@ -66,20 +107,14 @@ function close_modal_conta_client() {
document.getElementById('conta-cliente').style.display = 'none'; document.getElementById('conta-cliente').style.display = 'none';
} }
function close_modal_payment_parcial() { function close_modal_payment_parcial() {
document.getElementById('payment-parcial').style.display = 'none'; document.getElementById('payment-parcial').style.display = 'none';
} }
function close_modal_payment_comanda() { function close_modal_payment_comanda() {
document.getElementById('payment-comanda').style.display = 'none'; document.getElementById('payment-comanda').style.display = 'none';
} }
function closeModalObs() {
document.getElementById('modal-obs').style.display = 'none';
}
function imprimirFichas() { function imprimirFichas() {
const element = document.getElementById("list-products-comanda"); const element = document.getElementById("list-products-comanda");
const style = `<style> const style = `<style>
@@ -140,7 +175,6 @@ function printOrder(id) {
} }
function imprimirConta() { function imprimirConta() {
reloadPage(); reloadPage();
const element = document.getElementById("list-products-comanda"); const element = document.getElementById("list-products-comanda");
@@ -265,14 +299,12 @@ function troco(){
} }
function addOrder(){ function addOrder(id, obs){
var obs = document.getElementById('obs')
id = document.getElementById('id-temp').value
var obsPrint = document.getElementById(id+'-obsOrder') var obsPrint = document.getElementById(id+'-obsOrder')
var order = obsPrint.value.split('|'); var order = obsPrint.value.split('|');
var newOrder = ''; var newOrder = '';
fetch(`/comandas/editOrders/${id}/${obs.value}`, { fetch(`/comandas/editOrders/${id}/${obs}`, {
method: 'POST', method: 'POST',
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
@@ -281,22 +313,18 @@ function addOrder(){
.then(response => response.json()) .then(response => response.json())
.then(data => { .then(data => {
if(data.status == 'ok'){ if(data.status == 'ok'){
showToast('✅Pedido atualizado com sucesso!😁','success')
obs.value = ''
order[1] = data.obs; order[1] = data.obs;
for(var i = 0; i < order.length; i++){ for(var i = 0; i < order.length; i++){
newOrder += order[i] + '|'; newOrder += order[i] + '|';
} }
obsPrint.value = newOrder; obsPrint.value = newOrder;
document.getElementById('modal-obs').style.display = 'none'; feedback('Obsevação alterada com sucesso!😁','success');
} }
}) })
.catch(error => { .catch(error => {
console.log(error) console.log(error)
showToast('❌Ocorreu um erro!😢','error') feedback('❌Ocorreu um erro!😢','error','Erro: ' + error.message);
}); });
} }