diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index b3e2025..254ba9c 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,12 +4,14 @@
-
+
-
+
+
+
@@ -274,7 +276,8 @@
-
+
+
@@ -588,7 +591,23 @@
1769700808988
-
+
+
+ 1769705141157
+
+
+
+ 1769705141157
+
+
+
+ 1769705240487
+
+
+
+ 1769705240487
+
+
@@ -638,8 +657,6 @@
-
-
@@ -663,7 +680,9 @@
-
+
+
+
diff --git a/frontend/components/reception/reception-form.vue b/frontend/components/reception/reception-form.vue
index a07a8f8..5100ca7 100644
--- a/frontend/components/reception/reception-form.vue
+++ b/frontend/components/reception/reception-form.vue
@@ -142,6 +142,7 @@ import type {DriverData} from '~/services/dto/driver-data'
import {getDriverList} from '~/services/driver'
import type {VehicleData} from '~/services/dto/vehicle-data'
import {getVehicleList} from '~/services/vehicle'
+import {SUPLLIER_CODE} from "~/utils/constants";
type ReceptionFormData = {
licensePlate: string
@@ -185,12 +186,16 @@ const isLoadingDrivers = ref(false)
const vehicles = ref([])
const isLoadingVehicles = ref(false)
const authStore = useAuthStore()
+// Empêche les watchers de reset des champs pendant le remplissage initial
const isHydrating = ref(false)
-const liotCode = 'LIOT'
+
+// Transporteur sélectionné dans le formulaire
const selectedCarrier = computed(() =>
carriers.value.find((carrier) => String(carrier.id) === form.carrierId) ?? null
)
-const isLiotCarrier = computed(() => selectedCarrier.value?.code === liotCode)
+// Indique si le transporteur est LIOT
+const isLiotCarrier = computed(() => selectedCarrier.value?.code === SUPLLIER_CODE.LIOT)
+// Adresses disponibles pour le fournisseur sélectionné
const supplierAddresses = computed(() => {
const supplierId = Number(form.supplierId)
if (!Number.isFinite(supplierId)) {
@@ -198,13 +203,15 @@ const supplierAddresses = computed(() => {
}
return suppliers.value.find((supplier) => supplier.id === supplierId)?.addresses ?? []
})
-const filteredDrivers = computed(() => {
+// Chauffeurs filtrés par transporteur (LIOT)
+const filteredDrivers = computed(() => {
if (!form.carrierId) {
return []
}
return drivers.value.filter((driver) => String(driver.carrier?.id) === form.carrierId)
})
-const filteredVehicles = computed(() => {
+// Véhicules filtrés par transporteur + type de camion
+const filteredVehicles = computed(() => {
if (!form.carrierId) {
return []
}
@@ -215,6 +222,7 @@ const filteredVehicles = computed(() => {
)
})
+// Hydrate le formulaire depuis la réception en cours
watch(
() => receptionStore.current,
(reception) => {
@@ -247,6 +255,7 @@ watch(
{immediate: true}
)
+// Charge la liste des users pour le select
const loadUsers = async () => {
isLoadingUsers.value = true
try {
@@ -256,6 +265,7 @@ const loadUsers = async () => {
}
}
+// Charge la liste des fournisseurs pour le select
const loadSuppliers = async () => {
isLoadingSuppliers.value = true
try {
@@ -265,6 +275,7 @@ const loadSuppliers = async () => {
}
}
+// Charge la liste des camions pour le select
const loadTrucks = async () => {
isLoadingTrucks.value = true
try {
@@ -274,6 +285,7 @@ const loadTrucks = async () => {
}
}
+// Charge la liste des transporteurs pour le select
const loadCarriers = async () => {
isLoadingCarriers.value = true
try {
@@ -283,6 +295,7 @@ const loadCarriers = async () => {
}
}
+// Charge la liste des chauffeurs pour le select
const loadDrivers = async () => {
isLoadingDrivers.value = true
try {
@@ -292,6 +305,7 @@ const loadDrivers = async () => {
}
}
+// Charge la liste des véhicules pour le select
const loadVehicles = async () => {
isLoadingVehicles.value = true
try {
@@ -301,6 +315,7 @@ const loadVehicles = async () => {
}
}
+// On met le user connecté par défaut dans le select
const setDefaultUser = () => {
if (form.userId) {
return
@@ -310,6 +325,7 @@ const setDefaultUser = () => {
}
}
+// On récupère toutes les données des selects au chargement du composant
onMounted(async () => {
receptionTypes.value = await getReceptionTypeList()
await loadUsers()
@@ -322,6 +338,7 @@ onMounted(async () => {
setDefaultUser()
})
+// Ajuste driver/vehicle quand le transporteur change (logique LIOT)
watch(
() => [form.supplierId, suppliers.value],
() => {
@@ -346,6 +363,7 @@ watch(
{immediate: true}
)
+// Valide/auto-sélectionne le véhicule selon camion + transporteur (LIOT)
watch(
() => form.carrierId,
() => {
@@ -372,6 +390,7 @@ watch(
{immediate: true}
)
+// Récupère la plaque depuis le véhicule choisi (LIOT)
watch(
() => [form.truckId, form.carrierId, vehicles.value],
() => {
@@ -395,6 +414,7 @@ watch(
{immediate: true}
)
+// Auto-renseigne le véhicule si la plaque correspond (LIOT)
watch(
() => [form.vehicleId, form.carrierId, vehicles.value],
() => {
@@ -428,6 +448,7 @@ watch(
}
)
+// Valide le formulaire et crée/met à jour la réception
async function validate() {
const normalizedLicensePlate = form.licensePlate.trim()
const normalizedReceptionDate = form.receptionDate.trim()
diff --git a/frontend/components/reception/reception-product-received.vue b/frontend/components/reception/reception-product-received.vue
index 8e58e6c..20ec5ed 100644
--- a/frontend/components/reception/reception-product-received.vue
+++ b/frontend/components/reception/reception-product-received.vue
@@ -98,12 +98,16 @@ const selectedBuildingIds = ref([])
const selectedPelletBuildingIds = ref>({})
const merchandiseDetail = ref('')
+// Type de marchandise sélectionné dans le select
const selectedMerchandiseType = computed(() =>
merchandiseTypes.value.find((type) => String(type.id) === selectedMerchandiseTypeId.value)
)
+// Indique si le type est "Granulé"
const isGranule = computed(() => selectedMerchandiseType.value?.code === MERCHANDISE_TYPE_CODES.GRANULE)
+// Indique si le type est "Autres"
const isAutres = computed(() => selectedMerchandiseType.value?.code === MERCHANDISE_TYPE_CODES.AUTRES)
+// Charge les référentiels et hydrate le formulaire depuis la réception
onMounted(async () => {
const [merchandiseTypeList, buildingList, pelletTypeList] = await Promise.all([
getMerchandiseTypeList(),
@@ -142,6 +146,7 @@ onMounted(async () => {
selectedPelletBuildingIds.value = selectionMap
})
+// Enregistre les sélections et passe à l'étape suivante
async function goNext() {
if (!receptionStore.current) {
return
@@ -168,6 +173,7 @@ async function goNext() {
}
}
+// Supprime toutes les associations granulés/bâtiments existantes
async function clearPelletSelections(receptionIri: string) {
const existing = await getReceptionPelletBuildingList(receptionIri)
for (const selection of existing) {
@@ -175,6 +181,7 @@ async function clearPelletSelections(receptionIri: string) {
}
}
+// Synchronise les associations granulés/bâtiments avec l'état du formulaire
async function syncPelletSelections(receptionIri: string) {
const existing = await getReceptionPelletBuildingList(receptionIri)
const existingMap = new Map()
diff --git a/frontend/components/reception/reception-weight.vue b/frontend/components/reception/reception-weight.vue
index cf6c7a9..a227e1a 100644
--- a/frontend/components/reception/reception-weight.vue
+++ b/frontend/components/reception/reception-weight.vue
@@ -62,10 +62,12 @@ const {
updateReception: receptionStore.updateReception,
loadReception: receptionStore.loadReception
})
+// Affiche le bouton de génération du bon à l'étape tare
const showGenerateReceipt = computed(
() => props.mode === 'tare' && displayWeight.value !== null
)
+// Génère le bon de réception, puis clôture la réception
const printReceipt = async () => {
if (!import.meta.client || !receptionStore.current) {
return
@@ -88,6 +90,7 @@ const printReceipt = async () => {
await router.push('/')
}
+// Récupère le poids dès l'arrivée sur l'écran
onMounted(() => {
fetchWeight()
})
diff --git a/frontend/composables/usePdfPrinter.ts b/frontend/composables/usePdfPrinter.ts
index b920f1e..f7215ac 100644
--- a/frontend/composables/usePdfPrinter.ts
+++ b/frontend/composables/usePdfPrinter.ts
@@ -24,7 +24,7 @@ export const usePdfPrinter = () => {
a.click();
a.remove();
- window.open(blobUrl, '_blank', 'noopener,noreferrer');
+ // L'ouverture dans un nouvel onglet déclenche un 2e PDF sans le nom personnalisé.
setTimeout(() => URL.revokeObjectURL(blobUrl), 60_000);
}
diff --git a/frontend/utils/constants.ts b/frontend/utils/constants.ts
index 00d3a3e..3676886 100644
--- a/frontend/utils/constants.ts
+++ b/frontend/utils/constants.ts
@@ -6,3 +6,7 @@ export const MERCHANDISE_TYPE_CODES = {
GRANULE: 'GRANULE',
AUTRES: 'AUTRES'
} as const
+
+export const SUPLLIER_CODE = {
+ LIOT: 'LIOT'
+}