6629-addressObservation #1011

Open
robert wants to merge 10 commits from 6629-addressObservation into dev
1 changed files with 28 additions and 18 deletions
Showing only changes of commit 8a0b65998e - Show all commits

View File

@ -83,19 +83,27 @@ const deleteNote = (id, index) => {
notes.value.splice(index, 1); notes.value.splice(index, 1);
}; };
const updateAddress = async () => { const updateAddress = async (data) => {
/* await axios.patch( await axios.patch(urlUpdate.value, data);
`Clients/${route.params.id}/updateAddress/${route.params.addressId}?updateObservations=true` };
);*/
urlUpdate.value = `Clients/${route.params.id}/updateAddress/${route.params.addressId}?updateObservations=true`; const updateAddressTicket = async () => {
urlUpdate.value += '?updateObservations=true';
console.log('gg'); console.log('gg');
}; };
const resetAndSend = async (payload) => {
const updateObservations = async (payload) => {
await axios.post('AddressObservations/crud', payload); await axios.post('AddressObservations/crud', payload);
notes.value = []; notes.value = [];
deletes.value = []; deletes.value = [];
toCustomerAddress();
}; };
async function updateAll({ data, payload }) {
console.log('Si no hay notas modificadas');
await updateAddress(data);
await updateObservations(payload);
}
function getPayload() { function getPayload() {
return { return {
creates: notes.value.filter((note) => note.$isNew), 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) { async function handleDialog(data) {
console.error(data); console.error(data);
if (getPayload().updates.length) { const payload = getPayload();
const body = { data, payload };
if (payload.updates.length) {
quasar quasar
.dialog({ .dialog({
component: VnConfirm, component: VnConfirm,
@ -136,24 +140,30 @@ async function handleDialog(data) {
}, },
}) })
.onOk(async () => { .onOk(async () => {
console.log('Actualiza notas');
// await resetAndSend(payload); // await resetAndSend(payload);
await updateAddress(); await updateAll(body);
await onDataSaved(data); await updateAddressTicket();
toCustomerAddress();
}) })
.onCancel(async () => { .onCancel(async () => {
// await resetAndSend(payload); // await resetAndSend(payload);
await onDataSaved(data); console.log('Actualiza datos');
await updateAll(body);
toCustomerAddress();
}); });
// .hide(toCustomerAddress); // .hide(toCustomerAddress);
} else { } else {
console.log('sinModificarObservation'); updateAll(body);
await onDataSaved(data); toCustomerAddress();
// await resetAndSend(payload); // await resetAndSend(payload);
// toCustomerAddress(); // toCustomerAddress();
} }
} }
const toCustomerAddress = () => { const toCustomerAddress = () => {
notes.value = [];
deletes.value = [];
router.push({ router.push({
name: 'CustomerAddress', name: 'CustomerAddress',
params: { params: {