fix [P-290]: поиск сотрудников
This commit is contained in:
1 parent
c9b07659d1
commit
06e2d58107
2 files changed
+113
-53
No files matched your search
@@ -6,7 +6,6 @@
|
|||||||
label="Выберите из списка или найдите по ФИО"
|
label="Выберите из списка или найдите по ФИО"
|
||||||
item-title="title"
|
item-title="title"
|
||||||
item-value="id"
|
item-value="id"
|
||||||
:custom-filter="onFilter"
|
|
||||||
:search-input.sync="filtered"
|
:search-input.sync="filtered"
|
||||||
@update:search="(val) => (filtered = val)"
|
@update:search="(val) => (filtered = val)"
|
||||||
multiple
|
multiple
|
||||||
@@ -15,7 +14,9 @@
|
|||||||
density="compact"
|
density="compact"
|
||||||
class="max-height-select py-3"
|
class="max-height-select py-3"
|
||||||
return-object
|
return-object
|
||||||
|
:custom-filter="customFilterFn"
|
||||||
>
|
>
|
||||||
|
<!-- :custom-filter="onFilter" -->
|
||||||
<template v-slot:selection="{ item }">
|
<template v-slot:selection="{ item }">
|
||||||
<v-chip class="me-2" color="teal-darken-3" size="small" label>
|
<v-chip class="me-2" color="teal-darken-3" size="small" label>
|
||||||
<span> {{ item.title }}</span>
|
<span> {{ item.title }}</span>
|
||||||
@@ -30,9 +31,9 @@
|
|||||||
</template>
|
</template>
|
||||||
<template v-slot:prepend-item>
|
<template v-slot:prepend-item>
|
||||||
<v-list-item
|
<v-list-item
|
||||||
@click.stop="allUser()"
|
|
||||||
:disabled="staffed.length == 1 && staffed[0].employees.length == 1"
|
:disabled="staffed.length == 1 && staffed[0].employees.length == 1"
|
||||||
class="text-body-2"
|
class="text-body-2"
|
||||||
|
@click.stop="allUser()"
|
||||||
>
|
>
|
||||||
<span class="text-body-2"> ВСЕ СОТРУДНИКИ </span>
|
<span class="text-body-2"> ВСЕ СОТРУДНИКИ </span>
|
||||||
|
|
||||||
@@ -139,7 +140,6 @@ export default {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
const selectedStaff = computed({
|
const selectedStaff = computed({
|
||||||
get() {
|
get() {
|
||||||
let selected = [];
|
let selected = [];
|
||||||
@@ -168,8 +168,6 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
console.log(staffed);
|
|
||||||
console.log(selectedStaff);
|
|
||||||
|
|
||||||
const emitUp = (part) => {
|
const emitUp = (part) => {
|
||||||
if ('employees' in part) {
|
if ('employees' in part) {
|
||||||
@@ -218,16 +216,34 @@ export default {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
function onFilter(item, queryText) {
|
const customFilterFn = (item, queryText, itemText) => {
|
||||||
|
if (!queryText) return true;
|
||||||
|
|
||||||
const searchText = queryText.toLowerCase();
|
const searchText = queryText.toLowerCase();
|
||||||
// Если item — это объект с employees, проверяем их
|
const target = item.raw || item;
|
||||||
if (item.raw && item.raw.employees) {
|
|
||||||
return item.raw.employees.some((e) => e.title.toLowerCase().includes(searchText));
|
// Создаем Map для быстрого поиска отделов по названию
|
||||||
|
const departmentMap = new Map(staffed.value.map((dept) => [dept.title, dept]));
|
||||||
|
|
||||||
|
let department;
|
||||||
|
|
||||||
|
if (typeof target === 'string') {
|
||||||
|
// Ищем отдел по названию
|
||||||
|
department = departmentMap.get(target);
|
||||||
|
} else if (target.title) {
|
||||||
|
// Уже имеем объект отдела
|
||||||
|
department = target;
|
||||||
}
|
}
|
||||||
// Если item — это строка, проверяем её
|
|
||||||
return item.title.toLowerCase().includes(searchText);
|
if (department && department.employees) {
|
||||||
|
return department.employees.some((employee) =>
|
||||||
|
employee.title?.toLowerCase().includes(searchText),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
const disable = (department) => {
|
const disable = (department) => {
|
||||||
return department.id == accountStore.user.id_dict_department &&
|
return department.id == accountStore.user.id_dict_department &&
|
||||||
department.employees.length == 1
|
department.employees.length == 1
|
||||||
@@ -245,9 +261,9 @@ export default {
|
|||||||
accountStore,
|
accountStore,
|
||||||
selectedStaff,
|
selectedStaff,
|
||||||
splitname,
|
splitname,
|
||||||
onFilter,
|
|
||||||
disable,
|
disable,
|
||||||
allUser,
|
allUser,
|
||||||
|
customFilterFn,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -52,7 +52,6 @@
|
|||||||
return-object
|
return-object
|
||||||
:rules="rules.calendar"
|
:rules="rules.calendar"
|
||||||
:disabled="'id' in propsEvent.event"
|
:disabled="'id' in propsEvent.event"
|
||||||
clearable
|
|
||||||
auto-select-first
|
auto-select-first
|
||||||
>
|
>
|
||||||
<template v-slot:selection="{ item }">
|
<template v-slot:selection="{ item }">
|
||||||
@@ -381,62 +380,107 @@ export default {
|
|||||||
// },
|
// },
|
||||||
// });
|
// });
|
||||||
|
|
||||||
const newStaff = computed(() => {
|
// const newStaff = computed(() => {
|
||||||
|
// if (isNewEvent.value) {
|
||||||
|
// const participants = myCalendar.value.participant || [];
|
||||||
|
|
||||||
|
// // 2. Создаем Set из id участников
|
||||||
|
// const calendarParticipantIds = new Set(participants.map((p) => p.participant_calendar));
|
||||||
|
|
||||||
|
// return staff.value
|
||||||
|
// .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;
|
||||||
|
|
||||||
|
// const currentCalendar = propsEvent.value.mycalendars?.find(
|
||||||
|
// (cal) => parseInt(cal.id) === parseInt(eventCalendarId),
|
||||||
|
// );
|
||||||
|
|
||||||
|
// if (!currentCalendar?.participant) return [];
|
||||||
|
|
||||||
|
// const calendarParticipantIds = new Set(currentCalendar.participant.map((p) => p.id));
|
||||||
|
// const eventParticipantIds = new Set(propsEvent.value.event.participant || []);
|
||||||
|
|
||||||
|
// return staff.value
|
||||||
|
// .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);
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
|
||||||
|
const newStaff = computed({
|
||||||
|
get() {
|
||||||
if (isNewEvent.value) {
|
if (isNewEvent.value) {
|
||||||
const participants = myCalendar.value.participant || [];
|
const participants = myCalendar.value.participant || [];
|
||||||
|
|
||||||
// 2. Создаем Set из id участников
|
|
||||||
const calendarParticipantIds = new Set(participants.map((p) => p.participant_calendar));
|
const calendarParticipantIds = new Set(participants.map((p) => p.participant_calendar));
|
||||||
|
|
||||||
return staff.value
|
staff.value.forEach((department) => {
|
||||||
.map((department) => {
|
department.employees.forEach((employee) => {
|
||||||
// ФИЛЬТРУЕМ сотрудников - оставляем только тех, кто в календаре
|
if (calendarParticipantIds.has(employee.id)) {
|
||||||
const employees = department.employees
|
employee.selected = true;
|
||||||
.filter((employee) => calendarParticipantIds.has(employee.id))
|
// employee.editor = ... если нужно
|
||||||
|
} else {
|
||||||
.map((employee) => ({
|
employee.selected = false;
|
||||||
...employee,
|
// employee.editor = false;
|
||||||
}));
|
}
|
||||||
|
});
|
||||||
return {
|
});
|
||||||
...department,
|
|
||||||
employees,
|
|
||||||
};
|
|
||||||
})
|
|
||||||
.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) return [];
|
if (currentCalendar?.participant) {
|
||||||
|
|
||||||
const calendarParticipantIds = new Set(currentCalendar.participant.map((p) => p.id));
|
const calendarParticipantIds = new Set(currentCalendar.participant.map((p) => p.id));
|
||||||
const eventParticipantIds = new Set(propsEvent.value.event.participant || []);
|
const eventParticipantIds = new Set(propsEvent.value.event.participant || []);
|
||||||
|
|
||||||
return staff.value
|
staff.value.forEach((department) => {
|
||||||
.map((department) => {
|
department.employees.forEach((employee) => {
|
||||||
// ФИЛЬТРУЕМ сотрудников - оставляем только тех, кто в календаре
|
if (calendarParticipantIds.has(employee.id)) {
|
||||||
const employees = department.employees
|
employee.selected =
|
||||||
.filter((employee) => calendarParticipantIds.has(employee.id))
|
|
||||||
.map((employee) => ({
|
|
||||||
...employee,
|
|
||||||
selected:
|
|
||||||
employee.id === accountStore.user.is_idEmployee ||
|
employee.id === accountStore.user.is_idEmployee ||
|
||||||
eventParticipantIds.has(employee.id),
|
eventParticipantIds.has(employee.id);
|
||||||
}));
|
} else {
|
||||||
|
employee.selected = false;
|
||||||
return {
|
|
||||||
...department,
|
|
||||||
employees,
|
|
||||||
};
|
|
||||||
})
|
|
||||||
.filter((dept) => dept.employees.length > 0);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return staff.value;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
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) => {
|
||||||
|
|||||||
Reference in new issue
Block a user