Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2c8c686a94 | ||
|
|
3ae3cff498 | ||
|
|
c8561a1749 | ||
|
|
cb8c70639b | ||
|
|
584ad4ccb3 | ||
|
|
00a0498caf | ||
|
|
e5168ddd5e | ||
|
|
fa07dd83ef | ||
|
|
867f120c5f | ||
|
|
a22c4453ce | ||
|
|
6ab58babcb | ||
|
|
dbdc5f30be | ||
|
|
a36f4a4856 | ||
|
|
bc89809b9b | ||
|
|
67b201a5fe | ||
|
|
d8b228c1fc | ||
|
|
055ea431eb | ||
|
|
7ae8f1ea18 | ||
|
|
77244f2d06 | ||
|
|
1ea87f85cd | ||
|
|
8c2eb5d040 | ||
|
|
0d404e533b | ||
|
|
3f0f1e8f1a | ||
|
|
2883930a7e | ||
|
|
a7703fbc1b | ||
|
|
cda088fa65 | ||
|
|
18caac1bb7 | ||
|
|
b110909b33 | ||
|
|
06e2d58107 | ||
|
|
c9b07659d1 | ||
|
|
de5c669ee2 | ||
|
|
01b7416ff8 | ||
|
|
e114879e6f |
No files matched your search
@@ -7,3 +7,4 @@ DB_USER="root"
|
|||||||
DB_PASSWORD="yourpassword"
|
DB_PASSWORD="yourpassword"
|
||||||
DB_HOST="db"
|
DB_HOST="db"
|
||||||
DB_PORT=3306
|
DB_PORT=3306
|
||||||
|
MYDEBUG=True
|
||||||
+10
@@ -0,0 +1,10 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# Editor-based HTTP Client requests
|
||||||
|
/httpRequests/
|
||||||
|
# Ignored default folder with query files
|
||||||
|
/queries/
|
||||||
|
# Datasource local storage ignored files
|
||||||
|
/dataSources/
|
||||||
|
/dataSources.local.xml
|
||||||
+8
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="WEB_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager">
|
||||||
|
<content url="file://$MODULE_DIR$" />
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
</module>
|
||||||
+59
@@ -0,0 +1,59 @@
|
|||||||
|
<component name="ProjectCodeStyleConfiguration">
|
||||||
|
<code_scheme name="Project" version="173">
|
||||||
|
<HTMLCodeStyleSettings>
|
||||||
|
<option name="HTML_SPACE_INSIDE_EMPTY_TAG" value="true" />
|
||||||
|
</HTMLCodeStyleSettings>
|
||||||
|
<JSCodeStyleSettings version="0">
|
||||||
|
<option name="FORCE_SEMICOLON_STYLE" value="true" />
|
||||||
|
<option name="SPACE_BEFORE_FUNCTION_LEFT_PARENTH" value="false" />
|
||||||
|
<option name="USE_DOUBLE_QUOTES" value="false" />
|
||||||
|
<option name="FORCE_QUOTE_STYlE" value="true" />
|
||||||
|
<option name="ENFORCE_TRAILING_COMMA" value="WhenMultiline" />
|
||||||
|
<option name="SPACES_WITHIN_OBJECT_LITERAL_BRACES" value="true" />
|
||||||
|
<option name="SPACES_WITHIN_IMPORTS" value="true" />
|
||||||
|
</JSCodeStyleSettings>
|
||||||
|
<TypeScriptCodeStyleSettings version="0">
|
||||||
|
<option name="FORCE_SEMICOLON_STYLE" value="true" />
|
||||||
|
<option name="SPACE_BEFORE_FUNCTION_LEFT_PARENTH" value="false" />
|
||||||
|
<option name="USE_DOUBLE_QUOTES" value="false" />
|
||||||
|
<option name="FORCE_QUOTE_STYlE" value="true" />
|
||||||
|
<option name="ENFORCE_TRAILING_COMMA" value="WhenMultiline" />
|
||||||
|
<option name="SPACES_WITHIN_OBJECT_LITERAL_BRACES" value="true" />
|
||||||
|
<option name="SPACES_WITHIN_IMPORTS" value="true" />
|
||||||
|
</TypeScriptCodeStyleSettings>
|
||||||
|
<VueCodeStyleSettings>
|
||||||
|
<option name="INTERPOLATION_NEW_LINE_AFTER_START_DELIMITER" value="false" />
|
||||||
|
<option name="INTERPOLATION_NEW_LINE_BEFORE_END_DELIMITER" value="false" />
|
||||||
|
</VueCodeStyleSettings>
|
||||||
|
<codeStyleSettings language="HTML">
|
||||||
|
<option name="SOFT_MARGINS" value="100" />
|
||||||
|
<indentOptions>
|
||||||
|
<option name="INDENT_SIZE" value="2" />
|
||||||
|
<option name="CONTINUATION_INDENT_SIZE" value="2" />
|
||||||
|
<option name="TAB_SIZE" value="2" />
|
||||||
|
</indentOptions>
|
||||||
|
</codeStyleSettings>
|
||||||
|
<codeStyleSettings language="JavaScript">
|
||||||
|
<option name="SOFT_MARGINS" value="100" />
|
||||||
|
<indentOptions>
|
||||||
|
<option name="INDENT_SIZE" value="2" />
|
||||||
|
<option name="CONTINUATION_INDENT_SIZE" value="2" />
|
||||||
|
<option name="TAB_SIZE" value="2" />
|
||||||
|
</indentOptions>
|
||||||
|
</codeStyleSettings>
|
||||||
|
<codeStyleSettings language="TypeScript">
|
||||||
|
<option name="SOFT_MARGINS" value="100" />
|
||||||
|
<indentOptions>
|
||||||
|
<option name="INDENT_SIZE" value="2" />
|
||||||
|
<option name="CONTINUATION_INDENT_SIZE" value="2" />
|
||||||
|
<option name="TAB_SIZE" value="2" />
|
||||||
|
</indentOptions>
|
||||||
|
</codeStyleSettings>
|
||||||
|
<codeStyleSettings language="Vue">
|
||||||
|
<option name="SOFT_MARGINS" value="100" />
|
||||||
|
<indentOptions>
|
||||||
|
<option name="CONTINUATION_INDENT_SIZE" value="2" />
|
||||||
|
</indentOptions>
|
||||||
|
</codeStyleSettings>
|
||||||
|
</code_scheme>
|
||||||
|
</component>
|
||||||
+5
@@ -0,0 +1,5 @@
|
|||||||
|
<component name="ProjectCodeStyleConfiguration">
|
||||||
|
<state>
|
||||||
|
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
|
||||||
|
</state>
|
||||||
|
</component>
|
||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<profile version="1.0">
|
||||||
|
<option name="myName" value="Project Default" />
|
||||||
|
<inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||||
|
</profile>
|
||||||
|
</component>
|
||||||
+8
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/PORTAL_COD2.iml" filepath="$PROJECT_DIR$/.idea/PORTAL_COD2.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
+7
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="" vcs="Git" />
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
@@ -178,14 +178,12 @@ def default_date():
|
|||||||
|
|
||||||
class Screensaver(models.Model):
|
class Screensaver(models.Model):
|
||||||
img = models.ImageField(upload_to='screengallery/%Y/%m/%d', null=True, verbose_name='Изображение')
|
img = models.ImageField(upload_to='screengallery/%Y/%m/%d', null=True, verbose_name='Изображение')
|
||||||
cdate =models.DateField(default=default_date, null=True, verbose_name='Дата начала периода')
|
cdate = models.DateField(default=default_date, null=True, verbose_name='Дата начала периода')
|
||||||
enddate = models.DateField(default= default_date, verbose_name='Дата окончания периода', null=True)
|
enddate = models.DateField(default=default_date, null=True, verbose_name='Дата окончания периода')
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|
||||||
verbose_name = "Вход. Изображение"
|
verbose_name = "Вход. Изображение"
|
||||||
verbose_name_plural = "Вход. Изображения"
|
verbose_name_plural = "Вход. Изображения"
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return str(self.img)
|
return str(self.img)
|
||||||
|
|
||||||
Generated
+18432
File diff suppressed because it is too large.
Load diff
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "front",
|
"name": "front",
|
||||||
"version": "1.2.2",
|
"version": "1.3.2",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
|
|||||||
@@ -60,21 +60,23 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Существующие файлы из БД -->
|
<!-- Существующие файлы из БД -->
|
||||||
<div class="existing-files-section mb-4">
|
<div class="existing-files-section mb-2">
|
||||||
<div class="text-caption text-grey mb-2">Прикрепленные файлы:</div>
|
<div class="text-caption text-grey mb-2">Прикрепленные файлы:</div>
|
||||||
<div>
|
<div>
|
||||||
<template v-if="existingFiles.length">
|
<template v-if="existingFiles.length">
|
||||||
<v-chip
|
<v-chip
|
||||||
v-for="file in existingFiles"
|
v-for="file in existingFiles"
|
||||||
: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)"
|
||||||
@@ -197,26 +199,37 @@ export default {
|
|||||||
|
|
||||||
// Получаем имя файла из объекта файла
|
// Получаем имя файла из объекта файла
|
||||||
const getFileName = (fileData) => {
|
const getFileName = (fileData) => {
|
||||||
|
// Для новых файлов (File object) - берем оригинальное имя
|
||||||
if (fileData instanceof File) {
|
if (fileData instanceof File) {
|
||||||
return cleanFileName(fileData.name);
|
return fileData.name;
|
||||||
}
|
}
|
||||||
// Для существующих файлов с бэка - извлекаем имя из пути
|
|
||||||
|
// Для существующих файлов с бэкенда - извлекаем из URL
|
||||||
if (fileData.file) {
|
if (fileData.file) {
|
||||||
try {
|
try {
|
||||||
const filePath = fileData.file.split('?')[0]; // Убираем параметры
|
const filePath = fileData.file.startsWith('http')
|
||||||
const fileName = filePath.split('/').pop(); // Берем последнюю часть пути
|
? new URL(fileData.file).pathname
|
||||||
return cleanFileName(fileName) || 'Файл';
|
: fileData.file;
|
||||||
} catch {
|
|
||||||
|
// Извлекаем имя файла
|
||||||
|
let fileName = filePath.split('/').pop();
|
||||||
|
|
||||||
|
// Декодируем URL-encoded символы, но НЕ изменяем имя
|
||||||
|
fileName = decodeURIComponent(fileName);
|
||||||
|
|
||||||
|
return fileName || 'Файл';
|
||||||
|
} catch (error) {
|
||||||
|
console.warn('Ошибка извлечения имени файла:', error, fileData);
|
||||||
return 'Файл';
|
return 'Файл';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return cleanFileName(fileData.name || 'Файл');
|
// Если есть name в данных - используем как есть
|
||||||
};
|
if (fileData.name) {
|
||||||
|
return fileData.name;
|
||||||
|
}
|
||||||
|
|
||||||
const cleanFileName = (fileName) => {
|
return 'Файл';
|
||||||
// Убираем суффиксы в скобках (1), (2) и т.д.
|
|
||||||
return fileName.replace(/\s*\(\d+\)(?=\.\w+$|$)/, '');
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Иконка в зависимости от типа файла
|
// Иконка в зависимости от типа файла
|
||||||
@@ -304,30 +317,41 @@ export default {
|
|||||||
|
|
||||||
const downloadExistingFile = async (file) => {
|
const downloadExistingFile = async (file) => {
|
||||||
try {
|
try {
|
||||||
const getOriginalFileName = (filePath) => {
|
const fileName = getFileName(file); // Теперь будет работать правильно!
|
||||||
try {
|
const fileUrl = file.file.startsWith('http')
|
||||||
const pathParts = filePath.split('/');
|
? file.file
|
||||||
return pathParts[pathParts.length - 1];
|
: `${window.location.origin}${file.file}`; // Для относительных путей
|
||||||
} catch {
|
|
||||||
return 'file';
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const fileName = getOriginalFileName(file.file);
|
|
||||||
const fileUrl = file.file;
|
|
||||||
// Создаем временную ссылку для скачивания
|
|
||||||
const link = document.createElement('a');
|
const link = document.createElement('a');
|
||||||
link.href = fileUrl;
|
link.href = fileUrl;
|
||||||
link.download = fileName; // Указываем имя файла при скачивании
|
link.download = fileName;
|
||||||
|
link.style.display = 'none';
|
||||||
|
|
||||||
document.body.appendChild(link);
|
document.body.appendChild(link);
|
||||||
link.click();
|
link.click();
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
document.body.removeChild(link);
|
document.body.removeChild(link);
|
||||||
|
}, 100);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Ошибка при скачивании файла:', error);
|
console.error('Ошибка при скачивании файла:', error);
|
||||||
|
errorMessages.value = ['Ошибка скачивания файла'];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Функция для обрезки длинных имен файлов
|
||||||
|
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,
|
||||||
@@ -345,8 +369,8 @@ export default {
|
|||||||
handleFileSelect,
|
handleFileSelect,
|
||||||
triggerFileInput,
|
triggerFileInput,
|
||||||
handleDrop,
|
handleDrop,
|
||||||
cleanFileName,
|
|
||||||
downloadExistingFile,
|
downloadExistingFile,
|
||||||
|
truncateFileName,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -408,7 +432,7 @@ export default {
|
|||||||
|
|
||||||
.existing-files-section {
|
.existing-files-section {
|
||||||
border-top: 1px solid #e0e0e0;
|
border-top: 1px solid #e0e0e0;
|
||||||
padding-top: 16px;
|
padding-top: 6px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.download-icon {
|
.download-icon {
|
||||||
@@ -424,8 +448,6 @@ export default {
|
|||||||
|
|
||||||
.close-icon:hover {
|
.close-icon:hover {
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
color: #024e45 ;
|
color: #024e45;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
@@ -4,25 +4,37 @@
|
|||||||
<mini-calendar />
|
<mini-calendar />
|
||||||
</v-col>
|
</v-col>
|
||||||
<v-col class="d-flex flex-column">
|
<v-col class="d-flex flex-column">
|
||||||
<custom-calendar @openEventDialog="openEventDialog" />
|
<custom-calendar
|
||||||
|
:key="calendarKey"
|
||||||
|
@openEventDialog="openEventDialog"
|
||||||
|
@openEventView="openEventView"
|
||||||
|
/>
|
||||||
</v-col>
|
</v-col>
|
||||||
|
|
||||||
<v-dialog v-model="showEventDialog" max-width="700">
|
<v-dialog v-model="showEventDialog" max-width="700">
|
||||||
<event-create
|
<event-create
|
||||||
@closeDialog="closeEventDialog"
|
@closeDialog="closeEventDialog"
|
||||||
:eventCalendar="eventFromCalendar"
|
:eventCalendar="eventFromCalendar"
|
||||||
:myCalendars="calendarStore.myCalendars"
|
:allCalendars="allCalendars"
|
||||||
@getCalendar="getCalendar"
|
@getCalendar="getCalendar"
|
||||||
@update:eventCalendar="eventFromCalendar = $event"
|
@update:eventCalendar="eventFromCalendar = $event"
|
||||||
ref="createEvents"
|
ref="createEvents"
|
||||||
:key="eventKey"
|
:key="eventKey"
|
||||||
/>
|
/>
|
||||||
</v-dialog>
|
</v-dialog>
|
||||||
|
|
||||||
|
<event-calendar-show
|
||||||
|
v-model:show="showViewDialog"
|
||||||
|
:all-calendars="allCalendars"
|
||||||
|
:event-data="selectedEventForView"
|
||||||
|
@close="handleViewDialogClose"
|
||||||
|
:employees="calendarStore.employees"
|
||||||
|
/>
|
||||||
</v-row>
|
</v-row>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { ref, onMounted, watch } from 'vue';
|
import { ref, onMounted, watch, computed } from 'vue';
|
||||||
import { useWeekendsStore } from '@/store/WeekendsStore';
|
import { useWeekendsStore } from '@/store/WeekendsStore';
|
||||||
import EventCreate from '@/components/calendar_of_events/event-create.vue';
|
import EventCreate from '@/components/calendar_of_events/event-create.vue';
|
||||||
import CustomCalendar from '@/components/calendar_of_events/UI_calendar/CustomCalendar.vue';
|
import CustomCalendar from '@/components/calendar_of_events/UI_calendar/CustomCalendar.vue';
|
||||||
@@ -31,9 +43,10 @@ import { storeToRefs } from 'pinia';
|
|||||||
import MiniCalendar from '@/components/calendar_of_events/UI_calendar/MiniCalendar.vue';
|
import MiniCalendar from '@/components/calendar_of_events/UI_calendar/MiniCalendar.vue';
|
||||||
import { axiosApiInstance } from '@/utils/axios-api';
|
import { axiosApiInstance } from '@/utils/axios-api';
|
||||||
import { useAccountStore } from '@/store/AccountStore';
|
import { useAccountStore } from '@/store/AccountStore';
|
||||||
|
import EventCalendarShow from '@/components/calendar_of_events/event-calendar-show.vue';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: { EventCreate, MiniCalendar, CustomCalendar },
|
components: { EventCreate, MiniCalendar, CustomCalendar, EventCalendarShow },
|
||||||
setup() {
|
setup() {
|
||||||
const week = useWeekendsStore();
|
const week = useWeekendsStore();
|
||||||
const selectdate = ref(new Date());
|
const selectdate = ref(new Date());
|
||||||
@@ -42,10 +55,12 @@ export default {
|
|||||||
const calendarForMy = ref([]);
|
const calendarForMy = ref([]);
|
||||||
const eventFromCalendar = ref({});
|
const eventFromCalendar = ref({});
|
||||||
const eventKey = ref(0);
|
const eventKey = ref(0);
|
||||||
const isClosingDialog = ref(false);
|
const calendarKey = ref(0);
|
||||||
|
|
||||||
const calendarStore = useCalendarStore();
|
const calendarStore = useCalendarStore();
|
||||||
const accountStore = useAccountStore();
|
const accountStore = useAccountStore();
|
||||||
|
const showViewDialog = ref(false);
|
||||||
|
const selectedEventForView = ref({});
|
||||||
|
|
||||||
const { selectedDate, showEventDialog } = storeToRefs(calendarStore); // синхронизируем с date-picker
|
const { selectedDate, showEventDialog } = storeToRefs(calendarStore); // синхронизируем с date-picker
|
||||||
|
|
||||||
@@ -60,6 +75,19 @@ export default {
|
|||||||
calendarStore.loadCalendars();
|
calendarStore.loadCalendars();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getDictEmployee = () => {
|
||||||
|
calendarStore.loadDictEmployees();
|
||||||
|
};
|
||||||
|
|
||||||
|
const getEmployees = () => {
|
||||||
|
calendarStore.loadEmployees();
|
||||||
|
};
|
||||||
|
|
||||||
|
const allCalendars = computed(() => [
|
||||||
|
...calendarStore.myCalendars,
|
||||||
|
...calendarStore.subscribedCalendars,
|
||||||
|
]);
|
||||||
|
|
||||||
const getEvent = (idEvent) => {
|
const getEvent = (idEvent) => {
|
||||||
if (!idEvent) {
|
if (!idEvent) {
|
||||||
eventFromCalendar.value = createEmptyEvent();
|
eventFromCalendar.value = createEmptyEvent();
|
||||||
@@ -99,6 +127,9 @@ export default {
|
|||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
getEvent();
|
getEvent();
|
||||||
week.getWeekend(MyYear.value);
|
week.getWeekend(MyYear.value);
|
||||||
|
getDictEmployee();
|
||||||
|
getCalendar();
|
||||||
|
getEmployees();
|
||||||
});
|
});
|
||||||
|
|
||||||
const closeEventDialog = () => {
|
const closeEventDialog = () => {
|
||||||
@@ -135,6 +166,41 @@ export default {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => accountStore.user?.id,
|
||||||
|
(newUserId, oldUserId) => {
|
||||||
|
if (newUserId !== oldUserId) {
|
||||||
|
console.log('User changed, forcing calendar recreation...');
|
||||||
|
calendarKey.value += 1; // Изменяем key для пересоздания компонента
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
const getEventForView = (idEvent) => {
|
||||||
|
if (!idEvent) {
|
||||||
|
selectedEventForView.value = {};
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
axiosApiInstance.get(`api/calendar_of_events/my_events/?id=${idEvent}`).then((res) => {
|
||||||
|
selectedEventForView.value = res.data;
|
||||||
|
showViewDialog.value = true;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const openEventView = (eventId) => {
|
||||||
|
if (eventId) {
|
||||||
|
getEventForView(eventId);
|
||||||
|
} else {
|
||||||
|
console.log('❌ No event ID provided');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Закрытие модалки
|
||||||
|
const handleViewDialogClose = () => {
|
||||||
|
showViewDialog.value = false;
|
||||||
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
selectedDate,
|
selectedDate,
|
||||||
getMonth,
|
getMonth,
|
||||||
@@ -152,6 +218,14 @@ export default {
|
|||||||
openEventDialog,
|
openEventDialog,
|
||||||
createEmptyEvent,
|
createEmptyEvent,
|
||||||
eventKey,
|
eventKey,
|
||||||
|
getDictEmployee,
|
||||||
|
openEventView,
|
||||||
|
handleViewDialogClose,
|
||||||
|
showViewDialog,
|
||||||
|
selectedEventForView,
|
||||||
|
allCalendars,
|
||||||
|
eventKey,
|
||||||
|
calendarKey,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,12 +1,14 @@
|
|||||||
<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-col md="4" class="flex-grow-0 d-flex align-center">
|
<v-row no-gutters class="mb-2 align-end" style="height: 60px" justify="space-between">
|
||||||
|
<v-col md="5" class="flex-grow-0 d-flex align-center">
|
||||||
|
<template v-if="currentView !== 'listAllEvents'">
|
||||||
|
<div class="pb-3 d-flex align-center">
|
||||||
<v-btn
|
<v-btn
|
||||||
v-show="!forHomePage"
|
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
class="text-subtitle-2 mr-2"
|
class="text-subtitle-2 mr-2"
|
||||||
@click="handleToday"
|
@click="handleToday"
|
||||||
@@ -35,17 +37,25 @@
|
|||||||
>
|
>
|
||||||
<v-icon size="large">mdi-chevron-right</v-icon>
|
<v-icon size="large">mdi-chevron-right</v-icon>
|
||||||
</v-btn>
|
</v-btn>
|
||||||
<span v-if="!forHomePage" class="text-h6 text-no-wrap ml-2">
|
|
||||||
{{ currentTitle }}
|
<span class="text-h5 text-no-wrap ml-2">
|
||||||
</span>
|
|
||||||
<span v-else class="text-caption text-no-wrap ml-2">
|
|
||||||
{{ currentTitle }}
|
{{ currentTitle }}
|
||||||
</span>
|
</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
<!-- Фильтры для кастомного вида -->
|
||||||
|
<EventListFilters
|
||||||
|
:date-range="filters.dateRange.value"
|
||||||
|
:sort-order="filters.sortOrder.value"
|
||||||
|
:sort-options="filters.sortOptions"
|
||||||
|
@update:filters="handleFiltersUpdate"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
</v-col>
|
</v-col>
|
||||||
|
|
||||||
<v-col class="flex-grow-0 d-flex justify-end">
|
<v-col class="flex-grow-0 d-flex justify-end">
|
||||||
<v-btn-toggle
|
<v-btn-toggle
|
||||||
v-show="!forHomePage"
|
|
||||||
v-model="currentView"
|
v-model="currentView"
|
||||||
mandatory
|
mandatory
|
||||||
divided
|
divided
|
||||||
@@ -57,12 +67,21 @@
|
|||||||
<v-btn value="dayGridMonth">Месяц</v-btn>
|
<v-btn value="dayGridMonth">Месяц</v-btn>
|
||||||
<v-btn value="multiMonthYear">Год</v-btn>
|
<v-btn value="multiMonthYear">Год</v-btn>
|
||||||
<v-btn value="listWeek">Расписание</v-btn>
|
<v-btn value="listWeek">Расписание</v-btn>
|
||||||
|
<v-btn value="listAllEvents">Все события</v-btn>
|
||||||
</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
|
||||||
|
v-if="currentView !== 'listAllEvents'"
|
||||||
|
ref="calendarRef"
|
||||||
|
:options="calendarOptions"
|
||||||
|
class="custom-calendar"
|
||||||
|
/>
|
||||||
|
<!-- Кастомный список событий -->
|
||||||
|
<EventsListView v-else @event-click="handleEventClick" :filters="unwrappedFilters" />
|
||||||
</div>
|
</div>
|
||||||
</v-card-text>
|
</v-card-text>
|
||||||
</v-card>
|
</v-card>
|
||||||
@@ -81,33 +100,46 @@ import rrulePlugin from '@fullcalendar/rrule';
|
|||||||
import { onMounted } from 'vue';
|
import { onMounted } from 'vue';
|
||||||
import { useCalendarStore } from '@/store/calendarStore';
|
import { useCalendarStore } from '@/store/calendarStore';
|
||||||
import { useRecurrence } from '@/components/calendar_of_events/composables/useReccurrence';
|
import { useRecurrence } from '@/components/calendar_of_events/composables/useReccurrence';
|
||||||
|
import { useAccountStore } from '@/store/AccountStore';
|
||||||
|
import EventsListView from './EventsListView.vue';
|
||||||
|
import EventListFilters from './EventListFilters.vue';
|
||||||
|
import { useEventListFilters } from '../composables/useEventListFilters';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'CustomCalendar',
|
name: 'CustomCalendar',
|
||||||
props: {
|
|
||||||
view: {
|
emits: ['openEventDialog', 'openEventView'],
|
||||||
type: String,
|
components: {
|
||||||
default: '',
|
EventsListView,
|
||||||
|
EventListFilters,
|
||||||
},
|
},
|
||||||
forHomePage: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
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 accountStore = useAccountStore();
|
||||||
|
|
||||||
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 { isRecurringEvent, generateRecurringInstances } = useRecurrence();
|
||||||
|
|
||||||
|
const calendarApi = computed(() => {
|
||||||
|
return calendarRef.value?.getApi?.() || null;
|
||||||
|
});
|
||||||
|
|
||||||
|
const filters = useEventListFilters();
|
||||||
|
|
||||||
|
// Создаем развернутую версию фильтров для передачи в EventsListView
|
||||||
|
const unwrappedFilters = computed(() => ({
|
||||||
|
dateRange: filters.dateRange.value,
|
||||||
|
sortOrder: filters.sortOrder.value,
|
||||||
|
}));
|
||||||
|
|
||||||
const handleEventClick = (info) => {
|
const handleEventClick = (info) => {
|
||||||
if (calendarStore.canEditEvent(info.event.id)) {
|
if (calendarStore.canEditEvent(info.event.id)) {
|
||||||
emit('openEventDialog', info);
|
emit('openEventDialog', info);
|
||||||
|
} else {
|
||||||
|
emit('openEventView', info.event.id);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -123,11 +155,19 @@ export default {
|
|||||||
initialView: props.forHomePage ? props.view : currentView.value,
|
initialView: props.forHomePage ? props.view : currentView.value,
|
||||||
locales: [ruLocale],
|
locales: [ruLocale],
|
||||||
locale: 'ru',
|
locale: 'ru',
|
||||||
|
timeZone: 'local',
|
||||||
firstDay: 1,
|
firstDay: 1,
|
||||||
headerToolbar: false,
|
headerToolbar: false,
|
||||||
height: '80vh',
|
height: '80vh',
|
||||||
aspectRatio: 1.5,
|
aspectRatio: 1.5,
|
||||||
weekNumbers: true,
|
weekNumbers: true,
|
||||||
|
eventDisplay: 'block',
|
||||||
|
eventTimeFormat: {
|
||||||
|
hour: '2-digit',
|
||||||
|
minute: '2-digit',
|
||||||
|
hour12: false,
|
||||||
|
meridiem: false,
|
||||||
|
},
|
||||||
weekNumberFormat: {
|
weekNumberFormat: {
|
||||||
week: 'numeric',
|
week: 'numeric',
|
||||||
},
|
},
|
||||||
@@ -160,8 +200,7 @@ export default {
|
|||||||
hour12: false,
|
hour12: false,
|
||||||
meridiem: false,
|
meridiem: false,
|
||||||
},
|
},
|
||||||
allDaySlot: false,
|
allDaySlot: true,
|
||||||
allDaySlot: false,
|
|
||||||
slotMinTime: '07:00:00',
|
slotMinTime: '07:00:00',
|
||||||
slotMaxTime: '22:00:00',
|
slotMaxTime: '22:00:00',
|
||||||
expandRows: true,
|
expandRows: true,
|
||||||
@@ -179,8 +218,9 @@ export default {
|
|||||||
slotDuration: '01:00:00',
|
slotDuration: '01:00:00',
|
||||||
slotMinTime: '07:00:00',
|
slotMinTime: '07:00:00',
|
||||||
slotMaxTime: '22:00:00',
|
slotMaxTime: '22:00:00',
|
||||||
allDaySlot: false,
|
allDaySlot: true,
|
||||||
expandRows: true,
|
expandRows: true,
|
||||||
|
|
||||||
dayHeaderFormat: { weekday: 'short', day: 'numeric' },
|
dayHeaderFormat: { weekday: 'short', day: 'numeric' },
|
||||||
titleFormat: {
|
titleFormat: {
|
||||||
day: 'numeric',
|
day: 'numeric',
|
||||||
@@ -199,6 +239,12 @@ export default {
|
|||||||
return arg.num;
|
return arg.num;
|
||||||
},
|
},
|
||||||
weekText: 'Нед.',
|
weekText: 'Нед.',
|
||||||
|
eventTimeFormat: {
|
||||||
|
hour: '2-digit',
|
||||||
|
minute: '2-digit',
|
||||||
|
hour12: false,
|
||||||
|
omitZeroMinute: false,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
multiMonthYear: {
|
multiMonthYear: {
|
||||||
type: 'multiMonth',
|
type: 'multiMonth',
|
||||||
@@ -209,7 +255,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',
|
||||||
@@ -218,10 +264,57 @@ export default {
|
|||||||
listDaySideFormat: false,
|
listDaySideFormat: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
events: [],
|
events: function (fetchInfo, successCallback) {
|
||||||
|
const events = allEvents.value.flatMap((event) => {
|
||||||
|
const eventColor = calendarColorMap.value.get(event.calendar) || '#3788d8';
|
||||||
|
const startDate = new Date(event.date_start);
|
||||||
|
const endDate = new Date(event.date_end);
|
||||||
|
const isMultiDay = startDate.toDateString() !== endDate.toDateString();
|
||||||
|
|
||||||
|
if (isRecurringEvent(event)) {
|
||||||
|
return generateRecurringInstances(event, 52).map((instance) => ({
|
||||||
|
id: instance.id,
|
||||||
|
title: instance.title,
|
||||||
|
start: instance.start,
|
||||||
|
end: instance.end,
|
||||||
|
allDay: instance.allDay || isMultiDay,
|
||||||
|
textColor: '#ffffff',
|
||||||
|
backgroundColor: eventColor,
|
||||||
|
borderColor: eventColor,
|
||||||
|
extendedProps: {
|
||||||
|
...instance.extendedProps,
|
||||||
|
_userHash: accountStore.user?.id || 'anonymous',
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
} else {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
id: event.id,
|
||||||
|
title: event.name,
|
||||||
|
start: new Date(event.date_start),
|
||||||
|
end: new Date(event.date_end),
|
||||||
|
allDay: event.all_day,
|
||||||
|
textColor: '#ffffff',
|
||||||
|
backgroundColor: eventColor,
|
||||||
|
borderColor: eventColor,
|
||||||
|
allDay: isMultiDay,
|
||||||
|
extendedProps: {
|
||||||
|
originalEventId: event.id,
|
||||||
|
description: event.description,
|
||||||
|
participant: event.participant,
|
||||||
|
calendar: event.calendar,
|
||||||
|
files: event.files,
|
||||||
|
_userHash: accountStore.user?.id || 'anonymous',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
successCallback(events);
|
||||||
|
},
|
||||||
editable: true,
|
editable: true,
|
||||||
selectable: true,
|
selectable: true,
|
||||||
|
|
||||||
eventClick: handleEventClick,
|
eventClick: handleEventClick,
|
||||||
|
|
||||||
dateClick: (info) => {
|
dateClick: (info) => {
|
||||||
@@ -258,46 +351,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,72 +397,43 @@ 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 = () => {
|
|
||||||
if (calendarRef.value) {
|
|
||||||
const api = calendarRef.value.getApi();
|
|
||||||
api.removeAllEvents();
|
|
||||||
allEvents.value.forEach((event) => {
|
|
||||||
const eventColor = calendarColorMap.value.get(event.calendar) || '#3788d8';
|
|
||||||
const rruleOptions = isRecurringEvent(event)
|
|
||||||
? parseRecurrenceOptions(event.period, event.date_start)
|
|
||||||
: null;
|
|
||||||
|
|
||||||
const baseEvent = {
|
|
||||||
id: event.id,
|
|
||||||
title: event.name,
|
|
||||||
start:new Date(event.date_start),
|
|
||||||
end: new Date(event.date_end),
|
|
||||||
allDay: event.all_day,
|
|
||||||
textColor: '#ffffff',
|
|
||||||
backgroundColor: eventColor,
|
|
||||||
borderColor: eventColor,
|
|
||||||
};
|
|
||||||
if (!rruleOptions) {
|
|
||||||
api.addEvent(baseEvent);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
api.addEvent({
|
|
||||||
...baseEvent,
|
|
||||||
rrule: {
|
|
||||||
...rruleOptions,
|
|
||||||
},
|
|
||||||
extendedProps: {
|
|
||||||
originalEvent: event,
|
|
||||||
isRecurring: true,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
nextTick(() => {
|
|
||||||
if (calendarRef.value && calendarRef.value.getApi) {
|
|
||||||
calendarApi.value = calendarRef.value.getApi();
|
|
||||||
updateCalendarEvents();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (selectedDate.value != undefined && selectedDate.value) {
|
|
||||||
handleDateSelection(selectedDate.value);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
const currentYear = new Date().getFullYear();
|
const currentYear = new Date().getFullYear();
|
||||||
calendarStore.fetchHolidays(currentYear);
|
calendarStore.fetchHolidays(currentYear);
|
||||||
|
// Ждем следующего тика для гарантии, что календарь инициализирован
|
||||||
|
await nextTick();
|
||||||
|
|
||||||
|
// Принудительно обновляем события после загрузки праздников
|
||||||
|
if (calendarApi.value) {
|
||||||
|
calendarApi.value.refetchEvents();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (selectedDate.value) {
|
||||||
|
handleDateSelection(selectedDate.value);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
watch(
|
||||||
|
allEvents,
|
||||||
|
() => {
|
||||||
|
// При изменении событий перезагружаем календарь
|
||||||
|
if (calendarApi.value) {
|
||||||
|
calendarApi.value.refetchEvents();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ deep: true },
|
||||||
|
);
|
||||||
|
|
||||||
|
watch(
|
||||||
|
calendarColorMap,
|
||||||
|
(newColorMap, oldColorMap) => {
|
||||||
|
if (calendarRef.value && JSON.stringify(newColorMap) !== JSON.stringify(oldColorMap)) {
|
||||||
|
renderEvents();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ deep: true },
|
||||||
|
);
|
||||||
|
|
||||||
watch(selectedDate, (newDate) => {
|
watch(selectedDate, (newDate) => {
|
||||||
if (newDate && calendarApi.value && lastUpdatedBy.value !== 'calendar') {
|
if (newDate && calendarApi.value && lastUpdatedBy.value !== 'calendar') {
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
@@ -390,35 +444,33 @@ export default {
|
|||||||
});
|
});
|
||||||
|
|
||||||
watch(currentView, (newView) => {
|
watch(currentView, (newView) => {
|
||||||
if (calendarApi.value) {
|
if (newView === 'listAllEvents') {
|
||||||
|
currentTitle.value = 'Все события';
|
||||||
|
} else if (calendarApi.value) {
|
||||||
calendarApi.value.changeView(newView);
|
calendarApi.value.changeView(newView);
|
||||||
|
currentTitle.value = calendarApi.value.view.title;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
watch(
|
const handleFiltersUpdate = (newFilters) => {
|
||||||
[allEvents],
|
Object.keys(newFilters).forEach((key) => {
|
||||||
([newEvents]) => {
|
if (filters[key] !== undefined) {
|
||||||
if (newEvents.length > 0) {
|
filters[key].value = newFilters[key];
|
||||||
updateCalendarEvents();
|
|
||||||
}
|
}
|
||||||
},
|
});
|
||||||
{ deep: true, immediate: true },
|
};
|
||||||
);
|
|
||||||
|
|
||||||
watch(
|
// Сброс фильтров при выходе из кастомного вида
|
||||||
() => props.eventCalendar,
|
watch(currentView, (newView, oldView) => {
|
||||||
(newEvent) => {
|
if (oldView === 'listAllEvents' && newView !== 'listAllEvents') {
|
||||||
if (calendarRef.value) {
|
filters.resetFilters();
|
||||||
const api = calendarRef.value.getApi();
|
|
||||||
api.refetchEvents(); // Обновляем события в календаре
|
|
||||||
}
|
}
|
||||||
},
|
});
|
||||||
{ deep: true },
|
|
||||||
);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
currentTitle,
|
currentTitle,
|
||||||
calendarRef,
|
calendarRef,
|
||||||
|
calendarApi,
|
||||||
currentView,
|
currentView,
|
||||||
calendarOptions,
|
calendarOptions,
|
||||||
handleToday,
|
handleToday,
|
||||||
@@ -426,9 +478,11 @@ export default {
|
|||||||
handlePrev,
|
handlePrev,
|
||||||
handleCalendarDateClick,
|
handleCalendarDateClick,
|
||||||
handleDateSelection,
|
handleDateSelection,
|
||||||
updateCalendarEvents,
|
|
||||||
handleEventClick,
|
handleEventClick,
|
||||||
calendarStore,
|
calendarStore,
|
||||||
|
filters,
|
||||||
|
handleFiltersUpdate,
|
||||||
|
unwrappedFilters,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -496,8 +550,8 @@ export default {
|
|||||||
:deep(.fc-multiMonthYear-view) {
|
:deep(.fc-multiMonthYear-view) {
|
||||||
.fc-day-today .fc-daygrid-day-number::before,
|
.fc-day-today .fc-daygrid-day-number::before,
|
||||||
.fc-day-selected-custom .fc-daygrid-day-number::before {
|
.fc-day-selected-custom .fc-daygrid-day-number::before {
|
||||||
width: 24px;
|
width: 26px;
|
||||||
height: 24px;
|
height: 26px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -513,7 +567,8 @@ export default {
|
|||||||
:deep(.fc-highlight) {
|
:deep(.fc-highlight) {
|
||||||
background-color: transparent !important;
|
background-color: transparent !important;
|
||||||
}
|
}
|
||||||
:deep(.fc-day) {
|
:deep(.fc-day),
|
||||||
|
:deep(.fc-list-event-title) {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -540,4 +595,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>
|
||||||
@@ -0,0 +1,302 @@
|
|||||||
|
<template>
|
||||||
|
<div class="event-list-filters d-flex align-end ga-3">
|
||||||
|
<!-- Диапазон дат -->
|
||||||
|
<div class="date-range-group justify-center">
|
||||||
|
<div class="date-range-label">Выбрать период событий</div>
|
||||||
|
<div class="date-inputs d-flex align-center gap-2">
|
||||||
|
<!-- Дата начала -->
|
||||||
|
<v-menu :close-on-content-click="false" scrim>
|
||||||
|
<template v-slot:activator="{ props }">
|
||||||
|
<v-text-field
|
||||||
|
v-bind="props"
|
||||||
|
:model-value="formatDateDisplay(startDate)"
|
||||||
|
placeholder="Начало"
|
||||||
|
density="compact"
|
||||||
|
variant="outlined"
|
||||||
|
prepend-inner-icon="mdi-calendar-arrow-left"
|
||||||
|
readonly
|
||||||
|
hide-details
|
||||||
|
class="date-input compact-field"
|
||||||
|
:class="{ active: startDate }"
|
||||||
|
>
|
||||||
|
</v-text-field>
|
||||||
|
</template>
|
||||||
|
<v-locale-provider locale="ru">
|
||||||
|
<v-date-picker hide-header show-adjacent-months v-model="startDate" />
|
||||||
|
</v-locale-provider>
|
||||||
|
</v-menu>
|
||||||
|
|
||||||
|
<div class="date-separator">
|
||||||
|
<v-icon size="small" color="grey">mdi-arrow-right</v-icon>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Дата окончания -->
|
||||||
|
<v-menu :close-on-content-click="false" scrim>
|
||||||
|
<template v-slot:activator="{ props }">
|
||||||
|
<v-text-field
|
||||||
|
v-bind="props"
|
||||||
|
:model-value="formatDateDisplay(endDate)"
|
||||||
|
density="compact"
|
||||||
|
variant="outlined"
|
||||||
|
placeholder="Конец"
|
||||||
|
prepend-inner-icon="mdi-calendar-arrow-right"
|
||||||
|
readonly
|
||||||
|
hide-details
|
||||||
|
class="date-input compact-field"
|
||||||
|
:class="{ active: endDate }"
|
||||||
|
:disabled="!startDate"
|
||||||
|
>
|
||||||
|
</v-text-field>
|
||||||
|
</template>
|
||||||
|
<v-locale-provider locale="ru">
|
||||||
|
<v-date-picker v-model="endDate" :min="startDate" hide-header show-adjacent-months />
|
||||||
|
</v-locale-provider>
|
||||||
|
</v-menu>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Сортировка -->
|
||||||
|
<v-select
|
||||||
|
v-model="localSortOrder"
|
||||||
|
:items="sortOptions"
|
||||||
|
density="compact"
|
||||||
|
variant="outlined"
|
||||||
|
hide-details
|
||||||
|
class="sort-select compact-field"
|
||||||
|
style="min-width: 160px"
|
||||||
|
>
|
||||||
|
<template v-slot:item="{ item, props: itemProps }">
|
||||||
|
<v-list-item v-bind="itemProps" density="compact">
|
||||||
|
<template v-slot:prepend>
|
||||||
|
<v-icon :icon="item.raw.props.prependIcon" size="small" />
|
||||||
|
</template>
|
||||||
|
</v-list-item>
|
||||||
|
</template>
|
||||||
|
</v-select>
|
||||||
|
|
||||||
|
<!-- Сброс фильтров -->
|
||||||
|
<v-btn
|
||||||
|
class="mb-1"
|
||||||
|
variant="text"
|
||||||
|
@click="handleReset"
|
||||||
|
:disabled="!hasActiveFilters"
|
||||||
|
size="small"
|
||||||
|
>
|
||||||
|
Сбросить
|
||||||
|
</v-btn>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { computed, watch } from 'vue';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'EventListFilters',
|
||||||
|
props: {
|
||||||
|
dateRange: Array,
|
||||||
|
sortOrder: String,
|
||||||
|
sortOptions: Array,
|
||||||
|
},
|
||||||
|
emits: ['update:filters'],
|
||||||
|
|
||||||
|
setup(props, { emit }) {
|
||||||
|
const startDate = computed({
|
||||||
|
get: () => props.dateRange?.[0] || null,
|
||||||
|
set: (value) => {
|
||||||
|
const newRange = value ? [value, props.dateRange?.[1] || null] : null;
|
||||||
|
emit('update:filters', { dateRange: newRange });
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const endDate = computed({
|
||||||
|
get: () => props.dateRange?.[1] || null,
|
||||||
|
set: (value) => {
|
||||||
|
const newRange = props.dateRange?.[0] ? [props.dateRange[0], value] : null;
|
||||||
|
emit('update:filters', { dateRange: newRange });
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const localSortOrder = computed({
|
||||||
|
get: () => props.sortOrder,
|
||||||
|
set: (value) => emit('update:filters', { sortOrder: value }),
|
||||||
|
});
|
||||||
|
|
||||||
|
// Автоматически устанавливаем конец даты = начало, если конец не выбран
|
||||||
|
watch(startDate, (newStart) => {
|
||||||
|
if (newStart && !endDate.value) {
|
||||||
|
endDate.value = newStart;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const formatDateDisplay = (date) => {
|
||||||
|
if (!date) return '';
|
||||||
|
return new Date(date).toLocaleDateString('ru-RU');
|
||||||
|
};
|
||||||
|
|
||||||
|
const hasActiveFilters = computed(() => {
|
||||||
|
return props.dateRange && props.dateRange.length === 2;
|
||||||
|
});
|
||||||
|
|
||||||
|
const handleReset = () => {
|
||||||
|
emit('update:filters', {
|
||||||
|
dateRange: null,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
startDate,
|
||||||
|
endDate,
|
||||||
|
localSortOrder,
|
||||||
|
formatDateDisplay,
|
||||||
|
hasActiveFilters,
|
||||||
|
handleReset,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.event-list-filters {
|
||||||
|
min-height: 50px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.date-range-group {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sort-select :deep(.v-field) {
|
||||||
|
border-radius: 4px;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sort-select :deep(.v-field__prepend-inner) {
|
||||||
|
padding-inline-start: 8px;
|
||||||
|
padding-top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.date-range-btn {
|
||||||
|
border-radius: 8px;
|
||||||
|
border: 1px solid rgba(0, 0, 0, 0.12);
|
||||||
|
height: 40px;
|
||||||
|
min-width: 200px;
|
||||||
|
padding: 0 16px;
|
||||||
|
transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
|
||||||
|
background: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.date-range-btn:hover {
|
||||||
|
border-color: rgb(var(--v-theme-primary));
|
||||||
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
||||||
|
transform: translateY(-1px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.date-range-btn.active-filter {
|
||||||
|
background-color: rgba(var(--v-theme-primary), 0.04);
|
||||||
|
border-color: rgb(var(--v-theme-primary));
|
||||||
|
color: rgb(var(--v-theme-primary));
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-content {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: flex-start;
|
||||||
|
line-height: 1.2;
|
||||||
|
flex-grow: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-label {
|
||||||
|
font-size: 0.75rem;
|
||||||
|
font-weight: 500;
|
||||||
|
color: rgba(0, 0, 0, 0.6);
|
||||||
|
margin-bottom: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-value {
|
||||||
|
font-size: 0.875rem;
|
||||||
|
font-weight: 500;
|
||||||
|
color: rgba(0, 0, 0, 0.87);
|
||||||
|
}
|
||||||
|
|
||||||
|
.date-range-btn.active-filter .btn-value {
|
||||||
|
color: rgb(var(--v-theme-primary));
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.date-range-label {
|
||||||
|
font-size: 1rem;
|
||||||
|
|
||||||
|
margin-left: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Убираем стандартные стили Vuetify для более кастомного вида */
|
||||||
|
.date-range-btn :deep(.v-btn__prepend) {
|
||||||
|
margin-inline-end: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.date-range-btn :deep(.v-btn__content) {
|
||||||
|
flex-grow: 1;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.date-input {
|
||||||
|
min-width: 120px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Выравнивание по высоте */
|
||||||
|
.date-input :deep(.v-field),
|
||||||
|
.sort-select :deep(.v-field),
|
||||||
|
.reset-control :deep(.v-btn) {
|
||||||
|
height: 40px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Убираем проблему с закрытием date-picker */
|
||||||
|
:deep(.v-overlay__content) {
|
||||||
|
border-radius: 8px;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.v-date-picker-controls) {
|
||||||
|
padding: 4px 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.v-date-picker-month) {
|
||||||
|
padding: 0 8px 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.compact-field :deep(.v-field) {
|
||||||
|
border-radius: 5px;
|
||||||
|
cursor: pointer;
|
||||||
|
height: 36px;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
padding-left: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Уменьшаем отступы у иконки */
|
||||||
|
.compact-field :deep(.v-field__prepend-inner) {
|
||||||
|
height: 39px;
|
||||||
|
padding-inline-start: 0;
|
||||||
|
margin-inline-end: 4px; /* Уменьшили отступ после иконки */
|
||||||
|
}
|
||||||
|
|
||||||
|
.compact-field :deep(.v-field__prepend-inner .v-icon) {
|
||||||
|
font-size: 16px;
|
||||||
|
opacity: 0.7; /* Делаем иконку менее заметной */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Увеличиваем область текста */
|
||||||
|
.compact-field :deep(.v-field__input) {
|
||||||
|
padding-inline-start: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sort-select {
|
||||||
|
width: 170px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sort-select :deep(.v-field) {
|
||||||
|
padding: 0 6px ;
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,348 @@
|
|||||||
|
<template>
|
||||||
|
<div class="list-all-events d-flex flex-column" style="height: 100%">
|
||||||
|
<!-- Фильтры - растянуты на всю ширину -->
|
||||||
|
<div class="filters pa-6 flex-grow-0 mt-1">
|
||||||
|
<v-row class="flex-nowrap">
|
||||||
|
<v-col class="flex-grow-1 pa-0">
|
||||||
|
<v-select
|
||||||
|
v-model="selectedCalendar"
|
||||||
|
:items="calendarOptions"
|
||||||
|
density="compact"
|
||||||
|
label="Календарь"
|
||||||
|
variant="outlined"
|
||||||
|
hide-details
|
||||||
|
class="w-100"
|
||||||
|
/>
|
||||||
|
</v-col>
|
||||||
|
</v-row>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Статистика -->
|
||||||
|
<div class="px-3 pb-2 text-body-2 text-medium-emphasis flex-grow-0">
|
||||||
|
Найдено событий: {{ filteredEvents.length }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Список событий - растянут на всю оставшуюся высоту -->
|
||||||
|
<div class="events-list flex-grow-1" style="overflow-y: auto">
|
||||||
|
<div
|
||||||
|
v-for="event in filteredEvents"
|
||||||
|
:key="event.id"
|
||||||
|
class="event-item pa-3 mb-3"
|
||||||
|
:style="{ borderLeft: `4px solid ${getEventColor(event)}` }"
|
||||||
|
@click="handleItemClick(event)"
|
||||||
|
style="cursor: pointer; border-bottom: 1px solid #e0e0e0; width: 100%"
|
||||||
|
>
|
||||||
|
<div class="event-date text-subtitle-2 pb-3">
|
||||||
|
{{ formatEventDate(event) }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="event-content">
|
||||||
|
<div class="event-title d-flex align-center">
|
||||||
|
<span class="font-weight-medium">{{ event.name }}</span>
|
||||||
|
<v-chip
|
||||||
|
v-if="isRecurringEvent(event)"
|
||||||
|
:prepend-icon="getRecurrenceIcon(event.period)"
|
||||||
|
size="x-small"
|
||||||
|
color="primary"
|
||||||
|
class="ml-2"
|
||||||
|
variant="outlined"
|
||||||
|
>
|
||||||
|
{{ getRecurrenceText(event) }}
|
||||||
|
</v-chip>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="event-meta text-subtitle-2 text-medium-emphasis">
|
||||||
|
<span class="calendar-badge" :style="{ color: getEventColor(event) }">
|
||||||
|
{{ getCalendarName(event.calendar) }}
|
||||||
|
</span>
|
||||||
|
•
|
||||||
|
{{ formatEventTime(event) }}
|
||||||
|
•
|
||||||
|
{{ formatDuration(event) }}
|
||||||
|
|
||||||
|
<span v-if="isRecurringEvent(event)" class="ml-1">
|
||||||
|
• {{ getRecurrenceDetails(event) }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-if="event.description" class="event-description text-subtitle-1 mt-1">
|
||||||
|
{{ truncateDescription(event.description) }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-if="filteredEvents.length === 0" class="text-center pa-8 text-medium-emphasis">
|
||||||
|
{{ getEmptyStateMessage() }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { ref, computed } from 'vue';
|
||||||
|
import { useCalendarStore } from '@/store/calendarStore';
|
||||||
|
import { RRule } from 'rrule';
|
||||||
|
import { useRecurrence } from '@/components/calendar_of_events/composables/useReccurrence.js';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'EventsListView',
|
||||||
|
emits: ['event-click'],
|
||||||
|
props: {
|
||||||
|
filters: {
|
||||||
|
type: Object,
|
||||||
|
required: true,
|
||||||
|
default: () => ({
|
||||||
|
dateRange: null,
|
||||||
|
sortOrder: 'asc',
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
setup(props, { emit }) {
|
||||||
|
const { isRecurringEvent, formatRecurrenceText, getRecurrenceIcon } = useRecurrence();
|
||||||
|
const calendarStore = useCalendarStore();
|
||||||
|
|
||||||
|
// Локальное состояние для фильтра календаря
|
||||||
|
const selectedCalendar = ref(null);
|
||||||
|
|
||||||
|
// Подготовка данных
|
||||||
|
const flattenedEvents = computed(() => {
|
||||||
|
return calendarStore.allEvents
|
||||||
|
.map((event) => ({
|
||||||
|
...event,
|
||||||
|
startDate: new Date(event.date_start),
|
||||||
|
endDate: new Date(event.date_end),
|
||||||
|
}))
|
||||||
|
.sort((a, b) => a.startDate - b.startDate);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Опции для селекта календарей
|
||||||
|
const calendarOptions = computed(() => {
|
||||||
|
const baseOptions = [{ title: 'Все календари', value: null }];
|
||||||
|
const activeCalendars = calendarStore.calendars
|
||||||
|
.filter((calendar) => !calendarStore.hiddenCalendarIds.includes(calendar.id))
|
||||||
|
.map((calendar) => ({
|
||||||
|
title: calendar.cl_name,
|
||||||
|
value: calendar.id,
|
||||||
|
}));
|
||||||
|
|
||||||
|
return [...baseOptions, ...activeCalendars];
|
||||||
|
});
|
||||||
|
|
||||||
|
// Фильтрация событий
|
||||||
|
const filteredEvents = computed(() => {
|
||||||
|
let filtered = flattenedEvents.value;
|
||||||
|
|
||||||
|
// Фильтр по дате (из props)
|
||||||
|
if (
|
||||||
|
props.filters.dateRange &&
|
||||||
|
Array.isArray(props.filters.dateRange) &&
|
||||||
|
props.filters.dateRange.length === 2
|
||||||
|
) {
|
||||||
|
const [startDate, endDate] = props.filters.dateRange;
|
||||||
|
filtered = filtered.filter(
|
||||||
|
(event) => event.startDate >= startDate && event.endDate <= endDate,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Фильтр по календарю (локальный)
|
||||||
|
if (selectedCalendar.value) {
|
||||||
|
filtered = filtered.filter((event) => event.calendar === selectedCalendar.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Сортировка (из props)
|
||||||
|
filtered = [...filtered].sort((a, b) => {
|
||||||
|
return props.filters.sortOrder === 'asc'
|
||||||
|
? a.startDate - b.startDate
|
||||||
|
: b.startDate - a.startDate;
|
||||||
|
});
|
||||||
|
|
||||||
|
return filtered;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Вспомогательные функции
|
||||||
|
const getEventColor = (event) => {
|
||||||
|
return calendarStore.calendarColorMap.get(event.calendar) || '#3788d8';
|
||||||
|
};
|
||||||
|
|
||||||
|
const getCalendarName = (calendarId) => {
|
||||||
|
const calendar = calendarStore.calendars.find((c) => c.id === calendarId);
|
||||||
|
return calendar?.cl_name || 'Неизвестно';
|
||||||
|
};
|
||||||
|
|
||||||
|
const formatEventDate = (event) => {
|
||||||
|
const start = event.startDate;
|
||||||
|
const end = event.endDate;
|
||||||
|
|
||||||
|
// Если событие в один день
|
||||||
|
if (start.toDateString() === end.toDateString()) {
|
||||||
|
return start.toLocaleDateString('ru-RU', {
|
||||||
|
day: 'numeric',
|
||||||
|
month: 'long',
|
||||||
|
year: 'numeric',
|
||||||
|
weekday: 'short',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Если событие (диапазон)
|
||||||
|
const startFormatted = start.toLocaleDateString('ru-RU', {
|
||||||
|
day: 'numeric',
|
||||||
|
month: 'long',
|
||||||
|
weekday: 'short',
|
||||||
|
});
|
||||||
|
|
||||||
|
const endFormatted = end.toLocaleDateString('ru-RU', {
|
||||||
|
day: 'numeric',
|
||||||
|
month: 'long',
|
||||||
|
year: 'numeric',
|
||||||
|
weekday: 'short',
|
||||||
|
});
|
||||||
|
|
||||||
|
return `${startFormatted} – ${endFormatted}`;
|
||||||
|
};
|
||||||
|
|
||||||
|
const formatEventTime = (event) => {
|
||||||
|
if (event.all_day) return 'Весь день'; // Исправлено: было allday, должно быть all_day
|
||||||
|
|
||||||
|
const start = event.startDate.toLocaleTimeString('ru-RU', {
|
||||||
|
hour: '2-digit',
|
||||||
|
minute: '2-digit',
|
||||||
|
});
|
||||||
|
|
||||||
|
const end = event.endDate.toLocaleTimeString('ru-RU', {
|
||||||
|
hour: '2-digit',
|
||||||
|
minute: '2-digit',
|
||||||
|
});
|
||||||
|
|
||||||
|
return `${start} - ${end}`;
|
||||||
|
};
|
||||||
|
|
||||||
|
const formatDuration = (event) => {
|
||||||
|
const diff = event.endDate - event.startDate;
|
||||||
|
const hours = Math.floor(diff / (1000 * 60 * 60));
|
||||||
|
const minutes = Math.floor((diff % (1000 * 60 * 60)) / (1000 * 60));
|
||||||
|
|
||||||
|
if (hours === 0) return `${minutes} мин`;
|
||||||
|
if (minutes === 0) return `${hours} ч`;
|
||||||
|
return `${hours} ч ${minutes} мин`;
|
||||||
|
};
|
||||||
|
|
||||||
|
const truncateDescription = (desc) => {
|
||||||
|
if (!desc) return '';
|
||||||
|
return desc.length > 150 ? desc.substring(0, 150) + '...' : desc;
|
||||||
|
};
|
||||||
|
|
||||||
|
const getEmptyStateMessage = () => {
|
||||||
|
if (props.filters.searchQuery) {
|
||||||
|
// Исправлено: используем props.filters.searchQuery
|
||||||
|
return 'События по вашему запросу не найдены';
|
||||||
|
}
|
||||||
|
if (selectedCalendar.value) {
|
||||||
|
return 'В выбранном календаре нет событий';
|
||||||
|
}
|
||||||
|
if (props.filters.dateRange) {
|
||||||
|
return 'В выбранном диапазоне дат нет событий';
|
||||||
|
}
|
||||||
|
return 'Нет событий для отображения';
|
||||||
|
};
|
||||||
|
|
||||||
|
// Получаем текст повторения
|
||||||
|
const getRecurrenceText = (event) => {
|
||||||
|
return formatRecurrenceText(event.period, event.date_start) || '';
|
||||||
|
};
|
||||||
|
|
||||||
|
// Дополнительные детали о повторении
|
||||||
|
const getRecurrenceDetails = (event) => {
|
||||||
|
if (!isRecurringEvent(event)) return '';
|
||||||
|
|
||||||
|
try {
|
||||||
|
let rrule;
|
||||||
|
|
||||||
|
if (event.period.includes('RRULE:')) {
|
||||||
|
rrule = RRule.fromString(event.period);
|
||||||
|
} else {
|
||||||
|
const periodData = JSON.parse(event.period);
|
||||||
|
if (periodData?.origOptions) {
|
||||||
|
rrule = new RRule(periodData.origOptions);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!rrule || !rrule.origOptions.until) return '';
|
||||||
|
|
||||||
|
const untilDate = new Date(rrule.origOptions.until);
|
||||||
|
return `до ${untilDate.toLocaleDateString('ru-RU')}`;
|
||||||
|
} catch (error) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleItemClick = (event) => {
|
||||||
|
const eventInfo = {
|
||||||
|
event: {
|
||||||
|
id: event.id,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
emit('event-click', eventInfo);
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
// Реактивные данные
|
||||||
|
selectedCalendar,
|
||||||
|
|
||||||
|
// Вычисляемые свойства
|
||||||
|
filteredEvents,
|
||||||
|
calendarOptions,
|
||||||
|
|
||||||
|
// Методы
|
||||||
|
getEventColor,
|
||||||
|
getCalendarName,
|
||||||
|
formatEventDate,
|
||||||
|
formatEventTime,
|
||||||
|
formatDuration,
|
||||||
|
truncateDescription,
|
||||||
|
getEmptyStateMessage,
|
||||||
|
getRecurrenceText,
|
||||||
|
getRecurrenceDetails,
|
||||||
|
handleItemClick,
|
||||||
|
isRecurringEvent,
|
||||||
|
getRecurrenceIcon,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.list-all-events {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filters {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.events-list {
|
||||||
|
width: 100%;
|
||||||
|
height: 70vh;
|
||||||
|
overflow-y: scroll !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.event-item {
|
||||||
|
width: 100%;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.event-item:hover {
|
||||||
|
background-color: #f5f5f5;
|
||||||
|
transition: background-color 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Убедимся, что все элементы занимают всю ширину */
|
||||||
|
.v-col.pa-0 {
|
||||||
|
min-width: 0; /* Для правильного flexbox поведения */
|
||||||
|
}
|
||||||
|
|
||||||
|
.v-text-field,
|
||||||
|
.v-select {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -37,8 +37,6 @@
|
|||||||
}"
|
}"
|
||||||
@click="onDateClick(day.date)"
|
@click="onDateClick(day.date)"
|
||||||
>
|
>
|
||||||
|
|
||||||
|
|
||||||
<div class="day-content">
|
<div class="day-content">
|
||||||
<span class="day-number">{{ day.day }}</span>
|
<span class="day-number">{{ day.day }}</span>
|
||||||
<div class="day-events">
|
<div class="day-events">
|
||||||
@@ -59,7 +57,9 @@
|
|||||||
<!-- Дневное расписание -->
|
<!-- Дневное расписание -->
|
||||||
<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">
|
||||||
@@ -102,6 +102,7 @@
|
|||||||
import { ref, computed, onMounted, watch } from 'vue';
|
import { ref, computed, onMounted, watch } from 'vue';
|
||||||
import { storeToRefs } from 'pinia';
|
import { storeToRefs } from 'pinia';
|
||||||
import { useCalendarStore } from '@/store/calendarStore';
|
import { useCalendarStore } from '@/store/calendarStore';
|
||||||
|
import { useRecurrence } from '@/components/calendar_of_events/composables/useReccurrence';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'HomeCalendarWidget',
|
name: 'HomeCalendarWidget',
|
||||||
@@ -115,6 +116,7 @@ export default {
|
|||||||
// Работа с хранилищем
|
// Работа с хранилищем
|
||||||
const calendarStore = useCalendarStore();
|
const calendarStore = useCalendarStore();
|
||||||
const { allEvents, calendarColorMap } = storeToRefs(calendarStore);
|
const { allEvents, calendarColorMap } = storeToRefs(calendarStore);
|
||||||
|
const { generateRecurringInstances, isRecurringEvent } = useRecurrence();
|
||||||
|
|
||||||
// Утилиты для работы с датами (главный источник проблем!)
|
// Утилиты для работы с датами (главный источник проблем!)
|
||||||
const formatToLocalDate = (date) => {
|
const formatToLocalDate = (date) => {
|
||||||
@@ -134,25 +136,92 @@ export default {
|
|||||||
return getStartOfDay(date1).getTime() === getStartOfDay(date2).getTime();
|
return getStartOfDay(date1).getTime() === getStartOfDay(date2).getTime();
|
||||||
};
|
};
|
||||||
|
|
||||||
// Преобразование событий с защитой от ошибок
|
|
||||||
const events = computed(() => {
|
const events = computed(() => {
|
||||||
const userEvents = allEvents.value.map((event) => {
|
const expandedEvents = allEvents.value.flatMap((event) => {
|
||||||
const eventColor = calendarColorMap.value.get(event.calendar) || event.color || '#1976d2';
|
const startDate = new Date(event.date_start);
|
||||||
return {
|
const endDate = new Date(event.date_end);
|
||||||
id: event.id,
|
const isMultiDay = startDate.toDateString() !== endDate.toDateString();
|
||||||
title: event.name || event.title || 'Без названия',
|
const hasRecurrence = event.period && event.period !== 'null';
|
||||||
start: event.date_start || event.start,
|
|
||||||
end: event.date_end || event.end,
|
// 1. Периодичное + многодневное
|
||||||
description: event.description,
|
if (hasRecurrence && isMultiDay) {
|
||||||
color: eventColor || '#1976d2',
|
const instances = generateRecurringInstances(event, 12);
|
||||||
calendar: event.calendar,
|
return instances.flatMap((instance) => expandMultiDayInstance(event, instance));
|
||||||
isHoliday: false,
|
}
|
||||||
};
|
|
||||||
|
// 2. Периодичное + однодневное
|
||||||
|
if (hasRecurrence && !isMultiDay) {
|
||||||
|
const instances = generateRecurringInstances(event, 12);
|
||||||
|
return instances.map((instance) => ({
|
||||||
|
...event,
|
||||||
|
id: instance.id,
|
||||||
|
date_start: instance.date_start || instance.start,
|
||||||
|
date_end: instance.date_end || instance.end,
|
||||||
|
isRecurringInstance: true,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. Непериодичное + многодневное
|
||||||
|
if (!hasRecurrence && isMultiDay) {
|
||||||
|
return expandMultiDayInstance(event, event);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4. Непериодичное + однодневное
|
||||||
|
return event;
|
||||||
});
|
});
|
||||||
|
|
||||||
return [...userEvents];
|
return expandedEvents.map((event) => formatForWidget(event));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Разбивает многодневный экземпляр на дни
|
||||||
|
const expandMultiDayInstance = (originalEvent, instance) => {
|
||||||
|
const startDate = new Date(instance.date_start || instance.start);
|
||||||
|
const endDate = new Date(instance.date_end || instance.end);
|
||||||
|
const days = [];
|
||||||
|
const currentDay = new Date(startDate);
|
||||||
|
|
||||||
|
while (currentDay < endDate) {
|
||||||
|
const dayStart = new Date(currentDay);
|
||||||
|
const dayEnd = new Date(currentDay);
|
||||||
|
dayEnd.setDate(dayEnd.getDate() + 1);
|
||||||
|
|
||||||
|
days.push({
|
||||||
|
...originalEvent,
|
||||||
|
id: instance.id, // ID от экземпляра периодичности
|
||||||
|
date_start: dayStart.toISOString(),
|
||||||
|
date_end: dayEnd.toISOString(),
|
||||||
|
allday: true,
|
||||||
|
isMultiDayPart: true,
|
||||||
|
isRecurringInstance: instance.isRecurringInstance || false,
|
||||||
|
originalStart: instance.date_start || instance.start,
|
||||||
|
originalEnd: instance.date_end || instance.end,
|
||||||
|
});
|
||||||
|
|
||||||
|
currentDay.setDate(currentDay.getDate() + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return days;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Форматирование для виджета
|
||||||
|
const formatForWidget = (event) => {
|
||||||
|
const eventColor =
|
||||||
|
event.calendarData?.cl_color || calendarColorMap.value?.get(event.calendar) || '#1976d2';
|
||||||
|
|
||||||
|
return {
|
||||||
|
id: event.id,
|
||||||
|
title: event.name || 'Без названия',
|
||||||
|
start: event.date_start,
|
||||||
|
end: event.date_end,
|
||||||
|
description: event.description,
|
||||||
|
color: eventColor,
|
||||||
|
calendar: event.calendar,
|
||||||
|
calendarData: event.calendarData,
|
||||||
|
isRecurringInstance: event.isRecurringInstance || false,
|
||||||
|
isMultiDayPart: event.isMultiDayPart || false,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
const russianWeekdays = ['Пн', 'Вт', 'Ср', 'Чт', 'Пт', 'Сб', 'Вс'];
|
const russianWeekdays = ['Пн', 'Вт', 'Ср', 'Чт', 'Пт', 'Сб', 'Вс'];
|
||||||
|
|
||||||
// Генерация календаря
|
// Генерация календаря
|
||||||
@@ -316,6 +385,8 @@ export default {
|
|||||||
|
|
||||||
calendarStore,
|
calendarStore,
|
||||||
allEvents,
|
allEvents,
|
||||||
|
expandMultiDayInstance,
|
||||||
|
formatForWidget,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -529,6 +600,6 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.day-cell:not(.current-month).non-working-day {
|
.day-cell:not(.current-month).non-working-day {
|
||||||
color: inherit !important;
|
/* color: inherit !important; */
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -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"
|
||||||
@@ -22,9 +13,9 @@
|
|||||||
block
|
block
|
||||||
elevation="1"
|
elevation="1"
|
||||||
@click="openEventDialog"
|
@click="openEventDialog"
|
||||||
|
:disabled="!myCalendars || myCalendars.length === 0"
|
||||||
>Создать событие</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">
|
||||||
@@ -35,20 +26,25 @@
|
|||||||
hide-header
|
hide-header
|
||||||
show-adjacent-months
|
show-adjacent-months
|
||||||
@update:modelValue="handleDateClick"
|
@update:modelValue="handleDateClick"
|
||||||
|
@update:display="currentDisplay = $event"
|
||||||
>
|
>
|
||||||
</v-date-picker>
|
</v-date-picker>
|
||||||
</v-locale-provider>
|
</v-locale-provider>
|
||||||
</v-col>
|
</v-col>
|
||||||
|
|
||||||
<v-col class="flex-column d-flex">
|
<v-col class="flex-column d-flex">
|
||||||
<v-row no-gutters class="h-0 overflow-auto flex-column flex-nowrap">
|
<v-row no-gutters class=" overflow-hidden flex-column flex-nowrap">
|
||||||
<v-col>
|
<v-col>
|
||||||
<calendar-my
|
<calendar-my
|
||||||
:calendars="myCalendars"
|
:calendars="myCalendars"
|
||||||
title="Мои календари"
|
title="Мои календари"
|
||||||
@getCalendar="loadCalendars"
|
@getCalendar="loadCalendars"
|
||||||
/>
|
/>
|
||||||
<calendar-my :calendars="subscribedCalendars" title="Подписки" />
|
<calendar-my
|
||||||
|
:calendars="subscribedCalendars"
|
||||||
|
title="Подписки"
|
||||||
|
@getCalendar="loadCalendars"
|
||||||
|
/>
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
</v-col>
|
</v-col>
|
||||||
@@ -59,12 +55,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, ref } 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();
|
||||||
@@ -73,6 +70,8 @@ export default {
|
|||||||
|
|
||||||
const { user } = storeToRefs(accountStore);
|
const { user } = storeToRefs(accountStore);
|
||||||
|
|
||||||
|
const currentDisplay = ref(null);
|
||||||
|
|
||||||
const handleDateClick = (date) => {
|
const handleDateClick = (date) => {
|
||||||
calendarStore.setSelectedDateFromPicker(date);
|
calendarStore.setSelectedDateFromPicker(date);
|
||||||
setTimeout(updateCalendarDays, 200);
|
setTimeout(updateCalendarDays, 200);
|
||||||
@@ -90,7 +89,6 @@ export default {
|
|||||||
loadCalendars();
|
loadCalendars();
|
||||||
|
|
||||||
updateCalendarDays();
|
updateCalendarDays();
|
||||||
setInterval(updateCalendarDays, 500);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Реакция на изменения пользователя
|
// Реакция на изменения пользователя
|
||||||
@@ -112,8 +110,6 @@ export default {
|
|||||||
|
|
||||||
if (ariaLabel) {
|
if (ariaLabel) {
|
||||||
try {
|
try {
|
||||||
// Парсим дату из aria-label "воскресенье, 28 сентября 2025 г."
|
|
||||||
|
|
||||||
const dayDate = parseDateFromAriaLabel(ariaLabel);
|
const dayDate = parseDateFromAriaLabel(ariaLabel);
|
||||||
if (dayDate) {
|
if (dayDate) {
|
||||||
const dayInfo = calendarStore.isNonWorkingDay(dayDate);
|
const dayInfo = calendarStore.isNonWorkingDay(dayDate);
|
||||||
@@ -134,7 +130,7 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}, 100);
|
}, 50);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -176,6 +172,39 @@ export default {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
watch(
|
||||||
|
[selectedDate, currentDisplay],
|
||||||
|
() => {
|
||||||
|
updateCalendarDays();
|
||||||
|
},
|
||||||
|
{ deep: true, immediate: true },
|
||||||
|
);
|
||||||
|
|
||||||
|
watch(
|
||||||
|
[myCalendars, subscribedCalendars],
|
||||||
|
() => {
|
||||||
|
updateCalendarDays();
|
||||||
|
},
|
||||||
|
{ deep: true },
|
||||||
|
);
|
||||||
|
|
||||||
|
// При смене месяца через кнопки навигации
|
||||||
|
const observer = new MutationObserver((mutations) => {
|
||||||
|
mutations.forEach((mutation) => {
|
||||||
|
if (mutation.type === 'childList') {
|
||||||
|
updateCalendarDays();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
// Наблюдаем за изменениями в DOM date-picker
|
||||||
|
const datePicker = document.querySelector('.minCal');
|
||||||
|
if (datePicker) {
|
||||||
|
observer.observe(datePicker, { childList: true, subtree: true });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
accountStore,
|
accountStore,
|
||||||
user,
|
user,
|
||||||
@@ -186,6 +215,7 @@ export default {
|
|||||||
loadCalendars,
|
loadCalendars,
|
||||||
handleDateClick,
|
handleDateClick,
|
||||||
updateCalendarDays,
|
updateCalendarDays,
|
||||||
|
currentDisplay,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -236,4 +266,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,207 @@
|
|||||||
|
<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="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) => {
|
||||||
|
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: 80%;
|
||||||
|
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" max-height="80%" 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
|
||||||
@@ -22,16 +22,6 @@
|
|||||||
size="36px"
|
size="36px"
|
||||||
@click="$emit('delObject')"
|
@click="$emit('delObject')"
|
||||||
/>
|
/>
|
||||||
<!-- <v-btn
|
|
||||||
class="text-subtitle-1"
|
|
||||||
elevation="0"
|
|
||||||
width="150"
|
|
||||||
@click="clearValidation"
|
|
||||||
color="btn_gray"
|
|
||||||
variant="flat"
|
|
||||||
>резет</v-btn
|
|
||||||
> -->
|
|
||||||
<!-- <v-btn @click="clearFormValidation"></v-btn> -->
|
|
||||||
<v-btn
|
<v-btn
|
||||||
class="text-subtitle-1"
|
class="text-subtitle-1"
|
||||||
elevation="0"
|
elevation="0"
|
||||||
@@ -39,6 +29,7 @@
|
|||||||
@click="$emit('closeDialog')"
|
@click="$emit('closeDialog')"
|
||||||
color="btn_gray"
|
color="btn_gray"
|
||||||
variant="flat"
|
variant="flat"
|
||||||
|
type="button"
|
||||||
>Отменить</v-btn
|
>Отменить</v-btn
|
||||||
>
|
>
|
||||||
|
|
||||||
@@ -48,9 +39,9 @@
|
|||||||
variant="flat"
|
variant="flat"
|
||||||
elevation="0"
|
elevation="0"
|
||||||
width="150"
|
width="150"
|
||||||
type="transformation"
|
type="submit"
|
||||||
>
|
>
|
||||||
{{ newOrOld ? "Создать" : "Редактировать" }}
|
{{ newOrOld ? "Создать" : "Сохранить" }}
|
||||||
</v-btn>
|
</v-btn>
|
||||||
</v-card-actions>
|
</v-card-actions>
|
||||||
</v-form>
|
</v-form>
|
||||||
|
|||||||
@@ -39,7 +39,7 @@
|
|||||||
</v-locale-provider>
|
</v-locale-provider>
|
||||||
</v-menu>
|
</v-menu>
|
||||||
</v-col>
|
</v-col>
|
||||||
<v-col class="flex-grow-0" :class="`order-${order[1]}`">
|
<v-col class="flex-grow-0" :class="`order-${order[1]}`" v-if="showTime">
|
||||||
<v-textarea
|
<v-textarea
|
||||||
density="compact"
|
density="compact"
|
||||||
no-resize
|
no-resize
|
||||||
@@ -61,13 +61,19 @@
|
|||||||
activator="parent"
|
activator="parent"
|
||||||
transition="scale-transition"
|
transition="scale-transition"
|
||||||
>
|
>
|
||||||
<v-time-picker v-if="menutime" v-model="timeEvent" full-width format="24hr"></v-time-picker>
|
<v-time-picker
|
||||||
|
v-if="menutime"
|
||||||
|
:model-value="timeEvent"
|
||||||
|
@update:model-value="onTimePickerChange"
|
||||||
|
full-width
|
||||||
|
format="24hr"
|
||||||
|
></v-time-picker>
|
||||||
</v-menu>
|
</v-menu>
|
||||||
</v-col>
|
</v-col>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { ref, computed } from 'vue';
|
import { ref, computed, watch } from 'vue';
|
||||||
import { formatComa } from '@/utils/universal_functions';
|
import { formatComa } from '@/utils/universal_functions';
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
@@ -97,6 +103,16 @@ export default {
|
|||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
|
// Новый проп - ограничение по времени (для окончания повторений)
|
||||||
|
timeLimit: {
|
||||||
|
type: String,
|
||||||
|
default: '23:59',
|
||||||
|
},
|
||||||
|
// Новый проп - режим работы (обычный или для окончания повторений)
|
||||||
|
showTime: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
emits: ['update:dateEvent', 'adjustEndDate'],
|
emits: ['update:dateEvent', 'adjustEndDate'],
|
||||||
@@ -107,7 +123,9 @@ export default {
|
|||||||
|
|
||||||
const propsDateEvent = computed({
|
const propsDateEvent = computed({
|
||||||
get: () => new Date(props.dateEvent),
|
get: () => new Date(props.dateEvent),
|
||||||
set: (value) => emit('update:dateEvent', value),
|
set: (value) => {
|
||||||
|
emit('update:dateEvent', value);
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const modelDate = computed({
|
const modelDate = computed({
|
||||||
@@ -121,15 +139,48 @@ export default {
|
|||||||
|
|
||||||
const timeEvent = computed({
|
const timeEvent = computed({
|
||||||
get() {
|
get() {
|
||||||
return `${new Date(propsDateEvent.value).getHours()}:${String(
|
const date = new Date(propsDateEvent.value);
|
||||||
new Date(propsDateEvent.value).getMinutes(),
|
const time = `${date.getHours()}:${String(date.getMinutes()).padStart(2, '0')}`;
|
||||||
).padStart(2, '0')}`;
|
return time;
|
||||||
},
|
},
|
||||||
set(newValue) {
|
set(newValue) {
|
||||||
createdDate(modelDate.value, newValue);
|
applyTimeChange(newValue);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Новый метод для применения изменений времени
|
||||||
|
const applyTimeChange = (newTime) => {
|
||||||
|
const [hours, minutes] = newTime.split(':').map(Number);
|
||||||
|
const newDate = new Date(propsDateEvent.value);
|
||||||
|
newDate.setHours(hours, minutes, 0, 0);
|
||||||
|
|
||||||
|
// Бизнес-логика из createdDate
|
||||||
|
if (props.order[0] == 4) {
|
||||||
|
const startDate = new Date(props.limitation);
|
||||||
|
if (newDate <= startDate) {
|
||||||
|
const correctedDate = new Date(startDate);
|
||||||
|
correctedDate.setHours(startDate.getHours() + 1);
|
||||||
|
propsDateEvent.value = correctedDate;
|
||||||
|
} else {
|
||||||
|
propsDateEvent.value = newDate;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
propsDateEvent.value = newDate;
|
||||||
|
const currentEnd = new Date(props.limitation);
|
||||||
|
if (newDate > currentEnd) {
|
||||||
|
const newEnd = new Date(newDate);
|
||||||
|
newEnd.setHours(newDate.getHours() + 1);
|
||||||
|
emit('adjustEndDate', newEnd.toISOString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const onTimePickerChange = (newTime) => {
|
||||||
|
// Применяем изменения времени сразу
|
||||||
|
applyTimeChange(newTime);
|
||||||
|
// Меню НЕ закрываем - пользователь может продолжить выбирать время
|
||||||
|
};
|
||||||
|
|
||||||
const createdDate = (date, time) => {
|
const createdDate = (date, time) => {
|
||||||
const [hours, minutes] = time.split(':').map(Number);
|
const [hours, minutes] = time.split(':').map(Number);
|
||||||
const newDate = new Date(date);
|
const newDate = new Date(date);
|
||||||
@@ -174,6 +225,7 @@ export default {
|
|||||||
propsDateEvent,
|
propsDateEvent,
|
||||||
menudate,
|
menudate,
|
||||||
menutime,
|
menutime,
|
||||||
|
onTimePickerChange,
|
||||||
modelDate,
|
modelDate,
|
||||||
formatComa,
|
formatComa,
|
||||||
timeEvent,
|
timeEvent,
|
||||||
|
|||||||
@@ -1,12 +1,14 @@
|
|||||||
<template>
|
<template>
|
||||||
|
<div>
|
||||||
<!-- -->
|
<!-- -->
|
||||||
|
|
||||||
<v-autocomplete
|
<v-autocomplete
|
||||||
v-model="selectedStaff"
|
v-model="selectedStaff"
|
||||||
:items="staffed"
|
:items="staffed"
|
||||||
label="Выберите из списка или найдите по ФИО"
|
label="Выберите из списка или найдите по ФИО"
|
||||||
item-title="title"
|
item-title="title"
|
||||||
item-value="id"
|
item-value="id"
|
||||||
:custom-filter="onFilter"
|
:search-input.sync="filtered"
|
||||||
@update:search="(val) => (filtered = val)"
|
@update:search="(val) => (filtered = val)"
|
||||||
multiple
|
multiple
|
||||||
hide-details
|
hide-details
|
||||||
@@ -14,12 +16,14 @@
|
|||||||
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>
|
||||||
<v-icon
|
<v-icon
|
||||||
v-if="item.value != accountStore.user.is_idEmployee"
|
v-if="!isAuthor(item.raw)"
|
||||||
icon="mdi-close-circle"
|
icon="mdi-close-circle"
|
||||||
size="x-small"
|
size="x-small"
|
||||||
class="ml-3"
|
class="ml-3"
|
||||||
@@ -29,9 +33,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>
|
||||||
|
|
||||||
@@ -42,7 +46,35 @@
|
|||||||
></v-checkbox-btn>
|
></v-checkbox-btn>
|
||||||
</template>
|
</template>
|
||||||
</v-list-item>
|
</v-list-item>
|
||||||
|
<!-- ВСЕ НАЧАЛЬНИКИ -->
|
||||||
|
<v-list-item
|
||||||
|
:disabled="!hasBossesInStaff"
|
||||||
|
class="text-body-2"
|
||||||
|
@click.stop="toggleByPosition('начальник')"
|
||||||
|
>
|
||||||
|
<span class="text-body-2"> ВСЕ НАЧАЛЬНИКИ </span>
|
||||||
|
<template v-slot:prepend>
|
||||||
|
<v-checkbox-btn
|
||||||
|
:model-value="hasBossesSelected"
|
||||||
|
:disabled="!hasBossesInStaff"
|
||||||
|
></v-checkbox-btn>
|
||||||
|
</template>
|
||||||
|
</v-list-item>
|
||||||
|
|
||||||
|
<!-- ВСЕ ЗАМЕСТИТЕЛИ -->
|
||||||
|
<v-list-item
|
||||||
|
:disabled="!hasDeputiesInStaff"
|
||||||
|
class="text-body-2"
|
||||||
|
@click.stop="toggleByPosition('заместитель')"
|
||||||
|
>
|
||||||
|
<span class="text-body-2"> ВСЕ ЗАМЕСТИТЕЛИ </span>
|
||||||
|
<template v-slot:prepend>
|
||||||
|
<v-checkbox-btn
|
||||||
|
:model-value="hasDeputiesSelected"
|
||||||
|
:disabled="!hasDeputiesInStaff"
|
||||||
|
></v-checkbox-btn>
|
||||||
|
</template>
|
||||||
|
</v-list-item>
|
||||||
<v-divider class="mt-2"></v-divider>
|
<v-divider class="mt-2"></v-divider>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -56,7 +88,7 @@
|
|||||||
:color="'indigo-darken-4'"
|
:color="'indigo-darken-4'"
|
||||||
:true-value="true"
|
:true-value="true"
|
||||||
:false-value="false"
|
:false-value="false"
|
||||||
:disabled="disable(item.raw)"
|
:disabled="disable(item.raw) || isAuthor(item.raw)"
|
||||||
:indeterminate="
|
:indeterminate="
|
||||||
item.raw.employees.some((e) => e[okey] == true) &&
|
item.raw.employees.some((e) => e[okey] == true) &&
|
||||||
!item.raw.employees.every((e) => e[okey] == true)
|
!item.raw.employees.every((e) => e[okey] == true)
|
||||||
@@ -73,13 +105,13 @@
|
|||||||
)"
|
)"
|
||||||
:key="x.id"
|
:key="x.id"
|
||||||
:value="x.title"
|
:value="x.title"
|
||||||
:disabled="x.id == accountStore.user.is_idEmployee"
|
|
||||||
@click.stop="selectedStaff = x"
|
@click.stop="selectedStaff = x"
|
||||||
|
:disabled=" isAuthor(x)"
|
||||||
density="compact"
|
density="compact"
|
||||||
>
|
>
|
||||||
<template v-slot:prepend>
|
<template v-slot:prepend>
|
||||||
<v-checkbox-btn
|
<v-checkbox-btn
|
||||||
:disabled="x.id == accountStore.user.is_idEmployee"
|
:disabled="isAuthor(x)"
|
||||||
color="indigo-darken-4"
|
color="indigo-darken-4"
|
||||||
:model-value="x[okey]"
|
:model-value="x[okey]"
|
||||||
></v-checkbox-btn>
|
></v-checkbox-btn>
|
||||||
@@ -89,12 +121,16 @@
|
|||||||
</v-list-group>
|
</v-list-group>
|
||||||
</template>
|
</template>
|
||||||
</v-autocomplete>
|
</v-autocomplete>
|
||||||
|
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { ref, computed } from 'vue';
|
import { ref, computed } from 'vue';
|
||||||
|
import { storeToRefs } from 'pinia';
|
||||||
import { splitname } from '@/utils/universal_functions';
|
import { splitname } from '@/utils/universal_functions';
|
||||||
import { useAccountStore } from '@/store/AccountStore';
|
import { useAccountStore } from '@/store/AccountStore';
|
||||||
|
import { useCalendarStore } from '@/store/calendarStore';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
@@ -106,19 +142,30 @@ export default {
|
|||||||
type: String,
|
type: String,
|
||||||
default: 'selected',
|
default: 'selected',
|
||||||
},
|
},
|
||||||
|
authorID: {
|
||||||
|
type: Number,
|
||||||
|
default: null,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
setup(props, { emit }) {
|
setup(props, { emit }) {
|
||||||
const filtered = ref('');
|
const filtered = ref('');
|
||||||
|
|
||||||
const accountStore = useAccountStore();
|
const accountStore = useAccountStore();
|
||||||
|
const calendarStore = useCalendarStore();
|
||||||
|
const { dictEmployeesLoaded } = storeToRefs(calendarStore);
|
||||||
|
|
||||||
const back = ref([]);
|
const back = ref([]);
|
||||||
|
|
||||||
const staffed = computed({
|
const staffed = computed({
|
||||||
get() {
|
get() {
|
||||||
if (props.okey == 'editor') {
|
if (props.okey == 'editor') {
|
||||||
let ns = [];
|
let ns = [];
|
||||||
props.staff.forEach((e) => {
|
props.staff.forEach((e) => {
|
||||||
let emp = { ...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);
|
if (emp.employees.length > 0) ns.push(emp);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -127,8 +174,10 @@ export default {
|
|||||||
e.editor = true;
|
e.editor = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return ns;
|
return ns;
|
||||||
}
|
}
|
||||||
|
|
||||||
return props.staff;
|
return props.staff;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -141,8 +190,14 @@ export default {
|
|||||||
e[props.okey] = true;
|
e[props.okey] = true;
|
||||||
selected.push(e);
|
selected.push(e);
|
||||||
} else if (e.employees.length == 1) {
|
} else if (e.employees.length == 1) {
|
||||||
e[props.okey] = true;
|
const singleEmployee = e.employees[0];
|
||||||
selected.push(...e.employees.filter((n) => n[props.okey] == true));
|
if (singleEmployee[props.okey] === true) {
|
||||||
|
selected.push(singleEmployee);
|
||||||
|
}
|
||||||
|
// Состояние отдела должно вычисляться на основе сотрудника
|
||||||
|
e[props.okey] = singleEmployee[props.okey] === true;
|
||||||
|
// e[props.okey] = true;
|
||||||
|
// selected.push(...e.employees.filter((n) => n[props.okey] == true));
|
||||||
} else {
|
} else {
|
||||||
e[props.okey] = false;
|
e[props.okey] = false;
|
||||||
selected.push(...e.employees.filter((n) => n[props.okey] == true));
|
selected.push(...e.employees.filter((n) => n[props.okey] == true));
|
||||||
@@ -197,7 +252,7 @@ export default {
|
|||||||
|
|
||||||
const cbstaff = (item, value) => {
|
const cbstaff = (item, value) => {
|
||||||
item.forEach((e) => {
|
item.forEach((e) => {
|
||||||
if (e.id != accountStore.user.is_idEmployee) {
|
if (e.id !== accountStore.user.is_idEmployee) {
|
||||||
e[props.okey] = value;
|
e[props.okey] = value;
|
||||||
}
|
}
|
||||||
if (!('employees' in e)) {
|
if (!('employees' in e)) {
|
||||||
@@ -209,15 +264,34 @@ export default {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
function onFilter(item, itemText) {
|
const customFilterFn = (item, queryText, itemText) => {
|
||||||
return (
|
if (!queryText) return true;
|
||||||
item.includes(filtered.value) ||
|
|
||||||
itemText.raw.employees.some((e) =>
|
const searchText = queryText.toLowerCase();
|
||||||
e.title.toLowerCase().includes(filtered.value.toLowerCase()),
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
@@ -225,29 +299,148 @@ export default {
|
|||||||
: false;
|
: false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Функция проверки является ли сотрудник создателем
|
||||||
|
const isAuthor = (item) => {
|
||||||
|
if (!props.authorID) return false;
|
||||||
|
|
||||||
|
// Если это отдел - проверяем всех сотрудников
|
||||||
|
if ('employees' in item) {
|
||||||
|
return item.employees.some((emp) => emp.id === props.authorID);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Если это сотрудник - проверяем напрямую
|
||||||
|
return item.id === props.authorID;
|
||||||
|
};
|
||||||
|
|
||||||
const allUser = () => {
|
const allUser = () => {
|
||||||
emitUp(staffed.value);
|
emitUp(staffed.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Проверяем выбраны ли все начальники (с исключениями)
|
||||||
|
const hasBossesSelected = computed(() => {
|
||||||
|
const bosses = findEmployeesByPosition(['начальник', 'и.о'], ['заместитель', 'зам.']);
|
||||||
|
return bosses.length > 0 && bosses.every((emp) => emp[props.okey] === true);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Проверяем выбраны ли все заместители (с исключениями)
|
||||||
|
const hasDeputiesSelected = computed(() => {
|
||||||
|
const deputies = findEmployeesByPosition(['заместитель', 'зам.'], []);
|
||||||
|
return deputies.length > 0 && deputies.every((emp) => emp[props.okey] === true);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Toggle функция с исключением
|
||||||
|
const toggleByPosition = (positionType) => {
|
||||||
|
let keywords = [];
|
||||||
|
let excludeKeywords = [];
|
||||||
|
|
||||||
|
if (positionType === 'начальник') {
|
||||||
|
keywords = ['начальник', 'и.о'];
|
||||||
|
excludeKeywords = ['заместитель', 'зам.'];
|
||||||
|
} else if (positionType === 'заместитель') {
|
||||||
|
keywords = ['заместитель', 'зам.'];
|
||||||
|
excludeKeywords = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
const employeesToToggle = findEmployeesByPosition(keywords, excludeKeywords);
|
||||||
|
const shouldSelect = !employeesToToggle.every((emp) => emp[props.okey] === true);
|
||||||
|
|
||||||
|
// if (employeesToToggle.length > 0) {
|
||||||
|
// employeesToToggle.forEach((employee) => {
|
||||||
|
// if (employee[props.okey] !== shouldSelect) {
|
||||||
|
// emitUp(employee);
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
|
||||||
|
if (employeesToToggle.length > 0) {
|
||||||
|
// ФИЛЬТРУЕМ - убираем создателя события из массовых операций
|
||||||
|
const filteredEmployees = employeesToToggle.filter(
|
||||||
|
(employee) => employee.id !== props.authorID, //
|
||||||
|
);
|
||||||
|
|
||||||
|
if (filteredEmployees.length > 0) {
|
||||||
|
filteredEmployees.forEach((employee) => {
|
||||||
|
if (employee[props.okey] !== shouldSelect) {
|
||||||
|
selectedStaff.value = employee;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Обновленная функция поиска с исключением
|
||||||
|
const findEmployeesByPosition = (positionKeywords, excludeKeywords = []) => {
|
||||||
|
const foundEmployees = [];
|
||||||
|
|
||||||
|
props.staff.forEach((department) => {
|
||||||
|
department.employees.forEach((employee) => {
|
||||||
|
if (department.id == 1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (employee.id === accountStore.user.is_idEmployee) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (props.okey === 'editor' && employee.selected !== true) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const employeeData = calendarStore.dictEmployees.find((de) => de.id === employee.id);
|
||||||
|
|
||||||
|
if (employeeData && employeeData.post) {
|
||||||
|
const post = employeeData.post.toLowerCase();
|
||||||
|
|
||||||
|
// Ищем включения и исключения
|
||||||
|
const hasInclude = positionKeywords.some((keyword) =>
|
||||||
|
post.includes(keyword.toLowerCase()),
|
||||||
|
);
|
||||||
|
const hasExclude = excludeKeywords.some((exclude) =>
|
||||||
|
post.includes(exclude.toLowerCase()),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (hasInclude && !hasExclude) {
|
||||||
|
foundEmployees.push(employee);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
return foundEmployees;
|
||||||
|
};
|
||||||
|
// Проверяем есть ли начальники в staff
|
||||||
|
const hasBossesInStaff = computed(() => {
|
||||||
|
return (
|
||||||
|
findEmployeesByPosition(['начальник', 'и.о. начальника'], ['заместитель', 'зам.']).length >
|
||||||
|
0
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Проверяем есть ли заместители в staff
|
||||||
|
const hasDeputiesInStaff = computed(() => {
|
||||||
|
return (
|
||||||
|
findEmployeesByPosition(['заместитель начальника', 'зам. начальника', 'заместитель'])
|
||||||
|
.length > 0
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
isAuthor,
|
||||||
staffed,
|
staffed,
|
||||||
filtered,
|
filtered,
|
||||||
accountStore,
|
accountStore,
|
||||||
selectedStaff,
|
selectedStaff,
|
||||||
splitname,
|
splitname,
|
||||||
onFilter,
|
|
||||||
disable,
|
disable,
|
||||||
allUser,
|
allUser,
|
||||||
|
customFilterFn,
|
||||||
|
findEmployeesByPosition,
|
||||||
|
toggleByPosition,
|
||||||
|
hasBossesInStaff,
|
||||||
|
hasBossesSelected,
|
||||||
|
hasDeputiesInStaff,
|
||||||
|
hasDeputiesSelected,
|
||||||
|
dictEmployeesLoaded,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
|
||||||
.max-height-select .v-field__input {
|
|
||||||
max-height: 300px; /* Установите желаемую максимальную высоту */
|
|
||||||
overflow-y: auto; /* Добавьте прокрутку, если список превышает максимальную высоту */
|
|
||||||
overflow-x: hidden;
|
|
||||||
margin: 5px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -46,6 +46,7 @@
|
|||||||
<calendar-create-select
|
<calendar-create-select
|
||||||
:staff="newStaff"
|
:staff="newStaff"
|
||||||
@returnIdParticant="returnIdParticant"
|
@returnIdParticant="returnIdParticant"
|
||||||
|
:authorID="calendarAuthorId"
|
||||||
/> </v-col
|
/> </v-col
|
||||||
></v-row>
|
></v-row>
|
||||||
</v-col>
|
</v-col>
|
||||||
@@ -69,6 +70,7 @@
|
|||||||
:staff="newStaff"
|
:staff="newStaff"
|
||||||
:okey="'editor'"
|
:okey="'editor'"
|
||||||
@returnIdParticant="returnIdParticant"
|
@returnIdParticant="returnIdParticant"
|
||||||
|
:authorID="calendarAuthorId"
|
||||||
/>
|
/>
|
||||||
</v-col>
|
</v-col>
|
||||||
<v-col lg="1" class="text-center">
|
<v-col lg="1" class="text-center">
|
||||||
@@ -109,6 +111,15 @@ export default {
|
|||||||
setup(props, { emit }) {
|
setup(props, { emit }) {
|
||||||
const accountStore = useAccountStore();
|
const accountStore = useAccountStore();
|
||||||
|
|
||||||
|
const calendarAuthorId = computed(() => {
|
||||||
|
// Для нового календаря - текущий пользователь
|
||||||
|
if (isNewCalendar.value) {
|
||||||
|
return accountStore.user.is_idEmployee;
|
||||||
|
}
|
||||||
|
// Для существующего - автор из props
|
||||||
|
return propsCalendar.value.author;
|
||||||
|
});
|
||||||
|
|
||||||
const returnIdParticant = (idPart) => {
|
const returnIdParticant = (idPart) => {
|
||||||
idPart.staff.forEach((e) => {
|
idPart.staff.forEach((e) => {
|
||||||
let indx = propsCalendar.value.participant.findIndex((l) => l.participant_calendar == e.id);
|
let indx = propsCalendar.value.participant.findIndex((l) => l.participant_calendar == e.id);
|
||||||
@@ -206,24 +217,41 @@ export default {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const color = [
|
// const color = [
|
||||||
'#3788d8', // Синий (аналог default FullCalendar)
|
// '#0ea5e9', // Яркий голубой
|
||||||
'#4caf50', // Зеленый
|
// '#3b82f6', // Королевский синий
|
||||||
'#ff9800', // Оранжевый
|
// '#10b981', // Изумрудно-зеленый
|
||||||
'#9c27b0', // Фиолетовый
|
// '#f59e0b', // Теплый янтарный
|
||||||
'#2196f3', // Голубой
|
// '#ef4444', // Акцентный красный
|
||||||
'#795548', // Коричневый
|
// '#8b5cf6', // Фиолетовый
|
||||||
'#607d8b', // Серо-голубой
|
// '#4f46e5', // Индиго (профессиональный синий)
|
||||||
'#e91e63', // Розовый
|
// '#06b6d4', // Бирюзовый
|
||||||
'#00bcd4', // Бирюзовый
|
// '#84cc16', // Лаймовый
|
||||||
'#8bc34a', // Салатовый
|
// '#f97316', // Оранжевый
|
||||||
'#ff5722', // Красно-оранжевый
|
// '#ec4899', // Розовый
|
||||||
'#673ab7', // Темно-фиолетовый
|
// '#6366f1', // Фиолетово-синий
|
||||||
'#3f51b5', // Индиго
|
// '#14b8a6', // Бирюзово-зеленый
|
||||||
'#009688', // Зелено-бирюзовый
|
// '#eab308', // Золотисто-желтый
|
||||||
'#ffc107', // Янтарный
|
// '#22c55e', // Зеленый
|
||||||
];
|
// ];
|
||||||
|
|
||||||
|
const color = [
|
||||||
|
'#3b82f6', // Синий
|
||||||
|
'#10b981', // Зеленый
|
||||||
|
'#dc2626', // Красный
|
||||||
|
'#d97706', // Оранжевый
|
||||||
|
'#7c3aed', // Фиолетовый
|
||||||
|
'#0ea5e9', // Голубой
|
||||||
|
'#84cc16', // Лаймовый
|
||||||
|
'#f59e0b', // Янтарный
|
||||||
|
'#8b5cf6', // Пурпурный
|
||||||
|
'#06b6d4', // Бирюзовый
|
||||||
|
'#f97316', // Теплый оранжевый
|
||||||
|
'#6366f1', // Фиолетово-синий
|
||||||
|
'#14b8a6', // Морской волны
|
||||||
|
'#ec4899', // Розовый
|
||||||
|
'#64748b', // Серо-синий
|
||||||
|
];
|
||||||
const colorPik = (col) => {
|
const colorPik = (col) => {
|
||||||
if (propsCalendar.value.cl_color === col) {
|
if (propsCalendar.value.cl_color === col) {
|
||||||
propsCalendar.value.cl_color = null;
|
propsCalendar.value.cl_color = null;
|
||||||
@@ -261,6 +289,7 @@ export default {
|
|||||||
newCalendar,
|
newCalendar,
|
||||||
newStaff,
|
newStaff,
|
||||||
isNewCalendar,
|
isNewCalendar,
|
||||||
|
calendarAuthorId,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
<template v-if="Object.keys(calendars).length > 0">
|
<template v-if="Object.keys(calendars).length > 0">
|
||||||
<v-list-item
|
<v-list-item
|
||||||
v-for="(x, i) in calendars"
|
v-for="(x, i) in calendars"
|
||||||
:key="i"
|
:key="x.id"
|
||||||
:value="x.cl_name"
|
:value="x.cl_name"
|
||||||
@mouseenter="hover = i"
|
@mouseenter="hover = i"
|
||||||
@mouseleave="hover = null"
|
@mouseleave="hover = null"
|
||||||
@@ -33,8 +33,8 @@
|
|||||||
:color="x.cl_color"
|
:color="x.cl_color"
|
||||||
v-model="x.visible"
|
v-model="x.visible"
|
||||||
@update:modelValue="toggleVisiblityEvents(x)"
|
@update:modelValue="toggleVisiblityEvents(x)"
|
||||||
|
:model-value="x.visible"
|
||||||
></v-checkbox-btn>
|
></v-checkbox-btn>
|
||||||
<!-- :model-value="x.visible" -->
|
|
||||||
</template>
|
</template>
|
||||||
<template v-slot:title>
|
<template v-slot:title>
|
||||||
<span class="text-body-2"> {{ x.cl_name }} </span>
|
<span class="text-body-2"> {{ x.cl_name }} </span>
|
||||||
@@ -66,9 +66,8 @@
|
|||||||
</v-expansion-panel>
|
</v-expansion-panel>
|
||||||
<v-dialog v-model="showDialog" min-width="636" max-width="800">
|
<v-dialog v-model="showDialog" min-width="636" max-width="800">
|
||||||
<calendar-create
|
<calendar-create
|
||||||
@closeDialog="showDialog = false"
|
@closeDialog="handleCloseDialog"
|
||||||
:calendar="calendar"
|
:calendar="calendar"
|
||||||
@update:calendar="calendar = $event"
|
|
||||||
@getCalendar="$emit('getCalendar')"
|
@getCalendar="$emit('getCalendar')"
|
||||||
/>
|
/>
|
||||||
</v-dialog>
|
</v-dialog>
|
||||||
@@ -76,7 +75,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { ref } from 'vue';
|
import { ref, watch } from 'vue';
|
||||||
import calendarCreate from '@/components/calendar_of_events/calendar-create.vue';
|
import calendarCreate from '@/components/calendar_of_events/calendar-create.vue';
|
||||||
import { useAccountStore } from '@/store/AccountStore';
|
import { useAccountStore } from '@/store/AccountStore';
|
||||||
import { storeToRefs } from 'pinia';
|
import { storeToRefs } from 'pinia';
|
||||||
@@ -102,9 +101,9 @@ export default {
|
|||||||
const accountStore = useAccountStore();
|
const accountStore = useAccountStore();
|
||||||
const { user } = storeToRefs(accountStore);
|
const { user } = storeToRefs(accountStore);
|
||||||
const calendarStore = useCalendarStore();
|
const calendarStore = useCalendarStore();
|
||||||
const { toggleCalendarVisibility } = calendarStore;
|
const { toggleCalendarVisibility, hiddenCalendarIds } = calendarStore;
|
||||||
|
|
||||||
const calendar = ref({});
|
const calendar = ref(null);
|
||||||
const openGroup = ref([0]);
|
const openGroup = ref([0]);
|
||||||
const trans = ref(false);
|
const trans = ref(false);
|
||||||
const hover = ref(0);
|
const hover = ref(0);
|
||||||
@@ -118,15 +117,31 @@ export default {
|
|||||||
cl_descr: '',
|
cl_descr: '',
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
calendar.value = cal;
|
calendar.value = { ...cal };
|
||||||
}
|
}
|
||||||
showDialog.value = true;
|
showDialog.value = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
const toggleVisiblityEvents = (cal) => {
|
const handleCloseDialog = () => {
|
||||||
toggleCalendarVisibility(cal.id, cal.visible);
|
showDialog.value = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const resetCalendar = () => {
|
||||||
|
calendar.value = {};
|
||||||
|
};
|
||||||
|
|
||||||
|
const toggleVisiblityEvents = (cal) => {
|
||||||
|
toggleCalendarVisibility(cal.id);
|
||||||
|
};
|
||||||
|
|
||||||
|
watch(hiddenCalendarIds, (newHiddenIds) => {}, { deep: true });
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.calendars,
|
||||||
|
(newCalendars) => {},
|
||||||
|
{ deep: true },
|
||||||
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
accountStore,
|
accountStore,
|
||||||
user,
|
user,
|
||||||
@@ -137,6 +152,8 @@ export default {
|
|||||||
openGroup,
|
openGroup,
|
||||||
trans,
|
trans,
|
||||||
hover,
|
hover,
|
||||||
|
handleCloseDialog,
|
||||||
|
resetCalendar,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
import { ref, computed } from 'vue';
|
||||||
|
|
||||||
|
export function useEventListFilters() {
|
||||||
|
// Состояние фильтров
|
||||||
|
const dateRange = ref(null);
|
||||||
|
const sortOrder = ref('asc');
|
||||||
|
|
||||||
|
const sortOptions = [
|
||||||
|
{
|
||||||
|
title: 'По возрастанию',
|
||||||
|
value: 'asc',
|
||||||
|
props: {
|
||||||
|
prependIcon: 'mdi-sort-calendar-ascending',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'По убыванию',
|
||||||
|
value: 'desc',
|
||||||
|
props: {
|
||||||
|
prependIcon: 'mdi-sort-calendar-descending',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
// Сброс фильтров
|
||||||
|
const resetFilters = () => {
|
||||||
|
dateRange.value = null;
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
// Состояние
|
||||||
|
dateRange,
|
||||||
|
sortOrder,
|
||||||
|
|
||||||
|
// Опции
|
||||||
|
sortOptions,
|
||||||
|
|
||||||
|
// Методы
|
||||||
|
resetFilters,
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -1,18 +1,18 @@
|
|||||||
import { RRule } from 'rrule';
|
import { RRule } from 'rrule';
|
||||||
|
|
||||||
export function useRecurrence() {
|
export function useRecurrence() {
|
||||||
/**
|
|
||||||
* Парсит строку периода из БД и возвращает опции для RRule
|
|
||||||
*/
|
|
||||||
const parseRecurrenceOptions = (periodString, eventDateStart) => {
|
const parseRecurrenceOptions = (periodString, eventDateStart) => {
|
||||||
if (!periodString || periodString === 'null') return null;
|
if (!periodString || periodString === 'null') return null;
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Пробуем распарсить как RRULE-строку
|
// Пробуем распарсить как RRULE-строку
|
||||||
if (periodString.includes('RRULE:')) {
|
if (periodString.includes('RRULE:')) {
|
||||||
const rrule = RRule.fromString(periodString);
|
const rrule = RRule.fromString(periodString);
|
||||||
return { ...rrule.origOptions, dtstart: new Date(eventDateStart) };
|
return {
|
||||||
|
...rrule.origOptions,
|
||||||
|
dtstart: new Date(eventDateStart),
|
||||||
|
interval: rrule.origOptions.interval || 1,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
// Пробуем распарсить как JSON
|
// Пробуем распарсить как JSON
|
||||||
const periodData = JSON.parse(periodString);
|
const periodData = JSON.parse(periodString);
|
||||||
@@ -21,6 +21,9 @@ export function useRecurrence() {
|
|||||||
if (options.dtstart && typeof options.dtstart === 'string') {
|
if (options.dtstart && typeof options.dtstart === 'string') {
|
||||||
options.dtstart = new Date(eventDateStart);
|
options.dtstart = new Date(eventDateStart);
|
||||||
}
|
}
|
||||||
|
if (options.interval === undefined) {
|
||||||
|
options.interval = 1;
|
||||||
|
}
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -28,29 +31,153 @@ export function useRecurrence() {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Проверяет, является ли событие повторяющимся
|
* Проверяет, является ли событие повторяющимся
|
||||||
*/
|
*/
|
||||||
const isRecurringEvent = (event) => {
|
const isRecurringEvent = (event) => {
|
||||||
if (!event.period || event.period === 'null') return false;
|
if (!event.period || event.period === 'null') return false;
|
||||||
return event.period.includes('RRULE:') || JSON.parse(event.period)?.origOptions;
|
return (
|
||||||
|
event.period.includes('RRULE:') || (event.period && event.period.includes('"origOptions"'))
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Создает объект правила для нового события
|
* Генерирует все экземпляры повторяющегося события
|
||||||
*/
|
*/
|
||||||
const createRecurrenceRule = (options) => {
|
const generateRecurringInstances = (event, count = 24) => {
|
||||||
const rrule = new RRule({
|
if (!isRecurringEvent(event)) return [event];
|
||||||
...options,
|
|
||||||
dtstart: new Date(options.dtstart),
|
try {
|
||||||
});
|
let rrule;
|
||||||
return rrule.toString(); // Возвращаем строку RRULE
|
|
||||||
|
if (event.period.includes('RRULE:')) {
|
||||||
|
rrule = RRule.fromString(event.period);
|
||||||
|
} else {
|
||||||
|
const periodData = JSON.parse(event.period);
|
||||||
|
if (periodData?.origOptions) {
|
||||||
|
rrule = new RRule(periodData.origOptions);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!rrule) return [event];
|
||||||
|
|
||||||
|
const dates = rrule.all((date, i) => i < count);
|
||||||
|
const start = new Date(event.date_start);
|
||||||
|
const end = new Date(event.date_end);
|
||||||
|
const duration = end - start;
|
||||||
|
|
||||||
|
return dates.map((date, index) => ({
|
||||||
|
id: event.id,
|
||||||
|
title: event.name,
|
||||||
|
start: new Date(date),
|
||||||
|
end: new Date(date.getTime() + duration),
|
||||||
|
allDay: event.allday,
|
||||||
|
extendedProps: {
|
||||||
|
originalEventId: event.id,
|
||||||
|
description: event.description,
|
||||||
|
participant: event.participant,
|
||||||
|
calendar: event.calendar,
|
||||||
|
files: event.files,
|
||||||
|
isRecurringInstance: true,
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error generating recurring instances:', error);
|
||||||
|
return [event];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const formatRecurrenceText = (periodString, eventDateStart) => {
|
||||||
|
if (!periodString || periodString === 'null') return null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
let interval = 1;
|
||||||
|
|
||||||
|
if (periodString.includes('RRULE:')) {
|
||||||
|
// Парсим RRULE строку чтобы достать FREQ и INTERVAL
|
||||||
|
const rrulePart = periodString.split('RRULE:')[1];
|
||||||
|
if (rrulePart) {
|
||||||
|
const params = rrulePart.split(';');
|
||||||
|
|
||||||
|
// Достаем FREQ
|
||||||
|
const freqParam = params.find((p) => p.startsWith('FREQ='));
|
||||||
|
const freq = freqParam ? freqParam.split('=')[1] : '';
|
||||||
|
|
||||||
|
// Достаем INTERVAL
|
||||||
|
const intervalParam = params.find((p) => p.startsWith('INTERVAL='));
|
||||||
|
interval = intervalParam ? parseInt(intervalParam.split('=')[1]) : 1;
|
||||||
|
|
||||||
|
// Форматируем по частоте
|
||||||
|
switch (freq) {
|
||||||
|
case 'DAILY':
|
||||||
|
return interval === 1 ? 'Ежедневно' : `Каждый ${interval} день`;
|
||||||
|
case 'WEEKLY':
|
||||||
|
return interval === 1 ? 'Еженедельно' : `Каждую ${interval} неделю`;
|
||||||
|
case 'MONTHLY':
|
||||||
|
return interval === 1
|
||||||
|
? 'Каждый месяц'
|
||||||
|
: interval === 3
|
||||||
|
? 'Ежеквартально'
|
||||||
|
: `Каждый ${interval} месяц`;
|
||||||
|
case 'YEARLY':
|
||||||
|
return interval === 1 ? 'Ежегодно' : `Каждый ${interval} год`;
|
||||||
|
default:
|
||||||
|
return 'Повторяется';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 'Повторяется';
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error formatting recurrence:', error);
|
||||||
|
return 'Повторяется';
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Получает иконку для типа повторения
|
||||||
|
*/
|
||||||
|
const getRecurrenceIcon = (periodString) => {
|
||||||
|
if (!periodString) return 'mdi-repeat';
|
||||||
|
|
||||||
|
try {
|
||||||
|
let rrule;
|
||||||
|
|
||||||
|
if (periodString.includes('RRULE:')) {
|
||||||
|
rrule = RRule.fromString(periodString);
|
||||||
|
} else {
|
||||||
|
const periodData = JSON.parse(periodString);
|
||||||
|
if (periodData?.origOptions) {
|
||||||
|
rrule = new RRule(periodData.origOptions);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!rrule) return 'mdi-repeat';
|
||||||
|
|
||||||
|
const options = rrule.origOptions;
|
||||||
|
|
||||||
|
switch (options.freq) {
|
||||||
|
case RRule.DAILY:
|
||||||
|
return 'mdi-calendar-today';
|
||||||
|
case RRule.WEEKLY:
|
||||||
|
return 'mdi-calendar-week';
|
||||||
|
case RRule.MONTHLY:
|
||||||
|
return 'mdi-calendar-month';
|
||||||
|
case RRule.YEARLY:
|
||||||
|
return 'mdi-calendar-star';
|
||||||
|
default:
|
||||||
|
return 'mdi-repeat';
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
return 'mdi-repeat';
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
parseRecurrenceOptions,
|
|
||||||
createRecurrenceRule,
|
|
||||||
isRecurringEvent,
|
isRecurringEvent,
|
||||||
|
generateRecurringInstances,
|
||||||
|
parseRecurrenceOptions,
|
||||||
|
formatRecurrenceText,
|
||||||
|
getRecurrenceIcon,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,513 @@
|
|||||||
|
<template>
|
||||||
|
<v-dialog v-model="internalShow" max-width="700">
|
||||||
|
<v-card class="pa-4" min-height="400">
|
||||||
|
<!-- Заголовок -->
|
||||||
|
<v-card-title class="pr-0 pl-2 d-flex justify-space-between pb-3">
|
||||||
|
<span class="text-h5 font-weight-medium">Просмотр события</span>
|
||||||
|
<v-icon
|
||||||
|
icon="mdi-close"
|
||||||
|
size="small"
|
||||||
|
color="grey"
|
||||||
|
class="cursor-pointer"
|
||||||
|
@click="closeDialog"
|
||||||
|
/>
|
||||||
|
</v-card-title>
|
||||||
|
|
||||||
|
<v-divider></v-divider>
|
||||||
|
|
||||||
|
<!-- Контент -->
|
||||||
|
<v-card-text class="px-2">
|
||||||
|
<v-row no-gutters class="flex-column">
|
||||||
|
<!-- Название события -->
|
||||||
|
<v-row no-gutters class="align-center border-bottom">
|
||||||
|
<v-col
|
||||||
|
style="font-size: 1.1rem; line-height: 1.4"
|
||||||
|
class="text-body-1 text-text_grey font-weight-medium"
|
||||||
|
lg="3"
|
||||||
|
>
|
||||||
|
Название
|
||||||
|
</v-col>
|
||||||
|
<v-col>
|
||||||
|
<div class="text-body-1" style="font-size: 1.1rem; line-height: 1.4">
|
||||||
|
{{ eventData.event?.name || 'Без названия' }}
|
||||||
|
</div>
|
||||||
|
</v-col>
|
||||||
|
</v-row>
|
||||||
|
|
||||||
|
<!-- Календарь -->
|
||||||
|
<v-row no-gutters class="align-center pb-3 mb-3 border-bottom">
|
||||||
|
<v-col class="text-body-1 text-text_grey font-weight-medium" lg="3"> Календарь </v-col>
|
||||||
|
<v-col>
|
||||||
|
<div class="d-flex align-center">
|
||||||
|
<v-avatar size="20" :color="calendarColor" class="mr-3" />
|
||||||
|
<span class="text-body-1">{{ calendarName }}</span>
|
||||||
|
</div>
|
||||||
|
</v-col>
|
||||||
|
</v-row>
|
||||||
|
|
||||||
|
<!-- Участники -->
|
||||||
|
<v-row
|
||||||
|
no-gutters
|
||||||
|
class="align-start pb-3 mb-3 border-bottom"
|
||||||
|
v-if="participantsList.length > 0"
|
||||||
|
>
|
||||||
|
<v-col class="text-body-1 text-text_grey font-weight-medium pt-1" lg="3">
|
||||||
|
Участники
|
||||||
|
</v-col>
|
||||||
|
<v-col>
|
||||||
|
<div class="participants-list">
|
||||||
|
<div
|
||||||
|
v-for="participant in participantsList"
|
||||||
|
:key="participant.id"
|
||||||
|
class="text-body-1 mb-1"
|
||||||
|
>
|
||||||
|
• {{ participant.title }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</v-col>
|
||||||
|
</v-row>
|
||||||
|
|
||||||
|
<!-- Дата и время -->
|
||||||
|
<v-row no-gutters class="align-top pb-3 mb-3 border-bottom">
|
||||||
|
<v-col class="text-body-1 text-text_grey font-weight-medium pt-1" lg="3">
|
||||||
|
Дата и время
|
||||||
|
</v-col>
|
||||||
|
<v-col class="d-flex flex-column">
|
||||||
|
<div class="d-flex align-center gap">
|
||||||
|
<div class="text-body-1 font-weight-medium">
|
||||||
|
{{ formatDateTime(eventData.event?.date_start, eventData.event?.allday) }}
|
||||||
|
</div>
|
||||||
|
<v-icon icon="mdi-minus" color="grey" class="mx-3" />
|
||||||
|
<div class="text-body-1 font-weight-medium">
|
||||||
|
{{ formatDateTime(eventData.event?.date_end, eventData.event?.allday) }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</v-col>
|
||||||
|
</v-row>
|
||||||
|
|
||||||
|
<!-- Повторение -->
|
||||||
|
<v-row
|
||||||
|
no-gutters
|
||||||
|
class="align-center pb-3 mb-3 border-bottom"
|
||||||
|
v-if="eventData.event?.period"
|
||||||
|
>
|
||||||
|
<v-col class="text-body-1 text-text_grey font-weight-medium" lg="3"> Повтор события </v-col>
|
||||||
|
<v-col>
|
||||||
|
<div class="text-body-1">{{ recurrenceText }}</div>
|
||||||
|
</v-col>
|
||||||
|
</v-row>
|
||||||
|
|
||||||
|
<!-- Окончание события -->
|
||||||
|
<v-row no-gutters class="align-center pb-3 mb-3 border-bottom" v-if="showRepeatEnd">
|
||||||
|
<v-col class="text-body-1 text-text_grey font-weight-medium" lg="3">
|
||||||
|
Окончание события
|
||||||
|
</v-col>
|
||||||
|
<v-col>
|
||||||
|
<div class="text-body-1">
|
||||||
|
{{ formatRepeatEndDate }}
|
||||||
|
</div>
|
||||||
|
</v-col>
|
||||||
|
</v-row>
|
||||||
|
|
||||||
|
<!-- Файлы -->
|
||||||
|
<v-row
|
||||||
|
no-gutters
|
||||||
|
class="align-top pb-3 mb-3 border-bottom"
|
||||||
|
v-if="eventData.event?.files?.length"
|
||||||
|
>
|
||||||
|
<v-col class="text-body-1 text-text_grey font-weight-medium" lg="3"> Файлы </v-col>
|
||||||
|
<v-col>
|
||||||
|
<div class="files-list">
|
||||||
|
<div
|
||||||
|
v-for="file in eventData.event.files"
|
||||||
|
:key="file.id"
|
||||||
|
class="d-flex align-center mb-2 cursor-pointer"
|
||||||
|
@click="downloadFile(file)"
|
||||||
|
>
|
||||||
|
<v-icon :icon="getFileIcon(file)" color="primary" class="mr-2" size="small" />
|
||||||
|
<span class="text-body-1 text-primary text-decoration-underline">
|
||||||
|
{{ truncateFileName(getFileName(file)) }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</v-col>
|
||||||
|
</v-row>
|
||||||
|
|
||||||
|
<!-- Описание -->
|
||||||
|
<v-row no-gutters class="align-top pb-3" v-if="eventData.event?.description">
|
||||||
|
<v-col class="text-body-1 text-text_grey font-weight-medium" lg="3"> Описание </v-col>
|
||||||
|
<v-col>
|
||||||
|
<div class="text-body-1 description-text">
|
||||||
|
{{ eventData.event.description }}
|
||||||
|
</div>
|
||||||
|
</v-col>
|
||||||
|
</v-row>
|
||||||
|
|
||||||
|
<!-- Если нет данных -->
|
||||||
|
<v-row v-if="!eventData.event?.name" class="justify-center mt-8">
|
||||||
|
<v-col class="text-center">
|
||||||
|
<v-icon size="64" color="grey-lighten-1">mdi-calendar-remove</v-icon>
|
||||||
|
<div class="text-h6 text-grey mt-2">Нет данных о событии</div>
|
||||||
|
</v-col>
|
||||||
|
</v-row>
|
||||||
|
</v-row>
|
||||||
|
</v-card-text>
|
||||||
|
|
||||||
|
<!-- Кнопки -->
|
||||||
|
<v-card-actions class="justify-end pa-4 pt-0">
|
||||||
|
<v-btn
|
||||||
|
width="120"
|
||||||
|
@click="closeDialog"
|
||||||
|
color="grey-darken-1"
|
||||||
|
variant="tonal"
|
||||||
|
class="text-body-1"
|
||||||
|
>
|
||||||
|
Закрыть
|
||||||
|
</v-btn>
|
||||||
|
</v-card-actions>
|
||||||
|
</v-card>
|
||||||
|
</v-dialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { computed, ref, watch } from 'vue';
|
||||||
|
import { useRecurrence } from '@/components/calendar_of_events/composables/useReccurrence';
|
||||||
|
import { RRule } from 'rrule';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'EventCalendarShow',
|
||||||
|
|
||||||
|
props: {
|
||||||
|
show: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
eventData: {
|
||||||
|
type: Object,
|
||||||
|
default: () => ({}),
|
||||||
|
},
|
||||||
|
allCalendars: {
|
||||||
|
type: Array,
|
||||||
|
default: () => [],
|
||||||
|
},
|
||||||
|
employees: {
|
||||||
|
type: Array,
|
||||||
|
default: [],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
emits: ['update:show', 'close'],
|
||||||
|
|
||||||
|
setup(props, { emit }) {
|
||||||
|
const internalShow = ref(props.show);
|
||||||
|
const { parseRecurrenceOptions, isRecurringEvent } = useRecurrence();
|
||||||
|
|
||||||
|
// Синхронизация с внешним состоянием
|
||||||
|
watch(
|
||||||
|
() => props.show,
|
||||||
|
(newVal) => {
|
||||||
|
internalShow.value = newVal;
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
watch(internalShow, (newVal) => {
|
||||||
|
if (!newVal) {
|
||||||
|
emit('update:show', false);
|
||||||
|
emit('close');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const closeDialog = () => {
|
||||||
|
internalShow.value = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Информация о календаре - ИСПРАВЛЕНО
|
||||||
|
const calendarInfo = computed(() => {
|
||||||
|
const calendarId = props.eventData.event?.calendar;
|
||||||
|
return props.allCalendars.find((cal) => cal.id == calendarId) || {};
|
||||||
|
});
|
||||||
|
|
||||||
|
const calendarName = computed(() => calendarInfo.value.cl_name || 'Неизвестный календарь');
|
||||||
|
const calendarColor = computed(() => calendarInfo.value.cl_color || 'grey');
|
||||||
|
|
||||||
|
// Участники - ИСПРАВЛЕНО
|
||||||
|
const participantsList = computed(() => {
|
||||||
|
const participantIds = props.eventData.event?.participant || [];
|
||||||
|
|
||||||
|
// Собираем всех сотрудников
|
||||||
|
const allEmployees = props.employees.flatMap((dept) => dept.employees || []);
|
||||||
|
|
||||||
|
return participantIds
|
||||||
|
.map((id) => {
|
||||||
|
const employee = allEmployees.find((emp) => emp.id == id);
|
||||||
|
return employee
|
||||||
|
? {
|
||||||
|
id: employee.id,
|
||||||
|
title: employee.title,
|
||||||
|
}
|
||||||
|
: null;
|
||||||
|
})
|
||||||
|
.filter(Boolean);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Форматирование даты
|
||||||
|
const formatDateTime = (dateString, isAllDay) => {
|
||||||
|
if (!dateString) return 'Не указано';
|
||||||
|
|
||||||
|
try {
|
||||||
|
const date = new Date(dateString);
|
||||||
|
|
||||||
|
if (isAllDay) {
|
||||||
|
return date.toLocaleDateString('ru-RU', {
|
||||||
|
day: 'numeric',
|
||||||
|
month: 'long',
|
||||||
|
year: 'numeric',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return date.toLocaleString('ru-RU', {
|
||||||
|
day: 'numeric',
|
||||||
|
month: 'long',
|
||||||
|
year: 'numeric',
|
||||||
|
hour: '2-digit',
|
||||||
|
minute: '2-digit',
|
||||||
|
});
|
||||||
|
} catch {
|
||||||
|
return 'Неверный формат даты';
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Определяем показывать ли окончание повтора
|
||||||
|
const showRepeatEnd = computed(() => {
|
||||||
|
const period = props.eventData.event?.period;
|
||||||
|
if (!period || !isRecurringEvent(props.eventData.event)) return false;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const options = parseRecurrenceOptions(period, props.eventData.event?.date_start);
|
||||||
|
return !!options?.until;
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Форматируем дату окончания повтора
|
||||||
|
const formatRepeatEndDate = computed(() => {
|
||||||
|
const period = props.eventData.event?.period;
|
||||||
|
if (!period || !isRecurringEvent(props.eventData.event)) return '';
|
||||||
|
|
||||||
|
try {
|
||||||
|
const options = parseRecurrenceOptions(period, props.eventData.event?.date_start);
|
||||||
|
if (options?.until) {
|
||||||
|
return new Date(options.until).toLocaleDateString('ru-RU', {
|
||||||
|
day: 'numeric',
|
||||||
|
month: 'long',
|
||||||
|
year: 'numeric',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error parsing repeat end date:', error);
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
});
|
||||||
|
|
||||||
|
// Текст повторения с использованием composable
|
||||||
|
const recurrenceText = computed(() => {
|
||||||
|
const period = props.eventData.event?.period;
|
||||||
|
if (!period || !isRecurringEvent(props.eventData.event)) return '';
|
||||||
|
|
||||||
|
try {
|
||||||
|
const options = parseRecurrenceOptions(period, props.eventData.event?.date_start);
|
||||||
|
if (!options) return 'Повторяющееся событие';
|
||||||
|
|
||||||
|
const freq = options.freq;
|
||||||
|
const interval = options.interval || 1;
|
||||||
|
|
||||||
|
switch (freq) {
|
||||||
|
case RRule.DAILY:
|
||||||
|
return interval === 1 ? 'Каждый день' : `Каждые ${interval} дней`;
|
||||||
|
|
||||||
|
case RRule.WEEKLY:
|
||||||
|
if (interval === 1) {
|
||||||
|
if (options.byweekday && options.byweekday.length > 0) {
|
||||||
|
const dayNames = options.byweekday
|
||||||
|
.map((day) => {
|
||||||
|
const dayMap = {
|
||||||
|
[RRule.MO]: 'понедельник',
|
||||||
|
[RRule.TU]: 'вторник',
|
||||||
|
[RRule.WE]: 'среду',
|
||||||
|
[RRule.TH]: 'четверг',
|
||||||
|
[RRule.FR]: 'пятницу',
|
||||||
|
[RRule.SA]: 'субботу',
|
||||||
|
[RRule.SU]: 'воскресенье',
|
||||||
|
};
|
||||||
|
return dayMap[day] || '';
|
||||||
|
})
|
||||||
|
.filter(Boolean);
|
||||||
|
|
||||||
|
if (dayNames.length === 1) return `Каждую ${dayNames[0]}`;
|
||||||
|
if (dayNames.length > 1) return `По ${dayNames.join(', ')}`;
|
||||||
|
}
|
||||||
|
return 'Каждую неделю';
|
||||||
|
}
|
||||||
|
return `Каждые ${interval} недель`;
|
||||||
|
|
||||||
|
case RRule.MONTHLY:
|
||||||
|
if (interval === 1) {
|
||||||
|
if (options.bymonthday && options.bymonthday.length > 0) {
|
||||||
|
const day = options.bymonthday[0];
|
||||||
|
return `Каждое ${day}-е число`;
|
||||||
|
}
|
||||||
|
return 'Каждый месяц';
|
||||||
|
}
|
||||||
|
return interval === 3 ? 'Каждый квартал' : `Каждые ${interval} месяцев`;
|
||||||
|
|
||||||
|
case RRule.YEARLY:
|
||||||
|
if (interval === 1) {
|
||||||
|
if (options.bymonth && options.bymonthday) {
|
||||||
|
const month = options.bymonth[0];
|
||||||
|
const day = options.bymonthday[0];
|
||||||
|
const monthNames = [
|
||||||
|
'января',
|
||||||
|
'февраля',
|
||||||
|
'марта',
|
||||||
|
'апреля',
|
||||||
|
'мая',
|
||||||
|
'июня',
|
||||||
|
'июля',
|
||||||
|
'августа',
|
||||||
|
'сентября',
|
||||||
|
'октября',
|
||||||
|
'ноября',
|
||||||
|
'декабря',
|
||||||
|
];
|
||||||
|
return `Каждый год ${day} ${monthNames[month - 1]}`;
|
||||||
|
}
|
||||||
|
return 'Каждый год';
|
||||||
|
}
|
||||||
|
return `Каждые ${interval} лет`;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return 'Повторяющееся событие';
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error parsing recurrence:', error);
|
||||||
|
return 'Повторяющееся событие';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Функции для файлов
|
||||||
|
const getFileName = (fileData) => {
|
||||||
|
if (fileData.file) {
|
||||||
|
const fileName = fileData.file.split('/').pop();
|
||||||
|
return decodeURIComponent(fileName) || 'Файл';
|
||||||
|
}
|
||||||
|
return fileData.name || 'Файл';
|
||||||
|
};
|
||||||
|
|
||||||
|
const getFileIcon = (fileData) => {
|
||||||
|
const fileName = getFileName(fileData);
|
||||||
|
const extension = fileName.split('.').pop()?.toLowerCase() || '';
|
||||||
|
|
||||||
|
const iconMap = {
|
||||||
|
pdf: 'mdi-file-pdf',
|
||||||
|
doc: 'mdi-file-word',
|
||||||
|
docx: 'mdi-file-word',
|
||||||
|
xls: 'mdi-file-excel',
|
||||||
|
xlsx: 'mdi-file-excel',
|
||||||
|
jpg: 'mdi-file-image',
|
||||||
|
jpeg: 'mdi-file-image',
|
||||||
|
png: 'mdi-file-image',
|
||||||
|
zip: 'mdi-folder-zip',
|
||||||
|
rar: 'mdi-folder-zip',
|
||||||
|
txt: 'mdi-file-document',
|
||||||
|
};
|
||||||
|
|
||||||
|
return iconMap[extension] || 'mdi-file';
|
||||||
|
};
|
||||||
|
|
||||||
|
const downloadFile = (file) => {
|
||||||
|
try {
|
||||||
|
const fileUrl = file.file.startsWith('http')
|
||||||
|
? file.file
|
||||||
|
: `${window.location.origin}${file.file}`;
|
||||||
|
|
||||||
|
const link = document.createElement('a');
|
||||||
|
link.href = fileUrl;
|
||||||
|
link.download = getFileName(file);
|
||||||
|
link.style.display = 'none';
|
||||||
|
document.body.appendChild(link);
|
||||||
|
link.click();
|
||||||
|
setTimeout(() => {
|
||||||
|
document.body.removeChild(link);
|
||||||
|
}, 100);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Ошибка скачивания файла:', error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const truncateFileName = (fileName) => {
|
||||||
|
if (!fileName) return 'Файл';
|
||||||
|
|
||||||
|
if (fileName.length <= 30) return fileName;
|
||||||
|
|
||||||
|
const extension = fileName.split('.').pop();
|
||||||
|
const nameWithoutExt = fileName.slice(0, -(extension.length + 1));
|
||||||
|
|
||||||
|
if (nameWithoutExt.length <= 20) return fileName;
|
||||||
|
|
||||||
|
return `${nameWithoutExt.slice(0, 20)}...${extension ? '.' + extension : ''}`;
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
internalShow,
|
||||||
|
closeDialog,
|
||||||
|
calendarName,
|
||||||
|
calendarColor,
|
||||||
|
participantsList,
|
||||||
|
formatDateTime,
|
||||||
|
recurrenceText,
|
||||||
|
getFileName,
|
||||||
|
getFileIcon,
|
||||||
|
downloadFile,
|
||||||
|
truncateFileName,
|
||||||
|
showRepeatEnd,
|
||||||
|
formatRepeatEndDate,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
<style scoped>
|
||||||
|
.border-bottom {
|
||||||
|
border-bottom: 1px solid #e0e0e0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cursor-pointer {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.participants-list {
|
||||||
|
line-height: 1.6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.description-text {
|
||||||
|
white-space: pre-wrap;
|
||||||
|
line-height: 1.6;
|
||||||
|
background-color: #fafafa;
|
||||||
|
padding: 12px;
|
||||||
|
border-radius: 4px;
|
||||||
|
border-left: 3px solid #00897b;
|
||||||
|
}
|
||||||
|
|
||||||
|
.gap {
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Убираем стандартные отступы Vuetify для более чистого вида */
|
||||||
|
:deep(.v-card-text) {
|
||||||
|
padding: 8px 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.v-card-title) {
|
||||||
|
padding: 16px 20px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -11,8 +11,6 @@
|
|||||||
<v-row no-gutters class="flex-column">
|
<v-row no-gutters class="flex-column">
|
||||||
<v-col class="d-flex flex-column">
|
<v-col class="d-flex flex-column">
|
||||||
<v-row no-gutters class="align-center">
|
<v-row no-gutters class="align-center">
|
||||||
<!-- <my-helper :pretext="propsEvent.event" /> -->
|
|
||||||
|
|
||||||
<v-col class="text-body-2 text-text_grey pb-5" lg="2"> Название </v-col>
|
<v-col class="text-body-2 text-text_grey pb-5" lg="2"> Название </v-col>
|
||||||
|
|
||||||
<v-col>
|
<v-col>
|
||||||
@@ -33,6 +31,7 @@
|
|||||||
<calendar-create-select
|
<calendar-create-select
|
||||||
:staff="newStaff"
|
:staff="newStaff"
|
||||||
@returnIdParticant="returnIdParticant"
|
@returnIdParticant="returnIdParticant"
|
||||||
|
:authorID="currentCalendarAuthorId"
|
||||||
/> </v-col
|
/> </v-col
|
||||||
></v-row>
|
></v-row>
|
||||||
|
|
||||||
@@ -52,7 +51,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 }">
|
||||||
@@ -122,33 +120,36 @@
|
|||||||
>
|
>
|
||||||
</v-autocomplete>
|
</v-autocomplete>
|
||||||
</v-col>
|
</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-row>
|
||||||
<v-col class="text-body-2 text-text_grey pt-3 h-0" lg="2"> Напоминание </v-col>
|
</v-col>
|
||||||
|
<v-row no-gutters class="align-top" style="height: 50px">
|
||||||
|
<v-col class="text-body-2 text-text_grey" lg="2"> Окончание события </v-col>
|
||||||
<v-col class="d-flex flex-column">
|
<v-col class="d-flex flex-column">
|
||||||
<v-row no-gutters class="gap flex-grow-0">
|
<v-row class="gap" no-gutters>
|
||||||
<reminder-event />
|
<v-checkbox
|
||||||
|
v-model="showRepeatEnd"
|
||||||
|
:disabled="isRepeatEndDisabled"
|
||||||
|
density="compact"
|
||||||
|
hide-details
|
||||||
|
class="pr-3 pb-3"
|
||||||
|
/>
|
||||||
|
<time-select
|
||||||
|
:showTime="false"
|
||||||
|
v-if="showRepeatEnd"
|
||||||
|
:chek="false"
|
||||||
|
:order="[1, 2]"
|
||||||
|
:dateEvent="repeatEndDate ? String(repeatEndDate) : new Date()"
|
||||||
|
@update:dateEvent="updateRepeatEndDate"
|
||||||
|
/>
|
||||||
</v-row>
|
</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-col>
|
||||||
</v-row>
|
</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"
|
||||||
style="height: auto; min-height: 100px; max-height: 400px"
|
style="height: auto; min-height: 100px; max-height: 300px"
|
||||||
>
|
>
|
||||||
<v-col class="text-body-2 text-text_grey pb-5 pt-3" lg="2"> Файлы </v-col>
|
<v-col class="text-body-2 text-text_grey pb-5 pt-3" lg="2"> Файлы </v-col>
|
||||||
|
|
||||||
@@ -159,15 +160,16 @@
|
|||||||
@postFiles="postFiles"
|
@postFiles="postFiles"
|
||||||
/>
|
/>
|
||||||
</v-row>
|
</v-row>
|
||||||
<v-row no-gutters class="align-center">
|
<v-row no-gutters class="align-center pt-6">
|
||||||
<v-col>
|
<v-col>
|
||||||
<v-textarea
|
<v-textarea
|
||||||
density="compact"
|
density="compact"
|
||||||
label="Дополнительное описание"
|
label="Дополнительное описание"
|
||||||
row-height="25"
|
|
||||||
rows="3"
|
rows="3"
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
|
auto-grow
|
||||||
v-model="propsEvent.event.description"
|
v-model="propsEvent.event.description"
|
||||||
|
class="scrollable-textarea pt-3"
|
||||||
></v-textarea> </v-col
|
></v-textarea> </v-col
|
||||||
></v-row>
|
></v-row>
|
||||||
</v-row>
|
</v-row>
|
||||||
@@ -188,6 +190,7 @@ import PeriodEvents from '@/components/calendar_of_events/UI_calendar/periodEven
|
|||||||
import { useAlertStore } from '@/store/UseAlertStore';
|
import { useAlertStore } from '@/store/UseAlertStore';
|
||||||
import { RRule } from 'rrule';
|
import { RRule } from 'rrule';
|
||||||
import { useRecurrence } from '@/components/calendar_of_events/composables/useReccurrence';
|
import { useRecurrence } from '@/components/calendar_of_events/composables/useReccurrence';
|
||||||
|
import { useCalendarStore } from '../../store/calendarStore';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
@@ -204,14 +207,19 @@ export default {
|
|||||||
type: Object,
|
type: Object,
|
||||||
default: () => {},
|
default: () => {},
|
||||||
},
|
},
|
||||||
myCalendars: {
|
allCalendars: {
|
||||||
type: Array,
|
type: Array,
|
||||||
default: () => [],
|
default: () => [],
|
||||||
},
|
},
|
||||||
|
selectedRule: {
|
||||||
|
type: Object,
|
||||||
|
default: null,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
setup(props, { emit }) {
|
setup(props, { emit }) {
|
||||||
const accountStore = useAccountStore();
|
const accountStore = useAccountStore();
|
||||||
|
const calendarStore = useCalendarStore();
|
||||||
const createDialog = ref(null);
|
const createDialog = ref(null);
|
||||||
|
|
||||||
const { parseRecurrenceOptions, isRecurringEvent } = useRecurrence();
|
const { parseRecurrenceOptions, isRecurringEvent } = useRecurrence();
|
||||||
@@ -224,6 +232,87 @@ export default {
|
|||||||
set: (value) => emit('update:eventCalendar', value),
|
set: (value) => emit('update:eventCalendar', value),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const currentCalendarAuthorId = computed(() => {
|
||||||
|
if (isNewEvent.value) {
|
||||||
|
// Для нового события - автор текущего выбранного календаря
|
||||||
|
return myCalendar.value?.author;
|
||||||
|
} else {
|
||||||
|
// Для существующего события - автор календаря события
|
||||||
|
const eventCalendarId = propsEvent.value.event.calendar;
|
||||||
|
const currentCalendar = propsEvent.value.mycalendars?.find(
|
||||||
|
(cal) => parseInt(cal.id) === parseInt(eventCalendarId),
|
||||||
|
);
|
||||||
|
return currentCalendar?.author;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const newStaff = computed({
|
||||||
|
get() {
|
||||||
|
let filteredStaff = [];
|
||||||
|
|
||||||
|
if (isNewEvent.value) {
|
||||||
|
if (myCalendar.value == null) return [];
|
||||||
|
const participants = myCalendar.value.participant || [];
|
||||||
|
const calendarParticipantIds = new Set(participants.map((p) => p.participant_calendar));
|
||||||
|
|
||||||
|
// Мутируем И фильтруем для НОВОГО события
|
||||||
|
filteredStaff = calendarStore.employees
|
||||||
|
.map((department) => {
|
||||||
|
// ФИЛЬТРУЕМ сотрудников - оставляем только тех, кто в календаре
|
||||||
|
const filteredEmployees = department.employees.filter((employee) =>
|
||||||
|
calendarParticipantIds.has(employee.id),
|
||||||
|
);
|
||||||
|
|
||||||
|
// МУТАЦИЯ: устанавливаем selected=true для отфильтрованных сотрудников
|
||||||
|
filteredEmployees.forEach((employee) => {
|
||||||
|
employee.selected = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
...department,
|
||||||
|
employees: filteredEmployees,
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.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 || []);
|
||||||
|
|
||||||
|
// Мутируем И фильтруем для СУЩЕСТВУЮЩЕГО события
|
||||||
|
filteredStaff = calendarStore.employees
|
||||||
|
.map((department) => {
|
||||||
|
// ФИЛЬТРУЕМ сотрудников - оставляем только тех, кто в календаре
|
||||||
|
const filteredEmployees = department.employees.filter((employee) =>
|
||||||
|
calendarParticipantIds.has(employee.id),
|
||||||
|
);
|
||||||
|
|
||||||
|
// МУТАЦИЯ: устанавливаем selected на основе участников события
|
||||||
|
filteredEmployees.forEach((employee) => {
|
||||||
|
employee.selected =
|
||||||
|
employee.id === accountStore.user.is_idEmployee ||
|
||||||
|
eventParticipantIds.has(employee.id);
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
...department,
|
||||||
|
employees: filteredEmployees,
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.filter((dept) => dept.employees.length > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return filteredStaff;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
// ВАЛИДАЦИЯ
|
// ВАЛИДАЦИЯ
|
||||||
const rules = {
|
const rules = {
|
||||||
name: [
|
name: [
|
||||||
@@ -233,6 +322,7 @@ export default {
|
|||||||
],
|
],
|
||||||
calendar: [(val) => !!val || 'Выберите календарь'],
|
calendar: [(val) => !!val || 'Выберите календарь'],
|
||||||
};
|
};
|
||||||
|
|
||||||
const repeatRules = [
|
const repeatRules = [
|
||||||
{ type: 'Не повторять', rule: null, id: 1 },
|
{ type: 'Не повторять', rule: null, id: 1 },
|
||||||
{
|
{
|
||||||
@@ -252,6 +342,7 @@ export default {
|
|||||||
},
|
},
|
||||||
id: 3,
|
id: 3,
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
type: 'Каждый месяц',
|
type: 'Каждый месяц',
|
||||||
rule: { freq: RRule.MONTHLY },
|
rule: { freq: RRule.MONTHLY },
|
||||||
@@ -262,6 +353,20 @@ export default {
|
|||||||
}),
|
}),
|
||||||
id: 4,
|
id: 4,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
type: 'Каждый квартал',
|
||||||
|
rule: { freq: RRule.MONTHLY, interval: 3 },
|
||||||
|
getRule: (startDate) => {
|
||||||
|
const date = new Date(startDate);
|
||||||
|
return {
|
||||||
|
freq: RRule.MONTHLY,
|
||||||
|
interval: 3, // каждые 3 месяца
|
||||||
|
bymonthday: [date.getDate()],
|
||||||
|
};
|
||||||
|
},
|
||||||
|
id: 6,
|
||||||
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
type: 'Каждый год',
|
type: 'Каждый год',
|
||||||
rule: { freq: RRule.YEARLY },
|
rule: { freq: RRule.YEARLY },
|
||||||
@@ -279,11 +384,16 @@ export default {
|
|||||||
];
|
];
|
||||||
|
|
||||||
const selectedRule = ref(repeatRules[0]);
|
const selectedRule = ref(repeatRules[0]);
|
||||||
|
const showRepeatEnd = ref(false);
|
||||||
|
const repeatEndDate = ref(new Date());
|
||||||
|
|
||||||
// Инициализация при редактировании
|
// Инициализация повторов при редактировании
|
||||||
const initializeRule = () => {
|
const initializeRule = () => {
|
||||||
if (!propsEvent.value.event.period) {
|
if (!propsEvent.value.event.period) {
|
||||||
selectedRule.value = repeatRules[0]; // "Не повторять"
|
selectedRule.value = repeatRules[0]; // "Не повторять"
|
||||||
|
repeatEndDate.value = propsEvent.value.event.date_end
|
||||||
|
? new Date(propsEvent.value.event.date_end)
|
||||||
|
: new Date();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@@ -296,19 +406,53 @@ export default {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (rruleOptions) {
|
if (rruleOptions) {
|
||||||
// Находим правило в repeatRules по freq
|
// ОБНОВЛЕННЫЙ ПОИСК ПРАВИЛА С ПОДДЕРЖКОЙ КВАРТАЛОВ
|
||||||
const foundRule = repeatRules.find((rule) => rule.rule?.freq === rruleOptions.freq);
|
let foundRule;
|
||||||
|
|
||||||
|
// Для квартальных событий (MONTHLY с interval=3)
|
||||||
|
if (rruleOptions.freq === RRule.MONTHLY && rruleOptions.interval === 3) {
|
||||||
|
foundRule = repeatRules.find((rule) => rule.id === 6); // ID квартального правила
|
||||||
|
} else {
|
||||||
|
// Для остальных типов - ищем по freq
|
||||||
|
foundRule = repeatRules.find((rule) => rule.rule?.freq === rruleOptions.freq);
|
||||||
|
}
|
||||||
|
|
||||||
selectedRule.value = foundRule || repeatRules[0];
|
selectedRule.value = foundRule || repeatRules[0];
|
||||||
|
|
||||||
|
// ВАЖНО: инициализируем repeatEndDate и showRepeatEnd
|
||||||
|
if (rruleOptions.until) {
|
||||||
|
// Если в RRULE есть UNTIL, используем эту дату
|
||||||
|
repeatEndDate.value = new Date(rruleOptions.until);
|
||||||
|
showRepeatEnd.value = true;
|
||||||
|
} else {
|
||||||
|
// Если нет UNTIL, используем date_end события
|
||||||
|
repeatEndDate.value = propsEvent.value.event.date_end
|
||||||
|
? new Date(propsEvent.value.event.date_end)
|
||||||
|
: new Date();
|
||||||
|
showRepeatEnd.value = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
selectedRule.value = repeatRules[0];
|
selectedRule.value = repeatRules[0];
|
||||||
|
showRepeatEnd.value = false;
|
||||||
|
repeatEndDate.value = propsEvent.value.event.date_end
|
||||||
|
? new Date(propsEvent.value.event.date_end)
|
||||||
|
: new Date();
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error parsing period:', error, 'Raw period:', propsEvent.value.event.period);
|
console.error('Error parsing period:', error, 'Raw period:', propsEvent.value.event.period);
|
||||||
selectedRule.value = repeatRules[0];
|
selectedRule.value = repeatRules[0];
|
||||||
|
showRepeatEnd.value = false;
|
||||||
|
repeatEndDate.value = propsEvent.value.event.date_end
|
||||||
|
? new Date(propsEvent.value.event.date_end)
|
||||||
|
: new Date();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const isRepeatEndDisabled = computed(() => {
|
||||||
|
return !selectedRule.value.rule; // disabled если правило null (не повторять)
|
||||||
|
});
|
||||||
|
|
||||||
const feedalert = useAlertStore().alert;
|
const feedalert = useAlertStore().alert;
|
||||||
|
|
||||||
const titleCard = computed(() => {
|
const titleCard = computed(() => {
|
||||||
@@ -325,7 +469,24 @@ export default {
|
|||||||
// const isNewEvent = computed(() => !propsEvent.value.event.id);
|
// const isNewEvent = computed(() => !propsEvent.value.event.id);
|
||||||
|
|
||||||
// Computed property с защитой от undefined
|
// Computed property с защитой от undefined
|
||||||
const safeCalendars = computed(() => props.myCalendars || []);
|
// const safeCalendars = computed(() => props.allCalendars || []);
|
||||||
|
|
||||||
|
|
||||||
|
const safeCalendars = computed(() => {
|
||||||
|
const userId = accountStore.user.is_idEmployee;
|
||||||
|
|
||||||
|
return (props.allCalendars || []).filter((calendar) => {
|
||||||
|
// Пользователь - автор календаря (полные права)
|
||||||
|
if (calendar.author === userId) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Пользователь - участник с правами редактора
|
||||||
|
const participant = calendar.participant?.find((p) => p.participant_calendar === userId);
|
||||||
|
|
||||||
|
return participant?.editor === true;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
const isCalendarsReady = computed(() => safeCalendars.value.length > 0);
|
const isCalendarsReady = computed(() => safeCalendars.value.length > 0);
|
||||||
|
|
||||||
@@ -367,88 +528,6 @@ export default {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const staff = ref([]);
|
|
||||||
|
|
||||||
axiosApiInstance.get('api/calendar_of_events/get_employees/').then((res) => {
|
|
||||||
staff.value = res.data.filter((e) => e.employees.length > 0);
|
|
||||||
});
|
|
||||||
|
|
||||||
// const newStaff = computed({
|
|
||||||
// get() {
|
|
||||||
// let ns = [];
|
|
||||||
|
|
||||||
// let indCal = safeCalendars.value.findIndex((e) => e.id == myCalendar.id);
|
|
||||||
|
|
||||||
// staff.value.forEach((e) => {
|
|
||||||
// let emp = { ...e };
|
|
||||||
// emp.employees = e.employees.filter((n) => {
|
|
||||||
// if (
|
|
||||||
// n.id == accountStore.user.is_idEmployee ||
|
|
||||||
// propsEvent.value.event.participant.some((e) => n.id == e)
|
|
||||||
// ) {
|
|
||||||
// n.selected = true;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return propsEvent.value.mycalendars[indCal].participant.some(
|
|
||||||
// (part) => part.id === n.id,
|
|
||||||
// );
|
|
||||||
// });
|
|
||||||
|
|
||||||
// if (emp.employees.length > 0) ns.push(emp);
|
|
||||||
// });
|
|
||||||
// return ns;
|
|
||||||
// },
|
|
||||||
// });
|
|
||||||
|
|
||||||
const newStaff = computed(() => {
|
|
||||||
// Для нового события - все сотрудники, для существующего - фильтр по календарю
|
|
||||||
// const isNewEvent = !propsEvent.value.event.id;
|
|
||||||
|
|
||||||
if (isNewEvent) {
|
|
||||||
// НОВОЕ СОБЫТИЕ - все сотрудники
|
|
||||||
const eventParticipantIds = propsEvent.value.event.participant || [];
|
|
||||||
|
|
||||||
return staff.value
|
|
||||||
.map((department) => ({
|
|
||||||
...department,
|
|
||||||
employees: department.employees.map((employee) => ({
|
|
||||||
...employee,
|
|
||||||
selected:
|
|
||||||
employee.id === accountStore.user.is_idEmployee ||
|
|
||||||
eventParticipantIds.includes(employee.id),
|
|
||||||
})),
|
|
||||||
}))
|
|
||||||
.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),
|
|
||||||
);
|
|
||||||
|
|
||||||
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) => ({
|
|
||||||
...department,
|
|
||||||
employees: department.employees.map((employee) => ({
|
|
||||||
...employee,
|
|
||||||
selected: eventParticipantIds.has(employee.id),
|
|
||||||
// Дополнительная информация для UX
|
|
||||||
inCalendar: calendarParticipantIds.has(employee.id),
|
|
||||||
disabled: false, // Всех можно выбирать
|
|
||||||
})),
|
|
||||||
}))
|
|
||||||
.filter((dept) => dept.employees.length > 0);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
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) => {
|
||||||
feedalert.alert = true;
|
feedalert.alert = true;
|
||||||
@@ -518,9 +597,11 @@ export default {
|
|||||||
JSON.stringify({ ...propsEvent.value.event, files: propsEvent.value.event.files }),
|
JSON.stringify({ ...propsEvent.value.event, files: propsEvent.value.event.files }),
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log([propsEvent.value]);
|
|
||||||
if (propsEvent.value.event.files !== null) {
|
if (propsEvent.value.event.files !== null) {
|
||||||
newFiles.value.forEach((e) => postEvent.append('files', e));
|
// newFiles.value.forEach((e) => postEvent.append('files', e));
|
||||||
|
newFiles.value.forEach((file) => {
|
||||||
|
postEvent.append('files', file, file.name);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
axiosApiInstance.post('api/calendar_of_events/my_events/', postEvent).then((result) => {
|
axiosApiInstance.post('api/calendar_of_events/my_events/', postEvent).then((result) => {
|
||||||
@@ -538,6 +619,18 @@ export default {
|
|||||||
propsEvent.value.event.date_end = newEndDate;
|
propsEvent.value.event.date_end = newEndDate;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const updateRepeatEndDate = (date) => {
|
||||||
|
repeatEndDate.value = date;
|
||||||
|
updatePeriodRule(selectedRule.value); // Пересоздаем правило с новой датой
|
||||||
|
};
|
||||||
|
|
||||||
|
watch(selectedRule, (newRule) => {
|
||||||
|
if (!newRule.rule) {
|
||||||
|
showRepeatEnd.value = false;
|
||||||
|
repeatEndDate.value = null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const updateDateStart = (newDate) => {
|
const updateDateStart = (newDate) => {
|
||||||
// Нормализуем к ISO строке
|
// Нормализуем к ISO строке
|
||||||
const normalizedDate = new Date(newDate).toISOString();
|
const normalizedDate = new Date(newDate).toISOString();
|
||||||
@@ -579,6 +672,10 @@ export default {
|
|||||||
dtstart: dtstart,
|
dtstart: dtstart,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (showRepeatEnd.value && repeatEndDate.value) {
|
||||||
|
ruleOptions.until = new Date(repeatEndDate.value);
|
||||||
|
}
|
||||||
|
|
||||||
if (rule.rule.freq === RRule.WEEKLY) {
|
if (rule.rule.freq === RRule.WEEKLY) {
|
||||||
const day = new Date(propsEvent.value.event.date_start).getDay();
|
const day = new Date(propsEvent.value.event.date_start).getDay();
|
||||||
// Преобразуем день недели в формат RRule (0 — понедельник)
|
// Преобразуем день недели в формат RRule (0 — понедельник)
|
||||||
@@ -612,7 +709,6 @@ export default {
|
|||||||
menudate,
|
menudate,
|
||||||
titleCard,
|
titleCard,
|
||||||
propsEvent,
|
propsEvent,
|
||||||
staff,
|
|
||||||
newStaff,
|
newStaff,
|
||||||
returnIdParticant,
|
returnIdParticant,
|
||||||
postFiles,
|
postFiles,
|
||||||
@@ -623,6 +719,8 @@ export default {
|
|||||||
safeCalendars,
|
safeCalendars,
|
||||||
isCalendarsReady,
|
isCalendarsReady,
|
||||||
isNewEvent,
|
isNewEvent,
|
||||||
|
currentCalendarAuthorId,
|
||||||
|
isRepeatEndDisabled,
|
||||||
|
|
||||||
repeatRules,
|
repeatRules,
|
||||||
updatePeriodRule,
|
updatePeriodRule,
|
||||||
@@ -636,9 +734,35 @@ export default {
|
|||||||
newFiles,
|
newFiles,
|
||||||
handleFilesUpdate,
|
handleFilesUpdate,
|
||||||
initializeCalendar,
|
initializeCalendar,
|
||||||
|
updateRepeatEndDate,
|
||||||
|
showRepeatEnd,
|
||||||
|
repeatEndDate,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style></style>
|
<style>
|
||||||
|
.scrollable-textarea {
|
||||||
|
overflow-y: auto;
|
||||||
|
max-height: 160px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.scrollable-textarea::-webkit-scrollbar {
|
||||||
|
width: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.scrollable-textarea::-webkit-scrollbar-track {
|
||||||
|
background: #f1f1f1;
|
||||||
|
border-radius: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.scrollable-textarea::-webkit-scrollbar-thumb {
|
||||||
|
background: #c1c1c1;
|
||||||
|
border-radius: 1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.scrollable-textarea::-webkit-scrollbar-thumb:hover {
|
||||||
|
background: #a8a8a8;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -1,5 +1,8 @@
|
|||||||
<template>
|
<template>
|
||||||
<v-card>
|
<v-card flat class="flip-card">
|
||||||
|
<div class="flip-card-inner" :class="{ 'is-flipped': isExpanded }">
|
||||||
|
<!-- Передняя сторона карточки -->
|
||||||
|
<div class="flip-card-front">
|
||||||
<v-card-text class="d-flex justify-space-between ga-3 text-h6">
|
<v-card-text class="d-flex justify-space-between ga-3 text-h6">
|
||||||
<v-tooltip bottom>
|
<v-tooltip bottom>
|
||||||
<template v-slot:activator="{ props }">
|
<template v-slot:activator="{ props }">
|
||||||
@@ -16,7 +19,8 @@
|
|||||||
<v-col>
|
<v-col>
|
||||||
<v-carousel
|
<v-carousel
|
||||||
cycle
|
cycle
|
||||||
height="200" hide-delimiters
|
height="200"
|
||||||
|
hide-delimiters
|
||||||
show-arrows="hover">
|
show-arrows="hover">
|
||||||
<v-carousel-item
|
<v-carousel-item
|
||||||
v-for="(picture, index) in images"
|
v-for="(picture, index) in images"
|
||||||
@@ -26,41 +30,60 @@
|
|||||||
</v-carousel>
|
</v-carousel>
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
<v-card-text class="">
|
<v-card-text class="description-container">
|
||||||
<v-tooltip bottom>
|
<span>
|
||||||
<template v-slot:activator="{ props }">
|
{{ truncatedText }}
|
||||||
<span
|
<span
|
||||||
style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis;"
|
v-if="needsTruncation"
|
||||||
v-bind="props">
|
class="show-more-btn"
|
||||||
{{ voteCard.description }}
|
@click="isExpanded = true"
|
||||||
|
>
|
||||||
|
...полное описание➡️
|
||||||
|
</span>
|
||||||
</span>
|
</span>
|
||||||
</template>
|
|
||||||
<span>{{ voteCard.description }}</span>
|
|
||||||
</v-tooltip>
|
|
||||||
</v-card-text>
|
</v-card-text>
|
||||||
<div class="px-2">
|
<div class="px-2">
|
||||||
<Timer v-if="!isFinished" :voteTime="{ dateend: voteCard.dateend, datestart: voteCard.datestart }"
|
<Timer
|
||||||
@changeBtn="(time) => timeChange = time"/>
|
v-if="!isFinished"
|
||||||
|
:voteTime="{ dateend: voteCard.dateend, datestart: voteCard.datestart }"
|
||||||
<div v-else class="font-weight-bold text-center"> Завершено: {{
|
@changeBtn="(time) => timeChange = time"
|
||||||
new Date(voteCard.dateend).toLocaleDateString()
|
/>
|
||||||
}}
|
<div v-else class="font-weight-bold text-center">
|
||||||
|
Завершено: {{ new Date(voteCard.dateend).toLocaleDateString() }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<v-card-actions class="justify-space-between mt-4 pb-2">
|
<v-card-actions class="justify-space-between mt-4 pb-2">
|
||||||
<template v-if="!isFinished">
|
<template v-if="!isFinished">
|
||||||
<v-btn :disabled="voteCard.is_passed || timeChange" color="teal-darken-4" prepend-icon="mdi-vote-outline"
|
<v-btn
|
||||||
rounded="xl" size="small" variant="outlined" @click="$emit('openVoteModal', voteCard)">
|
:disabled="voteCard.is_passed || timeChange"
|
||||||
|
color="teal-darken-4"
|
||||||
|
prepend-icon="mdi-vote-outline"
|
||||||
|
rounded="xl"
|
||||||
|
size="small"
|
||||||
|
variant="outlined"
|
||||||
|
@click="$emit('openVoteModal', voteCard)"
|
||||||
|
>
|
||||||
{{ !voteCard.is_passed ? "Проголосовать" : "Уже проголосовали" }}
|
{{ !voteCard.is_passed ? "Проголосовать" : "Уже проголосовали" }}
|
||||||
</v-btn>
|
</v-btn>
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-if="user.id === voteCard.author || isFinished || user.is_superuser">
|
||||||
<v-btn color="teal-darken-4" prepend-icon="mdi-trophy-outline"
|
<v-btn
|
||||||
rounded="xl" size="small" variant="outlined" @click="$emit('openResultModal', voteCard)">
|
color="teal-darken-4"
|
||||||
|
prepend-icon="mdi-trophy-outline"
|
||||||
|
rounded="xl"
|
||||||
|
size="small"
|
||||||
|
variant="outlined"
|
||||||
|
@click="$emit('openResultModal', voteCard)"
|
||||||
|
>
|
||||||
Результаты
|
Результаты
|
||||||
</v-btn>
|
</v-btn>
|
||||||
</template>
|
</template>
|
||||||
<v-btn v-if="user.id === voteCard.author || user.is_superuser" color="error" size="medium" @click="youSure=true">
|
<v-btn
|
||||||
|
v-if="user.id === voteCard.author || user.is_superuser"
|
||||||
|
color="error"
|
||||||
|
size="medium"
|
||||||
|
@click="youSure=true"
|
||||||
|
>
|
||||||
<v-icon>mdi-delete</v-icon>
|
<v-icon>mdi-delete</v-icon>
|
||||||
<v-dialog v-model="youSure" width="500">
|
<v-dialog v-model="youSure" width="500">
|
||||||
<v-card class="flex" max-width="450">
|
<v-card class="flex" max-width="450">
|
||||||
@@ -78,12 +101,14 @@
|
|||||||
<v-btn-group>
|
<v-btn-group>
|
||||||
<v-btn
|
<v-btn
|
||||||
class="text-red"
|
class="text-red"
|
||||||
@click="$emit('deleteVoting', voteCard.id), youSure = false">
|
@click="$emit('deleteVoting', voteCard.id), youSure = false"
|
||||||
|
>
|
||||||
Да
|
Да
|
||||||
</v-btn>
|
</v-btn>
|
||||||
<v-btn
|
<v-btn
|
||||||
class="text-green"
|
class="text-green"
|
||||||
@click="youSure = false">
|
@click="youSure = false"
|
||||||
|
>
|
||||||
Нет
|
Нет
|
||||||
</v-btn>
|
</v-btn>
|
||||||
</v-btn-group>
|
</v-btn-group>
|
||||||
@@ -92,6 +117,30 @@
|
|||||||
</v-dialog>
|
</v-dialog>
|
||||||
</v-btn>
|
</v-btn>
|
||||||
</v-card-actions>
|
</v-card-actions>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Задняя сторона карточки -->
|
||||||
|
<div class="flip-card-back">
|
||||||
|
<v-card-text class="text-h6">
|
||||||
|
{{ voteCard.name }}
|
||||||
|
</v-card-text>
|
||||||
|
<v-card-text class="description-full">
|
||||||
|
{{ voteCard.description }}
|
||||||
|
</v-card-text>
|
||||||
|
<v-card-actions class="justify-center mt-4 pb-2">
|
||||||
|
<v-btn
|
||||||
|
color="teal-darken-4"
|
||||||
|
prepend-icon="mdi-arrow-left"
|
||||||
|
rounded="xl"
|
||||||
|
size="small"
|
||||||
|
variant="outlined"
|
||||||
|
@click="isExpanded = false"
|
||||||
|
>
|
||||||
|
Обратно
|
||||||
|
</v-btn>
|
||||||
|
</v-card-actions>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</v-card>
|
</v-card>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -131,6 +180,20 @@ export default {
|
|||||||
const accountStore = useAccountStore();
|
const accountStore = useAccountStore();
|
||||||
const user = accountStore.user;
|
const user = accountStore.user;
|
||||||
|
|
||||||
|
const isExpanded = ref(false);
|
||||||
|
const maxLength = 22;
|
||||||
|
|
||||||
|
const needsTruncation = computed(() => {
|
||||||
|
return props.voteCard.description.length > maxLength;
|
||||||
|
});
|
||||||
|
|
||||||
|
const truncatedText = computed(() => {
|
||||||
|
if (!needsTruncation.value) {
|
||||||
|
return props.voteCard.description;
|
||||||
|
}
|
||||||
|
return props.voteCard.description.slice(0, maxLength);
|
||||||
|
});
|
||||||
|
|
||||||
const images = computed(() => {
|
const images = computed(() => {
|
||||||
return props.voteCard.files.length > 0 ? props.voteCard.files : ['']
|
return props.voteCard.files.length > 0 ? props.voteCard.files : ['']
|
||||||
})
|
})
|
||||||
@@ -143,9 +206,83 @@ export default {
|
|||||||
isFinished.value = true;
|
isFinished.value = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {timeChange, baseURL, images, youSure, isFinished, user, defaultImage}
|
return {
|
||||||
|
timeChange,
|
||||||
|
baseURL,
|
||||||
|
images,
|
||||||
|
youSure,
|
||||||
|
isFinished,
|
||||||
|
user,
|
||||||
|
defaultImage,
|
||||||
|
isExpanded,
|
||||||
|
truncatedText,
|
||||||
|
needsTruncation
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.flip-card {
|
||||||
|
perspective: 1000px;
|
||||||
|
background: transparent !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
.flip-card-inner {
|
||||||
|
position: relative;
|
||||||
|
width: 100%;
|
||||||
|
transition: transform 0.6s;
|
||||||
|
transform-style: preserve-3d;
|
||||||
|
}
|
||||||
|
|
||||||
|
.flip-card-inner.is-flipped {
|
||||||
|
transform: rotateY(180deg);
|
||||||
|
}
|
||||||
|
|
||||||
|
.flip-card-front,
|
||||||
|
.flip-card-back {
|
||||||
|
width: 100%;
|
||||||
|
backface-visibility: hidden;
|
||||||
|
-webkit-backface-visibility: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.flip-card-front {
|
||||||
|
background: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.flip-card-back {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
background: white;
|
||||||
|
transform: rotateY(180deg);
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
padding: 16px;
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.description-container {
|
||||||
|
word-wrap: break-word;
|
||||||
|
}
|
||||||
|
|
||||||
|
.description-full {
|
||||||
|
word-wrap: break-word;
|
||||||
|
white-space: pre-wrap;
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.show-more-btn {
|
||||||
|
color: #1976d2;
|
||||||
|
cursor: pointer;
|
||||||
|
font-weight: 500;
|
||||||
|
user-select: none;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.show-more-btn:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -38,15 +38,15 @@
|
|||||||
<v-card
|
<v-card
|
||||||
class="cursor-pointer"
|
class="cursor-pointer"
|
||||||
@click="opendialogWinn(department, getWinnersByDepartment(question).groupedByDepartment[department])"
|
@click="opendialogWinn(department, getWinnersByDepartment(question).groupedByDepartment[department])"
|
||||||
style="max-height: 50vh; overflow-y: auto;">
|
style="height: 30vh; overflow-y: auto;">
|
||||||
<v-card-title>
|
<v-card-title>
|
||||||
<strong class="text-teal-darken-4">{{ department }}</strong>
|
<strong class="text-teal-darken-4" style="max-width: 800px; white-space: normal; word-wrap: break-word;">{{ department }}</strong>
|
||||||
</v-card-title>
|
</v-card-title>
|
||||||
<v-card-subtitle>
|
<v-card-subtitle>
|
||||||
Победитель: {{ winner.employee.fio || winner.name }} 🏆
|
Победитель: {{ getWinnerNames(winner) }} 🏆
|
||||||
</v-card-subtitle>
|
</v-card-subtitle>
|
||||||
<v-card-text>
|
<v-card-text>
|
||||||
Количество голосов: {{ winner.count }}
|
Количество голосов: {{ winner[0]?.count || 0 }}
|
||||||
</v-card-text>
|
</v-card-text>
|
||||||
</v-card>
|
</v-card>
|
||||||
</v-col>
|
</v-col>
|
||||||
@@ -57,10 +57,10 @@
|
|||||||
<h3 class="text-center">{{ question.name }}</h3>
|
<h3 class="text-center">{{ question.name }}</h3>
|
||||||
<v-card-title class="d-flex ga-2 align-center">
|
<v-card-title class="d-flex ga-2 align-center">
|
||||||
<h4 class="text-teal-darken-4">Победитель:</h4>
|
<h4 class="text-teal-darken-4">Победитель:</h4>
|
||||||
<h3>{{ getWinner(question).employee?.fio || getWinner(question).name }} 🏆</h3>
|
<h3>{{ getWinnerNames(getWinners(question)) }} 🏆</h3>
|
||||||
</v-card-title>
|
</v-card-title>
|
||||||
<v-card-subtitle>
|
<v-card-subtitle>
|
||||||
Количество голосов: {{ getWinner(question)?.count || 0 }}
|
Количество голосов: {{ getWinners(question)[0]?.count || 0 }}
|
||||||
</v-card-subtitle>
|
</v-card-subtitle>
|
||||||
</v-col>
|
</v-col>
|
||||||
<v-col cols="12">
|
<v-col cols="12">
|
||||||
@@ -77,17 +77,17 @@
|
|||||||
<v-avatar v-if="answer.file === null && answer.employee"
|
<v-avatar v-if="answer.file === null && answer.employee"
|
||||||
:image="checkremote(`${spravURL()}${answer.employee.login}.jpg`)"
|
:image="checkremote(`${spravURL()}${answer.employee.login}.jpg`)"
|
||||||
class="cursor-pointer"
|
class="cursor-pointer"
|
||||||
@click.stop="opendialog(checkremote(`${spravURL()}${answer.employee.login}.jpg`))"/>
|
@click.stop="opendialog(checkremote(`${spravURL()}${answer.employee.login}.jpg`))" />
|
||||||
<v-avatar v-if="answer.file !== null" :image="baseURL.slice(0, -1) + answer.file"
|
<v-avatar v-if="answer.file !== null" :image="baseURL.slice(0, -1) + answer.file"
|
||||||
class="cursor-pointer"
|
class="cursor-pointer"
|
||||||
@click.stop="opendialog(answer)"/>
|
@click.stop="opendialog(answer)" />
|
||||||
<strong class="ml-4">{{ answer.employee ? answer.employee.fio : answer.name }}</strong>:
|
<strong class="ml-4">{{ answer.employee ? answer.employee.fio : answer.name }}</strong>:
|
||||||
{{ answer.count }}
|
{{ answer.count }}
|
||||||
{{ voteCount(answer.count) }}
|
{{ voteCount(answer.count) }}
|
||||||
<template v-if="answer.employee">
|
<template v-if="answer.employee">
|
||||||
<br/>
|
<br />
|
||||||
<small>Отдел: {{ answer.employee ? answer.employee.department : '' }}</small>
|
<small>Отдел: {{ answer.employee ? answer.employee.department : '' }}</small>
|
||||||
<br/>
|
<br />
|
||||||
<small>Должность: {{ answer.employee ? answer.employee.post : '' }}</small>
|
<small>Должность: {{ answer.employee ? answer.employee.post : '' }}</small>
|
||||||
</template>
|
</template>
|
||||||
</p>
|
</p>
|
||||||
@@ -111,12 +111,12 @@
|
|||||||
</v-row>
|
</v-row>
|
||||||
</v-tabs-window-item>
|
</v-tabs-window-item>
|
||||||
<v-tabs-window-item>
|
<v-tabs-window-item>
|
||||||
<NonVoteSad v-if="nonVoters.length > 0"/>
|
<NonVoteSad v-if="nonVoters.length > 0" />
|
||||||
<v-card-title v-if="nonVoters.length > 0" class="text-red-darken-3">Число сотрудников, которые не проголосовали
|
<v-card-title v-if="nonVoters.length > 0" class="text-red-darken-3">Число сотрудников, которые не проголосовали
|
||||||
<strong>{{ nonVoters.length }}</strong>
|
<strong>{{ nonVoters.length }}</strong>
|
||||||
</v-card-title>
|
</v-card-title>
|
||||||
<v-card-item style="max-height: 50vh; overflow-y: auto;">
|
<v-card-item style="max-height: 50vh; overflow-y: auto;">
|
||||||
<NonVoteHappy v-if="nonVoters.length < 1"/>
|
<NonVoteHappy v-if="nonVoters.length < 1" />
|
||||||
<template v-for="(voters, department) in groupedByDepartment" :key="department">
|
<template v-for="(voters, department) in groupedByDepartment" :key="department">
|
||||||
<v-list-item-title class="text-teal-darken-4">{{ department }}</v-list-item-title>
|
<v-list-item-title class="text-teal-darken-4">{{ department }}</v-list-item-title>
|
||||||
<v-list-item v-for="(voter, voterIndex) in voters" :key="`${department}-${voterIndex}`">
|
<v-list-item v-for="(voter, voterIndex) in voters" :key="`${department}-${voterIndex}`">
|
||||||
@@ -148,7 +148,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<v-spacer></v-spacer>
|
<v-spacer></v-spacer>
|
||||||
<div>
|
<div>
|
||||||
<v-btn color="red-darken-1" density="compact" icon="mdi-close-thick" size="small" @click="dialog=false"/>
|
<v-btn color="red-darken-1" density="compact" icon="mdi-close-thick" size="small" @click="dialog=false" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</v-card-title>
|
</v-card-title>
|
||||||
@@ -162,14 +162,14 @@
|
|||||||
<v-dialog v-model="dialogWinner" max-width="800">
|
<v-dialog v-model="dialogWinner" max-width="800">
|
||||||
<v-card>
|
<v-card>
|
||||||
<v-card-title class="d-flex">
|
<v-card-title class="d-flex">
|
||||||
<strong class="text-teal-darken-4">Результаты голосования: {{ activeDepartment }}</strong>
|
<strong class="text-teal-darken-4" style="max-width: 800px; white-space: normal; word-wrap: break-word;">Результаты голосования: {{ activeDepartment }}</strong>
|
||||||
<v-spacer></v-spacer>
|
<v-spacer></v-spacer>
|
||||||
<v-btn color="red-darken-1" density="compact" icon="mdi-close-thick" size="small" @click="dialogWinner=false"/>
|
<v-btn color="red-darken-1" density="compact" icon="mdi-close-thick" size="small" @click="dialogWinner=false" />
|
||||||
</v-card-title>
|
</v-card-title>
|
||||||
<v-card-text>
|
<v-card-text>
|
||||||
<v-list>
|
<v-list>
|
||||||
<v-list-item
|
<v-list-item
|
||||||
v-for="(answer, index) in activeDepartmentResults.filter(el => el.count > 0)"
|
v-for="(answer, index) in activeDepartmentResults.filter(el => el.count > 0).sort((a, b) => b.count - a.count)"
|
||||||
:key="index"
|
:key="index"
|
||||||
>
|
>
|
||||||
<p>
|
<p>
|
||||||
@@ -177,23 +177,22 @@
|
|||||||
<v-avatar v-if="answer.file === null && answer.employee"
|
<v-avatar v-if="answer.file === null && answer.employee"
|
||||||
:image="checkremote(`${spravURL()}${answer.employee.login}.jpg`)"
|
:image="checkremote(`${spravURL()}${answer.employee.login}.jpg`)"
|
||||||
class="cursor-pointer"
|
class="cursor-pointer"
|
||||||
@click.stop="opendialog(checkremote(`${spravURL()}${answer.employee.login}.jpg`))"/>
|
@click.stop="opendialog(checkremote(`${spravURL()}${answer.employee.login}.jpg`))" />
|
||||||
<v-avatar v-if="answer.file !== null" :image="baseURL.slice(0, -1) + answer.file"
|
<v-avatar v-if="answer.file !== null" :image="baseURL.slice(0, -1) + answer.file"
|
||||||
class="cursor-pointer"
|
class="cursor-pointer"
|
||||||
@click.stop="opendialog(answer)"/>
|
@click.stop="opendialog(answer)" />
|
||||||
<strong class="ml-4">{{ answer.employee ? answer.employee.fio : answer.name }}</strong>:
|
<strong class="ml-4">{{ answer.employee ? answer.employee.fio : answer.name }}</strong>:
|
||||||
{{ answer.count }}
|
{{ answer.count }}
|
||||||
{{ voteCount(answer.count) }}
|
{{ voteCount(answer.count) }}
|
||||||
<template v-if="answer.employee">
|
<template v-if="answer.employee">
|
||||||
<br/>
|
<br />
|
||||||
<small>Отдел: {{ answer.employee ? answer.employee.department : '' }}</small>
|
<small>Отдел: {{ answer.employee ? answer.employee.department : '' }}</small>
|
||||||
<br/>
|
<br />
|
||||||
<small>Должность: {{ answer.employee ? answer.employee.post : '' }}</small>
|
<small>Должность: {{ answer.employee ? answer.employee.post : '' }}</small>
|
||||||
</template>
|
</template>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<v-progress-linear
|
<v-progress-linear
|
||||||
:model-value="getPercentage(answer.count, questions[index])"
|
:model-value="getPercentage(answer.count, questions[activeTab])"
|
||||||
color="teal-darken-4"
|
color="teal-darken-4"
|
||||||
height="13"
|
height="13"
|
||||||
rounded
|
rounded
|
||||||
@@ -215,26 +214,26 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {computed, ref} from 'vue';
|
import { computed, ref } from 'vue';
|
||||||
import {baseURL, spravURL} from "@/utils/axios-api";
|
import { baseURL, spravURL } from '@/utils/axios-api';
|
||||||
import {checkremote} from "@/utils/universal_functions";
|
import { checkremote } from '@/utils/universal_functions';
|
||||||
import NonVoteHappy from "@/components/vote/NonVoteHappy.vue";
|
import NonVoteHappy from '@/components/vote/NonVoteHappy.vue';
|
||||||
import NonVoteSad from "@/components/vote/NonVoteSad.vue";
|
import NonVoteSad from '@/components/vote/NonVoteSad.vue';
|
||||||
import InfoUserCard from "@/components/UI/fiousercard/infoUserCard.vue";
|
import InfoUserCard from '@/components/UI/fiousercard/infoUserCard.vue';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'VoteResult',
|
name: 'VoteResult',
|
||||||
components: {InfoUserCard, NonVoteSad, NonVoteHappy},
|
components: { InfoUserCard, NonVoteSad, NonVoteHappy },
|
||||||
methods: {
|
methods: {
|
||||||
checkremote,
|
checkremote,
|
||||||
spravURL() {
|
spravURL() {
|
||||||
return spravURL
|
return spravURL;
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
baseURL() {
|
baseURL() {
|
||||||
return baseURL
|
return baseURL;
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
emits: ['closer'],
|
emits: ['closer'],
|
||||||
props: {
|
props: {
|
||||||
@@ -250,7 +249,8 @@ export default {
|
|||||||
|
|
||||||
const title = props.data.name;
|
const title = props.data.name;
|
||||||
const description = props.data.description;
|
const description = props.data.description;
|
||||||
const nonVoters = props.data.nonvoting;
|
const allVoters = props.data.nonvoting;
|
||||||
|
const nonVoters = allVoters.filter(el => el.deleted !== 1);
|
||||||
|
|
||||||
const activeDepartment = ref(null);
|
const activeDepartment = ref(null);
|
||||||
const activeDepartmentResults = ref([]);
|
const activeDepartmentResults = ref([]);
|
||||||
@@ -263,11 +263,19 @@ export default {
|
|||||||
dialogWinner.value = true;
|
dialogWinner.value = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
const getWinner = (question) => {
|
const getWinners = (question) => {
|
||||||
return question.answers.reduce(
|
const answers = question.answers || [];
|
||||||
(max, answer) => (answer.count > max.count ? answer : max),
|
const maxCount = answers.reduce((max, answer) => Math.max(max, answer.count), 0);
|
||||||
{count: 0, employee: {fio: '', department: '', post: ''}, name: ''}
|
|
||||||
);
|
if (maxCount === 0) {
|
||||||
|
return [{ count: 0, employee: { fio: '', department: '', post: '' }, name: '' }];
|
||||||
|
}
|
||||||
|
|
||||||
|
return answers.filter(answer => answer.count === maxCount);
|
||||||
|
};
|
||||||
|
|
||||||
|
const getWinnerNames = (winners) => {
|
||||||
|
return winners.map(answer => answer.employee?.fio || answer.name).join(' / ');
|
||||||
};
|
};
|
||||||
|
|
||||||
const getTopResults = (question) => {
|
const getTopResults = (question) => {
|
||||||
@@ -283,7 +291,7 @@ export default {
|
|||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
...answer,
|
...answer,
|
||||||
rank
|
rank,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -300,23 +308,25 @@ export default {
|
|||||||
const voteCount = (count) => {
|
const voteCount = (count) => {
|
||||||
let currentVote = '';
|
let currentVote = '';
|
||||||
const lastDigit = count % 10;
|
const lastDigit = count % 10;
|
||||||
if (lastDigit === 1) currentVote = 'голос'
|
if (lastDigit === 1) currentVote = 'голос';
|
||||||
if (lastDigit > 1) currentVote = 'голоса'
|
if (lastDigit > 1) currentVote = 'голоса';
|
||||||
if (lastDigit > 4 || count === 0 || count === 11 || count === 12 || count === 13 || count === 14) currentVote = 'голосов'
|
if (lastDigit > 4 || count === 0 || count === 11 || count === 12 || count === 13 || count === 14) currentVote = 'голосов';
|
||||||
return currentVote
|
return currentVote;
|
||||||
}
|
};
|
||||||
|
|
||||||
const getPercentage = (count, question) => {
|
const getPercentage = (count, question) => {
|
||||||
|
console.log(question);
|
||||||
|
if (typeof question === 'undefined') return 100
|
||||||
const totalVotes = question.answers.reduce((sum, answer) => sum + answer.count, 0);
|
const totalVotes = question.answers.reduce((sum, answer) => sum + answer.count, 0);
|
||||||
return totalVotes > 0 ? (count / totalVotes) * 100 : 0;
|
return totalVotes > 0 ? (count / totalVotes) * 100 : 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
const activepick = ref(null)
|
const activepick = ref(null);
|
||||||
// const dialog = ref(false)
|
// const dialog = ref(false)
|
||||||
const opendialog = (val) => {
|
const opendialog = (val) => {
|
||||||
dialog.value = true
|
dialog.value = true;
|
||||||
activepick.value = val
|
activepick.value = val;
|
||||||
}
|
};
|
||||||
|
|
||||||
const groupedByDepartment = computed(() => {
|
const groupedByDepartment = computed(() => {
|
||||||
// Группируем пользователей по департаментам
|
// Группируем пользователей по департаментам
|
||||||
@@ -352,7 +362,6 @@ export default {
|
|||||||
return sortedGroupedByDepartment;
|
return sortedGroupedByDepartment;
|
||||||
});
|
});
|
||||||
|
|
||||||
// const groupedByDepartment = {};
|
|
||||||
|
|
||||||
const getWinnersByDepartment = (question) => {
|
const getWinnersByDepartment = (question) => {
|
||||||
// Группируем ответы по департаментам
|
// Группируем ответы по департаментам
|
||||||
@@ -365,15 +374,10 @@ export default {
|
|||||||
return groups;
|
return groups;
|
||||||
}, {});
|
}, {});
|
||||||
|
|
||||||
// Для каждого департамента находим победителя
|
// Для каждого департамента находим всех лидеров
|
||||||
const winnersByDepartment = {};
|
const winnersByDepartment = {};
|
||||||
for (const department in groupedByDepartment) {
|
for (const department in groupedByDepartment) {
|
||||||
const answers = groupedByDepartment[department];
|
winnersByDepartment[department] = getWinners({ answers: groupedByDepartment[department] });
|
||||||
const winner = answers.reduce(
|
|
||||||
(max, answer) => (answer.count > max.count ? answer : max),
|
|
||||||
{count: 0, employee: {fio: '', department: '', post: ''}, name: ''}
|
|
||||||
);
|
|
||||||
winnersByDepartment[department] = winner;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return { groupedByDepartment, winnersByDepartment };
|
return { groupedByDepartment, winnersByDepartment };
|
||||||
@@ -392,7 +396,8 @@ export default {
|
|||||||
dialog,
|
dialog,
|
||||||
activeTab,
|
activeTab,
|
||||||
questions,
|
questions,
|
||||||
getWinner,
|
getWinners,
|
||||||
|
getWinnerNames,
|
||||||
getTopResults,
|
getTopResults,
|
||||||
truncateText,
|
truncateText,
|
||||||
shouldShowTooltip,
|
shouldShowTooltip,
|
||||||
@@ -401,7 +406,7 @@ export default {
|
|||||||
description,
|
description,
|
||||||
getPercentage,
|
getPercentage,
|
||||||
nonVoters,
|
nonVoters,
|
||||||
groupedByDepartment
|
groupedByDepartment,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import '@mdi/font/css/materialdesignicons.css'
|
import '@mdi/font/css/materialdesignicons.css'
|
||||||
import 'vuetify/styles'
|
import 'vuetify/styles'
|
||||||
import { VCalendar } from 'vuetify/labs/VCalendar'
|
import { VCalendar } from 'vuetify/components/VCalendar'
|
||||||
|
|
||||||
import { createVuetify } from 'vuetify'
|
import { createVuetify } from 'vuetify'
|
||||||
import { ru } from 'vuetify/locale'
|
import { ru } from 'vuetify/locale'
|
||||||
|
|||||||
@@ -15,9 +15,12 @@ export const useCalendarStore = defineStore('calendarStore', () => {
|
|||||||
const calendars = ref([]); // Список календарей пользователя
|
const calendars = ref([]); // Список календарей пользователя
|
||||||
const lastUpdatedBy = ref(null);
|
const lastUpdatedBy = ref(null);
|
||||||
const holidays = ref([]);
|
const holidays = ref([]);
|
||||||
|
const dictEmployees = ref([]);
|
||||||
|
const dictEmployeesLoaded = ref(false);
|
||||||
|
const employees = ref([]);
|
||||||
|
|
||||||
// Массив ID скрытых календарей. Загружаем из localStorage при инициализации.
|
// Массив ID скрытых календарей. Загружаем из localStorage при инициализации.
|
||||||
const hiddenCalendarIds = ref(JSON.parse(localStorage.getItem('hiddenCalendars')) || []);
|
const hiddenCalendarIds = ref([]);
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
const formattedSelectedDate = computed(() => selectedDate.value.toISOString().split('T')[0]);
|
const formattedSelectedDate = computed(() => selectedDate.value.toISOString().split('T')[0]);
|
||||||
@@ -26,46 +29,38 @@ export const useCalendarStore = defineStore('calendarStore', () => {
|
|||||||
const userId = accountStore.user.is_idEmployee;
|
const userId = accountStore.user.is_idEmployee;
|
||||||
|
|
||||||
return calendars.value
|
return calendars.value
|
||||||
|
.filter((calendar) => calendar.author === userId) // ТОЛЬКО календари где пользователь автор
|
||||||
.map((calendar) => {
|
.map((calendar) => {
|
||||||
const isAuthor = calendar.author === userId;
|
|
||||||
const participant = calendar.participant.find((p) => p.participant_calendar === userId);
|
const participant = calendar.participant.find((p) => p.participant_calendar === userId);
|
||||||
const isEditor = participant?.editor === true;
|
const isEditor = participant?.editor === true;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
calendar,
|
|
||||||
isAuthor,
|
|
||||||
isEditor,
|
|
||||||
hasAccess: isAuthor || isEditor,
|
|
||||||
};
|
|
||||||
})
|
|
||||||
.filter(({ hasAccess }) => hasAccess)
|
|
||||||
.map(({ calendar, isAuthor, isEditor }) => ({
|
|
||||||
...calendar,
|
...calendar,
|
||||||
isAuthor,
|
isAuthor: true, // Всегда true, так как отфильтровали по автору
|
||||||
isEditor,
|
isEditor,
|
||||||
visible: !hiddenCalendarIds.value.includes(calendar.id),
|
visible: !hiddenCalendarIds.value.includes(calendar.id),
|
||||||
}));
|
};
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
const subscribedCalendars = computed(() =>
|
|
||||||
calendars.value
|
|
||||||
.filter((e) => e.author !== accountStore.user.is_idEmployee)
|
|
||||||
.map((calendar) => ({
|
|
||||||
...calendar,
|
|
||||||
visible: !hiddenCalendarIds.value.includes(calendar.id),
|
|
||||||
})),
|
|
||||||
);
|
|
||||||
|
|
||||||
// Watcher: автоматически сохраняем hiddenCalendarIds в localStorage при изменении
|
const subscribedCalendars = computed(() => {
|
||||||
watch(
|
const userId = accountStore.user.is_idEmployee;
|
||||||
() => {
|
|
||||||
hiddenCalendarIds.value;
|
return calendars.value
|
||||||
},
|
.filter((calendar) => calendar.author !== userId) // Все календари где пользователь НЕ автор
|
||||||
(newValue) => {
|
.map((calendar) => {
|
||||||
localStorage.setItem('hiddenCalendars', JSON.stringify(newValue));
|
const participant = calendar.participant.find((p) => p.participant_calendar === userId);
|
||||||
},
|
const isEditor = participant?.editor === true;
|
||||||
{ deep: true },
|
|
||||||
);
|
return {
|
||||||
|
...calendar,
|
||||||
|
isAuthor: false,
|
||||||
|
isEditor,
|
||||||
|
visible: !hiddenCalendarIds.value.includes(calendar.id),
|
||||||
|
};
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
const eventsForSelectedDate = computed(() =>
|
const eventsForSelectedDate = computed(() =>
|
||||||
events.value.filter((event) => event.date_start.split('T')[0] === formattedSelectedDate.value),
|
events.value.filter((event) => event.date_start.split('T')[0] === formattedSelectedDate.value),
|
||||||
@@ -94,15 +89,33 @@ export const useCalendarStore = defineStore('calendarStore', () => {
|
|||||||
const loadCalendars = async () => {
|
const loadCalendars = async () => {
|
||||||
try {
|
try {
|
||||||
const response = await axiosApiInstance.get('api/calendar_of_events/my_calendars/');
|
const response = await axiosApiInstance.get('api/calendar_of_events/my_calendars/');
|
||||||
calendars.value = response.data.map((calendar) => ({
|
calendars.value = response.data;
|
||||||
...calendar,
|
hiddenCalendarIds.value = [];
|
||||||
// visible: true,
|
|
||||||
}));
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Ошибка загрузки календарей:', error);
|
console.error('Ошибка загрузки календарей:', error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const loadDictEmployees = async () => {
|
||||||
|
try {
|
||||||
|
const response = await axiosApiInstance.get(`api/vote/getdictemployee/`);
|
||||||
|
dictEmployees.value = response.data;
|
||||||
|
dictEmployeesLoaded.value = true;
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Ошибка получения всех сотрудников:', error);
|
||||||
|
dictEmployeesLoaded.value = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const loadEmployees = async () => {
|
||||||
|
try {
|
||||||
|
const response = await axiosApiInstance.get('api/calendar_of_events/get_employees/');
|
||||||
|
employees.value = response.data;
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Ошибка получения всех сотрудников:', error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const toggleCalendarVisibility = (calendarId) => {
|
const toggleCalendarVisibility = (calendarId) => {
|
||||||
const index = hiddenCalendarIds.value.indexOf(calendarId);
|
const index = hiddenCalendarIds.value.indexOf(calendarId);
|
||||||
if (index === -1) {
|
if (index === -1) {
|
||||||
@@ -120,7 +133,7 @@ export const useCalendarStore = defineStore('calendarStore', () => {
|
|||||||
|
|
||||||
const calendarColorMap = computed(() => {
|
const calendarColorMap = computed(() => {
|
||||||
const map = new Map();
|
const map = new Map();
|
||||||
myCalendars.value.forEach((calendar) => {
|
calendars.value.forEach((calendar) => {
|
||||||
map.set(calendar.id, calendar.cl_color);
|
map.set(calendar.id, calendar.cl_color);
|
||||||
});
|
});
|
||||||
return map;
|
return map;
|
||||||
@@ -246,6 +259,7 @@ export const useCalendarStore = defineStore('calendarStore', () => {
|
|||||||
lastUpdatedBy,
|
lastUpdatedBy,
|
||||||
hiddenCalendarIds,
|
hiddenCalendarIds,
|
||||||
holidays,
|
holidays,
|
||||||
|
dictEmployeesLoaded,
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
formattedSelectedDate,
|
formattedSelectedDate,
|
||||||
@@ -256,6 +270,8 @@ export const useCalendarStore = defineStore('calendarStore', () => {
|
|||||||
allEvents,
|
allEvents,
|
||||||
calendarColorMap,
|
calendarColorMap,
|
||||||
|
|
||||||
|
dictEmployees,
|
||||||
|
employees,
|
||||||
editableEvents,
|
editableEvents,
|
||||||
canEditEvent,
|
canEditEvent,
|
||||||
|
|
||||||
@@ -270,5 +286,7 @@ export const useCalendarStore = defineStore('calendarStore', () => {
|
|||||||
toggleCalendarVisibility,
|
toggleCalendarVisibility,
|
||||||
fetchHolidays,
|
fetchHolidays,
|
||||||
isNonWorkingDay,
|
isNonWorkingDay,
|
||||||
|
loadDictEmployees,
|
||||||
|
loadEmployees,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
@@ -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>
|
||||||
|
|||||||
@@ -129,8 +129,8 @@ export default {
|
|||||||
resultsModal.value = false;
|
resultsModal.value = false;
|
||||||
selectedVoting.value = null;
|
selectedVoting.value = null;
|
||||||
router.push({ name: 'VoteHomePage' });
|
router.push({ name: 'VoteHomePage' });
|
||||||
if (route.name === 'Voting') updating('active');
|
// if (route.name === 'Voting') updating('active');
|
||||||
if (route.name === 'VoteResults') updating('completed');
|
// if (route.name === 'VoteResults') updating('completed');
|
||||||
};
|
};
|
||||||
|
|
||||||
const openModal = async (type, voting) => {
|
const openModal = async (type, voting) => {
|
||||||
|
|||||||
Reference in new issue
Block a user