- Repository BovineRepository avec getInventoryStats en DQL - Sécurité ApiProperty ROLE_ADMIN sur pricePerKg et finalPrice - Endpoint inventory-export passe en ROLE_ADMIN - Composable useBovineColumns mutualisé entre inventory et case (admin/user séparés) - Stats par tranche d'âge filtrables par buildingCaseId - Légende avec cartes colorées pleines + texte blanc - Coloration de la cellule Age (badge) au lieu de toute la ligne - Décalage couleurs : red ≥ 24, orange 22-24, yellow 20-22 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
48 lines
1.9 KiB
TypeScript
48 lines
1.9 KiB
TypeScript
import { computed } from 'vue'
|
|
import { useAuthStore } from '~/stores/auth'
|
|
|
|
export interface BovineColumn {
|
|
key: string
|
|
label: string
|
|
width?: string
|
|
}
|
|
|
|
/**
|
|
* Définition partagée des colonnes des tableaux bovins (inventory + case).
|
|
* Deux définitions distinctes admin/user pour pouvoir ajuster les largeurs
|
|
* indépendamment selon le contexte.
|
|
*/
|
|
export const useBovineColumns = () => {
|
|
const auth = useAuthStore()
|
|
|
|
const adminColumns: BovineColumn[] = [
|
|
{ key: 'nationalNumber', label: 'N° National', width: '80px' },
|
|
{ key: 'workNumber', label: 'N° Travail', width: '60px' },
|
|
{ key: 'sex', label: 'Sexe', width: '70px' },
|
|
{ key: 'birthDate', label: 'Né le', width: '72px' },
|
|
{ key: 'age', label: 'Age', width: '110px' },
|
|
{ key: 'breedCode', label: 'Race', width: '70px' },
|
|
{ key: 'buildingCase.building.label', label: 'Bâtiment', width: '1fr' },
|
|
{ key: 'buildingCase.caseNumber', label: 'Case', width: '42px' },
|
|
{ key: 'arrivalDate', label: 'Entrée le', width: '90px' },
|
|
{ key: 'pricePerKg', label: 'Prix/kg', width: '65px' },
|
|
{ key: 'finalPrice', label: 'Prix total', width: '100px' }
|
|
]
|
|
|
|
const userColumns: BovineColumn[] = [
|
|
{ key: 'nationalNumber', label: 'N° National', width: '80px' },
|
|
{ key: 'workNumber', label: 'N° Travail', width: '60px' },
|
|
{ key: 'sex', label: 'Sexe', width: '70px' },
|
|
{ key: 'birthDate', label: 'Né le', width: '72px' },
|
|
{ key: 'age', label: 'Age', width: '110px' },
|
|
{ key: 'breedCode', label: 'Race', width: '70px' },
|
|
{ key: 'buildingCase.building.label', label: 'Bâtiment', width: '1fr' },
|
|
{ key: 'buildingCase.caseNumber', label: 'Case', width: '42px' },
|
|
{ key: 'arrivalDate', label: 'Entrée le', width: '90px' }
|
|
]
|
|
|
|
const columns = computed<BovineColumn[]>(() => auth.isAdmin ? adminColumns : userColumns)
|
|
|
|
return { columns }
|
|
}
|