Skip to content

Commit

Permalink
change precise filter for rooms to Less More
Browse files Browse the repository at this point in the history
  • Loading branch information
Alikohd committed Dec 12, 2024
1 parent a1fda8c commit 1979a7a
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 27 deletions.
2 changes: 1 addition & 1 deletion frontend/src/features/sidebar/ui/admin/ReportsSection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
<el-table-column prop="sectionName" label="Тип тренировки" sortable/>
<el-table-column prop="trainingCount" label="Количество проведенных" sortable/>
<el-table-column prop="clientCount" label="Количество клиентов" sortable/>
<el-table-column prop="loadPercentage" label="Загруженность" sortable/>
<el-table-column prop="loadPercentage" label="Загруженность, %" sortable/>
</el-table>

<el-pagination
Expand Down
70 changes: 45 additions & 25 deletions frontend/src/features/sidebar/ui/admin/ServiceInfoSection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,21 @@
<el-input v-model="filters.name" placeholder="Фильтр по названию" clearable />
</el-col>
<el-col :span="6">
<el-input v-model="filters.capacity" placeholder="Фильтр по емкости" clearable type="number" />
<el-input
v-model="filters.minCapacity"
placeholder="Больше чем"
clearable
type="number"
/>
</el-col>

<el-col :span="6">
<el-input
v-model="filters.maxCapacity"
placeholder="Меньше чем"
clearable
type="number"
/>
</el-col>
<el-col :span="6">
<el-input v-model="filters.address" placeholder="Фильтр по адресу" clearable />
Expand Down Expand Up @@ -190,15 +204,17 @@ const editingMode = ref(false);
const filters = ref({
name: '',
capacity: '',
minCapacity: '',
maxCapacity: '',
address: '',
workingDays: [] as string[], // ПН,ВТ, ...
workingDays: [] as string[], // ПН, ВТ, ...
openingTime: '',
closingTime: '',
trainers: [] as string[],
sections: [] as string[],
});
const sortBy = ref('name');
const sortOrder = ref('asc');
Expand Down Expand Up @@ -377,8 +393,12 @@ const displayedRooms = computed(() => {
filtered = filtered.filter(r => (r.name ?? '').toLowerCase().includes(filters.value.name.toLowerCase()));
}
if (filters.value.capacity) {
filtered = filtered.filter(r => String(r.capacity ?? '').includes(filters.value.capacity.toString()));
if (filters.value.minCapacity) {
filtered = filtered.filter(r => r.capacity >= Number(filters.value.minCapacity));
}
if (filters.value.maxCapacity) {
filtered = filtered.filter(r => r.capacity <= Number(filters.value.maxCapacity));
}
if (filters.value.address) {
Expand All @@ -393,27 +413,27 @@ const displayedRooms = computed(() => {
// Фильтрация по рабочим дням
if (filters.value.workingDays.length > 0) {
filtered = filtered.filter(r => {
if(!Array.isArray(r.workingDays) || r.workingDays.length===0) return false;
if (!Array.isArray(r.workingDays) || r.workingDays.length === 0) return false;
// Проверяем, что все выбранные в фильтре дни присутствуют в массиве r.workingDays
return filters.value.workingDays.every(dayFilter => r.workingDays.includes(dayFilter));
});
}
// Фильтрация по секциям
if (filters.value.sections.length>0) {
if (filters.value.sections.length > 0) {
filtered = filtered.filter(r => {
if(!Array.isArray(r.sections) || r.sections.length===0) return false;
return filters.value.sections.every(sec=> r.sections.includes(sec));
})
if (!Array.isArray(r.sections) || r.sections.length === 0) return false;
return filters.value.sections.every(sec => r.sections.includes(sec));
});
}
// Сортировка
if (sortBy.value) {
filtered.sort((a, b) => {
let aValue:any = '';
let bValue:any = '';
let aValue: any = '';
let bValue: any = '';
switch(sortBy.value) {
switch (sortBy.value) {
case 'name':
aValue = (a.name ?? '').toLowerCase(); bValue = (b.name ?? '').toLowerCase();
break;
Expand All @@ -422,14 +442,14 @@ const displayedRooms = computed(() => {
bValue = b.capacity ?? Number.MAX_SAFE_INTEGER;
break;
case 'address':
const aAddr = ((a.location?.address ?? '') + ', ' + (a.location?.number??'')).toLowerCase();
const bAddr = ((b.location?.address ?? '') + ', ' + (b.location?.number??'')).toLowerCase();
const aAddr = ((a.location?.address ?? '') + ', ' + (a.location?.number ?? '')).toLowerCase();
const bAddr = ((b.location?.address ?? '') + ', ' + (b.location?.number ?? '')).toLowerCase();
aValue = aAddr; bValue = bAddr;
break;
case 'workingDays':
// workingDays - массив, для сравнения превращаем в строку
aValue = Array.isArray(a.workingDays)? a.workingDays.join(', ').toLowerCase():'';
bValue = Array.isArray(b.workingDays)? b.workingDays.join(', ').toLowerCase():'';
aValue = Array.isArray(a.workingDays) ? a.workingDays.join(', ').toLowerCase() : '';
bValue = Array.isArray(b.workingDays) ? b.workingDays.join(', ').toLowerCase() : '';
break;
case 'openingTime':
aValue = a.openingTime ?? '';
Expand All @@ -444,22 +464,22 @@ const displayedRooms = computed(() => {
bValue = '';
}
if (typeof aValue==='string') aValue = aValue.toLowerCase();
if (typeof bValue==='string') bValue = bValue.toLowerCase();
if (typeof aValue === 'string') aValue = aValue.toLowerCase();
if (typeof bValue === 'string') bValue = bValue.toLowerCase();
if (aValue<bValue) return sortOrder.value==='asc'?-1:1;
if (aValue>bValue) return sortOrder.value==='asc'?1:-1;
if (aValue < bValue) return sortOrder.value === 'asc' ? -1 : 1;
if (aValue > bValue) return sortOrder.value === 'asc' ? 1 : -1;
return 0;
});
}
// Преобразуем данные для отображения
return filtered.map((room:any)=> {
const wd = Array.isArray(room.workingDays) && room.workingDays.length>0 ? room.workingDays.join(', ') : 'Не указано';
return filtered.map((room: any) => {
const wd = Array.isArray(room.workingDays) && room.workingDays.length > 0 ? room.workingDays.join(', ') : 'Не указано';
const opening = room.openingTime || 'Не указано';
const closing = room.closingTime || 'Не указано';
const trainerNames = getTrainerNames(room.trainers);
const sec = Array.isArray(room.sections) && room.sections.length>0 ? room.sections.join(', ') : 'Не указано';
const sec = Array.isArray(room.sections) && room.sections.length > 0 ? room.sections.join(', ') : 'Не указано';
return {
name: room.name ?? 'Не указано',
Expand All @@ -472,7 +492,7 @@ const displayedRooms = computed(() => {
trainers: trainerNames,
sections: sec,
id: room.id ?? ''
}
};
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ public List<SectionStatistics> getFinishedTrainings(LocalDate startDate, LocalDa
int currentClientCount = training.getClients().size();
sectionStats.setClientCount(sectionStats.getClientCount() == null ? currentClientCount : sectionStats.getClientCount() + currentClientCount);

int totalSlots = training.getAvailableSlots();
int totalSlots = training.getRoom().getCapacity();
double loadPercentage = totalSlots > 0 ? (currentClientCount / (double) totalSlots) * 100 : 0;
sectionStats.setLoadPercentage(loadPercentage);

Expand Down

0 comments on commit 1979a7a

Please sign in to comment.