feat: mejorar ux y validaciones del toldo

This commit is contained in:
mono
2026-10-25 18:09:01 -05:00
parent 4ffce3e3cd
commit 8e286d6fec
24 changed files with 387 additions and 121 deletions

View File

@@ -1,6 +1,7 @@
<template>
<div>
<h2>Gastos</h2>
<v-alert v-if="mensaje" :type="tipoMensaje" variant="tonal" class="mb-3">{{ mensaje }}</v-alert>
<p v-if="!jornadaAbierta" style="color: orange">Sin jornada abierta - debe abrir jornada para registrar gastos</p>
<p v-else style="color: green">Jornada abierta</p>
<section>
@@ -32,6 +33,8 @@ const monto = ref(0);
const formaPago = ref<'EFECTIVO' | 'QR'>('EFECTIVO');
const gastos = ref<any[]>([]);
const jornadaAbierta = ref<any>(null);
const mensaje = ref('');
const tipoMensaje = ref<'success' | 'error'>('success');
async function cargar() {
gastos.value = await gastosService.getGastosDelDia(new Date());
@@ -39,9 +42,9 @@ async function cargar() {
}
async function registrar() {
if (!concepto.value || monto.value <= 0) return;
if (!concepto.value.trim() || monto.value <= 0) { tipoMensaje.value = 'error'; mensaje.value = 'Escribe un concepto y un monto mayor que cero.'; return; }
if (!jornadaAbierta.value) {
alert('Debe abrir una jornada primero (Jornada > Apertura)');
tipoMensaje.value = 'error'; mensaje.value = 'Debe abrir una jornada antes de registrar gastos.';
return;
}
try {
@@ -56,9 +59,9 @@ async function registrar() {
concepto.value = '';
monto.value = 0;
await cargar();
alert('Gasto registrado');
tipoMensaje.value = 'success'; mensaje.value = 'Gasto registrado.';
} catch (e: any) {
alert(e.message);
tipoMensaje.value = 'error'; mensaje.value = e.message;
}
}