53 lines
2.5 KiB
Vue
53 lines
2.5 KiB
Vue
<template>
|
|
<v-app>
|
|
<v-app-bar color="primary" elevation="2">
|
|
<v-btn icon="mdi-menu" data-testid="navigation-toggle" aria-label="Abrir navegación" @click="drawer = !drawer" />
|
|
<v-app-bar-title>ToldoConjunto - CESTA</v-app-bar-title>
|
|
<v-chip v-if="jornada" color="success" variant="tonal" class="mr-3" prepend-icon="mdi-circle">Jornada activa</v-chip>
|
|
</v-app-bar>
|
|
|
|
<v-navigation-drawer v-model="drawer" :permanent="!isMobile" :temporary="isMobile">
|
|
<v-list density="comfortable" nav>
|
|
<v-list-subheader>OPERACION</v-list-subheader>
|
|
<v-list-item to="/" prepend-icon="mdi-home" title="Inicio" @click="closeOnMobile"></v-list-item>
|
|
<v-list-item v-for="item in navItems" :key="item.to" :to="item.to" :prepend-icon="item.icon" :title="item.title" @click="closeOnMobile"></v-list-item>
|
|
</v-list>
|
|
</v-navigation-drawer>
|
|
|
|
<v-main>
|
|
<v-container fluid class="pa-4 pa-md-6">
|
|
<div class="d-flex justify-end mb-3 ga-2">
|
|
<v-btn variant="text" size="small" prepend-icon="mdi-arrow-left" data-testid="back-button" @click="goBack">Atrás</v-btn>
|
|
<v-btn to="/" variant="text" size="small" prepend-icon="mdi-home">Inicio</v-btn>
|
|
</div>
|
|
<router-view />
|
|
</v-container>
|
|
</v-main>
|
|
</v-app>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { onMounted, onUnmounted, ref } from 'vue';
|
|
import { JornadaService } from '@toldo/services';
|
|
import { useRouter } from 'vue-router';
|
|
|
|
const drawer = ref(true);
|
|
const isMobile = ref(false);
|
|
const jornada = ref<any>(null);
|
|
const jornadaService = new JornadaService();
|
|
const router = useRouter();
|
|
const navItems = [
|
|
{ to: '/jornada', icon: 'mdi-calendar-check', title: 'Jornada' },
|
|
{ to: '/inventario', icon: 'mdi-package-variant', title: 'Inventario' },
|
|
{ to: '/ventas', icon: 'mdi-cart', title: 'Ventas POS' },
|
|
{ to: '/gastos', icon: 'mdi-cash-minus', title: 'Gastos' },
|
|
{ to: '/reportes', icon: 'mdi-chart-bar', title: 'Reportes' },
|
|
{ to: '/exportar', icon: 'mdi-export', title: 'Exportar / importar' },
|
|
];
|
|
function updateViewport() { isMobile.value = window.innerWidth < 960; if (isMobile.value) drawer.value = false; }
|
|
function closeOnMobile() { if (isMobile.value) drawer.value = false; }
|
|
function goBack() { if (window.history.state?.back) router.back(); else router.push('/'); }
|
|
onMounted(async () => { updateViewport(); window.addEventListener('resize', updateViewport); jornada.value = await jornadaService.getJornadaAbierta(); });
|
|
onUnmounted(() => window.removeEventListener('resize', updateViewport));
|
|
</script>
|