Merge pull request '#8370: Change year param rely on month' (!1326) from 8370-WorkerTimeControl into dev
gitea/salix-front/pipeline/head This commit looks good Details

Reviewed-on: #1326
Reviewed-by: Alex Moreno <alexm@verdnatura.es>
This commit is contained in:
Jon Elias 2025-03-04 14:00:38 +00:00
commit 57de2466c2
1 changed files with 19 additions and 9 deletions

View File

@ -343,19 +343,29 @@ const updateData = async () => {
const getMailStates = async (date) => {
const url = `WorkerTimeControls/${route.params.id}/getMailStates`;
const year = date.getFullYear();
const month = date.getMonth() + 1;
const prevMonth = month == 1 ? 12 : month - 1;
const params = {
month,
year: date.getFullYear(),
const getMonthStates = async (month, year) => {
return (await axios.get(url, { params: { month, year } })).data;
};
const curMonthStates = (await axios.get(url, { params })).data;
const prevMonthStates = (
await axios.get(url, { params: { ...params, month: prevMonth } })
).data;
const curMonthStates = await getMonthStates(month, year);
workerTimeControlMails.value = curMonthStates.concat(prevMonthStates);
const prevMonthStates = await getMonthStates(
month === 1 ? 12 : month - 1,
month === 1 ? year - 1 : year,
);
const postMonthStates = await getMonthStates(
month === 12 ? 1 : month + 1,
month === 12 ? year + 1 : year,
);
workerTimeControlMails.value = [
...curMonthStates,
...prevMonthStates,
...postMonthStates,
];
};
const showWorkerTimeForm = (propValue, formType) => {