#8370: Change year param rely on month #1326
|
@ -69,12 +69,12 @@ const acl = useAcl();
|
||||||
const selectedDateYear = computed(() => moment(selectedDate.value).isoWeekYear());
|
const selectedDateYear = computed(() => moment(selectedDate.value).isoWeekYear());
|
||||||
const worker = computed(() => arrayData.store?.data);
|
const worker = computed(() => arrayData.store?.data);
|
||||||
const canSend = computed(() =>
|
const canSend = computed(() =>
|
||||||
acl.hasAny([{ model: 'WorkerTimeControl', props: 'sendMail', accessType: 'WRITE' }])
|
acl.hasAny([{ model: 'WorkerTimeControl', props: 'sendMail', accessType: 'WRITE' }]),
|
||||||
);
|
);
|
||||||
const canUpdate = computed(() =>
|
const canUpdate = computed(() =>
|
||||||
acl.hasAny([
|
acl.hasAny([
|
||||||
{ model: 'WorkerTimeControl', props: 'updateMailState', accessType: 'WRITE' },
|
{ model: 'WorkerTimeControl', props: 'updateMailState', accessType: 'WRITE' },
|
||||||
])
|
]),
|
||||||
);
|
);
|
||||||
const isHimself = computed(() => user.value.id === Number(route.params.id));
|
const isHimself = computed(() => user.value.id === Number(route.params.id));
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ const getHeaderFormattedDate = (date) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const formattedWeekTotalHours = computed(() =>
|
const formattedWeekTotalHours = computed(() =>
|
||||||
secondsToHoursMinutes(weekTotalHours.value)
|
secondsToHoursMinutes(weekTotalHours.value),
|
||||||
);
|
);
|
||||||
|
|
||||||
const onInputChange = async (date) => {
|
const onInputChange = async (date) => {
|
||||||
|
@ -320,7 +320,7 @@ const getFinishTime = () => {
|
||||||
today.setHours(0, 0, 0, 0);
|
today.setHours(0, 0, 0, 0);
|
||||||
|
|
||||||
let todayInWeek = weekDays.value.find(
|
let todayInWeek = weekDays.value.find(
|
||||||
(day) => day.dated.getTime() === today.getTime()
|
(day) => day.dated.getTime() === today.getTime(),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (todayInWeek && todayInWeek.hours && todayInWeek.hours.length) {
|
if (todayInWeek && todayInWeek.hours && todayInWeek.hours.length) {
|
||||||
|
@ -343,37 +343,29 @@ const updateData = async () => {
|
||||||
|
|
||||||
const getMailStates = async (date) => {
|
const getMailStates = async (date) => {
|
||||||
const url = `WorkerTimeControls/${route.params.id}/getMailStates`;
|
const url = `WorkerTimeControls/${route.params.id}/getMailStates`;
|
||||||
alexm marked this conversation as resolved
|
|||||||
|
const year = date.getFullYear();
|
||||||
const month = date.getMonth() + 1;
|
const month = date.getMonth() + 1;
|
||||||
const prevMonth = month == 1 ? 12 : month - 1;
|
|
||||||
const postMonth = month == 12 ? 1 : month + 1;
|
const getMonthStates = async (month, year) => {
|
||||||
const params = {
|
return (await axios.get(url, { params: { month, year } })).data;
|
||||||
month,
|
|
||||||
year: date.getFullYear(),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const curMonthStates = (await axios.get(url, { params })).data;
|
const curMonthStates = await getMonthStates(month, year);
|
||||||
|
|
||||||
if (prevMonth == 12) {
|
const prevMonthStates = await getMonthStates(
|
||||||
params.year = params.year - 1;
|
month === 1 ? 12 : month - 1,
|
||||||
}
|
month === 1 ? year - 1 : year,
|
||||||
const prevMonthStates = (
|
|
||||||
await axios.get(url, { params: { ...params, month: prevMonth } })
|
|
||||||
).data;
|
|
||||||
|
|
||||||
if (postMonth == 1) {
|
|
||||||
params.year = date.getFullYear() + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
const postMonthStates = (
|
|
||||||
await axios.get(url, {
|
|
||||||
params: { ...params, month: postMonth },
|
|
||||||
})
|
|
||||||
).data;
|
|
||||||
|
|
||||||
workerTimeControlMails.value = curMonthStates.concat(
|
|
||||||
prevMonthStates,
|
|
||||||
postMonthStates
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const postMonthStates = await getMonthStates(
|
||||||
|
month === 12 ? 1 : month + 1,
|
||||||
|
month === 12 ? year + 1 : year,
|
||||||
|
);
|
||||||
|
workerTimeControlMails.value = [
|
||||||
|
...curMonthStates,
|
||||||
|
...prevMonthStates,
|
||||||
|
...postMonthStates,
|
||||||
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
const showWorkerTimeForm = (propValue, formType) => {
|
const showWorkerTimeForm = (propValue, formType) => {
|
||||||
|
@ -490,7 +482,7 @@ onMounted(async () => {
|
||||||
openConfirmationModal(
|
openConfirmationModal(
|
||||||
t('Send time control email'),
|
t('Send time control email'),
|
||||||
t('Are you sure you want to send it?'),
|
t('Are you sure you want to send it?'),
|
||||||
resendEmail
|
resendEmail,
|
||||||
)
|
)
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
|
@ -579,7 +571,7 @@ onMounted(async () => {
|
||||||
@show-worker-time-form="
|
@show-worker-time-form="
|
||||||
showWorkerTimeForm(
|
showWorkerTimeForm(
|
||||||
{ id: hour.id, entryCode: hour.direction },
|
{ id: hour.id, entryCode: hour.direction },
|
||||||
'edit'
|
'edit',
|
||||||
)
|
)
|
||||||
"
|
"
|
||||||
class="hour-chip"
|
class="hour-chip"
|
||||||
|
|
Loading…
Reference in New Issue
https://chatgpt.com/c/67a5bac7-c6cc-8011-be56-bf2ac23df374