From d7ba8868a654ecb36ea3d1c6c287fa5c3c633127 Mon Sep 17 00:00:00 2001 From: provira Date: Wed, 5 Mar 2025 07:49:42 +0100 Subject: [PATCH] feat: refs #7449 added new button on claimLines, prevented claimAction to import lines with 0 quantity --- src/components/CrudModel.vue | 6 +-- src/components/FormModel.vue | 4 +- src/i18n/locale/en.yml | 5 ++- src/i18n/locale/es.yml | 5 ++- src/pages/Claim/Card/ClaimAction.vue | 19 ++++++--- src/pages/Claim/Card/ClaimBasicData.vue | 1 + src/pages/Claim/Card/ClaimLines.vue | 52 +++++++++++++++++++------ src/router/modules/claim.js | 20 +++++----- 8 files changed, 78 insertions(+), 34 deletions(-) diff --git a/src/components/CrudModel.vue b/src/components/CrudModel.vue index 8c4f70f3b..b40f0c2fc 100644 --- a/src/components/CrudModel.vue +++ b/src/components/CrudModel.vue @@ -347,8 +347,8 @@ watch(formUrl, async () => { { :label="t && t('globals.pleaseWait')" color="primary" /> - + \ No newline at end of file diff --git a/src/components/FormModel.vue b/src/components/FormModel.vue index c4d9a4149..ff1b9ec4f 100644 --- a/src/components/FormModel.vue +++ b/src/components/FormModel.vue @@ -368,8 +368,8 @@ defineExpose({ data-cy="saveAndContinueDefaultBtn" v-if="$props.goTo" @click="saveAndGo" - :label="tMobile('globals.saveAndContinue')" - :title="t('globals.saveAndContinue')" + :label="tMobile('globals.saveAndContinue') + ' ' + t('globals.' + $props.goTo.split('/').pop())" + :title="t('globals.saveAndContinue') + ' ' + t('globals.' + $props.goTo.split('/').pop())" :disable="!hasChanges" color="primary" icon="save" diff --git a/src/i18n/locale/en.yml b/src/i18n/locale/en.yml index 5b667555e..6c0e470cc 100644 --- a/src/i18n/locale/en.yml +++ b/src/i18n/locale/en.yml @@ -28,7 +28,7 @@ globals: create: Create edit: Edit save: Save - saveAndContinue: Save and continue + saveAndContinue: Save and go to remove: Remove reset: Reset close: Close @@ -106,6 +106,8 @@ globals: from: From to: To notes: Notes + photos: Photos + due-day: Due day refresh: Refresh item: Item ticket: Ticket @@ -383,6 +385,7 @@ errors: updateUserConfig: Error updating user config tokenConfig: Error fetching token config writeRequest: The requested operation could not be completed + claimBeginningQuantity: Cannot import a line with a claimed quantity of 0 login: title: Login username: Username diff --git a/src/i18n/locale/es.yml b/src/i18n/locale/es.yml index 3f004485d..9af2bd7c9 100644 --- a/src/i18n/locale/es.yml +++ b/src/i18n/locale/es.yml @@ -28,7 +28,7 @@ globals: create: Crear edit: Modificar save: Guardar - saveAndContinue: Guardar y continuar + saveAndContinue: Guardar e ir a remove: Eliminar reset: Restaurar close: Cerrar @@ -110,6 +110,8 @@ globals: from: Desde to: Hasta notes: Notas + photos: Fotos + due-day: Vencimiento refresh: Actualizar item: Artículo ticket: Ticket @@ -379,6 +381,7 @@ errors: updateUserConfig: Error al actualizar la configuración de usuario tokenConfig: Error al obtener configuración de token writeRequest: No se pudo completar la operación solicitada + claimBeginningQuantity: No se puede importar una linea sin una cantidad reclamada login: title: Inicio de sesión username: Nombre de usuario diff --git a/src/pages/Claim/Card/ClaimAction.vue b/src/pages/Claim/Card/ClaimAction.vue index baa36710c..4b2414d46 100644 --- a/src/pages/Claim/Card/ClaimAction.vue +++ b/src/pages/Claim/Card/ClaimAction.vue @@ -13,8 +13,10 @@ import ItemDescriptorProxy from 'src/pages/Item/Card/ItemDescriptorProxy.vue'; import TicketDescriptorProxy from 'src/pages/Ticket/Card/TicketDescriptorProxy.vue'; import { useArrayData } from 'composables/useArrayData'; import RightMenu from 'src/components/common/RightMenu.vue'; +import useNotify from 'src/composables/useNotify.js'; const { t } = useI18n(); +const { notify } = useNotify(); const quasar = useQuasar(); const route = useRoute(); const claim = ref(null); @@ -176,12 +178,17 @@ async function save(data) { } async function importToNewRefundTicket() { - await post(`ClaimBeginnings/${claimId}/importToNewRefundTicket`); - await claimActionsForm.value.reload(); - quasar.notify({ - message: t('globals.dataSaved'), - type: 'positive', - }); + try{ + await post(`ClaimBeginnings/${claimId}/importToNewRefundTicket`); + await claimActionsForm.value.reload(); + quasar.notify({ + message: t('globals.dataSaved'), + type: 'positive', + }); + } catch (error) { + const errorMessage = error.response?.data?.error?.message; + notify( t(errorMessage), 'negative' ); + } } async function post(query, params) { diff --git a/src/pages/Claim/Card/ClaimBasicData.vue b/src/pages/Claim/Card/ClaimBasicData.vue index 43941d1dc..62721703a 100644 --- a/src/pages/Claim/Card/ClaimBasicData.vue +++ b/src/pages/Claim/Card/ClaimBasicData.vue @@ -26,6 +26,7 @@ const workersOptions = ref([]); diff --git a/src/pages/Claim/Card/ClaimLines.vue b/src/pages/Claim/Card/ClaimLines.vue index dee03b95d..1df7fbeef 100644 --- a/src/pages/Claim/Card/ClaimLines.vue +++ b/src/pages/Claim/Card/ClaimLines.vue @@ -152,12 +152,33 @@ function showImportDialog() { .onOk(() => claimLinesForm.value.reload()); } -async function saveWhenHasChanges() { - if (claimLinesForm.value.getChanges().updates) { - await claimLinesForm.value.onSubmit(); - onFetch(claimLinesForm.value.formData); +function fillClaimedQuantities() { + const formData = claimLinesForm.value.formData; + let hasChanges = false; + + const selectedRows = formData.filter(row => selected.value.includes(row)); + + for (const row of selectedRows) { + if (row.quantity === 0 || row.quantity === null) { + row.quantity = row.sale.quantity; + hasChanges = true; + } + } + + if (hasChanges) { + quasar.notify({ + message: t('Cantidades rellenadas automáticamente'), + type: 'positive', + }); + } else { + quasar.notify({ + message: t('No hay cantidades para rellenar'), + type: 'info', + }); } } + + @@ -272,10 +293,7 @@ async function saveWhenHasChanges() { type="number" dense autofocus - @keyup.enter=" - saveWhenHasChanges() - " - @blur="saveWhenHasChanges()" + /> @@ -313,6 +331,18 @@ async function saveWhenHasChanges() { + diff --git a/src/router/modules/claim.js b/src/router/modules/claim.js index 4dfde08da..aa0fc2819 100644 --- a/src/router/modules/claim.js +++ b/src/router/modules/claim.js @@ -8,9 +8,9 @@ const claimCard = { meta: { menu: [ 'ClaimBasicData', + 'ClaimNotes', 'ClaimLines', 'ClaimPhotos', - 'ClaimNotes', 'ClaimDevelopment', 'ClaimAction', 'ClaimLog', @@ -36,6 +36,15 @@ const claimCard = { }, component: () => import('src/pages/Claim/Card/ClaimBasicData.vue'), }, + { + path: 'notes', + name: 'ClaimNotes', + meta: { + title: 'notes', + icon: 'draft', + }, + component: () => import('src/pages/Claim/Card/ClaimNotes.vue'), + }, { path: 'lines', name: 'ClaimLines', @@ -54,15 +63,6 @@ const claimCard = { }, component: () => import('src/pages/Claim/Card/ClaimPhoto.vue'), }, - { - path: 'notes', - name: 'ClaimNotes', - meta: { - title: 'notes', - icon: 'draft', - }, - component: () => import('src/pages/Claim/Card/ClaimNotes.vue'), - }, { path: 'development', name: 'ClaimDevelopment',