feat: search on group

This commit is contained in:
oat_dev 2024-06-13 11:20:35 +07:00
parent d18d8712df
commit c50ca43437

View file

@ -78,9 +78,20 @@ const formData = ref<ProductCreate>({
const currentId = ref<string>(''); const currentId = ref<string>('');
const currentIdType = ref<string>(''); const currentIdType = ref<string>('');
const resultSearchGroup = ref<Product>(); const resultSearchGroup = ref<Product[]>();
const resultSearchType = ref<Product>(); const resultSearchType = ref<Product>();
async function searchGroup() {
const resultList = await fetchListProductService({
query: inputSearch.value,
});
if (resultList) {
resultSearchGroup.value = resultList;
}
console.log(resultSearchGroup.value);
}
async function fetchListType() { async function fetchListType() {
const res = await fetchListProductServiceType({ const res = await fetchListProductServiceType({
productGroupId: currentId.value, productGroupId: currentId.value,
@ -322,6 +333,13 @@ onMounted(async () => {
:bg-color="$q.dark.isActive ? 'dark' : 'white'" :bg-color="$q.dark.isActive ? 'dark' : 'white'"
v-model="inputSearch" v-model="inputSearch"
debounce="500" debounce="500"
@update:model-value="
productMode === 'group'
? searchGroup()
: productMode === 'type'
? console.log('type')
: ''
"
> >
<template v-slot:prepend> <template v-slot:prepend>
<q-icon name="mdi-magnify" /> <q-icon name="mdi-magnify" />
@ -368,7 +386,9 @@ onMounted(async () => {
:class="`${$q.screen.gt.sm ? 'col-3' : $q.screen.gt.xs ? 'col-6' : 'col-12'}`" :class="`${$q.screen.gt.sm ? 'col-3' : $q.screen.gt.xs ? 'col-6' : 'col-12'}`"
v-for="(v, i) in productMode === 'type' v-for="(v, i) in productMode === 'type'
? productType ? productType
: productGroup" : !!inputSearch
? resultSearchGroup
: productGroup"
:key="i" :key="i"
> >
<ProductCardComponent <ProductCardComponent