Files
PORTAL_COD2/src/front/src/components/dialog-search.vue
T
2023-11-08 09:47:36 +03:00

178 lines
3.5 KiB
Vue

<template>
<v-card
class="bg-white pa-3 px-0"
width="550"
height="600"
>
<v-card
class="mx-auto overflow-auto mx-0 px-3"
width="550"
height="600"
flat
>
<v-card-title class="fixed-bar bg-white">
<v-row class="bggrad">
<v-col class="text-center text-black_and_white">
{{t_dailyRound.position}}
</v-col>
</v-row>
<v-row>
<v-col class="pa-0 mb-3">
<v-textarea
v-model="searchname"
clearable
prepend-inner-icon="mdi-magnify"
hide-details
class="mx-0"
label="Поиск"
rows="1"
no-resize
/>
</v-col>
</v-row>
</v-card-title>
<div
v-for="(x, key) in result"
:key="key"
class="px-3" >
<v-list class="py-0">
<v-list-subheader>{{key}} </v-list-subheader>
</v-list>
<v-card
v-for="item in x"
:key="item"
class="bg-transparent"
density="compact"
:prepend-avatar="checkremote(`${spravURL}${item.login}.jpg`)"
:title="item.fio"
:subtitle="item.post"
variant="text"
@click="getcard(item.login)"
>
</v-card>
</div>
</v-card>
<v-divider/>
<v-card-actions class="align-self-end pb-0">
<v-btn
color="more_details_btn"
variant="text"
@click="onSubmit"
>
Закрыть
</v-btn>
</v-card-actions>
</v-card>
</template>
<script>
import { ref,watch, onMounted, computed } from 'vue'
import {checkremote} from '@/utils/universal_functions'
import { spravURL } from '@/utils/axios-api'
import { axiosApiInstance } from '@/utils/axios-api'
export default {
props: {
idpos: {
type: Number,
default: ''
}
},
setup(props, {emit}){
const t_dailyRound = ref({})
const result = ref({})
const searchname = ref('')
const onSubmit = () => {
emit('searchClose')
}
onMounted(() => {
detailRound(props.idpos)
})
const detailRound = (pos) => {
axiosApiInstance.get(`api/general_vacation/dailyload/?id=${pos}`).then(data => {
t_dailyRound.value = data.data
result.value=JSON.parse(JSON.stringify(data.data.daily))
})
}
const filterItems = (query) => {
console.log(props.idpos, '33333333333333333333333333333');
result.value={}
Object.keys(t_dailyRound.value['daily']).map(el1 => {
let myarr = t_dailyRound.value['daily'][el1].filter((el) =>el.fio.toLowerCase().includes(query.toLowerCase()))
if(myarr.length>0)
{
result.value[el1] = myarr
}
}
)
}
watch(()=> searchname.value,(newValue,oldValue)=>{
if(newValue){
filterItems(newValue)
}
else {
result.value = JSON.parse(JSON.stringify(t_dailyRound.value['daily']))
}
}, {deep:true})
return {
onSubmit,
checkremote,
searchname,
spravURL,
t_dailyRound,
result
}
}
}
</script>
<style>
</style>