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