From e8b1d0fe7e50a3965b1cdc14d44d27e232532eef Mon Sep 17 00:00:00 2001 From: wbuezas Date: Sat, 25 Nov 2023 19:02:26 -0300 Subject: [PATCH 1/4] travel WIP --- src/composables/inputSelectFilterFn.js | 26 ++ src/i18n/en/index.js | 32 +++ src/i18n/es/index.js | 32 +++ .../InvoiceOut/InvoiceOutNegativeBases.vue | 2 +- src/pages/Supplier/Card/SupplierSummary.vue | 4 +- src/pages/Supplier/SupplierCreate.vue | 11 +- src/pages/Travel/Card/TravelCard.vue | 66 +++++ src/pages/Travel/Card/TravelSummary.vue | 264 ++++++++++++++++++ src/pages/Travel/Card/TravelSummaryDialog.vue | 29 ++ src/pages/Travel/TravelCreate.vue | 157 +++++++++++ src/pages/Travel/TravelList.vue | 132 +++++++++ src/pages/Travel/TravelMain.vue | 17 ++ src/router/modules/index.js | 13 +- src/router/modules/invoiceOut.js | 2 +- src/router/modules/travel.js | 59 ++++ src/router/routes.js | 2 + ...ceOut.service.js => invoiceOut.service.js} | 0 ...pliers.service.js => suppliers.service.js} | 0 src/services/travel.service.js | 32 +++ src/stores/invoiceOutGlobal.js | 2 +- src/stores/travel.js | 36 +++ src/stores/useNavigationStore.js | 1 + 22 files changed, 911 insertions(+), 8 deletions(-) create mode 100644 src/composables/inputSelectFilterFn.js create mode 100644 src/pages/Travel/Card/TravelCard.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/TravelCreate.vue create mode 100644 src/pages/Travel/TravelList.vue create mode 100644 src/pages/Travel/TravelMain.vue create mode 100644 src/router/modules/travel.js rename src/services/{InvoiceOut.service.js => invoiceOut.service.js} (100%) rename src/services/{Suppliers.service.js => suppliers.service.js} (100%) create mode 100644 src/services/travel.service.js create mode 100644 src/stores/travel.js diff --git a/src/composables/inputSelectFilterFn.js b/src/composables/inputSelectFilterFn.js new file mode 100644 index 000000000..f038e7a7d --- /dev/null +++ b/src/composables/inputSelectFilterFn.js @@ -0,0 +1,26 @@ +/** + * Filtra las opciones basadas en un valor de entrada y actualiza las opciones filtradas. + * + * @param {string} val - El valor de entrada para filtrar las opciones. (la emite el evento @filter del componente QSelect) + * @param {Function} update - Función de actualización que debe ser llamada para actualizar las opciones filtradas.(la provee el evento @filter del componente QSelect) + * @param {Function} abort - Función que puede ser llamada para abortar o cancelar el filtrado actual. (la provee el evento @filter del componente QSelect) + * @param {Object} optionsToFilter - Objeto que contiene las opciones originales y filtradas. + */ + +export function inputSelectFilter(val, update, abort, optionsToFilter) { + if (val === '') { + update(() => { + optionsToFilter.filtered = JSON.parse( + JSON.stringify(optionsToFilter.original) + ); + }); + return; + } + + update(() => { + const searchQuery = val.toLowerCase(); + optionsToFilter.filtered = optionsToFilter.original.filter((option) => + option.label.toLowerCase().includes(searchQuery) + ); + }); +} diff --git a/src/i18n/en/index.js b/src/i18n/en/index.js index b4761a77f..632ecd4ec 100644 --- a/src/i18n/en/index.js +++ b/src/i18n/en/index.js @@ -581,6 +581,38 @@ export default { supplierName: 'Supplier name', }, }, + travel: { + shared: { + reference: 'Reference', + agency: 'Agency', + wareHouseOut: 'Warehouse Out', + wareHouseIn: 'Warehouse In', + landed: 'Landed', + shipped: 'Shipped', + totalEntries: 'Total entries', + }, + pageTitles: { + travel: 'Travels', + list: 'List', + create: 'Create', + summary: 'Summary', + }, + list: { + clone: 'Clone', + addEntry: 'Add entry', + preview: 'Preview', + }, + summary: { + confirmed: 'Confirmed', + entryId: 'Entry Id', + supplier: 'Supplier', + freight: 'Freight', + package: 'Package', + delivered: 'Delivered', + received: 'Received', + entries: 'Entries', + }, + }, components: { topbar: {}, userPanel: { diff --git a/src/i18n/es/index.js b/src/i18n/es/index.js index 85fb6b6e6..da9bbd21b 100644 --- a/src/i18n/es/index.js +++ b/src/i18n/es/index.js @@ -583,6 +583,38 @@ export default { supplierName: 'Nombre del proveedor', }, }, + travel: { + shared: { + reference: 'Referencia', + agency: 'Agencia', + wareHouseOut: 'Alm. salida', + wareHouseIn: 'Alm. entrada', + landed: 'F. entrega', + shipped: 'F. envío', + totalEntries: 'Ent. totales', + }, + pageTitles: { + travel: 'Envíos', + list: 'Listado', + create: 'Crear', + summary: 'Resumen', + }, + list: { + clone: 'Clonar', + addEntry: 'Añadir entrada', + preview: 'Vista previa', + }, + summary: { + confirmed: 'Confirmado', + entryId: 'Id entrada', + supplier: 'Proveedor', + freight: 'Porte', + package: 'Embalaje', + delivered: 'Enviada', + received: 'Recibida', + entries: 'Entradas', + }, + }, components: { topbar: {}, userPanel: { diff --git a/src/pages/InvoiceOut/InvoiceOutNegativeBases.vue b/src/pages/InvoiceOut/InvoiceOutNegativeBases.vue index e4b8f4f89..b148d98bb 100644 --- a/src/pages/InvoiceOut/InvoiceOutNegativeBases.vue +++ b/src/pages/InvoiceOut/InvoiceOutNegativeBases.vue @@ -3,7 +3,7 @@ import { onMounted, computed, ref } from 'vue'; import { useI18n } from 'vue-i18n'; /* import { QBadge, QBtn } from 'quasar'; import CustomerDescriptor from 'src/pages/Customer/Card/CustomerDescriptor.vue'; */ -import invoiceOutService from 'src/services/InvoiceOut.service'; +import invoiceOutService from 'src/services/invoiceOut.service'; import { toCurrency } from 'src/filters'; import { QBadge, QCheckbox, exportFile } from 'quasar'; diff --git a/src/pages/Supplier/Card/SupplierSummary.vue b/src/pages/Supplier/Card/SupplierSummary.vue index 120ae8713..c04c76234 100644 --- a/src/pages/Supplier/Card/SupplierSummary.vue +++ b/src/pages/Supplier/Card/SupplierSummary.vue @@ -51,7 +51,9 @@ const isAdministrative = computed(() => { @on-fetch="(data) => setData(data)" > - + +import { useI18n } from 'vue-i18n'; +import { useStateStore } from 'stores/useStateStore'; +import VnSearchbar from 'src/components/ui/VnSearchbar.vue'; + +const stateStore = useStateStore(); +const { t } = useI18n(); + + + + + + + + + diff --git a/src/pages/Travel/Card/TravelSummary.vue b/src/pages/Travel/Card/TravelSummary.vue new file mode 100644 index 000000000..c476b6bc0 --- /dev/null +++ b/src/pages/Travel/Card/TravelSummary.vue @@ -0,0 +1,264 @@ + + + + diff --git a/src/pages/Travel/Card/TravelSummaryDialog.vue b/src/pages/Travel/Card/TravelSummaryDialog.vue new file mode 100644 index 000000000..8351d6e5b --- /dev/null +++ b/src/pages/Travel/Card/TravelSummaryDialog.vue @@ -0,0 +1,29 @@ + + + + + diff --git a/src/pages/Travel/TravelCreate.vue b/src/pages/Travel/TravelCreate.vue new file mode 100644 index 000000000..fa8520f95 --- /dev/null +++ b/src/pages/Travel/TravelCreate.vue @@ -0,0 +1,157 @@ + + + + + + + + + diff --git a/src/pages/Travel/TravelList.vue b/src/pages/Travel/TravelList.vue new file mode 100644 index 000000000..716c7632f --- /dev/null +++ b/src/pages/Travel/TravelList.vue @@ -0,0 +1,132 @@ + + + + + + + + { + "en": { + Search suppliers: Search suppliers + }, + "es": { + Search suppliers: Buscar proveedores + } + } + diff --git a/src/pages/Travel/TravelMain.vue b/src/pages/Travel/TravelMain.vue new file mode 100644 index 000000000..66ce78f23 --- /dev/null +++ b/src/pages/Travel/TravelMain.vue @@ -0,0 +1,17 @@ + + + diff --git a/src/router/modules/index.js b/src/router/modules/index.js index 2456e57aa..d6141fb81 100644 --- a/src/router/modules/index.js +++ b/src/router/modules/index.js @@ -6,5 +6,16 @@ import Worker from './worker'; import Wagon from './wagon'; import Route from './route'; import Supplier from './Supplier'; +import Travel from './travel'; -export default [Customer, Ticket, Claim, InvoiceOut, Worker, Wagon, Route, Supplier]; +export default [ + Customer, + Ticket, + Claim, + InvoiceOut, + Worker, + Wagon, + Route, + Supplier, + Travel, +]; diff --git a/src/router/modules/invoiceOut.js b/src/router/modules/invoiceOut.js index ec30e4fc0..084cf6ac3 100644 --- a/src/router/modules/invoiceOut.js +++ b/src/router/modules/invoiceOut.js @@ -34,7 +34,7 @@ export default { name: 'InvoiceOutGlobal', meta: { title: 'globalInvoicing', - icon: 'view_list', + icon: 'contact_support', }, component: () => import('src/pages/InvoiceOut/InvoiceOutGlobal.vue'), }, diff --git a/src/router/modules/travel.js b/src/router/modules/travel.js new file mode 100644 index 000000000..9ba10380e --- /dev/null +++ b/src/router/modules/travel.js @@ -0,0 +1,59 @@ +import { RouterView } from 'vue-router'; + +export default { + path: '/travel', + name: 'Travel', + meta: { + title: 'travel', + icon: 'vn:package', + }, + component: RouterView, + redirect: { name: 'TravelMain' }, + menus: { + main: ['TravelList'], + card: [], + }, + children: [ + { + path: '', + name: 'TravelMain', + component: () => import('src/pages/Travel/TravelMain.vue'), + redirect: { name: 'TravelList' }, + children: [ + { + path: 'list', + name: 'TravelList', + meta: { + title: 'list', + icon: 'view_list', + }, + component: () => import('src/pages/Travel/TravelList.vue'), + }, + { + path: 'create', + name: 'TravelCreate', + meta: { + title: 'create', + }, + component: () => import('src/pages/Travel/TravelCreate.vue'), + }, + ], + }, + { + name: 'TravelCard', + path: ':id', + component: () => import('src/pages/Travel/Card/TravelCard.vue'), + redirect: { name: 'TravelSummary' }, + children: [ + { + name: 'TravelSummary', + path: 'summary', + meta: { + title: 'summary', + }, + component: () => import('src/pages/Travel/Card/TravelSummary.vue'), + }, + ], + }, + ], +}; diff --git a/src/router/routes.js b/src/router/routes.js index faf340e0c..dc4b51ec2 100644 --- a/src/router/routes.js +++ b/src/router/routes.js @@ -6,6 +6,7 @@ import invoiceOut from './modules/invoiceOut'; import wagon from './modules/wagon'; import supplier from './modules/Supplier'; import route from './modules/route'; +import travel from './modules/travel'; const routes = [ { @@ -53,6 +54,7 @@ const routes = [ wagon, route, supplier, + travel, { path: '/:catchAll(.*)*', name: 'NotFound', diff --git a/src/services/InvoiceOut.service.js b/src/services/invoiceOut.service.js similarity index 100% rename from src/services/InvoiceOut.service.js rename to src/services/invoiceOut.service.js diff --git a/src/services/Suppliers.service.js b/src/services/suppliers.service.js similarity index 100% rename from src/services/Suppliers.service.js rename to src/services/suppliers.service.js diff --git a/src/services/travel.service.js b/src/services/travel.service.js new file mode 100644 index 000000000..606e2eb48 --- /dev/null +++ b/src/services/travel.service.js @@ -0,0 +1,32 @@ +import axios from 'axios'; + +const travelService = { + getTravels: async (filter = {}) => { + try { + return await axios.get('Travels/filter', filter); + } catch (err) { + console.error(`Error fetching travels`, err); + return err.response; + } + }, + + createTravel: async (params) => { + try { + return await axios.patch('Travels', params); + } catch (err) { + console.error(`Error creating travel`, err); + return err.response; + } + }, + + getTravelEntries: async (param) => { + try { + return await axios.get(`Travels/${param}/getEntries`); + } catch (err) { + console.error(`Error fetching travel entries`, err); + return err.response; + } + }, +}; + +export default travelService; diff --git a/src/stores/invoiceOutGlobal.js b/src/stores/invoiceOutGlobal.js index 7223f7655..128d5a397 100644 --- a/src/stores/invoiceOutGlobal.js +++ b/src/stores/invoiceOutGlobal.js @@ -1,6 +1,6 @@ import { defineStore } from 'pinia'; import { useUserConfig } from 'src/composables/useUserConfig'; -import invoiceOutService from 'src/services/InvoiceOut.service.js'; +import invoiceOutService from 'src/services/invoiceOut.service'; import useNotify from 'src/composables/useNotify.js'; const { notify } = useNotify(); diff --git a/src/stores/travel.js b/src/stores/travel.js new file mode 100644 index 000000000..799c773e8 --- /dev/null +++ b/src/stores/travel.js @@ -0,0 +1,36 @@ +import { defineStore } from 'pinia'; +import travelService from 'src/services/travel.service'; + +export const useTravelStore = defineStore({ + id: 'travel', + + state: () => ({ + initialDataLoading: true, + travels: [], + }), + actions: { + async init() { + await this.fetchAllData(); + }, + + async fetchAllData() { + const { data } = await travelService.getTravels(); + this.travels = data || []; + }, + + async createTravel(travelData) { + const params = { + ref: travelData.ref, + agencyModeFk: travelData.agencyModeFk.value, + warehouseOutFk: travelData.warehouseOutFk.value, + warehouseInFk: travelData.warehouseInFk.value, + landed: new Date(travelData.landed), + shipped: new Date(travelData.shipped), + }; + + return await travelService.createTravel(params); + }, + }, + + getters: {}, +}); diff --git a/src/stores/useNavigationStore.js b/src/stores/useNavigationStore.js index ea4e175ab..9933924e0 100644 --- a/src/stores/useNavigationStore.js +++ b/src/stores/useNavigationStore.js @@ -15,6 +15,7 @@ export const useNavigationStore = defineStore('navigationStore', () => { 'wagon', 'route', 'supplier', + 'travel', ]; const pinnedModules = ref([]); const role = useRole(); From e291a69846448dc39fa3cfbd70f1bd4fa75529c0 Mon Sep 17 00:00:00 2001 From: wbuezas Date: Sat, 25 Nov 2023 19:42:24 -0300 Subject: [PATCH 2/4] Add travel clone feature --- src/pages/Travel/TravelCreate.vue | 30 ++++++++++++++++++++------- src/pages/Travel/TravelList.vue | 34 ++++++++++++++++++------------- 2 files changed, 43 insertions(+), 21 deletions(-) diff --git a/src/pages/Travel/TravelCreate.vue b/src/pages/Travel/TravelCreate.vue index fa8520f95..b0ea45917 100644 --- a/src/pages/Travel/TravelCreate.vue +++ b/src/pages/Travel/TravelCreate.vue @@ -3,10 +3,12 @@ import { useI18n } from 'vue-i18n'; import { reactive, computed } from 'vue'; import FetchData from 'components/FetchData.vue'; import { useTravelStore } from 'src/stores/travel'; -import { useRouter } from 'vue-router'; +import { useRouter, useRoute } from 'vue-router'; import { inputSelectFilter } from 'src/composables/inputSelectFilterFn.js'; +import { onBeforeMount } from 'vue'; const { t } = useI18n(); +const route = useRoute(); const router = useRouter(); const travelStore = useTravelStore(); @@ -29,6 +31,15 @@ const warehousesOptions = reactive({ filtered: [], }); +onBeforeMount(() => { + if (route.query.travelData) { + const travelData = JSON.parse(route.query.travelData); + for (let key in travelData) { + newTravelData[key] = travelData[key]; + } + } +}); + const createTravel = async () => { const response = await travelStore.createTravel(newTravelData); if (response.status === 200) router.push({ path: `/travel/${response.data.id}` }); @@ -52,6 +63,10 @@ const canSubmit = computed(() => { } return true; }); + +const redirectToTravelList = () => { + router.push({ name: 'TravelList' }); +};