forked from verdnatura/salix-front
refs #7767 fix contractHolidays
This commit is contained in:
parent
2edeb1043e
commit
b225f6a4c8
|
@ -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([]);
|
||||
|
|
Loading…
Reference in New Issue