fix : correction de l'enregistrement des pesées sur l'admin
This commit is contained in:
82
.idea/workspace.xml
generated
82
.idea/workspace.xml
generated
@@ -4,10 +4,12 @@
|
|||||||
<option name="autoReloadType" value="SELECTIVE" />
|
<option name="autoReloadType" value="SELECTIVE" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="7c107abe-5995-4428-8429-b146aaca8386" name="Changes" comment="fix : corrections diverses">
|
<list default="true" id="7c107abe-5995-4428-8429-b146aaca8386" name="Changes" comment="fix : correction du retour sur la liste des réceptions + suppression de la redirection après enregistrement">
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/data_source_mapping.xml" beforeDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/CHANGELOG.md" beforeDir="false" afterPath="$PROJECT_DIR$/CHANGELOG.md" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/config/reference.php" beforeDir="false" afterPath="$PROJECT_DIR$/config/reference.php" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/frontend/components/reception/update-weight.vue" beforeDir="false" afterPath="$PROJECT_DIR$/frontend/components/reception/update-weight.vue" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/frontend/pages/reception/update/[[id]].vue" beforeDir="false" afterPath="$PROJECT_DIR$/frontend/pages/reception/update/[[id]].vue" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/frontend/services/dto/reception-data.ts" beforeDir="false" afterPath="$PROJECT_DIR$/frontend/services/dto/reception-data.ts" afterDir="false" />
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
@@ -39,7 +41,7 @@
|
|||||||
<component name="Git.Settings">
|
<component name="Git.Settings">
|
||||||
<option name="RECENT_BRANCH_BY_REPOSITORY">
|
<option name="RECENT_BRANCH_BY_REPOSITORY">
|
||||||
<map>
|
<map>
|
||||||
<entry key="$PROJECT_DIR$" value="feat/276-lister-expeditions-terminees" />
|
<entry key="$PROJECT_DIR$" value="develop" />
|
||||||
</map>
|
</map>
|
||||||
</option>
|
</option>
|
||||||
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||||
@@ -223,36 +225,36 @@
|
|||||||
<option name="hideEmptyMiddlePackages" value="true" />
|
<option name="hideEmptyMiddlePackages" value="true" />
|
||||||
<option name="showLibraryContents" value="true" />
|
<option name="showLibraryContents" value="true" />
|
||||||
</component>
|
</component>
|
||||||
<component name="PropertiesComponent">{
|
<component name="PropertiesComponent"><![CDATA[{
|
||||||
"keyToString": {
|
"keyToString": {
|
||||||
"RunOnceActivity.MCP Project settings loaded": "true",
|
"RunOnceActivity.MCP Project settings loaded": "true",
|
||||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||||
"RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager.252": "true",
|
"RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager.252": "true",
|
||||||
"RunOnceActivity.git.unshallow": "true",
|
"RunOnceActivity.git.unshallow": "true",
|
||||||
"RunOnceActivity.typescript.service.memoryLimit.init": "true",
|
"RunOnceActivity.typescript.service.memoryLimit.init": "true",
|
||||||
"git-widget-placeholder": "fix/325-corrections-diverses",
|
"git-widget-placeholder": "fit/332-refonte-reception-terminee",
|
||||||
"last_opened_file_path": "//wsl.localhost/Ubuntu-24.04/home/kevin/Stage/Ferme/frontend/pages/shipment",
|
"last_opened_file_path": "//wsl.localhost/Ubuntu-24.04/home/kevin/Stage/Ferme/frontend/pages/shipment",
|
||||||
"node.js.detected.package.eslint": "true",
|
"node.js.detected.package.eslint": "true",
|
||||||
"node.js.detected.package.tslint": "true",
|
"node.js.detected.package.tslint": "true",
|
||||||
"node.js.selected.package.eslint": "(autodetect)",
|
"node.js.selected.package.eslint": "(autodetect)",
|
||||||
"node.js.selected.package.tslint": "(autodetect)",
|
"node.js.selected.package.tslint": "(autodetect)",
|
||||||
"nodejs_package_manager_path": "npm",
|
"nodejs_package_manager_path": "npm",
|
||||||
"settings.editor.selected.configurable": "preferences.pluginManager",
|
"settings.editor.selected.configurable": "preferences.pluginManager",
|
||||||
"ts.external.directory.path": "/opt/phpstorm/plugins/javascript-plugin/jsLanguageServicesImpl/external",
|
"ts.external.directory.path": "/opt/phpstorm/plugins/javascript-plugin/jsLanguageServicesImpl/external",
|
||||||
"vue.rearranger.settings.migration": "true"
|
"vue.rearranger.settings.migration": "true"
|
||||||
},
|
},
|
||||||
"keyToStringList": {
|
"keyToStringList": {
|
||||||
"DatabaseDriversLRU": [
|
"DatabaseDriversLRU": [
|
||||||
"postgresql"
|
"postgresql"
|
||||||
],
|
],
|
||||||
"com.intellij.ide.scratch.ScratchImplUtil$2/New Scratch File": [
|
"com.intellij.ide.scratch.ScratchImplUtil$2/New Scratch File": [
|
||||||
"TEXT"
|
"TEXT"
|
||||||
],
|
],
|
||||||
"vue.recent.templates": [
|
"vue.recent.templates": [
|
||||||
"Vue Composition API Component"
|
"Vue Composition API Component"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}</component>
|
}]]></component>
|
||||||
<component name="RecentsManager">
|
<component name="RecentsManager">
|
||||||
<key name="CopyFile.RECENT_KEYS">
|
<key name="CopyFile.RECENT_KEYS">
|
||||||
<recent name="\\wsl.localhost\Ubuntu-24.04\home\kevin\Stage\Ferme\frontend\pages\shipment" />
|
<recent name="\\wsl.localhost\Ubuntu-24.04\home\kevin\Stage\Ferme\frontend\pages\shipment" />
|
||||||
@@ -309,14 +311,6 @@
|
|||||||
<workItem from="1770966186589" duration="914000" />
|
<workItem from="1770966186589" duration="914000" />
|
||||||
<workItem from="1770967274060" duration="2388000" />
|
<workItem from="1770967274060" duration="2388000" />
|
||||||
</task>
|
</task>
|
||||||
<task id="LOCAL-00007" summary="test : ajout de TU sur les services et providers">
|
|
||||||
<option name="closed" value="true" />
|
|
||||||
<created>1768318921478</created>
|
|
||||||
<option name="number" value="00007" />
|
|
||||||
<option name="presentableId" value="LOCAL-00007" />
|
|
||||||
<option name="project" value="LOCAL" />
|
|
||||||
<updated>1768318921478</updated>
|
|
||||||
</task>
|
|
||||||
<task id="LOCAL-00008" summary="feat : ajout de la génération du bon de reception, correction de la base du formulaire multi-etape de reception et ajout d'une gestion d'erreur global">
|
<task id="LOCAL-00008" summary="feat : ajout de la génération du bon de reception, correction de la base du formulaire multi-etape de reception et ajout d'une gestion d'erreur global">
|
||||||
<option name="closed" value="true" />
|
<option name="closed" value="true" />
|
||||||
<created>1768498751836</created>
|
<created>1768498751836</created>
|
||||||
@@ -701,7 +695,15 @@
|
|||||||
<option name="project" value="LOCAL" />
|
<option name="project" value="LOCAL" />
|
||||||
<updated>1770969471135</updated>
|
<updated>1770969471135</updated>
|
||||||
</task>
|
</task>
|
||||||
<option name="localTasksCounter" value="56" />
|
<task id="LOCAL-00056" summary="fix : correction du retour sur la liste des réceptions + suppression de la redirection après enregistrement">
|
||||||
|
<option name="closed" value="true" />
|
||||||
|
<created>1772008192160</created>
|
||||||
|
<option name="number" value="00056" />
|
||||||
|
<option name="presentableId" value="LOCAL-00056" />
|
||||||
|
<option name="project" value="LOCAL" />
|
||||||
|
<updated>1772008192161</updated>
|
||||||
|
</task>
|
||||||
|
<option name="localTasksCounter" value="57" />
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
<component name="TypeScriptGeneratedFilesManager">
|
<component name="TypeScriptGeneratedFilesManager">
|
||||||
@@ -751,7 +753,6 @@
|
|||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
<component name="VcsManagerConfiguration">
|
<component name="VcsManagerConfiguration">
|
||||||
<MESSAGE value="fix : gitea workflow" />
|
|
||||||
<MESSAGE value="fix : script de déploiement" />
|
<MESSAGE value="fix : script de déploiement" />
|
||||||
<MESSAGE value="feat : ajout plus d'information sur la liste des réceptions côté front sur la page d'accueil" />
|
<MESSAGE value="feat : ajout plus d'information sur la liste des réceptions côté front sur la page d'accueil" />
|
||||||
<MESSAGE value="fix : redirige sur le login sur une 401 et reset du auth state + doc + timeout du toaster" />
|
<MESSAGE value="fix : redirige sur le login sur une 401 et reset du auth state + doc + timeout du toaster" />
|
||||||
@@ -776,7 +777,8 @@
|
|||||||
<MESSAGE value="feat : lister les expeditions terminees" />
|
<MESSAGE value="feat : lister les expeditions terminees" />
|
||||||
<MESSAGE value="fix: corrections diverses" />
|
<MESSAGE value="fix: corrections diverses" />
|
||||||
<MESSAGE value="fix : corrections diverses" />
|
<MESSAGE value="fix : corrections diverses" />
|
||||||
<option name="LAST_COMMIT_MESSAGE" value="fix : corrections diverses" />
|
<MESSAGE value="fix : correction du retour sur la liste des réceptions + suppression de la redirection après enregistrement" />
|
||||||
|
<option name="LAST_COMMIT_MESSAGE" value="fix : correction du retour sur la liste des réceptions + suppression de la redirection après enregistrement" />
|
||||||
</component>
|
</component>
|
||||||
<component name="XDebuggerManager">
|
<component name="XDebuggerManager">
|
||||||
<breakpoint-manager>
|
<breakpoint-manager>
|
||||||
|
|||||||
@@ -2,11 +2,11 @@
|
|||||||
<form>
|
<form>
|
||||||
<div class="grid grid-cols-3 gap-x-40 gap-y-8 mb-8">
|
<div class="grid grid-cols-3 gap-x-40 gap-y-8 mb-8">
|
||||||
<UiNumberInput
|
<UiNumberInput
|
||||||
:key="weight.type"
|
:key="localWeight.type"
|
||||||
:label="'POIDS'"
|
:label="'POIDS'"
|
||||||
labelClass="font-bold uppercase text-xl "
|
labelClass="font-bold uppercase text-xl "
|
||||||
v-model="weight.weight"
|
v-model="localWeight.weight"
|
||||||
:disabled="!auth.isAdmin"
|
:disabled="!isAdmin"
|
||||||
:min="0"
|
:min="0"
|
||||||
:max="48000"
|
:max="48000"
|
||||||
wrapper-class="flex-col"
|
wrapper-class="flex-col"
|
||||||
@@ -14,16 +14,16 @@
|
|||||||
|
|
||||||
<UiDateInput
|
<UiDateInput
|
||||||
label="Date pesée"
|
label="Date pesée"
|
||||||
v-model="sharedWeightMeta.weighedAt"
|
v-model="localWeight.weighedAt"
|
||||||
:disabled="!auth.isAdmin"
|
:disabled="!isAdmin"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<UiNumberInput
|
<UiNumberInput
|
||||||
label="Dsd"
|
label="Dsd"
|
||||||
class="col-start-2"
|
class="col-start-2"
|
||||||
labelClass="font-bold uppercase"
|
labelClass="font-bold uppercase"
|
||||||
v-model="sharedWeightMeta.dsd"
|
v-model="localWeight.dsd"
|
||||||
:disabled="!auth.isAdmin"
|
:disabled="!isAdmin"
|
||||||
wrapper-class="flex-col"
|
wrapper-class="flex-col"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -31,133 +31,33 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type {ReceptionFormWeight} from '~/services/dto/reception-data'
|
import type {WeightEntryData} from '~/services/dto/reception-data'
|
||||||
import {getReception} from '~/services/reception'
|
import {reactive, watch} from "vue";
|
||||||
import {updateWeight} from "~/services/weight";
|
|
||||||
import {useAuthStore} from "~/stores/auth";
|
|
||||||
import {ref, watch} from "vue";
|
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
idReception: number
|
modelValue: WeightEntryData
|
||||||
weightType: string
|
isAdmin: boolean
|
||||||
isValidate: boolean
|
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const form = reactive({
|
const emit = defineEmits<{
|
||||||
weights: [
|
(event: 'update:modelValue', value: WeightEntryData): void
|
||||||
{id: 0, type: 'tare' as const, weight: 0, dsd: null, weighedAt: null},
|
}>()
|
||||||
{id: 0, type: 'gross' as const, weight: 0, dsd: null, weighedAt: null}
|
|
||||||
]
|
|
||||||
})
|
|
||||||
|
|
||||||
const idReception = props.idReception
|
const localWeight = reactive<WeightEntryData>({...props.modelValue})
|
||||||
const weightType = props.weightType
|
|
||||||
const auth = useAuthStore()
|
|
||||||
const weight = form.weights.find(w => w.type === weightType)
|
|
||||||
const initialWeight = ref<{ weight: number | null; dsd: number | null; weighedAt: string | null } | null>(null)
|
|
||||||
|
|
||||||
// DSD et date de pesée sont partagés entre tare et gross dans l'UI.
|
|
||||||
const sharedWeightMeta = reactive<{
|
|
||||||
dsd: number | string | null
|
|
||||||
weighedAt: string | null
|
|
||||||
}>({
|
|
||||||
dsd: null,
|
|
||||||
weighedAt: null
|
|
||||||
})
|
|
||||||
|
|
||||||
const normalizeMeta = () => {
|
|
||||||
const sharedDsd =
|
|
||||||
sharedWeightMeta.dsd === null || sharedWeightMeta.dsd === undefined || sharedWeightMeta.dsd === ''
|
|
||||||
? null
|
|
||||||
: Number(sharedWeightMeta.dsd)
|
|
||||||
const sharedWeighedAt =
|
|
||||||
sharedWeightMeta.weighedAt === null || sharedWeightMeta.weighedAt === undefined || sharedWeightMeta.weighedAt === ''
|
|
||||||
? null
|
|
||||||
: sharedWeightMeta.weighedAt
|
|
||||||
|
|
||||||
return {
|
|
||||||
dsd: Number.isFinite(sharedDsd) ? sharedDsd : null,
|
|
||||||
weighedAt: sharedWeighedAt
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const hydrateFromReception = (reception: ReceptionFormWeight) => {
|
|
||||||
// On hydrate chaque ligne par son type (tare/gross), sans dépendre d'un index.
|
|
||||||
for (const receptionWeight of reception.weights) {
|
|
||||||
const formWeight = form.weights.find(weight => weight.type === receptionWeight.type)
|
|
||||||
if (formWeight) {
|
|
||||||
Object.assign(formWeight, receptionWeight)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// On récupère une valeur existante pour préremplir les champs partagés.
|
|
||||||
const weightWithMeta = reception.weights.find(weight =>
|
|
||||||
(weight.dsd !== null && weight.dsd !== undefined)
|
|
||||||
|| (weight.weighedAt !== null && weight.weighedAt !== undefined && weight.weighedAt !== '')
|
|
||||||
)
|
|
||||||
|
|
||||||
if (weightWithMeta) {
|
|
||||||
sharedWeightMeta.dsd = weightWithMeta.dsd ?? null
|
|
||||||
sharedWeightMeta.weighedAt = weightWithMeta.weighedAt ?? null
|
|
||||||
}
|
|
||||||
|
|
||||||
if (weight) {
|
|
||||||
const normalized = normalizeMeta()
|
|
||||||
initialWeight.value = {
|
|
||||||
weight: weight.weight ?? null,
|
|
||||||
dsd: normalized.dsd,
|
|
||||||
weighedAt: normalized.weighedAt
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onMounted(async () => {
|
|
||||||
const reception = await getReception(idReception)
|
|
||||||
hydrateFromReception(reception)
|
|
||||||
})
|
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => props.isValidate,
|
() => props.modelValue,
|
||||||
async (val) => {
|
(value) => {
|
||||||
if (!val) return
|
Object.assign(localWeight, value)
|
||||||
await runValidate()
|
},
|
||||||
}
|
{deep: true}
|
||||||
)
|
)
|
||||||
|
|
||||||
const hasChanged = (current: { weight: number | null; dsd: number | null; weighedAt: string | null }) => {
|
watch(
|
||||||
if (!initialWeight.value) {
|
localWeight,
|
||||||
return true
|
(value) => {
|
||||||
}
|
emit('update:modelValue', {...value})
|
||||||
return (
|
},
|
||||||
(current.weight ?? null) !== (initialWeight.value.weight ?? null) ||
|
{deep: true}
|
||||||
(current.dsd ?? null) !== (initialWeight.value.dsd ?? null) ||
|
)
|
||||||
(current.weighedAt ?? null) !== (initialWeight.value.weighedAt ?? null)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
const runValidate = async () => {
|
|
||||||
if (!weight?.id) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const normalized = normalizeMeta()
|
|
||||||
const current = {
|
|
||||||
weight: weight.weight ?? null,
|
|
||||||
dsd: normalized.dsd,
|
|
||||||
weighedAt: normalized.weighedAt
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!hasChanged(current)) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
await updateWeight(weight.id, {
|
|
||||||
weight: current.weight,
|
|
||||||
dsd: current.dsd,
|
|
||||||
weighedAt: current.weighedAt
|
|
||||||
})
|
|
||||||
|
|
||||||
initialWeight.value = current
|
|
||||||
}
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -9,7 +9,6 @@
|
|||||||
<h1 class="font-bold text-4xl col-start-1 row-start-1 text-primary-500 uppercase">Réception {{ form.identificationNumber }}</h1>
|
<h1 class="font-bold text-4xl col-start-1 row-start-1 text-primary-500 uppercase">Réception {{ form.identificationNumber }}</h1>
|
||||||
<Icon @click="printReceipt" name="mdi:printer-outline" size="44" class="cursor-pointer text-primary-500"/>
|
<Icon @click="printReceipt" name="mdi:printer-outline" size="44" class="cursor-pointer text-primary-500"/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Nom de l'utilisateur -->
|
<!-- Nom de l'utilisateur -->
|
||||||
<UiSelect
|
<UiSelect
|
||||||
id="reception-user"
|
id="reception-user"
|
||||||
@@ -137,15 +136,15 @@
|
|||||||
<div class="flex justify-evenly gap-y-8 gap-x-41 mb-10 border-b border-primary-500/60">
|
<div class="flex justify-evenly gap-y-8 gap-x-41 mb-10 border-b border-primary-500/60">
|
||||||
<h1
|
<h1
|
||||||
class="font-bold text-3xl uppercase px-12 col-start-1 row-start-1 cursor-pointer "
|
class="font-bold text-3xl uppercase px-12 col-start-1 row-start-1 cursor-pointer "
|
||||||
:class="activeTab === 'weightsEmpty' ? 'border-b-[6px] border-primary-500 text-primary-500' : 'text-primary-500/50'"
|
:class="activeTab === 'weights' ? 'border-b-[6px] border-primary-500 text-primary-500' : 'text-primary-500/50'"
|
||||||
@click="activeTab = 'weightsEmpty'"
|
@click="activeTab = 'weights'"
|
||||||
>
|
>
|
||||||
pesée à plein
|
pesée à plein
|
||||||
</h1>
|
</h1>
|
||||||
<h1
|
<h1
|
||||||
class="font-bold text-3xl uppercase col-start-1 row-start-1 px-12 cursor-pointer "
|
class="font-bold text-3xl uppercase col-start-1 row-start-1 px-12 cursor-pointer "
|
||||||
:class="activeTab === 'weights' ? 'border-b-[6px] border-primary-500 text-primary-500 ' : 'text-primary-500/50'"
|
:class="activeTab === 'weightsEmpty' ? 'border-b-[6px] border-primary-500 text-primary-500 ' : 'text-primary-500/50'"
|
||||||
@click="activeTab = 'weights'"
|
@click="activeTab = 'weightsEmpty'"
|
||||||
>
|
>
|
||||||
pesée à vide
|
pesée à vide
|
||||||
</h1>
|
</h1>
|
||||||
@@ -157,22 +156,20 @@
|
|||||||
{{ isMerchandise ? "Marchandise" : "Bovins" }}
|
{{ isMerchandise ? "Marchandise" : "Bovins" }}
|
||||||
</h1>
|
</h1>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="mb-12 ">
|
||||||
|
<update-weight
|
||||||
|
v-show="activeTab === 'weights'"
|
||||||
|
v-model="grossWeight"
|
||||||
|
v-if="grossWeight"
|
||||||
|
:isAdmin="auth.isAdmin"
|
||||||
|
/>
|
||||||
|
|
||||||
<update-weight
|
<update-weight
|
||||||
v-show="activeTab === 'weights'"
|
v-show="activeTab === 'weightsEmpty'"
|
||||||
:idReception="idReception"
|
v-model="tareWeight"
|
||||||
:weightType="'tare'"
|
v-if="tareWeight"
|
||||||
:disabled="!auth.isAdmin"
|
:isAdmin="auth.isAdmin"
|
||||||
:isValidate="isValid"
|
/>
|
||||||
/>
|
|
||||||
<div class="mb-12 ">
|
|
||||||
<update-weight
|
|
||||||
v-show="activeTab === 'weightsEmpty'"
|
|
||||||
:idReception="idReception"
|
|
||||||
:weightType="'gross'"
|
|
||||||
:disabled="!auth.isAdmin"
|
|
||||||
:isValidate="isValid"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<update-merchandise
|
<update-merchandise
|
||||||
v-show="activeTab === 'merchandise' && isMerchandise"
|
v-show="activeTab === 'merchandise' && isMerchandise"
|
||||||
@@ -221,7 +218,7 @@ import type {VehicleData} from '~/services/dto/vehicle-data'
|
|||||||
import {getVehicleList} from '~/services/vehicle'
|
import {getVehicleList} from '~/services/vehicle'
|
||||||
import {RECEPTION_TYPE_CODES, SUPPLIER_CODE} from "~/utils/constants";
|
import {RECEPTION_TYPE_CODES, SUPPLIER_CODE} from "~/utils/constants";
|
||||||
import {deleteReceptionBovine, getReceptionBovineList,} from "~/services/reception-bovine";
|
import {deleteReceptionBovine, getReceptionBovineList,} from "~/services/reception-bovine";
|
||||||
import type {ReceptionData, ReceptionFormData} from "~/services/dto/reception-data";
|
import type {ReceptionData, ReceptionFormData, WeightEntryData} from "~/services/dto/reception-data";
|
||||||
import {getReception, updateReception} from "~/services/reception";
|
import {getReception, updateReception} 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 UpdateMerchandise from "~/components/reception/update-merchandise.vue";
|
||||||
@@ -229,7 +226,7 @@ import UpdateBovin from "~/components/reception/update-bovin.vue";
|
|||||||
import {getReceptionTypeList} from "~/services/reception-type";
|
import {getReceptionTypeList} from "~/services/reception-type";
|
||||||
import type {ReceptionTypeData} from "~/services/dto/reception-type-data";
|
import type {ReceptionTypeData} from "~/services/dto/reception-type-data";
|
||||||
import {computed} from "vue";
|
import {computed} from "vue";
|
||||||
import {updateWeight} from "~/services/weight";
|
import {createWeight, updateWeight} from "~/services/weight";
|
||||||
import {deleteReceptionPelletBuilding, getReceptionPelletBuildingList} from "~/services/reception-pellet-building";
|
import {deleteReceptionPelletBuilding, getReceptionPelletBuildingList} from "~/services/reception-pellet-building";
|
||||||
|
|
||||||
const form = reactive<ReceptionFormData>({
|
const form = reactive<ReceptionFormData>({
|
||||||
@@ -246,8 +243,18 @@ const form = reactive<ReceptionFormData>({
|
|||||||
vehicleId: ''
|
vehicleId: ''
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const createEmptyWeightEntry = (type: 'gross' | 'tare'): WeightEntryData => ({
|
||||||
|
type,
|
||||||
|
dsd: null,
|
||||||
|
weight: null,
|
||||||
|
weighedAt: null
|
||||||
|
})
|
||||||
|
|
||||||
|
const grossWeight = ref<WeightEntryData>(createEmptyWeightEntry('gross'))
|
||||||
|
const tareWeight = ref<WeightEntryData>(createEmptyWeightEntry('tare'))
|
||||||
|
|
||||||
const { printPdf } = usePdfPrinter()
|
const { printPdf } = usePdfPrinter()
|
||||||
const activeTab = ref<'weightsEmpty' | 'weights' | 'merchandise'>('weightsEmpty')
|
const activeTab = ref<'weightsEmpty' | 'weights' | 'merchandise'>('weights')
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const receptionStore = useReceptionStore()
|
const receptionStore = useReceptionStore()
|
||||||
const allowAnyLicensePlate = ref(false)
|
const allowAnyLicensePlate = ref(false)
|
||||||
@@ -377,6 +384,10 @@ const hydrateFromReception = (reception: ReceptionData | null) => {
|
|||||||
form.receptionTypeId = reception?.receptionType?.id
|
form.receptionTypeId = reception?.receptionType?.id
|
||||||
? String(reception.receptionType.id)
|
? String(reception.receptionType.id)
|
||||||
: ''
|
: ''
|
||||||
|
const gross = reception.weights?.find((weight) => weight.type === 'gross') ?? null
|
||||||
|
const tare = reception.weights?.find((weight) => weight.type === 'tare') ?? null
|
||||||
|
grossWeight.value = gross ? {...gross} : createEmptyWeightEntry('gross')
|
||||||
|
tareWeight.value = tare ? {...tare} : createEmptyWeightEntry('tare')
|
||||||
isHydrating.value = false
|
isHydrating.value = false
|
||||||
syncMerchandiseFlag()
|
syncMerchandiseFlag()
|
||||||
}
|
}
|
||||||
@@ -629,6 +640,30 @@ const printReceipt = async () => {
|
|||||||
// Laisse le temps a la boite de dialogue d'impression de s'ouvrir.
|
// Laisse le temps a la boite de dialogue d'impression de s'ouvrir.
|
||||||
await new Promise((resolve) => setTimeout(resolve, 600))
|
await new Promise((resolve) => setTimeout(resolve, 600))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const saveWeightEntry = async (entry: WeightEntryData) => {
|
||||||
|
if (!idReception || entry.weight === null) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const payload = {
|
||||||
|
type: entry.type,
|
||||||
|
dsd: entry.dsd ?? null,
|
||||||
|
weight: entry.weight,
|
||||||
|
weighedAt: entry.weighedAt ?? null
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entry.id) {
|
||||||
|
await updateWeight(entry.id, payload)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
await createWeight({
|
||||||
|
reception: `api/receptions/${idReception}`,
|
||||||
|
...payload
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
async function validate() {
|
async function validate() {
|
||||||
const normalizedLicensePlate = form.licensePlate.trim()
|
const normalizedLicensePlate = form.licensePlate.trim()
|
||||||
const normalizedReceptionDate = form.receptionDate.trim()
|
const normalizedReceptionDate = form.receptionDate.trim()
|
||||||
@@ -683,6 +718,10 @@ async function validate() {
|
|||||||
await receptionStore.updateReception(idReception, {
|
await receptionStore.updateReception(idReception, {
|
||||||
...payload
|
...payload
|
||||||
})
|
})
|
||||||
|
await saveWeightEntry(grossWeight.value)
|
||||||
|
await saveWeightEntry(tareWeight.value)
|
||||||
|
const refreshedReception = await getReception(idReception)
|
||||||
|
hydrateFromReception(refreshedReception)
|
||||||
|
|
||||||
if (isMerchandise.value) {
|
if (isMerchandise.value) {
|
||||||
await clearReceptionBovines(idReception)
|
await clearReceptionBovines(idReception)
|
||||||
|
|||||||
@@ -44,6 +44,8 @@ export interface WeightEntryData {
|
|||||||
export interface WeightFormData {
|
export interface WeightFormData {
|
||||||
id: number
|
id: number
|
||||||
weight: number
|
weight: number
|
||||||
|
weighedAt : string
|
||||||
|
dsd: number
|
||||||
type: 'gross' | 'tare'
|
type: 'gross' | 'tare'
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,6 +82,7 @@ export type ReceptionFormData = {
|
|||||||
carrierId: string
|
carrierId: string
|
||||||
driverId: string
|
driverId: string
|
||||||
vehicleId: string
|
vehicleId: string
|
||||||
|
weight?: ReceptionFormWeight | null
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ReceptionFormWeight = {
|
export type ReceptionFormWeight = {
|
||||||
|
|||||||
Reference in New Issue
Block a user