|
@@ -67,7 +67,7 @@
|
|
|
</tr>
|
|
</tr>
|
|
|
</thead>
|
|
</thead>
|
|
|
<tbody>
|
|
<tbody>
|
|
|
- <tr v-for="relation in displayedRelations" :key="relation.id" class="hover:bg-gray-50">
|
|
|
|
|
|
|
+ <tr v-for="relation in stationCompanies" :key="relation.id" class="hover:bg-gray-50">
|
|
|
<td class="py-3 px-4 border-b border-gray-200">{{ relation.id }}</td>
|
|
<td class="py-3 px-4 border-b border-gray-200">{{ relation.id }}</td>
|
|
|
<td class="py-3 px-4 border-b border-gray-200">{{ getStationName(relation.stationId) }}</td>
|
|
<td class="py-3 px-4 border-b border-gray-200">{{ getStationName(relation.stationId) }}</td>
|
|
|
<td class="py-3 px-4 border-b border-gray-200">{{ getCompanyName(relation.companyId) }}</td>
|
|
<td class="py-3 px-4 border-b border-gray-200">{{ getCompanyName(relation.companyId) }}</td>
|
|
@@ -144,8 +144,8 @@
|
|
|
</select>
|
|
</select>
|
|
|
</div>
|
|
</div>
|
|
|
<div class="mb-4">
|
|
<div class="mb-4">
|
|
|
- <label class="block text-sm font-medium text-gray-700 mb-2">Chef de Station</label>
|
|
|
|
|
- <select v-model="formData.stationChiefId" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
|
|
|
|
|
|
|
+ <label class="block text-sm font-medium text-gray-700 mb-2">Chef de Station <span class="text-red-500">*</span></label>
|
|
|
|
|
+ <select v-model="formData.stationChiefId" required class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
|
|
|
<option value="">Sélectionner un chef de station</option>
|
|
<option value="">Sélectionner un chef de station</option>
|
|
|
<option v-for="employee in employees" :key="employee.id" :value="employee.id">
|
|
<option v-for="employee in employees" :key="employee.id" :value="employee.id">
|
|
|
{{ employee.name || `${employee.firstName} ${employee.lastName}` }}
|
|
{{ employee.name || `${employee.firstName} ${employee.lastName}` }}
|
|
@@ -186,7 +186,7 @@ import { useUserCompanyStore } from '@/stores/useCompanyStore'
|
|
|
|
|
|
|
|
const userStore = useUserStore()
|
|
const userStore = useUserStore()
|
|
|
const stationStore = useStationStore()
|
|
const stationStore = useStationStore()
|
|
|
-const loading = ref(false)
|
|
|
|
|
|
|
+const loading = ref<boolean>(false)
|
|
|
const stationCompanies = ref<StationCompany[]>([])
|
|
const stationCompanies = ref<StationCompany[]>([])
|
|
|
const companies = ref<Company[]>([])
|
|
const companies = ref<Company[]>([])
|
|
|
const employees = ref<any[]>([])
|
|
const employees = ref<any[]>([])
|
|
@@ -220,10 +220,6 @@ const isCompanyFieldDisabled = computed(() => {
|
|
|
return !isAdmin.value
|
|
return !isAdmin.value
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
-// Computed pour les relations affichées (directement depuis le backend)
|
|
|
|
|
-const displayedRelations = computed(() => {
|
|
|
|
|
- return stationCompanies.value
|
|
|
|
|
-})
|
|
|
|
|
|
|
|
|
|
onMounted(async () => {
|
|
onMounted(async () => {
|
|
|
await loadData()
|
|
await loadData()
|
|
@@ -239,7 +235,7 @@ watch([searchQuery, stationFilter], () => {
|
|
|
}
|
|
}
|
|
|
searchTimeout = setTimeout(() => {
|
|
searchTimeout = setTimeout(() => {
|
|
|
pagination.value.page = 1
|
|
pagination.value.page = 1
|
|
|
- loadStationCompanies()
|
|
|
|
|
|
|
+ //loadStationCompanies()
|
|
|
}, 300)
|
|
}, 300)
|
|
|
})
|
|
})
|
|
|
|
|
|
|
@@ -254,25 +250,25 @@ watch(() => formData.companyId, async (newCompanyId) => {
|
|
|
formData.stationChiefId = undefined
|
|
formData.stationChiefId = undefined
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
-const loadStationCompanies = async () => {
|
|
|
|
|
- loading.value = true
|
|
|
|
|
- try {
|
|
|
|
|
- const searchParam = searchQuery.value.trim() || undefined
|
|
|
|
|
- const stationParam = stationFilter.value || undefined
|
|
|
|
|
- const response = await StationCompanyService.getStationCompanies(
|
|
|
|
|
- pagination.value.page,
|
|
|
|
|
- pagination.value.limit,
|
|
|
|
|
- searchParam,
|
|
|
|
|
- stationParam
|
|
|
|
|
- )
|
|
|
|
|
- stationCompanies.value = response.stationCompanies
|
|
|
|
|
- pagination.value = response.pagination
|
|
|
|
|
- } catch (error) {
|
|
|
|
|
- console.error('Erreur lors du chargement des relations:', error)
|
|
|
|
|
- } finally {
|
|
|
|
|
- loading.value = false
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
|
|
+// const loadStationCompanies = async () => {
|
|
|
|
|
+// loading.value = true
|
|
|
|
|
+// try {
|
|
|
|
|
+// const searchParam = searchQuery.value.trim() || undefined
|
|
|
|
|
+// const stationParam = stationFilter.value || undefined
|
|
|
|
|
+// const response = await StationCompanyService.getStationCompanies(
|
|
|
|
|
+// pagination.value.page,
|
|
|
|
|
+// pagination.value.limit,
|
|
|
|
|
+// searchParam,
|
|
|
|
|
+// stationParam
|
|
|
|
|
+// )
|
|
|
|
|
+// stationCompanies.value = response.stationCompanies
|
|
|
|
|
+// pagination.value = response.pagination
|
|
|
|
|
+// } catch (error) {
|
|
|
|
|
+// console.error('Erreur lors du chargement des relations:', error)
|
|
|
|
|
+// } finally {
|
|
|
|
|
+// loading.value = false
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
|
|
|
const loadEmployees = async (companyId: number) => {
|
|
const loadEmployees = async (companyId: number) => {
|
|
|
try {
|
|
try {
|
|
@@ -286,24 +282,24 @@ const loadEmployees = async (companyId: number) => {
|
|
|
|
|
|
|
|
const loadData = async () => {
|
|
const loadData = async () => {
|
|
|
loading.value = true
|
|
loading.value = true
|
|
|
|
|
+ console.log('seUserCompanyStore().id:',useUserCompanyStore().id)
|
|
|
try {
|
|
try {
|
|
|
- const searchParam = searchQuery.value.trim() || undefined
|
|
|
|
|
- const stationParam = stationFilter.value || undefined
|
|
|
|
|
- const [relationsResponse, companiesResponse] = await Promise.all([
|
|
|
|
|
- StationCompanyService.getStationCompanies(
|
|
|
|
|
- pagination.value.page,
|
|
|
|
|
- pagination.value.limit,
|
|
|
|
|
- searchParam,
|
|
|
|
|
- stationParam
|
|
|
|
|
- ),
|
|
|
|
|
- CompanyService.getCompanies()
|
|
|
|
|
- ])
|
|
|
|
|
|
|
+
|
|
|
|
|
+ const relationsResponse = await StationCompanyService.getStationCompaniesByCompanyId(useUserCompanyStore().id)
|
|
|
|
|
+
|
|
|
|
|
+ console.log('relationsResponse:', relationsResponse?.data)
|
|
|
// Charger les stations via le store
|
|
// Charger les stations via le store
|
|
|
await stationStore.fetchStations()
|
|
await stationStore.fetchStations()
|
|
|
|
|
|
|
|
- stationCompanies.value = relationsResponse.stationCompanies
|
|
|
|
|
- pagination.value = relationsResponse.pagination
|
|
|
|
|
- companies.value = companiesResponse.companies
|
|
|
|
|
|
|
+ stationCompanies.value = relationsResponse?.data as StationCompany[]
|
|
|
|
|
+ //TODO:: géré la pagination dans le back
|
|
|
|
|
+ pagination.value = {
|
|
|
|
|
+ total: 10,
|
|
|
|
|
+ page: 1,
|
|
|
|
|
+ limit: 10,
|
|
|
|
|
+ totalPages: 1
|
|
|
|
|
+ } //relationsResponse.pagination
|
|
|
|
|
+ //companies.value = companiesResponse.companies
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
console.error('Erreur lors du chargement des données:', error)
|
|
console.error('Erreur lors du chargement des données:', error)
|
|
|
} finally {
|
|
} finally {
|
|
@@ -408,7 +404,7 @@ const handleUserMenu = () => {
|
|
|
// Méthode de gestion du changement de page
|
|
// Méthode de gestion du changement de page
|
|
|
const handlePageChange = async (page: number) => {
|
|
const handlePageChange = async (page: number) => {
|
|
|
pagination.value.page = page
|
|
pagination.value.page = page
|
|
|
- await loadStationCompanies()
|
|
|
|
|
|
|
+ //await loadStationCompanies()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// onBeforeMount supprimé pour éviter les doubles chargements
|
|
// onBeforeMount supprimé pour éviter les doubles chargements
|