feat: UI completa funcional para todos los módulos

This commit is contained in:
mono
2026-10-24 22:57:04 -05:00
parent c81ef268ff
commit 27b084dd52
21 changed files with 461 additions and 121 deletions

View File

@@ -1,6 +1,105 @@
<template>
<div>
<h2>Inventario</h2>
<p>Módulo en desarrollo</p>
<section>
<h3>Productores</h3>
<input v-model="nuevoProductor" placeholder="Nombre del productor" />
<button @click="crearProductor">Agregar Productor</button>
<ul>
<li v-for="p in productores" :key="p.id">{{ p.nombre }}</li>
</ul>
</section>
<section>
<h3>Productos (por productor)</h3>
<select v-model="productorSel">
<option value="">Seleccionar productor</option>
<option v-for="p in productores" :key="p.id" :value="p.id">{{ p.nombre }}</option>
</select>
<input v-model="nombreProd" placeholder="Ej: Café molido 250gr" />
<input v-model.number="precioProd" type="number" placeholder="Precio unitario" />
<button @click="crearProducto">Agregar Producto</button>
<ul>
<li v-for="prod in productos" :key="prod.id">{{ prod.nombrePresentacion }} - ${{ prod.precioUnitario }}</li>
</ul>
</section>
<section>
<h3>Ingreso Inicial</h3>
<select v-model="prodInv">
<option value="">Seleccionar producto</option>
<option v-for="prod in productos" :key="prod.id" :value="prod.id">{{ prod.nombrePresentacion }}</option>
</select>
<input v-model.number="cantInv" type="number" placeholder="Cantidad" />
<button @click="ingresoInicial">Registrar Ingreso Inicial</button>
</section>
<section>
<h3>Ingreso entre semana</h3>
<select v-model="prodInv2">
<option value="">Seleccionar producto</option>
<option v-for="prod in productos" :key="prod.id" :value="prod.id">{{ prod.nombrePresentacion }}</option>
</select>
<input v-model.number="cantInv2" type="number" placeholder="Cantidad" />
<input v-model="recibidoPor" placeholder="Recibido por" />
<button @click="ingresoSemana">Registrar Ingreso</button>
</section>
</div>
</template>
<script setup lang="ts">
import { ref, onMounted } from 'vue';
import { db } from '@toldo/data';
import { InventarioService } from '@toldo/services';
const invService = new InventarioService();
const productores = ref<any[]>([]);
const productos = ref<any[]>([]);
const nuevoProductor = ref('');
const productorSel = ref('');
const nombreProd = ref('');
const precioProd = ref(0);
const prodInv = ref('');
const cantInv = ref(0);
const prodInv2 = ref('');
const cantInv2 = ref(0);
const recibidoPor = ref('');
async function cargar() {
productores.value = await db.productores.toArray();
productos.value = await db.productos.toArray();
}
async function crearProductor() {
if (!nuevoProductor.value) return;
await db.productores.add({ id: crypto.randomUUID(), nombre: nuevoProductor.value, activo: true, createdAt: new Date() });
nuevoProductor.value = '';
await cargar();
}
async function crearProducto() {
if (!productorSel.value || !nombreProd.value) return;
await db.productos.add({ id: crypto.randomUUID(), productorId: productorSel.value, nombrePresentacion: nombreProd.value, precioUnitario: precioProd.value, activo: true, createdAt: new Date() });
nombreProd.value = '';
precioProd.value = 0;
await cargar();
}
async function ingresoInicial() {
if (!prodInv.value || cantInv.value <= 0) return;
await invService.registrarIngresoInicial(prodInv.value, cantInv.value, new Date());
cantInv.value = 0;
alert('Ingreso inicial registrado');
}
async function ingresoSemana() {
if (!prodInv2.value || cantInv2.value <= 0 || !recibidoPor.value) return;
await invService.registrarIngresoSemana(prodInv2.value, cantInv2.value, new Date(), recibidoPor.value);
cantInv2.value = 0;
recibidoPor.value = '';
alert('Ingreso entre semana registrado');
}
onMounted(cargar);
</script>