feat : finalisation de affichage et update reception terminee suite
This commit is contained in:
@@ -34,6 +34,7 @@ Ajouter dans le fichier .env du frontend
|
|||||||
* [#315] Creation page admin utilisateur
|
* [#315] Creation page admin utilisateur
|
||||||
* [#317] Admin modification creation transporteur
|
* [#317] Admin modification creation transporteur
|
||||||
* [#318] Affichage modification reception terminée
|
* [#318] Affichage modification reception terminée
|
||||||
|
* [#320] Affichage modification reception terminée suite
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
|||||||
183
frontend/components/reception/update-bovin.vue
Normal file
183
frontend/components/reception/update-bovin.vue
Normal file
@@ -0,0 +1,183 @@
|
|||||||
|
<template>
|
||||||
|
<form @submit.prevent="validate">
|
||||||
|
<div
|
||||||
|
class="flex flex-col items-center gap-16">
|
||||||
|
<div
|
||||||
|
class="flex flex-row gap-6 items-center">
|
||||||
|
<div
|
||||||
|
v-for="type in bovineType"
|
||||||
|
:key="type.id"
|
||||||
|
class="flex flex-row mb-2 gap-6 ">
|
||||||
|
<UiNumberInput
|
||||||
|
:label="type.label"
|
||||||
|
:code="type.code"
|
||||||
|
v-model="bovineQuantities[String(type.id)]"
|
||||||
|
:disabled="!auth.isAdmin"
|
||||||
|
:placeholder="0"
|
||||||
|
:min="0"
|
||||||
|
:max="10"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class=" flex flex-row mb-2 gap-6">
|
||||||
|
<UiNumberInput
|
||||||
|
label="Autres"
|
||||||
|
v-model="otherQuantity"
|
||||||
|
:disabled="!auth.isAdmin"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<button
|
||||||
|
type="submit"
|
||||||
|
class="text-xl uppercase bg-primary-500 text-white h-[50px] w-[272px]"
|
||||||
|
:disabled="!auth.isAdmin"
|
||||||
|
>Valider
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</template>
|
||||||
|
<script setup lang="ts">
|
||||||
|
import type {BovineTypeData} from "~/services/dto/bovine-type-data";
|
||||||
|
import {getBovineTypeList} from "~/services/bovine-type";
|
||||||
|
import {
|
||||||
|
createReceptionBovine,
|
||||||
|
deleteReceptionBovine,
|
||||||
|
getReceptionBovineList,
|
||||||
|
updateReceptionBovine
|
||||||
|
} from "~/services/reception-bovine";
|
||||||
|
import {computed, onMounted, reactive, ref, watch} from "vue";
|
||||||
|
import {getReception, updateReception} from "~/services/reception";
|
||||||
|
const toast = useToast()
|
||||||
|
const isLoadingBovineType = ref(false)
|
||||||
|
const bovineType = ref<BovineTypeData[]>([])
|
||||||
|
const bovineQuantities = reactive<Record<string, number | null>>({})
|
||||||
|
const otherQuantity = ref<number | null>(0)
|
||||||
|
const auth = useAuthStore()
|
||||||
|
const props = defineProps<{
|
||||||
|
idReception: number
|
||||||
|
}>()
|
||||||
|
const receptionId = props.idReception
|
||||||
|
const reception = await getReception(receptionId)
|
||||||
|
|
||||||
|
const receptionIri = computed(() =>
|
||||||
|
receptionId ? `/api/receptions/${receptionId}` : null
|
||||||
|
)
|
||||||
|
const totalBovines = computed(() => {
|
||||||
|
const base = Object.values(bovineQuantities).reduce((sum, value) => {
|
||||||
|
return sum + (value ?? 0)
|
||||||
|
}, 0)
|
||||||
|
return base + (otherQuantity.value ?? 0)
|
||||||
|
})
|
||||||
|
|
||||||
|
const loadBovineType = async () => {
|
||||||
|
isLoadingBovineType.value = true
|
||||||
|
try {
|
||||||
|
bovineType.value = await getBovineTypeList()
|
||||||
|
} finally {
|
||||||
|
isLoadingBovineType.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
await loadBovineType()
|
||||||
|
})
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => receptionId,
|
||||||
|
async (id) => {
|
||||||
|
if (!id || !receptionIri.value) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const selectionMap: Record<string, number | null> = {}
|
||||||
|
for (const type of bovineType.value) {
|
||||||
|
selectionMap[String(type.id)] = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
const existing = await getReceptionBovineList(receptionIri.value)
|
||||||
|
for (const selection of existing) {
|
||||||
|
const bovineTypeId = String(selection.bovineType.id)
|
||||||
|
selectionMap[bovineTypeId] = selection.quantity ?? 0
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const key of Object.keys(bovineQuantities)) {
|
||||||
|
delete bovineQuantities[key]
|
||||||
|
}
|
||||||
|
Object.assign(bovineQuantities, selectionMap)
|
||||||
|
|
||||||
|
const existingOther = await reception.bovineDetail
|
||||||
|
const parsedOther =
|
||||||
|
typeof existingOther === 'string' && existingOther.trim() !== ''
|
||||||
|
? Number(existingOther)
|
||||||
|
: 0
|
||||||
|
otherQuantity.value = Number.isFinite(parsedOther) ? parsedOther : 0
|
||||||
|
},
|
||||||
|
{immediate: true}
|
||||||
|
)
|
||||||
|
|
||||||
|
async function syncBovineSelections(receptionIri: string) {
|
||||||
|
const existing = await getReceptionBovineList(receptionIri)
|
||||||
|
const existingMap = new Map<string, { id: number; quantity: number | null }>()
|
||||||
|
|
||||||
|
for (const selection of existing) {
|
||||||
|
const bovineTypeId = String(selection.bovineType.id)
|
||||||
|
existingMap.set(bovineTypeId, {
|
||||||
|
id: selection.id,
|
||||||
|
quantity: selection.quantity ?? 0
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// Supprime les entrées supprimées ou modifiées
|
||||||
|
for (const [bovineTypeId, entry] of existingMap.entries()) {
|
||||||
|
const selectedQuantity = bovineQuantities[bovineTypeId] ?? 0
|
||||||
|
if (!selectedQuantity) {
|
||||||
|
await deleteReceptionBovine(entry.id)
|
||||||
|
existingMap.delete(bovineTypeId)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if (selectedQuantity !== entry.quantity) {
|
||||||
|
await updateReceptionBovine(entry.id, {quantity: selectedQuantity})
|
||||||
|
existingMap.set(bovineTypeId, {
|
||||||
|
id: entry.id,
|
||||||
|
quantity: selectedQuantity
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Crée les entrées manquantes
|
||||||
|
for (const [bovineTypeId, quantity] of Object.entries(bovineQuantities)) {
|
||||||
|
if (!quantity) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if (existingMap.has(bovineTypeId)) {
|
||||||
|
// Déjà à jour
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
await createReceptionBovine({
|
||||||
|
reception: receptionIri,
|
||||||
|
bovineType: `/api/bovine_types/${bovineTypeId}`,
|
||||||
|
quantity
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function validate() {
|
||||||
|
// @TODO Ajouter un composable pour le toaster qui gère les key i18n
|
||||||
|
if (totalBovines.value > 52) {
|
||||||
|
toast.error({
|
||||||
|
title: 'Erreur',
|
||||||
|
message: ('Le total des bovins ne peut pas dépasser 52.')
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
await syncBovineSelections(receptionIri.value)
|
||||||
|
|
||||||
|
await updateReception(receptionId, {
|
||||||
|
merchandiseType: null,
|
||||||
|
merchandiseDetail: null,
|
||||||
|
bovineDetail: otherQuantity.value ? String(otherQuantity.value) : null,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</script>
|
||||||
257
frontend/components/reception/update-merchandise.vue
Normal file
257
frontend/components/reception/update-merchandise.vue
Normal file
@@ -0,0 +1,257 @@
|
|||||||
|
<template>
|
||||||
|
<form @submit.prevent="validate">
|
||||||
|
<div class="flex flex-col items-center gap-16">
|
||||||
|
<div
|
||||||
|
class="flex flex-col gap-16 items-center w-full">
|
||||||
|
<UiTextInput
|
||||||
|
id="merchandise-type"
|
||||||
|
v-model="selectedMerchandiseTypeId"
|
||||||
|
label="Type de marchandises"
|
||||||
|
:value="reception.merchandiseType?.label"
|
||||||
|
wrapper-class="w-[550px]"
|
||||||
|
:disabled="true"
|
||||||
|
/>
|
||||||
|
<div
|
||||||
|
v-if="merchandiseTypeId && isAutres"
|
||||||
|
class="flex flex-col w-full max-w-[550px]"
|
||||||
|
>
|
||||||
|
<UiTextInput
|
||||||
|
id="merchandise-detail"
|
||||||
|
:disabled="!auth.isAdmin"
|
||||||
|
v-model="merchandiseDetail"
|
||||||
|
label="Préciser"
|
||||||
|
placeholder="Précisions complémentaires"
|
||||||
|
:maxlength="255"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-if="merchandiseTypeId && !isGranule"
|
||||||
|
class="flex gap-4 w-[550px] justify-evenly"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
v-for="building in buildings"
|
||||||
|
:key="building.id"
|
||||||
|
>
|
||||||
|
<UiCheckbox
|
||||||
|
v-model="selectedBuildingIds"
|
||||||
|
:value="String(building.id)"
|
||||||
|
:label="building.label"
|
||||||
|
:disabled="!auth.isAdmin"
|
||||||
|
label-class="text-xl"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
v-if="merchandiseTypeId && isGranule"
|
||||||
|
class="flex flex-col gap-10 w-full max-w-[1100px]"
|
||||||
|
>
|
||||||
|
<div class="grid grid-cols-1 gap-10 md:grid-cols-4">
|
||||||
|
<div v-for="type in pelletTypes" :key="type.id" class="flex flex-col gap-4">
|
||||||
|
<p class="font-bold uppercase">{{ type.label }}</p>
|
||||||
|
<div
|
||||||
|
v-for="building in buildings"
|
||||||
|
:key="building.id"
|
||||||
|
class="flex items-center gap-2 text-lg"
|
||||||
|
>
|
||||||
|
<UiCheckbox
|
||||||
|
v-model="selectedPelletBuildingIds[String(type.id)]"
|
||||||
|
:value="String(building.id)"
|
||||||
|
:label="building.label"
|
||||||
|
:disabled="!auth.isAdmin"
|
||||||
|
label-class="text-lg"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<button
|
||||||
|
type="submit"
|
||||||
|
class="text-xl uppercase bg-primary-500 text-white h-[50px] w-[272px]"
|
||||||
|
:disabled="!auth.isAdmin"
|
||||||
|
>Valider
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import {computed, onMounted, ref} from 'vue'
|
||||||
|
import {getBuildingList} from '~/services/building'
|
||||||
|
import {getMerchandiseTypeList} from '~/services/merchandise-type'
|
||||||
|
import type {MerchandiseTypeData} from '~/services/dto/merchandise-type-data'
|
||||||
|
import type {BuildingData} from '~/services/dto/building-data'
|
||||||
|
import type {PelletTypeData} from '~/services/dto/pellet-type-data'
|
||||||
|
import {getPelletTypeList} from '~/services/pellet-type'
|
||||||
|
import {
|
||||||
|
createReceptionPelletBuilding,
|
||||||
|
deleteReceptionPelletBuilding,
|
||||||
|
getReceptionPelletBuildingList
|
||||||
|
} from '~/services/reception-pellet-building'
|
||||||
|
import {MERCHANDISE_TYPE_CODES} from '~/utils/constants'
|
||||||
|
import {getReception, updateReception} from "~/services/reception";
|
||||||
|
|
||||||
|
const merchandiseTypes = ref<MerchandiseTypeData[]>([])
|
||||||
|
const buildings = ref<BuildingData[]>([])
|
||||||
|
const pelletTypes = ref<PelletTypeData[]>([])
|
||||||
|
const selectedMerchandiseTypeId = ref('')
|
||||||
|
const selectedBuildingIds = ref<string[]>([])
|
||||||
|
const selectedPelletBuildingIds = ref<Record<string, string[]>>({})
|
||||||
|
const merchandiseDetail = ref('')
|
||||||
|
const auth = useAuthStore()
|
||||||
|
const props = defineProps<{
|
||||||
|
idReception: number
|
||||||
|
}>()
|
||||||
|
const receptionId = props.idReception
|
||||||
|
const reception = await getReception(receptionId)
|
||||||
|
const merchandiseTypeId = await reception.receptionType?.id
|
||||||
|
|
||||||
|
// Extrait l'ID d'une relation depuis un IRI ou un objet complet.
|
||||||
|
const getRelationId = (value: unknown): string | null => {
|
||||||
|
if (!value) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof value === 'string') {
|
||||||
|
const match = value.match(/\/(\d+)$/)
|
||||||
|
return match ? match[1] : null
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof value === 'object' && 'id' in value) {
|
||||||
|
const record = value as { id?: number | string }
|
||||||
|
if (typeof record.id === 'number') {
|
||||||
|
return String(record.id)
|
||||||
|
}
|
||||||
|
if (typeof record.id === 'string') {
|
||||||
|
return record.id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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(),
|
||||||
|
getBuildingList(),
|
||||||
|
getPelletTypeList()
|
||||||
|
])
|
||||||
|
merchandiseTypes.value = merchandiseTypeList
|
||||||
|
buildings.value = buildingList
|
||||||
|
pelletTypes.value = pelletTypeList
|
||||||
|
|
||||||
|
const currentId = reception.merchandiseType?.id
|
||||||
|
if (currentId) {
|
||||||
|
selectedMerchandiseTypeId.value = String(currentId)
|
||||||
|
}
|
||||||
|
merchandiseDetail.value = reception.merchandiseDetail ?? ''
|
||||||
|
|
||||||
|
selectedBuildingIds.value =
|
||||||
|
reception.buildings?.map((building) => String(building.id)) ?? []
|
||||||
|
|
||||||
|
const existingPelletSelections = reception.pelletBuildings ?? []
|
||||||
|
const selectionMap: Record<string, string[]> = {}
|
||||||
|
for (const selection of existingPelletSelections) {
|
||||||
|
// L'API peut renvoyer les relations comme IRI ou comme objets selon le contexte.
|
||||||
|
const pelletTypeId = getRelationId(selection.pelletType)
|
||||||
|
const buildingId = getRelationId(selection.building)
|
||||||
|
if (!pelletTypeId || !buildingId) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if (!selectionMap[pelletTypeId]) {
|
||||||
|
selectionMap[pelletTypeId] = []
|
||||||
|
}
|
||||||
|
selectionMap[pelletTypeId].push(buildingId)
|
||||||
|
}
|
||||||
|
for (const pelletType of pelletTypes.value) {
|
||||||
|
const key = String(pelletType.id)
|
||||||
|
if (!selectionMap[key]) {
|
||||||
|
selectionMap[key] = []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
selectedPelletBuildingIds.value = selectionMap
|
||||||
|
})
|
||||||
|
// Enregistre les sélections et passe à l'étape suivante
|
||||||
|
async function validate() {
|
||||||
|
|
||||||
|
const receptionIri = `/api/receptions/${reception.id}`
|
||||||
|
|
||||||
|
await updateReception(reception.id, {
|
||||||
|
merchandiseDetail: isAutres.value ? merchandiseDetail.value.trim() : null,
|
||||||
|
buildings: isGranule.value
|
||||||
|
? []
|
||||||
|
: selectedBuildingIds.value.map((id) => `/api/buildings/${id}`),
|
||||||
|
bovineDetail: null,
|
||||||
|
bovinesTypes: null,
|
||||||
|
})
|
||||||
|
|
||||||
|
if (isGranule.value) {
|
||||||
|
await syncPelletSelections(receptionIri)
|
||||||
|
} else {
|
||||||
|
await clearPelletSelections(receptionIri)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Supprime toutes les associations granulés/bâtiments existantes
|
||||||
|
async function clearPelletSelections(receptionIri: string) {
|
||||||
|
const existing = await getReceptionPelletBuildingList(receptionIri)
|
||||||
|
for (const selection of existing) {
|
||||||
|
await deleteReceptionPelletBuilding(selection.id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 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<string, number>()
|
||||||
|
for (const selection of existing) {
|
||||||
|
// Construit la table de correspondance avec des IDs normalisés pour éviter les doublons.
|
||||||
|
const pelletTypeId = getRelationId(selection.pelletType)
|
||||||
|
const buildingId = getRelationId(selection.building)
|
||||||
|
if (!pelletTypeId || !buildingId) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
const key = `${pelletTypeId}:${buildingId}`
|
||||||
|
existingMap.set(key, selection.id)
|
||||||
|
}
|
||||||
|
|
||||||
|
const desiredEntries: Array<{ pelletTypeId: string; buildingId: string }> = []
|
||||||
|
for (const [pelletTypeId, buildingIds] of Object.entries(selectedPelletBuildingIds.value)) {
|
||||||
|
for (const buildingId of buildingIds) {
|
||||||
|
desiredEntries.push({pelletTypeId, buildingId})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const desiredKeys = new Set(desiredEntries.map(
|
||||||
|
(entry) => `${entry.pelletTypeId}:${entry.buildingId}`
|
||||||
|
))
|
||||||
|
|
||||||
|
for (const [key, id] of existingMap.entries()) {
|
||||||
|
if (!desiredKeys.has(key)) {
|
||||||
|
await deleteReceptionPelletBuilding(id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const entry of desiredEntries) {
|
||||||
|
const key = `${entry.pelletTypeId}:${entry.buildingId}`
|
||||||
|
if (!existingMap.has(key)) {
|
||||||
|
await createReceptionPelletBuilding({
|
||||||
|
reception: receptionIri,
|
||||||
|
pelletType: `/api/pellet_types/${entry.pelletTypeId}`,
|
||||||
|
building: `/api/buildings/${entry.buildingId}`
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@@ -1,40 +1,47 @@
|
|||||||
<template>
|
<template>
|
||||||
<form @submit.prevent="validate">
|
<form @submit.prevent="validate">
|
||||||
|
|
||||||
<div class="grid grid-cols-2 gap-x-40 gap-y-8 mb-16">
|
<div class="grid grid-cols-2 gap-x-40 gap-y-8 mb-16">
|
||||||
<UiNumberInput
|
<UiNumberInput
|
||||||
label="Pesée à vide"
|
label="Pesée à vide"
|
||||||
v-model="form.weights[0].weight"
|
v-model="form.weights[0].weight"
|
||||||
|
:disabled="!auth.isAdmin"
|
||||||
:min="0"
|
:min="0"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<UiNumberInput
|
<UiNumberInput
|
||||||
label="Pesée à plein"
|
label="Pesée à plein"
|
||||||
v-model="form.weights[1].weight"
|
v-model="form.weights[1].weight"
|
||||||
|
:disabled="!auth.isAdmin"
|
||||||
:min="0"
|
:min="0"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button
|
<div class="flex justify-center">
|
||||||
type="submit"
|
<button
|
||||||
class="bg-primary-500 text-white px-6 py-3 rounded-md"
|
type="submit"
|
||||||
>
|
class="text-xl uppercase bg-primary-500 text-white h-[50px] w-[272px]"
|
||||||
Enregistrer
|
:disabled="!auth.isAdmin"
|
||||||
</button>
|
>
|
||||||
|
Valider
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type {ReceptionFormWeight, ReceptionUpdatePayload} from '~/services/dto/reception-data'
|
import type {ReceptionFormWeight} from '~/services/dto/reception-data'
|
||||||
import { getReception } from '~/services/reception'
|
import { getReception } from '~/services/reception'
|
||||||
import { useReceptionStore } from '~/stores/reception'
|
|
||||||
import {updateWeight} from "~/services/weight";
|
import {updateWeight} from "~/services/weight";
|
||||||
|
import {useAuthStore} from "~/stores/auth";
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
idReception: number
|
idReception: number
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const receptionStore = useReceptionStore()
|
const idReception = props.idReception
|
||||||
const router = useRouter()
|
const auth = useAuthStore()
|
||||||
|
|
||||||
const form = reactive({
|
const form = reactive({
|
||||||
weights: [
|
weights: [
|
||||||
@@ -52,7 +59,7 @@ const hydrateFromReception = (reception: ReceptionFormWeight) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
const reception = await getReception(props.idReception)
|
const reception = await getReception(idReception)
|
||||||
hydrateFromReception(reception)
|
hydrateFromReception(reception)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
<button
|
<button
|
||||||
type="submit"
|
type="submit"
|
||||||
class="text-xl uppercase bg-primary-500 text-white h-[50px] w-[272px] justify-self-end"
|
class="text-xl uppercase bg-primary-500 text-white h-[50px] w-[272px] justify-self-end"
|
||||||
|
:disabled="!auth.isAdmin"
|
||||||
>Enregistrer
|
>Enregistrer
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
@@ -120,12 +121,27 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="grid grid-cols-2 items-start gap-y-8 gap-x-40 mb-16">
|
<div class="grid grid-cols-2 items-start gap-y-8 gap-x-40 mb-16">
|
||||||
<h1 class="font-bold text-5xl uppercase col-start-1 row-start-1">pesée</h1>
|
<h1 class="font-bold text-5xl uppercase col-start-1 row-start-1" @click="isBtWeight = true" >pesées</h1>
|
||||||
<h1 class="font-bold text-5xl uppercase col-start-2 row-start-1">marchandise</h1>
|
<h1 class="font-bold text-5xl uppercase col-start-2 row-start-1" @click="isBtWeight = false">{{isMerchandise ? "Marchandises" : "Bovins"}}</h1>
|
||||||
</div>
|
</div>
|
||||||
<update-weight
|
<update-weight
|
||||||
|
v-if="isBtWeight"
|
||||||
:idReception="idReception"
|
:idReception="idReception"
|
||||||
|
:disabled="!auth.isAdmin"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<update-merchandise
|
||||||
|
v-else-if="isMerchandise"
|
||||||
|
:idReception="idReception"
|
||||||
|
:disabled="!auth.isAdmin"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<update-bovin
|
||||||
|
v-else
|
||||||
|
:idReception="idReception"
|
||||||
|
:disabled="!auth.isAdmin"
|
||||||
|
/>
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -149,6 +165,8 @@ import {deleteReceptionBovine, getReceptionBovineList} from "~/services/receptio
|
|||||||
import type {ReceptionData, ReceptionFormData} from "~/services/dto/reception-data";
|
import type {ReceptionData, ReceptionFormData} from "~/services/dto/reception-data";
|
||||||
import {getReception} from "~/services/reception";
|
import {getReception} from "~/services/reception";
|
||||||
import UpdateWeight from "~/components/reception/update-weight.vue";
|
import UpdateWeight from "~/components/reception/update-weight.vue";
|
||||||
|
import UpdateMerchandise from "~/components/reception/update-merchandise.vue";
|
||||||
|
import UpdateBovin from "~/components/reception/update-bovin.vue";
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const receptionStore = useReceptionStore()
|
const receptionStore = useReceptionStore()
|
||||||
@@ -187,6 +205,8 @@ const idReception = Number(route.params.id)
|
|||||||
const receptionLoad = await getReception(idReception)
|
const receptionLoad = await getReception(idReception)
|
||||||
const receptionType = receptionLoad.receptionType
|
const receptionType = receptionLoad.receptionType
|
||||||
const auth = useAuthStore()
|
const auth = useAuthStore()
|
||||||
|
const isBtWeight = ref(true)
|
||||||
|
const isMerchandise = ref(receptionType.code === 'MARCHANDISES')
|
||||||
|
|
||||||
// Transporteur sélectionné dans le formulaire
|
// Transporteur sélectionné dans le formulaire
|
||||||
const selectedCarrier = computed(() =>
|
const selectedCarrier = computed(() =>
|
||||||
|
|||||||
Reference in New Issue
Block a user