fix: show clear icon only when search is input

This commit is contained in:
puri-ph4tt 2023-12-06 16:41:02 +07:00
parent c726b9abb4
commit 2ca3355366
2 changed files with 31 additions and 6 deletions

View file

@ -96,7 +96,7 @@ function clearAdvSearchData() {
<div class="row items-center" style="width: 45px; height: 45px">
<q-btn
dense
color="teal"
color="teal-5"
icon="mdi-plus"
v-if="index === advSearchDataRow.length - 1"
@click="addAdvSearchData"
@ -135,6 +135,7 @@ function clearAdvSearchData() {
@keydown.enter.prevent="searchSubmit()"
><template v-slot:append>
<q-icon
v-if="item.value"
name="close"
@click="() => (item.value = '')"
class="cursor-pointer"
@ -172,24 +173,34 @@ function clearAdvSearchData() {
outlined
dense
v-model="advSearchDataField.keyword"
placeholder="คำสำคัญ"
use-input
use-chips
multiple
hide-dropdown-icon
input-debounce="0"
new-value-mode="add"
/>
new-value-mode="add-unique"
><template v-slot:prepend
><span class="text-subtitle2">คำสำค:</span></template
></q-select
>
</div>
<div class="col-12 col-md-grow">
<q-input
id="advSearchDes"
dense
outlined
placeholder="รายละเอียด"
@keydown.enter.prevent="searchSubmit()"
v-model="advSearchDataField.description"
/>
><template v-slot:prepend
><span class="text-subtitle2">รายละเอยด:</span></template
><template v-slot:append>
<q-icon
v-if="advSearchDataField.description"
name="close"
@click="() => (advSearchDataField.description = '')"
class="cursor-pointer"
/> </template
></q-input>
</div>
</div>
</div>

View file

@ -8,8 +8,10 @@ import { useSearchDataStore } from '@/stores/searched-data'
import { useLoader } from '@/stores/loader'
import AdvancedSearch from '@/modules/01_user/components/AdvancedSearch.vue'
import { useFileInfoStore } from '@/stores/file-info-data'
const loaderStore = useLoader()
const { isFilePreview } = storeToRefs(useFileInfoStore())
const {
isSearch,
isAdvSearchCall,
@ -37,6 +39,7 @@ const props = defineProps<{
}>()
async function searchSubmit() {
isFilePreview.value = false
if (searchData.value.value.trim() !== '') {
submitSearchData.value = { AND: [], OR: [] }
if (props.mode === 'admin') {
@ -46,6 +49,14 @@ async function searchSubmit() {
value: searchData.value.value,
})
})
submitSearchData.value.OR.push({
field: 'fileName',
value: searchData.value.value,
})
submitSearchData.value.OR.push({
field: 'fileType',
value: searchData.value.value,
})
} else {
submitSearchData.value.OR.push({
field: searchData.value.field,
@ -85,6 +96,8 @@ async function searchSubmit() {
`${import.meta.env.VITE_API_ENDPOINT}/search`,
submitSearchData.value,
)
console.log(submitSearchData)
getFoundFile(res.data)
isSearch.value = true
} catch (error) {
@ -153,6 +166,7 @@ watch(
>
<template v-slot:append>
<q-icon
v-if="searchData.value"
name="close"
@click="() => ((searchData.value = ''), (isSearch = false))"
class="cursor-pointer"