P-42 Добавление людей из отделов

This commit is contained in:
iriska-gri committed 2024-05-30 12:47:00 +03:00
1 parent 177cab0479
commit 5a9fa50127
4 files changed
+117 -119

No files matched your search

+1 -1
View File
@@ -17,7 +17,7 @@ class ExclusionDatesAPIView(APIView):
exclude = ExclusionDates.objects.filter(exclusiondate__year=year) exclude = ExclusionDates.objects.filter(exclusiondate__year=year)
months = {} months = {}
for i in range(1,12): 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}) return Response({year:months})
@@ -49,9 +49,8 @@
</v-col> </v-col>
<v-col></v-col> <v-col></v-col>
</v-row> </v-row>
<!-- <v-date-picker show-adjacent-months></v-date-picker> --> </v-card>
</v-card></v-col </v-col>
>
<v-col class="bg-green"> <v-col class="bg-green">
<v-btn @click="drawer_right = !drawer_right"> <v-btn @click="drawer_right = !drawer_right">
{{ drawer_right }} {{ drawer_right }}
@@ -76,42 +75,23 @@
</template> </template>
<script> <script>
import { axiosApiInstance } from "@/utils/axios-api"; import { ref, onMounted, watch } from "vue";
import { ref, onMounted } from "vue";
import { useWeekendsStore } from "@/store/WeekendsStore"; import { useWeekendsStore } from "@/store/WeekendsStore";
import EventCreate from "@/components/calendar_of_events/event-create.vue"; import EventCreate from "@/components/calendar_of_events/event-create.vue";
import CalendarMy from "@/components/calendar_of_events/calendar-my.vue"; import CalendarMy from "@/components/calendar_of_events/calendar-my.vue";
// const burl = baseURL.slice(0, -1);
export default { export default {
components: { EventCreate, CalendarMy }, components: { EventCreate, CalendarMy },
setup() { setup() {
const showDialog = ref(false); const showDialog = ref(false);
const week = useWeekendsStore().week; const week = useWeekendsStore();
const drawer_right = ref(false); const drawer_right = ref(false);
const cal = ref(null); const cal = ref(null);
const selectdate = ref(new Date()); const selectdate = ref(new Date());
const MyYear = ref(selectdate.value.getFullYear()); const MyYear = ref(selectdate.value.getFullYear());
const MyMonth = ref(selectdate.value.getMonth() + 1); 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) => { const getMonth = (month) => {
MyMonth.value = month + 1; MyMonth.value = month + 1;
}; };
@@ -131,9 +111,8 @@ export default {
n.classList.add("text-red"); n.classList.add("text-red");
}); });
} }
if (MyMonth.value in week.week[MyYear.value]) {
if (MyMonth.value in week[MyYear.value]) { if (week.week[MyYear.value][MyMonth.value].includes(datas)) {
if (week[MyYear.value][MyMonth.value].includes(datas)) {
e.querySelectorAll("span").forEach((n) => { e.querySelectorAll("span").forEach((n) => {
n.classList.add("text-red"); n.classList.add("text-red");
if (n.classList.contains("text-red") && weeks) { if (n.classList.contains("text-red") && weeks) {
@@ -145,18 +124,26 @@ export default {
}); });
}; };
const CheckingStore = () => {
if (MyYear.value in week) {
weekendsData();
} else {
getWeekend();
}
};
onMounted(() => { 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 { return {
drawer_right, drawer_right,
selectdate, selectdate,
@@ -167,7 +154,6 @@ export default {
week, week,
CheckingStore, CheckingStore,
showDialog, showDialog,
}; };
}, },
}; };
@@ -3,20 +3,25 @@
v-model="selectedStaff" v-model="selectedStaff"
:items="staff" :items="staff"
label="Выберите из списка или найдите по ФИО" label="Выберите из списка или найдите по ФИО"
item-title="department"
item-value="department"
multiple multiple
hide-details hide-details
variant="outlined" variant="outlined"
density="compact" density="compact"
class="max-height-select" class="max-height-select"
return-object
> >
<template v-slot:selection="{ item, index }"> <template v-slot:selection="{ item, index }">
{{item}} <!-- <v-chip v-if="(index < 1) && allStaff">
<v-chip v-if="(index < 1) && likesAllFruit">
<span>Выбраны все сотрудники</span> <span>Выбраны все сотрудники</span>
</v-chip> -->
<v-chip>
<span> {{ item.value }}</span>
</v-chip> </v-chip>
<!-- <span <!-- <span
v-if="index === 2" v-if="index === 2"
class="text-grey text-caption align-self-center" class="text-grey text-caption align-self-center"
> >
@@ -25,12 +30,15 @@
</template> </template>
<template v-slot:prepend-item> <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> <template v-slot:prepend>
{{selectedStaff}}
<v-checkbox-btn <v-checkbox-btn
:color="likesSomeFruit ? 'indigo-darken-4' : undefined" :color="onePlusStaff ? 'indigo-darken-4' : undefined"
:indeterminate="likesSomeFruit && !likesAllFruit" :indeterminate="onePlusStaff && !allStaff"
:model-value="likesAllFruit" :model-value="allStaff"
></v-checkbox-btn> ></v-checkbox-btn>
</template> </template>
</v-list-item> </v-list-item>
@@ -38,16 +46,39 @@
<v-divider class="mt-2"></v-divider> <v-divider class="mt-2"></v-divider>
</template> </template>
<template v-slot:item="{ props, item }">
<!-- <template v-slot:append-item> <v-list-group v-bind="props" :value="item.raw.department">
<v-divider class="mb-2"></v-divider> <template v-slot:activator="{ props }">
<v-list-item
<v-list-item :subtitle="subtitle" :title="title" disabled> v-bind="props"
<template v-slot:prepend> @click.stop=""
<v-avatar color="primary" icon="mdi-food-apple"></v-avatar> density="compact"
class="text-body-2"
>
<!-- <span class="text-body-2">{{item.title}}</span> -->
</v-list-item>
</template> </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>
<!-- <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> </v-select>
</template> </template>
@@ -56,75 +87,56 @@ import { ref, onMounted, computed } from "vue";
export default { export default {
setup() { setup() {
const items = ref(['foo', 'bar', 'fizz', 'buzz', 'fizzbuzz', 'foobar'])
const value = ref(['foo', 'bar', 'fizz'])
const staff = ref([ const staff = ref([
{department: "ОКТП", {
id: 1, department: "ОКТП",
staff: [ id: 1,
{fio: 'ГИС'}, staff: [{ fio: "ГИС", id: 1 }, { fio: "СВВ", id: 2 }, { fio: "ФА", id: 3 }, { fio: "АА", id: 4 }],
{fio: 'СВВ'}, },
{fio: 'ФА'}, { department: "ОВТП", id: 2, staff: [{ fio: "ЩВ", id: 1 }, { fio: "ДК", id: 2 }] },
{fio: 'АА'},
]
},
{department: "ОВТП",
id: 2,
staff: [
{fio: 'ЩВ'},
{fio: 'ДК'},
]
},
]); ]);
const selectedStaff = ref([]); const selectedStaff = ref([]);
// const mydialog = computed({
// get: () => props.opendialog,
// set: (value) => emit('update:opendialog', value)
// })
const allStaff = computed(
() => selectedStaff.value.length === staff.value.length
const likesAllFruit = computed(() => selectedStaff.value.length === staff.value.length
); );
const likesSomeFruit = computed(() => selectedStaff.value.length > 0); const onePlusStaff = 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!";
});
function toggle() { function toggle() {
if (allStaff.value) {
if (likesAllFruit.value) {
selectedStaff.value = []; selectedStaff.value = [];
} else { } else {
selectedStaff.value = staff.value.slice(); 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 { return {
staff, staff,
selectedStaff, selectedStaff,
likesAllFruit, allStaff,
likesSomeFruit, onePlusStaff,
title, selectFIO,
subtitle,
toggle, toggle,
items,
value
}; };
}, },
}; };
+14 -14
View File
@@ -1,17 +1,17 @@
// Utilities import { axiosApiInstance } from "@/utils/axios-api";
import { defineStore } from 'pinia' import { defineStore } from "pinia";
import { ref } from 'vue' 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 }
},
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 };
});