forked from verdnatura/salix-front
Reviewed-on: verdnatura/salix-front#338 Reviewed-by: Javi Gallego <jgallego@verdnatura.es>
This commit is contained in:
commit
cde918744d
|
@ -13,6 +13,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
|
- (Worker) => Se crea la sección Taquilla
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- (General) => Se vuelven a mostrar los parámetros en la url al aplicar un filtro
|
- (General) => Se vuelven a mostrar los parámetros en la url al aplicar un filtro
|
||||||
|
|
|
@ -156,9 +156,12 @@ const startFormWatcher = () => {
|
||||||
|
|
||||||
async function fetch() {
|
async function fetch() {
|
||||||
try {
|
try {
|
||||||
const { data } = await axios.get($props.url, {
|
let { data } = await axios.get($props.url, {
|
||||||
params: { filter: JSON.stringify($props.filter) },
|
params: { filter: JSON.stringify($props.filter) },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (Array.isArray(data)) data = data[0] ?? {};
|
||||||
|
|
||||||
state.set($props.model, data);
|
state.set($props.model, data);
|
||||||
originalData.value = data && JSON.parse(JSON.stringify(data));
|
originalData.value = data && JSON.parse(JSON.stringify(data));
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { onBeforeMount, computed } from 'vue';
|
import { onBeforeMount, computed, watchEffect } from 'vue';
|
||||||
import { useRoute, onBeforeRouteUpdate } from 'vue-router';
|
import { useRoute, onBeforeRouteUpdate } from 'vue-router';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useArrayData } from 'src/composables/useArrayData';
|
import { useArrayData } from 'src/composables/useArrayData';
|
||||||
|
@ -47,6 +47,11 @@ if (props.baseUrl) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
watchEffect(() => {
|
||||||
|
if (Array.isArray(arrayData.store.data))
|
||||||
|
arrayData.store.data = arrayData.store.data[0];
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<Teleport
|
<Teleport
|
||||||
|
|
|
@ -826,6 +826,7 @@ worker:
|
||||||
log: Log
|
log: Log
|
||||||
calendar: Calendar
|
calendar: Calendar
|
||||||
timeControl: Time control
|
timeControl: Time control
|
||||||
|
locker: Locker
|
||||||
list:
|
list:
|
||||||
name: Name
|
name: Name
|
||||||
email: Email
|
email: Email
|
||||||
|
|
|
@ -824,6 +824,7 @@ worker:
|
||||||
log: Historial
|
log: Historial
|
||||||
calendar: Calendario
|
calendar: Calendario
|
||||||
timeControl: Control de horario
|
timeControl: Control de horario
|
||||||
|
locker: Taquilla
|
||||||
list:
|
list:
|
||||||
name: Nombre
|
name: Nombre
|
||||||
email: Email
|
email: Email
|
||||||
|
|
|
@ -0,0 +1,64 @@
|
||||||
|
<script setup>
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
<template>
|
||||||
|
<FetchData
|
||||||
|
ref="fetchData"
|
||||||
|
url="Lockers/codes"
|
||||||
|
:filter="filter"
|
||||||
|
@on-fetch="(data) => (lockers = data)"
|
||||||
|
/>
|
||||||
|
<FormModel
|
||||||
|
:url="`Workers/${entityId}/locker`"
|
||||||
|
model="worker"
|
||||||
|
auto-load
|
||||||
|
:save-fn="save"
|
||||||
|
@on-fetch="init"
|
||||||
|
>
|
||||||
|
<template #form="{ data }">
|
||||||
|
<VnSelect
|
||||||
|
:label="t('Locker')"
|
||||||
|
v-model="data.id"
|
||||||
|
:options="lockers"
|
||||||
|
option-label="code"
|
||||||
|
option-value="id"
|
||||||
|
hide-selected
|
||||||
|
:readonly="!hasAny(['productionBoss', 'hr'])"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</FormModel>
|
||||||
|
</template>
|
|
@ -1,2 +1,3 @@
|
||||||
Search worker: Buscar trabajador
|
Search worker: Buscar trabajador
|
||||||
You can search by worker id or name: Puedes buscar por id o nombre del trabajador
|
You can search by worker id or name: Puedes buscar por id o nombre del trabajador
|
||||||
|
Locker: Taquilla
|
||||||
|
|
|
@ -22,6 +22,7 @@ export default {
|
||||||
'WorkerCalendar',
|
'WorkerCalendar',
|
||||||
'WorkerDms',
|
'WorkerDms',
|
||||||
'WorkerTimeControl',
|
'WorkerTimeControl',
|
||||||
|
'WorkerLocker',
|
||||||
],
|
],
|
||||||
departmentCard: ['BasicData'],
|
departmentCard: ['BasicData'],
|
||||||
},
|
},
|
||||||
|
@ -167,6 +168,15 @@ export default {
|
||||||
component: () =>
|
component: () =>
|
||||||
import('src/pages/Worker/Card/WorkerTimeControl.vue'),
|
import('src/pages/Worker/Card/WorkerTimeControl.vue'),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'WorkerLocker',
|
||||||
|
path: 'locker',
|
||||||
|
meta: {
|
||||||
|
title: 'locker',
|
||||||
|
icon: 'lock',
|
||||||
|
},
|
||||||
|
component: () => import('src/pages/Worker/Card/WorkerLocker.vue'),
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
|
@ -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);
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in New Issue