diff --git a/CHANGELOG.md b/CHANGELOG.md index e34523545..fd8a900b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- (Worker) => Se crea la sección Taquilla + ### Fixed - (General) => Se vuelven a mostrar los parámetros en la url al aplicar un filtro diff --git a/src/components/FormModel.vue b/src/components/FormModel.vue index b18433d4e..2c2acb61c 100644 --- a/src/components/FormModel.vue +++ b/src/components/FormModel.vue @@ -156,9 +156,12 @@ const startFormWatcher = () => { async function fetch() { try { - const { data } = await axios.get($props.url, { + let { data } = await axios.get($props.url, { params: { filter: JSON.stringify($props.filter) }, }); + + if (Array.isArray(data)) data = data[0] ?? {}; + state.set($props.model, data); originalData.value = data && JSON.parse(JSON.stringify(data)); diff --git a/src/components/common/VnCard.vue b/src/components/common/VnCard.vue index 6d0badffb..a062e4d80 100644 --- a/src/components/common/VnCard.vue +++ b/src/components/common/VnCard.vue @@ -1,5 +1,5 @@ async function remove(key) { userParams.value[key] = null; - await search(); + await arrayData.applyFilter({ params: userParams.value }); emit('remove', key); } diff --git a/src/i18n/locale/en.yml b/src/i18n/locale/en.yml index 4b76d602d..05241747b 100644 --- a/src/i18n/locale/en.yml +++ b/src/i18n/locale/en.yml @@ -827,6 +827,7 @@ worker: log: Log calendar: Calendar timeControl: Time control + locker: Locker list: name: Name email: Email diff --git a/src/i18n/locale/es.yml b/src/i18n/locale/es.yml index 512b253b9..ad7c8d4aa 100644 --- a/src/i18n/locale/es.yml +++ b/src/i18n/locale/es.yml @@ -825,6 +825,7 @@ worker: log: Historial calendar: Calendario timeControl: Control de horario + locker: Taquilla list: name: Nombre email: Email diff --git a/src/pages/Route/RouteAutonomous.vue b/src/pages/Route/RouteAutonomous.vue index 0ecf0a971..238dce070 100644 --- a/src/pages/Route/RouteAutonomous.vue +++ b/src/pages/Route/RouteAutonomous.vue @@ -280,7 +280,7 @@ function navigateToRouteSummary(event, row) { { { +import { ref, computed } from 'vue'; +import { useRoute } from 'vue-router'; +import { useI18n } from 'vue-i18n'; +import axios from 'axios'; +import { useRole } from 'src/composables/useRole'; +import FormModel from 'components/FormModel.vue'; +import VnSelect from 'src/components/common/VnSelect.vue'; +import { useArrayData } from 'src/composables/useArrayData'; +import FetchData from 'components/FetchData.vue'; + +const { hasAny } = useRole(); +const { t } = useI18n(); +const fetchData = ref(); +const originaLockerId = ref(); +const lockers = ref([]); +const { store } = useArrayData('Worker'); +const entityId = computed(() => useRoute().params.id); +const filter = computed(() => ({ + where: { + gender: store.data?.sex, + or: [{ workerFk: null }, { workerFk: entityId.value }], + }, +})); + +const save = async (data) => { + const lockerId = data.id ?? originaLockerId.value; + const workerFk = lockerId == originaLockerId.value ? null : entityId.value; + + await axios.patch(`Lockers/${lockerId}`, { workerFk }); +}; + +const init = async (data) => { + await fetchData.value.fetch(); + originaLockerId.value = data.id; +}; + + + (lockers = data)" + /> + + + + + + diff --git a/src/pages/Worker/locale/es.yml b/src/pages/Worker/locale/es.yml index 86dd9d0d9..a960dffe6 100644 --- a/src/pages/Worker/locale/es.yml +++ b/src/pages/Worker/locale/es.yml @@ -1,2 +1,3 @@ Search worker: Buscar trabajador You can search by worker id or name: Puedes buscar por id o nombre del trabajador +Locker: Taquilla diff --git a/src/pages/Zone/Card/ZoneCard.vue b/src/pages/Zone/Card/ZoneCard.vue index 948636c55..9d6895f36 100644 --- a/src/pages/Zone/Card/ZoneCard.vue +++ b/src/pages/Zone/Card/ZoneCard.vue @@ -1,6 +1,15 @@ - + diff --git a/src/pages/Zone/Card/ZoneDescriptor.vue b/src/pages/Zone/Card/ZoneDescriptor.vue index 93e951801..8f0aa9e07 100644 --- a/src/pages/Zone/Card/ZoneDescriptor.vue +++ b/src/pages/Zone/Card/ZoneDescriptor.vue @@ -6,6 +6,7 @@ import { useI18n } from 'vue-i18n'; import CardDescriptor from 'components/ui/CardDescriptor.vue'; import VnLv from 'src/components/ui/VnLv.vue'; import { toTimeFormat } from 'src/filters/date'; +import { toCurrency } from 'filters/index'; import useCardDescription from 'src/composables/useCardDescription'; @@ -73,24 +74,11 @@ const setData = (entity) => { --> {{ console.log('entity', entity) }} - - - - - + + + + + - - -es: - Summary: Detalles - The zone will be deleted: El envío será eliminado - Do you want to delete this zone?: ¿Quieres eliminar este envío? - All zones with current agency: Todos los envíos con la agencia actual - Agency: Agencia - Closing hour: Hora de cierre - zoneing days: Días de viaje - Price: Precio - Bonus: Bonificación - diff --git a/src/pages/Zone/Card/ZoneSummary.vue b/src/pages/Zone/Card/ZoneSummary.vue index 00df03cb0..b39d2aaab 100644 --- a/src/pages/Zone/Card/ZoneSummary.vue +++ b/src/pages/Zone/Card/ZoneSummary.vue @@ -2,14 +2,16 @@ import { ref, onMounted, computed } from 'vue'; import { useRoute } from 'vue-router'; import { useI18n } from 'vue-i18n'; -import { dashIfEmpty } from 'src/filters'; -import { getUrl } from 'src/composables/getUrl'; + import VnLv from 'src/components/ui/VnLv.vue'; -import VnLinkPhone from 'src/components/ui/VnLinkPhone.vue'; import CardSummary from 'components/ui/CardSummary.vue'; -import VnUserLink from 'src/components/ui/VnUserLink.vue'; import VnTitle from 'src/components/common/VnTitle.vue'; +import { getUrl } from 'src/composables/getUrl'; +import { toCurrency } from 'filters/index'; +import { toTimeFormat } from 'src/filters/date'; +import axios from 'axios'; + const route = useRoute(); const { t } = useI18n(); @@ -23,71 +25,84 @@ const $props = defineProps({ const entityId = computed(() => $props.id || route.params.id); const zoneUrl = ref(); -onMounted(async () => { - zoneUrl.value = (await getUrl('')) + `zone/${entityId.value}/`; +const filter = computed(() => { + const filter = { + include: { + relation: 'agencyMode', + fields: ['name'], + }, + where: { + id: route.params.id, + }, + }; + return filter; }); -const filter = computed(() => { - return { where: { id: entityId.value } }; +const columns = computed(() => [ + { + label: t('summary.name'), + name: 'name', + field: 'warehouse', + align: 'left', + format: (val) => val.name, + }, +]); +const warehouses = ref([]); + +const getWarehouses = async () => { + const params = { + filter: { + include: { + relation: 'warehouse', + fields: ['name'], + }, + }, + }; + + const { data } = await axios.get(`Zones/${entityId.value}/warehouses`, { params }); + warehouses.value = data; +}; + +onMounted(async () => { + zoneUrl.value = (await getUrl('')) + `zone/${entityId.value}/`; + await getWarehouses(); }); - {{ entity.id }} - {{ entity.firstName }} {{ entity.lastName }} + #{{ entity.id }} - {{ entity.name }} - - - - - - - - - - - - {{ t('zone.summary.phoneExtension') }} - - - - - - {{ t('zone.summary.entPhone') }} - - - - + + + + - - - - - - - {{ t('zone.summary.sipExtension') }} - - - + + + + + + + + diff --git a/src/pages/Zone/Delivery/ZoneDeliveryList.vue b/src/pages/Zone/Delivery/ZoneDeliveryList.vue index 695388a9b..ca87dbd84 100644 --- a/src/pages/Zone/Delivery/ZoneDeliveryList.vue +++ b/src/pages/Zone/Delivery/ZoneDeliveryList.vue @@ -63,7 +63,7 @@ async function remove(row) { outline /> @@ -116,7 +116,7 @@ function filterType(val, update) { - + - (agencies = data)" - auto-load - /> - - + (agencies = data)" auto-load /> + + + + {{ t(`filterPanel.${tag.label}`) }}: + {{ tag.value }} + + + - + - - + diff --git a/src/pages/Zone/ZoneList.vue b/src/pages/Zone/ZoneList.vue index f260eb134..3806a519e 100644 --- a/src/pages/Zone/ZoneList.vue +++ b/src/pages/Zone/ZoneList.vue @@ -1,111 +1,219 @@ - (agencyOptions = data)" - :filter="{ fields: ['id', 'name'] }" - auto-load - /> + + + + + + + + + + - + - - - - - - - - - - - - - - - + + + + + + {{ t(col.label) }} + {{ + col.tooltip + }} + + + + + + + + {{ props.value }} + + + + + + + {{ t('globals.clone') }} + + + {{ t('Preview') }} + + + + + - - {{ t('zone.list.create') }} + + {{ t('list.create') }} diff --git a/src/pages/Zone/locale/en.yml b/src/pages/Zone/locale/en.yml index e62111d57..d0a22ebcd 100644 --- a/src/pages/Zone/locale/en.yml +++ b/src/pages/Zone/locale/en.yml @@ -1,19 +1,40 @@ zone: - list: - volume: Volume - clone: Clone - id: Id - name: Name - agency: Agency - close: Close - price: Price - create: Create zone - openSummary: Details - create: - name: Name - agency: Agency - close: Close - price: Price - type: - submit: Save - reset: Reset + pageTitles: + zones: Zone + zonesList: Zones + deliveryList: Delivery days + upcomingList: Upcoming deliveries +list: + clone: Clone + id: Id + name: Name + agency: Agency + close: Close + price: Price + create: Create zone + openSummary: Details + confirmCloneTitle: All it's properties will be copied + confirmCloneSubtitle: Do you want to clone this zone? + searchZone: Search zones + searchInfo: Search zone by id or name +create: + name: Name + agency: Agency + close: Close + price: Price +type: + submit: Save + reset: Reset +summary: + agency: Agency + price: Price + basicData: Basic data + bonus: Bonus + closeHour: Close hour + travelingDays: Traveling days + volumetric: Volumetric + warehouse: Warehouse + name: Name +filterPanel: + name: Name + agencyModeFk: Agency diff --git a/src/pages/Zone/locale/es.yml b/src/pages/Zone/locale/es.yml index 5d7a265bf..ad740d5f7 100644 --- a/src/pages/Zone/locale/es.yml +++ b/src/pages/Zone/locale/es.yml @@ -1,19 +1,42 @@ zone: - list: - volume: Volumen - clone: Clonar - id: Id - name: Nombre - agency: Agencia - close: Cierre - price: Precio - create: Crear zona - openSummary: Detalles - create: - name: Nombre - agency: Agencia - close: Cierre - price: Precio - type: - submit: Guardar - reset: Reiniciar + pageTitles: + zones: Zonas + zonesList: Zonas + deliveryList: Días de entrega + upcomingList: Próximos repartos +list: + clone: Clonar + id: Id + name: Nombre + agency: Agencia + close: Cierre + price: Precio + create: Crear zona + openSummary: Detalles + confirmCloneTitle: Todas sus propiedades serán copiadas + confirmCloneSubtitle: ¿Seguro que quieres clonar esta zona? + searchZone: Buscar zonas + searchInfo: Buscar zonas por identificador o nombre +create: + name: Nombre + agency: Agencia + close: Cierre + price: Precio +type: + submit: Guardar + reset: Reiniciar +summary: + agency: Agencia + price: Precio + basicData: Datos básicos + bonus: Bonificación + closeHour: Hora de cierre + travelingDays: Días de viaje + volumetric: Volumétrico + warehouse: Almacén + name: Nombre +filterPanel: + name: Nombre + agencyModeFk: Agencia +Search zones: Buscar zonas +You can search by zone reference: Puedes buscar por referencia de la zona diff --git a/src/router/modules/worker.js b/src/router/modules/worker.js index d4d3bc3e7..384978d13 100644 --- a/src/router/modules/worker.js +++ b/src/router/modules/worker.js @@ -22,6 +22,7 @@ export default { 'WorkerCalendar', 'WorkerDms', 'WorkerTimeControl', + 'WorkerLocker', ], departmentCard: ['BasicData'], }, @@ -167,6 +168,15 @@ export default { component: () => import('src/pages/Worker/Card/WorkerTimeControl.vue'), }, + { + name: 'WorkerLocker', + path: 'locker', + meta: { + title: 'locker', + icon: 'lock', + }, + component: () => import('src/pages/Worker/Card/WorkerLocker.vue'), + }, ], }, ], diff --git a/src/router/modules/zone.js b/src/router/modules/zone.js index 079dfaa84..d39ed82d0 100644 --- a/src/router/modules/zone.js +++ b/src/router/modules/zone.js @@ -11,58 +11,54 @@ export default { component: RouterView, redirect: { name: 'ZoneMain' }, menus: { - main: [ - /*'ZoneList', 'ZoneDeliveryList', 'ZoneUpcomingList'*/ - ], - card: [ - // - ], + main: ['ZoneList', 'ZoneDeliveryList', 'ZoneUpcomingList'], + card: ['ZoneBasicData'], }, children: [ - // { - // path: '/zone', - // name: 'ZoneMain', - // component: () => import('src/pages/Zone/ZoneMain.vue'), - // redirect: { name: 'ZoneList' }, - // children: [ - // { - // path: 'list', - // name: 'ZoneList', - // meta: { - // title: 'zonesList', - // icon: 'vn:zone', - // }, - // component: () => import('src/pages/Zone/ZoneList.vue'), - // }, - // { - // path: 'create', - // name: 'ZoneCreate', - // meta: { - // title: 'zoneCreate', - // icon: 'create', - // }, - // component: () => import('src/pages/Zone/ZoneCreate.vue'), - // }, - // { - // path: ':id/edit', - // name: 'ZoneEdit', - // meta: { - // title: 'zoneEdit', - // icon: 'edit', - // }, - // component: () => import('src/pages/Zone/ZoneCreate.vue'), - // }, - // { - // path: 'counter', - // name: 'ZoneCounter', - // meta: { - // title: 'zoneCounter', - // icon: 'add_circle', - // }, - // component: () => import('src/pages/Zone/ZoneCounter.vue'), - // }, - // ], - // }, + { + path: '/zone', + name: 'ZoneMain', + component: () => import('src/pages/Zone/ZoneMain.vue'), + redirect: { name: 'ZoneList' }, + children: [ + { + path: 'list', + name: 'ZoneList', + meta: { + title: 'zonesList', + icon: 'vn:zone', + }, + component: () => import('src/pages/Zone/ZoneList.vue'), + }, + { + path: 'create', + name: 'ZoneCreate', + meta: { + title: 'zoneCreate', + icon: 'create', + }, + component: () => import('src/pages/Zone/ZoneCreate.vue'), + }, + { + path: ':id/edit', + name: 'ZoneEdit', + meta: { + title: 'zoneEdit', + icon: 'edit', + }, + component: () => import('src/pages/Zone/ZoneCreate.vue'), + }, + { + path: 'counter', + name: 'ZoneCounter', + meta: { + title: 'zoneCounter', + icon: 'add_circle', + }, + component: () => import('src/pages/Zone/ZoneCounter.vue'), + }, + ], + }, { name: 'ZoneCard', path: ':id', @@ -78,6 +74,15 @@ export default { }, component: () => import('src/pages/Zone/Card/ZoneSummary.vue'), }, + { + name: 'ZoneBasicData', + path: 'basic-data', + meta: { + title: 'basicData', + icon: 'vn:settings', + }, + component: () => import('src/pages/Zone/Card/ZoneBasicData.vue'), + }, // { // path: '/zone/delivery', // name: 'ZoneDeliveryMain', diff --git a/test/cypress/integration/worker/workerLocker.spec.js b/test/cypress/integration/worker/workerLocker.spec.js new file mode 100644 index 000000000..8c1886438 --- /dev/null +++ b/test/cypress/integration/worker/workerLocker.spec.js @@ -0,0 +1,19 @@ +describe('WorkerList', () => { + const workerId = 1110; + const lockerCode = '200A'; + const input = '.q-card input'; + const firstOpt = '[role="listbox"] .q-item:nth-child(1)'; + beforeEach(() => { + cy.viewport(1280, 720); + cy.login('productionBoss'); + cy.visit(`/#/worker/${workerId}/locker`); + }); + + it('should allocates a locker', () => { + cy.get(input).click(); + cy.get(input).type(lockerCode); + cy.get(firstOpt).click(); + cy.saveCard(); + cy.get(input).invoke('val').should('eq', lockerCode); + }); +});