0
0
Fork 0
This commit is contained in:
Alex Moreno 2024-01-03 09:00:39 +01:00
commit 0a44c43715
3 changed files with 20 additions and 40 deletions

View File

@ -16,7 +16,7 @@ export function useUserConfig() {
return data; return data;
} catch (error) { } catch (error) {
notify('globals.errors.userConfig', 'negative'); notify('errors.userConfig', 'negative');
console.error('Error fetching user config:', error); console.error('Error fetching user config:', error);
} }
} }

View File

@ -127,11 +127,14 @@ async function updateDestination(claimDestinationFk, row, options = {}) {
} }
async function regularizeClaim() { async function regularizeClaim() {
const query = `Claims/${claimId}/regularizeClaim`; await axios.post(`Claims/${claimId}/regularizeClaim`);
await claimRef.value.fetch();
await axios.post(query); await arrayData.fetch({ append: false });
quasar.notify({
message: t('globals.dataSaved'),
type: 'positive',
});
if (claim.value.responsibility >= Math.ceil(DEFAULT_MAX_RESPONSABILITY) / 2) { if (claim.value.responsibility >= Math.ceil(DEFAULT_MAX_RESPONSABILITY) / 2) {
await claimRef.value.fetch();
quasar quasar
.dialog({ .dialog({
component: VnConfirm, component: VnConfirm,
@ -141,29 +144,19 @@ async function regularizeClaim() {
}, },
}) })
.onOk(async () => await onUpdateGreugeAccept()); .onOk(async () => await onUpdateGreugeAccept());
} else {
quasar.notify({
message: t('globals.dataSaved'),
type: 'positive',
});
} }
await arrayData.fetch({ append: false });
}
async function updateGreuge(greuges) {
const { data } = await axios.post(`Greuges`, greuges);
quasar.notify({
message: t('globals.dataSaved'),
type: 'positive',
});
return data;
} }
async function onUpdateGreugeAccept() { async function onUpdateGreugeAccept() {
const greugeTypeFreightId = await getGreugeTypeId(); const greugeTypeFreightId = (
const freightPickUpPrice = await getGreugeConfig(); await axios.get(`GreugeTypes/findOne`, {
filter: { where: { code: 'freightPickUp' } },
})
).data.id;
const freightPickUpPrice = (await axios.get(`GreugeConfigs/findOne`)).data
.freightPickUpPrice;
await updateGreuge({ await axios.post(`Greuges`, {
clientFk: claim.value.clientFk, clientFk: claim.value.clientFk,
description: `${t('ClaimGreugeDescription')} ${claimId}`.toUpperCase(), description: `${t('ClaimGreugeDescription')} ${claimId}`.toUpperCase(),
amount: freightPickUpPrice, amount: freightPickUpPrice,
@ -176,19 +169,6 @@ async function onUpdateGreugeAccept() {
}); });
} }
async function getGreugeTypeId() {
const params = { filter: { where: { code: 'freightPickUp' } } };
const query = `GreugeTypes/findOne`;
const { data } = await axios.get(query, { params });
return data.id;
}
async function getGreugeConfig() {
const query = `GreugeConfigs/findOne`;
const { data } = await axios.get(query);
return data.freightPickUpPrice;
}
async function save(data) { async function save(data) {
const query = `Claims/${claimId}/updateClaimAction`; const query = `Claims/${claimId}/updateClaimAction`;
await axios.patch(query, data); await axios.patch(query, data);

View File

@ -49,7 +49,7 @@ async function setData(data) {
function formattedAddress() { function formattedAddress() {
if (!ticket.value) return ''; if (!ticket.value) return '';
const address = this.ticket.address; const address = ticket.value.address;
const postcode = address.postalCode; const postcode = address.postalCode;
const province = address.province ? `(${address.province.name})` : ''; const province = address.province ? `(${address.province.name})` : '';
@ -58,7 +58,7 @@ function formattedAddress() {
function isEditable() { function isEditable() {
try { try {
return !this.ticket.ticketState.state.alertLevel; return !ticket.value.ticketState.state.alertLevel;
} catch (e) { } catch (e) {
console.error(e); console.error(e);
} }
@ -67,10 +67,10 @@ function isEditable() {
} }
async function changeState(value) { async function changeState(value) {
if (!this.ticket.id) return; if (!ticket.value.id) return;
const formData = { const formData = {
ticketFk: this.ticket.id, ticketFk: ticket.value.id,
code: value, code: value,
}; };