From ccb558f4e90ade522e99e7f67a08358e14d6f309 Mon Sep 17 00:00:00 2001 From: jorgep <jorgep@verdnatura.es> Date: Fri, 10 Jan 2025 17:29:31 +0100 Subject: [PATCH] refactor: refs #6919 update reload default value and extract InvoiceIn filter to a separate file --- src/components/FormModel.vue | 2 +- src/pages/Claim/Card/ClaimBasicData.vue | 1 - src/pages/Claim/Card/ClaimDescriptor.vue | 8 +---- src/pages/InvoiceIn/Card/InvoiceInCard.vue | 35 +------------------ .../InvoiceIn/Card/InvoiceInDescriptor.vue | 28 ++------------- src/pages/InvoiceIn/Card/InvoiceInFilter.js | 33 +++++++++++++++++ 6 files changed, 38 insertions(+), 69 deletions(-) create mode 100644 src/pages/InvoiceIn/Card/InvoiceInFilter.js diff --git a/src/components/FormModel.vue b/src/components/FormModel.vue index ea1ea53f2..c23598a99 100644 --- a/src/components/FormModel.vue +++ b/src/components/FormModel.vue @@ -84,7 +84,7 @@ const $props = defineProps({ }, reload: { type: Boolean, - default: false, + default: true, }, defaultTrim: { type: Boolean, diff --git a/src/pages/Claim/Card/ClaimBasicData.vue b/src/pages/Claim/Card/ClaimBasicData.vue index 63b0b7c0d..67034da1a 100644 --- a/src/pages/Claim/Card/ClaimBasicData.vue +++ b/src/pages/Claim/Card/ClaimBasicData.vue @@ -28,7 +28,6 @@ const workersOptions = ref([]); model="Claim" :url-update="`Claims/updateClaim/${route.params.id}`" auto-load - :reload="true" > <template #form="{ data, validate }"> <VnRow> diff --git a/src/pages/Claim/Card/ClaimDescriptor.vue b/src/pages/Claim/Card/ClaimDescriptor.vue index 244d10811..f55b0c48b 100644 --- a/src/pages/Claim/Card/ClaimDescriptor.vue +++ b/src/pages/Claim/Card/ClaimDescriptor.vue @@ -3,7 +3,6 @@ import { ref, computed, onMounted } from 'vue'; import { useRoute } from 'vue-router'; import { useI18n } from 'vue-i18n'; import { toDateHourMinSec, toPercentage } from 'src/filters'; -import { useState } from 'src/composables/useState'; import TicketDescriptorProxy from 'pages/Ticket/Card/TicketDescriptorProxy.vue'; import ClaimDescriptorMenu from 'pages/Claim/Card/ClaimDescriptorMenu.vue'; import CardDescriptor from 'components/ui/CardDescriptor.vue'; @@ -22,7 +21,6 @@ const $props = defineProps({ }); const route = useRoute(); -const state = useState(); const { t } = useI18n(); const salixUrl = ref(); const entityId = computed(() => { @@ -38,10 +36,7 @@ const STATE_COLOR = { function stateColor(code) { return STATE_COLOR[code]; } -const setData = (entity) => { - if (!entity) return; - state.set('ClaimDescriptor', entity); -}; + onMounted(async () => { salixUrl.value = await getUrl(''); }); @@ -53,7 +48,6 @@ onMounted(async () => { :filter="filter" module="Claim" title="client.name" - @on-fetch="setData" data-key="Claim" > <template #menu="{ entity }"> diff --git a/src/pages/InvoiceIn/Card/InvoiceInCard.vue b/src/pages/InvoiceIn/Card/InvoiceInCard.vue index af6843016..a13589909 100644 --- a/src/pages/InvoiceIn/Card/InvoiceInCard.vue +++ b/src/pages/InvoiceIn/Card/InvoiceInCard.vue @@ -5,40 +5,7 @@ import InvoiceInFilter from '../InvoiceInFilter.vue'; import InvoiceInSearchbar from '../InvoiceInSearchbar.vue'; import { onBeforeRouteUpdate } from 'vue-router'; import { setRectificative } from '../composables/setRectificative'; - -const filter = { - include: [ - { - relation: 'supplier', - scope: { - include: { - relation: 'contacts', - scope: { where: { email: { neq: null } } }, - }, - }, - }, - { relation: 'invoiceInDueDay' }, - { relation: 'company' }, - { relation: 'currency' }, - { - relation: 'dms', - scope: { - fields: [ - 'dmsTypeFk', - 'reference', - 'hardCopyNumber', - 'workerFk', - 'description', - 'hasFile', - 'file', - 'created', - 'companyFk', - 'warehouseFk', - ], - }, - }, - ], -}; +import filter from './InvoiceInFilter.js'; onBeforeRouteUpdate(async (to) => await setRectificative(to)); </script> diff --git a/src/pages/InvoiceIn/Card/InvoiceInDescriptor.vue b/src/pages/InvoiceIn/Card/InvoiceInDescriptor.vue index cb8a45833..c2d9ca562 100644 --- a/src/pages/InvoiceIn/Card/InvoiceInDescriptor.vue +++ b/src/pages/InvoiceIn/Card/InvoiceInDescriptor.vue @@ -17,6 +17,7 @@ import VnConfirm from 'src/components/ui/VnConfirm.vue'; import VnSelect from 'src/components/common/VnSelect.vue'; import SupplierDescriptorProxy from 'src/pages/Supplier/Card/SupplierDescriptorProxy.vue'; import InvoiceInToBook from '../InvoiceInToBook.vue'; +import filter from './InvoiceInFilter.js'; const $props = defineProps({ id: { type: Number, default: null } }); @@ -55,32 +56,7 @@ const actions = { sendPdf: { cb: sendPdfInvoiceConfirmation }, correct: { cb: () => correctionDialogRef.value.show() }, }; -const filter = { - include: [ - { - relation: 'supplier', - scope: { - include: { - relation: 'contacts', - scope: { - where: { - email: { neq: null }, - }, - }, - }, - }, - }, - { - relation: 'invoiceInDueDay', - }, - { - relation: 'company', - }, - { - relation: 'currency', - }, - ], -}; + const invoiceInCorrection = reactive({ correcting: [], corrected: null }); const routes = reactive({ getSupplier: (id) => { diff --git a/src/pages/InvoiceIn/Card/InvoiceInFilter.js b/src/pages/InvoiceIn/Card/InvoiceInFilter.js new file mode 100644 index 000000000..6df8b5830 --- /dev/null +++ b/src/pages/InvoiceIn/Card/InvoiceInFilter.js @@ -0,0 +1,33 @@ +export default { + include: [ + { + relation: 'supplier', + scope: { + include: { + relation: 'contacts', + scope: { where: { email: { neq: null } } }, + }, + }, + }, + { relation: 'invoiceInDueDay' }, + { relation: 'company' }, + { relation: 'currency' }, + { + relation: 'dms', + scope: { + fields: [ + 'dmsTypeFk', + 'reference', + 'hardCopyNumber', + 'workerFk', + 'description', + 'hasFile', + 'file', + 'created', + 'companyFk', + 'warehouseFk', + ], + }, + }, + ], +};