Merge branch '38_calendar_back' into P-10

This commit is contained in:
Nukeap committed 2024-06-03 09:32:58 +03:00
commit 3ba272b11b
7 files changed
+343 -135

No files matched your search

+1 -1
View File
@@ -17,7 +17,7 @@ class ExclusionDatesAPIView(APIView):
exclude = ExclusionDates.objects.filter(exclusiondate__year=year)
months = {}
for i in range(1,12):
months[i] = exclude.filter(exclusiondate__month=i).values_list("exclusiondate")
months[i] = exclude.filter(exclusiondate__month=i).values_list("exclusiondate", flat=True)
return Response({year:months})
+18 -4
View File
@@ -205,9 +205,23 @@ class CarouselsAPIView(ListAPIView):
class ScreensaverAPIView(ListAPIView):
"""Получаем ссылку на картинку для экрана перед входом на сайт. Выбирает все записи с месяца и дня меньше и равного текущему и окончание больше или равному текущему дню и месяцу. Год не учитывается. Выбирается одна рандомная запись"""
def get(self, request):
result=''
# print(result, "--------------------------no foto screensaver")
# try:
# queryset = Screensaver.objects.all()
# queryset = Screensaver.objects.filter(cdate__month__lte = date.today().month, cdate__day__lte = date.today().day,
# enddate__month__gte=date.today().month, enddate__day__gte=date.today().day).order_by('-cdate')
queryset = Screensaver.objects.filter(cdate__month__lte = 6, cdate__day__lte = 3,
enddate__month__gte=6, enddate__day__gte=3).order_by('-cdate')
b = Screensaver.objects.values('cdate__month', 'cdate__day', 'enddate__month', 'enddate__day')
# result = ScreensaverSerializer(queryset, many= True).data
print(queryset,"--------------------------no foto screensaver")
# queryset = queryset.filter(cdate=queryset[0].cdate).order_by("?")[:1]
queryset = Screensaver.objects.filter(cdate__month__lte = date.today().month, cdate__day__lte = date.today().day,
enddate__month__gte=date.today().month, enddate__day__gte=date.today().day).order_by('-cdate')
queryset = queryset.filter(cdate=queryset[0].cdate).order_by("?")[:1]
# result = ScreensaverSerializer(queryset, many= True).data
# except Exception as e:
# print("no foto screensaver")
# print (e)
return Response(ScreensaverSerializer(queryset, many= True).data)
return Response(result)
@@ -49,9 +49,8 @@
</v-col>
<v-col></v-col>
</v-row>
<!-- <v-date-picker show-adjacent-months></v-date-picker> -->
</v-card></v-col
>
</v-card>
</v-col>
<v-col class="bg-green">
<v-btn @click="drawer_right = !drawer_right">
{{ drawer_right }}
@@ -76,42 +75,23 @@
</template>
<script>
import { axiosApiInstance } from "@/utils/axios-api";
import { ref, onMounted } from "vue";
import { ref, onMounted, watch } 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";
// const burl = baseURL.slice(0, -1);
export default {
components: { EventCreate, CalendarMy },
setup() {
const showDialog = ref(false);
const week = useWeekendsStore().week;
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);
function getWeekend() {
axiosApiInstance
.post(`api/calendar_of_events/exclusionDatas/?year=${MyYear.value}`, {})
.then((data) => {
week[MyYear.value] = data.data;
weekendsData();
});
}
function getcalendar() {
}
const getMonth = (month) => {
MyMonth.value = month + 1;
};
@@ -131,9 +111,8 @@ export default {
n.classList.add("text-red");
});
}
if (MyMonth.value in week[MyYear.value]) {
if (week[MyYear.value][MyMonth.value].includes(datas)) {
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) {
@@ -145,18 +124,26 @@ export default {
});
};
const CheckingStore = () => {
if (MyYear.value in week) {
weekendsData();
} else {
getWeekend();
}
};
onMounted(() => {
CheckingStore();
week.getWeekend(MyYear.value);
});
watch(
() => week.week,
(newValue, oldValue) => {
if (newValue) {
weekendsData();
}
}
);
const CheckingStore = () => {
if (MyYear.value in week.week) {
weekendsData();
} else {
week.getWeekend(MyYear.value);
}
};
return {
drawer_right,
selectdate,
@@ -167,7 +154,6 @@ export default {
week,
CheckingStore,
showDialog,
};
},
};
@@ -0,0 +1,152 @@
<template>
<v-select
v-model="selectedStaff"
:items="staff"
label="Выберите из списка или найдите по ФИО"
item-title="department"
item-value="department"
multiple
hide-details
variant="outlined"
density="compact"
class="max-height-select"
return-object
>
<template v-slot:selection="{ item, index }">
<!-- <v-chip v-if="(index < 1) && allStaff">
<span>Выбраны все сотрудники</span>
</v-chip> -->
<v-chip>
<span> {{ item.value }}</span>
</v-chip>
<!-- <span
v-if="index === 2"
class="text-grey text-caption align-self-center"
>
(+{{ selectedFruits.length - 2 }} others)
</span> -->
</template>
<template v-slot:prepend-item>
<v-list-item @click="toggle" class="text-body-2">
<span class="text-body-2"> ВСЕ СОТРУДНИКИ </span>
<template v-slot:prepend>
{{selectedStaff}}
<v-checkbox-btn
:color="onePlusStaff ? 'indigo-darken-4' : undefined"
:indeterminate="onePlusStaff && !allStaff"
:model-value="allStaff"
></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.department">
<template v-slot:activator="{ props }">
<v-list-item
v-bind="props"
@click.stop=""
density="compact"
class="text-body-2"
>
</v-list-item>
</template>
<v-list-item
v-for="(x, i) in item.raw.staff"
:key="i"
:value="x.fio"
@click.stop="selectFIO(x, item.raw.id)"
density="compact"
>
<span class="text-body-2"> {{ x.fio }} </span>
</v-list-item>
</v-list-group>
<!-- <v-list-item v-bind="props" :title="item.raw.department">
<template v-slot:prepend>
<v-checkbox-btn
:color="onePlusStaff ? 'indigo-darken-4' : undefined"
:indeterminate="onePlusStaff && !allStaff"
:model-value="allStaff"
></v-checkbox-btn>
</template>
</v-list-item> -->
</template>
</v-select>
</template>
<script>
import { ref, onMounted, computed } from "vue";
export default {
setup() {
const staff = ref([
{
department: "ОКТП",
id: 1,
staff: [{ fio: "ГИС", id: 1 }, { fio: "СВВ", id: 2 }, { fio: "ФА", id: 3 }, { fio: "АА", id: 4 }],
},
{ department: "ОВТП", id: 2, staff: [{ fio: "ЩВ", id: 1 }, { fio: "ДК", id: 2 }] },
]);
const selectedStaff = ref([]);
const allStaff = computed(
() => selectedStaff.value.length === staff.value.length
);
const onePlusStaff = computed(() => selectedStaff.value.length > 0);
function toggle() {
if (allStaff.value) {
selectedStaff.value = [];
} else {
selectedStaff.value = staff.value.slice();
}
}
function selectFIO(user, dep) {
let ob = staff.value.find(el => el.id == dep)
ob['chek'] = false
let indx = selectedStaff.value.findIndex((i) => i.id == dep)
if (indx ==-1) {
selectedStaff.value.push(ob)
}
console.log(ob, 'ki')
}
return {
staff,
selectedStaff,
allStaff,
onePlusStaff,
selectFIO,
toggle,
};
},
};
</script>
<style>
.max-height-select .v-field__input {
max-height: 60px; /* Установите желаемую максимальную высоту */
overflow-y: auto; /* Добавьте прокрутку, если список превышает максимальную высоту */
overflow-x: hidden;
margin: 5px;
}
</style>
@@ -3,34 +3,30 @@
v-model="selectedStaff"
:items="staff"
label="Выберите из списка или найдите по ФИО"
item-title="department"
item-value="department"
multiple
hide-details
variant="outlined"
density="compact"
class="max-height-select"
return-object
>
<template v-slot:selection="{ item, index }">
{{item}}
<v-chip v-if="(index < 1) && likesAllFruit">
<span>Выбраны все сотрудники</span>
<template v-slot:selection="{ item, index }">
<v-chip>
<span> {{ item.title }}</span>
</v-chip>
<!-- <span
v-if="index === 2"
class="text-grey text-caption align-self-center"
>
(+{{ selectedFruits.length - 2 }} others)
</span> -->
</template>
<template v-slot:prepend-item>
<v-list-item title="Выбрать всех сотрудников" @click="toggle">
<v-list-item @click="toggle" class="text-body-2">
<span class="text-body-2"> ВСЕ СОТРУДНИКИ </span>
<template v-slot:prepend>
<v-checkbox-btn
:color="likesSomeFruit ? 'indigo-darken-4' : undefined"
:indeterminate="likesSomeFruit && !likesAllFruit"
:model-value="likesAllFruit"
:color="onePlusStaff ? 'indigo-darken-4' : undefined"
:indeterminate="onePlusStaff && !allStaff"
:model-value="allStaff"
></v-checkbox-btn>
</template>
</v-list-item>
@@ -38,93 +34,151 @@
<v-divider class="mt-2"></v-divider>
</template>
<!-- <template v-slot:append-item>
<v-divider class="mb-2"></v-divider>
<v-list-item :subtitle="subtitle" :title="title" disabled>
<template v-slot:prepend>
<v-avatar color="primary" icon="mdi-food-apple"></v-avatar>
<template v-slot:item="{ props, item }">
<v-list-group v-bind="props" :value="item.raw.department">
<template v-slot:activator="{ props }">
<v-list-item
v-bind="props"
@click.stop=""
density="compact"
class="text-body-2"
>
</v-list-item>
</template>
</v-list-item>
</template> -->
<v-list-item
v-for="(x, i) in item.raw.staff"
:key="i"
:value="x.fio"
@click.stop="selectFIO(x, item.raw.id)"
density="compact"
>
<span class="text-body-2"> {{ x.fio }} </span>
</v-list-item>
</v-list-group>
</template>
</v-select>
</template>
<script>
import { ref, onMounted, computed } from "vue";
import { ref, computed } from "vue";
export default {
setup() {
const items = ref(['foo', 'bar', 'fizz', 'buzz', 'fizzbuzz', 'foobar'])
const value = ref(['foo', 'bar', 'fizz'])
const staff = ref([
{department: "ОКТП",
id: 1,
staff: [
{fio: 'ГИС'},
{fio: 'СВВ'},
{fio: 'ФА'},
{fio: 'АА'},
]
},
{department: "ОВТП",
id: 2,
staff: [
{fio: 'ЩВ'},
{fio: 'ДК'},
]
},
{
department: "ОКТП",
id: 1,
staff: [
{ fio: "ГИС", id: 1 },
{ fio: "СВВ", id: 2 },
{ fio: "ФА", id: 3 },
{ fio: "АА", id: 4 },
],
},
{
department: "ОВТП",
id: 2,
staff: [
{ fio: "ЩВ", id: 1 },
{ fio: "ДК", id: 2 },
],
},
]);
const selectedStaff = ref([]);
// const mydialog = computed({
// get: () => props.opendialog,
// set: (value) => emit('update:opendialog', value)
// })
const selectDepartnment = ref({});
const likesAllFruit = computed(() => selectedStaff.value.length === staff.value.length
const allStaff = computed(
() => {
let summSelectDep = 0
Object.keys(selectDepartnment.value).map((el) => { summSelectDep += selectDepartnment.value[el].length})
return summSelectDep === 6
}
);
const likesSomeFruit = computed(() => selectedStaff.value.length > 0);
const title = computed(() => {
if (likesAllFruit.value)
return "Holy smokes, someone call the fruit police!";
if (likesSomeFruit.value) return "Fruit Count";
return "How could you not like fruit?";
});
const subtitle = computed(() => {
if (likesAllFruit.value) return undefined;
if (likesSomeFruit.value) return selectedStaff.value.length;
return "Go ahead, make a selection above!";
});
const onePlusStaff = computed(() => selectedStaff.value.length > 0);
function toggle() {
staff.value.forEach((e) => {
if (!selectDepartnment.value[e.id]) {
selectDepartnment.value[e.id] = [];
}
});
if (likesAllFruit.value) {
selectedStaff.value = [];
console.log(allStaff.value, '1111111111111111111')
if (allStaff.value) {
selectDepartnment.value = [];
selectedStaff.value = []
} else {
selectedStaff.value = staff.value.slice();
Object.keys(staff.value).map((el) => {
staff.value[el].staff.map((fio) =>
// console.log(fio.fio)
selectDepartnment.value[staff.value[el].id].push(fio.fio)
);
selectedStaff.value.push(staff.value[el].department)
}
);
}
}
function selectFIO(user, dep) {
staff.value.forEach((e) => {
if (!selectDepartnment.value[e.id]) {
selectDepartnment.value[e.id] = [];
}
});
if (selectedStaff.value.includes(user.fio)) {
let index = selectedStaff.value.indexOf(user.fio);
selectedStaff.value.splice(index, 1);
}
let ob = staff.value.find((el) => el.id == dep);
if (selectDepartnment.value[dep].includes(user.fio)) {
let inddep = selectDepartnment.value[dep].indexOf(user.fio);
selectDepartnment.value[dep].splice(inddep, 1);
} else {
selectDepartnment.value[dep].push(user.fio);
}
if (selectDepartnment.value[dep].length == ob.staff.length) {
selectedStaff.value = selectedStaff.value.filter(
(el) => !~selectDepartnment.value[dep].indexOf(el)
);
selectedStaff.value.push(ob.department);
} else {
selectedStaff.value = selectedStaff.value.filter(
(el) => el != ob.department
);
selectDepartnment.value[dep].filter((el) => {
if (!selectedStaff.value.includes(el)) {
selectedStaff.value.push(el);
}
});
}
}
return {
staff,
selectedStaff,
likesAllFruit,
likesSomeFruit,
title,
subtitle,
allStaff,
onePlusStaff,
selectFIO,
selectDepartnment,
toggle,
items,
value
};
},
};
@@ -331,8 +331,10 @@ export default {
const screenimg = () => {
if (!accountStore.cod2user) {
clearAxios.get(`api/navigation/screensaver/`).then((data) => {
scrimg.value = data.data[0].img;
console.log(data, 'saver--')
// scrimg.value = data.data[0].img;
});
}
};
@@ -472,7 +474,7 @@ export default {
});
};
getSafetyChapter();
// getSafetyChapter();
return {
theme,
+14 -14
View File
@@ -1,17 +1,17 @@
// Utilities
import { defineStore } from 'pinia'
import { ref } from 'vue'
export const useWeekendsStore = defineStore('weekends', () => {
// const week = ref({ '2024': {'5': ["2024-05-08", "2024-05-11"], '6': ["2024-06-08", "2024-06-11"]} })
const week = ref({})
return { week }
},
import { axiosApiInstance } from "@/utils/axios-api";
import { defineStore } from "pinia";
import { ref } from "vue";
export const useWeekendsStore = defineStore("weekends", () => {
)
const week = ref({});
function getWeekend(year) {
axiosApiInstance
.get(`api/calendar_of_events/exclusion_dates/?year=${year}`, {})
.then((data) => {
week.value = data.data;
});
}
return { week, getWeekend };
});