From 7557096af6c13f4091790cfa30afd0ae794b6577 Mon Sep 17 00:00:00 2001 From: alexm Date: Wed, 13 Dec 2023 14:19:42 +0100 Subject: [PATCH] refs #6062 fix: migration errors --- package-lock.json | 12 +- src/boot/vnDate.js | 10 + src/components/FormModel.vue | 81 +++- src/components/common/VnInputDate.vue | 76 ++++ src/components/common/VnLog.vue | 28 +- src/components/common/VnSelectFilter.vue | 7 +- src/components/ui/CardDescriptor.vue | 23 +- src/components/ui/CardList.vue | 81 +++- src/components/ui/CardSummary.vue | 4 +- src/components/ui/VnFilterPanel.vue | 66 +-- src/composables/useArrayData.js | 4 +- src/composables/useNotify.js | 22 + src/composables/useState.js | 6 +- src/composables/useUserConfig.js | 18 +- src/i18n/en/index.js | 174 +++++++- src/i18n/es/index.js | 175 +++++++- src/pages/Claim/Card/ClaimBasicData.vue | 32 +- src/pages/Claim/ClaimFilter.vue | 29 +- src/pages/Claim/ClaimList.vue | 36 +- src/pages/Customer/Card/CustomerBasicData.vue | 2 +- src/pages/Customer/CustomerList.vue | 26 +- src/pages/Customer/CustomerPaymentsFilter.vue | 71 +-- .../InvoiceOut/Card/InvoiceOutDescriptor.vue | 9 +- .../Card/InvoiceOutDescriptorMenu.vue | 40 ++ src/pages/InvoiceOut/InvoiceOutFilter.vue | 201 +++------ src/pages/InvoiceOut/InvoiceOutGlobal.vue | 198 +++++++++ src/pages/InvoiceOut/InvoiceOutGlobalForm.vue | 201 +++++++++ src/pages/InvoiceOut/InvoiceOutList.vue | 273 ++++++++---- .../InvoiceOut/InvoiceOutNegativeBases.vue | 356 +++++++++++++++ src/pages/Route/Cmr/CmrFilter.vue | 33 +- src/pages/Shelving/Card/ShelvingCard.vue | 21 + .../Shelving/Card/ShelvingDescriptor.vue | 71 +++ .../Shelving/Card/ShelvingDescriptorMenu.vue | 61 +++ .../Shelving/Card/ShelvingDescriptorProxy.vue | 15 + src/pages/Shelving/Card/ShelvingFilter.vue | 120 +++++ src/pages/Shelving/Card/ShelvingForm.vue | 126 ++++++ src/pages/Shelving/Card/ShelvingLog.vue | 6 + src/pages/Shelving/Card/ShelvingSearchbar.vue | 20 + src/pages/Shelving/Card/ShelvingSummary.vue | 110 +++++ .../Shelving/Card/ShelvingSummaryDialog.vue | 29 ++ src/pages/Shelving/ShelvingList.vue | 138 ++++++ src/pages/Shelving/ShelvingMain.vue | 17 + src/pages/Supplier/Card/SupplierCard.vue | 63 +++ .../Supplier/Card/SupplierDescriptor.vue | 94 ++++ .../Supplier/Card/SupplierDescriptorProxy.vue | 16 + src/pages/Supplier/Card/SupplierSummary.vue | 188 ++++++++ .../Supplier/Card/SupplierSummaryDialog.vue | 29 ++ src/pages/Supplier/SupplierCreate.vue | 61 +++ src/pages/Supplier/SupplierList.vue | 111 +++++ src/pages/Supplier/SupplierMain.vue | 17 + src/pages/Ticket/Card/TicketSummary.vue | 8 +- src/pages/Ticket/TicketFilter.vue | 64 +-- src/pages/Ticket/TicketList.vue | 11 +- src/pages/Travel/Card/TravelCard.vue | 51 +++ src/pages/Travel/Card/TravelDescriptor.vue | 80 ++++ .../Travel/Card/TravelDescriptorProxy.vue | 16 + src/pages/Travel/Card/TravelSummary.vue | 323 ++++++++++++++ src/pages/Travel/Card/TravelSummaryDialog.vue | 29 ++ src/pages/Travel/ExtraCommunity.vue | 419 ++++++++++++++++++ src/pages/Travel/ExtraCommunityFilter.vue | 263 +++++++++++ src/pages/Travel/TravelCreate.vue | 179 ++++++++ src/pages/Travel/TravelFilter.vue | 311 +++++++++++++ src/pages/Travel/TravelList.vue | 147 ++++++ src/pages/Travel/TravelMain.vue | 17 + src/pages/Wagon/Type/WagonTypeCreate.vue | 45 +- src/pages/Wagon/Type/WagonTypeList.vue | 61 +-- src/pages/Wagon/WagonCreate.vue | 35 +- src/pages/Wagon/WagonList.vue | 99 ++--- src/pages/Worker/WorkerList.vue | 26 +- src/router/modules/Supplier.js | 61 +++ src/router/modules/index.js | 17 +- src/router/modules/invoiceOut.js | 38 +- src/router/modules/shelving.js | 80 ++++ src/router/modules/travel.js | 69 +++ src/router/routes.js | 10 +- src/services/invoiceOut.service.js | 49 ++ src/services/travel.service.js | 23 + src/stores/invoiceOutGlobal.js | 264 +++++++++++ src/stores/useNavigationStore.js | 5 +- 79 files changed, 5656 insertions(+), 751 deletions(-) create mode 100644 src/components/common/VnInputDate.vue create mode 100644 src/composables/useNotify.js create mode 100644 src/pages/InvoiceOut/Card/InvoiceOutDescriptorMenu.vue create mode 100644 src/pages/InvoiceOut/InvoiceOutGlobal.vue create mode 100644 src/pages/InvoiceOut/InvoiceOutGlobalForm.vue create mode 100644 src/pages/InvoiceOut/InvoiceOutNegativeBases.vue create mode 100644 src/pages/Shelving/Card/ShelvingCard.vue create mode 100644 src/pages/Shelving/Card/ShelvingDescriptor.vue create mode 100644 src/pages/Shelving/Card/ShelvingDescriptorMenu.vue create mode 100644 src/pages/Shelving/Card/ShelvingDescriptorProxy.vue create mode 100644 src/pages/Shelving/Card/ShelvingFilter.vue create mode 100644 src/pages/Shelving/Card/ShelvingForm.vue create mode 100644 src/pages/Shelving/Card/ShelvingLog.vue create mode 100644 src/pages/Shelving/Card/ShelvingSearchbar.vue create mode 100644 src/pages/Shelving/Card/ShelvingSummary.vue create mode 100644 src/pages/Shelving/Card/ShelvingSummaryDialog.vue create mode 100644 src/pages/Shelving/ShelvingList.vue create mode 100644 src/pages/Shelving/ShelvingMain.vue create mode 100644 src/pages/Supplier/Card/SupplierCard.vue create mode 100644 src/pages/Supplier/Card/SupplierDescriptor.vue create mode 100644 src/pages/Supplier/Card/SupplierDescriptorProxy.vue create mode 100644 src/pages/Supplier/Card/SupplierSummary.vue create mode 100644 src/pages/Supplier/Card/SupplierSummaryDialog.vue create mode 100644 src/pages/Supplier/SupplierCreate.vue create mode 100644 src/pages/Supplier/SupplierList.vue create mode 100644 src/pages/Supplier/SupplierMain.vue create mode 100644 src/pages/Travel/Card/TravelCard.vue create mode 100644 src/pages/Travel/Card/TravelDescriptor.vue create mode 100644 src/pages/Travel/Card/TravelDescriptorProxy.vue create mode 100644 src/pages/Travel/Card/TravelSummary.vue create mode 100644 src/pages/Travel/Card/TravelSummaryDialog.vue create mode 100644 src/pages/Travel/ExtraCommunity.vue create mode 100644 src/pages/Travel/ExtraCommunityFilter.vue create mode 100644 src/pages/Travel/TravelCreate.vue create mode 100644 src/pages/Travel/TravelFilter.vue create mode 100644 src/pages/Travel/TravelList.vue create mode 100644 src/pages/Travel/TravelMain.vue create mode 100644 src/router/modules/Supplier.js create mode 100644 src/router/modules/shelving.js create mode 100644 src/router/modules/travel.js create mode 100644 src/services/invoiceOut.service.js create mode 100644 src/services/travel.service.js create mode 100644 src/stores/invoiceOutGlobal.js diff --git a/package-lock.json b/package-lock.json index 2e96d2ccf..9db93eff3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,14 +1,14 @@ { "name": "salix-front", - "version": "23.36.01", + "version": "23.52.01", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "salix-front", - "version": "0.0.1", + "version": "23.52.01", "dependencies": { - "@quasar/cli": "^2.2.1", + "@quasar/cli": "^2.3.0", "@quasar/extras": "^1.16.4", "axios": "^1.4.0", "chromium": "^3.0.3", @@ -946,9 +946,9 @@ } }, "node_modules/@quasar/cli": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/@quasar/cli/-/cli-2.2.1.tgz", - "integrity": "sha512-PMwJ76IeeNRRBw+08hUMjhqGC6JKJ/t1zIb+IOiyR5D4rkBR26Ha/Z46OD3KfwUprq4Q8s4ieB1+d3VY8FhPKg==", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/@quasar/cli/-/cli-2.3.0.tgz", + "integrity": "sha512-DNFDemicj3jXe5+Ib+5w9Bwj1U3yoHQkqn0bU/qysIl/p0MmGA1yqOfUF0V4fw/5or1dfCvStIA/oZxUcC+2pQ==", "dependencies": { "@quasar/ssl-certificate": "^1.0.0", "ci-info": "^3.8.0", diff --git a/src/boot/vnDate.js b/src/boot/vnDate.js index c78886b57..33d5ac27f 100644 --- a/src/boot/vnDate.js +++ b/src/boot/vnDate.js @@ -15,4 +15,14 @@ export default boot(() => { Date.vnNow = () => { return new Date(Date.vnUTC()).getTime(); }; + + Date.vnFirstDayOfMonth = () => { + const date = new Date(Date.vnUTC()); + return new Date(date.getFullYear(), date.getMonth(), 1); + }; + + Date.vnLastDayOfMonth = () => { + const date = new Date(Date.vnUTC()); + return new Date(date.getFullYear(), date.getMonth() + 1, 0); + }; }); diff --git a/src/components/FormModel.vue b/src/components/FormModel.vue index e8a9e4c17..453b3ffe1 100644 --- a/src/components/FormModel.vue +++ b/src/components/FormModel.vue @@ -6,6 +6,7 @@ import { useQuasar } from 'quasar'; import { useState } from 'src/composables/useState'; import { useStateStore } from 'stores/useStateStore'; import { useValidator } from 'src/composables/useValidator'; +import useNotify from 'src/composables/useNotify.js'; import SkeletonForm from 'components/ui/SkeletonForm.vue'; const quasar = useQuasar(); @@ -13,6 +14,7 @@ const state = useState(); const stateStore = useStateStore(); const { t } = useI18n(); const { validate } = useValidator(); +const { notify } = useNotify(); const $props = defineProps({ url: { @@ -31,10 +33,28 @@ const $props = defineProps({ type: String, default: null, }, + urlCreate: { + type: String, + default: null, + }, defaultActions: { type: Boolean, default: true, }, + autoLoad: { + type: Boolean, + default: false, + }, + formInitialData: { + type: Object, + default: () => {}, + }, + observeFormChanges: { + type: Boolean, + default: true, + description: + 'Esto se usa principalmente para permitir guardar sin hacer cambios (Útil para la feature de clonar ya que en este caso queremos poder guardar de primeras)', + }, }); const emit = defineEmits(['onFetch']); @@ -43,44 +63,73 @@ defineExpose({ save, }); -onMounted(async () => await fetch()); +onMounted(async () => { + // Podemos enviarle al form la estructura de data inicial sin necesidad de fetchearla + if ($props.formInitialData && !$props.autoLoad) { + state.set($props.model, $props.formInitialData); + } else { + await fetch(); + } + + // Disparamos el watcher del form después de que se haya cargado la data inicial, si así se desea + if ($props.observeFormChanges) { + startFormWatcher(); + } +}); onUnmounted(() => { state.unset($props.model); }); const isLoading = ref(false); -const hasChanges = ref(false); -const originalData = ref(); +// Si elegimos observar los cambios del form significa que inicialmente las actions estaran deshabilitadas +const hasChanges = ref(!$props.observeFormChanges); +const originalData = ref({...$props.formInitialData}); const formData = computed(() => state.get($props.model)); const formUrl = computed(() => $props.url); +const startFormWatcher = () => { + watch( + () => formData.value, + (val) => { + if (val) hasChanges.value = true; + }, + { deep: true } + ); +}; + function tMobile(...args) { if (!quasar.platform.is.mobile) return t(...args); } async function fetch() { const { data } = await axios.get($props.url, { - params: { filter: $props.filter }, + params: { filter: JSON.stringify($props.filter) }, }); state.set($props.model, data); originalData.value = data && JSON.parse(JSON.stringify(data)); - watch(formData.value, () => (hasChanges.value = true)); - emit('onFetch', state.get($props.model)); } async function save() { if (!hasChanges.value) { - return quasar.notify({ - type: 'negative', - message: t('globals.noChanges'), - }); + notify('globals.noChanges', 'negative'); + return; } isLoading.value = true; - await axios.patch($props.urlUpdate || $props.url, formData.value); + + try { + if ($props.urlCreate) { + await axios.post($props.urlCreate, formData.value); + notify('globals.dataCreated', 'positive'); + } else { + await axios.patch($props.urlUpdate || $props.url, formData.value); + } + } catch (err) { + notify('errors.create', 'negative'); + } originalData.value = JSON.parse(JSON.stringify(formData.value)); hasChanges.value = false; @@ -91,11 +140,12 @@ function reset() { state.set($props.model, originalData.value); originalData.value = JSON.parse(JSON.stringify(originalData.value)); - watch(formData.value, () => (hasChanges.value = true)); - emit('onFetch', state.get($props.model)); - hasChanges.value = false; + if ($props.observeFormChanges) { + hasChanges.value = false; + } } + // eslint-disable-next-line vue/no-dupe-keys function filter(value, update, filterOptions) { update( @@ -118,7 +168,7 @@ watch(formUrl, async () => { });