feat: เพิ่ม ค้นหา ของ productAndService
This commit is contained in:
parent
3a291cd1ad
commit
a2ca765eb0
1 changed files with 63 additions and 10 deletions
|
|
@ -105,7 +105,7 @@ import { storeToRefs } from 'pinia';
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
|
||||||
const inputSearch = ref<string>('');
|
const inputSearch = ref<string>('');
|
||||||
const searchTotalProduct = ref<string>('');
|
const inputSearchProductAndService = ref<string>('');
|
||||||
|
|
||||||
const currentStatusProduct = ref<boolean>(false);
|
const currentStatusProduct = ref<boolean>(false);
|
||||||
const drawerInfo = ref<boolean>(false);
|
const drawerInfo = ref<boolean>(false);
|
||||||
|
|
@ -241,13 +241,49 @@ async function searchGroup() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function searchProductAndService() {}
|
async function searchProductAndService() {
|
||||||
|
const res = await fetchListProductAndService({
|
||||||
|
query: inputSearchProductAndService.value,
|
||||||
|
});
|
||||||
|
|
||||||
async function searchProduct() {
|
if (res) {
|
||||||
const result = await fetchListProduct({ query: searchTotalProduct.value });
|
productAndService.value = res.result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (result) {
|
async function searchProduct(isAdd: boolean = true) {
|
||||||
resultSearchProduct.value = result.result;
|
const res = await fetchListProduct({
|
||||||
|
query: inputSearchProductAndService.value,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (res) {
|
||||||
|
if (isAdd) {
|
||||||
|
resultSearchProduct.value = res.result;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isAdd) {
|
||||||
|
product.value = res.result.map((v) => {
|
||||||
|
return {
|
||||||
|
...v,
|
||||||
|
type: 'product',
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function searchService() {
|
||||||
|
const res = await fetchListService({
|
||||||
|
query: inputSearchProductAndService.value,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (res) {
|
||||||
|
service.value = res.result.map((v) => {
|
||||||
|
return {
|
||||||
|
...v,
|
||||||
|
type: 'service',
|
||||||
|
};
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -806,6 +842,18 @@ async function fetchStatus() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function fetchSearch() {
|
||||||
|
if (productAndServiceTab.value === 'all') {
|
||||||
|
await searchProductAndService();
|
||||||
|
}
|
||||||
|
if (productAndServiceTab.value === 'product') {
|
||||||
|
await searchProduct(false);
|
||||||
|
}
|
||||||
|
if (productAndServiceTab.value === 'service') {
|
||||||
|
await searchService();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
calculateStats();
|
calculateStats();
|
||||||
await fetchListGroups();
|
await fetchListGroups();
|
||||||
|
|
@ -1286,8 +1334,13 @@ watch(currentStatus, async () => {
|
||||||
:label="$t('search')"
|
:label="$t('search')"
|
||||||
class="q-mr-md"
|
class="q-mr-md"
|
||||||
:bg-color="$q.dark.isActive ? 'dark' : 'white'"
|
:bg-color="$q.dark.isActive ? 'dark' : 'white'"
|
||||||
v-model="inputSearch"
|
v-model="inputSearchProductAndService"
|
||||||
debounce="500"
|
debounce="500"
|
||||||
|
@update:model-value="
|
||||||
|
async () => {
|
||||||
|
await fetchSearch();
|
||||||
|
}
|
||||||
|
"
|
||||||
>
|
>
|
||||||
<template v-slot:prepend>
|
<template v-slot:prepend>
|
||||||
<q-icon name="mdi-magnify" />
|
<q-icon name="mdi-magnify" />
|
||||||
|
|
@ -1515,7 +1568,7 @@ watch(currentStatus, async () => {
|
||||||
:close="
|
:close="
|
||||||
() => {
|
() => {
|
||||||
dialogTotalProduct = false;
|
dialogTotalProduct = false;
|
||||||
searchTotalProduct = '';
|
inputSearchProductAndService = '';
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
|
|
@ -1527,7 +1580,7 @@ watch(currentStatus, async () => {
|
||||||
dense
|
dense
|
||||||
:label="$t('search')"
|
:label="$t('search')"
|
||||||
:bg-color="$q.dark.isActive ? 'dark' : 'white'"
|
:bg-color="$q.dark.isActive ? 'dark' : 'white'"
|
||||||
v-model="searchTotalProduct"
|
v-model="inputSearchProductAndService"
|
||||||
debounce="500"
|
debounce="500"
|
||||||
@update:model-value="searchProduct()"
|
@update:model-value="searchProduct()"
|
||||||
>
|
>
|
||||||
|
|
@ -1548,7 +1601,7 @@ watch(currentStatus, async () => {
|
||||||
<div
|
<div
|
||||||
class="q-pa-xs"
|
class="q-pa-xs"
|
||||||
: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="i in (!!searchTotalProduct
|
v-for="i in (!!inputSearchProductAndService
|
||||||
? resultSearchProduct
|
? resultSearchProduct
|
||||||
: product
|
: product
|
||||||
)?.filter((i) => {
|
)?.filter((i) => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue