chore [X-01]: пулл
This commit is contained in:
commit
6ab58babcb
27 files changed
+5148
-1091
No files matched your search
@@ -36,7 +36,15 @@
|
||||
"vue3-autocounter": "^1.0.8",
|
||||
"vuelidate": "^0.7.7",
|
||||
"vuetify": "^3.7.8",
|
||||
"webfontloader": "^1.6.28"
|
||||
"webfontloader": "^1.6.28",
|
||||
"@fullcalendar/core": "^6.1.19",
|
||||
"@fullcalendar/daygrid": "^6.1.19",
|
||||
"@fullcalendar/interaction": "^6.1.19",
|
||||
"@fullcalendar/multimonth": "^6.1.19",
|
||||
"@fullcalendar/timegrid": "^6.1.19",
|
||||
"@fullcalendar/list": "6.1.19",
|
||||
"@fullcalendar/vue3": "^6.1.19",
|
||||
"@fullcalendar/rrule": "^6.1.15"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@commitlint/cli": "^19.7.1",
|
||||
|
||||
@@ -1,150 +1,453 @@
|
||||
<template>
|
||||
<v-col>
|
||||
<v-file-input
|
||||
label="Файлы"
|
||||
chips
|
||||
multiple
|
||||
v-model="eventFiles"
|
||||
density="compact"
|
||||
variant="outlined"
|
||||
@click.stop=""
|
||||
>
|
||||
<template v-slot:selection="{ fileNames }">
|
||||
<template v-for="(fileName, index) in fileNames" :key="fileName">
|
||||
<v-chip
|
||||
v-if="index < 4"
|
||||
class="me-2"
|
||||
color="teal-darken-3"
|
||||
size="small"
|
||||
label
|
||||
>
|
||||
{{ fileName }}
|
||||
</v-chip>
|
||||
<div class="custom-file-input-wrapper">
|
||||
<label class="v-label v-field-label v-field-label--floating">
|
||||
Добавить файл (размер файла не должен превышать 2Мб)
|
||||
</label>
|
||||
|
||||
<span
|
||||
v-else-if="index === 4"
|
||||
class="text-overline text-grey-darken-3 mx-2"
|
||||
>
|
||||
+{{ files.length - 4 }} файла(ов)
|
||||
</span>
|
||||
</template>
|
||||
</template>
|
||||
</v-file-input>
|
||||
<!-- Область, куда можно перетащить файлы -->
|
||||
<div
|
||||
class="file-input-area"
|
||||
@click="triggerFileInput"
|
||||
@drop="handleDrop"
|
||||
@dragover.prevent
|
||||
@dragenter.prevent
|
||||
>
|
||||
<!-- Кастомные чипы новых файлов ВНУТРИ "инпута" -->
|
||||
<div class="chips-container" v-if="localNewFiles.length > 0">
|
||||
<template v-for="(file, index) in localNewFiles" :key="getFileKey(file, index)">
|
||||
<v-chip
|
||||
class="file-chip"
|
||||
color="grey-darken-1"
|
||||
size="small"
|
||||
label
|
||||
closable
|
||||
@click:close="removeNewFile(index)"
|
||||
>
|
||||
<v-icon start size="small">mdi-file-plus</v-icon>
|
||||
<span class="text-truncate" style="max-width: 100px">
|
||||
{{ file.name }}({{ formatFileSize(file.size) }})
|
||||
</span>
|
||||
</v-chip>
|
||||
</template>
|
||||
<span class="file-counter text-caption text-grey">
|
||||
{{ localNewFiles.length }}/{{ MAX_NEW_FILES }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<!-- Плейсхолдер, когда файлов нет -->
|
||||
<div v-else class="placeholder">
|
||||
<v-icon class="me-1">mdi-paperclip</v-icon>
|
||||
<span class="text-caption">Перетащите файлы сюда или кликните для выбора</span>
|
||||
</div>
|
||||
|
||||
<!-- Скрытый настоящий input -->
|
||||
<input
|
||||
ref="fileInputRef"
|
||||
type="file"
|
||||
multiple
|
||||
style="display: none"
|
||||
@change="handleFileSelect"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- Область ошибок -->
|
||||
<div class="error-messages" v-if="errorMessages.length">
|
||||
<div v-for="(error, index) in errorMessages" :key="index" class="text-caption text-error">
|
||||
{{ error }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Существующие файлы из БД -->
|
||||
<div class="existing-files-section mb-2">
|
||||
<div class="text-caption text-grey mb-2">Прикрепленные файлы:</div>
|
||||
<div>
|
||||
<template v-if="existingFiles.length">
|
||||
<v-chip
|
||||
v-for="file in existingFiles"
|
||||
:key="file.id"
|
||||
class="me-2 mb-1"
|
||||
color="teal-darken-3"
|
||||
label
|
||||
@click:close="removeExistingFile(file.id)"
|
||||
>
|
||||
<v-icon start class="pb-1">{{ getFileIcon(file) }}</v-icon>
|
||||
<span class="text-truncate" style="max-width: 120px">
|
||||
{{ truncateFileName(getFileName(file)) }}
|
||||
</span>
|
||||
|
||||
<v-icon
|
||||
class="ms-1 download-icon"
|
||||
@click.stop="downloadExistingFile(file)"
|
||||
title="Скачать файл"
|
||||
>
|
||||
mdi-download
|
||||
</v-icon>
|
||||
<v-icon
|
||||
class="ms-1 close-icon"
|
||||
@click.stop="removeExistingFile(file.id)"
|
||||
title="Удалить файл"
|
||||
>
|
||||
mdi-close
|
||||
</v-icon>
|
||||
</v-chip>
|
||||
</template>
|
||||
<template v-else>
|
||||
<span class="text-caption text-grey">Файлов нет</span>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</v-col>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { computed, ref } from "vue";
|
||||
import { get_name } from "@/utils/universal_functions";
|
||||
import { computed, ref, watch } from 'vue';
|
||||
export default {
|
||||
props: {
|
||||
files: {
|
||||
type: Object,
|
||||
default: () => {},
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
newFiles: {
|
||||
type: Array,
|
||||
default: [],
|
||||
},
|
||||
},
|
||||
emits: ['update:files', 'update:newFiles', 'postFiles'],
|
||||
|
||||
setup(props, { emit }) {
|
||||
const localNewFiles = ref([]);
|
||||
const errorMessages = ref([]);
|
||||
const MAX_FILE_SIZE = 2 * 1024 * 1024; // 2 МБ
|
||||
const MAX_NEW_FILES = 5;
|
||||
|
||||
const propsFiles = computed({
|
||||
get: () => props.files,
|
||||
set: (value) => emit("update:files", value),
|
||||
});
|
||||
const fileInputRef = ref(null);
|
||||
|
||||
const arrFiles = ref([]);
|
||||
|
||||
const eventFiles = computed({
|
||||
get() {
|
||||
propsFiles.value.forEach((e) =>
|
||||
{
|
||||
|
||||
arrFiles.value.push(
|
||||
dataURLtoFile(
|
||||
"data:text/plain;base64,aGVsbG8gd29ybGQ=",
|
||||
get_name(decodeURI(e.file))
|
||||
)
|
||||
)}
|
||||
);
|
||||
return arrFiles.value;
|
||||
watch(
|
||||
() => props.newFiles,
|
||||
(newVal) => {
|
||||
localNewFiles.value = Array.isArray(newVal) ? [...newVal] : [];
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
set(newValue) {
|
||||
let newFile = []
|
||||
arrFiles.value = [];
|
||||
if (newValue.length == 0) {
|
||||
arrFiles.value = [];
|
||||
propsFiles.value = [];
|
||||
} else {
|
||||
newValue.forEach((e) => {
|
||||
arrFiles.value.push(e)
|
||||
newFile.push(e)
|
||||
});
|
||||
}
|
||||
// Существующие файлы из event.files
|
||||
const existingFiles = computed(() => (Array.isArray(props.files) ? props.files : []));
|
||||
|
||||
emit("postFiles", newFile);
|
||||
|
||||
|
||||
},
|
||||
});
|
||||
//
|
||||
const triggerFileInput = () => {
|
||||
if (fileInputRef.value) {
|
||||
fileInputRef.value.click();
|
||||
}
|
||||
};
|
||||
|
||||
function dataURLtoFile(dataurl, filename) {
|
||||
var arr = dataurl.split(","),
|
||||
mime = arr[0].match(/:(.*?);/)[1],
|
||||
bstr = atob(arr[1]),
|
||||
n = bstr.length,
|
||||
u8arr = new Uint8Array(n);
|
||||
const handleFileSelect = (event) => {
|
||||
const files = Array.from(event.target.files || []);
|
||||
if (files.length > 0) {
|
||||
handleFilesChange(files);
|
||||
}
|
||||
// Очищаем input для возможности выбора тех же файлов снова
|
||||
event.target.value = '';
|
||||
};
|
||||
|
||||
while (n--) {
|
||||
u8arr[n] = bstr.charCodeAt(n);
|
||||
// Обработка drag & drop
|
||||
const handleDrop = (event) => {
|
||||
event.preventDefault();
|
||||
const files = Array.from(event.dataTransfer.files || []);
|
||||
if (files.length > 0) {
|
||||
handleFilesChange(files);
|
||||
}
|
||||
};
|
||||
|
||||
const formatFileSize = (bytes) => {
|
||||
if (bytes === 0) return '0 Б';
|
||||
const k = 1024;
|
||||
const sizes = ['Б', 'КБ', 'МБ', 'ГБ'];
|
||||
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
||||
return parseFloat((bytes / Math.pow(k, i)).toFixed(1)) + ' ' + sizes[i];
|
||||
};
|
||||
|
||||
const validateFiles = (files) => {
|
||||
errorMessages.value = [];
|
||||
|
||||
const currentFiles = Array.isArray(localNewFiles.value) ? localNewFiles.value : [];
|
||||
const totalFiles = currentFiles.length + files.length;
|
||||
|
||||
// Проверка количества
|
||||
if (totalFiles > MAX_NEW_FILES) {
|
||||
errorMessages.value.push(`Можно добавить не более ${MAX_NEW_FILES} файлов`);
|
||||
return false;
|
||||
}
|
||||
|
||||
return new File([u8arr], filename, { type: mime });
|
||||
}
|
||||
|
||||
|
||||
// const eventFiles = computed({
|
||||
// get() {
|
||||
// if (propsFiles.value.length > 0) {
|
||||
// propsFiles.value.forEach((e) =>
|
||||
// files.value.push(
|
||||
// dataURLtoFile(
|
||||
// "data:text/plain;base64,aGVsbG8gd29ybGQ=",
|
||||
// get_name(decodeURI(e.file))
|
||||
// )
|
||||
// )
|
||||
// );
|
||||
// // let file = dataURLtoFile(
|
||||
// // "data:text/plain;base64,aGVsbG8gd29ybGQ=",
|
||||
// // get_name(
|
||||
// // decodeURI(propsFiles.value.event.files[0].file)
|
||||
// // )
|
||||
// // );
|
||||
// Проверка размера
|
||||
const oversizedFiles = files.filter((file) => file.size > MAX_FILE_SIZE);
|
||||
if (oversizedFiles.length > 0) {
|
||||
errorMessages.value.push(
|
||||
`Следующие файлы превышают 2 МБ: ${oversizedFiles.map((f) => f.name).join(', ')}`,
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
// // files.value.push(file);
|
||||
// }
|
||||
return true;
|
||||
};
|
||||
|
||||
const getFileKey = (file, index) => {
|
||||
return file instanceof File
|
||||
? `${file.name}-${file.size}-${file.lastModified}`
|
||||
: file.id || index;
|
||||
};
|
||||
|
||||
// Получаем имя файла из объекта файла
|
||||
const getFileName = (fileData) => {
|
||||
// Для новых файлов (File object) - берем оригинальное имя
|
||||
if (fileData instanceof File) {
|
||||
return fileData.name;
|
||||
}
|
||||
|
||||
// Для существующих файлов с бэкенда - извлекаем из URL
|
||||
if (fileData.file) {
|
||||
try {
|
||||
const filePath = fileData.file.startsWith('http')
|
||||
? new URL(fileData.file).pathname
|
||||
: fileData.file;
|
||||
|
||||
// Извлекаем имя файла
|
||||
let fileName = filePath.split('/').pop();
|
||||
|
||||
// Декодируем URL-encoded символы, но НЕ изменяем имя
|
||||
fileName = decodeURIComponent(fileName);
|
||||
|
||||
return fileName || 'Файл';
|
||||
} catch (error) {
|
||||
console.warn('Ошибка извлечения имени файла:', error, fileData);
|
||||
return 'Файл';
|
||||
}
|
||||
}
|
||||
|
||||
// Если есть name в данных - используем как есть
|
||||
if (fileData.name) {
|
||||
return fileData.name;
|
||||
}
|
||||
|
||||
return 'Файл';
|
||||
};
|
||||
|
||||
// Иконка в зависимости от типа файла
|
||||
const getFileIcon = (fileData) => {
|
||||
let fileName = '';
|
||||
|
||||
if (fileData instanceof File) {
|
||||
fileName = fileData.name;
|
||||
} else {
|
||||
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',
|
||||
gif: 'mdi-file-image',
|
||||
svg: 'mdi-file-image',
|
||||
zip: 'mdi-folder-zip',
|
||||
rar: 'mdi-folder-zip',
|
||||
'7z': 'mdi-folder-zip',
|
||||
txt: 'mdi-file-document',
|
||||
json: 'mdi-code-json',
|
||||
js: 'mdi-language-javascript',
|
||||
vue: 'mdi-vuejs',
|
||||
html: 'mdi-language-html5',
|
||||
css: 'mdi-language-css3',
|
||||
};
|
||||
return iconMap[extension] || 'mdi-file';
|
||||
};
|
||||
|
||||
// Обработка изменения новых файлов
|
||||
const handleFilesChange = (newFiles) => {
|
||||
if (!newFiles || newFiles.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const validFiles = newFiles.filter((file) => file instanceof File);
|
||||
|
||||
if (validFiles.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Валидация
|
||||
if (!validateFiles(validFiles)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// localNewFiles.value = [...validFiles];
|
||||
const currentFiles = Array.isArray(localNewFiles.value) ? localNewFiles.value : [];
|
||||
const updatedFiles = [...currentFiles, ...validFiles];
|
||||
localNewFiles.value = updatedFiles;
|
||||
|
||||
emit('update:newFiles', updatedFiles);
|
||||
emit('postFiles', updatedFiles);
|
||||
};
|
||||
|
||||
// Удаление существующего файла
|
||||
const removeExistingFile = (fileId) => {
|
||||
try {
|
||||
// Создаем копию event и удаляем файл
|
||||
const updatedFiles = existingFiles.value.filter((file) => file.id !== fileId);
|
||||
// props.files = updatedFiles;
|
||||
emit('update:files', updatedFiles);
|
||||
} catch (error) {
|
||||
console.error('Ошибка при удалении файла:', error);
|
||||
}
|
||||
};
|
||||
|
||||
// Удаление нового файла (еще не загруженного)
|
||||
const removeNewFile = (index) => {
|
||||
const updatedFiles = localNewFiles.value.filter((_, i) => i !== index);
|
||||
localNewFiles.value = updatedFiles;
|
||||
// localNewFiles.value.splice(index, 1);
|
||||
// emit('postFiles', localNewFiles.value);
|
||||
emit('update:newFiles', updatedFiles);
|
||||
emit('postFiles', updatedFiles);
|
||||
};
|
||||
|
||||
const downloadExistingFile = async (file) => {
|
||||
try {
|
||||
const fileName = getFileName(file); // Теперь будет работать правильно!
|
||||
const fileUrl = file.file.startsWith('http')
|
||||
? file.file
|
||||
: `${window.location.origin}${file.file}`; // Для относительных путей
|
||||
|
||||
const link = document.createElement('a');
|
||||
link.href = fileUrl;
|
||||
link.download = fileName;
|
||||
link.style.display = 'none';
|
||||
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
|
||||
setTimeout(() => {
|
||||
document.body.removeChild(link);
|
||||
}, 100);
|
||||
} catch (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 files.value;
|
||||
// },
|
||||
// set(newValue) {
|
||||
// newValue.forEach((e) => {
|
||||
// if (!files.value.some((l) => l.name == e.name.split(" ").join("_"))) {
|
||||
// files.value.push(e);
|
||||
// }
|
||||
// });
|
||||
// if (newValue.length == 0) {
|
||||
// files.value = [];
|
||||
// propsFiles.value = [];
|
||||
// }
|
||||
// },
|
||||
// });
|
||||
return {
|
||||
eventFiles,
|
||||
arrFiles,
|
||||
|
||||
localNewFiles,
|
||||
existingFiles,
|
||||
handleFilesChange,
|
||||
removeExistingFile,
|
||||
removeNewFile,
|
||||
getFileName,
|
||||
getFileIcon,
|
||||
formatFileSize,
|
||||
errorMessages,
|
||||
validateFiles,
|
||||
getFileKey,
|
||||
MAX_NEW_FILES,
|
||||
fileInputRef,
|
||||
handleFileSelect,
|
||||
triggerFileInput,
|
||||
handleDrop,
|
||||
downloadExistingFile,
|
||||
truncateFileName,
|
||||
};
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style></style>
|
||||
<style scoped>
|
||||
:deep(.v-chip) {
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.custom-file-input-wrapper {
|
||||
border: 1px solid rgba(0, 0, 0, 0.38);
|
||||
border-radius: 4px;
|
||||
padding: 12px;
|
||||
position: relative;
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
.custom-file-input-wrapper:focus-within {
|
||||
border-color: #1976d2;
|
||||
border-width: 2px;
|
||||
}
|
||||
|
||||
.file-input-area {
|
||||
min-height: 40px;
|
||||
cursor: pointer;
|
||||
padding: 4px;
|
||||
}
|
||||
|
||||
.chips-container {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.file-chip {
|
||||
max-width: 150px;
|
||||
}
|
||||
|
||||
.file-counter {
|
||||
margin-left: 8px;
|
||||
}
|
||||
|
||||
.placeholder {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
color: rgba(0, 0, 0, 0.6);
|
||||
padding: 8px 0;
|
||||
}
|
||||
|
||||
.error-messages {
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.text-error {
|
||||
color: #d32f2f;
|
||||
}
|
||||
|
||||
.existing-files-section {
|
||||
border-top: 1px solid #e0e0e0;
|
||||
padding-top: 6px;
|
||||
}
|
||||
|
||||
.download-icon {
|
||||
cursor: pointer;
|
||||
opacity: 0.7;
|
||||
transition: opacity 0.2s;
|
||||
}
|
||||
|
||||
.download-icon:hover {
|
||||
opacity: 1;
|
||||
color: #024e45;
|
||||
}
|
||||
|
||||
.close-icon:hover {
|
||||
opacity: 1;
|
||||
color: #024e45;
|
||||
}
|
||||
</style>
|
||||
@@ -1,127 +1,68 @@
|
||||
<template>
|
||||
<v-row no-gutters>
|
||||
<v-col class="flex-grow-0 d-flex flex-column">
|
||||
<v-card class="h-100 rounded-0 d-flex flex-colmn" width="250">
|
||||
<v-row no-gutters class="flex-column">
|
||||
<v-col class="flex-grow-0 px-2 pt-1">
|
||||
<v-text-field
|
||||
density="compact"
|
||||
clearable
|
||||
append-inner-icon="mdi-magnify"
|
||||
hide-details
|
||||
class="py-3"
|
||||
label="Найти событие"
|
||||
rows="1"
|
||||
no-resize
|
||||
variant="outlined"
|
||||
/>
|
||||
</v-col>
|
||||
<v-col class="flex-grow-0 px-2">
|
||||
<v-btn
|
||||
type="submit"
|
||||
class="text-subtitle-1 font-weight-light"
|
||||
color="btn_text"
|
||||
block
|
||||
elevation="1"
|
||||
@click="createEvent()"
|
||||
>Создать событие</v-btn
|
||||
>
|
||||
<!-- {{eventFromCalendar}} -->
|
||||
</v-col>
|
||||
<v-col class="w100" lg="3">
|
||||
<v-locale-provider locale="ru">
|
||||
<v-date-picker
|
||||
ref="cal"
|
||||
v-model="selectdate"
|
||||
color="btn_text"
|
||||
class="rounded-0 minCal"
|
||||
max-width="250"
|
||||
hide-header
|
||||
show-adjacent-months
|
||||
@click="CheckingStore"
|
||||
@update:month="getMonth"
|
||||
@update:year="getYear"
|
||||
>
|
||||
</v-date-picker>
|
||||
</v-locale-provider>
|
||||
</v-col>
|
||||
|
||||
<v-col class="flex-column d-flex">
|
||||
<v-row no-gutters class="h-0 overflow-auto flex-column flex-nowrap">
|
||||
<v-col>
|
||||
<calendar-my
|
||||
:calendars="
|
||||
calendarForMy.filter((e) => e.author == accountStore.user.is_idEmployee)
|
||||
"
|
||||
title="Мои календари"
|
||||
@getCalendar="getCalendar"
|
||||
/>
|
||||
|
||||
<calendar-my
|
||||
:calendars="
|
||||
calendarForMy.filter((e) => e.author != accountStore.user.is_idEmployee)
|
||||
"
|
||||
title="Подписки"
|
||||
/>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-card>
|
||||
<mini-calendar />
|
||||
</v-col>
|
||||
<v-col class="d-flex flex-column">
|
||||
<calendar-full
|
||||
:allEvent="calendarForMy.filter((e) => e.events.length > 0)"
|
||||
@getEvent="createEvent"
|
||||
@update:allEvent="infoEvent($event)"
|
||||
<custom-calendar
|
||||
:key="calendarKey"
|
||||
@openEventDialog="openEventDialog"
|
||||
@openEventView="openEventView"
|
||||
/>
|
||||
</v-col>
|
||||
|
||||
<!-- <v-navigation-drawer
|
||||
v-model="drawer_right"
|
||||
floating
|
||||
permanent
|
||||
location="right"
|
||||
rail-width="400"
|
||||
rail
|
||||
>
|
||||
</v-navigation-drawer> -->
|
||||
<v-dialog v-model="showDialog" max-width="700">
|
||||
<v-dialog v-model="showEventDialog" max-width="700">
|
||||
<event-create
|
||||
@closeDialog="showDialog = false"
|
||||
@closeDialog="closeEventDialog"
|
||||
:eventCalendar="eventFromCalendar"
|
||||
@update:eventCalendar="eventFromCalendar = $event"
|
||||
:allCalendars="allCalendars"
|
||||
@getCalendar="getCalendar"
|
||||
@update:eventCalendar="eventFromCalendar = $event"
|
||||
ref="createEvents"
|
||||
:key="eventKey"
|
||||
/>
|
||||
</v-dialog>
|
||||
|
||||
<event-calendar-show
|
||||
v-model:show="showViewDialog"
|
||||
:all-calendars="allCalendars"
|
||||
:event-data="selectedEventForView"
|
||||
@close="handleViewDialogClose"
|
||||
:employees="calendarStore.employees"
|
||||
/>
|
||||
</v-row>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { ref, onMounted, watch } from 'vue';
|
||||
import { ref, onMounted, watch, computed } from 'vue';
|
||||
import { useWeekendsStore } from '@/store/WeekendsStore';
|
||||
import EventCreate from '@/components/calendar_of_events/event-create.vue';
|
||||
import CalendarMy from '@/components/calendar_of_events/calendar-my.vue';
|
||||
import CustomCalendar from '@/components/calendar_of_events/UI_calendar/CustomCalendar.vue';
|
||||
import { useCalendarStore } from '@/store/calendarStore';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import MiniCalendar from '@/components/calendar_of_events/UI_calendar/MiniCalendar.vue';
|
||||
import { axiosApiInstance } from '@/utils/axios-api';
|
||||
import { useAccountStore } from '@/store/AccountStore';
|
||||
import CalendarFull from '@/components/calendar_of_events/UI_calendar/calendarFull.vue';
|
||||
import EventCalendarShow from '@/components/calendar_of_events/event-calendar-show.vue';
|
||||
|
||||
export default {
|
||||
components: { EventCreate, CalendarMy, CalendarFull },
|
||||
|
||||
components: { EventCreate, MiniCalendar, CustomCalendar, EventCalendarShow },
|
||||
setup() {
|
||||
const accountStore = useAccountStore();
|
||||
const showDialog = ref(false);
|
||||
const week = useWeekendsStore();
|
||||
const drawer_right = ref(false);
|
||||
const cal = ref(null);
|
||||
const selectdate = ref(new Date());
|
||||
const MyYear = ref(selectdate.value.getFullYear());
|
||||
const MyMonth = ref(selectdate.value.getMonth() + 1);
|
||||
const calendarForMy = ref([]);
|
||||
const eventFromCalendar = ref({});
|
||||
const createEvents = ref(null);
|
||||
const eventKey = ref(0);
|
||||
const calendarKey = ref(0);
|
||||
|
||||
const calendarStore = useCalendarStore();
|
||||
const accountStore = useAccountStore();
|
||||
const showViewDialog = ref(false);
|
||||
const selectedEventForView = ref({});
|
||||
|
||||
const { selectedDate, showEventDialog } = storeToRefs(calendarStore); // синхронизируем с date-picker
|
||||
|
||||
const getMonth = (month) => {
|
||||
MyMonth.value = month + 1;
|
||||
@@ -131,79 +72,75 @@ export default {
|
||||
};
|
||||
|
||||
const getCalendar = () => {
|
||||
axiosApiInstance.get(`api/calendar_of_events/my_calendars/`).then((res) => {
|
||||
res.data.forEach((e) => (e.visible = accountStore.calendar.includes(e.id) ? false : true));
|
||||
calendarForMy.value = res.data;
|
||||
});
|
||||
calendarStore.loadCalendars();
|
||||
};
|
||||
|
||||
getCalendar();
|
||||
const getDictEmployee = () => {
|
||||
calendarStore.loadDictEmployees();
|
||||
};
|
||||
|
||||
const getEvents = (idEvent, clik) => {
|
||||
axiosApiInstance
|
||||
.get(`api/calendar_of_events/my_events/${idEvent === undefined ? '' : `?id=${idEvent}`}`)
|
||||
.then((res) => {
|
||||
if (idEvent === undefined) {
|
||||
res.data.event = {
|
||||
name: '',
|
||||
participant: [accountStore.user.is_idEmployee],
|
||||
files: [],
|
||||
date_start: new Date(),
|
||||
date_end: new Date(),
|
||||
period: null,
|
||||
description: '',
|
||||
calendar: null,
|
||||
};
|
||||
}
|
||||
const getEmployees = () => {
|
||||
calendarStore.loadEmployees();
|
||||
};
|
||||
|
||||
const allCalendars = computed(() => [
|
||||
...calendarStore.myCalendars,
|
||||
...calendarStore.subscribedCalendars,
|
||||
]);
|
||||
|
||||
const getEvent = (idEvent) => {
|
||||
if (!idEvent) {
|
||||
eventFromCalendar.value = createEmptyEvent();
|
||||
return;
|
||||
} else {
|
||||
axiosApiInstance.get(`api/calendar_of_events/my_events/?id=${idEvent}`).then((res) => {
|
||||
eventFromCalendar.value = res.data;
|
||||
|
||||
if (clik) showDialog.value = true;
|
||||
calendarStore.openEventDialog();
|
||||
});
|
||||
};
|
||||
|
||||
getEvents();
|
||||
|
||||
const createEvent = (idEv) => {
|
||||
getEvents(idEv, true);
|
||||
if (idEv) {
|
||||
getCalendar();
|
||||
}
|
||||
};
|
||||
|
||||
const weekendsData = () => {
|
||||
cal.value.$el.querySelectorAll('.v-date-picker-month__day').forEach((e) => {
|
||||
let datas = e.getAttribute('data-v-date');
|
||||
let weeks = new Date(datas).getDay() === 6 || new Date(datas).getDay() === 0;
|
||||
if (weeks) {
|
||||
e.querySelectorAll('span').forEach((n) => {
|
||||
n.classList.add('text-red');
|
||||
});
|
||||
}
|
||||
if (MyMonth.value in week.week[MyYear.value]) {
|
||||
if (week.week[MyYear.value][MyMonth.value].includes(datas)) {
|
||||
e.querySelectorAll('span').forEach((n) => {
|
||||
n.classList.add('text-red');
|
||||
if (n.classList.contains('text-red') && weeks) {
|
||||
n.classList.replace('text-red', 'text-black');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
const createEmptyEvent = () => ({
|
||||
event: {
|
||||
name: '',
|
||||
participant: [accountStore.user.is_idEmployee],
|
||||
files: [],
|
||||
date_start: new Date().toISOString(),
|
||||
date_end: new Date().toISOString(),
|
||||
period: null,
|
||||
description: '',
|
||||
calendar: null,
|
||||
},
|
||||
});
|
||||
|
||||
const openEventDialog = (selectedEvent) => {
|
||||
// Всегда сбрасываем данные перед открытием нового диалога
|
||||
if (!selectedEvent) {
|
||||
eventFromCalendar.value = createEmptyEvent();
|
||||
eventKey.value++;
|
||||
}
|
||||
|
||||
getEvent(selectedEvent?.event?.id);
|
||||
calendarStore.openEventDialog();
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
getEvent();
|
||||
week.getWeekend(MyYear.value);
|
||||
getDictEmployee();
|
||||
getCalendar();
|
||||
getEmployees();
|
||||
});
|
||||
|
||||
watch(
|
||||
() => week.week,
|
||||
(newValue) => {
|
||||
if (newValue) {
|
||||
weekendsData();
|
||||
}
|
||||
},
|
||||
);
|
||||
const closeEventDialog = () => {
|
||||
calendarStore.closeEventDialog();
|
||||
|
||||
// При ручном закрытии сбрасываем данные сразу
|
||||
setTimeout(() => {
|
||||
eventFromCalendar.value = createEmptyEvent();
|
||||
eventKey.value++;
|
||||
}, 200);
|
||||
};
|
||||
|
||||
const CheckingStore = () => {
|
||||
if (MyYear.value in week.week) {
|
||||
@@ -213,44 +150,85 @@ export default {
|
||||
}
|
||||
};
|
||||
|
||||
const infoEvent = (i) => {
|
||||
console.log(i, 'iiiiiiiiii');
|
||||
watch(
|
||||
() => calendarStore.showEventDialog,
|
||||
(newValue, oldValue) => {
|
||||
if (!newValue && oldValue) {
|
||||
// Диалог был открыт и закрыт не через нашу кнопку
|
||||
// Добавляем проверку чтобы не сбрасывать при инициализации
|
||||
if (eventFromCalendar.value.event?.id) {
|
||||
setTimeout(() => {
|
||||
eventFromCalendar.value = createEmptyEvent();
|
||||
eventKey.value++;
|
||||
}, 200);
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
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 {
|
||||
drawer_right,
|
||||
selectdate,
|
||||
cal,
|
||||
selectedDate,
|
||||
getMonth,
|
||||
getYear,
|
||||
weekendsData,
|
||||
week,
|
||||
CheckingStore,
|
||||
showDialog,
|
||||
showEventDialog,
|
||||
calendarForMy,
|
||||
accountStore,
|
||||
getCalendar,
|
||||
getEvent,
|
||||
eventFromCalendar,
|
||||
createEvent,
|
||||
infoEvent,
|
||||
createEvents,
|
||||
calendarStore,
|
||||
accountStore,
|
||||
closeEventDialog,
|
||||
openEventDialog,
|
||||
createEmptyEvent,
|
||||
eventKey,
|
||||
getDictEmployee,
|
||||
openEventView,
|
||||
handleViewDialogClose,
|
||||
showViewDialog,
|
||||
selectedEventForView,
|
||||
allCalendars,
|
||||
eventKey,
|
||||
calendarKey,
|
||||
};
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.minCal .v-date-picker-month__day {
|
||||
height: 31px;
|
||||
width: 31px;
|
||||
}
|
||||
|
||||
.minCal .v-btn--icon.v-btn--density-default {
|
||||
width: calc(var(--v-btn-height) + 12px);
|
||||
height: calc(var(--v-btn-height) + 6px);
|
||||
}
|
||||
|
||||
.minCal .v-btn__content {
|
||||
font-weight: 410;
|
||||
}
|
||||
</style>
|
||||
<style scoped></style>
|
||||
@@ -0,0 +1,604 @@
|
||||
<template>
|
||||
<v-col cols="12" class="d-flex flex-column" style="height: 80vh">
|
||||
<v-card class="d-flex flex-column flex-grow-1">
|
||||
<v-card-text class="d-flex flex-column flex-grow-1">
|
||||
<!-- Контролы навигации -->
|
||||
<div class="flex-grow-0 mb-1">
|
||||
<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
|
||||
variant="outlined"
|
||||
class="text-subtitle-2 mr-2"
|
||||
@click="handleToday"
|
||||
density="comfortable"
|
||||
>
|
||||
Сегодня
|
||||
</v-btn>
|
||||
<v-btn
|
||||
variant="text"
|
||||
@click="handlePrev"
|
||||
:elevation="0"
|
||||
style="border-radius: 4px"
|
||||
density="compact"
|
||||
icon
|
||||
>
|
||||
<v-icon size="large">mdi-chevron-left</v-icon>
|
||||
</v-btn>
|
||||
|
||||
<v-btn
|
||||
variant="text"
|
||||
@click="handleNext"
|
||||
:elevation="0"
|
||||
style="border-radius: 4px"
|
||||
density="compact"
|
||||
icon
|
||||
>
|
||||
<v-icon size="large">mdi-chevron-right</v-icon>
|
||||
</v-btn>
|
||||
|
||||
<span class="text-h5 text-no-wrap ml-2">
|
||||
{{ currentTitle }}
|
||||
</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 class="flex-grow-0 d-flex justify-end">
|
||||
<v-btn-toggle
|
||||
v-model="currentView"
|
||||
mandatory
|
||||
divided
|
||||
variant="plain"
|
||||
density="comfortable"
|
||||
>
|
||||
<v-btn value="timeGridDay">День</v-btn>
|
||||
<v-btn value="timeGridWeek">Неделя</v-btn>
|
||||
<v-btn value="dayGridMonth">Месяц</v-btn>
|
||||
<v-btn value="multiMonthYear">Год</v-btn>
|
||||
<v-btn value="listWeek">Расписание</v-btn>
|
||||
<v-btn value="listAllEvents">Все события</v-btn>
|
||||
</v-btn-toggle>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</div>
|
||||
<div class="flex-grow-1 d-flex">
|
||||
<!-- VCalendar -->
|
||||
<FullCalendar
|
||||
v-if="currentView !== 'listAllEvents'"
|
||||
ref="calendarRef"
|
||||
:options="calendarOptions"
|
||||
class="custom-calendar"
|
||||
/>
|
||||
<!-- Кастомный список событий -->
|
||||
<EventsListView v-else @event-click="handleEventClick" :filters="unwrappedFilters" />
|
||||
</div>
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
</v-col>
|
||||
</template>
|
||||
<script>
|
||||
import { ref, watch, nextTick, computed } from 'vue';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import dayGridPlugin from '@fullcalendar/daygrid';
|
||||
import timeGridPlugin from '@fullcalendar/timegrid';
|
||||
import multiMonthPlugin from '@fullcalendar/multimonth';
|
||||
import interactionPlugin from '@fullcalendar/interaction';
|
||||
import listPlugin from '@fullcalendar/list';
|
||||
import ruLocale from '@fullcalendar/core/locales/ru';
|
||||
import rrulePlugin from '@fullcalendar/rrule';
|
||||
import { onMounted } from 'vue';
|
||||
import { useCalendarStore } from '@/store/calendarStore';
|
||||
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 {
|
||||
name: 'CustomCalendar',
|
||||
|
||||
emits: ['openEventDialog', 'openEventView'],
|
||||
components: {
|
||||
EventsListView,
|
||||
EventListFilters,
|
||||
},
|
||||
setup(props, { emit }) {
|
||||
const currentView = ref('dayGridMonth');
|
||||
const currentTitle = ref('Календарь');
|
||||
const calendarRef = ref(null);
|
||||
const accountStore = useAccountStore();
|
||||
|
||||
const calendarStore = useCalendarStore();
|
||||
const { selectedDate, lastUpdatedBy, allEvents, calendarColorMap } = storeToRefs(calendarStore);
|
||||
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) => {
|
||||
if (calendarStore.canEditEvent(info.event.id)) {
|
||||
emit('openEventDialog', info);
|
||||
} else {
|
||||
emit('openEventView', info.event.id);
|
||||
}
|
||||
};
|
||||
|
||||
const calendarOptions = ref({
|
||||
plugins: [
|
||||
dayGridPlugin,
|
||||
timeGridPlugin,
|
||||
multiMonthPlugin,
|
||||
interactionPlugin,
|
||||
listPlugin,
|
||||
rrulePlugin,
|
||||
],
|
||||
initialView: props.forHomePage ? props.view : currentView.value,
|
||||
locales: [ruLocale],
|
||||
locale: 'ru',
|
||||
timeZone: 'local',
|
||||
firstDay: 1,
|
||||
headerToolbar: false,
|
||||
height: '80vh',
|
||||
aspectRatio: 1.5,
|
||||
weekNumbers: true,
|
||||
eventDisplay: 'block',
|
||||
eventTimeFormat: {
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
hour12: false,
|
||||
meridiem: false,
|
||||
},
|
||||
weekNumberFormat: {
|
||||
week: 'numeric',
|
||||
},
|
||||
weekNumberCalculation: 'ISO', // ISO стандарт (понедельник - первый день)
|
||||
selectable: true,
|
||||
unselectAuto: false,
|
||||
selectMirror: false,
|
||||
|
||||
dayCellDidMount: (arg) => {
|
||||
const date = arg.date;
|
||||
const dayInfo = calendarStore.isNonWorkingDay(date);
|
||||
|
||||
if (dayInfo.isHoliday === true) {
|
||||
arg.el.classList.add('non-working-day');
|
||||
}
|
||||
|
||||
if (dayInfo.isWeekendForStyling === true) {
|
||||
arg.el.classList.add('grey-background');
|
||||
}
|
||||
},
|
||||
views: {
|
||||
timeGridDay: {
|
||||
type: 'timeGrid',
|
||||
duration: { days: 1 },
|
||||
slotDuration: '01:00:00',
|
||||
slotLabelInterval: '01:00:00',
|
||||
slotLabelFormat: {
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
hour12: false,
|
||||
meridiem: false,
|
||||
},
|
||||
allDaySlot: true,
|
||||
slotMinTime: '07:00:00',
|
||||
slotMaxTime: '22:00:00',
|
||||
expandRows: true,
|
||||
dayHeaderFormat: {
|
||||
weekday: 'long',
|
||||
day: 'numeric',
|
||||
month: 'long',
|
||||
omitCommas: true,
|
||||
},
|
||||
},
|
||||
|
||||
timeGridWeek: {
|
||||
type: 'timeGrid',
|
||||
duration: { weeks: 1 },
|
||||
slotDuration: '01:00:00',
|
||||
slotMinTime: '07:00:00',
|
||||
slotMaxTime: '22:00:00',
|
||||
allDaySlot: true,
|
||||
expandRows: true,
|
||||
|
||||
dayHeaderFormat: { weekday: 'short', day: 'numeric' },
|
||||
titleFormat: {
|
||||
day: 'numeric',
|
||||
month: 'long',
|
||||
omitCommas: true,
|
||||
},
|
||||
},
|
||||
dayGridMonth: {
|
||||
type: 'dayGrid',
|
||||
fixedWeekCount: false,
|
||||
dayHeaderFormat: { weekday: 'short' },
|
||||
weekNumbers: true,
|
||||
|
||||
weekNumberFormat: { week: 'numeric' },
|
||||
weekNumberContent: (arg) => {
|
||||
return arg.num;
|
||||
},
|
||||
weekText: 'Нед.',
|
||||
eventTimeFormat: {
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
hour12: false,
|
||||
omitZeroMinute: false,
|
||||
},
|
||||
},
|
||||
multiMonthYear: {
|
||||
type: 'multiMonth',
|
||||
duration: { years: 1 },
|
||||
multiMonthMaxColumns: 4,
|
||||
fixedWeekCount: false,
|
||||
weekNumbers: false,
|
||||
},
|
||||
listWeek: {
|
||||
type: 'list',
|
||||
duration: { days: 1 },
|
||||
listDayFormat: {
|
||||
weekday: 'long',
|
||||
day: 'numeric',
|
||||
month: 'long',
|
||||
},
|
||||
listDaySideFormat: false,
|
||||
},
|
||||
},
|
||||
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,
|
||||
selectable: true,
|
||||
eventClick: handleEventClick,
|
||||
|
||||
dateClick: (info) => {
|
||||
calendarStore.setSelectedDateFromCalendar(info);
|
||||
handleDateSelection(info.dateStr);
|
||||
handleCalendarDateClick(info);
|
||||
calendarApi.value?.unselect();
|
||||
},
|
||||
|
||||
datesSet: (info) => {
|
||||
if (info.view.type === 'listWeek' && selectedDate.value) {
|
||||
const date = new Date(selectedDate.value);
|
||||
|
||||
const options = {
|
||||
weekday: 'long',
|
||||
day: 'numeric',
|
||||
month: 'long',
|
||||
year: 'numeric',
|
||||
};
|
||||
|
||||
const formattedDate = date.toLocaleDateString('ru-RU', options);
|
||||
currentTitle.value = `Расписание на ${formattedDate}`;
|
||||
} else {
|
||||
currentTitle.value = info.view.title;
|
||||
}
|
||||
|
||||
if (selectedDate?.value) {
|
||||
handleDateSelection(selectedDate.value);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
const handleCalendarDateClick = (info) => {
|
||||
calendarStore.setSelectedDateFromCalendar(info);
|
||||
currentTitle.value = info.view.title;
|
||||
|
||||
if (calendarApi.value) {
|
||||
calendarApi.value.gotoDate(info.date);
|
||||
calendarApi.value.changeView('listWeek');
|
||||
currentView.value = 'listWeek';
|
||||
}
|
||||
};
|
||||
|
||||
const handleToday = () => {
|
||||
calendarApi.value?.today();
|
||||
// Получаем текущую дату из календаря и передаем в стор
|
||||
updateSelectedDateFromCalendar();
|
||||
};
|
||||
|
||||
const handlePrev = () => {
|
||||
calendarApi.value?.prev();
|
||||
updateSelectedDateFromCalendar();
|
||||
};
|
||||
|
||||
const handleNext = () => {
|
||||
calendarApi.value?.next();
|
||||
updateSelectedDateFromCalendar();
|
||||
};
|
||||
|
||||
const updateSelectedDateFromCalendar = () => {
|
||||
const currentDate = calendarApi.value?.getDate();
|
||||
if (currentDate) {
|
||||
const todayInfo = {
|
||||
dateStr: currentDate.toISOString().split('T')[0],
|
||||
};
|
||||
calendarStore.setSelectedDateFromCalendar(todayInfo);
|
||||
}
|
||||
};
|
||||
|
||||
// Функция обновления выделения
|
||||
const handleDateSelection = (dateStr) => {
|
||||
// Убираем предыдущее выделение
|
||||
const previousSelected = document.querySelectorAll('.fc-day-selected-custom');
|
||||
previousSelected.forEach((el) => el.classList.remove('fc-day-selected-custom'));
|
||||
|
||||
// Добавляем новое выделение
|
||||
const dayElements = document.querySelectorAll(`[data-date="${dateStr}"]`);
|
||||
dayElements.forEach((el) => el.classList.add('fc-day-selected-custom'));
|
||||
|
||||
selectedDate.value = dateStr;
|
||||
};
|
||||
|
||||
onMounted(async () => {
|
||||
const currentYear = new Date().getFullYear();
|
||||
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) => {
|
||||
if (newDate && calendarApi.value && lastUpdatedBy.value !== 'calendar') {
|
||||
nextTick(() => {
|
||||
calendarApi.value.gotoDate(newDate);
|
||||
handleDateSelection(newDate);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
watch(currentView, (newView) => {
|
||||
if (newView === 'listAllEvents') {
|
||||
currentTitle.value = 'Все события';
|
||||
} else if (calendarApi.value) {
|
||||
calendarApi.value.changeView(newView);
|
||||
currentTitle.value = calendarApi.value.view.title;
|
||||
}
|
||||
});
|
||||
|
||||
const handleFiltersUpdate = (newFilters) => {
|
||||
Object.keys(newFilters).forEach((key) => {
|
||||
if (filters[key] !== undefined) {
|
||||
filters[key].value = newFilters[key];
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// Сброс фильтров при выходе из кастомного вида
|
||||
watch(currentView, (newView, oldView) => {
|
||||
if (oldView === 'listAllEvents' && newView !== 'listAllEvents') {
|
||||
filters.resetFilters();
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
currentTitle,
|
||||
calendarRef,
|
||||
calendarApi,
|
||||
currentView,
|
||||
calendarOptions,
|
||||
handleToday,
|
||||
handleNext,
|
||||
handlePrev,
|
||||
handleCalendarDateClick,
|
||||
handleDateSelection,
|
||||
handleEventClick,
|
||||
calendarStore,
|
||||
filters,
|
||||
handleFiltersUpdate,
|
||||
unwrappedFilters,
|
||||
};
|
||||
},
|
||||
};
|
||||
</script>
|
||||
<style scoped>
|
||||
:deep(.fc-daygrid-day-number) {
|
||||
display: flex !important;
|
||||
justify-content: center !important;
|
||||
align-items: center !important;
|
||||
width: 100% !important;
|
||||
height: 100% !important;
|
||||
margin: 0 !important;
|
||||
padding: 0.6rem !important;
|
||||
}
|
||||
|
||||
/* текущая дата обводка */
|
||||
:deep(.fc-day-today) {
|
||||
background-color: transparent !important;
|
||||
}
|
||||
|
||||
:deep(.fc-day-today .fc-daygrid-day-number) {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
color: #00897b;
|
||||
|
||||
&::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border: 1px solid #00897b;
|
||||
border-radius: 50%;
|
||||
z-index: -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Выбранная дата заливка */
|
||||
|
||||
:deep(.fc-day-selected-custom) {
|
||||
background-color: transparent !important;
|
||||
}
|
||||
|
||||
:deep(.fc-day-selected-custom .fc-daygrid-day-number) {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
color: white !important;
|
||||
}
|
||||
|
||||
:deep(.fc-day-selected-custom .fc-daygrid-day-number::before) {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
background-color: #00897b;
|
||||
border-radius: 50%;
|
||||
z-index: -1;
|
||||
}
|
||||
|
||||
:deep(.fc-multiMonthYear-view) {
|
||||
.fc-day-today .fc-daygrid-day-number::before,
|
||||
.fc-day-selected-custom .fc-daygrid-day-number::before {
|
||||
width: 26px;
|
||||
height: 26px;
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.v-btn--active) {
|
||||
background-color: transparent !important;
|
||||
color: #00897b !important;
|
||||
}
|
||||
|
||||
:deep(.fc .fc-timegrid-col.fc-day-today) {
|
||||
background-color: #e0f2f1 !important;
|
||||
}
|
||||
|
||||
:deep(.fc-highlight) {
|
||||
background-color: transparent !important;
|
||||
}
|
||||
:deep(.fc-day),
|
||||
:deep(.fc-list-event-title) {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
:deep(.fc-popover) {
|
||||
background-color: rgb(248, 244, 244) !important;
|
||||
}
|
||||
|
||||
.non-working-day {
|
||||
color: red !important;
|
||||
}
|
||||
|
||||
:global(.fc-daygrid-day.non-working-day .fc-daygrid-day-number) {
|
||||
color: #d32f2f !important;
|
||||
}
|
||||
|
||||
:global(.fc-daygrid-day.grey-background.fc-daygrid-day-number) {
|
||||
background-color: rgb(196, 187, 187) !important;
|
||||
}
|
||||
|
||||
.grey-background {
|
||||
background-color: rgb(240, 229, 229) !important;
|
||||
}
|
||||
|
||||
:deep(.fc-day.grey-background) {
|
||||
background-color: #f5f5f5 !important;
|
||||
}
|
||||
|
||||
.custom-calendar {
|
||||
height: 100% !important;
|
||||
min-height: 700px;
|
||||
flex: 1 1 auto;
|
||||
}
|
||||
</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>
|
||||
@@ -0,0 +1,605 @@
|
||||
<template>
|
||||
<v-card class="home-calendar-widget" elevation="2" rounded="lg">
|
||||
<v-card-text class="pa-4">
|
||||
<v-row no-gutters class="calendar-pair">
|
||||
<!-- Месячный календарь -->
|
||||
<v-col cols="7" class="pr-2">
|
||||
<div class="calendar-header">
|
||||
<v-btn icon size="small" @click="prevMonth" class="nav-btn">
|
||||
<v-icon>mdi-chevron-left</v-icon>
|
||||
</v-btn>
|
||||
<span class="month-title">{{ currentMonth }}</span>
|
||||
<v-btn icon size="small" @click="nextMonth" class="nav-btn">
|
||||
<v-icon>mdi-chevron-right</v-icon>
|
||||
</v-btn>
|
||||
</div>
|
||||
|
||||
<v-table class="month-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th v-for="day in russianWeekdays" :key="day" class="weekday-header">
|
||||
{{ day }}
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="(week, weekIndex) in calendarWeeks" :key="weekIndex">
|
||||
<td
|
||||
v-for="day in week"
|
||||
:key="day.date"
|
||||
class="day-cell"
|
||||
:class="{
|
||||
'current-month': day.isCurrentMonth,
|
||||
today: isToday(day.date),
|
||||
selected: isSelected(day.date),
|
||||
'non-working-day': calendarStore.isNonWorkingDay(day.date).isHoliday,
|
||||
'grey-background': calendarStore.isNonWorkingDay(day.date).isWeekendForStyling,
|
||||
}"
|
||||
@click="onDateClick(day.date)"
|
||||
>
|
||||
<div class="day-content">
|
||||
<span class="day-number">{{ day.day }}</span>
|
||||
<div class="day-events">
|
||||
<span
|
||||
v-for="event in getDayEvents(day.date)"
|
||||
:key="event.id"
|
||||
class="event-indicator"
|
||||
:style="{ backgroundColor: event.color }"
|
||||
></span>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</v-table>
|
||||
</v-col>
|
||||
|
||||
<!-- Дневное расписание -->
|
||||
<v-col cols="5" class="pl-2">
|
||||
<div class="schedule-header">
|
||||
<h3 class="day-title">
|
||||
<span v-if="isToday(selectedDate)">Сегодня, </span>{{ formattedSelectedDate }}
|
||||
</h3>
|
||||
</div>
|
||||
|
||||
<v-card variant="outlined" class="day-schedule" elevation="0">
|
||||
<v-list density="comfortable" class="py-0">
|
||||
<v-list-item
|
||||
v-for="event in dayEvents"
|
||||
:key="event.id"
|
||||
class="schedule-item"
|
||||
:class="{ 'current-event': isCurrentEvent(event) }"
|
||||
>
|
||||
<template #prepend>
|
||||
<div
|
||||
class="event-color-indicator"
|
||||
:style="{ backgroundColor: event.color }"
|
||||
></div>
|
||||
</template>
|
||||
|
||||
<v-list-item-title class="event-time">
|
||||
{{ formatTime(event.start) }}
|
||||
</v-list-item-title>
|
||||
<v-list-item-subtitle class="event-title">
|
||||
{{ event.title }}
|
||||
</v-list-item-subtitle>
|
||||
</v-list-item>
|
||||
|
||||
<v-list-item v-if="dayEvents.length === 0" class="no-events">
|
||||
<v-list-item-title class="text-grey text-center">
|
||||
На этот день событий нет
|
||||
</v-list-item-title>
|
||||
</v-list-item>
|
||||
</v-list>
|
||||
</v-card>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { ref, computed, onMounted, watch } from 'vue';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { useCalendarStore } from '@/store/calendarStore';
|
||||
import { useRecurrence } from '@/components/calendar_of_events/composables/useReccurrence';
|
||||
|
||||
export default {
|
||||
name: 'HomeCalendarWidget',
|
||||
|
||||
setup() {
|
||||
// Реактивные данные
|
||||
const currentDate = ref(new Date());
|
||||
const selectedDate = ref(''); // Будет установлено в формате YYYY-MM-DD
|
||||
const currentYear = new Date().getFullYear();
|
||||
|
||||
// Работа с хранилищем
|
||||
const calendarStore = useCalendarStore();
|
||||
const { allEvents, calendarColorMap } = storeToRefs(calendarStore);
|
||||
const { generateRecurringInstances, isRecurringEvent } = useRecurrence();
|
||||
|
||||
// Утилиты для работы с датами (главный источник проблем!)
|
||||
const formatToLocalDate = (date) => {
|
||||
const year = date.getFullYear();
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0');
|
||||
const day = String(date.getDate()).padStart(2, '0');
|
||||
return `${year}-${month}-${day}`;
|
||||
};
|
||||
|
||||
const getStartOfDay = (date) => {
|
||||
const newDate = new Date(date);
|
||||
newDate.setHours(0, 0, 0, 0);
|
||||
return newDate;
|
||||
};
|
||||
|
||||
const areDatesEqual = (date1, date2) => {
|
||||
return getStartOfDay(date1).getTime() === getStartOfDay(date2).getTime();
|
||||
};
|
||||
|
||||
const events = computed(() => {
|
||||
const expandedEvents = allEvents.value.flatMap((event) => {
|
||||
const startDate = new Date(event.date_start);
|
||||
const endDate = new Date(event.date_end);
|
||||
const isMultiDay = startDate.toDateString() !== endDate.toDateString();
|
||||
const hasRecurrence = event.period && event.period !== 'null';
|
||||
|
||||
// 1. Периодичное + многодневное
|
||||
if (hasRecurrence && isMultiDay) {
|
||||
const instances = generateRecurringInstances(event, 12);
|
||||
return instances.flatMap((instance) => expandMultiDayInstance(event, instance));
|
||||
}
|
||||
|
||||
// 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 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 calendarWeeks = computed(() => {
|
||||
const year = currentDate.value.getFullYear();
|
||||
const month = currentDate.value.getMonth();
|
||||
|
||||
const firstDay = new Date(year, month, 1);
|
||||
const lastDay = new Date(year, month + 1, 0);
|
||||
|
||||
const weeks = [];
|
||||
let week = [];
|
||||
|
||||
// Находим понедельник первой недели
|
||||
const startDay = new Date(firstDay);
|
||||
startDay.setDate(startDay.getDate() - ((startDay.getDay() + 6) % 7));
|
||||
|
||||
// Генерируем 6 недель (фиксированное количество для стабильности)
|
||||
for (let i = 0; i < 42; i++) {
|
||||
const currentDay = new Date(startDay);
|
||||
currentDay.setDate(startDay.getDate() + i);
|
||||
|
||||
week.push({
|
||||
day: currentDay.getDate(),
|
||||
date: formatToLocalDate(currentDay),
|
||||
isCurrentMonth: currentDay.getMonth() === month,
|
||||
});
|
||||
|
||||
if (week.length === 7) {
|
||||
weeks.push([...week]);
|
||||
week = [];
|
||||
}
|
||||
}
|
||||
|
||||
return weeks;
|
||||
});
|
||||
|
||||
const currentMonth = computed(() => {
|
||||
return currentDate.value.toLocaleDateString('ru-RU', {
|
||||
month: 'long',
|
||||
year: 'numeric',
|
||||
});
|
||||
});
|
||||
|
||||
const formattedSelectedDate = computed(() => {
|
||||
if (!selectedDate.value) return '';
|
||||
|
||||
// Добавляем время для избежания смещения часовых поясов
|
||||
const date = new Date(selectedDate.value + 'T12:00:00');
|
||||
return date.toLocaleDateString('ru-RU', {
|
||||
day: 'numeric',
|
||||
month: 'long',
|
||||
year: 'numeric',
|
||||
});
|
||||
});
|
||||
|
||||
const dayEvents = computed(() => {
|
||||
if (!selectedDate.value) return [];
|
||||
|
||||
const selected = new Date(selectedDate.value + 'T12:00:00');
|
||||
|
||||
return events.value
|
||||
.filter((event) => {
|
||||
const eventDate = new Date(event.start);
|
||||
return areDatesEqual(eventDate, selected);
|
||||
})
|
||||
.sort((a, b) => new Date(a.start).getTime() - new Date(b.start).getTime());
|
||||
});
|
||||
|
||||
// Методы
|
||||
const isToday = (date) => {
|
||||
const today = new Date();
|
||||
const checkDate = new Date(date + 'T12:00:00');
|
||||
return areDatesEqual(today, checkDate);
|
||||
};
|
||||
|
||||
const isSelected = (date) => {
|
||||
return date === selectedDate.value;
|
||||
};
|
||||
|
||||
const getDayEvents = (date) => {
|
||||
const checkDate = new Date(date + 'T12:00:00');
|
||||
|
||||
return events.value.filter((event) => {
|
||||
const eventDate = new Date(event.start);
|
||||
return areDatesEqual(eventDate, checkDate);
|
||||
});
|
||||
};
|
||||
|
||||
const isCurrentEvent = (event) => {
|
||||
const now = new Date();
|
||||
const start = new Date(event.start);
|
||||
const end = new Date(event.end);
|
||||
return now >= start && now <= end;
|
||||
};
|
||||
|
||||
const formatTime = (dateString) => {
|
||||
return new Date(dateString).toLocaleTimeString('ru-RU', {
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
});
|
||||
};
|
||||
|
||||
const onDateClick = (date) => {
|
||||
selectedDate.value = date;
|
||||
};
|
||||
|
||||
const prevMonth = () => {
|
||||
const date = new Date(currentDate.value);
|
||||
date.setMonth(date.getMonth() - 1);
|
||||
currentDate.value = date;
|
||||
};
|
||||
|
||||
const nextMonth = () => {
|
||||
const date = new Date(currentDate.value);
|
||||
date.setMonth(date.getMonth() + 1);
|
||||
currentDate.value = date;
|
||||
};
|
||||
|
||||
const isWeekendOrHoliday = (dateString) => {
|
||||
const dayInfo = calendarStore.isNonWorkingDay(dateString);
|
||||
return dayInfo.isHoliday || dayInfo.isWeekendForStyling;
|
||||
};
|
||||
|
||||
onMounted(async () => {
|
||||
selectedDate.value = formatToLocalDate(new Date());
|
||||
calendarStore.fetchHolidays(currentYear);
|
||||
});
|
||||
|
||||
watch(
|
||||
calendarColorMap,
|
||||
(newMap) => {
|
||||
newMap.value;
|
||||
},
|
||||
{ deep: true },
|
||||
);
|
||||
|
||||
return {
|
||||
// Реактивные данные
|
||||
currentDate,
|
||||
selectedDate,
|
||||
|
||||
// Вычисляемые свойства
|
||||
events,
|
||||
russianWeekdays,
|
||||
calendarWeeks,
|
||||
currentMonth,
|
||||
formattedSelectedDate,
|
||||
dayEvents,
|
||||
isWeekendOrHoliday,
|
||||
|
||||
// Методы
|
||||
isToday,
|
||||
isSelected,
|
||||
getDayEvents,
|
||||
isCurrentEvent,
|
||||
formatTime,
|
||||
onDateClick,
|
||||
prevMonth,
|
||||
nextMonth,
|
||||
|
||||
calendarStore,
|
||||
allEvents,
|
||||
expandMultiDayInstance,
|
||||
formatForWidget,
|
||||
};
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.home-calendar-widget {
|
||||
width: 100%;
|
||||
/* width: 700px; */
|
||||
height: 100%;
|
||||
font-family: 'Roboto', sans-serif;
|
||||
}
|
||||
|
||||
.calendar-pair {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
/* Месячный календарь */
|
||||
.calendar-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 12px;
|
||||
padding: 0 8px;
|
||||
}
|
||||
|
||||
.month-title {
|
||||
font-size: 1.1rem;
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
text-transform: capitalize;
|
||||
}
|
||||
|
||||
.nav-btn {
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
}
|
||||
|
||||
.month-table {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.weekday-header {
|
||||
font-size: 0.8rem;
|
||||
font-weight: 600;
|
||||
color: #666;
|
||||
text-align: center;
|
||||
padding: 8px 4px;
|
||||
border-bottom: 1px solid #afadad;
|
||||
}
|
||||
|
||||
.day-cell {
|
||||
width: 14.28%;
|
||||
height: 15%;
|
||||
/* height: 50px; */
|
||||
text-align: center;
|
||||
cursor: pointer;
|
||||
border: 1px solid transparent;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.day-cell:hover {
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
|
||||
.day-cell.current-month {
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.day-cell:not(.current-month) {
|
||||
color: #ccc;
|
||||
}
|
||||
|
||||
.day-cell.today {
|
||||
background-color: #e3f2fd;
|
||||
}
|
||||
|
||||
.day-cell.selected {
|
||||
background-color: #00897b;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.day-cell.selected .day-number {
|
||||
color: white;
|
||||
}
|
||||
|
||||
.day-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 100%;
|
||||
padding: 2px;
|
||||
}
|
||||
|
||||
.day-number {
|
||||
font-size: 0.9rem;
|
||||
font-weight: 500;
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
|
||||
.day-events {
|
||||
display: flex;
|
||||
gap: 2px;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.event-indicator {
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
border-radius: 50%;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.event-color-indicator {
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
border-radius: 50%;
|
||||
margin-right: 12px;
|
||||
flex-shrink: 0;
|
||||
box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
/* Дневное расписание */
|
||||
.schedule-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-bottom: 12px;
|
||||
padding: 0 4px;
|
||||
}
|
||||
|
||||
.day-title {
|
||||
font-size: 1.2rem;
|
||||
font-weight: 600;
|
||||
margin: 0;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.day-schedule {
|
||||
height: 90%;
|
||||
overflow-y: auto;
|
||||
border: 1px solid #e0e0e0;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.schedule-item {
|
||||
min-height: 48px;
|
||||
padding: 8px 12px;
|
||||
border-left: 4px solid transparent;
|
||||
border-bottom: 1px solid #d3cecede;
|
||||
}
|
||||
|
||||
.schedule-item:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.schedule-item.current-event {
|
||||
border-left-color: #2196f3;
|
||||
background-color: #f8f9fa;
|
||||
}
|
||||
|
||||
.event-time {
|
||||
font-size: 0.8rem;
|
||||
font-weight: 600;
|
||||
color: #302f2f;
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
|
||||
.event-title {
|
||||
font-size: 0.9rem;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
color: #1b1b1b;
|
||||
}
|
||||
|
||||
.no-events {
|
||||
min-height: 120px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
/* Скроллбар */
|
||||
.day-schedule::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
}
|
||||
|
||||
.day-schedule::-webkit-scrollbar-track {
|
||||
background: #f1f1f1;
|
||||
border-radius: 0 8px 8px 0;
|
||||
}
|
||||
|
||||
.day-schedule::-webkit-scrollbar-thumb {
|
||||
background: #c1c1c1;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.day-schedule::-webkit-scrollbar-thumb:hover {
|
||||
background: #a8a8a8;
|
||||
}
|
||||
|
||||
.non-working-day {
|
||||
color: red !important;
|
||||
}
|
||||
|
||||
.grey-background {
|
||||
background-color: rgb(243, 243, 243) !important;
|
||||
}
|
||||
|
||||
.day-cell:not(.current-month).non-working-day {
|
||||
/* color: inherit !important; */
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,288 @@
|
||||
<template>
|
||||
<v-card class="h-100 rounded-0 d-flex flex-colmn">
|
||||
<v-row no-gutters class="flex-column">
|
||||
<v-col class="flex-grow-0 px-2 pt-1">
|
||||
<SearchEvents />
|
||||
</v-col>
|
||||
|
||||
<v-col class="flex-grow-0 px-2">
|
||||
<v-btn
|
||||
type="submit"
|
||||
class="text-subtitle-1 font-weight-light"
|
||||
color="btn_text"
|
||||
block
|
||||
elevation="1"
|
||||
@click="openEventDialog"
|
||||
:disabled="!myCalendars || myCalendars.length === 0"
|
||||
>Создать событие</v-btn
|
||||
>
|
||||
</v-col>
|
||||
<v-col lg="3">
|
||||
<v-locale-provider locale="ru">
|
||||
<v-date-picker
|
||||
v-model="selectedDate"
|
||||
color="btn_text"
|
||||
class="rounded-0 minCal"
|
||||
hide-header
|
||||
show-adjacent-months
|
||||
@update:modelValue="handleDateClick"
|
||||
@update:display="currentDisplay = $event"
|
||||
>
|
||||
</v-date-picker>
|
||||
</v-locale-provider>
|
||||
</v-col>
|
||||
|
||||
<v-col class="flex-column d-flex">
|
||||
<v-row no-gutters class=" overflow-hidden flex-column flex-nowrap">
|
||||
<v-col>
|
||||
<calendar-my
|
||||
:calendars="myCalendars"
|
||||
title="Мои календари"
|
||||
@getCalendar="loadCalendars"
|
||||
/>
|
||||
<calendar-my
|
||||
:calendars="subscribedCalendars"
|
||||
title="Подписки"
|
||||
@getCalendar="loadCalendars"
|
||||
/>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-card>
|
||||
</template>
|
||||
<script>
|
||||
import { useCalendarStore } from '@/store/calendarStore';
|
||||
import { useAccountStore } from '@/store/AccountStore';
|
||||
import CalendarMy from '@/components/calendar_of_events/calendar-my.vue';
|
||||
import SearchEvents from '@/components/calendar_of_events/UI_calendar/SearchEvents.vue';
|
||||
import { onMounted, watch, nextTick, ref } from 'vue';
|
||||
import { storeToRefs } from 'pinia';
|
||||
|
||||
export default {
|
||||
name: 'MiniCalendar',
|
||||
components: { CalendarMy, SearchEvents },
|
||||
setup() {
|
||||
const calendarStore = useCalendarStore();
|
||||
const accountStore = useAccountStore();
|
||||
|
||||
const { selectedDate, myCalendars, subscribedCalendars } = storeToRefs(calendarStore);
|
||||
|
||||
const { user } = storeToRefs(accountStore);
|
||||
|
||||
const currentDisplay = ref(null);
|
||||
|
||||
const handleDateClick = (date) => {
|
||||
calendarStore.setSelectedDateFromPicker(date);
|
||||
setTimeout(updateCalendarDays, 200);
|
||||
};
|
||||
|
||||
const openEventDialog = () => {
|
||||
calendarStore.openEventDialog();
|
||||
};
|
||||
|
||||
const loadCalendars = () => {
|
||||
calendarStore.loadCalendars();
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
loadCalendars();
|
||||
|
||||
updateCalendarDays();
|
||||
});
|
||||
|
||||
// Реакция на изменения пользователя
|
||||
watch(user, (newUser) => {
|
||||
if (newUser) {
|
||||
loadCalendars();
|
||||
}
|
||||
});
|
||||
|
||||
// Функция для добавления классов дням
|
||||
const updateCalendarDays = () => {
|
||||
nextTick(() => {
|
||||
setTimeout(() => {
|
||||
const dayButtons = document.querySelectorAll('.minCal .v-date-picker-month__day-btn');
|
||||
|
||||
dayButtons.forEach((button) => {
|
||||
// Ищем дату в разных возможных атрибутах
|
||||
const ariaLabel = button.getAttribute('aria-label');
|
||||
|
||||
if (ariaLabel) {
|
||||
try {
|
||||
const dayDate = parseDateFromAriaLabel(ariaLabel);
|
||||
if (dayDate) {
|
||||
const dayInfo = calendarStore.isNonWorkingDay(dayDate);
|
||||
|
||||
// Очищаем предыдущие классы
|
||||
button.classList.remove('weekend-day', 'holiday-day');
|
||||
|
||||
// Добавляем классы по условию
|
||||
if (dayInfo?.isWeekendForStyling) {
|
||||
button.classList.add('weekend-day');
|
||||
}
|
||||
if (dayInfo?.isHoliday) {
|
||||
button.classList.add('holiday-day');
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error processing day:', error);
|
||||
}
|
||||
}
|
||||
});
|
||||
}, 50);
|
||||
});
|
||||
};
|
||||
|
||||
const parseDateFromAriaLabel = (ariaLabel) => {
|
||||
try {
|
||||
// Убираем день недели и запятую, оставляем "28 сентября 2025 г."
|
||||
const datePart = ariaLabel.replace(/^[^,]+,?\s*/, '');
|
||||
|
||||
// Заменяем русские названия месяцев на английские
|
||||
const monthMap = {
|
||||
января: 'January',
|
||||
февраля: 'February',
|
||||
марта: 'March',
|
||||
апреля: 'April',
|
||||
мая: 'May',
|
||||
июня: 'June',
|
||||
июля: 'July',
|
||||
августа: 'August',
|
||||
сентября: 'September',
|
||||
октября: 'October',
|
||||
ноября: 'November',
|
||||
декабря: 'December',
|
||||
};
|
||||
|
||||
let englishDateStr = datePart;
|
||||
for (const [ru, en] of Object.entries(monthMap)) {
|
||||
englishDateStr = englishDateStr.replace(ru, en);
|
||||
}
|
||||
|
||||
// Убираем " г." в конце
|
||||
englishDateStr = englishDateStr.replace(' г.', '');
|
||||
|
||||
const dayDate = new Date(englishDateStr);
|
||||
|
||||
return isNaN(dayDate.getTime()) ? null : dayDate;
|
||||
} catch (error) {
|
||||
console.error('Parse error:', error);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
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 {
|
||||
accountStore,
|
||||
user,
|
||||
myCalendars,
|
||||
subscribedCalendars,
|
||||
selectedDate,
|
||||
openEventDialog,
|
||||
loadCalendars,
|
||||
handleDateClick,
|
||||
updateCalendarDays,
|
||||
currentDisplay,
|
||||
};
|
||||
},
|
||||
};
|
||||
</script>
|
||||
<style scoped>
|
||||
/* .minCal:deep(.v-date-picker-month__days) {
|
||||
display: grid !important;
|
||||
grid-template-columns: repeat(7, 40px) !important;
|
||||
gap: 3px !important;
|
||||
width: 250px !important;
|
||||
justify-content: center !important;
|
||||
margin: 0 auto !important;
|
||||
} */
|
||||
|
||||
.minCal .v-date-picker-monWth__day {
|
||||
height: 31px;
|
||||
width: 31px;
|
||||
}
|
||||
|
||||
.minCal .v-btn--icon.v-btn--density-default {
|
||||
width: calc(var(--v-btn-height) + 12px);
|
||||
height: calc(var(--v-btn-height) + 6px);
|
||||
}
|
||||
|
||||
.minCal .v-btn__content {
|
||||
font-weight: 410;
|
||||
}
|
||||
|
||||
.minCal:deep(.v-date-picker-years__content) {
|
||||
gap: 0;
|
||||
}
|
||||
|
||||
/* СТИЛИ ДЛЯ ВЫХОДНЫХ И ПРАЗДНИКОВ */
|
||||
|
||||
.minCal:deep(.weekend-day .v-btn__content) {
|
||||
color: #666 !important;
|
||||
}
|
||||
|
||||
.minCal:deep(.holiday-day .v-btn__content) {
|
||||
color: #ff4444 !important;
|
||||
font-weight: bold !important;
|
||||
}
|
||||
|
||||
.minCal:deep(.weekend-day.holiday-day) {
|
||||
background-color: #ffe0e0 !important;
|
||||
}
|
||||
|
||||
.minCal:deep(.weekend-day.holiday-day .v-btn__content) {
|
||||
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>
|
||||
@@ -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>
|
||||
+4
-4
@@ -93,7 +93,7 @@ export default {
|
||||
{ type: "day", text: "День" },
|
||||
{ type: "week", text: "Неделя" },
|
||||
{ type: "month", text: "Месяц" },
|
||||
{ type: "modntdh", text: "Год" },
|
||||
// { type: "modntdh", text: "Год" },
|
||||
{ type: "modnth", text: "Расписание" },
|
||||
];
|
||||
|
||||
@@ -314,7 +314,7 @@ export default {
|
||||
ev.rule.byweekday[ev.rule.byweekday.length - 1].weekday == 6
|
||||
? 0
|
||||
: ev.rule.byweekday[ev.rule.byweekday.length - 1].weekday + 1;
|
||||
|
||||
|
||||
if (day.date.getDay() == weeknumS && weeknumS != weeknumE) {
|
||||
return "rounded-e-lg";
|
||||
} else if (day.date.getDay() == weeknumE && weeknumS != weeknumE) {
|
||||
@@ -328,7 +328,7 @@ export default {
|
||||
return "rounded-lg";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
if (ev.rule.freq == 0) {
|
||||
if (zeroTime(day.date) == zeroTime(ev.start_event)) {
|
||||
@@ -342,7 +342,7 @@ export default {
|
||||
// ev.rule.byweekday[ev.rule.byweekday.length - 1].weekday == 6
|
||||
// ? 0
|
||||
// : ev.rule.byweekday[ev.rule.byweekday.length - 1].weekday + 1;
|
||||
|
||||
|
||||
// if (day.date.getDay() == weeknumS && weeknumS != weeknumE) {
|
||||
// return "rounded-e-lg";
|
||||
// } else if (day.date.getDay() == weeknumE && weeknumS != weeknumE) {
|
||||
@@ -1,5 +1,5 @@
|
||||
<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">
|
||||
{{ title }}
|
||||
<v-icon
|
||||
@@ -22,23 +22,14 @@
|
||||
size="36px"
|
||||
@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"
|
||||
elevation="0"
|
||||
width="150"
|
||||
@click="$emit('closeDialog')"
|
||||
color="btn_gray"
|
||||
variant="flat"
|
||||
type="button"
|
||||
>Отменить</v-btn
|
||||
>
|
||||
|
||||
@@ -48,9 +39,9 @@
|
||||
variant="flat"
|
||||
elevation="0"
|
||||
width="150"
|
||||
type="transformation"
|
||||
type="submit"
|
||||
>
|
||||
{{ newOrOld ? "Создать" : "Редактировать" }}
|
||||
{{ newOrOld ? "Создать" : "Сохранить" }}
|
||||
</v-btn>
|
||||
</v-card-actions>
|
||||
</v-form>
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
<v-col lg="3" :class="`order-${order[0]}`">
|
||||
<v-menu
|
||||
v-model="menudate"
|
||||
:close-on-content-click="false"
|
||||
:nudge-right="40"
|
||||
transition="scale-transition"
|
||||
offset-y
|
||||
:close-on-content-click="false"
|
||||
>
|
||||
<template v-slot:activator="{ props }">
|
||||
<v-textarea
|
||||
@@ -21,12 +21,7 @@
|
||||
hide-details
|
||||
>
|
||||
<template v-slot:prepend-inner>
|
||||
<v-icon
|
||||
v-bind="props"
|
||||
icon="mdi-calendar-today"
|
||||
color="cyan-darken-3"
|
||||
size="x-small"
|
||||
/>
|
||||
<v-icon v-bind="props" icon="mdi-calendar-today" color="cyan-darken-3" size="x-small" />
|
||||
</template>
|
||||
</v-textarea>
|
||||
</template>
|
||||
@@ -38,13 +33,13 @@
|
||||
hide-header
|
||||
border
|
||||
no-time
|
||||
:max="order[0] == 2 ? new Date(limitation) : endMax()"
|
||||
:max="endMax()"
|
||||
:min="order[0] == 2 ? startMin() : minData()"
|
||||
/>
|
||||
</v-locale-provider>
|
||||
</v-menu>
|
||||
</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
|
||||
density="compact"
|
||||
no-resize
|
||||
@@ -68,7 +63,8 @@
|
||||
>
|
||||
<v-time-picker
|
||||
v-if="menutime"
|
||||
v-model="timeEvent"
|
||||
:model-value="timeEvent"
|
||||
@update:model-value="onTimePickerChange"
|
||||
full-width
|
||||
format="24hr"
|
||||
></v-time-picker>
|
||||
@@ -77,18 +73,18 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { ref, computed } from "vue";
|
||||
import { formatComa, formatDash } from "@/utils/universal_functions";
|
||||
import { ref, computed, watch } from 'vue';
|
||||
import { formatComa } from '@/utils/universal_functions';
|
||||
export default {
|
||||
props: {
|
||||
dateEvent: {
|
||||
type: String,
|
||||
default: "",
|
||||
default: '',
|
||||
},
|
||||
|
||||
limitation: {
|
||||
type: String,
|
||||
default: "",
|
||||
default: '',
|
||||
},
|
||||
|
||||
order: {
|
||||
@@ -103,15 +99,33 @@ export default {
|
||||
type: Number,
|
||||
default: -1,
|
||||
},
|
||||
isStart: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
// Новый проп - ограничение по времени (для окончания повторений)
|
||||
timeLimit: {
|
||||
type: String,
|
||||
default: '23:59',
|
||||
},
|
||||
// Новый проп - режим работы (обычный или для окончания повторений)
|
||||
showTime: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
},
|
||||
|
||||
emits: ['update:dateEvent', 'adjustEndDate'],
|
||||
|
||||
setup(props, { emit }) {
|
||||
const menudate = ref(false);
|
||||
const menutime = ref(false);
|
||||
|
||||
const propsDateEvent = computed({
|
||||
get: () => new Date(props.dateEvent),
|
||||
set: (value) => emit("update:dateEvent", value),
|
||||
set: (value) => {
|
||||
emit('update:dateEvent', value);
|
||||
},
|
||||
});
|
||||
|
||||
const modelDate = computed({
|
||||
@@ -119,83 +133,99 @@ export default {
|
||||
return propsDateEvent.value;
|
||||
},
|
||||
set(newValue) {
|
||||
creatwdDate(newValue, timeEvent.value);
|
||||
createdDate(newValue, timeEvent.value);
|
||||
},
|
||||
});
|
||||
|
||||
const timeEvent = computed({
|
||||
get() {
|
||||
return `${new Date(propsDateEvent.value).getHours()}:${String(
|
||||
new Date(propsDateEvent.value).getMinutes()
|
||||
).padStart(2, "0")}`;
|
||||
const date = new Date(propsDateEvent.value);
|
||||
const time = `${date.getHours()}:${String(date.getMinutes()).padStart(2, '0')}`;
|
||||
return time;
|
||||
},
|
||||
|
||||
set(newValue) {
|
||||
creatwdDate(modelDate.value, newValue);
|
||||
applyTimeChange(newValue);
|
||||
},
|
||||
});
|
||||
|
||||
const creatwdDate = (date, time) => {
|
||||
let tzero = time.split(":");
|
||||
time = tzero[0].padStart(2, "0") + ":" + tzero[1];
|
||||
// Новый метод для применения изменений времени
|
||||
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) {
|
||||
if (time == "0:00") {
|
||||
propsDateEvent.value = date;
|
||||
} else if (
|
||||
new Date(formatDash(date) + "T" + time) >= new Date(props.limitation)
|
||||
) {
|
||||
propsDateEvent.value = new Date(formatDash(date) + "T" + time);
|
||||
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 = new Date(props.limitation);
|
||||
propsDateEvent.value = newDate;
|
||||
}
|
||||
} else {
|
||||
propsDateEvent.value =
|
||||
time == "0:00" ? date : new Date(formatDash(date) + "T" + time);
|
||||
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 [hours, minutes] = time.split(':').map(Number);
|
||||
const newDate = new Date(date);
|
||||
newDate.setHours(hours, minutes, 0, 0);
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
menudate.value = false;
|
||||
menutime.value = false;
|
||||
};
|
||||
|
||||
const minData = () => {
|
||||
let h = `${new Date(props.limitation).getHours()}:${String(
|
||||
new Date(props.limitation).getMinutes()
|
||||
).padStart(2, "0")}`;
|
||||
let min =
|
||||
h == "0:00"
|
||||
? new Date(props.limitation)
|
||||
: new Date(
|
||||
new Date(props.limitation).setDate(
|
||||
new Date(props.limitation).getDate() - 1
|
||||
)
|
||||
);
|
||||
return new Date(min);
|
||||
return new Date(props.limitation);
|
||||
};
|
||||
|
||||
const startMin = () => {
|
||||
if (props.rule == 2) {
|
||||
return new Date(
|
||||
new Date(props.limitation).setDate(
|
||||
new Date(props.limitation).getDate() - 7
|
||||
)
|
||||
);
|
||||
}
|
||||
return false;
|
||||
return new Date(); // ← По умолчанию: нельзя выбрать прошедшие даты
|
||||
};
|
||||
|
||||
const endMax = () => {
|
||||
if (props.rule == 2) {
|
||||
return new Date(
|
||||
new Date(props.limitation).setDate(
|
||||
new Date(props.limitation).getDate() + 6
|
||||
)
|
||||
);
|
||||
}
|
||||
return false;
|
||||
return null; // ← Без ограничения сверху
|
||||
};
|
||||
|
||||
return {
|
||||
propsDateEvent,
|
||||
menudate,
|
||||
menutime,
|
||||
onTimePickerChange,
|
||||
modelDate,
|
||||
formatComa,
|
||||
timeEvent,
|
||||
|
||||
@@ -1,100 +1,136 @@
|
||||
<template>
|
||||
<!-- -->
|
||||
<v-autocomplete
|
||||
v-model="selectedStaff"
|
||||
:items="staffed"
|
||||
label="Выберите из списка или найдите по ФИО"
|
||||
item-title="title"
|
||||
item-value="id"
|
||||
:custom-filter="onFilter"
|
||||
@update:search="(val) => (filtered = val)"
|
||||
multiple
|
||||
hide-details
|
||||
variant="outlined"
|
||||
density="compact"
|
||||
class="max-height-select py-3"
|
||||
return-object
|
||||
>
|
||||
<template v-slot:selection="{ item }">
|
||||
<v-chip class="me-2" color="teal-darken-3" size="small" label>
|
||||
<span> {{ item.title }}</span>
|
||||
<v-icon
|
||||
v-if="item.value != accountStore.user.is_idEmployee"
|
||||
icon="mdi-close-circle"
|
||||
size="x-small"
|
||||
class="ml-3"
|
||||
@click.stop="selectedStaff = item.raw"
|
||||
/>
|
||||
</v-chip>
|
||||
</template>
|
||||
<template v-slot:prepend-item>
|
||||
<v-list-item
|
||||
@click.stop="allUser()"
|
||||
:disabled="staffed.length == 1 && staffed[0].employees.length == 1"
|
||||
class="text-body-2"
|
||||
>
|
||||
<span class="text-body-2"> ВСЕ СОТРУДНИКИ </span>
|
||||
|
||||
<template v-slot:prepend>
|
||||
<v-checkbox-btn
|
||||
:model-value="staffed.every((e) => e[okey] == true)"
|
||||
:disabled="staffed.length == 1 && staffed[0].employees.length == 1"
|
||||
></v-checkbox-btn>
|
||||
</template>
|
||||
</v-list-item>
|
||||
|
||||
<v-divider class="mt-2"></v-divider>
|
||||
</template>
|
||||
|
||||
<template v-slot:item="{ props, item }">
|
||||
<v-list-group v-bind="props" :value="item.raw.title">
|
||||
<template v-slot:activator="{ props }">
|
||||
<v-list-item v-bind="props" @click.stop="" density="compact" class="text-body-2">
|
||||
<template v-slot:prepend>
|
||||
<v-checkbox-btn
|
||||
@click.stop="selectedStaff = item.raw"
|
||||
:color="'indigo-darken-4'"
|
||||
:true-value="true"
|
||||
:false-value="false"
|
||||
:disabled="disable(item.raw)"
|
||||
:indeterminate="
|
||||
item.raw.employees.some((e) => e[okey] == true) &&
|
||||
!item.raw.employees.every((e) => e[okey] == true)
|
||||
"
|
||||
:model-value="item.raw[okey]"
|
||||
></v-checkbox-btn>
|
||||
</template>
|
||||
</v-list-item>
|
||||
</template>
|
||||
<div>
|
||||
<!-- -->
|
||||
|
||||
<v-autocomplete
|
||||
v-model="selectedStaff"
|
||||
:items="staffed"
|
||||
label="Выберите из списка или найдите по ФИО"
|
||||
item-title="title"
|
||||
item-value="id"
|
||||
:search-input.sync="filtered"
|
||||
@update:search="(val) => (filtered = val)"
|
||||
multiple
|
||||
hide-details
|
||||
variant="outlined"
|
||||
density="compact"
|
||||
class="max-height-select py-3"
|
||||
return-object
|
||||
:custom-filter="customFilterFn"
|
||||
>
|
||||
<!-- :custom-filter="onFilter" -->
|
||||
<template v-slot:selection="{ item }">
|
||||
<v-chip class="me-2" color="teal-darken-3" size="small" label>
|
||||
<span> {{ item.title }}</span>
|
||||
<v-icon
|
||||
v-if="!isAuthor(item.raw)"
|
||||
icon="mdi-close-circle"
|
||||
size="x-small"
|
||||
class="ml-3"
|
||||
@click.stop="selectedStaff = item.raw"
|
||||
/>
|
||||
</v-chip>
|
||||
</template>
|
||||
<template v-slot:prepend-item>
|
||||
<v-list-item
|
||||
v-for="x in item.raw.employees.filter((e) =>
|
||||
e.title.toLowerCase().includes(filtered.toLowerCase()),
|
||||
)"
|
||||
:key="x.id"
|
||||
:value="x.title"
|
||||
:disabled="x.id == accountStore.user.is_idEmployee"
|
||||
@click.stop="selectedStaff = x"
|
||||
density="compact"
|
||||
:disabled="staffed.length == 1 && staffed[0].employees.length == 1"
|
||||
class="text-body-2"
|
||||
@click.stop="allUser()"
|
||||
>
|
||||
<span class="text-body-2"> ВСЕ СОТРУДНИКИ </span>
|
||||
|
||||
<template v-slot:prepend>
|
||||
<v-checkbox-btn
|
||||
:disabled="x.id == accountStore.user.is_idEmployee"
|
||||
color="indigo-darken-4"
|
||||
:model-value="x[okey]"
|
||||
:model-value="staffed.every((e) => e[okey] == true)"
|
||||
:disabled="staffed.length == 1 && staffed[0].employees.length == 1"
|
||||
></v-checkbox-btn>
|
||||
</template>
|
||||
<span class="text-body-2"> {{ x.title }} </span>
|
||||
</v-list-item>
|
||||
</v-list-group>
|
||||
</template>
|
||||
</v-autocomplete>
|
||||
<!-- ВСЕ НАЧАЛЬНИКИ -->
|
||||
<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>
|
||||
</template>
|
||||
|
||||
<template v-slot:item="{ props, item }">
|
||||
<v-list-group v-bind="props" :value="item.raw.title">
|
||||
<template v-slot:activator="{ props }">
|
||||
<v-list-item v-bind="props" @click.stop="" density="compact" class="text-body-2">
|
||||
<template v-slot:prepend>
|
||||
<v-checkbox-btn
|
||||
@click.stop="selectedStaff = item.raw"
|
||||
:color="'indigo-darken-4'"
|
||||
:true-value="true"
|
||||
:false-value="false"
|
||||
:disabled="disable(item.raw) || isAuthor(item.raw)"
|
||||
:indeterminate="
|
||||
item.raw.employees.some((e) => e[okey] == true) &&
|
||||
!item.raw.employees.every((e) => e[okey] == true)
|
||||
"
|
||||
:model-value="item.raw[okey]"
|
||||
></v-checkbox-btn>
|
||||
</template>
|
||||
</v-list-item>
|
||||
</template>
|
||||
|
||||
<v-list-item
|
||||
v-for="x in item.raw.employees.filter((e) =>
|
||||
e.title.toLowerCase().includes(filtered.toLowerCase()),
|
||||
)"
|
||||
:key="x.id"
|
||||
:value="x.title"
|
||||
@click.stop="selectedStaff = x"
|
||||
:disabled=" isAuthor(x)"
|
||||
density="compact"
|
||||
>
|
||||
<template v-slot:prepend>
|
||||
<v-checkbox-btn
|
||||
:disabled="isAuthor(x)"
|
||||
color="indigo-darken-4"
|
||||
:model-value="x[okey]"
|
||||
></v-checkbox-btn>
|
||||
</template>
|
||||
<span class="text-body-2"> {{ x.title }} </span>
|
||||
</v-list-item>
|
||||
</v-list-group>
|
||||
</template>
|
||||
</v-autocomplete>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { ref, computed } from 'vue';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { splitname } from '@/utils/universal_functions';
|
||||
import { useAccountStore } from '@/store/AccountStore';
|
||||
import { useCalendarStore } from '@/store/calendarStore';
|
||||
|
||||
export default {
|
||||
props: {
|
||||
@@ -106,11 +142,19 @@ export default {
|
||||
type: String,
|
||||
default: 'selected',
|
||||
},
|
||||
authorID: {
|
||||
type: Number,
|
||||
default: null,
|
||||
},
|
||||
},
|
||||
|
||||
setup(props, { emit }) {
|
||||
const filtered = ref('');
|
||||
|
||||
const accountStore = useAccountStore();
|
||||
const calendarStore = useCalendarStore();
|
||||
const { dictEmployeesLoaded } = storeToRefs(calendarStore);
|
||||
|
||||
const back = ref([]);
|
||||
|
||||
const staffed = computed({
|
||||
@@ -119,7 +163,9 @@ export default {
|
||||
let ns = [];
|
||||
props.staff.forEach((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);
|
||||
});
|
||||
|
||||
@@ -128,8 +174,10 @@ export default {
|
||||
e.editor = true;
|
||||
}
|
||||
});
|
||||
|
||||
return ns;
|
||||
}
|
||||
|
||||
return props.staff;
|
||||
},
|
||||
});
|
||||
@@ -142,8 +190,14 @@ export default {
|
||||
e[props.okey] = true;
|
||||
selected.push(e);
|
||||
} else if (e.employees.length == 1) {
|
||||
e[props.okey] = true;
|
||||
selected.push(...e.employees.filter((n) => n[props.okey] == true));
|
||||
const singleEmployee = e.employees[0];
|
||||
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 {
|
||||
e[props.okey] = false;
|
||||
selected.push(...e.employees.filter((n) => n[props.okey] == true));
|
||||
@@ -198,7 +252,7 @@ export default {
|
||||
|
||||
const cbstaff = (item, value) => {
|
||||
item.forEach((e) => {
|
||||
if (e.id != accountStore.user.is_idEmployee) {
|
||||
if (e.id !== accountStore.user.is_idEmployee) {
|
||||
e[props.okey] = value;
|
||||
}
|
||||
if (!('employees' in e)) {
|
||||
@@ -210,14 +264,33 @@ export default {
|
||||
});
|
||||
};
|
||||
|
||||
function onFilter(item, itemText) {
|
||||
return (
|
||||
item.includes(filtered.value) ||
|
||||
itemText.raw.employees.some((e) =>
|
||||
e.title.toLowerCase().includes(filtered.value.toLowerCase()),
|
||||
)
|
||||
);
|
||||
}
|
||||
const customFilterFn = (item, queryText, itemText) => {
|
||||
if (!queryText) return true;
|
||||
|
||||
const searchText = queryText.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) => {
|
||||
return department.id == accountStore.user.id_dict_department &&
|
||||
@@ -226,29 +299,148 @@ export default {
|
||||
: 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 = () => {
|
||||
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 {
|
||||
isAuthor,
|
||||
staffed,
|
||||
filtered,
|
||||
accountStore,
|
||||
selectedStaff,
|
||||
splitname,
|
||||
onFilter,
|
||||
disable,
|
||||
allUser,
|
||||
customFilterFn,
|
||||
findEmployeesByPosition,
|
||||
toggleByPosition,
|
||||
hasBossesInStaff,
|
||||
hasBossesSelected,
|
||||
hasDeputiesInStaff,
|
||||
hasDeputiesSelected,
|
||||
dictEmployeesLoaded,
|
||||
};
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.max-height-select .v-field__input {
|
||||
max-height: 300px; /* Установите желаемую максимальную высоту */
|
||||
overflow-y: auto; /* Добавьте прокрутку, если список превышает максимальную высоту */
|
||||
overflow-x: hidden;
|
||||
margin: 5px;
|
||||
}
|
||||
</style>
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<dialog-create
|
||||
:title="titleCard"
|
||||
:newOrOld="newCalendar"
|
||||
:newOrOld="isNewCalendar"
|
||||
@closeDialog="$emit('closeDialog')"
|
||||
@delObject="delCalendar(propsCalendar.id)"
|
||||
@postData="postCalendar"
|
||||
@@ -46,6 +46,7 @@
|
||||
<calendar-create-select
|
||||
:staff="newStaff"
|
||||
@returnIdParticant="returnIdParticant"
|
||||
:authorID="calendarAuthorId"
|
||||
/> </v-col
|
||||
></v-row>
|
||||
</v-col>
|
||||
@@ -69,6 +70,7 @@
|
||||
:staff="newStaff"
|
||||
:okey="'editor'"
|
||||
@returnIdParticant="returnIdParticant"
|
||||
:authorID="calendarAuthorId"
|
||||
/>
|
||||
</v-col>
|
||||
<v-col lg="1" class="text-center">
|
||||
@@ -109,6 +111,15 @@ export default {
|
||||
setup(props, { emit }) {
|
||||
const accountStore = useAccountStore();
|
||||
|
||||
const calendarAuthorId = computed(() => {
|
||||
// Для нового календаря - текущий пользователь
|
||||
if (isNewCalendar.value) {
|
||||
return accountStore.user.is_idEmployee;
|
||||
}
|
||||
// Для существующего - автор из props
|
||||
return propsCalendar.value.author;
|
||||
});
|
||||
|
||||
const returnIdParticant = (idPart) => {
|
||||
idPart.staff.forEach((e) => {
|
||||
let indx = propsCalendar.value.participant.findIndex((l) => l.participant_calendar == e.id);
|
||||
@@ -150,20 +161,14 @@ export default {
|
||||
cl_descr: [(val) => req(val)],
|
||||
};
|
||||
|
||||
const titleCard = ref('');
|
||||
const newCalendar = ref(false);
|
||||
const isNewCalendar = computed(() => !propsCalendar.value.id);
|
||||
const isAuthor = computed(() => propsCalendar.value.author === accountStore.user.is_idEmployee);
|
||||
|
||||
const calendarNewOrOld = () => {
|
||||
if ('id' in propsCalendar.value) {
|
||||
titleCard.value = 'Редактирование календаря';
|
||||
if (propsCalendar.value.author != accountStore.user.is_idEmployee) newCalendar.value = true;
|
||||
} else {
|
||||
titleCard.value = 'Новый календарь';
|
||||
const titleCard = computed(() =>
|
||||
isNewCalendar.value ? 'Новый календарь' : 'Редактирование календаря',
|
||||
);
|
||||
|
||||
newCalendar.value = true;
|
||||
}
|
||||
};
|
||||
calendarNewOrOld();
|
||||
const newCalendar = computed(() => (isNewCalendar.value ? true : !isAuthor.value));
|
||||
|
||||
const postCalendar = (val) => {
|
||||
if (val) {
|
||||
@@ -212,24 +217,41 @@ export default {
|
||||
},
|
||||
});
|
||||
|
||||
const color = [
|
||||
'red',
|
||||
'pink',
|
||||
'deep-orange',
|
||||
'amber',
|
||||
'yellow',
|
||||
'lime',
|
||||
'light-green',
|
||||
'green',
|
||||
'light-blue',
|
||||
'blue',
|
||||
'indigo',
|
||||
'deep-purple',
|
||||
'purple',
|
||||
'blue-grey',
|
||||
'brown',
|
||||
];
|
||||
// const color = [
|
||||
// '#0ea5e9', // Яркий голубой
|
||||
// '#3b82f6', // Королевский синий
|
||||
// '#10b981', // Изумрудно-зеленый
|
||||
// '#f59e0b', // Теплый янтарный
|
||||
// '#ef4444', // Акцентный красный
|
||||
// '#8b5cf6', // Фиолетовый
|
||||
// '#4f46e5', // Индиго (профессиональный синий)
|
||||
// '#06b6d4', // Бирюзовый
|
||||
// '#84cc16', // Лаймовый
|
||||
// '#f97316', // Оранжевый
|
||||
// '#ec4899', // Розовый
|
||||
// '#6366f1', // Фиолетово-синий
|
||||
// '#14b8a6', // Бирюзово-зеленый
|
||||
// '#eab308', // Золотисто-желтый
|
||||
// '#22c55e', // Зеленый
|
||||
// ];
|
||||
|
||||
const color = [
|
||||
'#3b82f6', // Синий
|
||||
'#10b981', // Зеленый
|
||||
'#dc2626', // Красный
|
||||
'#d97706', // Оранжевый
|
||||
'#7c3aed', // Фиолетовый
|
||||
'#0ea5e9', // Голубой
|
||||
'#84cc16', // Лаймовый
|
||||
'#f59e0b', // Янтарный
|
||||
'#8b5cf6', // Пурпурный
|
||||
'#06b6d4', // Бирюзовый
|
||||
'#f97316', // Теплый оранжевый
|
||||
'#6366f1', // Фиолетово-синий
|
||||
'#14b8a6', // Морской волны
|
||||
'#ec4899', // Розовый
|
||||
'#64748b', // Серо-синий
|
||||
];
|
||||
const colorPik = (col) => {
|
||||
if (propsCalendar.value.cl_color === col) {
|
||||
propsCalendar.value.cl_color = null;
|
||||
@@ -266,6 +288,8 @@ export default {
|
||||
titleCard,
|
||||
newCalendar,
|
||||
newStaff,
|
||||
isNewCalendar,
|
||||
calendarAuthorId,
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,12 +1,5 @@
|
||||
<template>
|
||||
<v-expansion-panels
|
||||
class="calendar"
|
||||
variant="accordion"
|
||||
flat
|
||||
tile
|
||||
static
|
||||
v-model="openGroup"
|
||||
>
|
||||
<v-expansion-panels class="calendar" variant="accordion" flat tile static v-model="openGroup">
|
||||
<v-expansion-panel elevation="0" flat tile static>
|
||||
<v-expansion-panel-title flat tile static class="py-0 px-3">
|
||||
<div @click.stop="">
|
||||
@@ -26,7 +19,7 @@
|
||||
<template v-if="Object.keys(calendars).length > 0">
|
||||
<v-list-item
|
||||
v-for="(x, i) in calendars"
|
||||
:key="i"
|
||||
:key="x.id"
|
||||
:value="x.cl_name"
|
||||
@mouseenter="hover = i"
|
||||
@mouseleave="hover = null"
|
||||
@@ -37,9 +30,10 @@
|
||||
<v-checkbox-btn
|
||||
class="text-caption"
|
||||
:class="`text-${x.cl_color}`"
|
||||
v-model="x.visible"
|
||||
:color="x.cl_color"
|
||||
@update:modelValue="chekUpdate(x)"
|
||||
v-model="x.visible"
|
||||
@update:modelValue="toggleVisiblityEvents(x)"
|
||||
:model-value="x.visible"
|
||||
></v-checkbox-btn>
|
||||
</template>
|
||||
<template v-slot:title>
|
||||
@@ -47,16 +41,12 @@
|
||||
</template>
|
||||
|
||||
<template v-slot:append>
|
||||
|
||||
<transition name="fade">
|
||||
<v-btn
|
||||
v-if="
|
||||
x.author == accountStore.user.is_idEmployee ||
|
||||
x.author == user.is_idEmployee ||
|
||||
x.participant.some(
|
||||
(e) =>
|
||||
e.editor == true &&
|
||||
e.participant_calendar ==
|
||||
accountStore.user.is_idEmployee
|
||||
(e) => e.editor === true && e.participant_calendar === user.is_idEmployee,
|
||||
)
|
||||
"
|
||||
size="x-small"
|
||||
@@ -74,21 +64,23 @@
|
||||
</template>
|
||||
</v-expansion-panel-text>
|
||||
</v-expansion-panel>
|
||||
<v-dialog v-model="showDialog" min-width="636" max-width="800">
|
||||
<calendar-create
|
||||
@closeDialog = "showDialog = false"
|
||||
:calendar="calendar"
|
||||
@update:calendar="calendar = $event"
|
||||
@getCalendar="$emit('getCalendar')"
|
||||
/>
|
||||
<v-dialog v-model="showDialog" min-width="636" max-width="800">
|
||||
<calendar-create
|
||||
@closeDialog="handleCloseDialog"
|
||||
:calendar="calendar"
|
||||
@getCalendar="$emit('getCalendar')"
|
||||
/>
|
||||
</v-dialog>
|
||||
</v-expansion-panels>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { ref } from "vue";
|
||||
import calendarCreate from "@/components/calendar_of_events/calendar-create.vue";
|
||||
import { useAccountStore } from "@/store/AccountStore";
|
||||
import { ref, watch } from 'vue';
|
||||
import calendarCreate from '@/components/calendar_of_events/calendar-create.vue';
|
||||
import { useAccountStore } from '@/store/AccountStore';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { useCalendarStore } from '@/store/calendarStore';
|
||||
|
||||
export default {
|
||||
components: { calendarCreate },
|
||||
|
||||
@@ -99,54 +91,69 @@ export default {
|
||||
},
|
||||
|
||||
title: {
|
||||
typr: String,
|
||||
default: "",
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
},
|
||||
|
||||
setup(props, { emit }) {
|
||||
setup(props) {
|
||||
const showDialog = ref(false);
|
||||
const accountStore = useAccountStore();
|
||||
const calendar = ref({});
|
||||
const { user } = storeToRefs(accountStore);
|
||||
const calendarStore = useCalendarStore();
|
||||
const { toggleCalendarVisibility, hiddenCalendarIds } = calendarStore;
|
||||
|
||||
const calendar = ref(null);
|
||||
const openGroup = ref([0]);
|
||||
const trans = ref(false);
|
||||
const hover = ref(0);
|
||||
|
||||
const editCreatedCalendar = (cal) => {
|
||||
|
||||
if (cal === undefined) {
|
||||
calendar.value = {
|
||||
cl_name: "",
|
||||
participant: [{ editor: true, participant_calendar: accountStore.user.is_idEmployee }],
|
||||
cl_color: "red",
|
||||
cl_descr: "",
|
||||
cl_name: '',
|
||||
participant: [{ editor: true, participant_calendar: user.value.is_idEmployee }],
|
||||
cl_color: 'red',
|
||||
cl_descr: '',
|
||||
};
|
||||
} else {
|
||||
|
||||
calendar.value = cal;
|
||||
calendar.value = { ...cal };
|
||||
}
|
||||
showDialog.value = true;
|
||||
};
|
||||
|
||||
const chekUpdate = (cal) => {
|
||||
let setcal = new Set(accountStore.calendar);
|
||||
if (cal.visible == false) {
|
||||
setcal.add(cal.id);
|
||||
} else {
|
||||
setcal.delete(cal.id);
|
||||
}
|
||||
accountStore.calendar = Array.from(setcal);
|
||||
const handleCloseDialog = () => {
|
||||
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 {
|
||||
showDialog,
|
||||
calendar,
|
||||
editCreatedCalendar,
|
||||
chekUpdate,
|
||||
accountStore,
|
||||
user,
|
||||
calendar,
|
||||
showDialog,
|
||||
editCreatedCalendar,
|
||||
toggleVisiblityEvents,
|
||||
openGroup,
|
||||
trans,
|
||||
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,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,183 @@
|
||||
import { RRule } from 'rrule';
|
||||
|
||||
export function useRecurrence() {
|
||||
const parseRecurrenceOptions = (periodString, eventDateStart) => {
|
||||
if (!periodString || periodString === 'null') return null;
|
||||
|
||||
try {
|
||||
// Пробуем распарсить как RRULE-строку
|
||||
if (periodString.includes('RRULE:')) {
|
||||
const rrule = RRule.fromString(periodString);
|
||||
return {
|
||||
...rrule.origOptions,
|
||||
dtstart: new Date(eventDateStart),
|
||||
interval: rrule.origOptions.interval || 1,
|
||||
};
|
||||
}
|
||||
// Пробуем распарсить как JSON
|
||||
const periodData = JSON.parse(periodString);
|
||||
if (periodData?.origOptions) {
|
||||
const options = { ...periodData.origOptions };
|
||||
if (options.dtstart && typeof options.dtstart === 'string') {
|
||||
options.dtstart = new Date(eventDateStart);
|
||||
}
|
||||
if (options.interval === undefined) {
|
||||
options.interval = 1;
|
||||
}
|
||||
return options;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Parse recurrence error:', error);
|
||||
}
|
||||
return null;
|
||||
};
|
||||
/**
|
||||
* Проверяет, является ли событие повторяющимся
|
||||
*/
|
||||
const isRecurringEvent = (event) => {
|
||||
if (!event.period || event.period === 'null') return false;
|
||||
return (
|
||||
event.period.includes('RRULE:') || (event.period && event.period.includes('"origOptions"'))
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Генерирует все экземпляры повторяющегося события
|
||||
*/
|
||||
const generateRecurringInstances = (event, count = 24) => {
|
||||
if (!isRecurringEvent(event)) return [event];
|
||||
|
||||
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) 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 {
|
||||
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>
|
||||
File diff suppressed because it is too large.
Load diff
@@ -20,7 +20,7 @@
|
||||
</template>
|
||||
<span>F.A.Q.</span>
|
||||
</v-tooltip>
|
||||
|
||||
|
||||
|
||||
<v-dialog v-model="LikeDialog" persistent width="800">
|
||||
<template v-slot:activator="{ props }">
|
||||
@@ -83,11 +83,11 @@
|
||||
<!-- v-if="!('submenu' in x) || (x.path== '/portal' && accountStore.user.is_staff)" -->
|
||||
<v-list-item v-if="(x.path == '/portal'? accountStore.user.is_superuser : true) && !('submenu' in x)
|
||||
" :key="x.key" :title="x.name" :value="x.name" :href="x.link" :disabled="x.path == ''" :to="x.path"
|
||||
:target="x.link ? '_blank' : ''"
|
||||
:target="x.link ? '_blank' : ''"
|
||||
color="navigation"
|
||||
|
||||
>
|
||||
|
||||
|
||||
>
|
||||
|
||||
<template v-slot:prepend>
|
||||
<v-icon :icon="x.ico" />
|
||||
<v-tooltip v-if="rail" activator="parent" location="top">
|
||||
@@ -117,7 +117,7 @@
|
||||
</v-list>
|
||||
|
||||
<v-list nav density="compact">
|
||||
<v-list-item v-for="x of mainmenuStore.portallinks" :key="x.name" :title="x.name" :value="x.name"
|
||||
<v-list-item v-for="x of mainmenuStore.portallinks" :key="x.name" :title="x.name" :value="x.name"
|
||||
:href="x.link" color="app_bar" :target="x.link ? '_blank' : ''">
|
||||
<template v-slot:prepend>
|
||||
<v-icon :icon="x.imagecode" />
|
||||
@@ -133,7 +133,7 @@
|
||||
<v-row class="flex-grow-0" v-if="accountStore.user.is_staff">
|
||||
<v-col>
|
||||
<AdminMenu :rail="rail" />
|
||||
|
||||
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-row no-gutters class="flex-grow-0">
|
||||
@@ -148,15 +148,16 @@
|
||||
<v-main v-if="accountStore.cod2user" class="d-flex bg-main_theme">
|
||||
<router-view />
|
||||
|
||||
|
||||
<alert-default />
|
||||
</v-main>
|
||||
<v-main v-else class="d-flex align-center text-h3 bg-teal-lighten-2">
|
||||
<v-card class="h-100 w-100 d-flex justify-center rounded-0 flex-column" :image="`${burl}${scrimg}`">
|
||||
<v-card-text
|
||||
<v-card-text
|
||||
class="justify-center bgCard h-100 ma-3 d-flex flex-column"
|
||||
style="background: rgba(255, 255, 255, 0.3) !important; background-color: rgba(255, 255, 255, 0.3) !important;"
|
||||
>
|
||||
<v-row
|
||||
<v-row
|
||||
class="bgText flex-grow-0"
|
||||
style="background: rgba(255, 255, 255, 0.5) !important; background-color: rgba(255, 255, 255, 0.5) !important;"
|
||||
>
|
||||
@@ -164,7 +165,7 @@
|
||||
Добро пожаловать на портал МИ ФНС России по ЦОД № 2
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-row
|
||||
<v-row
|
||||
class="bgText flex-grow-0"
|
||||
style="background: rgba(255, 255, 255, 0.5) !important; background-color: rgba(255, 255, 255, 0.5) !important;"
|
||||
>
|
||||
@@ -258,7 +259,7 @@ export default {
|
||||
|
||||
mainmenuStore.loadlinks();
|
||||
|
||||
|
||||
|
||||
|
||||
const navigations = ref([
|
||||
{
|
||||
@@ -303,11 +304,11 @@ export default {
|
||||
// ],
|
||||
// },
|
||||
|
||||
// {
|
||||
// name: "Календарь",
|
||||
// ico: "mdi-calendar",
|
||||
// path: "/ical",
|
||||
// },
|
||||
{
|
||||
name: "Календарь",
|
||||
ico: "mdi-calendar",
|
||||
path: "/ical",
|
||||
},
|
||||
{
|
||||
name: "Голосование",
|
||||
ico: "mdi-vote",
|
||||
@@ -331,7 +332,7 @@ export default {
|
||||
path: "/portal",
|
||||
},
|
||||
|
||||
|
||||
|
||||
]);
|
||||
|
||||
const imageSrc = computed(() => {
|
||||
@@ -375,7 +376,7 @@ export default {
|
||||
navigations,
|
||||
imageSrc,
|
||||
LikeDialog,
|
||||
scrimg,
|
||||
scrimg,
|
||||
rail,
|
||||
showTooltip,
|
||||
menuTruncated,
|
||||
@@ -384,7 +385,7 @@ export default {
|
||||
name,
|
||||
closeinfo,
|
||||
baseURL,
|
||||
|
||||
|
||||
message,
|
||||
};
|
||||
},
|
||||
|
||||
@@ -5,15 +5,32 @@
|
||||
*/
|
||||
|
||||
// Plugins
|
||||
import { loadFonts } from './webfontloader'
|
||||
import vuetify from './vuetify'
|
||||
import pinia from '../store'
|
||||
import router from '../router'
|
||||
import { loadFonts } from './webfontloader';
|
||||
import vuetify from './vuetify';
|
||||
import pinia from '../store';
|
||||
import router from '../router';
|
||||
|
||||
export function registerPlugins (app) {
|
||||
loadFonts()
|
||||
app
|
||||
.use(vuetify)
|
||||
.use(pinia)
|
||||
.use(router)
|
||||
// FullCalendar
|
||||
import FullCalendar from '@fullcalendar/vue3';
|
||||
import dayGridPlugin from '@fullcalendar/daygrid';
|
||||
import timeGridPlugin from '@fullcalendar/timegrid';
|
||||
import multiMonthPlugin from '@fullcalendar/multimonth';
|
||||
import interactionPlugin from '@fullcalendar/interaction';
|
||||
import listPlugin from '@fullcalendar/list';
|
||||
import ruLocale from '@fullcalendar/core/locales/ru';
|
||||
|
||||
export function registerPlugins(app) {
|
||||
loadFonts();
|
||||
app.use(vuetify).use(pinia).use(router);
|
||||
|
||||
app.component('FullCalendar', FullCalendar);
|
||||
|
||||
app.config.globalProperties.$fullCalendarPlugins = {
|
||||
dayGridPlugin,
|
||||
timeGridPlugin,
|
||||
multiMonthPlugin,
|
||||
interactionPlugin,
|
||||
listPlugin,
|
||||
ruLocale,
|
||||
};
|
||||
}
|
||||
@@ -1,24 +1,19 @@
|
||||
// Utilities
|
||||
import { defineStore } from "pinia";
|
||||
import { ref, watch, computed } from "vue";
|
||||
import { clearAxios, spravURL } from "@/utils/axios-api";
|
||||
import VueJwtDecode from "vue-jwt-decode";
|
||||
import { checkremote } from "@/utils/universal_functions";
|
||||
import { useAppStore } from "@/store/app.js";
|
||||
import { defineStore } from 'pinia';
|
||||
import { ref, watch, computed } from 'vue';
|
||||
import { clearAxios, spravURL } from '@/utils/axios-api';
|
||||
import VueJwtDecode from 'vue-jwt-decode';
|
||||
import { checkremote } from '@/utils/universal_functions';
|
||||
import { useAppStore } from '@/store/app.js';
|
||||
|
||||
export const useAccountStore = defineStore("AccountStore", () => {
|
||||
export const useAccountStore = defineStore('AccountStore', () => {
|
||||
const AppStore = useAppStore();
|
||||
const user = ref(getuserFromStorage());
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const settingsStorage = computed({
|
||||
get() {
|
||||
if (Object.keys(user.value).length==0){
|
||||
getuserFromStorage()
|
||||
if (Object.keys(user.value).length == 0) {
|
||||
getuserFromStorage();
|
||||
}
|
||||
return JSON.parse(localStorage.getItem(user.value.is_idEmployee));
|
||||
},
|
||||
@@ -29,12 +24,11 @@ export const useAccountStore = defineStore("AccountStore", () => {
|
||||
};
|
||||
|
||||
function get_setting(key) {
|
||||
return settingsStorage.value === null? defaultSettings[key]: settingsStorage.value[key];
|
||||
return settingsStorage.value === null ? defaultSettings[key] : settingsStorage.value[key];
|
||||
}
|
||||
|
||||
|
||||
const cod2user = ref(false);
|
||||
const calendar = ref(get_setting("calendar")
|
||||
);
|
||||
const calendar = ref(get_setting('calendar'));
|
||||
const setUser = (value) => {
|
||||
value.photo = checkremote(`${spravURL}${value.login}.jpg`);
|
||||
user.value = value;
|
||||
@@ -43,66 +37,57 @@ export const useAccountStore = defineStore("AccountStore", () => {
|
||||
//
|
||||
// геттер бывший
|
||||
// const getUser=computed(()=> uyser.value)
|
||||
function getuserFromStorage(){
|
||||
try{
|
||||
let u = VueJwtDecode.decode(localStorage.getItem("refresh"));
|
||||
u.user.photo = checkremote(`${spravURL}${u.user.login}.jpg`);
|
||||
return u.user;
|
||||
}catch{
|
||||
return {}}
|
||||
function getuserFromStorage() {
|
||||
try {
|
||||
let u = VueJwtDecode.decode(localStorage.getItem('refresh'));
|
||||
u.user.photo = checkremote(`${spravURL}${u.user.login}.jpg`);
|
||||
return u.user;
|
||||
} catch {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
const logging = async (anon) => {
|
||||
AppStore.loading = true;
|
||||
const result = await clearAxios.post("api/accounts/token/", anon);
|
||||
|
||||
localStorage.setItem("access", result.data.access);
|
||||
localStorage.setItem("refresh", result.data.refresh);
|
||||
user.value=getuserFromStorage()
|
||||
|
||||
const result = await clearAxios.post('api/accounts/token/', anon);
|
||||
|
||||
localStorage.setItem('access', result.data.access);
|
||||
localStorage.setItem('refresh', result.data.refresh);
|
||||
user.value = getuserFromStorage();
|
||||
|
||||
if (settingsStorage.value === null) {
|
||||
settingsUp(defaultSettings)
|
||||
settingsUp(defaultSettings);
|
||||
}
|
||||
|
||||
|
||||
AppStore.loading = false;
|
||||
};
|
||||
|
||||
|
||||
|
||||
const logout = () => {
|
||||
user.value = {};
|
||||
localStorage.removeItem("access");
|
||||
localStorage.removeItem("refresh");
|
||||
|
||||
localStorage.removeItem('access');
|
||||
localStorage.removeItem('refresh');
|
||||
};
|
||||
watch(
|
||||
user,
|
||||
(newValue, oldValue) => {
|
||||
cod2user.value =
|
||||
"login" in newValue && newValue.login.startsWith("9966-")
|
||||
? true
|
||||
: false;
|
||||
cod2user.value = 'login' in newValue && newValue.login.startsWith('9966-') ? true : false;
|
||||
},
|
||||
{ deep: true }
|
||||
{ deep: true },
|
||||
);
|
||||
|
||||
function settingsUp(newSet) {
|
||||
|
||||
localStorage.setItem(user.value.is_idEmployee, JSON.stringify(newSet)
|
||||
|
||||
);
|
||||
|
||||
function settingsUp(newSet) {
|
||||
localStorage.setItem(user.value.is_idEmployee, JSON.stringify(newSet));
|
||||
}
|
||||
|
||||
watch(
|
||||
() => calendar.value,
|
||||
(newValue) => {
|
||||
let settings = JSON.parse(localStorage.getItem(user.value.is_idEmployee));
|
||||
settings.calendar = newValue;
|
||||
|
||||
settingsUp(settings);
|
||||
},
|
||||
{ deep: true },
|
||||
);
|
||||
|
||||
watch(() => calendar.value, (newValue) => {
|
||||
|
||||
let settings = JSON.parse(localStorage.getItem(user.value.is_idEmployee))
|
||||
settings.calendar = newValue
|
||||
|
||||
settingsUp(settings)
|
||||
|
||||
}, {deep: true})
|
||||
|
||||
return { user, setUser, cod2user, logging, logout, calendar,getuserFromStorage };
|
||||
return { user, setUser, cod2user, logging, logout, calendar, getuserFromStorage };
|
||||
});
|
||||
@@ -0,0 +1,292 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import { ref, computed, watch } from 'vue';
|
||||
import { axiosApiInstance } from '@/utils/axios-api';
|
||||
import { useAccountStore } from '@/store/AccountStore';
|
||||
|
||||
export const useCalendarStore = defineStore('calendarStore', () => {
|
||||
const accountStore = useAccountStore();
|
||||
|
||||
// State
|
||||
const selectedDate = ref(new Date());
|
||||
const events = ref([]);
|
||||
const selectedEvent = ref(null);
|
||||
const showEventDialog = ref(false);
|
||||
const currentView = ref('dayGridMonth'); // Текущий вид календаря
|
||||
const calendars = ref([]); // Список календарей пользователя
|
||||
const lastUpdatedBy = ref(null);
|
||||
const holidays = ref([]);
|
||||
const dictEmployees = ref([]);
|
||||
const dictEmployeesLoaded = ref(false);
|
||||
const employees = ref([]);
|
||||
|
||||
// Массив ID скрытых календарей. Загружаем из localStorage при инициализации.
|
||||
const hiddenCalendarIds = ref([]);
|
||||
|
||||
// Getters
|
||||
const formattedSelectedDate = computed(() => selectedDate.value.toISOString().split('T')[0]);
|
||||
|
||||
const myCalendars = computed(() => {
|
||||
const userId = accountStore.user.is_idEmployee;
|
||||
|
||||
return calendars.value
|
||||
.filter((calendar) => calendar.author === userId) // ТОЛЬКО календари где пользователь автор
|
||||
.map((calendar) => {
|
||||
const participant = calendar.participant.find((p) => p.participant_calendar === userId);
|
||||
const isEditor = participant?.editor === true;
|
||||
|
||||
return {
|
||||
...calendar,
|
||||
isAuthor: true, // Всегда true, так как отфильтровали по автору
|
||||
isEditor,
|
||||
visible: !hiddenCalendarIds.value.includes(calendar.id),
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
const subscribedCalendars = computed(() => {
|
||||
const userId = accountStore.user.is_idEmployee;
|
||||
|
||||
return calendars.value
|
||||
.filter((calendar) => calendar.author !== userId) // Все календари где пользователь НЕ автор
|
||||
.map((calendar) => {
|
||||
const participant = calendar.participant.find((p) => p.participant_calendar === userId);
|
||||
const isEditor = participant?.editor === true;
|
||||
|
||||
return {
|
||||
...calendar,
|
||||
isAuthor: false,
|
||||
isEditor,
|
||||
visible: !hiddenCalendarIds.value.includes(calendar.id),
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
const eventsForSelectedDate = computed(() =>
|
||||
events.value.filter((event) => event.date_start.split('T')[0] === formattedSelectedDate.value),
|
||||
);
|
||||
|
||||
// Actions
|
||||
const setSelectedDate = (date, source = 'unknown') => {
|
||||
selectedDate.value = new Date(date);
|
||||
lastUpdatedBy.value = source;
|
||||
};
|
||||
|
||||
const setSelectedDateFromCalendar = (info) => {
|
||||
const date = new Date(info.dateStr);
|
||||
setSelectedDate(date, 'calendar');
|
||||
};
|
||||
|
||||
const setSelectedDateFromPicker = (date) => {
|
||||
setSelectedDate(date, 'datepicker');
|
||||
};
|
||||
|
||||
const setCurrentView = (view) => {
|
||||
currentView.value = view;
|
||||
};
|
||||
|
||||
// Загрузка календарей пользователя
|
||||
const loadCalendars = async () => {
|
||||
try {
|
||||
const response = await axiosApiInstance.get('api/calendar_of_events/my_calendars/');
|
||||
calendars.value = response.data;
|
||||
hiddenCalendarIds.value = [];
|
||||
} catch (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 index = hiddenCalendarIds.value.indexOf(calendarId);
|
||||
if (index === -1) {
|
||||
// Если ID нет в массиве скрытых, добавляем его (значит, календарь скрывается)
|
||||
hiddenCalendarIds.value.push(calendarId);
|
||||
} else {
|
||||
// Если ID есть в массиве, удаляем его (значит, календарь показывается)
|
||||
hiddenCalendarIds.value.splice(index, 1);
|
||||
}
|
||||
};
|
||||
|
||||
const visibleCalendars = computed(() =>
|
||||
calendars.value.filter((calendar) => !hiddenCalendarIds.value.includes(calendar.id)),
|
||||
);
|
||||
|
||||
const calendarColorMap = computed(() => {
|
||||
const map = new Map();
|
||||
calendars.value.forEach((calendar) => {
|
||||
map.set(calendar.id, calendar.cl_color);
|
||||
});
|
||||
return map;
|
||||
});
|
||||
|
||||
const allEvents = computed(() => {
|
||||
return calendars.value
|
||||
.filter((calendar) => !hiddenCalendarIds.value.includes(calendar.id))
|
||||
.flatMap((calendar) =>
|
||||
calendar.events.map((event) => ({
|
||||
...event,
|
||||
calendarData: calendar,
|
||||
})),
|
||||
);
|
||||
});
|
||||
|
||||
const editableEvents = computed(() => {
|
||||
const currentUserId = accountStore.user.is_idEmployee;
|
||||
|
||||
return allEvents.value.filter((event) => {
|
||||
const calendar = event.calendarData;
|
||||
|
||||
if (!calendar) return false;
|
||||
|
||||
// Автор календаря
|
||||
if (calendar.author === currentUserId) return true;
|
||||
|
||||
// Ищем участника с правами редактора
|
||||
const isEditor = calendar.participant?.some(
|
||||
(part) => part.participant_calendar === currentUserId && part.editor === true,
|
||||
);
|
||||
|
||||
return isEditor;
|
||||
});
|
||||
});
|
||||
|
||||
const canEditEvent = (eventId) => {
|
||||
const id = Number(eventId);
|
||||
return editableEvents.value.some((e) => e.id === id);
|
||||
};
|
||||
|
||||
const fetchHolidays = async (year) => {
|
||||
try {
|
||||
const response = await axiosApiInstance.get(
|
||||
`api/calendar_of_events/exclusion_dates/?year=${year}`,
|
||||
);
|
||||
holidays.value = response.data;
|
||||
return holidays.value;
|
||||
} catch (err) {
|
||||
console.error('Ошибка загрузки праздников:', err);
|
||||
throw err;
|
||||
}
|
||||
};
|
||||
|
||||
// Метод для проверки, является ли день выходным или праздничным
|
||||
const isNonWorkingDay = (dateInput) => {
|
||||
let date;
|
||||
|
||||
// Если входные данные — это строка в формате 'YYYY-MM-DD'
|
||||
if (typeof dateInput === 'string') {
|
||||
date = new Date(dateInput);
|
||||
}
|
||||
// Если входные данные — это объект Date
|
||||
else if (dateInput instanceof Date) {
|
||||
date = new Date(dateInput);
|
||||
}
|
||||
// Если входные данные некорректны
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Проверяем, что дата корректна
|
||||
if (isNaN(date.getTime())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const day = date.getDay();
|
||||
|
||||
// Проверка на выходной (суббота или воскресенье)
|
||||
const isWeekend = day === 0 || day === 6;
|
||||
|
||||
// Получаем год, месяц и день
|
||||
const year = date.getFullYear();
|
||||
const month = date.getMonth() + 1; // Месяцы в JS начинаются с 0
|
||||
const dayOfMonth = date.getDate();
|
||||
|
||||
const normalizedCurrentDate = `${year}-${String(month).padStart(2, '0')}-${String(dayOfMonth).padStart(2, '0')}`;
|
||||
// Проверяем, что данные о праздничных днях существуют для текущего года и месяца
|
||||
const holidaysForYear = holidays.value[year] || {};
|
||||
const holidaysForMonth = holidaysForYear[month] || [];
|
||||
|
||||
// Проверка на исключение (рабочая суббота или праздничный будний день)
|
||||
const isExceptionDay = holidaysForMonth.includes(normalizedCurrentDate);
|
||||
|
||||
const result = {
|
||||
isNonWorking: (isWeekend && !isExceptionDay) || (!isWeekend && isExceptionDay),
|
||||
isWeekendForStyling: isWeekend && !isExceptionDay,
|
||||
isHoliday: !isWeekend && isExceptionDay,
|
||||
};
|
||||
return result;
|
||||
};
|
||||
|
||||
// Открыть диалог создания/редактирования
|
||||
const openEventDialog = (event = null) => {
|
||||
selectedEvent.value = event;
|
||||
showEventDialog.value = true;
|
||||
};
|
||||
|
||||
// Закрыть диалог
|
||||
const closeEventDialog = () => {
|
||||
showEventDialog.value = false;
|
||||
selectedEvent.value = null;
|
||||
};
|
||||
|
||||
return {
|
||||
// State
|
||||
selectedDate,
|
||||
events,
|
||||
selectedEvent,
|
||||
showEventDialog,
|
||||
currentView,
|
||||
calendars,
|
||||
lastUpdatedBy,
|
||||
hiddenCalendarIds,
|
||||
holidays,
|
||||
dictEmployeesLoaded,
|
||||
|
||||
// Getters
|
||||
formattedSelectedDate,
|
||||
myCalendars,
|
||||
subscribedCalendars,
|
||||
eventsForSelectedDate,
|
||||
visibleCalendars,
|
||||
allEvents,
|
||||
calendarColorMap,
|
||||
|
||||
dictEmployees,
|
||||
employees,
|
||||
editableEvents,
|
||||
canEditEvent,
|
||||
|
||||
// Actions
|
||||
setSelectedDate,
|
||||
setCurrentView,
|
||||
loadCalendars,
|
||||
openEventDialog,
|
||||
closeEventDialog,
|
||||
setSelectedDateFromCalendar,
|
||||
setSelectedDateFromPicker,
|
||||
toggleCalendarVisibility,
|
||||
fetchHolidays,
|
||||
isNonWorkingDay,
|
||||
loadDictEmployees,
|
||||
loadEmployees,
|
||||
};
|
||||
});
|
||||
@@ -32,7 +32,7 @@ export function checking_for_entry(where, what) {
|
||||
if (!where.includes(what)) {
|
||||
where.push(what);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function getfromserver(path, reactive) {
|
||||
try {
|
||||
@@ -63,7 +63,7 @@ export function checkremote(filecheck) {
|
||||
export default str;
|
||||
|
||||
export function splitname(name) {
|
||||
|
||||
|
||||
return name.familyname + " " + name.name[0] + "." + name.parentname[0] + ".";
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ export function pagecounter() {
|
||||
// Функция записи посещения страницы сотрудникам.
|
||||
// В случае, если в роуте присутствует ключ мета и в нем ико - тогда производится запись
|
||||
const router = useRouter();
|
||||
|
||||
|
||||
if('meta' in router.currentRoute.value && 'ico' in router.currentRoute.value.meta){
|
||||
const accountStore = useAccountStore();
|
||||
const appStore = useAppStore();
|
||||
@@ -95,7 +95,7 @@ export function pagecounter() {
|
||||
export function useICalReader(url) {
|
||||
///
|
||||
const events = ref([]);
|
||||
|
||||
|
||||
const loadICalFile = async () => {
|
||||
try {
|
||||
const response = await fetch(url);
|
||||
@@ -120,13 +120,13 @@ export function useICalReader(url) {
|
||||
location: event.location,
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
return {
|
||||
type: "calendar",
|
||||
title: name,
|
||||
calendar: calendarEvents,
|
||||
}
|
||||
|
||||
|
||||
// const vevents = comp.getAllSubcomponents('vevent')
|
||||
// const eventsData = vevents.map(vevent => ({
|
||||
// vevent: vevent,
|
||||
@@ -173,4 +173,4 @@ export function useICalReader(url) {
|
||||
export function declOfNum(value, titles) {
|
||||
const cases = [2, 0, 1, 1, 1, 2];
|
||||
return titles[(value % 100 > 4 && value % 100 < 20) ? 2 : cases[(value % 10 < 5) ? value % 10 : 5]];
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,15 @@
|
||||
<template>
|
||||
<v-container fluid class="d-flex mx-0 pa-0">
|
||||
<v-row class="ma-2">
|
||||
<v-container fluid class="d-flex pa-0">
|
||||
<v-row class="ma-0">
|
||||
<v-col class="d-flex flex-column" lg="7" md="12" cols="12">
|
||||
<v-row class="flex-grow-0">
|
||||
<v-col class="pa-1">
|
||||
<div class="flex-grow-0 mb-3">
|
||||
<Carousel-list />
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-row style="height: 250px">
|
||||
<v-col class="d-flex flex-column flex-grow-0 pa-1">
|
||||
<!-- <event-calendar/> -->
|
||||
</v-col>
|
||||
</v-row>
|
||||
</div>
|
||||
|
||||
<div class="flex-grow-1">
|
||||
<HomeCalendarWidget class="h-100"/>
|
||||
|
||||
</div>
|
||||
</v-col>
|
||||
<v-col class="d-flex flex-column" lg="5" md="12" cols="12">
|
||||
<v-row>
|
||||
@@ -47,7 +45,12 @@
|
||||
<v-btn-toggle v-model="toggle" divided variant="outlined" color="teal-darken-4">
|
||||
<v-tooltip :text="x.pages__page" location="top">
|
||||
<template v-slot:activator="{ props }">
|
||||
<v-btn v-bind="props" :icon="x.pages__ico" :to="x.pages__fullPath" color="teal-darken-4" />
|
||||
<v-btn
|
||||
v-bind="props"
|
||||
:icon="x.pages__ico"
|
||||
:to="x.pages__fullPath"
|
||||
color="teal-darken-4"
|
||||
/>
|
||||
</template>
|
||||
</v-tooltip>
|
||||
</v-btn-toggle>
|
||||
@@ -74,14 +77,15 @@ import NewsHome from '@/components/news-home.vue';
|
||||
|
||||
import DigitalLetna from '@/components/digital-letna.vue';
|
||||
import { axiosApiInstance } from '@/utils/axios-api';
|
||||
import HomeCalendarWidget from '@/components/calendar_of_events/UI_calendar/HomeCalendarWidget.vue';
|
||||
import { useCalendarStore } from '@/store/calendarStore';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
CarouselList,
|
||||
|
||||
DigitalLetna,
|
||||
|
||||
NewsHome,
|
||||
HomeCalendarWidget,
|
||||
},
|
||||
|
||||
setup() {
|
||||
@@ -90,11 +94,17 @@ export default {
|
||||
const toggle = ref(null);
|
||||
|
||||
const accountStore = useAccountStore();
|
||||
const calendarStore = useCalendarStore();
|
||||
|
||||
pagecounter();
|
||||
|
||||
const fetchMyCalendars = () => {
|
||||
calendarStore.loadCalendars();
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
favoritLinks();
|
||||
fetchMyCalendars();
|
||||
});
|
||||
|
||||
const favoritLinks = () => {
|
||||
@@ -108,14 +118,14 @@ export default {
|
||||
appStore,
|
||||
favoritLinks,
|
||||
favorit,
|
||||
|
||||
fetchMyCalendars,
|
||||
toggle,
|
||||
};
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
<style lang="scss" scoped>
|
||||
.v-picker-title,
|
||||
.v-picker__header,
|
||||
.v-picker__actions {
|
||||
|
||||
Reference in new issue
Block a user