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
39 lines
1008 B
TypeScript
39 lines
1008 B
TypeScript
/**
|
|
* GET /api/vinculaciones
|
|
*
|
|
* Lista vinculaciones con filtros opcionales.
|
|
*/
|
|
|
|
import { getVinculaciones } from '../../utils/queries'
|
|
|
|
export default defineEventHandler(async (event) => {
|
|
try {
|
|
const query = getQuery(event)
|
|
|
|
const filtros = {
|
|
tipo_registro: query.tipo as string | undefined,
|
|
lote_id: query.lote_id as string | undefined,
|
|
periodo_cosecha: (query.periodo as string) || '25-26',
|
|
limit: query.limit ? parseInt(query.limit as string) : undefined,
|
|
offset: query.offset ? parseInt(query.offset as string) : undefined,
|
|
}
|
|
|
|
const vinculaciones = await getVinculaciones(filtros)
|
|
|
|
return {
|
|
success: true,
|
|
data: vinculaciones,
|
|
meta: {
|
|
total: vinculaciones.length,
|
|
filtros,
|
|
},
|
|
}
|
|
} catch (error: any) {
|
|
console.error('[API] Error obteniendo vinculaciones:', error)
|
|
throw createError({
|
|
statusCode: 500,
|
|
statusMessage: error.message || 'Error obteniendo vinculaciones',
|
|
})
|
|
}
|
|
})
|