From b225f6a4c879cd1151aec64ed3bb0f48cedc2b73 Mon Sep 17 00:00:00 2001 From: carlossa Date: Mon, 14 Oct 2024 13:18:34 +0200 Subject: [PATCH] refs #7767 fix contractHolidays --- .../Worker/Card/WorkerCalendarFilter.vue | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/pages/Worker/Card/WorkerCalendarFilter.vue b/src/pages/Worker/Card/WorkerCalendarFilter.vue index 95fb2d393..cc99cde0e 100644 --- a/src/pages/Worker/Card/WorkerCalendarFilter.vue +++ b/src/pages/Worker/Card/WorkerCalendarFilter.vue @@ -5,7 +5,7 @@ import { useI18n } from 'vue-i18n'; import VnSelect from 'components/common/VnSelect.vue'; import useNotify from 'src/composables/useNotify'; import { useRoute } from 'vue-router'; -import { computed, onMounted, ref } from 'vue'; +import { computed, onMounted, ref, watch } from 'vue'; import { toDateFormat } from '../../../filters/date'; const { notify } = useNotify(); @@ -35,9 +35,13 @@ const props = defineProps({ }, }); -onMounted(async () => { - await checkHolidays(props.contractHolidays); -}); +watch( + () => props.contractHolidays, + (newValue) => { + checkHolidays(newValue); + }, + { deep: true, immediate: true } +); const emit = defineEmits(['update:businessFk', 'update:year', 'update:absenceType']); const selectedBusinessFk = computed({ @@ -58,22 +62,23 @@ const selectedAbsenceType = computed({ }, }); -const generateYears = () => { +function generateYears() { const now = Date.vnNew(); const maxYear = now.getFullYear() + 1; return Array.from({ length: 5 }, (_, i) => String(maxYear - i)) || []; -}; +} -const checkHolidays = (contractHolidays) => { +function checkHolidays(contractHolidays) { console.log('contractHolidays', contractHolidays); + if (!contractHolidays) return; if ( contractHolidays.holidaysEnjoyed > contractHolidays.totalHolidays || contractHolidays.hoursEnjoyed > contractHolidays.totalHours ) { notify(t('Vacation days have been exceeded'), 'negative'); } -}; +} const absenceTypeList = ref([]); const contractList = ref([]);