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