P_55 Настройки
This commit is contained in:
1 parent
133696de50
commit
ec35771276
11 files changed
+259
-184
No files matched your search
@@ -45,7 +45,22 @@
|
||||
</v-locale-provider>
|
||||
</v-col>
|
||||
<v-col>
|
||||
<calendar-my />
|
||||
<calendar-my
|
||||
:calendars="
|
||||
calendarForMy.filter(
|
||||
(e) => e.author == accountStore.user.is_idEmployee
|
||||
)
|
||||
"
|
||||
title="Мои календари"
|
||||
/>
|
||||
<calendar-my
|
||||
:calendars="
|
||||
calendarForMy.filter(
|
||||
(e) => e.author != accountStore.user.is_idEmployee
|
||||
)
|
||||
"
|
||||
title="Подписки"
|
||||
/>
|
||||
</v-col>
|
||||
<v-col></v-col>
|
||||
</v-row>
|
||||
@@ -80,10 +95,14 @@ 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";
|
||||
import { axiosApiInstance } from "@/utils/axios-api";
|
||||
import { useAccountStore } from "@/store/AccountStore";
|
||||
|
||||
|
||||
export default {
|
||||
components: { EventCreate, CalendarMy },
|
||||
|
||||
setup() {
|
||||
const accountStore = useAccountStore();
|
||||
const showDialog = ref(false);
|
||||
const week = useWeekendsStore();
|
||||
const drawer_right = ref(false);
|
||||
@@ -91,6 +110,7 @@ export default {
|
||||
const selectdate = ref(new Date());
|
||||
const MyYear = ref(selectdate.value.getFullYear());
|
||||
const MyMonth = ref(selectdate.value.getMonth() + 1);
|
||||
const calendarForMy = ref([]);
|
||||
|
||||
const getMonth = (month) => {
|
||||
MyMonth.value = month + 1;
|
||||
@@ -99,6 +119,17 @@ export default {
|
||||
MyYear.value = year;
|
||||
};
|
||||
|
||||
console.log(accountStore, 'store')
|
||||
|
||||
axiosApiInstance
|
||||
.get("api/calendar_of_events/get_calendars/")
|
||||
.then((res) => {
|
||||
res.data.forEach(e => e.visible = accountStore.calendar.includes(e.id)?false: true)
|
||||
calendarForMy.value = res.data;
|
||||
|
||||
console.log(calendarForMy.value, 'calendarForMy.valuecalendarForMy.value');
|
||||
});
|
||||
|
||||
const weekendsData = () => {
|
||||
cal.value.$el
|
||||
.querySelectorAll(".v-date-picker-month__day")
|
||||
@@ -145,10 +176,6 @@ export default {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return {
|
||||
drawer_right,
|
||||
selectdate,
|
||||
@@ -159,6 +186,8 @@ export default {
|
||||
week,
|
||||
CheckingStore,
|
||||
showDialog,
|
||||
calendarForMy,
|
||||
accountStore,
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
<span class="text-body-2"> ВСЕ СОТРУДНИКИ </span>
|
||||
|
||||
<template v-slot:prepend>
|
||||
{{selectedStaff}}
|
||||
|
||||
<v-checkbox-btn
|
||||
:color="onePlusStaff ? 'indigo-darken-4' : undefined"
|
||||
:indeterminate="onePlusStaff && !allStaff"
|
||||
|
||||
@@ -43,11 +43,7 @@
|
||||
</template>
|
||||
|
||||
<template v-slot:item="{ props, item }">
|
||||
<v-list-group
|
||||
v-bind="props"
|
||||
:value="item.raw.title"
|
||||
v-if="item.raw.id != 0"
|
||||
>
|
||||
<v-list-group v-bind="props" :value="item.raw.title">
|
||||
<template v-slot:activator="{ props }">
|
||||
<v-list-item
|
||||
v-bind="props"
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
<template>
|
||||
<v-dialog v-model="dialog_create_calendar" min-width="636" max-width="800">
|
||||
<v-card min-height="436" class="pa-3">
|
||||
{{calendar}}
|
||||
<v-card-title class="pr-0 pl-2 d-flex justify-space-between">
|
||||
Новый календарь
|
||||
|
||||
<v-icon
|
||||
icon="mdi-close cursor-pointer"
|
||||
size="small"
|
||||
@@ -123,6 +125,11 @@ export default {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
|
||||
calendar: {
|
||||
type: Object,
|
||||
default: {},
|
||||
},
|
||||
},
|
||||
|
||||
setup(props, { emit }) {
|
||||
@@ -131,28 +138,28 @@ export default {
|
||||
set: (value) => emit("update:opendialog", value),
|
||||
});
|
||||
|
||||
const calendar = ref([
|
||||
{
|
||||
cl_color: "#F44336",
|
||||
cl_descr: "Малюсенький календарь",
|
||||
cl_name: "Мой первый календарь",
|
||||
editor: true,
|
||||
participant: [
|
||||
{ editor: 0, user: 107 },
|
||||
{ editor: 1, user: 125 },
|
||||
],
|
||||
events: {
|
||||
date_end: "2024-06-29T12:20:28+03:00",
|
||||
date_start: "2024-05-29T12:20:24+03:00",
|
||||
description: "Описание такое описание",
|
||||
event: 1,
|
||||
id: 1,
|
||||
name: "Первое событие в календаре",
|
||||
period: null,
|
||||
},
|
||||
id: 1,
|
||||
},
|
||||
]);
|
||||
// const calendar = ref([
|
||||
// {
|
||||
// cl_color: "#F44336",
|
||||
// cl_descr: "Малюсенький календарь",
|
||||
// cl_name: "Мой первый календарь",
|
||||
// editor: true,
|
||||
// participant: [
|
||||
// { editor: 0, user: 107 },
|
||||
// { editor: 1, user: 125 },
|
||||
// ],
|
||||
// events: {
|
||||
// date_end: "2024-06-29T12:20:28+03:00",
|
||||
// date_start: "2024-05-29T12:20:24+03:00",
|
||||
// description: "Описание такое описание",
|
||||
// event: 1,
|
||||
// id: 1,
|
||||
// name: "Первое событие в календаре",
|
||||
// period: null,
|
||||
// },
|
||||
// id: 1,
|
||||
// },
|
||||
// ]);
|
||||
|
||||
// const getMyCalendar = () => {
|
||||
// axiosApiInstance
|
||||
@@ -211,7 +218,7 @@ export default {
|
||||
// Почему тут этот цвет? ЧЕМ ОН ОТЛИЧАЕТСЯ ОТ COLOR[0]?
|
||||
cl_color: "#F44336",
|
||||
cl_descr: "",
|
||||
patrcipant_calendar: [],
|
||||
participant_calendar: [],
|
||||
});
|
||||
|
||||
return {
|
||||
@@ -219,7 +226,7 @@ export default {
|
||||
newcalendar,
|
||||
color,
|
||||
colorPik,
|
||||
calendar,
|
||||
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
@@ -5,114 +5,106 @@
|
||||
<v-list-item v-bind="props">
|
||||
<template v-slot:prepend>
|
||||
<div @click.stop="">
|
||||
<span> Мои календари </span>
|
||||
<span> {{ title }} </span>
|
||||
</div>
|
||||
|
||||
<v-btn
|
||||
v-if="title == 'Мои календари'"
|
||||
size="x-small"
|
||||
icon="mdi-plus"
|
||||
variant="text"
|
||||
@click.stop="showDialog = true"
|
||||
@click.stop="editCreatedCalendar()"
|
||||
></v-btn>
|
||||
</template>
|
||||
</v-list-item>
|
||||
</template>
|
||||
|
||||
<v-list-item
|
||||
v-for="(x, i) in calendar"
|
||||
:key="i"
|
||||
v-for="(x, i) in calendars"
|
||||
:title="x.cl_name"
|
||||
:value="x.cl_name"
|
||||
@click.stop=""
|
||||
>
|
||||
<template v-slot:append>
|
||||
|
||||
<v-btn
|
||||
size="x-small"
|
||||
icon="mdi-pen"
|
||||
variant="text"
|
||||
@click.stop="editCreatedCalendar(x.id)"
|
||||
></v-btn>
|
||||
</template>
|
||||
<!-- <template v-slot:prepend="{ isActive }">
|
||||
<template v-slot:prepend>
|
||||
<v-checkbox-btn
|
||||
:color="x.color"
|
||||
:model-value="isActive"
|
||||
v-model="x.chek"
|
||||
/>
|
||||
</template> -->
|
||||
v-model="x.visible"
|
||||
@update:modelValue="chekUpdate(x)"
|
||||
></v-checkbox-btn>
|
||||
</template>
|
||||
|
||||
<template v-slot:append>
|
||||
<v-btn
|
||||
size="x-small"
|
||||
icon="mdi-pen"
|
||||
variant="text"
|
||||
@click.stop="editCreatedCalendar(x)"
|
||||
></v-btn>
|
||||
</template>
|
||||
</v-list-item>
|
||||
</v-list-group>
|
||||
<calendar-create
|
||||
@update:opendialog="showDialog = $event"
|
||||
:opendialog="showDialog"
|
||||
:calendar="calendar"
|
||||
/>
|
||||
</v-list>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { ref, onMounted, computed } from "vue";
|
||||
import { ref } from "vue";
|
||||
import calendarCreate from "@/components/calendar_of_events/calendar-create.vue";
|
||||
|
||||
import { useAccountStore } from "@/store/AccountStore";
|
||||
export default {
|
||||
components: { calendarCreate },
|
||||
|
||||
props: {
|
||||
calendars: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
|
||||
title: {
|
||||
typr: String,
|
||||
default: "",
|
||||
},
|
||||
},
|
||||
|
||||
setup(props, { emit }) {
|
||||
const showDialog = ref(false);
|
||||
const selected = ref(true);
|
||||
const subscribe = [
|
||||
{ name: "Дни рождения", chek: true, id: 0, color: "yellow" },
|
||||
];
|
||||
const accountStore = useAccountStore();
|
||||
const calendar = ref({});
|
||||
|
||||
const editCreatedCalendar = (id) => {
|
||||
console.log(id, '-----------------')
|
||||
showDialog.value = true
|
||||
}
|
||||
|
||||
const calendar = ref([
|
||||
{
|
||||
cl_color: "#F44336",
|
||||
cl_descr: "Малюсенький календарь",
|
||||
cl_name: "Мой первый календарь",
|
||||
editor: true,
|
||||
participant : [
|
||||
{editor:0, user: 107},
|
||||
{editor: 1, user: 125}
|
||||
],
|
||||
events:{
|
||||
date_end: "2024-06-29T12:20:28+03:00",
|
||||
date_start: "2024-05-29T12:20:24+03:00",
|
||||
description: "Описание такое описание",
|
||||
event: 1,
|
||||
id: 1,
|
||||
name: "Первое событие в календаре",
|
||||
period: null
|
||||
},
|
||||
id: 1
|
||||
}]
|
||||
)
|
||||
const editCreatedCalendar = (cal) => {
|
||||
calendar.value = cal;
|
||||
showDialog.value = true;
|
||||
};
|
||||
|
||||
const mycalendar = ref([
|
||||
{ name: "Портал ЦОД2", chek: false, id: 1, color: "red" },
|
||||
{ name: "Личный календарь", chek: true, id: 2, color: "green" },
|
||||
]);
|
||||
const chekUpdate = (cal) => {
|
||||
// console.log(cal.visible);
|
||||
let setcal = new Set(accountStore.calendar)
|
||||
if (cal.visible == false) {
|
||||
setcal.add(cal.id);
|
||||
} else {
|
||||
setcal.delete(cal.id);
|
||||
}
|
||||
accountStore.calendar= Array.from(setcal)
|
||||
};
|
||||
|
||||
return {
|
||||
mycalendar,
|
||||
subscribe,
|
||||
selected,
|
||||
showDialog,
|
||||
calendar,
|
||||
editCreatedCalendar
|
||||
editCreatedCalendar,
|
||||
chekUpdate,
|
||||
};
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
.calen .v-list-group--prepend {
|
||||
--parent-padding: 0px;
|
||||
font-size: 14px;
|
||||
--parent-padding: 0px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.calen .v-list-item-title {
|
||||
|
||||
@@ -1,54 +1,108 @@
|
||||
// Utilities
|
||||
import { defineStore } from 'pinia'
|
||||
import {ref, watch} from 'vue'
|
||||
import { clearAxios, spravURL } from '@/utils/axios-api'
|
||||
import VueJwtDecode from 'vue-jwt-decode'
|
||||
import {checkremote} from '@/utils/universal_functions'
|
||||
import {useAppStore} from '@/store/app.js'
|
||||
import { defineStore } from "pinia";
|
||||
import { ref, watch, computed } from "vue";
|
||||
import { clearAxios, spravURL } from "@/utils/axios-api";
|
||||
import VueJwtDecode from "vue-jwt-decode";
|
||||
import { checkremote } from "@/utils/universal_functions";
|
||||
import { useAppStore } from "@/store/app.js";
|
||||
|
||||
export const useAccountStore = defineStore("AccountStore", () => {
|
||||
const AppStore = useAppStore();
|
||||
const settingsStorage = computed({
|
||||
get() {
|
||||
return JSON.parse(localStorage.getItem(user.value.is_idEmployee));
|
||||
},
|
||||
});
|
||||
|
||||
const defaultSettings = {
|
||||
calendar: [],
|
||||
};
|
||||
|
||||
function get_setting(key) {
|
||||
return settingsStorage.value === null
|
||||
? defaultSettings[key]
|
||||
: settingsStorage.value[key];
|
||||
}
|
||||
const user = ref({});
|
||||
const cod2user = ref(false);
|
||||
const calendar = ref(get_setting("calendar")
|
||||
);
|
||||
console.log(calendar.value, 'calval');
|
||||
|
||||
const setUser = (value) => {
|
||||
value.photo = checkremote(`${spravURL}${value.login}.jpg`);
|
||||
user.value = value;
|
||||
};
|
||||
|
||||
//
|
||||
// геттер бывший
|
||||
// const getUser=computed(()=> uyser.value)
|
||||
|
||||
const logging = async (anon) => {
|
||||
AppStore.loading = true;
|
||||
const result = await clearAxios.post("api/accounts/token/", anon);
|
||||
// .then(result => {
|
||||
localStorage.setItem("access", result.data.access);
|
||||
localStorage.setItem("refresh", result.data.refresh);
|
||||
|
||||
let u = VueJwtDecode.decode(result.data.refresh);
|
||||
u.user.photo = checkremote(`${spravURL}${u.user.login}.jpg`);
|
||||
// `${spravURL}${u.user.login}.jpg`
|
||||
user.value = u.user;
|
||||
//
|
||||
if (settingsStorage.value === null) {
|
||||
settingsUp(defaultSettings)
|
||||
}
|
||||
else{
|
||||
console.log(settingsStorage.value, "ddddddds");
|
||||
for (let[key,val] of Object.entries(settingsStorage.value)){
|
||||
[key].value=val
|
||||
}
|
||||
}
|
||||
|
||||
// console.log(JSON.parse(localStorage[107]), 'localStoragelocalStoragelocalStorage'); Прочитать строку
|
||||
AppStore.loading = false;
|
||||
};
|
||||
|
||||
|
||||
|
||||
export const useAccountStore = defineStore('AccountStore', () => {
|
||||
const AppStore = useAppStore()
|
||||
|
||||
const user=ref({})
|
||||
const cod2user=ref(false)
|
||||
const setUser = (value)=> {
|
||||
value.photo = checkremote(`${spravURL}${value.login}.jpg`)
|
||||
user.value=value
|
||||
|
||||
}
|
||||
|
||||
const logout = () => {
|
||||
user.value = {};
|
||||
localStorage.removeItem("access");
|
||||
localStorage.removeItem("refresh");
|
||||
|
||||
};
|
||||
watch(
|
||||
user,
|
||||
(newValue, oldValue) => {
|
||||
cod2user.value =
|
||||
"login" in newValue && newValue.login.startsWith("9966-")
|
||||
? true
|
||||
: false;
|
||||
},
|
||||
{ deep: true }
|
||||
);
|
||||
|
||||
//
|
||||
// геттер бывший
|
||||
// const getUser=computed(()=> uyser.value)
|
||||
|
||||
const logging=async (anon)=>{
|
||||
|
||||
AppStore.loading = true
|
||||
const result = await clearAxios.post('api/accounts/token/', anon)
|
||||
// .then(result => {
|
||||
localStorage.setItem('access', result.data.access)
|
||||
localStorage.setItem('refresh', result.data.refresh)
|
||||
|
||||
let u = VueJwtDecode.decode(result.data.refresh)
|
||||
u.user.photo = checkremote( `${spravURL}${u.user.login}.jpg`)
|
||||
// `${spravURL}${u.user.login}.jpg`
|
||||
user.value = u.user
|
||||
AppStore.loading = false
|
||||
}
|
||||
const logout =()=>{
|
||||
user.value = {}
|
||||
localStorage.removeItem('access')
|
||||
localStorage.removeItem('refresh')
|
||||
function settingsUp(newSet) {
|
||||
|
||||
localStorage.setItem(
|
||||
user.value.is_idEmployee,
|
||||
JSON.stringify(newSet)
|
||||
|
||||
);
|
||||
|
||||
}
|
||||
watch(user, (newValue,oldValue)=>{
|
||||
cod2user.value = 'login' in newValue && newValue.login.startsWith('9966-')?true:false
|
||||
}, {deep:true})
|
||||
// console.log(newSet,'ddddddddddddddddddd');
|
||||
|
||||
|
||||
watch(() => calendar.value, (newValue) => {
|
||||
|
||||
let settings = JSON.parse(localStorage.getItem(user.value.is_idEmployee))
|
||||
settings.calendar = newValue
|
||||
|
||||
return {user, setUser,cod2user,logging, logout}
|
||||
})
|
||||
settingsUp(settings)
|
||||
|
||||
}, {deep: true})
|
||||
|
||||
return { user, setUser, cod2user, logging, logout, calendar };
|
||||
});
|
||||
Reference in new issue
Block a user