Agregar sistema de vinculaciones con registros externos de Metabase
All checks were successful
build-and-deploy / build-and-deploy (push) Successful in 2m46s

- Nuevo schema BD para vinculaciones_externas con constraint único por período
- Cliente Metabase para consultar Ingresos, Carretas, Salidas y Rechazos
- Endpoints API para registros externos (/api/externos/*) y vinculaciones (/api/vinculaciones/*)
- Composable useRegistrosExternos con lógica de vinculación individual y masiva
- Componentes: TablaRegistros, ModalAsignar, ProgressDashboard
- Tab "Externos" en app.vue con sub-tabs y dashboard de progreso
- LotesCard.vue ahora muestra registros vinculados al lote
This commit is contained in:
2025-11-29 15:25:26 -06:00
parent 1c96b696fa
commit ce8bad68d5
38 changed files with 2987 additions and 1 deletions

View File

@@ -0,0 +1,52 @@
/**
* GET /api/vinculaciones/por-lote/:loteId
*
* Obtiene todas las vinculaciones de un lote específico.
*/
import { getVinculacionesByLote } from '../../../utils/queries'
export default defineEventHandler(async (event) => {
try {
const loteId = getRouterParam(event, 'loteId')
if (!loteId) {
throw createError({
statusCode: 400,
statusMessage: 'loteId requerido',
})
}
const vinculaciones = await getVinculacionesByLote(loteId)
// Agrupar por tipo de registro
const agrupados = {
ingresos: vinculaciones.filter(v => v.tipo_registro === 'ingreso'),
carretas: vinculaciones.filter(v => v.tipo_registro === 'carreta'),
salidas: vinculaciones.filter(v => v.tipo_registro === 'salida'),
rechazos: vinculaciones.filter(v => v.tipo_registro === 'rechazo'),
}
return {
success: true,
data: vinculaciones,
agrupados,
meta: {
lote_id: loteId,
total: vinculaciones.length,
por_tipo: {
ingresos: agrupados.ingresos.length,
carretas: agrupados.carretas.length,
salidas: agrupados.salidas.length,
rechazos: agrupados.rechazos.length,
},
},
}
} catch (error: any) {
console.error('[API] Error obteniendo vinculaciones del lote:', error)
throw createError({
statusCode: 500,
statusMessage: error.message || 'Error obteniendo vinculaciones del lote',
})
}
})