implemented simpleSearch for Employees/Index.
This commit is contained in:
64
src/components/Employees/EmployeesSimpleSearch.vue
Normal file
64
src/components/Employees/EmployeesSimpleSearch.vue
Normal file
@@ -0,0 +1,64 @@
|
||||
<template>
|
||||
<div class="input-group">
|
||||
<input
|
||||
type="text"
|
||||
class="form-control"
|
||||
v-model="searchQuery"
|
||||
placeholder="Suche nach..."
|
||||
@keyup="search"
|
||||
>
|
||||
<button aria-expanded="false" data-bs-toggle="dropdown" data-bs-auto-close="outside" type="button" class="btn btn-outline-secondary dropdown-toggle">
|
||||
Suche in...
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
<li v-for="(item, index) in unionColumns" :key="item">
|
||||
<label class="dropdown-item form-check">
|
||||
<input type="checkbox" :value="item" :id="'checkBox'+item" v-model="checkedColumns" class="form-check-input">
|
||||
{{item}}
|
||||
</label>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
{{ unionColumns }}
|
||||
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
|
||||
import { ref, computed} from 'vue';
|
||||
import { storeToRefs } from 'pinia'
|
||||
import { useEmployees } from '@/stores/employees';
|
||||
import { union } from 'lodash';
|
||||
|
||||
const searchQuery = ref('')
|
||||
const checkedColumns = ref([])
|
||||
const store = useEmployees()
|
||||
const { columns, simple_search } = storeToRefs(store)
|
||||
|
||||
const queryString = computed(() => {
|
||||
return searchQuery.value + '(' + checkedColumns.value.join(',') + ')'
|
||||
})
|
||||
|
||||
const unionColumns = computed(() => {
|
||||
return union(columns.value, checkedColumns.value)
|
||||
})
|
||||
|
||||
async function search() {
|
||||
simple_search.value = queryString.value
|
||||
await store.fetchFromApi()
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
.form-check {
|
||||
padding-left: 20px;
|
||||
}
|
||||
.form-check input {
|
||||
margin-left: -0.5rem;
|
||||
margin-right: 0.5rem;
|
||||
}
|
||||
|
||||
</style>
|
||||
Reference in New Issue
Block a user