feat [P-281]: переделана шапка, список отделов получен и отрисован в селекте
This commit is contained in:
1 parent
1051b69dd5
commit
02e7ed4ceb
5 files changed
+118
-29
No files matched your search
@@ -70,4 +70,5 @@ urlpatterns = [
|
||||
path('api/safety/', include('safety.urls')),
|
||||
path('api/tests/', include('tests.urls')),
|
||||
path('api/vote/', include('vote.urls')),
|
||||
path('api/userauth/', include('userauth.urls')),
|
||||
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||
@@ -135,3 +135,10 @@ class InfoUserCardSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = DictEmployee
|
||||
fields = ['department', 'fio', 'post', 'email', 'tel', 'room', 'login', 'familyname', 'name', 'parentname', 'id']
|
||||
|
||||
|
||||
|
||||
class DepartmentsSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = DictDepartment
|
||||
fields = '__all__'
|
||||
@@ -0,0 +1,6 @@
|
||||
from django.urls import path
|
||||
from .views import *
|
||||
|
||||
urlpatterns = [
|
||||
path('getdepartments', GetDepartment.as_view(), name= "GetDepartment")
|
||||
]
|
||||
@@ -1,3 +1,16 @@
|
||||
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>
|
||||
<v-row>
|
||||
<v-col cols="2">
|
||||
<v-select
|
||||
variant="outlined"
|
||||
density="compact"
|
||||
clearable
|
||||
hide-details
|
||||
bg-color="grey-lighten-4"
|
||||
label="Список отделов">
|
||||
</v-select>
|
||||
</v-col>
|
||||
<v-col class="d-flex justify-center">Title сюда</v-col>
|
||||
<v-col cols="3">
|
||||
<v-row>
|
||||
<v-col class="">
|
||||
<v-text-field
|
||||
append-inner-icon="mdi-magnify"
|
||||
label="Поиск сотрудников"
|
||||
variant="outlined"
|
||||
density="comfortable"
|
||||
bg-color="grey-lighten-4"
|
||||
hide-details clearable />
|
||||
<v-switch :model-value="true" color="teal" label="on" hide-details></v-switch>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</template>
|
||||
<v-card class="pa-2">
|
||||
<v-row align="center">
|
||||
<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-col cols="1">
|
||||
<v-switch
|
||||
:model-value="true"
|
||||
color="teal"
|
||||
label="on"
|
||||
hide-details>
|
||||
</v-switch>
|
||||
</v-col>
|
||||
<v-col class="ml-auto" cols="2">
|
||||
<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-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>
|
||||
|
||||
<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>
|
||||
Reference in new issue
Block a user