feat: refs #6629 addressObservation
This commit is contained in:
parent
6c866e48a0
commit
f0f6a7e9a3
|
@ -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 = [];
|
||||
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"
|
||||
>
|
||||
|
|
Loading…
Reference in New Issue