feat(api) : add machine count to category related items endpoint
This commit is contained in:
@@ -48,6 +48,39 @@
|
||||
<span class="whitespace-nowrap">{{ formatDate(row.createdAt) }}</span>
|
||||
</template>
|
||||
|
||||
<template #cell-composantCount="{ row }">
|
||||
<NuxtLink
|
||||
v-if="stats[row.id]?.composantCount"
|
||||
:to="`/catalogues/composants?constructeur=${row.id}`"
|
||||
class="badge badge-ghost badge-sm hover:badge-primary transition-colors"
|
||||
>
|
||||
{{ stats[row.id].composantCount }}
|
||||
</NuxtLink>
|
||||
<span v-else class="text-base-content/30">—</span>
|
||||
</template>
|
||||
|
||||
<template #cell-pieceCount="{ row }">
|
||||
<NuxtLink
|
||||
v-if="stats[row.id]?.pieceCount"
|
||||
:to="`/catalogues/pieces?constructeur=${row.id}`"
|
||||
class="badge badge-ghost badge-sm hover:badge-primary transition-colors"
|
||||
>
|
||||
{{ stats[row.id].pieceCount }}
|
||||
</NuxtLink>
|
||||
<span v-else class="text-base-content/30">—</span>
|
||||
</template>
|
||||
|
||||
<template #cell-machineCount="{ row }">
|
||||
<NuxtLink
|
||||
v-if="stats[row.id]?.machineCount"
|
||||
:to="`/machines?constructeur=${row.id}`"
|
||||
class="badge badge-ghost badge-sm hover:badge-primary transition-colors"
|
||||
>
|
||||
{{ stats[row.id].machineCount }}
|
||||
</NuxtLink>
|
||||
<span v-else class="text-base-content/30">—</span>
|
||||
</template>
|
||||
|
||||
<template #cell-actions="{ row }">
|
||||
<div class="flex items-center justify-end gap-2">
|
||||
<button class="btn btn-ghost btn-xs" @click="openEditModal(row)">
|
||||
@@ -103,6 +136,7 @@ import { formatPhone } from '~/utils/formatters/phone'
|
||||
import { formatFrenchDate } from '~/utils/date'
|
||||
import IconLucidePlus from '~icons/lucide/plus'
|
||||
|
||||
const api = useApi()
|
||||
const { canEdit } = usePermissions()
|
||||
const { constructeurs, loading, searchConstructeurs, createConstructeur, updateConstructeur, deleteConstructeur, loadConstructeurs } = useConstructeurs()
|
||||
const { showError } = useToast()
|
||||
@@ -112,12 +146,16 @@ const columns = [
|
||||
{ key: 'email', label: 'Email', sortable: true },
|
||||
{ key: 'phone', label: 'Téléphone', sortable: true },
|
||||
{ key: 'createdAt', label: 'Date de création', sortable: true },
|
||||
{ key: 'composantCount', label: 'Composants', align: 'center' },
|
||||
{ key: 'pieceCount', label: 'Pièces', align: 'center' },
|
||||
{ key: 'machineCount', label: 'Machines', align: 'center' },
|
||||
{ key: 'actions', label: 'Actions', align: 'right' },
|
||||
]
|
||||
|
||||
const searchTerm = ref('')
|
||||
const sortKey = usePersistedValue('constructeurs-sort', 'name')
|
||||
const sortDir = ref('asc')
|
||||
const stats = ref({})
|
||||
|
||||
const currentSort = computed(() => ({
|
||||
field: sortKey.value,
|
||||
@@ -236,5 +274,15 @@ const confirmDelete = async (constructeur) => {
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => loadConstructeurs())
|
||||
const loadStats = async () => {
|
||||
const result = await api.get('/constructeurs/stats')
|
||||
if (result.success && result.data) {
|
||||
stats.value = result.data
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
loadConstructeurs()
|
||||
loadStats()
|
||||
})
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user