feat [P-282]: сделаны и отображены карточки, реализован функционал поиска, внесены правки в бэк - в части запроса данных
This commit is contained in:
1 parent
c4feb6aee7
commit
838f43a710
4 files changed
+41
-18
No files matched your search
@@ -132,9 +132,11 @@ class InfoUserCardSerializer(serializers.ModelSerializer):
|
|||||||
""" Собирает необходимую информацию о пользователе, содержит необходимые
|
""" Собирает необходимую информацию о пользователе, содержит необходимые
|
||||||
поля для отрисовки карточки информации о пользователе при клике на фамилию
|
поля для отрисовки карточки информации о пользователе при клике на фамилию
|
||||||
Необходим для компонента infoUserCard"""
|
Необходим для компонента infoUserCard"""
|
||||||
|
position = serializers.IntegerField(source='id_dict_position.order_position')
|
||||||
|
department = serializers.CharField(source='id_dict_department.name')
|
||||||
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', 'deleted','position']
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
<template>
|
<template>
|
||||||
<v-container fluid>
|
<div v-for="(sort, depart) in grouped" class="mt-2">
|
||||||
|
<h2 class="py-2">{{ depart }}</h2>
|
||||||
<v-row>
|
<v-row>
|
||||||
<v-col v-for="person in selectedDep.persons" cols="4">
|
<v-col v-for="person in sort.sort((a,b)=>a.position-b.position)" cols="4" :key="person.id" class="cursor-pointer">
|
||||||
<v-card>
|
<v-card>
|
||||||
<v-avatar :image="checkremote(`${spravURL}.jpg`)" rounded="0" size="130"></v-avatar>
|
<v-avatar :image="checkremote(`${spravURL}.jpg`)" rounded="0" size="100"></v-avatar>
|
||||||
<v-card-item>
|
<v-card-item>
|
||||||
<v-card-title>{{ person.familyname }} {{ person.name }} {{ person.parentname }}</v-card-title>
|
<v-card-title>{{ person.familyname }} {{ person.name }} {{ person.parentname }}</v-card-title>
|
||||||
<v-card-title class="text-subtitle-1">{{ person.post }}</v-card-title>
|
<v-card-title class="text-subtitle-1">{{ person.post }}</v-card-title>
|
||||||
@@ -12,18 +13,31 @@
|
|||||||
</v-card>
|
</v-card>
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
</v-container>
|
</div>
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { checkremote } from "@/utils/universal_functions";
|
import { checkremote } from "@/utils/universal_functions";
|
||||||
import { spravURL } from "@/utils/axios-api";
|
import { spravURL } from "@/utils/axios-api";
|
||||||
|
import { computed } from 'vue'
|
||||||
|
|
||||||
defineProps({
|
const props = defineProps({
|
||||||
selectedDep: {
|
selectedDep: {
|
||||||
name: String,
|
name: String,
|
||||||
}
|
},
|
||||||
|
isWork: Number,
|
||||||
|
search: String,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const filteredPerson = computed(() => {
|
||||||
|
return props.selectedDep.persons.filter(item => item.deleted == props.isWork && item.fio.toLowerCase().includes(props.search.toLowerCase()))
|
||||||
|
})
|
||||||
|
|
||||||
|
const grouped = computed(() => {
|
||||||
|
let group = []
|
||||||
|
group = Object.groupBy(filteredPerson.value, (item) => item.department)
|
||||||
|
return group
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
<v-select
|
<v-select
|
||||||
return-object
|
return-object
|
||||||
item-title="name"
|
item-title="name"
|
||||||
:items="department"
|
:items="props.department"
|
||||||
v-model="selectedDep"
|
v-model="selectedDep"
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
density="compact"
|
density="compact"
|
||||||
@@ -15,7 +15,9 @@
|
|||||||
</v-col>
|
</v-col>
|
||||||
<v-col cols="2">
|
<v-col cols="2">
|
||||||
<v-switch
|
<v-switch
|
||||||
:model-value="isWork"
|
v-model="isWork"
|
||||||
|
:false-value="0"
|
||||||
|
:true-value="1"
|
||||||
color="teal"
|
color="teal"
|
||||||
label="Уволенные"
|
label="Уволенные"
|
||||||
hide-details>
|
hide-details>
|
||||||
@@ -23,24 +25,31 @@
|
|||||||
</v-col>
|
</v-col>
|
||||||
<v-col class="ml-auto" cols="2">
|
<v-col class="ml-auto" cols="2">
|
||||||
<v-text-field
|
<v-text-field
|
||||||
|
v-model="search"
|
||||||
append-inner-icon="mdi-magnify"
|
append-inner-icon="mdi-magnify"
|
||||||
label="Поиск сотрудников"
|
label="Поиск сотрудников"
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
density="compact"
|
density="compact"
|
||||||
bg-color="grey-lighten-5"
|
bg-color="grey-lighten-5"
|
||||||
hide-details
|
hide-details
|
||||||
clearable />
|
clearable
|
||||||
|
@click:clear="handleClear"
|
||||||
|
/>
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
</v-card>
|
</v-card>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
defineProps({
|
const props = defineProps({
|
||||||
department: Array,
|
department: Array,
|
||||||
})
|
})
|
||||||
|
|
||||||
const selectedDep = defineModel('selectedDep')
|
const selectedDep = defineModel('selectedDep')
|
||||||
const isWork = defineModel('isWork')
|
const isWork = defineModel('isWork')
|
||||||
|
const search = defineModel('search')
|
||||||
|
|
||||||
|
const handleClear = () => {
|
||||||
|
search.value = '';
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
@@ -1,8 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<v-container fluid>
|
<v-container fluid>
|
||||||
<HeaderEmployeeDirectory :department="department" v-model:selectedDep="selectedDep" v-model:isWork="isWork"/>
|
<HeaderEmployeeDirectory :department="department" v-model:selectedDep="selectedDep" v-model:isWork="isWork" v-model:search="search"/>
|
||||||
{{ selectedDep }}
|
<CardEmployeeDirection :selectedDep="selectedDep" :isWork="isWork" :search="search"/>
|
||||||
<CardEmployeeDirection :selectedDep="selectedDep"/>
|
|
||||||
</v-container>
|
</v-container>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -18,7 +17,8 @@ const selectedDep = ref({
|
|||||||
id: 0,
|
id: 0,
|
||||||
persons: []
|
persons: []
|
||||||
})
|
})
|
||||||
const isWork = ref(false)
|
const isWork = ref(0)
|
||||||
|
const search = ref('')
|
||||||
|
|
||||||
async function getDepartment() {
|
async function getDepartment() {
|
||||||
try {
|
try {
|
||||||
@@ -37,8 +37,6 @@ async function getDepartment() {
|
|||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await getDepartment();
|
await getDepartment();
|
||||||
selectedDep.value = department.value[0]
|
selectedDep.value = department.value[0]
|
||||||
selectedDep.value = department.value[0]
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
Reference in new issue
Block a user