This commit is contained in:
iriska-gri committed 2024-05-06 15:27:06 +03:00
1 parent 3fe102b6da
commit be6f3dbd2b
7 files changed
+420 -230

No files matched your search

+7 -1
View File
@@ -55,10 +55,16 @@ class CalendarEvents(models.Model):
class FilesEvent(models.Model): class FilesEvent(models.Model):
""" Прикрепленные файлы к событию""" """ Прикрепленные файлы к событию"""
name = models.CharField(max_length=300, verbose_name='Название файла')
link = models.FileField(upload_to='calendar/%Y/%m/%d') link = models.FileField(upload_to='calendar/%Y/%m/%d')
event = models.ForeignKey(CalendarEvents, on_delete=models.PROTECT, null=True, blank= True, related_name='get_calendar_events_files', verbose_name='Событие к которому привязаны файлы') event = models.ForeignKey(CalendarEvents, on_delete=models.PROTECT, null=True, blank= True, related_name='get_calendar_events_files', verbose_name='Событие к которому привязаны файлы')
class Meta:
verbose_name = "Файл к событию"
verbose_name_plural = "Файлы к событиям"
def __str__(self):
return str(self.link)
class ParticipantsEvent(models.Model): class ParticipantsEvent(models.Model):
""" Участники события """ """ Участники события """
participant = models.ForeignKey(settings.AUTH_USER_MODEL, editable=False, on_delete=models.PROTECT, verbose_name='Участник события') participant = models.ForeignKey(settings.AUTH_USER_MODEL, editable=False, on_delete=models.PROTECT, verbose_name='Участник события')
+9 -2
View File
@@ -7,11 +7,14 @@ from rest_framework.response import Response
class CalendarEventsAPIView(APIView): class CalendarEventsAPIView(APIView):
def updateCreate(self, ev, calendar, bigname): def updateCreate(self, ev, calendar, bigname):
# print(calendar['start'], '11111111111111111111111111111111111111111111')
CalendarEvents.objects.update_or_create(**ev, CalendarEvents.objects.update_or_create(**ev,
defaults = {**calendar, defaults = {**calendar,
'author': User.objects.get(pk=self.request.user.id), 'author': User.objects.get(pk=self.request.user.id),
'calendarname_id': bigname.pk, 'calendarname_id': bigname.pk,
'frequency': 'repeat: {weekdays: [5] }', 'frequency': 'repeat: {weekdays: [5] }',
'startdate': calendar['start']
}) })
@@ -21,6 +24,8 @@ class CalendarEventsAPIView(APIView):
eventslist = CalendarEventsSerializer(CalendarEvents.objects.all(), many=True) eventslist = CalendarEventsSerializer(CalendarEvents.objects.all(), many=True)
return Response(eventslist.data) return Response(eventslist.data)
def post(self, request): def post(self, request):
""" Записываем или обновляем глобальное название в таблицу, если есть участники так же пишем в соотвтв. таблицу с привязкой к событию. """ Записываем или обновляем глобальное название в таблицу, если есть участники так же пишем в соотвтв. таблицу с привязкой к событию.
Добавляем или удаляяем запись о событии Добавляем или удаляяем запись о событии
@@ -28,11 +33,13 @@ class CalendarEventsAPIView(APIView):
namecalendar, created = CalendarEventsName.objects.update_or_create(name=request.data['participants'], namecalendar, created = CalendarEventsName.objects.update_or_create(name=request.data['participants'],
defaults = {'name':request.data['participants'], defaults = {'name':request.data['participants'],
'author_id': self.request.user.id}) 'author_id': self.request.user.id})
print('request.data', request.data['files'])
if 'pk' in request.data['calendar']: if 'pk' in request.data['calendar']:
event = {"calendarname_id":namecalendar.pk, event = {"calendarname_id":namecalendar.pk,
"pk": request.data['calendar']['pk'],} "pk": request.data['calendar']['pk'],}
self.updateCreate(event, request.data['calendar'], namecalendar) self.updateCreate(event, request.data['calendar'], namecalendar)
else: else:
@@ -2,7 +2,7 @@
<v-row> <v-row>
<v-col class="flex-column pr-0"> <v-col class="flex-column pr-0">
<v-card class="h-100"> <v-card class="h-100">
<my-helper :pretext="selectedEvent" /> <!-- <my-helper :pretext="events" /> q -->
<vue-cal <vue-cal
locale="ru" locale="ru"
@@ -48,7 +48,7 @@
<v-col> <v-col>
<v-card class="h-100"> <v-card class="h-100">
<v-card-title class="text-center" <v-card-title class="text-center"
>События на {{selData }}</v-card-title >События на {{ selData }}</v-card-title
> >
<vue-cal <vue-cal
@@ -61,9 +61,8 @@
hide-view-selector hide-view-selector
:time="false" :time="false"
:events="events" :events="events"
> >
<!-- :on-event-dblclick="onEventClick" -->
<template #cell-content="{ view, events }"> <template #cell-content="{ view, events }">
<v-img <v-img
v-if="['week', 'day'].includes(view.id) && !events.length" v-if="['week', 'day'].includes(view.id) && !events.length"
@@ -73,15 +72,14 @@
cover cover
/> />
<v-card v-else> <v-card v-else>
<v-list lines="one"> <v-list lines="one">
<v-list-item <v-list-item
@click="onEventClick(n)" @click="onEventClick(n)"
v-for="n in events" v-for="n in events"
:key="n.pk" :key="n.pk"
:title="n.name" :title="n.name"
:subtitle="n.description" :subtitle="n.description"
></v-list-item> ></v-list-item>
</v-list> </v-list>
</v-card> </v-card>
</template> </template>
@@ -110,10 +108,8 @@ export default {
const events = ref([]); const events = ref([]);
const onEventClick = (n) => { const onEventClick = (n) => {
selectedEvent.value = n; selectedEvent.value = n;
showDialog.value = true; showDialog.value = true;
}; };
function f_generalvacation() { function f_generalvacation() {
@@ -121,14 +117,13 @@ export default {
axiosApiInstance axiosApiInstance
.get("api/calendar_of_events/calendarEvents/") .get("api/calendar_of_events/calendarEvents/")
.then((data) => { .then((data) => {
data.data.forEach((e)=>{ data.data.forEach((e) => {
e.start = formaDashTime(e.start) e.start = formaDashTime(e.start);
e.end = e.start e.end = e.start;
}) });
events.value=data.data events.value = data.data;
// icon: "mdi-book-open", // icon: "mdi-book-open",
// class: "bg-indigo-lighten-5 border-sm", // class: "bg-indigo-lighten-5 border-sm",
}); });
} }
@@ -140,21 +135,17 @@ export default {
const selectedDate = ref(null); const selectedDate = ref(null);
const selData = computed({
get: () => {
const d = new Date(selectedDate.value);
let mess = "сегодня";
if (d.getFullYear() != "1970") {
mess = `${d.getDate()} число`;
}
const selData = computed({ return mess;
get: () => { },
const d = new Date(selectedDate.value); });
let mess = "сегодня";
if (d.getFullYear() != "1970") {
mess = `${d.getDate()} число`;
}
return mess;
}
})
return { return {
selectedEvent, selectedEvent,
@@ -166,7 +157,7 @@ export default {
eventsCssClasses, eventsCssClasses,
burl, burl,
returnUpdateData, returnUpdateData,
selData selData,
}; };
}, },
}; };
@@ -0,0 +1,187 @@
<template>
<v-dialog v-model="mydialog" max-width="700">
<v-card
:loading="isUpdating"
class="mx-auto"
color="blue-grey-darken-1"
max-width="420"
>
<template v-slot:loader="{ isActive }">
<v-progress-linear
:active="isActive"
color="green-lighten-3"
height="4"
indeterminate
></v-progress-linear>
</template>
<v-img
height="200"
src="https://cdn.vuetifyjs.com/images/cards/dark-beach.jpg"
cover
>
<v-row class="pa-3">
<v-col cols="12">
<v-menu
location="bottom start"
origin="overlap"
transition="slide-y-transition"
>
<template v-slot:activator="{ props }">
<v-btn
v-bind="props"
density="comfortable"
icon="mdi-dots-vertical"
variant="tonal"
></v-btn>
</template>
<v-list :lines="false">
<v-list-item
title="Update"
@click="isUpdating = true"
></v-list-item>
</v-list>
</v-menu>
</v-col>
<v-row>
<v-col class="text-center">
<h3 class="text-h5">{{ name }}</h3>
<span class="text-grey-lighten-1">{{ title }}</span>
</v-col>
</v-row>
</v-row>
</v-img>
<v-form>
<v-container>
<v-row dense>
<v-col cols="12" md="6">
<v-text-field
v-model="name"
:disabled="isUpdating"
color="blue-grey-lighten-2"
label="Name"
></v-text-field>
</v-col>
<v-col cols="12" md="6">
<v-text-field
v-model="title"
:disabled="isUpdating"
color="blue-grey-lighten-2"
label="Title"
></v-text-field>
</v-col>
<v-col cols="12">
<v-autocomplete
v-model="friends"
:disabled="isUpdating"
:items="people"
color="blue-grey-lighten-2"
item-title="name"
item-value="name"
label="Select"
chips
closable-chips
multiple
>
<template v-slot:chip="{ props, item }">
<v-chip
v-bind="props"
:prepend-avatar="item.raw.avatar"
:text="item.raw.name"
></v-chip>
</template>
<template v-slot:item="{ props, item }">
<v-list-item
v-bind="props"
:prepend-avatar="item.raw.avatar"
:subtitle="item.raw.group"
:title="item.raw.name"
></v-list-item>
</template>
</v-autocomplete>
</v-col>
</v-row>
</v-container>
</v-form>
<v-divider></v-divider>
<v-card-actions>
<v-switch
v-model="autoUpdate"
:disabled="isUpdating"
class="mt-0 ms-2"
color="green-lighten-2"
density="compact"
label="Auto Update"
hide-details
></v-switch>
<v-spacer></v-spacer>
<v-btn
:disabled="autoUpdate"
:loading="isUpdating"
:variant="isUpdating ? 'tonal' : undefined"
color="blue-grey-lighten-3"
prepend-icon="mdi-update"
@click="isUpdating = true"
>
Update Now
</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
</template>
<script>
import { ref, computed } from "vue";
export default {
props: {
opendialog: {
type: Boolean,
default: false,
},
},
setup(props, { emit }) {
const mydialog = computed({
get: () => props.opendialog,
set: (value) => emit("update:opendialog", value),
});
const people= [
// TODO: https://github.com/vuetifyjs/vuetify/issues/15721
// { header: 'Group 1' },
{ name: 'Sandra Adams', group: 'Group 1', avatar: srcs[1] },
{ name: 'Ali Connors', group: 'Group 1', avatar: srcs[2] },
{ name: 'Trevor Hansen', group: 'Group 1', avatar: srcs[3] },
{ name: 'Tucker Smith', group: 'Group 1', avatar: srcs[2] },
// { divider: true },
// { header: 'Group 2' },
{ name: 'Britta Holt', group: 'Group 2', avatar: srcs[4] },
{ name: 'Jane Smith ', group: 'Group 2', avatar: srcs[5] },
{ name: 'John Smith', group: 'Group 2', avatar: srcs[1] },
{ name: 'Sandra Williams', group: 'Group 2', avatar: srcs[3] },
]
return {
mydialog,
};
},
};
</script>
<style></style>
@@ -1,12 +1,11 @@
<template> <template>
<v-card> <v-card>
<v-card-title> <v-card-title>
<v-textarea <!-- <v-textarea
v-model="dataToEdit.bigname" v-model="dataToEdit.bigname"
rows="1" rows="1"
placeholder="Название календаря" placeholder="Название календаря"
/> /> -->
<v-text-field v-model="dataToEdit.name" placeholder="Заголовок" /> <v-text-field v-model="dataToEdit.name" placeholder="Заголовок" />
</v-card-title> </v-card-title>
<v-card-subtitle> <v-card-subtitle>
@@ -54,20 +53,41 @@
</v-card-subtitle> </v-card-subtitle>
<v-card-text class="pt-2"> <v-card-text class="pt-2">
<!-- <v-textarea v-model="dataToEdit.description" placeholder="Описание события" /> --> <!-- <v-textarea v-model="dataToEdit.description" placeholder="Описание события" /> -->
<ckeditor :editor="editor" v-model="dataToEdit.description" :config="{ <ckeditor
placeholder:'Описание события', :editor="editor"
language: 'ru' v-model="dataToEdit.description"
:config="{
}"></ckeditor> placeholder: 'Описание события',
<v-textarea language: 'ru',
}"
/>
<ckeditor
:editor="editor"
v-model="dataToEdit.content" v-model="dataToEdit.content"
placeholder="Полное описание события" :config="{
placeholder: 'Полное описание события',
language: 'ru',
}"
/> />
<v-textarea <v-textarea
v-model="dataToEdit.place" v-model="dataToEdit.place"
placeholder="Местопроведение события" placeholder="Местопроведение события"
/> />
<!-- <v-btn @click="openDialog">
добавить
</v-btn> -->
<!-- <event-dialog-edit-participant
:opendialog="showDialog"
@update:opendialog="showDialog = $event"
/> -->
<v-file-input
label="File input w/ chips"
chips
multiple
@change="onFileChange"
></v-file-input>
<strong>Время:</strong> <strong>Время:</strong>
<ul class="pl-5"> <ul class="pl-5">
@@ -86,13 +106,12 @@
</v-card-text> </v-card-text>
<v-card-actions> <v-card-actions>
<v-icon <v-icon
icon="mdi-check" icon="mdi-check"
color="green" color="green"
class="pb-1" class="pb-1"
@click="confirmation" @click="confirmation"
/> />
</v-card-actions> </v-card-actions>
</v-card> </v-card>
</template> </template>
@@ -100,27 +119,29 @@
import { formatComa } from "@/utils/universal_functions"; import { formatComa } from "@/utils/universal_functions";
import { ref } from "vue"; import { ref } from "vue";
import { axiosApiInstance } from "@/utils/axios-api"; import { axiosApiInstance } from "@/utils/axios-api";
import CKEditor from '@ckeditor/ckeditor5-vue'; import CKEditor from "@ckeditor/ckeditor5-vue";
import ClassicEditor from '@ckeditor/ckeditor5-build-classic'; import ClassicEditor from "@ckeditor/ckeditor5-build-classic";
import '@ckeditor/ckeditor5-build-classic/build/translations/ru'; import "@ckeditor/ckeditor5-build-classic/build/translations/ru";
import EventDialogEditParticipant from "./event-dialog-edit-participant.vue";
export default { export default {
props: { props: {
event: { event: {
type: Object, type: Object,
default: () => {}, default: () => {},
}, },
}, },
components: { components: {
// Use the <ckeditor> component in this view. // Use the <ckeditor> component in this view.
ckeditor: CKEditor.component ckeditor: CKEditor.component,
}, EventDialogEditParticipant,
},
setup(props, { emit }) { setup(props, { emit }) {
const eventFiles = ref([]);
const menudate = ref(false); const menudate = ref(false);
const dataToEdit = ref({...props.event}) const dataToEdit = ref({ ...props.event, description: "" });
const showDialog = ref(false);
const startTime = ref( const startTime = ref(
`${dataToEdit.value.start.getHours()}:${String( `${dataToEdit.value.start.getHours()}:${String(
dataToEdit.value.start.getMinutes() dataToEdit.value.start.getMinutes()
@@ -130,28 +151,47 @@ export default {
const updateDateTime = () => { const updateDateTime = () => {
if (startTime.value) { if (startTime.value) {
const timeParts = startTime.value.split(":"); const timeParts = startTime.value.split(":");
dataToEdit.value.start.setHours(parseInt(timeParts[0], 10)); dataToEdit.value.start.setHours(parseInt(timeParts[0], 10));
dataToEdit.value.start.setMinutes(parseInt(timeParts[1], 10)); dataToEdit.value.start.setMinutes(parseInt(timeParts[1], 10));
} }
}; };
const onFileChange = (event) => {
}
const confirmation = () => { const confirmation = () => {
const participants = dataToEdit.value.bigname const sdata = new FormData();
sdata.append("dailyfiles", eventFiles.value[0]);
const participants = dataToEdit.value.bigname;
console.log(sdata,
'sdata')
console.log(eventFiles.value[0],
'sdata1')
axiosApiInstance axiosApiInstance
.post(`api/calendar_of_events/calendarEvents/`, { .post(`api/calendar_of_events/calendarEvents/`, {
participants: participants, participants: participants,
calendar: dataToEdit.value, calendar: dataToEdit.value,
}) files: sdata,
},
// {
// headers: {
// "Content-Type": "multipart/form-data"
// },
// }
)
.then((data) => { .then((data) => {
emit('returnUpdateData') emit("returnUpdateData");
}); });
};
}
const openDialog = () => {
showDialog.value = true;
};
return { return {
editor: ClassicEditor, editor: ClassicEditor,
@@ -160,7 +200,10 @@ export default {
startTime, startTime,
updateDateTime, updateDateTime,
dataToEdit, dataToEdit,
confirmation confirmation,
openDialog,
showDialog,
eventFiles,
}; };
}, },
}; };
@@ -22,7 +22,7 @@
<component <component
:is = "editEvent ? 'eventDialogEdit':'eventDialogInfo'" :is = "editEvent ? 'eventDialogEdit':'eventDialogInfo'"
:event="event" :event="event"
@returnUpdateData="returnUpdateData" @returnUpdateData="returnUpdateData"
/> />
</v-dialog> </v-dialog>
</template> </template>
+109 -153
View File
@@ -1,173 +1,129 @@
<template> <template>
<div> <div>
<v-card <v-card class="bg-white pa-1 px-0" width="550">
class="bg-white pa-1 px-0 " <v-card
class="mx-auto overflow-auto mx-0 px-0"
width="550" width="550"
height="600"
> flat
<v-card >
class="mx-auto overflow-auto mx-0 px-0" <v-card-title class="fixed-bar bg-white">
width="550" <v-row class="bggrad">
height="600" <v-col class="text-center text-black_and_white">
flat {{ namepos }}
> </v-col>
</v-row>
<v-row>
<v-col class="pa-0 mb-1">
<v-divider class="" />
<v-text-field
v-model="searchname"
clearable
prepend-inner-icon="mdi-magnify"
hide-details
class="ma-0"
label="Поиск"
rows="1"
no-resize
/>
</v-col>
</v-row>
</v-card-title>
<v-card-title class="fixed-bar bg-white"> <div v-for="(x, key) in result" :key="key" class="px-3 ddd">
<v-list class="py-0">
<v-row class="bggrad"> <v-list-subheader>{{ key }} </v-list-subheader>
<v-col class="text-center text-black_and_white"> </v-list>
{{namepos}} <div v-for="item in x" :key="item">
</v-col> <list-user :author="item" />
</v-row> <!-- <vcard-user :author = item /> -->
<v-row> </div>
<v-col class="pa-0 mb-1"> </div>
<v-divider class=""/> </v-card>
<v-text-field <v-divider class="" />
v-model="searchname" <v-card-actions class="pb-0" style="place-content: end">
clearable <v-btn color="more_details_btn" variant="text" @click="onSubmit">
prepend-inner-icon="mdi-magnify" Закрыть
hide-details </v-btn>
class="ma-0" </v-card-actions>
label="Поиск" </v-card>
rows="1" </div>
no-resize
/>
</v-col>
</v-row>
</v-card-title>
<div
v-for="(x, key) in result"
:key="key"
class="px-3 ddd" >
<v-list class="py-0">
<v-list-subheader>{{key}} </v-list-subheader>
</v-list>
<div
v-for="item in x"
:key="item"
>
<list-user :author=item />
<!-- <vcard-user :author = item /> -->
</div>
</div>
</v-card>
<v-divider class=""/>
<v-card-actions class="pb-0" style="place-content: end">
<v-btn
color="more_details_btn"
variant="text"
@click="onSubmit"
>
Закрыть
</v-btn>
</v-card-actions>
</v-card>
</div>
</template> </template>
<script> <script>
import { ref, onMounted, computed } from 'vue' import { ref, onMounted, computed } from "vue";
import {checkremote} from '@/utils/universal_functions' import { checkremote } from "@/utils/universal_functions";
import { spravURL } from '@/utils/axios-api' import { spravURL } from "@/utils/axios-api";
import { axiosApiInstance } from '@/utils/axios-api' import { axiosApiInstance } from "@/utils/axios-api";
import VcardUser from '@/components/UI/fiousercard/vcardUser.vue' import VcardUser from "@/components/UI/fiousercard/vcardUser.vue";
export default { export default {
components: {
components: { VcardUser,
VcardUser
},
props: {
idpos: {
type: Number,
default: ''
},
namepos: {
type: String,
default: ''
}
}, },
setup(props, {emit}){ props: {
idpos: {
const t_dailyRound = ref({}) type: Number,
// const result = ref({}) default: "",
const iduser = ref('') },
const searchname = ref('') namepos: {
type: String,
default: "",
},
},
setup(props, { emit }) {
const t_dailyRound = ref({});
// const result = ref({})
const iduser = ref("");
const searchname = ref("");
const onSubmit = () => {
emit("searchClose");
};
const onSubmit = () => { onMounted(() => {
emit('searchClose') axiosApiInstance
} .get(`api/general_vacation/dailyload/?id=${props.idpos}`)
.then((data) => {
t_dailyRound.value = data.data.daily;
});
});
onMounted(() => { const getcard = async (idus) => {
axiosApiInstance.get(`api/general_vacation/dailyload/?id=${props.idpos}`).then(data => { iduser.value = idus;
};
t_dailyRound.value = data.data.daily
}) const result = computed({
get() {
let ob = {};
Object.keys(t_dailyRound.value).map((el1) => {
let myarr = t_dailyRound.value[el1].filter((el) =>
el.fio.toLowerCase().includes(searchname.value.toLowerCase())
);
}) if (myarr.length > 0) {
ob[el1] = myarr;
}
});
return ob;
},
});
return {
onSubmit,
checkremote,
searchname,
spravURL,
t_dailyRound,
result,
const getcard = async (idus) => { getcard,
iduser,
iduser.value = idus };
} },
};
const result = computed({
get() {
let ob={}
Object.keys(t_dailyRound.value).map(el1 => {
let myarr = t_dailyRound.value[el1].filter((el) =>el.fio.toLowerCase().includes(searchname.value.toLowerCase()))
if(myarr.length>0)
{
ob[el1] = myarr
}
}
)
return ob
}
})
return {
onSubmit,
checkremote,
searchname,
spravURL,
t_dailyRound,
result,
getcard,
iduser
}
}
}
</script> </script>
<style> <style></style>
</style>