fix [P-290]: проверить время событий
This commit is contained in:
1 parent
06e2d58107
commit
b110909b33
3 files changed
+118
-30
No files matched your search
@@ -128,6 +128,7 @@ export default {
|
|||||||
initialView: props.forHomePage ? props.view : currentView.value,
|
initialView: props.forHomePage ? props.view : currentView.value,
|
||||||
locales: [ruLocale],
|
locales: [ruLocale],
|
||||||
locale: 'ru',
|
locale: 'ru',
|
||||||
|
timeZone: 'local',
|
||||||
firstDay: 1,
|
firstDay: 1,
|
||||||
headerToolbar: false,
|
headerToolbar: false,
|
||||||
height: '80vh',
|
height: '80vh',
|
||||||
|
|||||||
@@ -67,7 +67,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { ref, computed } from 'vue';
|
import { ref, computed, watch } from 'vue';
|
||||||
import { formatComa } from '@/utils/universal_functions';
|
import { formatComa } from '@/utils/universal_functions';
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
@@ -105,9 +105,16 @@ export default {
|
|||||||
const menudate = ref(false);
|
const menudate = ref(false);
|
||||||
const menutime = ref(false);
|
const menutime = ref(false);
|
||||||
|
|
||||||
|
|
||||||
const propsDateEvent = computed({
|
const propsDateEvent = computed({
|
||||||
get: () => new Date(props.dateEvent),
|
get: () => new Date(props.dateEvent),
|
||||||
set: (value) => emit('update:dateEvent', value),
|
set: (value) => {
|
||||||
|
console.log('=== EMITTING DATE ===');
|
||||||
|
console.log('Value:', value);
|
||||||
|
console.log('Type:', typeof value);
|
||||||
|
console.log('ISO String:', value.toISOString());
|
||||||
|
emit('update:dateEvent', value);
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const modelDate = computed({
|
const modelDate = computed({
|
||||||
@@ -115,26 +122,39 @@ export default {
|
|||||||
return propsDateEvent.value;
|
return propsDateEvent.value;
|
||||||
},
|
},
|
||||||
set(newValue) {
|
set(newValue) {
|
||||||
|
console.log('=== MODEL DATE SET ===');
|
||||||
|
console.log('New date value:', newValue);
|
||||||
createdDate(newValue, timeEvent.value);
|
createdDate(newValue, timeEvent.value);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const timeEvent = computed({
|
const timeEvent = computed({
|
||||||
get() {
|
get() {
|
||||||
return `${new Date(propsDateEvent.value).getHours()}:${String(
|
const date = new Date(propsDateEvent.value);
|
||||||
new Date(propsDateEvent.value).getMinutes(),
|
const time = `${date.getHours()}:${String(date.getMinutes()).padStart(2, '0')}`;
|
||||||
).padStart(2, '0')}`;
|
console.log('=== TIME EVENT GET ===');
|
||||||
|
console.log('Source date:', propsDateEvent.value);
|
||||||
|
console.log('Computed time:', time);
|
||||||
|
return time;
|
||||||
},
|
},
|
||||||
set(newValue) {
|
set(newValue) {
|
||||||
|
console.log('=== TIME EVENT SET ===');
|
||||||
|
console.log('New time value:', newValue);
|
||||||
createdDate(modelDate.value, newValue);
|
createdDate(modelDate.value, newValue);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const createdDate = (date, time) => {
|
const createdDate = (date, time) => {
|
||||||
|
console.log('=== CREATED DATE CALLED ===');
|
||||||
|
console.log('Input date:', date);
|
||||||
|
console.log('Input time:', time);
|
||||||
const [hours, minutes] = time.split(':').map(Number);
|
const [hours, minutes] = time.split(':').map(Number);
|
||||||
const newDate = new Date(date);
|
const newDate = new Date(date);
|
||||||
newDate.setHours(hours, minutes, 0, 0);
|
newDate.setHours(hours, minutes, 0, 0);
|
||||||
|
|
||||||
|
console.log('Final date before emit:', newDate);
|
||||||
|
console.log('Final date ISO:', newDate.toISOString());
|
||||||
|
|
||||||
if (props.order[0] == 4) {
|
if (props.order[0] == 4) {
|
||||||
const startDate = new Date(props.limitation);
|
const startDate = new Date(props.limitation);
|
||||||
if (newDate <= startDate) {
|
if (newDate <= startDate) {
|
||||||
|
|||||||
@@ -437,51 +437,118 @@ export default {
|
|||||||
// }
|
// }
|
||||||
// });
|
// });
|
||||||
|
|
||||||
|
// const newStaff = computed({
|
||||||
|
// get() {
|
||||||
|
// if (isNewEvent.value) {
|
||||||
|
// const participants = myCalendar.value.participant || [];
|
||||||
|
// const calendarParticipantIds = new Set(participants.map((p) => p.participant_calendar));
|
||||||
|
|
||||||
|
// staff.value.forEach((department) => {
|
||||||
|
// department.employees.forEach((employee) => {
|
||||||
|
// if (calendarParticipantIds.has(employee.id)) {
|
||||||
|
// employee.selected = true;
|
||||||
|
// // employee.editor = ... если нужно
|
||||||
|
// } else {
|
||||||
|
// employee.selected = false;
|
||||||
|
// // employee.editor = false;
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
// } else {
|
||||||
|
// const eventCalendarId = propsEvent.value.event.calendar;
|
||||||
|
// const currentCalendar = propsEvent.value.mycalendars?.find(
|
||||||
|
// (cal) => parseInt(cal.id) === parseInt(eventCalendarId),
|
||||||
|
// );
|
||||||
|
|
||||||
|
// if (currentCalendar?.participant) {
|
||||||
|
// const calendarParticipantIds = new Set(currentCalendar.participant.map((p) => p.id));
|
||||||
|
// const eventParticipantIds = new Set(propsEvent.value.event.participant || []);
|
||||||
|
|
||||||
|
// staff.value.forEach((department) => {
|
||||||
|
// department.employees.forEach((employee) => {
|
||||||
|
// if (calendarParticipantIds.has(employee.id)) {
|
||||||
|
// employee.selected =
|
||||||
|
// employee.id === accountStore.user.is_idEmployee ||
|
||||||
|
// eventParticipantIds.has(employee.id);
|
||||||
|
// } else {
|
||||||
|
// employee.selected = false;
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// return staff.value;
|
||||||
|
// },
|
||||||
|
// });
|
||||||
|
|
||||||
const newStaff = computed({
|
const newStaff = computed({
|
||||||
get() {
|
get() {
|
||||||
|
let filteredStaff = [];
|
||||||
|
|
||||||
if (isNewEvent.value) {
|
if (isNewEvent.value) {
|
||||||
const participants = myCalendar.value.participant || [];
|
const participants = myCalendar.value.participant || [];
|
||||||
const calendarParticipantIds = new Set(participants.map((p) => p.participant_calendar));
|
const calendarParticipantIds = new Set(participants.map((p) => p.participant_calendar));
|
||||||
|
|
||||||
staff.value.forEach((department) => {
|
// Мутируем И фильтруем для НОВОГО события
|
||||||
department.employees.forEach((employee) => {
|
filteredStaff = staff.value
|
||||||
if (calendarParticipantIds.has(employee.id)) {
|
.map((department) => {
|
||||||
|
// ФИЛЬТРУЕМ сотрудников - оставляем только тех, кто в календаре
|
||||||
|
const filteredEmployees = department.employees.filter((employee) =>
|
||||||
|
calendarParticipantIds.has(employee.id),
|
||||||
|
);
|
||||||
|
|
||||||
|
// МУТАЦИЯ: устанавливаем selected=true для отфильтрованных сотрудников
|
||||||
|
filteredEmployees.forEach((employee) => {
|
||||||
employee.selected = true;
|
employee.selected = true;
|
||||||
// employee.editor = ... если нужно
|
// employee.editor = ... если нужно
|
||||||
} else {
|
});
|
||||||
employee.selected = false;
|
|
||||||
// employee.editor = false;
|
return {
|
||||||
}
|
...department,
|
||||||
});
|
employees: filteredEmployees,
|
||||||
});
|
};
|
||||||
|
})
|
||||||
|
.filter((dept) => dept.employees.length > 0);
|
||||||
} else {
|
} else {
|
||||||
|
// СУЩЕСТВУЮЩЕЕ СОБЫТИЕ - фильтр по календарю
|
||||||
const eventCalendarId = propsEvent.value.event.calendar;
|
const eventCalendarId = propsEvent.value.event.calendar;
|
||||||
const currentCalendar = propsEvent.value.mycalendars?.find(
|
const currentCalendar = propsEvent.value.mycalendars?.find(
|
||||||
(cal) => parseInt(cal.id) === parseInt(eventCalendarId),
|
(cal) => parseInt(cal.id) === parseInt(eventCalendarId),
|
||||||
);
|
);
|
||||||
|
|
||||||
if (currentCalendar?.participant) {
|
if (!currentCalendar?.participant) return [];
|
||||||
const calendarParticipantIds = new Set(currentCalendar.participant.map((p) => p.id));
|
|
||||||
const eventParticipantIds = new Set(propsEvent.value.event.participant || []);
|
|
||||||
|
|
||||||
staff.value.forEach((department) => {
|
const calendarParticipantIds = new Set(currentCalendar.participant.map((p) => p.id));
|
||||||
department.employees.forEach((employee) => {
|
const eventParticipantIds = new Set(propsEvent.value.event.participant || []);
|
||||||
if (calendarParticipantIds.has(employee.id)) {
|
|
||||||
employee.selected =
|
// Мутируем И фильтруем для СУЩЕСТВУЮЩЕГО события
|
||||||
employee.id === accountStore.user.is_idEmployee ||
|
filteredStaff = staff.value
|
||||||
eventParticipantIds.has(employee.id);
|
.map((department) => {
|
||||||
} else {
|
// ФИЛЬТРУЕМ сотрудников - оставляем только тех, кто в календаре
|
||||||
employee.selected = false;
|
const filteredEmployees = department.employees.filter((employee) =>
|
||||||
}
|
calendarParticipantIds.has(employee.id),
|
||||||
|
);
|
||||||
|
|
||||||
|
// МУТАЦИЯ: устанавливаем selected на основе участников события
|
||||||
|
filteredEmployees.forEach((employee) => {
|
||||||
|
employee.selected =
|
||||||
|
employee.id === accountStore.user.is_idEmployee ||
|
||||||
|
eventParticipantIds.has(employee.id);
|
||||||
});
|
});
|
||||||
});
|
|
||||||
}
|
return {
|
||||||
|
...department,
|
||||||
|
employees: filteredEmployees,
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.filter((dept) => dept.employees.length > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return staff.value;
|
return filteredStaff;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const delEvent = (idev) => {
|
const delEvent = (idev) => {
|
||||||
axiosApiInstance.delete(`api/calendar_of_events/my_events/?delid=${idev}`).then((result) => {
|
axiosApiInstance.delete(`api/calendar_of_events/my_events/?delid=${idev}`).then((result) => {
|
||||||
feedalert.alert = true;
|
feedalert.alert = true;
|
||||||
|
|||||||
Reference in new issue
Block a user