feat: refs #6629 customerAddressEdit
gitea/salix-front/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Robert Ferrús 2024-11-26 13:41:26 +01:00
parent b07286d43d
commit 8a0b65998e
1 changed files with 28 additions and 18 deletions

View File

@ -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: {