|
@@ -82,7 +82,7 @@
|
|
|
<th>Modèle</th>
|
|
<th>Modèle</th>
|
|
|
<th>Immatriculation</th>
|
|
<th>Immatriculation</th>
|
|
|
<th>Type</th>
|
|
<th>Type</th>
|
|
|
- <th>Entreprise</th>
|
|
|
|
|
|
|
+ <th v-if="useUserStore().userRole === Role.Admin">Entreprise</th>
|
|
|
<th>Statut</th>
|
|
<th>Statut</th>
|
|
|
<th>Actions</th>
|
|
<th>Actions</th>
|
|
|
</tr>
|
|
</tr>
|
|
@@ -95,7 +95,7 @@
|
|
|
<td>{{ vehicle.model }}</td>
|
|
<td>{{ vehicle.model }}</td>
|
|
|
<td>{{ vehicle.immatriculation }}</td>
|
|
<td>{{ vehicle.immatriculation }}</td>
|
|
|
<td>{{ getVehicleTypeName(vehicle.type) }}</td>
|
|
<td>{{ getVehicleTypeName(vehicle.type) }}</td>
|
|
|
- <td>{{ getCompanyName(vehicle.companyId) }}</td>
|
|
|
|
|
|
|
+ <td v-if="useUserStore().userRole === Role.Admin">{{ getCompanyName(vehicle.companyId) }}</td>
|
|
|
<td>
|
|
<td>
|
|
|
<span :class="['status-badge', getStatusClass(vehicle.status)]">
|
|
<span :class="['status-badge', getStatusClass(vehicle.status)]">
|
|
|
{{ getStatusName(vehicle.status) }}
|
|
{{ getStatusName(vehicle.status) }}
|
|
@@ -245,6 +245,7 @@ import { useVehiculeStore, Vehicule } from '@/stores/useVehiculeStore'
|
|
|
import VehiculeService from '@/services/VehiculeService'
|
|
import VehiculeService from '@/services/VehiculeService'
|
|
|
//import CompanyService from '@/services/CompanyService'
|
|
//import CompanyService from '@/services/CompanyService'
|
|
|
import type { Vehicle, Company } from '@/types'
|
|
import type { Vehicle, Company } from '@/types'
|
|
|
|
|
+import CompanyService from '@/services/CompanyService'
|
|
|
|
|
|
|
|
// Variables réactives pour les données
|
|
// Variables réactives pour les données
|
|
|
const vehicles = ref<Vehicle[]>([])
|
|
const vehicles = ref<Vehicle[]>([])
|
|
@@ -316,14 +317,17 @@ const loadVehicles = async () => {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// const loadCompanies = async () => {
|
|
|
|
|
-// try {
|
|
|
|
|
-// const result = await CompanyService.getCompanies(1, 100) // Charger toutes les entreprises
|
|
|
|
|
-// companies.value = result.companies
|
|
|
|
|
-// } catch (error) {
|
|
|
|
|
-// console.error('Erreur lors du chargement des entreprises:', error)
|
|
|
|
|
-// }
|
|
|
|
|
-// }
|
|
|
|
|
|
|
+const loadCompanies = async () => {
|
|
|
|
|
+ if (useUserStore().userRole !== Role.Admin) {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ try {
|
|
|
|
|
+ const result = await CompanyService.getCompanies(1, 100) // Charger toutes les entreprises
|
|
|
|
|
+ companies.value = result.companies
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ console.error('Erreur lors du chargement des entreprises:', error)
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
const createNewVehicle = async (vehicule: Vehicle) => {
|
|
const createNewVehicle = async (vehicule: Vehicle) => {
|
|
|
|
|
|
|
@@ -375,7 +379,8 @@ const filteredVehicles = computed(() => {
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
// Méthodes utilitaires
|
|
// Méthodes utilitaires
|
|
|
-const getCompanyName = (companyId) => {
|
|
|
|
|
|
|
+const getCompanyName = (companyId: number) => {
|
|
|
|
|
+ console.log('companyId', companies.value)
|
|
|
const company = companies.value.find(c => c.id === companyId)
|
|
const company = companies.value.find(c => c.id === companyId)
|
|
|
return company ? company.name : 'Inconnue'
|
|
return company ? company.name : 'Inconnue'
|
|
|
}
|
|
}
|
|
@@ -500,7 +505,8 @@ const deleteVehicle = async () => {
|
|
|
onMounted(async () => {
|
|
onMounted(async () => {
|
|
|
await Promise.all([
|
|
await Promise.all([
|
|
|
loadVehicles(),
|
|
loadVehicles(),
|
|
|
- useVehiculeStore().fetchVehicles()
|
|
|
|
|
|
|
+ useVehiculeStore().fetchVehicles(),
|
|
|
|
|
+ loadCompanies()
|
|
|
])
|
|
])
|
|
|
})
|
|
})
|
|
|
|
|
|