fix : correction des retours de la V0
This commit is contained in:
@@ -3,10 +3,9 @@
|
||||
<div class="flex justify-between h-[52px] mb-[80px]">
|
||||
<div class="flex flex-1 mr-16">
|
||||
<UiStepper
|
||||
:labels="SHIPMENT_STEP_LABELS"
|
||||
:labels="stepLabels"
|
||||
:current-step="storeShipment?.currentStep ?? 0"
|
||||
@select="handleStepSelect"
|
||||
|
||||
/>
|
||||
</div>
|
||||
<UiButton
|
||||
@@ -17,45 +16,69 @@
|
||||
</UiButton>
|
||||
</div>
|
||||
<ShipmentForm v-if="!storeShipment || storeShipment.currentStep === 0" ref="shipmentFormRef"/>
|
||||
<ShipmentWeight v-if="storeShipment?.currentStep === 1" mode="gross"/>
|
||||
<WorkflowWeight
|
||||
v-if="storeShipment?.currentStep === 1"
|
||||
mode="gross"
|
||||
entity-name="shipment"
|
||||
api-resource="shipments"
|
||||
:title-label="shipmentConfig.weighingLabels.gross"
|
||||
:is-final="false"
|
||||
:entity="storeShipment"
|
||||
:get-weight-from-scale="getWeightShipment"
|
||||
:update-entity="shipmentStore.updateShipment"
|
||||
:load-entity="shipmentStore.loadShipment"
|
||||
:clear-entity="shipmentStore.clearCurrent"
|
||||
:build-receipt-filename="shipmentConfig.buildReceiptFilename"
|
||||
/>
|
||||
<ShipmentLoading v-if="storeShipment?.currentStep === 2"/>
|
||||
<ShipmentWeight v-if="storeShipment?.currentStep === 3" mode="tare"/>
|
||||
|
||||
<WorkflowWeight
|
||||
v-if="storeShipment?.currentStep === 3"
|
||||
mode="tare"
|
||||
entity-name="shipment"
|
||||
api-resource="shipments"
|
||||
:title-label="shipmentConfig.weighingLabels.tare"
|
||||
:is-final="true"
|
||||
:entity="storeShipment"
|
||||
:get-weight-from-scale="getWeightShipment"
|
||||
:update-entity="shipmentStore.updateShipment"
|
||||
:load-entity="shipmentStore.loadShipment"
|
||||
:clear-entity="shipmentStore.clearCurrent"
|
||||
:build-receipt-filename="shipmentConfig.buildReceiptFilename"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
|
||||
import {SHIPMENT_STEP_LABELS} from "~/constants/steps";
|
||||
import {storeToRefs} from "pinia";
|
||||
import {useShipmentStore} from "~/stores/shipment";
|
||||
<script setup lang="ts">
|
||||
import { storeToRefs } from 'pinia'
|
||||
import { useShipmentStore } from '~/stores/shipment'
|
||||
import { useWorkflowSteps } from '~/composables/useWorkflowSteps'
|
||||
import { shipmentConfig } from '~/config/shipment.config'
|
||||
import { getWeightShipment } from '~/services/shipment'
|
||||
import { ref, watch } from 'vue'
|
||||
|
||||
const shipmentStore = useShipmentStore()
|
||||
const {current: storeShipment} = storeToRefs(shipmentStore)
|
||||
const { current: storeShipment } = storeToRefs(shipmentStore)
|
||||
const shipmentFormRef = ref<{ saveDraft: () => Promise<void> } | null>(null)
|
||||
|
||||
const { stepLabels, handleStepSelect } = useWorkflowSteps(shipmentConfig, shipmentStore)
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
|
||||
const resolveShipmentId = (param: unknown) => {
|
||||
const idStr = Array.isArray(param) ? param[0] : param
|
||||
if (!idStr) {
|
||||
return null
|
||||
}
|
||||
const id = Number(idStr)
|
||||
return Number.isFinite(id) ? id : null
|
||||
}
|
||||
|
||||
watch (
|
||||
watch(
|
||||
() => route.params.id,
|
||||
async (param) => {
|
||||
const id = resolveShipmentId(param)
|
||||
if (id === null) {
|
||||
const idStr = Array.isArray(param) ? param[0] : param
|
||||
if (!idStr) {
|
||||
shipmentStore.clearCurrent()
|
||||
return
|
||||
}
|
||||
await shipmentStore.loadShipment(id)
|
||||
const id = Number(idStr)
|
||||
if (Number.isFinite(id)) {
|
||||
await shipmentStore.loadShipment(id)
|
||||
}
|
||||
},
|
||||
{immediate: true}
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
const saveAndHold = async () => {
|
||||
@@ -64,20 +87,4 @@ const saveAndHold = async () => {
|
||||
}
|
||||
await router.push('/')
|
||||
}
|
||||
const handleStepSelect = async (step: number) => {
|
||||
if (!shipmentStore.current) {
|
||||
return
|
||||
}
|
||||
|
||||
if (step === shipmentStore.current.currentStep) {
|
||||
return
|
||||
}
|
||||
|
||||
await shipmentStore.updateShipment(shipmentStore.current.id, {
|
||||
currentStep: step
|
||||
})
|
||||
await shipmentStore.loadShipment(shipmentStore.current.id)
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user