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 @@
+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/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/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);
+ });
+});