feat : harmonisation des pages infrastructure avec le pattern UiDataTable

- Page case : mêmes colonnes, filtres et alertes âge que la page inventaire
- Page building : header aligné sur le pattern case.vue (wrapper px-86, arrow en absolute)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-24 10:57:25 +02:00
parent 79077c7bbd
commit 2e72f93f29
2 changed files with 93 additions and 29 deletions

View File

@@ -1,19 +1,18 @@
<template> <template>
<div class="min-h-screen"> <div class="px-[86px]">
<!-- En-tête de page avec retour et titre --> <div class="flex items-center justify-between relative">
<div class="flex items-center justify-between mb-8"> <div class="flex flex-row absolute -left-[60px]">
<div class="flex items-center gap-10">
<Icon <Icon
@click="router.push('/')" @click="router.push('/')"
name="gg:arrow-left-o" name="gg:arrow-left-o"
size="44" size="44"
class="cursor-pointer text-primary-500" class="cursor-pointer text-primary-500"
/> />
<h1 class="text-3xl font-bold uppercase text-primary-500">bâtiments</h1>
</div> </div>
<h1 class="text-3xl font-bold uppercase text-primary-500">bâtiments</h1>
</div> </div>
<div class="px-[86px] space-y-6"> <div class="mt-6 space-y-6">
<!-- Liste des bâtiments + rendu du plan de chaque bâtiment --> <!-- Liste des bâtiments + rendu du plan de chaque bâtiment -->
<div <div
v-for="entry in buildingLayouts" v-for="entry in buildingLayouts"

View File

@@ -40,6 +40,7 @@
:items="items" :items="items"
:total-items="totalItems" :total-items="totalItems"
:loading="loading" :loading="loading"
:row-class="rowClass"
:row-clickable="auth.isAdmin" :row-clickable="auth.isAdmin"
empty-message="Aucun bovin dans cette case." empty-message="Aucun bovin dans cette case."
@row-click="goToBovine" @row-click="goToBovine"
@@ -47,25 +48,61 @@
<template #header-nationalNumber> <template #header-nationalNumber>
<UiTextInput <UiTextInput
v-model="filters.nationalNumber" v-model="filters.nationalNumber"
placeholder="Numéro national" placeholder="N° National"
size="compact" size="compact"
/> />
</template> </template>
<template #header-receivedWeight> <template #header-workNumber>
<UiTextInput <UiTextInput
v-model="filters.receivedWeight" v-model="filters.workNumber"
placeholder="Poids (kg)" placeholder="N° Travail"
size="compact" size="compact"
/> />
</template> </template>
<template #header-sex>
<UiSelect
v-model="filters.sex"
placeholder="Sexe"
:options="sexOptions"
size="compact"
/>
</template>
<template #header-birthDate>
<UiDateMaskedInput v-model="birthDateFilter" size="compact" placeholder="Né le" />
</template>
<template #header-age>
<UiTextInput :model-value="''" placeholder="Age" size="compact" disabled />
</template>
<template #header-breedCode>
<UiTextInput
v-model="filters.breedCode"
placeholder="Race"
size="compact"
/>
</template>
<template #header-buildingCase.building.label>
<UiTextInput :model-value="''" placeholder="Bâtiment" size="compact" disabled />
</template>
<template #header-buildingCase.caseNumber>
<UiTextInput :model-value="''" placeholder="Case" size="compact" disabled />
</template>
<template #header-arrivalDate> <template #header-arrivalDate>
<UiDateMaskedInput v-model="arrivalDateFilter" placeholder="Date d'arrivée" size="compact" /> <UiDateMaskedInput v-model="arrivalDateFilter" size="compact" placeholder="Entrée le" />
</template>
<template #cell-birthDate="{ item }">
{{ formatDate(item.birthDate) }}
</template>
<template #cell-age="{ item }">
{{ formatAgeLabel(item.ageMonths) }}
</template> </template>
<template #cell-arrivalDate="{ item }"> <template #cell-arrivalDate="{ item }">
{{ formatDate(item.arrivalDate) }} {{ formatDate(item.arrivalDate) }}
</template> </template>
<template #cell-receivedWeight="{ item }"> <template #cell-buildingCase.building.label="{ item }">
{{ item.receivedWeight ?? '—' }} {{ item.buildingCase?.building?.label ?? '—' }}
</template>
<template #cell-buildingCase.caseNumber="{ item }">
{{ item.buildingCase?.caseNumber ?? '—' }}
</template> </template>
</UiDataTable> </UiDataTable>
</div> </div>
@@ -77,6 +114,7 @@ import type { BuildingCaseData } from '~/services/dto/building-case-data'
import type { BovineData } from '~/services/dto/bovine-data' import type { BovineData } from '~/services/dto/bovine-data'
import { useAuthStore } from '~/stores/auth' import { useAuthStore } from '~/stores/auth'
import { useDataTableServerState } from '~/composables/useDataTableServerState' import { useDataTableServerState } from '~/composables/useDataTableServerState'
import { formatAgeLabel } from '~/utils/bovine-age'
const route = useRoute() const route = useRoute()
const router = useRouter() const router = useRouter()
@@ -93,38 +131,58 @@ const { items, totalItems, page, perPage, filters, loading, reload } =
useDataTableServerState<BovineData>( useDataTableServerState<BovineData>(
'bovines', 'bovines',
{ {
'exists[exitedAt]': 'false',
buildingCase: '', buildingCase: '',
nationalNumber: '', nationalNumber: '',
receivedWeight: '', workNumber: '',
breedCode: '',
sex: '',
'arrivalDate[after]': '', 'arrivalDate[after]': '',
'arrivalDate[strictly_before]': '' 'arrivalDate[strictly_before]': '',
'birthDate[after]': '',
'birthDate[strictly_before]': ''
}, },
{ initialPerPage: 10 } { initialPerPage: 10 }
) )
const sexOptions = [
{ value: 'M', label: 'Mâle' },
{ value: 'F', label: 'Femelle' }
]
const addOneDay = (dateString: string): string => { const addOneDay = (dateString: string): string => {
const [year, month, day] = dateString.split('-').map(Number) const [year, month, day] = dateString.split('-').map(Number)
const next = new Date(Date.UTC(year, month - 1, day + 1)) const next = new Date(Date.UTC(year, month - 1, day + 1))
return next.toISOString().slice(0, 10) return next.toISOString().slice(0, 10)
} }
const arrivalDateFilter = computed<string>({ const singleDateFilter = (afterKey: string, beforeKey: string) =>
get: () => (filters.value['arrivalDate[after]'] as string) ?? '', computed<string>({
set: (value: string) => { get: () => (filters.value[afterKey] as string) ?? '',
if (!value) { set: (value: string) => {
filters.value['arrivalDate[after]'] = '' if (!value) {
filters.value['arrivalDate[strictly_before]'] = '' filters.value[afterKey] = ''
return filters.value[beforeKey] = ''
return
}
filters.value[afterKey] = value
filters.value[beforeKey] = addOneDay(value)
} }
filters.value['arrivalDate[after]'] = value })
filters.value['arrivalDate[strictly_before]'] = addOneDay(value)
} const arrivalDateFilter = singleDateFilter('arrivalDate[after]', 'arrivalDate[strictly_before]')
}) const birthDateFilter = singleDateFilter('birthDate[after]', 'birthDate[strictly_before]')
const columns = [ const columns = [
{ key: 'nationalNumber', label: 'Numéro national' }, { key: 'nationalNumber', label: 'N° National', width: '160px' },
{ key: 'receivedWeight', label: "Poids à l'arrivée (kg)" }, { key: 'workNumber', label: 'N° Travail', width: '85px' },
{ key: 'arrivalDate', label: "Date d'arrivée" } { key: 'sex', label: 'Sexe', width: '70px' },
{ key: 'birthDate', label: 'Né le', width: '120px' },
{ key: 'age', label: 'Age', width: '110px' },
{ key: 'breedCode', label: 'Race' },
{ key: 'buildingCase.building.label', label: 'Bâtiment', width: '1.5fr' },
{ key: 'buildingCase.caseNumber', label: 'Case', width: '80px' },
{ key: 'arrivalDate', label: 'Entrée le', width: '120px' }
] ]
const title = computed(() => { const title = computed(() => {
@@ -150,6 +208,13 @@ const formatDate = (date: string | null) => {
}) })
} }
const rowClass = (item: BovineData): string => {
if (item.ageMonths === null || item.ageMonths === undefined) return ''
if (item.ageMonths >= 24) return 'bg-red-100 hover:bg-red-200'
if (item.ageMonths >= 22) return 'bg-orange-100 hover:bg-orange-200'
return ''
}
const loadCase = async () => { const loadCase = async () => {
if (!hasCaseId.value) { if (!hasCaseId.value) {
buildingCase.value = null buildingCase.value = null