fix [P-290]: фикс ошибок
This commit is contained in:
1 parent
b6f534aaf7
commit
51ab449c33
6 files changed
+739
-198
No files matched your search
@@ -1,151 +1,226 @@
|
||||
<template>
|
||||
<v-col>
|
||||
<v-file-input
|
||||
label="Файлы"
|
||||
label="Добавить файл (размер файла не должен превышать 2Мб)"
|
||||
chips
|
||||
multiple
|
||||
v-model="eventFiles"
|
||||
v-model="newFiles"
|
||||
density="compact"
|
||||
variant="outlined"
|
||||
@click.stop=""
|
||||
@update:modelValue="handleFilesChange"
|
||||
:error-messages="errorMessages"
|
||||
>
|
||||
<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>
|
||||
<template v-slot:selection>
|
||||
|
||||
<span
|
||||
v-else-if="index === 4"
|
||||
class="text-overline text-grey-darken-3 mx-2"
|
||||
>
|
||||
+{{ files.length - 4 }} файла(ов)
|
||||
</span>
|
||||
<template v-for="(file, index) in newFiles" :key="index">
|
||||
<v-chip
|
||||
class="me-2 mb-1"
|
||||
color="teal-darken-3"
|
||||
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: 120px">
|
||||
{{ file.name }}({{ formatFileSize(file.size) }})
|
||||
</span>
|
||||
</v-chip>
|
||||
</template>
|
||||
<!-- <span v-if="newFiles.length > 0" class="text-caption text-grey ms-2">
|
||||
{{ newFiles.length }}/5
|
||||
</span> -->
|
||||
</template>
|
||||
</template>
|
||||
</v-file-input>
|
||||
<!-- Существующие файлы отдельно -->
|
||||
<div class="existing-files-section mb-4">
|
||||
<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="grey-darken-1"
|
||||
size="small"
|
||||
label
|
||||
closable
|
||||
@click:close="removeExistingFile(file.id)"
|
||||
>
|
||||
<v-icon start size="small">{{ getFileIcon(file) }}</v-icon>
|
||||
{{ getFileName(file) }}
|
||||
</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 } from 'vue';
|
||||
export default {
|
||||
props: {
|
||||
files: {
|
||||
type: Object,
|
||||
default: () => {},
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
},
|
||||
emits: ['update:files', 'postFiles'],
|
||||
|
||||
setup(props, { emit }) {
|
||||
const newFiles = 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 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 arrFiles = ref([]);
|
||||
const validateFiles = (files) => {
|
||||
errorMessages.value = [];
|
||||
|
||||
const eventFiles = computed({
|
||||
get() {
|
||||
if (!props.value) return []
|
||||
propsFiles.value.forEach((e) =>
|
||||
{
|
||||
|
||||
arrFiles.value.push(
|
||||
dataURLtoFile(
|
||||
"data:text/plain;base64,aGVsbG8gd29ybGQ=",
|
||||
get_name(decodeURI(e.file))
|
||||
)
|
||||
)}
|
||||
);
|
||||
return arrFiles.value;
|
||||
},
|
||||
|
||||
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)
|
||||
});
|
||||
}
|
||||
|
||||
emit("postFiles", newFile);
|
||||
|
||||
|
||||
},
|
||||
});
|
||||
//
|
||||
|
||||
function dataURLtoFile(dataurl, filename) {
|
||||
var arr = dataurl.split(","),
|
||||
mime = arr[0].match(/:(.*?);/)[1],
|
||||
bstr = atob(arr[1]),
|
||||
n = bstr.length,
|
||||
u8arr = new Uint8Array(n);
|
||||
|
||||
while (n--) {
|
||||
u8arr[n] = bstr.charCodeAt(n);
|
||||
// Проверка количества
|
||||
if (files.length > MAX_NEW_FILES) {
|
||||
errorMessages.value.push(`Можно добавить не более ${MAX_NEW_FILES} файлов`);
|
||||
return false;
|
||||
}
|
||||
|
||||
return new File([u8arr], filename, { type: mime });
|
||||
}
|
||||
// Проверка размера
|
||||
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;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
// 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)
|
||||
// // )
|
||||
// // );
|
||||
// Существующие файлы из event.files
|
||||
const existingFiles = computed(() => (Array.isArray(props.files) ? props.files : []));
|
||||
|
||||
// // files.value.push(file);
|
||||
// }
|
||||
// Получаем имя файла из объекта файла
|
||||
const getFileName = (fileData) => {
|
||||
if (fileData instanceof File) {
|
||||
return fileData.name;
|
||||
}
|
||||
// Для существующих файлов с бэка - извлекаем имя из пути
|
||||
if (fileData.file) {
|
||||
try {
|
||||
const filePath = fileData.file.split('?')[0]; // Убираем параметры
|
||||
const fileName = filePath.split('/').pop(); // Берем последнюю часть пути
|
||||
return fileName || 'Файл';
|
||||
} catch {
|
||||
return 'Файл';
|
||||
}
|
||||
}
|
||||
|
||||
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 = (files) => {
|
||||
if (!files) {
|
||||
newFiles.value = [];
|
||||
emit('postFiles', []);
|
||||
return;
|
||||
}
|
||||
// Валидация
|
||||
if (!validateFiles(files)) {
|
||||
return;
|
||||
}
|
||||
|
||||
errorMessages.value = [];
|
||||
// newFiles.value = [...files];
|
||||
emit('postFiles', files);
|
||||
};
|
||||
|
||||
// Удаление существующего файла
|
||||
const removeExistingFile = (fileId) => {
|
||||
try {
|
||||
// Создаем копию event и удаляем файл
|
||||
const updatedFiles = props.files.filter((file) => file.id !== fileId);
|
||||
// props.files = updatedFiles;
|
||||
emit('update:files', [...updatedFiles]);
|
||||
} catch (error) {
|
||||
console.error('Ошибка при удалении файла:', error);
|
||||
}
|
||||
};
|
||||
|
||||
// Удаление нового файла (еще не загруженного)
|
||||
const removeNewFile = (index) => {
|
||||
const updatedFiles = [...newFiles.value];
|
||||
updatedFiles.splice(index, 1);
|
||||
newFiles.value = updatedFiles;
|
||||
emit('postFiles', updatedFiles);
|
||||
};
|
||||
|
||||
// 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,
|
||||
|
||||
newFiles,
|
||||
existingFiles,
|
||||
handleFilesChange,
|
||||
removeExistingFile,
|
||||
removeNewFile,
|
||||
getFileName,
|
||||
getFileIcon,
|
||||
formatFileSize,
|
||||
errorMessages,
|
||||
validateFiles,
|
||||
};
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style></style>
|
||||
<style scoped>
|
||||
:deep(.v-chip) {
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.v-file-input__selection {
|
||||
display: none !important;
|
||||
}
|
||||
</style>
|
||||
@@ -483,7 +483,13 @@ export default {
|
||||
:deep(.fc-highlight) {
|
||||
background-color: transparent !important;
|
||||
}
|
||||
:deep(.fc-day) {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
:deep(.fc-popover) {
|
||||
background-color: rgb(248, 244, 244) !important;
|
||||
}
|
||||
/* :deep(.fc-daygrid-day-frame) {
|
||||
position: relative;
|
||||
min-height: 50px;
|
||||
|
||||
@@ -0,0 +1,487 @@
|
||||
<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 density="compact" 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),
|
||||
}"
|
||||
@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">{{ formattedSelectedDate }}</h3>
|
||||
<v-chip size="small" color="primary" variant="outlined" v-if="isToday(selectedDate)">
|
||||
Сегодня
|
||||
</v-chip>
|
||||
</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>
|
||||
<v-icon :color="event.color" size="small" class="mr-2"> mdi-circle-small </v-icon>
|
||||
</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 } from 'vue';
|
||||
|
||||
export default {
|
||||
name: 'HomeCalendarWidget',
|
||||
|
||||
setup() {
|
||||
const currentDate = ref(new Date());
|
||||
const selectedDate = ref(new Date().toISOString().split('T')[0]);
|
||||
|
||||
// Тестовые события
|
||||
const events = ref([
|
||||
{
|
||||
id: 1,
|
||||
title: 'Еженедельное совещание команды',
|
||||
start: new Date(new Date().setHours(10, 0)).toISOString(),
|
||||
end: new Date(new Date().setHours(11, 30)).toISOString(),
|
||||
color: '#2196F3',
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
title: 'Обед с клиентом',
|
||||
start: new Date(new Date().setHours(13, 0)).toISOString(),
|
||||
end: new Date(new Date().setHours(14, 0)).toISOString(),
|
||||
color: '#4CAF50',
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
title: 'Презентация проекта',
|
||||
start: new Date(
|
||||
new Date(new Date().setDate(new Date().getDate() + 1)).setHours(15, 0),
|
||||
).toISOString(),
|
||||
end: new Date(
|
||||
new Date(new Date().setDate(new Date().getDate() + 1)).setHours(16, 0),
|
||||
).toISOString(),
|
||||
color: '#FF9800',
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
title: 'Планерка отдела',
|
||||
start: new Date(
|
||||
new Date(new Date().setDate(new Date().getDate() + 3)).setHours(9, 30),
|
||||
).toISOString(),
|
||||
end: new Date(
|
||||
new Date(new Date().setDate(new Date().getDate() + 3)).setHours(10, 30),
|
||||
).toISOString(),
|
||||
color: '#9C27B0',
|
||||
},
|
||||
]);
|
||||
|
||||
const russianWeekdays = computed(() => ['Пн', 'Вт', 'Ср', 'Чт', 'Пт', 'Сб', 'Вс']);
|
||||
|
||||
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 firstDayOfWeek = (firstDay.getDay() + 6) % 7; // Пн = 0, Вс = 6
|
||||
for (let i = 0; i < firstDayOfWeek; i++) {
|
||||
const prevMonthDay = new Date(year, month, -i);
|
||||
week.unshift({
|
||||
day: prevMonthDay.getDate(),
|
||||
date: prevMonthDay.toISOString().split('T')[0],
|
||||
isCurrentMonth: false,
|
||||
});
|
||||
}
|
||||
|
||||
// Текущий месяц
|
||||
for (let day = 1; day <= lastDay.getDate(); day++) {
|
||||
const date = new Date(year, month, day);
|
||||
week.push({
|
||||
day: day,
|
||||
date: date.toISOString().split('T')[0],
|
||||
isCurrentMonth: true,
|
||||
});
|
||||
|
||||
if (week.length === 7) {
|
||||
weeks.push([...week]);
|
||||
week = [];
|
||||
}
|
||||
}
|
||||
|
||||
// Заполняем оставшиеся дни следующего месяца
|
||||
if (week.length > 0) {
|
||||
let nextMonthDay = 1;
|
||||
while (week.length < 7) {
|
||||
const date = new Date(year, month + 1, nextMonthDay);
|
||||
week.push({
|
||||
day: nextMonthDay,
|
||||
date: date.toISOString().split('T')[0],
|
||||
isCurrentMonth: false,
|
||||
});
|
||||
nextMonthDay++;
|
||||
}
|
||||
weeks.push(week);
|
||||
}
|
||||
|
||||
return weeks;
|
||||
});
|
||||
|
||||
const currentMonth = computed(() => {
|
||||
return new Date(currentDate.value).toLocaleDateString('ru-RU', {
|
||||
month: 'long',
|
||||
year: 'numeric',
|
||||
});
|
||||
});
|
||||
|
||||
const formattedSelectedDate = computed(() => {
|
||||
return new Date(selectedDate.value).toLocaleDateString('ru-RU', {
|
||||
day: 'numeric',
|
||||
month: 'long',
|
||||
year: 'numeric',
|
||||
});
|
||||
});
|
||||
|
||||
const dayEvents = computed(() => {
|
||||
return events.value
|
||||
.filter((event) => {
|
||||
const eventDate = new Date(event.start).toISOString().split('T')[0];
|
||||
return eventDate === selectedDate.value;
|
||||
})
|
||||
.sort((a, b) => new Date(a.start) - new Date(b.start));
|
||||
});
|
||||
|
||||
const isToday = (date) => {
|
||||
const today = new Date().toISOString().split('T')[0];
|
||||
const checkDate = new Date(date).toISOString().split('T')[0];
|
||||
return today === checkDate;
|
||||
};
|
||||
|
||||
const isSelected = (date) => {
|
||||
return date === selectedDate.value;
|
||||
};
|
||||
|
||||
const getDayEvents = (date) => {
|
||||
const dateStr = new Date(date).toISOString().split('T')[0];
|
||||
return events.value.filter((event) => {
|
||||
const eventDate = new Date(event.start).toISOString().split('T')[0];
|
||||
return eventDate === dateStr;
|
||||
});
|
||||
};
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
selectedDate.value = new Date().toISOString().split('T')[0];
|
||||
});
|
||||
|
||||
return {
|
||||
currentDate,
|
||||
selectedDate,
|
||||
events,
|
||||
russianWeekdays,
|
||||
calendarWeeks,
|
||||
currentMonth,
|
||||
formattedSelectedDate,
|
||||
dayEvents,
|
||||
isToday,
|
||||
isSelected,
|
||||
getDayEvents,
|
||||
isCurrentEvent,
|
||||
formatTime,
|
||||
onDateClick,
|
||||
prevMonth,
|
||||
nextMonth,
|
||||
};
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.home-calendar-widget {
|
||||
width: 700px;
|
||||
height: 300px;
|
||||
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%;
|
||||
}
|
||||
|
||||
.weekday-header {
|
||||
font-size: 0.8rem;
|
||||
font-weight: 600;
|
||||
color: #666;
|
||||
text-align: center;
|
||||
padding: 8px 4px;
|
||||
border-bottom: 1px solid #e0e0e0;
|
||||
}
|
||||
|
||||
.day-cell {
|
||||
width: 14.28%;
|
||||
height: 40px;
|
||||
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: #2196f3;
|
||||
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;
|
||||
}
|
||||
|
||||
/* Дневное расписание */
|
||||
.schedule-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 12px;
|
||||
padding: 0 4px;
|
||||
}
|
||||
|
||||
.day-title {
|
||||
font-size: 1rem;
|
||||
font-weight: 600;
|
||||
margin: 0;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.day-schedule {
|
||||
height: 220px;
|
||||
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 #f5f5f5;
|
||||
}
|
||||
|
||||
.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: #666;
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
|
||||
.event-title {
|
||||
font-size: 0.85rem;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.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;
|
||||
}
|
||||
</style>
|
||||
@@ -153,8 +153,8 @@
|
||||
</v-row>
|
||||
</v-col></v-row
|
||||
>
|
||||
<v-row no-gutters class="align-center">
|
||||
<v-col class="text-body-2 text-text_grey pb-5" lg="2"> Файлы </v-col>
|
||||
<v-row no-gutters class="align-start d-flex pt-3" style="min-height: 150px">
|
||||
<v-col class="text-body-2 text-text_grey align-start" lg="2"> Файлы </v-col>
|
||||
|
||||
<uploading-file
|
||||
:files="propsEvent.event.files"
|
||||
@@ -215,7 +215,6 @@ export default {
|
||||
setup(props, { emit }) {
|
||||
const accountStore = useAccountStore();
|
||||
const createDialog = ref(null);
|
||||
|
||||
const propsEvent = computed({
|
||||
get: () => {
|
||||
return props.eventCalendar;
|
||||
@@ -278,6 +277,7 @@ export default {
|
||||
];
|
||||
|
||||
const selectedRule = ref(repeatRules[0]);
|
||||
|
||||
// Инициализация при редактировании
|
||||
const initializeRule = () => {
|
||||
if (!propsEvent.value.event.period) {
|
||||
@@ -292,7 +292,6 @@ export default {
|
||||
(rule) => rule.rule?.freq === periodData.origOptions.freq,
|
||||
);
|
||||
selectedRule.value = foundRule || repeatRules[0];
|
||||
console.log('Initialized rule:', foundRule); // для дебага
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error parsing period:', error, 'Raw period:', propsEvent.value.event.period);
|
||||
@@ -313,7 +312,6 @@ export default {
|
||||
const isNewEvent = computed(() => !propsEvent.value.event.hasOwnProperty('id'));
|
||||
|
||||
const myCalendar = ref(null);
|
||||
// const isNewEvent = computed(() => !propsEvent.value.event.id);
|
||||
|
||||
// Computed property с защитой от undefined
|
||||
const safeCalendars = computed(() => props.myCalendars || []);
|
||||
@@ -334,10 +332,7 @@ export default {
|
||||
|
||||
const isNewEvent = !newEvent.event.id;
|
||||
|
||||
if (isNewEvent) {
|
||||
// НОВОЕ СОБЫТИЕ - первый календарь из списка или календарь по умолчанию
|
||||
myCalendar.value = safeCalendars.value[0];
|
||||
} else {
|
||||
if (!isNewEvent) {
|
||||
// РЕДАКТИРОВАНИЕ - календарь из события
|
||||
const eventCalendar = safeCalendars.value.find(
|
||||
(cal) => cal.id === newEvent.event.calendar,
|
||||
@@ -442,8 +437,12 @@ export default {
|
||||
};
|
||||
|
||||
const files = ref([]);
|
||||
const postFiles = (f) => {
|
||||
files.value = f;
|
||||
|
||||
const postFiles = (newFiles) => {
|
||||
files.value = newFiles;
|
||||
|
||||
const updatedFiles = [...propsEvent.value.event.files, ...newFiles];
|
||||
propsEvent.value.event.files = updatedFiles;
|
||||
};
|
||||
|
||||
const returnIdParticant = (idPart) => {
|
||||
@@ -481,11 +480,13 @@ export default {
|
||||
propsEvent.value.event.calendar = myCalendar.value.id;
|
||||
|
||||
let postEvent = new FormData();
|
||||
postEvent.append('event', JSON.stringify({ ...propsEvent.value.event }));
|
||||
postEvent.append('event', JSON.stringify({ ...propsEvent.value.event, files: [] }));
|
||||
if (propsEvent.value.event.files !== null) {
|
||||
files.value.forEach((e) => postEvent.append('files', e));
|
||||
}
|
||||
|
||||
console.log(postEvent);
|
||||
|
||||
axiosApiInstance.post('api/calendar_of_events/my_events/', postEvent).then((result) => {
|
||||
feedalert.alert = true;
|
||||
feedalert.text = result.data.mess;
|
||||
@@ -565,6 +566,7 @@ export default {
|
||||
selectedRule,
|
||||
updateDateEnd,
|
||||
updateDateStart,
|
||||
initializeRule,
|
||||
|
||||
createDialog,
|
||||
};
|
||||
|
||||
@@ -21,15 +21,39 @@ export const useCalendarStore = defineStore('calendarStore', () => {
|
||||
// Getters
|
||||
const formattedSelectedDate = computed(() => selectedDate.value.toISOString().split('T')[0]);
|
||||
|
||||
const myCalendars = computed(() =>
|
||||
calendars.value
|
||||
.filter((e) => e.author === accountStore.user.is_idEmployee)
|
||||
.map((calendar) => ({
|
||||
// const myCalendars = computed(() =>
|
||||
// calendars.value
|
||||
// .filter((e) => e.author === accountStore.user.is_idEmployee)
|
||||
// .map((calendar) => ({
|
||||
// ...calendar,
|
||||
// // Видимый, если его нет в массиве скрытых
|
||||
// visible: !hiddenCalendarIds.value.includes(calendar.id),
|
||||
// })),
|
||||
// );
|
||||
const myCalendars = computed(() => {
|
||||
const userId = accountStore.user.is_idEmployee;
|
||||
|
||||
return calendars.value
|
||||
.map((calendar) => {
|
||||
const isAuthor = calendar.author === userId;
|
||||
const participant = calendar.participant.find((p) => p.participant_calendar === userId);
|
||||
const isEditor = participant?.editor === true;
|
||||
|
||||
return {
|
||||
calendar,
|
||||
isAuthor,
|
||||
isEditor,
|
||||
hasAccess: isAuthor || isEditor,
|
||||
};
|
||||
})
|
||||
.filter(({ hasAccess }) => hasAccess)
|
||||
.map(({ calendar, isAuthor, isEditor }) => ({
|
||||
...calendar,
|
||||
// Видимый, если его нет в массиве скрытых
|
||||
isAuthor,
|
||||
isEditor,
|
||||
visible: !hiddenCalendarIds.value.includes(calendar.id),
|
||||
})),
|
||||
);
|
||||
}));
|
||||
});
|
||||
|
||||
const subscribedCalendars = computed(() =>
|
||||
calendars.value
|
||||
@@ -130,20 +154,6 @@ export const useCalendarStore = defineStore('calendarStore', () => {
|
||||
});
|
||||
});
|
||||
|
||||
// Календари, где пользователь имеет права редактора
|
||||
const editableCalendars = computed(() => {
|
||||
return myCalendars.value
|
||||
.filter((calendar) => {
|
||||
if (calendar.author == accountStore.user.is_idEmployee) return true;
|
||||
|
||||
const participant = calendar.participant.find(
|
||||
(p) => p.participant_calendar === accountStore.user.is_idEmployee,
|
||||
);
|
||||
return participant?.editor == true;
|
||||
})
|
||||
.map((calendar) => calendar.id);
|
||||
});
|
||||
|
||||
const canEditEvent = (eventId) => {
|
||||
const id = Number(eventId);
|
||||
|
||||
@@ -180,7 +190,7 @@ export const useCalendarStore = defineStore('calendarStore', () => {
|
||||
eventsForSelectedDate,
|
||||
visibleCalendars,
|
||||
allEvents,
|
||||
editableCalendars,
|
||||
|
||||
editableEvents,
|
||||
canEditEvent,
|
||||
|
||||
|
||||
@@ -7,14 +7,15 @@
|
||||
<Carousel-list />
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-row class="fill-height">
|
||||
<!-- <v-col cols="12" md="6" lg="6">
|
||||
<CustomCalendar :view="'dayGridMonth'" :forHomePage="true" class="mini-calendar" />
|
||||
|
||||
<v-row class="flex-grow-0" style="min-height: 300px; max-height: 300px">
|
||||
<v-col class="pa-1 d-flex align-stretch" style="height: 100%">
|
||||
<HomeCalendarWidget class="h-100" />
|
||||
</v-col>
|
||||
<v-col cols="12" md="6" lg="6">
|
||||
<CustomCalendar :view="'timeGridDay'" :forHomePage="true" class="mini-calendar" />
|
||||
</v-col> -->
|
||||
</v-row>
|
||||
<!-- <v-row style="height: 250px">
|
||||
<HomeCalendarWidget />
|
||||
</v-row> -->
|
||||
</v-col>
|
||||
<v-col class="d-flex flex-column" lg="5" md="12" cols="12">
|
||||
<v-row>
|
||||
@@ -82,18 +83,15 @@ import NewsHome from '@/components/news-home.vue';
|
||||
|
||||
import DigitalLetna from '@/components/digital-letna.vue';
|
||||
import { axiosApiInstance } from '@/utils/axios-api';
|
||||
import CustomCalendar from '../components/calendar_of_events/UI_calendar/CustomCalendar.vue';
|
||||
import HomeCalendarWidget from '@/components/calendar_of_events/UI_calendar/HomeCalendarWidget.vue';
|
||||
import { useCalendarStore } from '@/store/calendarStore';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
CarouselList,
|
||||
|
||||
DigitalLetna,
|
||||
|
||||
NewsHome,
|
||||
|
||||
CustomCalendar,
|
||||
HomeCalendarWidget,
|
||||
},
|
||||
|
||||
setup() {
|
||||
@@ -106,8 +104,8 @@ export default {
|
||||
|
||||
pagecounter();
|
||||
|
||||
const fetchMyCalendars = () => {
|
||||
calendarStore.loadCalendars();
|
||||
const fetchMyCalendars = () => {
|
||||
calendarStore.loadCalendars();
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
@@ -182,41 +180,4 @@ export default {
|
||||
color: #222 !important;
|
||||
font-family: 'Montserrat', 'Arial', sans-serif;
|
||||
}
|
||||
|
||||
.mini-calendar {
|
||||
// max-width: 100%;
|
||||
width: 100%;
|
||||
font-size: 12px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.mini-calendar :deep(.fc-day) {
|
||||
height: 8px !important;
|
||||
// width: 10px !important;
|
||||
}
|
||||
|
||||
.mini-calendar :deep(.fc-event) {
|
||||
font-size: 0.8em;
|
||||
padding: 0 1px;
|
||||
margin: 1px 0;
|
||||
flex: 0 0 auto;
|
||||
height: 250px;
|
||||
}
|
||||
|
||||
.mini-calendar :deep(.fc-daygrid-day-number) {
|
||||
font-size: 1em;
|
||||
padding: 2px;
|
||||
}
|
||||
|
||||
.mini-calendar :deep(.fc) {
|
||||
width: 100% !important;
|
||||
max-height: 320px !important;
|
||||
}
|
||||
|
||||
.mini-calendar :deep(.fc .fc-daygrid-week-number) {
|
||||
background-color: transparent !important;
|
||||
border: none !important;
|
||||
color: transparent !important;
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user