P-42 Добавление людей из отделов
This commit is contained in:
1 parent
177cab0479
commit
5a9fa50127
4 files changed
+117
-119
No files matched your search
@@ -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,
|
||||
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
@@ -3,20 +3,25 @@
|
||||
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">
|
||||
<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
|
||||
<!-- <span
|
||||
v-if="index === 2"
|
||||
class="text-grey text-caption align-self-center"
|
||||
>
|
||||
@@ -25,12 +30,15 @@
|
||||
</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>
|
||||
{{selectedStaff}}
|
||||
<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,16 +46,39 @@
|
||||
<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"
|
||||
>
|
||||
<!-- <span class="text-body-2">{{item.title}}</span> -->
|
||||
</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>
|
||||
<!-- <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>
|
||||
|
||||
@@ -56,75 +87,56 @@ import { ref, onMounted, 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 likesAllFruit = computed(() => selectedStaff.value.length === staff.value.length
|
||||
const allStaff = computed(
|
||||
() => selectedStaff.value.length === staff.value.length
|
||||
);
|
||||
|
||||
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() {
|
||||
|
||||
if (likesAllFruit.value) {
|
||||
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,
|
||||
likesAllFruit,
|
||||
likesSomeFruit,
|
||||
title,
|
||||
subtitle,
|
||||
allStaff,
|
||||
onePlusStaff,
|
||||
selectFIO,
|
||||
|
||||
toggle,
|
||||
|
||||
items,
|
||||
value
|
||||
|
||||
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
@@ -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 };
|
||||
});
|
||||
Reference in new issue
Block a user