From f0f6a7e9a305e71be230ce3722f90a272c94df80 Mon Sep 17 00:00:00 2001 From: robert Date: Fri, 22 Nov 2024 14:10:46 +0100 Subject: [PATCH 1/5] feat: refs #6629 addressObservation --- .../components/CustomerAddressEdit.vue | 46 +++++++++++++++---- 1 file changed, 37 insertions(+), 9 deletions(-) diff --git a/src/pages/Customer/components/CustomerAddressEdit.vue b/src/pages/Customer/components/CustomerAddressEdit.vue index 0ea8315d6..af15962fa 100644 --- a/src/pages/Customer/components/CustomerAddressEdit.vue +++ b/src/pages/Customer/components/CustomerAddressEdit.vue @@ -2,7 +2,7 @@ import { onBeforeMount, ref } from 'vue'; import { useI18n } from 'vue-i18n'; import { useRoute, useRouter } from 'vue-router'; - +import { useQuasar } from 'quasar'; import axios from 'axios'; import VnLocation from 'src/components/common/VnLocation.vue'; import FetchData from 'components/FetchData.vue'; @@ -12,11 +12,12 @@ import VnInput from 'src/components/common/VnInput.vue'; import VnSelect from 'src/components/common/VnSelect.vue'; import VnSelectDialog from 'src/components/common/VnSelectDialog.vue'; import CustomerNewCustomsAgent from 'src/pages/Customer/components/CustomerNewCustomsAgent.vue'; +import VnConfirm from 'components/ui/VnConfirm.vue'; const { t } = useI18n(); const route = useRoute(); const router = useRouter(); - +const quasar = useQuasar(); const urlUpdate = ref(''); const agencyModes = ref([]); const incoterms = ref([]); @@ -27,7 +28,7 @@ let originalNotes = []; const deletes = ref([]); onBeforeMount(() => { - urlUpdate.value = `Clients/${route.params.id}/updateAddress/${route.params.addressId}`; + updateAddress(); }); const getData = async (observations) => { @@ -82,6 +83,14 @@ const deleteNote = (id, index) => { notes.value.splice(index, 1); }; +const updateAddress = () => { + urlUpdate.value = `Clients/${route.params.id}/updateAddress/${route.params.addressId}`; +}; +const resetAndSend = async (payload) => { + await axios.post('AddressObservations/crud', payload); + notes.value = []; + deletes.value = []; +}; const onDataSaved = async () => { let payload = { creates: notes.value.filter((note) => note.$isNew), @@ -100,11 +109,30 @@ const onDataSaved = async () => { where: { id: note.id }, })), }; - - await axios.post('AddressObservations/crud', payload); - notes.value = []; - deletes.value = []; - toCustomerAddress(); + if (payload.updates.length) { + quasar + .dialog({ + component: VnConfirm, + componentProps: { + title: t( + 'Do you also want to modify the states of all the tickets that are about to be served?' + ), + message: t('confirmDeletionMessage'), + }, + }) + .onOk(async () => { + resetAndSend(payload); + updateAddress(payload); + toCustomerAddress(); + }) + .onCancel(async () => { + resetAndSend(payload); + toCustomerAddress(); + }); + // .hide(toCustomerAddress); + } else { + resetAndSend(payload); + } }; const toCustomerAddress = () => { @@ -142,7 +170,7 @@ function handleLocation(data, location) { :observe-form-changes="false" :url-update="urlUpdate" :url="`Addresses/${route.params.addressId}`" - @on-data-saved="onDataSaved()" + @on-data-saved="onDataSaved" auto-load model="client" > -- 2.40.1 From b07286d43dc013b2ea87d85ef0472e7f364f6e86 Mon Sep 17 00:00:00 2001 From: robert Date: Tue, 26 Nov 2024 13:06:41 +0100 Subject: [PATCH 2/5] feat: refs #6629 update --- src/components/FormModel.vue | 4 +- .../components/CustomerAddressEdit.vue | 46 +++++++++++++------ 2 files changed, 35 insertions(+), 15 deletions(-) diff --git a/src/components/FormModel.vue b/src/components/FormModel.vue index bfb470c48..75f0648c8 100644 --- a/src/components/FormModel.vue +++ b/src/components/FormModel.vue @@ -207,7 +207,9 @@ async function save() { isLoading.value = true; try { formData.value = trimData(formData.value); - const body = $props.mapper ? $props.mapper(formData.value) : formData.value; + const body = $props.mapper + ? $props.mapper(formData.value, originalData.value) + : formData.value; const method = $props.urlCreate ? 'post' : 'patch'; const url = $props.urlCreate || $props.urlUpdate || $props.url || arrayData.store.url; diff --git a/src/pages/Customer/components/CustomerAddressEdit.vue b/src/pages/Customer/components/CustomerAddressEdit.vue index af15962fa..8e464dd7c 100644 --- a/src/pages/Customer/components/CustomerAddressEdit.vue +++ b/src/pages/Customer/components/CustomerAddressEdit.vue @@ -28,7 +28,7 @@ let originalNotes = []; const deletes = ref([]); onBeforeMount(() => { - updateAddress(); + urlUpdate.value = `Clients/${route.params.id}/updateAddress/${route.params.addressId}`; }); const getData = async (observations) => { @@ -83,16 +83,21 @@ const deleteNote = (id, index) => { notes.value.splice(index, 1); }; -const updateAddress = () => { - urlUpdate.value = `Clients/${route.params.id}/updateAddress/${route.params.addressId}`; +const updateAddress = async () => { + /* await axios.patch( + `Clients/${route.params.id}/updateAddress/${route.params.addressId}?updateObservations=true` + );*/ + urlUpdate.value = `Clients/${route.params.id}/updateAddress/${route.params.addressId}?updateObservations=true`; + + console.log('gg'); }; const resetAndSend = async (payload) => { await axios.post('AddressObservations/crud', payload); notes.value = []; deletes.value = []; }; -const onDataSaved = async () => { - let payload = { +function getPayload() { + return { creates: notes.value.filter((note) => note.$isNew), deletes: deletes.value, updates: notes.value @@ -109,7 +114,17 @@ const onDataSaved = async () => { where: { id: note.id }, })), }; - if (payload.updates.length) { +} +const onDataSaved = async (payload) => { + await axios.post('AddressObservations/crud', payload); + notes.value = []; + deletes.value = []; + toCustomerAddress(); +}; + +async function handleDialog(data) { + console.error(data); + if (getPayload().updates.length) { quasar .dialog({ component: VnConfirm, @@ -121,19 +136,22 @@ const onDataSaved = async () => { }, }) .onOk(async () => { - resetAndSend(payload); - updateAddress(payload); - toCustomerAddress(); + // await resetAndSend(payload); + await updateAddress(); + await onDataSaved(data); }) .onCancel(async () => { - resetAndSend(payload); - toCustomerAddress(); + // await resetAndSend(payload); + await onDataSaved(data); }); // .hide(toCustomerAddress); } else { - resetAndSend(payload); + console.log('sinModificarObservation'); + await onDataSaved(data); + // await resetAndSend(payload); + // toCustomerAddress(); } -}; +} const toCustomerAddress = () => { router.push({ @@ -170,7 +188,7 @@ function handleLocation(data, location) { :observe-form-changes="false" :url-update="urlUpdate" :url="`Addresses/${route.params.addressId}`" - @on-data-saved="onDataSaved" + :save-fn="handleDialog" auto-load model="client" > -- 2.40.1 From 8a0b65998ea2c437a801eb56a88c72fefaa4d7ab Mon Sep 17 00:00:00 2001 From: robert Date: Tue, 26 Nov 2024 13:41:26 +0100 Subject: [PATCH 3/5] feat: refs #6629 customerAddressEdit --- .../components/CustomerAddressEdit.vue | 46 +++++++++++-------- 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/src/pages/Customer/components/CustomerAddressEdit.vue b/src/pages/Customer/components/CustomerAddressEdit.vue index 8e464dd7c..b403d1012 100644 --- a/src/pages/Customer/components/CustomerAddressEdit.vue +++ b/src/pages/Customer/components/CustomerAddressEdit.vue @@ -83,19 +83,27 @@ const deleteNote = (id, index) => { notes.value.splice(index, 1); }; -const updateAddress = async () => { - /* await axios.patch( - `Clients/${route.params.id}/updateAddress/${route.params.addressId}?updateObservations=true` - );*/ - urlUpdate.value = `Clients/${route.params.id}/updateAddress/${route.params.addressId}?updateObservations=true`; +const updateAddress = async (data) => { + await axios.patch(urlUpdate.value, data); +}; + +const updateAddressTicket = async () => { + urlUpdate.value += '?updateObservations=true'; console.log('gg'); }; -const resetAndSend = async (payload) => { + +const updateObservations = async (payload) => { await axios.post('AddressObservations/crud', payload); notes.value = []; deletes.value = []; + toCustomerAddress(); }; +async function updateAll({ data, payload }) { + console.log('Si no hay notas modificadas'); + await updateAddress(data); + await updateObservations(payload); +} function getPayload() { return { creates: notes.value.filter((note) => note.$isNew), @@ -115,16 +123,12 @@ function getPayload() { })), }; } -const onDataSaved = async (payload) => { - await axios.post('AddressObservations/crud', payload); - notes.value = []; - deletes.value = []; - toCustomerAddress(); -}; async function handleDialog(data) { console.error(data); - if (getPayload().updates.length) { + const payload = getPayload(); + const body = { data, payload }; + if (payload.updates.length) { quasar .dialog({ component: VnConfirm, @@ -136,24 +140,30 @@ async function handleDialog(data) { }, }) .onOk(async () => { + console.log('Actualiza notas'); // await resetAndSend(payload); - await updateAddress(); - await onDataSaved(data); + await updateAll(body); + await updateAddressTicket(); + toCustomerAddress(); }) .onCancel(async () => { // await resetAndSend(payload); - await onDataSaved(data); + console.log('Actualiza datos'); + await updateAll(body); + toCustomerAddress(); }); // .hide(toCustomerAddress); } else { - console.log('sinModificarObservation'); - await onDataSaved(data); + updateAll(body); + toCustomerAddress(); // await resetAndSend(payload); // toCustomerAddress(); } } const toCustomerAddress = () => { + notes.value = []; + deletes.value = []; router.push({ name: 'CustomerAddress', params: { -- 2.40.1 From 5b10a3e60fcddbb915a1a3e4174f80d84ee4abf7 Mon Sep 17 00:00:00 2001 From: robert Date: Fri, 10 Jan 2025 11:17:01 +0100 Subject: [PATCH 4/5] feat: refs #6629 delete consolelog --- src/pages/Customer/components/CustomerAddressEdit.vue | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/pages/Customer/components/CustomerAddressEdit.vue b/src/pages/Customer/components/CustomerAddressEdit.vue index b403d1012..8058c8357 100644 --- a/src/pages/Customer/components/CustomerAddressEdit.vue +++ b/src/pages/Customer/components/CustomerAddressEdit.vue @@ -89,8 +89,6 @@ const updateAddress = async (data) => { const updateAddressTicket = async () => { urlUpdate.value += '?updateObservations=true'; - - console.log('gg'); }; const updateObservations = async (payload) => { @@ -100,7 +98,6 @@ const updateObservations = async (payload) => { toCustomerAddress(); }; async function updateAll({ data, payload }) { - console.log('Si no hay notas modificadas'); await updateAddress(data); await updateObservations(payload); } @@ -140,24 +137,17 @@ async function handleDialog(data) { }, }) .onOk(async () => { - console.log('Actualiza notas'); - // await resetAndSend(payload); await updateAll(body); await updateAddressTicket(); toCustomerAddress(); }) .onCancel(async () => { - // await resetAndSend(payload); - console.log('Actualiza datos'); await updateAll(body); toCustomerAddress(); }); - // .hide(toCustomerAddress); } else { updateAll(body); toCustomerAddress(); - // await resetAndSend(payload); - // toCustomerAddress(); } } -- 2.40.1 From 22467924041bfae23066127d8c6130bc531c8f11 Mon Sep 17 00:00:00 2001 From: robert Date: Mon, 13 Jan 2025 11:24:11 +0100 Subject: [PATCH 5/5] feat: refs #6629 change values --- src/pages/Customer/components/CustomerAddressEdit.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/Customer/components/CustomerAddressEdit.vue b/src/pages/Customer/components/CustomerAddressEdit.vue index bf117124c..5f74ebc17 100644 --- a/src/pages/Customer/components/CustomerAddressEdit.vue +++ b/src/pages/Customer/components/CustomerAddressEdit.vue @@ -99,8 +99,8 @@ const updateObservations = async (payload) => { toCustomerAddress(); }; async function updateAll({ data, payload }) { - await updateAddress(data); await updateObservations(payload); + await updateAddress(data); } function getPayload() { return { @@ -138,8 +138,8 @@ async function handleDialog(data) { }, }) .onOk(async () => { - await updateAll(body); await updateAddressTicket(); + await updateAll(body); toCustomerAddress(); }) .onCancel(async () => { -- 2.40.1