fix [P-290]: поиск

This commit is contained in:
Inna committed 2025-10-01 13:10:47 +03:00
1 parent 7095081811
commit e114879e6f
8 files changed
+301 -104

No files matched your search

@@ -69,12 +69,14 @@
:key="file.id" :key="file.id"
class="me-2 mb-1" class="me-2 mb-1"
color="teal-darken-3" color="teal-darken-3"
label label
@click:close="removeExistingFile(file.id)" @click:close="removeExistingFile(file.id)"
> >
<v-icon start class="pb-1">{{ getFileIcon(file) }}</v-icon> <v-icon start class="pb-1">{{ getFileIcon(file) }}</v-icon>
{{ getFileName(file) }} <span class="text-truncate" style="max-width: 120px">
{{ truncateFileName(getFileName(file)) }}
</span>
<v-icon <v-icon
class="ms-1 download-icon" class="ms-1 download-icon"
@click.stop="downloadExistingFile(file)" @click.stop="downloadExistingFile(file)"
@@ -328,6 +330,19 @@ export default {
} }
}; };
// Функция для обрезки длинных имен файлов
const truncateFileName = (fileName) => {
if (!fileName) return '';
if (fileName.length <= 20) return fileName;
const extension = fileName.split('.').pop();
const nameWithoutExt = fileName.slice(0, -(extension.length + 1));
if (nameWithoutExt.length <= 15) return fileName;
return `${nameWithoutExt.slice(0, 15)}...${extension ? '.' + extension : ''}`;
};
return { return {
localNewFiles, localNewFiles,
existingFiles, existingFiles,
@@ -347,6 +362,7 @@ export default {
handleDrop, handleDrop,
cleanFileName, cleanFileName,
downloadExistingFile, downloadExistingFile,
truncateFileName,
}; };
}, },
}; };
@@ -426,6 +442,4 @@ export default {
opacity: 1; opacity: 1;
color: #024e45; color: #024e45;
} }
</style> </style>
@@ -1,9 +1,10 @@
<template> <template>
<v-col cols="12"> <v-col cols="12" class="d-flex flex-column" style="height: 80vh">
<v-card> <v-card class="d-flex flex-column flex-grow-1">
<v-card-text> <v-card-text class="d-flex flex-column flex-grow-1">
<!-- Контролы навигации --> <!-- Контролы навигации -->
<v-row no-gutters class="mb-4" align="center" justify="space-between"> <div class="flex-grow-0 mb-1">
<v-row no-gutters class="mb-1" align="center" justify="space-between">
<v-col md="4" class="flex-grow-0 d-flex align-center"> <v-col md="4" class="flex-grow-0 d-flex align-center">
<v-btn <v-btn
v-show="!forHomePage" v-show="!forHomePage"
@@ -60,9 +61,10 @@
</v-btn-toggle> </v-btn-toggle>
</v-col> </v-col>
</v-row> </v-row>
<div class="flex-grow-1"> </div>
<div class="flex-grow-1 d-flex">
<!-- VCalendar --> <!-- VCalendar -->
<FullCalendar ref="calendarRef" :options="calendarOptions" class="compact-calendar" /> <FullCalendar ref="calendarRef" :options="calendarOptions" class="custom-calendar" />
</div> </div>
</v-card-text> </v-card-text>
</v-card> </v-card>
@@ -96,15 +98,18 @@ export default {
}, },
emits: ['openEventDialog'], emits: ['openEventDialog'],
setup(props, { emit }) { setup(props, { emit }) {
const calendarRef = ref(null);
const currentView = ref('dayGridMonth'); const currentView = ref('dayGridMonth');
const calendarApi = ref(null);
const currentTitle = ref('Календарь'); const currentTitle = ref('Календарь');
const calendarRef = ref(null);
const calendarStore = useCalendarStore(); const calendarStore = useCalendarStore();
const { selectedDate, lastUpdatedBy, allEvents, calendarColorMap } = storeToRefs(calendarStore); const { selectedDate, lastUpdatedBy, allEvents, calendarColorMap } = storeToRefs(calendarStore);
const { parseRecurrenceOptions, isRecurringEvent } = useRecurrence(); const { parseRecurrenceOptions, isRecurringEvent } = useRecurrence();
const calendarApi = computed(() => {
return calendarRef.value?.getApi?.() || null;
});
const handleEventClick = (info) => { const handleEventClick = (info) => {
if (calendarStore.canEditEvent(info.event.id)) { if (calendarStore.canEditEvent(info.event.id)) {
emit('openEventDialog', info); emit('openEventDialog', info);
@@ -209,7 +214,7 @@ export default {
}, },
listWeek: { listWeek: {
type: 'list', type: 'list',
duration: { weeks: 1 }, duration: { days: 1 },
listDayFormat: { listDayFormat: {
weekday: 'long', weekday: 'long',
day: 'numeric', day: 'numeric',
@@ -258,46 +263,36 @@ export default {
calendarStore.setSelectedDateFromCalendar(info); calendarStore.setSelectedDateFromCalendar(info);
currentTitle.value = info.view.title; currentTitle.value = info.view.title;
const calendarApi = calendarRef.value.getApi(); if (calendarApi.value) {
// Переходим к выбранной дате в дневном виде calendarApi.value.gotoDate(info.date);
calendarApi.gotoDate(info.date); calendarApi.value.changeView('listWeek');
calendarApi.changeView('listWeek');
currentView.value = 'listWeek'; currentView.value = 'listWeek';
}
}; };
const handleToday = () => { const handleToday = () => {
calendarApi.value?.today(); calendarApi.value?.today();
// Получаем текущую дату из календаря и передаем в стор // Получаем текущую дату из календаря и передаем в стор
const currentDate = calendarApi.value?.getDate(); updateSelectedDateFromCalendar();
if (currentDate) {
// Создаем объект похожий на info из FullCalendar
const todayInfo = {
dateStr: currentDate.toISOString().split('T')[0],
};
calendarStore.setSelectedDateFromCalendar(todayInfo);
}
}; };
const handlePrev = () => { const handlePrev = () => {
calendarApi.value?.prev(); calendarApi.value?.prev();
const currentDate = calendarApi.value?.getDate(); updateSelectedDateFromCalendar();
if (currentDate) {
const dateInfo = {
dateStr: currentDate.toISOString().split('T')[0],
};
calendarStore.setSelectedDateFromCalendar(dateInfo);
}
}; };
const handleNext = () => { const handleNext = () => {
calendarApi.value?.next(); calendarApi.value?.next();
updateSelectedDateFromCalendar();
};
const updateSelectedDateFromCalendar = () => {
const currentDate = calendarApi.value?.getDate(); const currentDate = calendarApi.value?.getDate();
if (currentDate) { if (currentDate) {
const dateInfo = { const todayInfo = {
dateStr: currentDate.toISOString().split('T')[0], dateStr: currentDate.toISOString().split('T')[0],
}; };
calendarStore.setSelectedDateFromCalendar(dateInfo); calendarStore.setSelectedDateFromCalendar(todayInfo);
} }
}; };
@@ -314,18 +309,10 @@ export default {
selectedDate.value = dateStr; selectedDate.value = dateStr;
}; };
// const calendarColorMap = computed(() => {
// const map = new Map();
// calendarStore.myCalendars.forEach((calendar) => {
// map.set(calendar.id, calendar.cl_color);
// });
// return map;
// });
// Обновление событий в календаре // Обновление событий в календаре
const updateCalendarEvents = () => { const updateCalendarEvents = () => {
if (calendarRef.value) { if (calendarRef.value) {
const api = calendarRef.value.getApi(); const api = calendarApi.value;
api.removeAllEvents(); api.removeAllEvents();
allEvents.value.forEach((event) => { allEvents.value.forEach((event) => {
const eventColor = calendarColorMap.value.get(event.calendar) || '#3788d8'; const eventColor = calendarColorMap.value.get(event.calendar) || '#3788d8';
@@ -364,12 +351,11 @@ export default {
onMounted(() => { onMounted(() => {
nextTick(() => { nextTick(() => {
if (calendarRef.value && calendarRef.value.getApi) { if (calendarApi.value) {
calendarApi.value = calendarRef.value.getApi();
updateCalendarEvents(); updateCalendarEvents();
} }
if (selectedDate.value != undefined && selectedDate.value) { if (selectedDate.value) {
handleDateSelection(selectedDate.value); handleDateSelection(selectedDate.value);
} }
}); });
@@ -396,11 +382,9 @@ export default {
}); });
watch( watch(
[allEvents], allEvents,
([newEvents]) => { (newEvents) => {
if (newEvents.length > 0) {
updateCalendarEvents(); updateCalendarEvents();
}
}, },
{ deep: true, immediate: true }, { deep: true, immediate: true },
); );
@@ -408,9 +392,8 @@ export default {
watch( watch(
() => props.eventCalendar, () => props.eventCalendar,
(newEvent) => { (newEvent) => {
if (calendarRef.value) { if (calendarApi.value) {
const api = calendarRef.value.getApi(); calendarApi.value.refetchEvents();
api.refetchEvents(); // Обновляем события в календаре
} }
}, },
{ deep: true }, { deep: true },
@@ -419,6 +402,7 @@ export default {
return { return {
currentTitle, currentTitle,
calendarRef, calendarRef,
calendarApi,
currentView, currentView,
calendarOptions, calendarOptions,
handleToday, handleToday,
@@ -540,4 +524,10 @@ export default {
:deep(.fc-day.grey-background) { :deep(.fc-day.grey-background) {
background-color: #f5f5f5 !important; background-color: #f5f5f5 !important;
} }
.custom-calendar {
height: 100% !important;
min-height: 700px;
flex: 1 1 auto;
}
</style> </style>
@@ -59,7 +59,7 @@
<!-- Дневное расписание --> <!-- Дневное расписание -->
<v-col cols="5" class="pl-2"> <v-col cols="5" class="pl-2">
<div class="schedule-header"> <div class="schedule-header">
<h3 class="day-title">Сегодня, {{ formattedSelectedDate }}</h3> <h3 class="day-title"> <span v-if="isToday(selectedDate)">Сегодня, </span>{{formattedSelectedDate }}</h3>
</div> </div>
<v-card variant="outlined" class="day-schedule" elevation="0"> <v-card variant="outlined" class="day-schedule" elevation="0">
@@ -2,18 +2,9 @@
<v-card class="h-100 rounded-0 d-flex flex-colmn"> <v-card class="h-100 rounded-0 d-flex flex-colmn">
<v-row no-gutters class="flex-column"> <v-row no-gutters class="flex-column">
<v-col class="flex-grow-0 px-2 pt-1"> <v-col class="flex-grow-0 px-2 pt-1">
<v-text-field <SearchEvents />
density="compact"
clearable
append-inner-icon="mdi-magnify"
hide-details
class="py-3"
label="Найти событие"
rows="1"
no-resize
variant="outlined"
/>
</v-col> </v-col>
<v-col class="flex-grow-0 px-2"> <v-col class="flex-grow-0 px-2">
<v-btn <v-btn
type="submit" type="submit"
@@ -24,7 +15,6 @@
@click="openEventDialog" @click="openEventDialog"
>Создать событие</v-btn >Создать событие</v-btn
> >
<!-- {{eventFromCalendar}} -->
</v-col> </v-col>
<v-col lg="3"> <v-col lg="3">
<v-locale-provider locale="ru"> <v-locale-provider locale="ru">
@@ -59,12 +49,13 @@
import { useCalendarStore } from '@/store/calendarStore'; import { useCalendarStore } from '@/store/calendarStore';
import { useAccountStore } from '@/store/AccountStore'; import { useAccountStore } from '@/store/AccountStore';
import CalendarMy from '@/components/calendar_of_events/calendar-my.vue'; import CalendarMy from '@/components/calendar_of_events/calendar-my.vue';
import { onMounted, watch, ref, nextTick } from 'vue'; import SearchEvents from '@/components/calendar_of_events/UI_calendar/SearchEvents.vue';
import { onMounted, watch, nextTick } from 'vue';
import { storeToRefs } from 'pinia'; import { storeToRefs } from 'pinia';
export default { export default {
name: 'MiniCalendar', name: 'MiniCalendar',
components: { CalendarMy }, components: { CalendarMy, SearchEvents },
setup() { setup() {
const calendarStore = useCalendarStore(); const calendarStore = useCalendarStore();
const accountStore = useAccountStore(); const accountStore = useAccountStore();
@@ -236,4 +227,23 @@ export default {
.minCal:deep(.weekend-day.holiday-day .v-btn__content) { .minCal:deep(.weekend-day.holiday-day .v-btn__content) {
color: #cc0000 !important; color: #cc0000 !important;
} }
search-dropdown {
max-height: 300px;
overflow-y: auto;
}
/* Стили для скроллбара */
.search-dropdown::-webkit-scrollbar {
width: 4px;
}
.search-dropdown::-webkit-scrollbar-track {
background: #f1f1f1;
}
.search-dropdown::-webkit-scrollbar-thumb {
background: #888;
border-radius: 2px;
}
</style> </style>
@@ -0,0 +1,208 @@
<template>
<div class="search-events-wrapper" ref="searchContainerRef">
<v-text-field
v-model="searchQuery"
density="compact"
clearable
append-inner-icon="mdi-magnify"
hide-details
class="py-3"
label="Найти событие"
rows="1"
no-resize
variant="outlined"
@click:clear="clearSearch"
@focus="showResults = true"
@keydown.esc="hideResults"
/>
<div v-if="searchQuery" class="search-overlay" @click="closeResults"></div>
<!-- Выпадающий список результатов -->
<v-card class="search-dropdown mt-1" elevation="4">
<v-list density="compact" class="py-0">
<v-list-item
v-for="event in filteredEvents"
:key="event.id"
@click="selectEvent(event)"
class="px-2"
>
<v-list-item-title class="text-body-2">
{{ event.name }}
</v-list-item-title>
<v-list-item-subtitle class="text-caption">
{{ formatEventDate(event) }}
• {{ event.calendarData?.cl_name }}
</v-list-item-subtitle>
</v-list-item>
</v-list>
</v-card>
<!-- Сообщение "не найдено" -->
<v-card
v-if="showResults && searchQuery && filteredEvents.length === 0"
class="search-dropdown mt-1"
elevation="4"
>
<v-list density="compact" class="py-0">
<v-list-item>
<v-list-item-title class="text-body-2 text-center text-disabled">
События не найдены
</v-list-item-title>
</v-list-item>
</v-list>
</v-card>
</div>
</template>
<script setup>
import { ref, computed, onMounted, onUnmounted, watch, nextTick } from 'vue';
import { useCalendarStore } from '@/store/calendarStore.js';
const calendarStore = useCalendarStore();
// Reactive data
const searchQuery = ref('');
const showResults = ref(false);
const searchContainerRef = ref(null);
const shouldShowDropdown = computed(() => {
return showResults.value && searchQuery.value;
});
const filteredEvents = ref([]);
const performSearch = () => {
if (!searchQuery.value) {
filteredEvents.value = [];
return;
}
if (!calendarStore.allEvents) {
filteredEvents.value = [];
return;
}
const query = searchQuery.value.toLowerCase().trim();
filteredEvents.value = calendarStore.allEvents
.filter((event) => {
return (
event.name?.toLowerCase().includes(query) ||
event.description?.toLowerCase().includes(query) ||
event.calendarData?.cl_name?.toLowerCase().includes(query)
);
})
.slice(0, 8);
};
watch(
searchQuery,
() => {
performSearch();
},
{ immediate: true },
);
const closeResults = () => {
showResults.value = false;
};
const hideResults = () => {
showResults.value = false;
};
const clearSearch = () => {
searchQuery.value = '';
showResults.value = false;
};
const formatEventDate = (event) => {
try {
const start = new Date(event.date_start);
return `${start.toLocaleDateString('ru-RU')} • ${formatTime(event.date_start)}`;
} catch {
return 'Дата неизвестна';
}
};
const formatTime = (dateString) => {
try {
return new Date(dateString).toLocaleTimeString('ru-RU', {
hour: '2-digit',
minute: '2-digit',
});
} catch {
return '--:--';
}
};
const selectEvent = (event) => {
console.log(event);
calendarStore.setSelectedDate(event.date_start, 'search');
searchQuery.value = '';
closeResults();
};
// Click outside handler
const handleClickOutside = (event) => {
if (showResults.value) {
closeResults();
}
};
onMounted(() => {
document.addEventListener('click', handleClickOutside);
performSearch();
// Дополнительно через nextTick
nextTick(() => {
if (searchQuery.value) {
performSearch();
}
});
});
onUnmounted(() => {
document.removeEventListener('click', handleClickOutside);
});
</script>
<style scoped>
.search-events-wrapper {
position: relative;
z-index: 100;
}
.search-overlay {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 999;
background: transparent;
}
.search-dropdown {
position: absolute;
top: 100%;
left: 0;
right: 0;
max-height: 400px;
overflow-y: auto;
margin-top: 4px;
z-index: 1001;
background: white;
}
.search-dropdown::-webkit-scrollbar {
width: 4px;
}
.search-dropdown::-webkit-scrollbar-track {
background: #f1f1f1;
}
.search-dropdown::-webkit-scrollbar-thumb {
background: #888;
border-radius: 2px;
}
</style>
@@ -1,5 +1,5 @@
<template> <template>
<v-card min-height="436" class="pa-3"> <v-card min-height="436" class="pa-3" max-width="50vw">
<v-card-title class="pr-0 pl-2 d-flex justify-space-between"> <v-card-title class="pr-0 pl-2 d-flex justify-space-between">
{{ title }} {{ title }}
<v-icon <v-icon
@@ -50,7 +50,7 @@
width="150" width="150"
type="transformation" type="transformation"
> >
{{ newOrOld ? "Создать" : "Редактировать" }} {{ newOrOld ? "Создать" : "Сохранить" }}
</v-btn> </v-btn>
</v-card-actions> </v-card-actions>
</v-form> </v-form>
@@ -125,26 +125,7 @@
</v-row> </v-col </v-row> </v-col
></v-row> ></v-row>
</v-col> </v-col>
<v-row no-gutters class="align-top flex-grow-0">
<v-col class="text-body-2 text-text_grey pt-3 h-0" lg="2"> Напоминание </v-col>
<v-col class="d-flex flex-column">
<v-row no-gutters class="gap flex-grow-0">
<reminder-event />
</v-row>
<v-row no-gutters class="flex-grow-0">
<v-col>
<v-btn
disabled
prepend-icon="mdi-plus"
variant="text"
class="text-body-2 text-text_grey"
>
Добавить уведомление
</v-btn>
</v-col>
</v-row>
</v-col></v-row
>
<v-row <v-row
no-gutters no-gutters
class="align-start d-flex pt-3 mb-3" class="align-start d-flex pt-3 mb-3"
+8 -14
View File
@@ -1,21 +1,15 @@
<template> <template>
<v-container fluid class="d-flex mx-0 pa-0"> <v-container fluid class="d-flex pa-0">
<v-row class="ma-2"> <v-row class="ma-0">
<v-col class="d-flex flex-column" lg="7" md="12" cols="12"> <v-col class="d-flex flex-column" lg="7" md="12" cols="12">
<v-row class="flex-grow-0"> <div class="flex-grow-0 mb-3">
<v-col class="pa-1">
<Carousel-list /> <Carousel-list />
</v-col> </div>
</v-row>
<v-row class="flex-grow-0" style="min-height: 300px"> <div class="flex-grow-1">
<v-col class="pa-1 d-flex align-stretch"> <HomeCalendarWidget class="h-100"/>
<HomeCalendarWidget />
</v-col> </div>
</v-row>
<!-- <v-row style="height: 250px">
<HomeCalendarWidget />
</v-row> -->
</v-col> </v-col>
<v-col class="d-flex flex-column" lg="5" md="12" cols="12"> <v-col class="d-flex flex-column" lg="5" md="12" cols="12">
<v-row> <v-row>