diff --git a/src/components/EditPictureForm.vue b/src/components/EditPictureForm.vue index cd6107aca..1f158e785 100644 --- a/src/components/EditPictureForm.vue +++ b/src/components/EditPictureForm.vue @@ -156,26 +156,22 @@ const rotateRight = () => { }; const onSubmit = () => { - try { - if (!newPhoto.files && !newPhoto.url) { - notify(t('Select an image'), 'negative'); - return; - } - - const options = { - type: 'blob', - }; - - editor.value - .result(options) - .then((result) => { - const file = new File([result], newPhoto.files?.name || ''); - newPhoto.blob = file; - }) - .then(() => makeRequest()); - } catch (err) { - console.error('Error uploading image'); + if (!newPhoto.files && !newPhoto.url) { + notify(t('Select an image'), 'negative'); + return; } + + const options = { + type: 'blob', + }; + + editor.value + .result(options) + .then((result) => { + const file = new File([result], newPhoto.files?.name || ''); + newPhoto.blob = file; + }) + .then(() => makeRequest()); }; const makeRequest = async () => { diff --git a/src/components/EditTableCellValueForm.vue b/src/components/EditTableCellValueForm.vue index 14709e884..7755df9ab 100644 --- a/src/components/EditTableCellValueForm.vue +++ b/src/components/EditTableCellValueForm.vue @@ -51,21 +51,17 @@ const onDataSaved = () => { }; const onSubmit = async () => { - try { - isLoading.value = true; - const rowsToEdit = $props.rows.map((row) => ({ id: row.id, itemFk: row.itemFk })); - const payload = { - field: selectedField.value.field, - newValue: newValue.value, - lines: rowsToEdit, - }; + isLoading.value = true; + const rowsToEdit = $props.rows.map((row) => ({ id: row.id, itemFk: row.itemFk })); + const payload = { + field: selectedField.value.field, + newValue: newValue.value, + lines: rowsToEdit, + }; - await axios.post($props.editUrl, payload); - onDataSaved(); - isLoading.value = false; - } catch (err) { - console.error('Error submitting table cell edit'); - } + await axios.post($props.editUrl, payload); + onDataSaved(); + isLoading.value = false; }; const closeForm = () => { diff --git a/src/components/FilterItemForm.vue b/src/components/FilterItemForm.vue index d1ceff4ce..34968ccef 100644 --- a/src/components/FilterItemForm.vue +++ b/src/components/FilterItemForm.vue @@ -84,34 +84,30 @@ const tableColumns = computed(() => [ ]); const onSubmit = async () => { - try { - let filter = itemFilter; - const params = itemFilterParams; - const where = {}; - for (let key in params) { - const value = params[key]; - if (!value) continue; + let filter = itemFilter; + const params = itemFilterParams; + const where = {}; + for (let key in params) { + const value = params[key]; + if (!value) continue; - switch (key) { - case 'name': - where[key] = { like: `%${value}%` }; - break; - case 'producerFk': - case 'typeFk': - case 'size': - case 'inkFk': - where[key] = value; - } + switch (key) { + case 'name': + where[key] = { like: `%${value}%` }; + break; + case 'producerFk': + case 'typeFk': + case 'size': + case 'inkFk': + where[key] = value; } - filter.where = where; - - const { data } = await axios.get(props.url, { - params: { filter: JSON.stringify(filter) }, - }); - tableRows.value = data; - } catch (err) { - console.error('Error fetching entries items'); } + filter.where = where; + + const { data } = await axios.get(props.url, { + params: { filter: JSON.stringify(filter) }, + }); + tableRows.value = data; }; const closeForm = () => { diff --git a/src/components/FilterTravelForm.vue b/src/components/FilterTravelForm.vue index a471552f2..9fc91457a 100644 --- a/src/components/FilterTravelForm.vue +++ b/src/components/FilterTravelForm.vue @@ -86,32 +86,28 @@ const tableColumns = computed(() => [ ]); const onSubmit = async () => { - try { - let filter = travelFilter; - const params = travelFilterParams; - const where = {}; - for (let key in params) { - const value = params[key]; - if (!value) continue; + let filter = travelFilter; + const params = travelFilterParams; + const where = {}; + for (let key in params) { + const value = params[key]; + if (!value) continue; - switch (key) { - case 'agencyModeFk': - case 'warehouseInFk': - case 'warehouseOutFk': - case 'shipped': - case 'landed': - where[key] = value; - } + switch (key) { + case 'agencyModeFk': + case 'warehouseInFk': + case 'warehouseOutFk': + case 'shipped': + case 'landed': + where[key] = value; } - - filter.where = where; - const { data } = await axios.get('Travels', { - params: { filter: JSON.stringify(filter) }, - }); - tableRows.value = data; - } catch (err) { - console.error('Error fetching travels'); } + + filter.where = where; + const { data } = await axios.get('Travels', { + params: { filter: JSON.stringify(filter) }, + }); + tableRows.value = data; }; const closeForm = () => { diff --git a/src/components/ItemsFilterPanel.vue b/src/components/ItemsFilterPanel.vue index 938dceb4d..405577095 100644 --- a/src/components/ItemsFilterPanel.vue +++ b/src/components/ItemsFilterPanel.vue @@ -88,20 +88,16 @@ const applyTags = (params, search) => { }; const fetchItemTypes = async (id) => { - try { - const filter = { - fields: ['id', 'name', 'categoryFk'], - where: { categoryFk: id }, - include: 'category', - order: 'name ASC', - }; - const { data } = await axios.get('ItemTypes', { - params: { filter: JSON.stringify(filter) }, - }); - itemTypesOptions.value = data; - } catch (err) { - console.error('Error fetching item types', err); - } + const filter = { + fields: ['id', 'name', 'categoryFk'], + where: { categoryFk: id }, + include: 'category', + order: 'name ASC', + }; + const { data } = await axios.get('ItemTypes', { + params: { filter: JSON.stringify(filter) }, + }); + itemTypesOptions.value = data; }; const getCategoryClass = (category, params) => { @@ -111,23 +107,19 @@ const getCategoryClass = (category, params) => { }; const getSelectedTagValues = async (tag) => { - try { - if (!tag?.selectedTag?.id) return; - tag.value = null; - const filter = { - fields: ['value'], - order: 'value ASC', - limit: 30, - }; + if (!tag?.selectedTag?.id) return; + tag.value = null; + const filter = { + fields: ['value'], + order: 'value ASC', + limit: 30, + }; - const params = { filter: JSON.stringify(filter) }; - const { data } = await axios.get(`Tags/${tag.selectedTag.id}/filterValue`, { - params, - }); - tag.valueOptions = data; - } catch (err) { - console.error('Error getting selected tag values'); - } + const params = { filter: JSON.stringify(filter) }; + const { data } = await axios.get(`Tags/${tag.selectedTag.id}/filterValue`, { + params, + }); + tag.valueOptions = data; }; const removeTag = (index, params, search) => { diff --git a/src/components/RefundInvoiceForm.vue b/src/components/RefundInvoiceForm.vue index 9d9f0cff1..590acede0 100644 --- a/src/components/RefundInvoiceForm.vue +++ b/src/components/RefundInvoiceForm.vue @@ -39,14 +39,10 @@ const refund = async () => { invoiceCorrectionTypeFk: invoiceParams.invoiceCorrectionTypeFk, }; - try { - const { data } = await axios.post('InvoiceOuts/refundAndInvoice', params); - notify(t('Refunded invoice'), 'positive'); - const [id] = data?.refundId || []; - if (id) router.push({ name: 'InvoiceOutSummary', params: { id } }); - } catch (err) { - console.error('Error refunding invoice', err); - } + const { data } = await axios.post('InvoiceOuts/refundAndInvoice', params); + notify(t('Refunded invoice'), 'positive'); + const [id] = data?.refundId || []; + if (id) router.push({ name: 'InvoiceOutSummary', params: { id } }); }; diff --git a/src/components/TransferInvoiceForm.vue b/src/components/TransferInvoiceForm.vue index f7050cdba..aa71070d6 100644 --- a/src/components/TransferInvoiceForm.vue +++ b/src/components/TransferInvoiceForm.vue @@ -49,36 +49,32 @@ const makeInvoice = async () => { makeInvoice: checked.value, }; - try { - if (checked.value && hasToInvoiceByAddress) { - const response = await new Promise((resolve) => { - quasar - .dialog({ - component: VnConfirm, - componentProps: { - title: t('Bill destination client'), - message: t('transferInvoiceInfo'), - }, - }) - .onOk(() => { - resolve(true); - }) - .onCancel(() => { - resolve(false); - }); - }); - if (!response) { - return; - } + if (checked.value && hasToInvoiceByAddress) { + const response = await new Promise((resolve) => { + quasar + .dialog({ + component: VnConfirm, + componentProps: { + title: t('Bill destination client'), + message: t('transferInvoiceInfo'), + }, + }) + .onOk(() => { + resolve(true); + }) + .onCancel(() => { + resolve(false); + }); + }); + if (!response) { + return; } - - const { data } = await axios.post('InvoiceOuts/transfer', params); - notify(t('Transferred invoice'), 'positive'); - const id = data?.[0]; - if (id) router.push({ name: 'InvoiceOutSummary', params: { id } }); - } catch (err) { - console.error('Error transfering invoice', err); } + + const { data } = await axios.post('InvoiceOuts/transfer', params); + notify(t('Transferred invoice'), 'positive'); + const id = data?.[0]; + if (id) router.push({ name: 'InvoiceOutSummary', params: { id } }); }; diff --git a/src/components/common/TableVisibleColumns.vue b/src/components/common/TableVisibleColumns.vue index 9a6c70ef0..ee1e56319 100644 --- a/src/components/common/TableVisibleColumns.vue +++ b/src/components/common/TableVisibleColumns.vue @@ -58,79 +58,71 @@ const getConfig = async (url, filter) => { }; const fetchViewConfigData = async () => { - try { - const userConfigFilter = { - where: { tableCode: $props.tableCode, userFk: user.value.id }, - }; - const userConfig = await getConfig('UserConfigViews', userConfigFilter); + const userConfigFilter = { + where: { tableCode: $props.tableCode, userFk: user.value.id }, + }; + const userConfig = await getConfig('UserConfigViews', userConfigFilter); - if (userConfig) { - initialUserConfigViewData.value = userConfig; - setUserConfigViewData(userConfig.configuration); - return; - } + if (userConfig) { + initialUserConfigViewData.value = userConfig; + setUserConfigViewData(userConfig.configuration); + return; + } - const defaultConfigFilter = { where: { tableCode: $props.tableCode } }; - const defaultConfig = await getConfig('DefaultViewConfigs', defaultConfigFilter); + const defaultConfigFilter = { where: { tableCode: $props.tableCode } }; + const defaultConfig = await getConfig('DefaultViewConfigs', defaultConfigFilter); - if (defaultConfig) { - // Si el backend devuelve una configuración por defecto la usamos - setUserConfigViewData(defaultConfig.columns); - return; - } else { - // Si no hay configuración por defecto mostramos todas las columnas - const defaultColumns = {}; - $props.allColumns.forEach((col) => (defaultColumns[col] = true)); - setUserConfigViewData(defaultColumns); - } - } catch (err) { - console.error('Error fetching config view data', err); + if (defaultConfig) { + // Si el backend devuelve una configuración por defecto la usamos + setUserConfigViewData(defaultConfig.columns); + return; + } else { + // Si no hay configuración por defecto mostramos todas las columnas + const defaultColumns = {}; + $props.allColumns.forEach((col) => (defaultColumns[col] = true)); + setUserConfigViewData(defaultColumns); } }; const saveConfig = async () => { - try { - const params = {}; - const configuration = {}; + const params = {}; + const configuration = {}; - formattedCols.value.forEach((col) => { - const { name, active } = col; - configuration[name] = active; - }); + formattedCols.value.forEach((col) => { + const { name, active } = col; + configuration[name] = active; + }); - // Si existe una view config del usuario hacemos un update si no la creamos - if (initialUserConfigViewData.value) { - params.updates = [ - { - data: { - configuration: configuration, - }, - where: { - id: initialUserConfigViewData.value.id, - }, - }, - ]; - } else { - params.creates = [ - { - userFk: user.value.id, - tableCode: $props.tableCode, - tableConfig: $props.tableCode, + // Si existe una view config del usuario hacemos un update si no la creamos + if (initialUserConfigViewData.value) { + params.updates = [ + { + data: { configuration: configuration, }, - ]; - } - - const response = await axios.post('UserConfigViews/crud', params); - if (response.data && response.data[0]) { - initialUserConfigViewData.value = response.data[0]; - } - emitSavedConfig(); - notify('globals.dataSaved', 'positive'); - popupProxyRef.value.hide(); - } catch (err) { - console.error('Error saving user view config', err); + where: { + id: initialUserConfigViewData.value.id, + }, + }, + ]; + } else { + params.creates = [ + { + userFk: user.value.id, + tableCode: $props.tableCode, + tableConfig: $props.tableCode, + configuration: configuration, + }, + ]; } + + const response = await axios.post('UserConfigViews/crud', params); + if (response.data && response.data[0]) { + initialUserConfigViewData.value = response.data[0]; + } + emitSavedConfig(); + notify('globals.dataSaved', 'positive'); + popupProxyRef.value.hide(); }; const emitSavedConfig = () => { diff --git a/src/components/ui/VnFilterPanel.vue b/src/components/ui/VnFilterPanel.vue index 84f2b43d7..fb1125fda 100644 --- a/src/components/ui/VnFilterPanel.vue +++ b/src/components/ui/VnFilterPanel.vue @@ -74,6 +74,9 @@ const arrayData = useArrayData($props.dataKey, { const route = useRoute(); const store = arrayData.store; const userParams = ref({}); + +defineExpose({ search, sanitizer, params: userParams }); + onMounted(() => { userParams.value = $props.modelValue ?? {}; emit('init', { params: userParams.value }); @@ -197,7 +200,7 @@ const customTags = computed(() => async function remove(key) { userParams.value[key] = undefined; - search(); + await search(); emit('remove', key); emit('update:modelValue', userParams.value); } @@ -223,8 +226,6 @@ function sanitizer(params) { } return params; } - -defineExpose({ search, sanitizer, userParams });