From 3d98bf578eb7e6a526a2bbff7aa8a80f41a470aa Mon Sep 17 00:00:00 2001 From: Kevin Martinez Date: Fri, 12 Jan 2024 10:03:18 -0400 Subject: [PATCH 1/6] Create route list --- src/components/common/VnInputTime.vue | 108 +++++++ src/filters/index.js | 2 + src/filters/isValidDate.js | 3 + src/filters/toHour.js | 16 + src/i18n/en/index.js | 1 + src/i18n/es/index.js | 1 + src/pages/Route/RouteList.vue | 407 ++++++++++++++++++++++++++ src/router/modules/route.js | 11 +- 8 files changed, 548 insertions(+), 1 deletion(-) create mode 100644 src/components/common/VnInputTime.vue create mode 100644 src/filters/isValidDate.js create mode 100644 src/filters/toHour.js create mode 100644 src/pages/Route/RouteList.vue diff --git a/src/components/common/VnInputTime.vue b/src/components/common/VnInputTime.vue new file mode 100644 index 000000000..b705d91f6 --- /dev/null +++ b/src/components/common/VnInputTime.vue @@ -0,0 +1,108 @@ + + + + + + + +es: + Cancel: Cancelar + diff --git a/src/filters/index.js b/src/filters/index.js index f0120e663..478cb0ac8 100644 --- a/src/filters/index.js +++ b/src/filters/index.js @@ -8,11 +8,13 @@ import toPercentage from './toPercentage'; import toLowerCamel from './toLowerCamel'; import dashIfEmpty from './dashIfEmpty'; import dateRange from './dateRange'; +import toHour from './toHour'; export { toLowerCase, toLowerCamel, toDate, + toHour, toDateString, toDateHour, toRelativeDate, diff --git a/src/filters/isValidDate.js b/src/filters/isValidDate.js new file mode 100644 index 000000000..8365564b8 --- /dev/null +++ b/src/filters/isValidDate.js @@ -0,0 +1,3 @@ +export default function isValidDate(date) { + return !isNaN(new Date(date).getTime()); +} diff --git a/src/filters/toHour.js b/src/filters/toHour.js new file mode 100644 index 000000000..f24f81949 --- /dev/null +++ b/src/filters/toHour.js @@ -0,0 +1,16 @@ +import isValidDate from 'filters/isValidDate'; + +export default function toHour(date) { + if (!isValidDate(date)) { + return '--:--'; + } + const dateHour = new Date(date); + let hours = dateHour.getUTCHours(); + hours = hours % 12; + hours = hours ? hours : 12; + + let minutes = dateHour.getUTCMinutes(); + minutes = minutes < 10 ? minutes.toString().padStart(2, '0') : minutes; + + return `${hours}:${minutes} ${dateHour.getUTCHours() >= 12 ? 'PM' : 'AM'}`; +} diff --git a/src/i18n/en/index.js b/src/i18n/en/index.js index bd59edad1..72ed1cba8 100644 --- a/src/i18n/en/index.js +++ b/src/i18n/en/index.js @@ -807,6 +807,7 @@ export default { pageTitles: { routes: 'Routes', cmrsList: 'External CMRs list', + RouteList: 'List' }, cmr: { list: { diff --git a/src/i18n/es/index.js b/src/i18n/es/index.js index 94f508429..f5a7483f4 100644 --- a/src/i18n/es/index.js +++ b/src/i18n/es/index.js @@ -806,6 +806,7 @@ export default { pageTitles: { routes: 'Rutas', cmrsList: 'Listado de CMRs externos', + RouteList: 'Listado' }, cmr: { list: { diff --git a/src/pages/Route/RouteList.vue b/src/pages/Route/RouteList.vue new file mode 100644 index 000000000..408119751 --- /dev/null +++ b/src/pages/Route/RouteList.vue @@ -0,0 +1,407 @@ + + + + + + +es: + ID: ID + Worker: Trabajador + Agency: Agencia + Vehicle: Vehículo + Date: Fecha + Description: Descripción + Hour started: Hora inicio + Hour finished: Hora fin + diff --git a/src/router/modules/route.js b/src/router/modules/route.js index acda898de..70c92f84b 100644 --- a/src/router/modules/route.js +++ b/src/router/modules/route.js @@ -10,7 +10,7 @@ export default { component: RouterView, redirect: { name: 'RouteMain' }, menus: { - main: ['CmrList'], + main: ['RouteList', 'CmrList'], card: [], }, children: [ @@ -29,6 +29,15 @@ export default { }, component: () => import('src/pages/Route/Cmr/CmrList.vue'), }, + { + path: 'list', + name: 'RouteList', + meta: { + title: 'RouteList', + icon: 'vn:delivery', + }, + component: () => import('src/pages/Route/RouteList.vue'), + }, ], }, ], From e1ac98cf3e54d698da695d9d6d9dc33546510115 Mon Sep 17 00:00:00 2001 From: Kevin Martinez Date: Wed, 17 Jan 2024 07:34:43 -0400 Subject: [PATCH 2/6] Add route list filter --- src/pages/Route/Card/RouteFilter.vue | 234 ++++++++++++++++++++++++ src/pages/Route/Card/RouteSearchbar.vue | 20 ++ src/pages/Route/RouteList.vue | 114 ++++++------ 3 files changed, 308 insertions(+), 60 deletions(-) create mode 100644 src/pages/Route/Card/RouteFilter.vue create mode 100644 src/pages/Route/Card/RouteSearchbar.vue diff --git a/src/pages/Route/Card/RouteFilter.vue b/src/pages/Route/Card/RouteFilter.vue new file mode 100644 index 000000000..45580d913 --- /dev/null +++ b/src/pages/Route/Card/RouteFilter.vue @@ -0,0 +1,234 @@ + + + + + +en: + params: + warehouseFk: Warehouse + description: Description + m3: m³ + vehicleFk: Vehicle + agencyModeFk: Agency + workerFk: Worker + from: From + to: To +es: + params: + warehouseFk: Almacén + description: Descripción + m3: m³ + vehicleFk: Vehículo + agencyModeFk: Agencia + workerFk: Trabajador + from: Desde + to: Hasta + Warehouse: Almacén + Description: Descripción + Vehicle: Vehículo + Agency: Agencia + Worker: Trabajador + From: Desde + To: Hasta + diff --git a/src/pages/Route/Card/RouteSearchbar.vue b/src/pages/Route/Card/RouteSearchbar.vue new file mode 100644 index 000000000..9ee4a602f --- /dev/null +++ b/src/pages/Route/Card/RouteSearchbar.vue @@ -0,0 +1,20 @@ + + + + + + +es: + Search route: Buscar rutas + You can search by route reference: Puedes buscar por referencia de la ruta + diff --git a/src/pages/Route/RouteList.vue b/src/pages/Route/RouteList.vue index 408119751..ddf3e1a12 100644 --- a/src/pages/Route/RouteList.vue +++ b/src/pages/Route/RouteList.vue @@ -3,14 +3,16 @@ import VnPaginate from 'components/ui/VnPaginate.vue'; import { useStateStore } from 'stores/useStateStore'; import { useI18n } from 'vue-i18n'; import { computed, onMounted, onUnmounted, ref } from 'vue'; -import {dashIfEmpty, toDate, toHour} from 'src/filters'; +import { dashIfEmpty, toDate, toHour } from 'src/filters'; import VnSelectFilter from 'components/common/VnSelectFilter.vue'; import FetchData from 'components/FetchData.vue'; import { useValidator } from 'composables/useValidator'; -import VnInputDate from "components/common/VnInputDate.vue"; -import VnInput from "components/common/VnInput.vue"; -import VnInputTime from "components/common/VnInputTime.vue"; -import axios from "axios"; +import VnInputDate from 'components/common/VnInputDate.vue'; +import VnInput from 'components/common/VnInput.vue'; +import VnInputTime from 'components/common/VnInputTime.vue'; +import axios from 'axios'; +import RouteSearchbar from 'pages/Route/Card/RouteSearchbar.vue'; +import RouteFilter from 'pages/Route/Card/RouteFilter.vue'; const stateStore = useStateStore(); // const router = useRouter(); @@ -98,7 +100,7 @@ const columns = computed(() => [ }, ]); -const refreshKey = ref(0) +const refreshKey = ref(0); const workers = ref([]); const agencyList = ref([]); const vehicleList = ref([]); @@ -108,76 +110,63 @@ const updateRoute = async (route) => { } catch (err) { return err; } -} +}; const updateVehicle = (row, vehicle) => { - row.vehicleFk = vehicle.id - row.vehiclePlateNumber = vehicle.numberPlate - updateRoute(row) -} + row.vehicleFk = vehicle.id; + row.vehiclePlateNumber = vehicle.numberPlate; + updateRoute(row); +}; const updateAgency = (row, agency) => { - row.agencyModeFk = agency.id - row.agencyName = agency.name - updateRoute(row) -} + row.agencyModeFk = agency.id; + row.agencyName = agency.name; + updateRoute(row); +}; const updateWorker = (row, worker) => { - row.workerFk = worker.id - row.workerUserName = worker.name - updateRoute(row) -} + row.workerFk = worker.id; + row.workerUserName = worker.name; + updateRoute(row); +}; @@ -389,6 +389,8 @@ const updateWorker = (row, worker) => { } +en: + newRoute: New Route es: ID: ID Worker: Trabajador @@ -398,4 +400,5 @@ es: Description: Descripción Hour started: Hora inicio Hour finished: Hora fin + newRoute: Nueva Ruta diff --git a/src/router/modules/route.js b/src/router/modules/route.js index 70c92f84b..f6553a4f1 100644 --- a/src/router/modules/route.js +++ b/src/router/modules/route.js @@ -38,6 +38,32 @@ export default { }, component: () => import('src/pages/Route/RouteList.vue'), }, + { + path: 'create', + name: 'RouteCreate', + meta: { + title: 'create', + }, + component: () => import('src/pages/Route/Card/RouteForm.vue'), + }, + ], + }, + { + name: 'RouteCard', + path: ':id', + component: () => import('src/pages/Route/Card/RouteCard.vue'), + // TODO: Add summary + redirect: { name: 'RouteBasicData' }, + children: [ + { + name: 'RouteBasicData', + path: 'basic-data', + meta: { + title: 'basicData', + icon: 'vn:settings', + }, + component: () => import('pages/Route/Card/RouteForm.vue'), + }, ], }, ], From ecea050b7779acd040b66a36e087e5dee3409cdf Mon Sep 17 00:00:00 2001 From: Kevin Martinez Date: Wed, 17 Jan 2024 10:24:09 -0400 Subject: [PATCH 4/6] Add route list actions --- src/pages/Route/RouteList.vue | 73 ++++++++++++++++++++++++++++++++++- 1 file changed, 71 insertions(+), 2 deletions(-) diff --git a/src/pages/Route/RouteList.vue b/src/pages/Route/RouteList.vue index 3dcc0af37..5dd82cc51 100644 --- a/src/pages/Route/RouteList.vue +++ b/src/pages/Route/RouteList.vue @@ -129,6 +129,28 @@ const updateWorker = (row, worker) => { row.workerUserName = worker.name; updateRoute(row); }; + +const confirmationDialog = ref(false); +const startingDate = ref(null); + +const cloneRoutes = () => { + axios.post('Routes/clone', { + created: startingDate.value, + ids: selectedRows.value.map((row) => row?.id), + }); + refreshKey.value++; + startingDate.value = null; +}; + +const markAsServed = () => { + selectedRows.value.forEach((row) => { + if (row?.id) { + axios.patch(`Routes/${row?.id}`, { isOk: true }); + } + }); + refreshKey.value++; + startingDate.value = null; +}; + + + +

{{ t('Select the starting date') }}

+
+ + + + + + + + + {{ t('Clone') }} + + +
+
@@ -165,7 +209,26 @@ const updateWorker = (row, worker) => { - + +
+ + {{ t('Clone Selected Routes') }} + + + + {{ t('Mark as served') }} + +
{ :rows="rows" flat row-key="id" - hide-pagination selection="multiple" + :rows-per-page-options="[0]" >