refactor: waning young worker
This commit is contained in:
parent
60966e0f1c
commit
33a3a929e1
2 changed files with 45 additions and 2 deletions
|
|
@ -177,7 +177,7 @@ function setDefaultFormEmployee() {
|
|||
namePrefix: '',
|
||||
nationality: '',
|
||||
gender: '',
|
||||
dateOfBirth: new Date(),
|
||||
dateOfBirth: null,
|
||||
attachment: [],
|
||||
};
|
||||
|
||||
|
|
@ -261,6 +261,49 @@ async function getWorkerFromCriteria(
|
|||
}
|
||||
|
||||
watch(() => state.search, getWorkerList);
|
||||
|
||||
watch(
|
||||
() => formDataEmployee.value.dateOfBirth,
|
||||
() => {
|
||||
const age = calculateAge(formDataEmployee.value.dateOfBirth, 'year');
|
||||
if (formDataEmployee.value.dateOfBirth && Number(age) < 15) {
|
||||
dialog({
|
||||
color: 'warning',
|
||||
icon: 'mdi-alert',
|
||||
title: t('dialog.title.youngWorker15'),
|
||||
cancelText: t('general.edit'),
|
||||
persistent: true,
|
||||
message: t('dialog.message.youngWorker15'),
|
||||
|
||||
cancel: async () => {
|
||||
formDataEmployee.value.dateOfBirth = null;
|
||||
return;
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if (
|
||||
formDataEmployee.value.dateOfBirth &&
|
||||
Number(age) > 15 &&
|
||||
Number(age) <= 18
|
||||
) {
|
||||
dialog({
|
||||
color: 'warning',
|
||||
icon: 'mdi-alert',
|
||||
title: t('dialog.title.youngWorker18'),
|
||||
cancelText: t('general.cancel'),
|
||||
actionText: t('general.confirm'),
|
||||
persistent: true,
|
||||
message: t('dialog.message.youngWorker18'),
|
||||
action: () => {},
|
||||
cancel: async () => {
|
||||
formDataEmployee.value.dateOfBirth = null;
|
||||
return;
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
|
|
|||
|
|
@ -388,7 +388,7 @@ export type EmployeeWorker = {
|
|||
namePrefix: string;
|
||||
nationality: string;
|
||||
gender: string;
|
||||
dateOfBirth: Date;
|
||||
dateOfBirth: Date | null;
|
||||
};
|
||||
|
||||
export type ProductGroup = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue