fix: refs #8039 o not handle unnecessary errors
gitea/salix-front/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Alex Moreno 2024-10-22 14:05:15 +02:00
parent cd00a3c67f
commit dd2dc86eea
14 changed files with 228 additions and 371 deletions

View File

@ -46,13 +46,9 @@ const columns = computed(() => [
]);
const deleteAlias = async (row) => {
try {
await axios.delete(`${urlPath.value}/${row.id}`);
notify(t('User removed'), 'positive');
fetchAliases();
} catch (error) {
console.error(error);
}
await axios.delete(`${urlPath.value}/${row.id}`);
notify(t('User removed'), 'positive');
fetchAliases();
};
watch(

View File

@ -61,23 +61,15 @@ const fetchAccountExistence = async () => {
};
const deleteMailAlias = async (row) => {
try {
await axios.delete(`${urlPath}/${row.id}`);
fetchMailAliases();
notify(t('Unsubscribed from alias!'), 'positive');
} catch (error) {
console.error(error);
}
await axios.delete(`${urlPath}/${row.id}`);
fetchMailAliases();
notify(t('Unsubscribed from alias!'), 'positive');
};
const createMailAlias = async (mailAliasFormData) => {
try {
await axios.post(urlPath, mailAliasFormData);
notify(t('Subscribed to alias!'), 'positive');
fetchMailAliases();
} catch (error) {
console.error(error);
}
await axios.post(urlPath, mailAliasFormData);
notify(t('Subscribed to alias!'), 'positive');
fetchMailAliases();
};
const fetchMailAliases = async () => {

View File

@ -46,29 +46,15 @@ const columns = computed(() => [
]);
const deleteSubRole = async (row) => {
try {
await axios.delete(`${urlPath.value}/${row.id}`);
fetchSubRoles();
notify(
t('Role removed. Changes will take a while to fully propagate.'),
'positive'
);
} catch (error) {
console.error(error);
}
await axios.delete(`${urlPath.value}/${row.id}`);
fetchSubRoles();
notify(t('Role removed. Changes will take a while to fully propagate.'), 'positive');
};
const createSubRole = async (subRoleFormData) => {
try {
await axios.post(urlPath.value, subRoleFormData);
notify(
t('Role added! Changes will take a while to fully propagate.'),
'positive'
);
fetchSubRoles();
} catch (error) {
console.error(error);
}
await axios.post(urlPath.value, subRoleFormData);
notify(t('Role added! Changes will take a while to fully propagate.'), 'positive');
fetchSubRoles();
};
watch(

View File

@ -112,32 +112,20 @@ const getShipped = async (params) => {
};
const onChangeZone = async (zoneId) => {
try {
formData.value.agencyModeFk = null;
const { data } = await axios.get(`Zones/${zoneId}`);
formData.value.agencyModeFk = data.agencyModeFk;
} catch (error) {
console.error(error);
}
formData.value.agencyModeFk = null;
const { data } = await axios.get(`Zones/${zoneId}`);
formData.value.agencyModeFk = data.agencyModeFk;
};
const onChangeAddress = async (addressId) => {
try {
formData.value.nickname = null;
const { data } = await axios.get(`Addresses/${addressId}`);
formData.value.nickname = data.nickname;
} catch (error) {
console.error(error);
}
formData.value.nickname = null;
const { data } = await axios.get(`Addresses/${addressId}`);
formData.value.nickname = data.nickname;
};
const getClientDefaultAddress = async (clientId) => {
try {
const { data } = await axios.get(`Clients/${clientId}`);
if (data) addressId.value = data.defaultAddressFk;
} catch (error) {
console.error(error);
}
const { data } = await axios.get(`Clients/${clientId}`);
if (data) addressId.value = data.defaultAddressFk;
};
const clientAddressesList = async (value) => {

View File

@ -70,60 +70,51 @@ const isFormInvalid = () => {
};
const getPriceDifference = async () => {
try {
const params = {
landed: formData.value.landed,
addressId: formData.value.addressFk,
agencyModeId: formData.value.agencyModeFk,
zoneId: formData.value.zoneFk,
warehouseId: formData.value.warehouseFk,
shipped: formData.value.shipped,
};
const { data } = await axios.post(
`tickets/${formData.value.id}/priceDifference`,
params
);
formData.value.sale = data;
} catch (error) {
console.error(error);
}
const params = {
landed: formData.value.landed,
addressId: formData.value.addressFk,
agencyModeId: formData.value.agencyModeFk,
zoneId: formData.value.zoneFk,
warehouseId: formData.value.warehouseFk,
shipped: formData.value.shipped,
};
const { data } = await axios.post(
`tickets/${formData.value.id}/priceDifference`,
params
);
formData.value.sale = data;
};
const submit = async () => {
try {
if (!formData.value.option)
return notify(t('basicData.chooseAnOption'), 'negative');
if (!formData.value.option) return notify(t('basicData.chooseAnOption'), 'negative');
const params = {
clientFk: formData.value.clientFk,
nickname: formData.value.nickname,
agencyModeFk: formData.value.agencyModeFk,
addressFk: formData.value.addressFk,
zoneFk: formData.value.zoneFk,
warehouseFk: formData.value.warehouseFk,
companyFk: formData.value.companyFk,
shipped: formData.value.shipped,
landed: formData.value.landed,
isDeleted: formData.value.isDeleted,
option: formData.value.option,
isWithoutNegatives: formData.value.withoutNegatives,
withWarningAccept: formData.value.withWarningAccept,
keepPrice: false,
};
const params = {
clientFk: formData.value.clientFk,
nickname: formData.value.nickname,
agencyModeFk: formData.value.agencyModeFk,
addressFk: formData.value.addressFk,
zoneFk: formData.value.zoneFk,
warehouseFk: formData.value.warehouseFk,
companyFk: formData.value.companyFk,
shipped: formData.value.shipped,
landed: formData.value.landed,
isDeleted: formData.value.isDeleted,
option: formData.value.option,
isWithoutNegatives: formData.value.withoutNegatives,
withWarningAccept: formData.value.withWarningAccept,
keepPrice: false,
};
const { data } = await axios.post(
`tickets/${formData.value.id}/componentUpdate`,
params
);
const { data } = await axios.post(
`tickets/${formData.value.id}/componentUpdate`,
params
);
if (!data) return;
if (!data) return;
const ticketToMove = data.id;
notify(t('basicData.unroutedTicket'), 'positive');
router.push({ name: 'TicketSummary', params: { id: ticketToMove } });
} catch (error) {
console.error(error);
}
const ticketToMove = data.id;
notify(t('basicData.unroutedTicket'), 'positive');
router.push({ name: 'TicketSummary', params: { id: ticketToMove } });
};
const submitWithNegatives = async () => {

View File

@ -34,26 +34,20 @@ const newTicketFormData = reactive({});
const date = new Date();
const createTicket = async () => {
try {
const expeditionIds = $props.selectedExpeditions.map(
(expedition) => expedition.id
);
const params = {
clientId: $props.ticket.clientFk,
landed: newTicketFormData.landed,
warehouseId: $props.ticket.warehouseFk,
addressId: $props.ticket.addressFk,
agencyModeId: $props.ticket.agencyModeFk,
routeId: newTicketFormData.routeFk,
expeditionIds: expeditionIds,
};
const expeditionIds = $props.selectedExpeditions.map((expedition) => expedition.id);
const params = {
clientId: $props.ticket.clientFk,
landed: newTicketFormData.landed,
warehouseId: $props.ticket.warehouseFk,
addressId: $props.ticket.addressFk,
agencyModeId: $props.ticket.agencyModeFk,
routeId: newTicketFormData.routeFk,
expeditionIds: expeditionIds,
};
const { data } = await axios.post('Expeditions/moveExpeditions', params);
notify(t('globals.dataSaved'), 'positive');
router.push({ name: 'TicketSummary', params: { id: data.id } });
} catch (error) {
console.error(error);
}
const { data } = await axios.post('Expeditions/moveExpeditions', params);
notify(t('globals.dataSaved'), 'positive');
router.push({ name: 'TicketSummary', params: { id: data.id } });
};
</script>

View File

@ -150,31 +150,19 @@ const getTotal = computed(() => {
});
const getComponentsSum = async () => {
try {
const { data } = await axios.get(`Tickets/${route.params.id}/getComponentsSum`);
componentsList.value = data;
} catch (error) {
console.error(error);
}
const { data } = await axios.get(`Tickets/${route.params.id}/getComponentsSum`);
componentsList.value = data;
};
const getTheoricalCost = async () => {
try {
const { data } = await axios.get(`Tickets/${route.params.id}/freightCost`);
theoricalCost.value = data;
} catch (error) {
console.error(error);
}
const { data } = await axios.get(`Tickets/${route.params.id}/freightCost`);
theoricalCost.value = data;
};
const getTicketVolume = async () => {
try {
if (!ticketData.value) return;
const { data } = await axios.get(`Tickets/${ticketData.value.id}/getVolume`);
ticketVolume.value = data[0].volume;
} catch (error) {
console.error(error);
}
if (!ticketData.value) return;
const { data } = await axios.get(`Tickets/${ticketData.value.id}/getVolume`);
ticketVolume.value = data[0].volume;
};
onMounted(() => {

View File

@ -187,18 +187,12 @@ const showNewTicketDialog = (withRoute = false) => {
};
const deleteExpedition = async () => {
try {
const expeditionIds = selectedExpeditions.value.map(
(expedition) => expedition.id
);
const params = { expeditionIds };
await axios.post('Expeditions/deleteExpeditions', params);
await refetchExpeditions();
selectedExpeditions.value = [];
notify(t('expedition.expeditionRemoved'), 'positive');
} catch (error) {
console.error(error);
}
const expeditionIds = selectedExpeditions.value.map((expedition) => expedition.id);
const params = { expeditionIds };
await axios.post('Expeditions/deleteExpeditions', params);
await refetchExpeditions();
selectedExpeditions.value = [];
notify(t('expedition.expeditionRemoved'), 'positive');
};
const showLog = async (expedition) => {
@ -207,29 +201,25 @@ const showLog = async (expedition) => {
};
const getExpeditionState = async (expedition) => {
try {
const filter = {
where: { expeditionFk: expedition.id },
order: ['created DESC'],
const filter = {
where: { expeditionFk: expedition.id },
order: ['created DESC'],
};
const { data: expeditionStates } = await axios.get(`ExpeditionStates/filter`, {
params: { filter: JSON.stringify(filter) },
});
const { data: scannedStates } = await axios.get(`ExpeditionStates`, {
params: { filter: JSON.stringify(filter), fields: ['id', 'isScanned'] },
});
expeditionsLogsData.value = expeditionStates.map((state) => {
const scannedState = scannedStates.find((s) => s.id === state.id);
return {
...state,
isScanned: scannedState ? scannedState.isScanned : false,
};
const { data: expeditionStates } = await axios.get(`ExpeditionStates/filter`, {
params: { filter: JSON.stringify(filter) },
});
const { data: scannedStates } = await axios.get(`ExpeditionStates`, {
params: { filter: JSON.stringify(filter), fields: ['id', 'isScanned'] },
});
expeditionsLogsData.value = expeditionStates.map((state) => {
const scannedState = scannedStates.find((s) => s.id === state.id);
return {
...state,
isScanned: scannedState ? scannedState.isScanned : false,
};
});
} catch (error) {
console.error(error);
}
});
};
onMounted(async () => {

View File

@ -165,14 +165,10 @@ const createRefund = async (withWarehouse) => {
negative: true,
};
try {
const { data } = await axios.post('Tickets/cloneAll', params);
const [refundTicket] = data;
notify(t('refundTicketCreated', { ticketId: refundTicket.id }), 'positive');
push({ name: 'TicketSale', params: { id: refundTicket.id } });
} catch (error) {
console.error(error);
}
const { data } = await axios.post('Tickets/cloneAll', params);
const [refundTicket] = data;
notify(t('refundTicketCreated', { ticketId: refundTicket.id }), 'positive');
push({ name: 'TicketSale', params: { id: refundTicket.id } });
};
</script>

View File

@ -150,18 +150,14 @@ const shelvingsTableColumns = computed(() => [
]);
const getSaleTrackings = async (sale) => {
try {
const filter = {
where: { saleFk: sale.saleFk },
order: ['itemFk DESC'],
};
const { data } = await axios.get(`SaleTrackings/listSaleTracking`, {
params: { filter: JSON.stringify(filter) },
});
saleTrackings.value = data;
} catch (error) {
console.error(error);
}
const filter = {
where: { saleFk: sale.saleFk },
order: ['itemFk DESC'],
};
const { data } = await axios.get(`SaleTrackings/listSaleTracking`, {
params: { filter: JSON.stringify(filter) },
});
saleTrackings.value = data;
};
const showLog = async (sale) => {
@ -170,17 +166,13 @@ const showLog = async (sale) => {
};
const getItemShelvingSales = async (sale) => {
try {
const filter = {
where: { saleFk: sale.saleFk },
};
const { data } = await axios.get(`ItemShelvingSales/filter`, {
params: { filter: JSON.stringify(filter) },
});
itemShelvingsSales.value = data;
} catch (error) {
console.error(error);
}
const filter = {
where: { saleFk: sale.saleFk },
};
const { data } = await axios.get(`ItemShelvingSales/filter`, {
params: { filter: JSON.stringify(filter) },
});
itemShelvingsSales.value = data;
};
const showShelving = async (sale) => {
@ -189,36 +181,28 @@ const showShelving = async (sale) => {
};
const updateQuantity = async (sale) => {
try {
if (oldQuantity.value === sale.quantity) return;
const params = {
quantity: sale.quantity,
};
await axios.patch(`ItemShelvingSales/${sale.id}`, params);
oldQuantity.value = null;
} catch (error) {
console.error(error);
}
if (oldQuantity.value === sale.quantity) return;
const params = {
quantity: sale.quantity,
};
await axios.patch(`ItemShelvingSales/${sale.id}`, params);
oldQuantity.value = null;
};
const updateParking = async (sale) => {
try {
const filter = {
fields: ['id'],
where: {
code: sale.shelvingFk,
},
};
const { data } = await axios.get(`Shelvings/findOne`, {
params: { filter: JSON.stringify(filter) },
});
const params = {
parkingFk: sale.parkingFk,
};
await axios.patch(`Shelvings/${data.id}`, params);
} catch (error) {
console.error(error);
}
const filter = {
fields: ['id'],
where: {
code: sale.shelvingFk,
},
};
const { data } = await axios.get(`Shelvings/findOne`, {
params: { filter: JSON.stringify(filter) },
});
const params = {
parkingFk: sale.parkingFk,
};
await axios.patch(`Shelvings/${data.id}`, params);
};
const updateShelving = async (sale) => {
@ -241,61 +225,41 @@ const updateShelving = async (sale) => {
};
const saleTrackingNew = async (sale, stateCode, isChecked) => {
try {
const params = {
saleFk: sale.saleFk,
isChecked,
quantity: sale.quantity,
stateCode,
};
await axios.post(`SaleTrackings/new`, params);
notify(t('globals.dataSaved'), 'positive');
} catch (error) {
console.error(error);
}
const params = {
saleFk: sale.saleFk,
isChecked,
quantity: sale.quantity,
stateCode,
};
await axios.post(`SaleTrackings/new`, params);
notify(t('globals.dataSaved'), 'positive');
};
const saleTrackingDel = async ({ saleFk }, stateCode) => {
try {
const params = {
saleFk,
stateCodes: [stateCode],
};
await axios.post(`SaleTrackings/delete`, params);
notify(t('globals.dataSaved'), 'positive');
} catch (error) {
console.error(error);
}
const params = {
saleFk,
stateCodes: [stateCode],
};
await axios.post(`SaleTrackings/delete`, params);
notify(t('globals.dataSaved'), 'positive');
};
const clickSaleGroupDetail = async (sale) => {
try {
if (!sale.saleGroupDetailFk) return;
if (!sale.saleGroupDetailFk) return;
await axios.delete(`SaleGroupDetails/${sale.saleGroupDetailFk}`);
sale.hasSaleGroupDetail = false;
notify(t('globals.dataSaved'), 'positive');
} catch (error) {
console.error(error);
}
await axios.delete(`SaleGroupDetails/${sale.saleGroupDetailFk}`);
sale.hasSaleGroupDetail = false;
notify(t('globals.dataSaved'), 'positive');
};
const clickPreviousSelected = (sale) => {
try {
qCheckBoxController(sale, 'isPreviousSelected');
if (!sale.isPreviousSelected) sale.isPrevious = false;
} catch (error) {
console.error(error);
}
qCheckBoxController(sale, 'isPreviousSelected');
if (!sale.isPreviousSelected) sale.isPrevious = false;
};
const clickPrevious = (sale) => {
try {
qCheckBoxController(sale, 'isPrevious');
if (sale.isPrevious) sale.isPreviousSelected = true;
} catch (error) {
console.error(error);
}
qCheckBoxController(sale, 'isPrevious');
if (sale.isPrevious) sale.isPreviousSelected = true;
};
const qCheckBoxController = (sale, action) => {
@ -306,16 +270,12 @@ const qCheckBoxController = (sale, action) => {
isPreviousSelected: 'PREVIOUS_PREPARATION',
};
const stateCode = STATE_CODES[action];
try {
if (!sale[action]) {
saleTrackingNew(sale, stateCode, true);
sale[action] = true;
} else {
saleTrackingDel(sale, stateCode);
sale[action] = false;
}
} catch (error) {
console.error(error);
if (!sale[action]) {
saleTrackingNew(sale, stateCode, true);
sale[action] = true;
} else {
saleTrackingDel(sale, stateCode);
sale[action] = false;
}
};
</script>

View File

@ -46,40 +46,32 @@ watch(
onMounted(async () => await getDefaultTaxClass());
const createRefund = async () => {
try {
if (!selected.value.length) return;
if (!selected.value.length) return;
const params = {
servicesIds: selected.value.map((s) => +s.id),
withWarehouse: false,
negative: true,
};
const { data } = await axios.post('Sales/clone', params);
const [refundTicket] = data;
notify(
t('service.createRefundSuccess', {
ticketId: refundTicket.id,
}),
'positive'
);
router.push({ name: 'TicketSale', params: { id: refundTicket.id } });
} catch (error) {
console.error(error);
}
const params = {
servicesIds: selected.value.map((s) => +s.id),
withWarehouse: false,
negative: true,
};
const { data } = await axios.post('Sales/clone', params);
const [refundTicket] = data;
notify(
t('service.createRefundSuccess', {
ticketId: refundTicket.id,
}),
'positive'
);
router.push({ name: 'TicketSale', params: { id: refundTicket.id } });
};
const getDefaultTaxClass = async () => {
try {
let filter = {
where: { code: 'G' },
};
const { data } = await axios.get('TaxClasses/findOne', {
params: { filter: JSON.stringify(filter) },
});
defaultTaxClass.value = data;
} catch (error) {
console.error(error);
}
let filter = {
where: { code: 'G' },
};
const { data } = await axios.get('TaxClasses/findOne', {
params: { filter: JSON.stringify(filter) },
});
defaultTaxClass.value = data;
};
const columns = computed(() => [

View File

@ -75,22 +75,18 @@ const columns = computed(() => [
]);
const applyVolumes = async (salesData) => {
try {
if (!salesData.length) return;
if (!salesData.length) return;
sales.value = salesData;
const ticket = sales.value[0].ticketFk;
const { data } = await axios.get(`Tickets/${ticket}/getVolume`);
const volumes = new Map(data.saleVolume.map((volume) => [volume.saleFk, volume]));
sales.value = salesData;
const ticket = sales.value[0].ticketFk;
const { data } = await axios.get(`Tickets/${ticket}/getVolume`);
const volumes = new Map(data.saleVolume.map((volume) => [volume.saleFk, volume]));
sales.value.forEach((sale) => {
sale.saleVolume = volumes.get(sale.id);
});
sales.value.forEach((sale) => {
sale.saleVolume = volumes.get(sale.id);
});
packingTypeVolume.value = data.packingTypeVolume;
} catch (error) {
console.error(error);
}
packingTypeVolume.value = data.packingTypeVolume;
};
onMounted(() => (stateStore.rightDrawer = true));

View File

@ -27,20 +27,16 @@ const warehousesOptions = ref([]);
const itemPackingTypes = ref([]);
const getItemPackingTypes = async () => {
try {
const filter = {
where: { isActive: true },
};
const { data } = await axios.get('ItemPackingTypes', {
params: { filter: JSON.stringify(filter) },
});
itemPackingTypes.value = data.map((ipt) => ({
description: t(ipt.description),
code: ipt.code,
}));
} catch (error) {
console.error(error);
}
const filter = {
where: { isActive: true },
};
const { data } = await axios.get('ItemPackingTypes', {
params: { filter: JSON.stringify(filter) },
});
itemPackingTypes.value = data.map((ipt) => ({
description: t(ipt.description),
code: ipt.code,
}));
};
onMounted(async () => await getItemPackingTypes());

View File

@ -24,33 +24,25 @@ const itemPackingTypes = ref([]);
const stateOptions = ref([]);
const getItemPackingTypes = async () => {
try {
const filter = {
where: { isActive: true },
};
const { data } = await axios.get('ItemPackingTypes', {
params: { filter: JSON.stringify(filter) },
});
itemPackingTypes.value = data.map((ipt) => ({
description: t(ipt.description),
code: ipt.code,
}));
} catch (error) {
console.error(error);
}
const filter = {
where: { isActive: true },
};
const { data } = await axios.get('ItemPackingTypes', {
params: { filter: JSON.stringify(filter) },
});
itemPackingTypes.value = data.map((ipt) => ({
description: t(ipt.description),
code: ipt.code,
}));
};
const getGroupedStates = async () => {
try {
const { data } = await axios.get('AlertLevels');
stateOptions.value = data.map((state) => ({
id: state.id,
name: t(`futureTickets.${state.code}`),
code: state.code,
}));
} catch (error) {
console.error(error);
}
const { data } = await axios.get('AlertLevels');
stateOptions.value = data.map((state) => ({
id: state.id,
name: t(`futureTickets.${state.code}`),
code: state.code,
}));
};
onMounted(async () => {