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,
|
||||
locales: [ruLocale],
|
||||
locale: 'ru',
|
||||
timeZone: 'local',
|
||||
firstDay: 1,
|
||||
headerToolbar: false,
|
||||
height: '80vh',
|
||||
|
||||
@@ -67,7 +67,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { ref, computed } from 'vue';
|
||||
import { ref, computed, watch } from 'vue';
|
||||
import { formatComa } from '@/utils/universal_functions';
|
||||
export default {
|
||||
props: {
|
||||
@@ -105,9 +105,16 @@ export default {
|
||||
const menudate = ref(false);
|
||||
const menutime = ref(false);
|
||||
|
||||
|
||||
const propsDateEvent = computed({
|
||||
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({
|
||||
@@ -115,26 +122,39 @@ export default {
|
||||
return propsDateEvent.value;
|
||||
},
|
||||
set(newValue) {
|
||||
console.log('=== MODEL DATE SET ===');
|
||||
console.log('New date value:', newValue);
|
||||
createdDate(newValue, timeEvent.value);
|
||||
},
|
||||
});
|
||||
|
||||
const timeEvent = computed({
|
||||
get() {
|
||||
return `${new Date(propsDateEvent.value).getHours()}:${String(
|
||||
new Date(propsDateEvent.value).getMinutes(),
|
||||
).padStart(2, '0')}`;
|
||||
const date = new Date(propsDateEvent.value);
|
||||
const time = `${date.getHours()}:${String(date.getMinutes()).padStart(2, '0')}`;
|
||||
console.log('=== TIME EVENT GET ===');
|
||||
console.log('Source date:', propsDateEvent.value);
|
||||
console.log('Computed time:', time);
|
||||
return time;
|
||||
},
|
||||
set(newValue) {
|
||||
console.log('=== TIME EVENT SET ===');
|
||||
console.log('New time value:', newValue);
|
||||
createdDate(modelDate.value, newValue);
|
||||
},
|
||||
});
|
||||
|
||||
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 newDate = new Date(date);
|
||||
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) {
|
||||
const startDate = new Date(props.limitation);
|
||||
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({
|
||||
get() {
|
||||
let filteredStaff = [];
|
||||
|
||||
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)) {
|
||||
// Мутируем И фильтруем для НОВОГО события
|
||||
filteredStaff = staff.value
|
||||
.map((department) => {
|
||||
// ФИЛЬТРУЕМ сотрудников - оставляем только тех, кто в календаре
|
||||
const filteredEmployees = department.employees.filter((employee) =>
|
||||
calendarParticipantIds.has(employee.id),
|
||||
);
|
||||
|
||||
// МУТАЦИЯ: устанавливаем selected=true для отфильтрованных сотрудников
|
||||
filteredEmployees.forEach((employee) => {
|
||||
employee.selected = true;
|
||||
// employee.editor = ... если нужно
|
||||
} else {
|
||||
employee.selected = false;
|
||||
// employee.editor = false;
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
return {
|
||||
...department,
|
||||
employees: filteredEmployees,
|
||||
};
|
||||
})
|
||||
.filter((dept) => dept.employees.length > 0);
|
||||
} 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 || []);
|
||||
if (!currentCalendar?.participant) return [];
|
||||
|
||||
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;
|
||||
}
|
||||
const calendarParticipantIds = new Set(currentCalendar.participant.map((p) => p.id));
|
||||
const eventParticipantIds = new Set(propsEvent.value.event.participant || []);
|
||||
|
||||
// Мутируем И фильтруем для СУЩЕСТВУЮЩЕГО события
|
||||
filteredStaff = staff.value
|
||||
.map((department) => {
|
||||
// ФИЛЬТРУЕМ сотрудников - оставляем только тех, кто в календаре
|
||||
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) => {
|
||||
axiosApiInstance.delete(`api/calendar_of_events/my_events/?delid=${idev}`).then((result) => {
|
||||
feedalert.alert = true;
|
||||
|
||||
Reference in new issue
Block a user