Update script.js
Browse files
script.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
| 1 |
-
// Script para gestión de comandas en un bar
|
| 2 |
-
|
| 3 |
const app = document.getElementById('app');
|
| 4 |
let mesas = [];
|
| 5 |
|
|
@@ -105,6 +103,24 @@ function gestionarMesa(index) {
|
|
| 105 |
</div>
|
| 106 |
`;
|
| 107 |
opcionesContainer.appendChild(opcionDiv);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
});
|
| 109 |
|
| 110 |
const confirmarButton = document.createElement('button');
|
|
@@ -157,11 +173,7 @@ function gestionarMesa(index) {
|
|
| 157 |
}
|
| 158 |
|
| 159 |
function generarTicket(mesa, total) {
|
| 160 |
-
const ticketContent = `
|
| 161 |
-
Mesa ${mesa.numero}\n
|
| 162 |
-
${mesa.pedidos.map(p => `${p.item} (${p.opcion}) x${p.cantidad} - €${(p.precio * p.cantidad).toFixed(2)}`).join('\n')}
|
| 163 |
-
\nTotal: €${total.toFixed(2)}
|
| 164 |
-
`;
|
| 165 |
|
| 166 |
const qrCodeContainer = document.createElement('div');
|
| 167 |
qrCodeContainer.id = 'qrcode';
|
|
@@ -183,3 +195,4 @@ function generarTicket(mesa, total) {
|
|
| 183 |
// Inicializar la aplicación
|
| 184 |
render();
|
| 185 |
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
const app = document.getElementById('app');
|
| 2 |
let mesas = [];
|
| 3 |
|
|
|
|
| 103 |
</div>
|
| 104 |
`;
|
| 105 |
opcionesContainer.appendChild(opcionDiv);
|
| 106 |
+
|
| 107 |
+
// Añadir los controladores de cantidad
|
| 108 |
+
const cantidadControl = opcionDiv.querySelector('.cantidad-controls');
|
| 109 |
+
const cantidadSpan = cantidadControl.querySelector('.cantidad');
|
| 110 |
+
|
| 111 |
+
cantidadControl.querySelector('.increase').onclick = () => {
|
| 112 |
+
let cantidad = parseInt(cantidadSpan.textContent, 10);
|
| 113 |
+
cantidad++;
|
| 114 |
+
cantidadSpan.textContent = cantidad;
|
| 115 |
+
};
|
| 116 |
+
|
| 117 |
+
cantidadControl.querySelector('.decrease').onclick = () => {
|
| 118 |
+
let cantidad = parseInt(cantidadSpan.textContent, 10);
|
| 119 |
+
if (cantidad > 0) {
|
| 120 |
+
cantidad--;
|
| 121 |
+
cantidadSpan.textContent = cantidad;
|
| 122 |
+
}
|
| 123 |
+
};
|
| 124 |
});
|
| 125 |
|
| 126 |
const confirmarButton = document.createElement('button');
|
|
|
|
| 173 |
}
|
| 174 |
|
| 175 |
function generarTicket(mesa, total) {
|
| 176 |
+
const ticketContent = `Mesa ${mesa.numero}\n${mesa.pedidos.map(p => `${p.item} (${p.opcion}) x${p.cantidad} - €${(p.precio * p.cantidad).toFixed(2)}`).join('\n')}\nTotal: €${total.toFixed(2)}`;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 177 |
|
| 178 |
const qrCodeContainer = document.createElement('div');
|
| 179 |
qrCodeContainer.id = 'qrcode';
|
|
|
|
| 195 |
// Inicializar la aplicación
|
| 196 |
render();
|
| 197 |
|
| 198 |
+
|