fix [P-290]: фикс участиников событий
This commit is contained in:
1 parent
de5c669ee2
commit
c9b07659d1
2 files changed
+53
-44
No files matched your search
@@ -7,6 +7,7 @@
|
||||
item-title="title"
|
||||
item-value="id"
|
||||
:custom-filter="onFilter"
|
||||
:search-input.sync="filtered"
|
||||
@update:search="(val) => (filtered = val)"
|
||||
multiple
|
||||
hide-details
|
||||
@@ -73,8 +74,8 @@
|
||||
)"
|
||||
:key="x.id"
|
||||
:value="x.title"
|
||||
:disabled="x.id == accountStore.user.is_idEmployee"
|
||||
@click.stop="selectedStaff = x"
|
||||
:disabled="x.id == accountStore.user.is_idEmployee"
|
||||
density="compact"
|
||||
>
|
||||
<template v-slot:prepend>
|
||||
@@ -112,13 +113,16 @@ export default {
|
||||
const filtered = ref('');
|
||||
const accountStore = useAccountStore();
|
||||
const back = ref([]);
|
||||
|
||||
const staffed = computed({
|
||||
get() {
|
||||
if (props.okey == 'editor') {
|
||||
let ns = [];
|
||||
props.staff.forEach((e) => {
|
||||
let emp = { ...e };
|
||||
emp.employees = e.employees.filter((n) => n.selected == true);
|
||||
emp.employees = e.employees.filter(
|
||||
(n) => n.selected == true || n.isCurrentUser == true,
|
||||
);
|
||||
if (emp.employees.length > 0) ns.push(emp);
|
||||
});
|
||||
|
||||
@@ -127,12 +131,15 @@ export default {
|
||||
e.editor = true;
|
||||
}
|
||||
});
|
||||
|
||||
return ns;
|
||||
}
|
||||
|
||||
return props.staff;
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
const selectedStaff = computed({
|
||||
get() {
|
||||
let selected = [];
|
||||
@@ -161,6 +168,8 @@ export default {
|
||||
}
|
||||
},
|
||||
});
|
||||
console.log(staffed);
|
||||
console.log(selectedStaff);
|
||||
|
||||
const emitUp = (part) => {
|
||||
if ('employees' in part) {
|
||||
@@ -209,13 +218,14 @@ export default {
|
||||
});
|
||||
};
|
||||
|
||||
function onFilter(item, itemText) {
|
||||
return (
|
||||
item.includes(filtered.value) ||
|
||||
itemText.raw.employees.some((e) =>
|
||||
e.title.toLowerCase().includes(filtered.value.toLowerCase()),
|
||||
)
|
||||
);
|
||||
function onFilter(item, queryText) {
|
||||
const searchText = queryText.toLowerCase();
|
||||
// Если item — это объект с employees, проверяем их
|
||||
if (item.raw && item.raw.employees) {
|
||||
return item.raw.employees.some((e) => e.title.toLowerCase().includes(searchText));
|
||||
}
|
||||
// Если item — это строка, проверяем её
|
||||
return item.title.toLowerCase().includes(searchText);
|
||||
}
|
||||
|
||||
const disable = (department) => {
|
||||
@@ -242,12 +252,3 @@ export default {
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.max-height-select .v-field__input {
|
||||
max-height: 300px; /* Установите желаемую максимальную высоту */
|
||||
overflow-y: auto; /* Добавьте прокрутку, если список превышает максимальную высоту */
|
||||
overflow-x: hidden;
|
||||
margin: 5px;
|
||||
}
|
||||
</style>
|
||||
@@ -382,29 +382,31 @@ export default {
|
||||
// });
|
||||
|
||||
const newStaff = computed(() => {
|
||||
// Для нового события - все сотрудники, для существующего - фильтр по календарю
|
||||
// const isNewEvent = !propsEvent.value.event.id;
|
||||
if (isNewEvent.value) {
|
||||
const participants = myCalendar.value.participant || [];
|
||||
|
||||
if (isNewEvent) {
|
||||
// НОВОЕ СОБЫТИЕ - все сотрудники
|
||||
const eventParticipantIds = propsEvent.value.event.participant || [];
|
||||
// 2. Создаем Set из id участников
|
||||
const calendarParticipantIds = new Set(participants.map((p) => p.participant_calendar));
|
||||
|
||||
return staff.value
|
||||
.map((department) => ({
|
||||
...department,
|
||||
employees: department.employees.map((employee) => ({
|
||||
...employee,
|
||||
selected:
|
||||
employee.id === accountStore.user.is_idEmployee ||
|
||||
eventParticipantIds.includes(employee.id),
|
||||
})),
|
||||
}))
|
||||
.map((department) => {
|
||||
// ФИЛЬТРУЕМ сотрудников - оставляем только тех, кто в календаре
|
||||
const employees = department.employees
|
||||
.filter((employee) => calendarParticipantIds.has(employee.id))
|
||||
|
||||
.map((employee) => ({
|
||||
...employee,
|
||||
}));
|
||||
|
||||
return {
|
||||
...department,
|
||||
employees,
|
||||
};
|
||||
})
|
||||
.filter((dept) => dept.employees.length > 0);
|
||||
} else {
|
||||
// СУЩЕСТВУЮЩЕЕ СОБЫТИЕ - фильтр по календарю
|
||||
|
||||
const eventCalendarId = propsEvent.value.event.calendar;
|
||||
if (!eventCalendarId) return [];
|
||||
|
||||
const currentCalendar = propsEvent.value.mycalendars?.find(
|
||||
(cal) => parseInt(cal.id) === parseInt(eventCalendarId),
|
||||
@@ -416,16 +418,22 @@ export default {
|
||||
const eventParticipantIds = new Set(propsEvent.value.event.participant || []);
|
||||
|
||||
return staff.value
|
||||
.map((department) => ({
|
||||
...department,
|
||||
employees: department.employees.map((employee) => ({
|
||||
...employee,
|
||||
selected: eventParticipantIds.has(employee.id),
|
||||
// Дополнительная информация для UX
|
||||
inCalendar: calendarParticipantIds.has(employee.id),
|
||||
disabled: false, // Всех можно выбирать
|
||||
})),
|
||||
}))
|
||||
.map((department) => {
|
||||
// ФИЛЬТРУЕМ сотрудников - оставляем только тех, кто в календаре
|
||||
const employees = department.employees
|
||||
.filter((employee) => calendarParticipantIds.has(employee.id))
|
||||
.map((employee) => ({
|
||||
...employee,
|
||||
selected:
|
||||
employee.id === accountStore.user.is_idEmployee ||
|
||||
eventParticipantIds.has(employee.id),
|
||||
}));
|
||||
|
||||
return {
|
||||
...department,
|
||||
employees,
|
||||
};
|
||||
})
|
||||
.filter((dept) => dept.employees.length > 0);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user