Agregar sistema de vinculaciones con registros externos de Metabase
All checks were successful
build-and-deploy / build-and-deploy (push) Successful in 2m46s
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:
38
nuxt4/server/api/vinculaciones/index.get.ts
Normal file
38
nuxt4/server/api/vinculaciones/index.get.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* 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',
|
||||
})
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user