fix : correction des retours de la V0
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
<div class="flex justify-between h-[52px] mb-[80px]">
|
||||
<div class="flex flex-1 mr-16">
|
||||
<UiStepper
|
||||
:labels="RECEPTION_STEP_LABELS"
|
||||
:labels="stepLabels"
|
||||
:current-step="storeReception?.currentStep ?? 0"
|
||||
@select="handleStepSelect"
|
||||
/>
|
||||
@@ -15,76 +15,70 @@
|
||||
</UiButton>
|
||||
</div>
|
||||
<ReceptionForm v-if="!storeReception || storeReception.currentStep === 0"/>
|
||||
<ReceptionWeight v-if="storeReception?.currentStep === 1" mode="gross"/>
|
||||
<WorkflowWeight
|
||||
v-if="storeReception?.currentStep === 1"
|
||||
mode="gross"
|
||||
entity-name="reception"
|
||||
api-resource="receptions"
|
||||
:title-label="receptionConfig.weighingLabels.gross"
|
||||
:is-final="false"
|
||||
:entity="storeReception"
|
||||
:get-weight-from-scale="getWeight"
|
||||
:update-entity="receptionStore.updateReception"
|
||||
:load-entity="receptionStore.loadReception"
|
||||
:clear-entity="receptionStore.clearCurrent"
|
||||
:build-receipt-filename="receptionConfig.buildReceiptFilename"
|
||||
/>
|
||||
<ReceptionProductReceived
|
||||
v-if="storeReception?.currentStep === 2 &&
|
||||
receptionStore.current?.receptionType?.code === RECEPTION_TYPE_CODES.MERCHANDISES"/>
|
||||
<ReceptionBovineReceived
|
||||
v-if="storeReception?.currentStep === 2 &&
|
||||
receptionStore.current?.receptionType?.code === RECEPTION_TYPE_CODES.BOVINS"/>
|
||||
<ReceptionWeight v-if="storeReception?.currentStep !== null && storeReception?.currentStep >= 3" mode="tare"/>
|
||||
<WorkflowWeight
|
||||
v-if="storeReception?.currentStep !== null && storeReception?.currentStep >= 3"
|
||||
mode="tare"
|
||||
entity-name="reception"
|
||||
api-resource="receptions"
|
||||
:title-label="receptionConfig.weighingLabels.tare"
|
||||
:is-final="true"
|
||||
:entity="storeReception"
|
||||
:get-weight-from-scale="getWeight"
|
||||
:update-entity="receptionStore.updateReception"
|
||||
:load-entity="receptionStore.loadReception"
|
||||
:clear-entity="receptionStore.clearCurrent"
|
||||
:build-receipt-filename="receptionConfig.buildReceiptFilename"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import {useReceptionStore} from '~/stores/reception'
|
||||
import {storeToRefs} from 'pinia'
|
||||
import {RECEPTION_STEP_LABELS} from '~/constants/steps'
|
||||
import {RECEPTION_TYPE_CODES} from "~/utils/constants";
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
import { useReceptionStore } from '~/stores/reception'
|
||||
import { storeToRefs } from 'pinia'
|
||||
import { useWorkflowSteps } from '~/composables/useWorkflowSteps'
|
||||
import { receptionConfig } from '~/config/reception.config'
|
||||
import { getWeight } from '~/services/reception'
|
||||
import { RECEPTION_TYPE_CODES } from '~/utils/constants'
|
||||
|
||||
const receptionStore = useReceptionStore()
|
||||
const {current: storeReception} = storeToRefs(receptionStore)
|
||||
const { current: storeReception } = storeToRefs(receptionStore)
|
||||
|
||||
const resolveReceptionId = (param: unknown) => {
|
||||
const idStr = Array.isArray(param) ? param[0] : param
|
||||
if (!idStr) {
|
||||
return null
|
||||
}
|
||||
const id = Number(idStr)
|
||||
return Number.isFinite(id) ? id : null
|
||||
}
|
||||
const { stepLabels, saveAndHold, handleStepSelect } = useWorkflowSteps(receptionConfig, receptionStore)
|
||||
|
||||
// Init route watcher
|
||||
const route = useRoute()
|
||||
watch(
|
||||
() => route.params.id,
|
||||
async (param) => {
|
||||
const id = resolveReceptionId(param)
|
||||
if (id === null) {
|
||||
const idStr = Array.isArray(param) ? param[0] : param
|
||||
if (!idStr) {
|
||||
receptionStore.clearCurrent()
|
||||
return
|
||||
}
|
||||
await receptionStore.loadReception(id)
|
||||
const id = Number(idStr)
|
||||
if (Number.isFinite(id)) {
|
||||
await receptionStore.loadReception(id)
|
||||
}
|
||||
},
|
||||
{immediate: true}
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
const saveAndHold = async () => {
|
||||
if (!receptionStore.current) {
|
||||
await router.push('/')
|
||||
return
|
||||
}
|
||||
|
||||
await receptionStore.updateReception(receptionStore.current.id, {
|
||||
currentStep: receptionStore.current.currentStep,
|
||||
licensePlate: receptionStore.current.licensePlate,
|
||||
receptionDate: receptionStore.current.receptionDate
|
||||
})
|
||||
await router.push('/')
|
||||
}
|
||||
|
||||
const handleStepSelect = async (step: number) => {
|
||||
if (!receptionStore.current) {
|
||||
return
|
||||
}
|
||||
|
||||
if (step === receptionStore.current.currentStep) {
|
||||
return
|
||||
}
|
||||
|
||||
await receptionStore.updateReception(receptionStore.current.id, {
|
||||
currentStep: step
|
||||
})
|
||||
await receptionStore.loadReception(receptionStore.current.id)
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user