forked from verdnatura/salix-front
refactor: refs #7828 wip
This commit is contained in:
parent
d072a11c1b
commit
6b79d70551
|
@ -271,44 +271,38 @@ const fetchWorkerTimeControlMails = async (filter) => {
|
||||||
|
|
||||||
const fetchWeekData = async () => {
|
const fetchWeekData = async () => {
|
||||||
try {
|
try {
|
||||||
const filter = {
|
const data = (
|
||||||
where: {
|
await axios.get(`WorkerTimeControlMails/${route.params.id}/getWeeklyMail`, {
|
||||||
workerFk: route.params.id,
|
params: {
|
||||||
year: selectedDate.value ? selectedDate.value?.getFullYear() : null,
|
workerFk: route.params.id,
|
||||||
week: selectedWeekNumber.value,
|
year: selectedDate.value.getFullYear(),
|
||||||
},
|
week: selectedWeekNumber.value,
|
||||||
};
|
},
|
||||||
|
})
|
||||||
const data = await fetchWorkerTimeControlMails(filter);
|
).data;
|
||||||
if (!data.length) {
|
if (!data.length) state.value = null;
|
||||||
state.value = null;
|
else {
|
||||||
} else {
|
|
||||||
const [mail] = data;
|
const [mail] = data;
|
||||||
state.value = mail.state;
|
state.value = mail.state;
|
||||||
reason.value = mail.reason;
|
reason.value = mail.reason;
|
||||||
}
|
}
|
||||||
|
|
||||||
await canBeResend();
|
canResend.value = !!(
|
||||||
|
await axios.get('WorkerTimeControlMails/count', {
|
||||||
|
filter: {
|
||||||
|
where: {
|
||||||
|
year: selectedDate.value.getFullYear(),
|
||||||
|
week: selectedWeekNumber.value,
|
||||||
|
limit: 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
).data.count;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Error fetching week data');
|
console.error('Error fetching week data');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const canBeResend = async () => {
|
|
||||||
canResend.value = false;
|
|
||||||
|
|
||||||
const filter = {
|
|
||||||
where: {
|
|
||||||
year: selectedDate.value.getFullYear(),
|
|
||||||
week: selectedWeekNumber.value,
|
|
||||||
},
|
|
||||||
limit: 1,
|
|
||||||
};
|
|
||||||
|
|
||||||
const data = await fetchWorkerTimeControlMails(filter);
|
|
||||||
if (data.length) canResend.value = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
const setHours = (data) => {
|
const setHours = (data) => {
|
||||||
for (const weekDay of weekDays.value) {
|
for (const weekDay of weekDays.value) {
|
||||||
if (data) {
|
if (data) {
|
||||||
|
|
Loading…
Reference in New Issue