feat [P-281]: переделана шапка, список отделов получен и отрисован в селекте

This commit is contained in:
lexxik753 committed 2025-07-14 13:47:15 +03:00
1 parent 1051b69dd5
commit 02e7ed4ceb
5 files changed
+117 -28

No files matched your search

+1
View File
@@ -70,4 +70,5 @@ urlpatterns = [
path('api/safety/', include('safety.urls')), path('api/safety/', include('safety.urls')),
path('api/tests/', include('tests.urls')), path('api/tests/', include('tests.urls')),
path('api/vote/', include('vote.urls')), path('api/vote/', include('vote.urls')),
path('api/userauth/', include('userauth.urls')),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
+7
View File
@@ -135,3 +135,10 @@ class InfoUserCardSerializer(serializers.ModelSerializer):
class Meta: class Meta:
model = DictEmployee model = DictEmployee
fields = ['department', 'fio', 'post', 'email', 'tel', 'room', 'login', 'familyname', 'name', 'parentname', 'id'] fields = ['department', 'fio', 'post', 'email', 'tel', 'room', 'login', 'familyname', 'name', 'parentname', 'id']
class DepartmentsSerializer(serializers.ModelSerializer):
class Meta:
model = DictDepartment
fields = '__all__'
+6
View File
@@ -0,0 +1,6 @@
from django.urls import path
from .views import *
urlpatterns = [
path('getdepartments', GetDepartment.as_view(), name= "GetDepartment")
]
+14 -1
View File
@@ -1,3 +1,16 @@
from django.shortcuts import render from django.shortcuts import render
from .models import DictDepartment
from .serializers import DepartmentsSerializer
from rest_framework.permissions import AllowAny, IsAuthenticated
from rest_framework.views import APIView
from rest_framework.response import Response
# Create your views here. class GetDepartment(APIView):
permission_classes = (AllowAny,)
"""
Получаем отделы
"""
def get(self,request):
department = DictDepartment.objects.all()
return Response(DepartmentsSerializer(department, many=True).data)
@@ -1,29 +1,91 @@
<template> <template>
<v-row> <v-card class="pa-2">
<v-col cols="2"> <v-row align="center">
<v-select <v-col cols="6">
variant="outlined" <v-select
density="compact" return-object
clearable item-title="name"
hide-details :items="department"
bg-color="grey-lighten-4" v-model="selectedDep"
label="Список отделов"> variant="outlined"
</v-select> density="compact"
</v-col> hide-details bg-color="grey-lighten-5"
<v-col class="d-flex justify-center">Title сюда</v-col> label="Список отделов">
<v-col cols="3"> </v-select>
<v-row> </v-col>
<v-col class=""> <v-col cols="1">
<v-text-field <v-switch
append-inner-icon="mdi-magnify" :model-value="true"
label="Поиск сотрудников" color="teal"
variant="outlined" label="on"
density="comfortable" hide-details>
bg-color="grey-lighten-4" </v-switch>
hide-details clearable /> </v-col>
<v-switch :model-value="true" color="teal" label="on" hide-details></v-switch> <v-col class="ml-auto" cols="2">
</v-col> <v-text-field
</v-row> append-inner-icon="mdi-magnify"
</v-col> label="Поиск сотрудников"
</v-row> variant="outlined"
density="compact"
bg-color="grey-lighten-5"
hide-details clearable />
</v-col>
</v-row>
<!-- <v-row>
<v-col cols="6">
<v-select
return-object
item-title="name"
:items="department"
v-model="selectedDep"
variant="outlined"
density="compact"
hide-details
bg-color="grey-lighten-5"
label="Список отделов">
</v-select>
</v-col>
<v-switch :model-value="true" color="teal" label="on" hide-details></v-switch>
<v-col cols="auto">
<v-row>
<v-col>
<v-text-field
append-inner-icon="mdi-magnify"
label="Поиск сотрудников"
variant="outlined"
density="compact"
bg-color="grey-lighten-5"
hide-details clearable />
</v-col>
</v-row>
</v-col>
</v-row> -->
</v-card>
</template> </template>
<script setup>
import { axiosApiInstance } from '@/utils/axios-api'
import { ref, onMounted } from 'vue'
const department = ref([])
async function getDepartment() {
try {
const response = await axiosApiInstance.get('api/userauth/getdepartments')
console.log(response)
department.value = response.data
} catch (error) {
console.error('Ошибка запроса получения отделов:', error);
throw error;
}
}
const selectedDep = ref(null)
onMounted(async () => {
await getDepartment();
selectedDep.value = department.value[0]
})
</script>