fix(04): product search

This commit is contained in:
puriphatt 2024-10-17 13:31:36 +07:00
parent 93d7aa4eb7
commit 6ddf3a9030

View file

@ -195,6 +195,7 @@ const refImageUpload = ref<InstanceType<typeof ImageUploadDialog>>();
const inputSearch = ref(''); const inputSearch = ref('');
const inputSearchProductAndService = ref(''); const inputSearchProductAndService = ref('');
const inputSearchWorkProduct = ref('');
const currentStatusProduct = ref(false); const currentStatusProduct = ref(false);
const drawerInfo = ref(false); const drawerInfo = ref(false);
@ -508,8 +509,9 @@ const onCreateImageList = ref<{
}>({ selectedImage: '', list: [] }); }>({ selectedImage: '', list: [] });
async function searchProduct(isAdd: boolean = true) { async function searchProduct(isAdd: boolean = true) {
console.log('spd');
const res = await fetchListProduct({ const res = await fetchListProduct({
query: inputSearchProductAndService.value, query: inputSearchWorkProduct.value,
}); });
if (res) { if (res) {
@ -1287,7 +1289,6 @@ async function fetchStatus() {
async function alternativeFetch() { async function alternativeFetch() {
if (productAndServiceTab.value === 'product') { if (productAndServiceTab.value === 'product') {
await fetchListOfProduct(); await fetchListOfProduct();
flowStore.rotate(); flowStore.rotate();
} }
if (productAndServiceTab.value === 'service') { if (productAndServiceTab.value === 'service') {
@ -1532,9 +1533,6 @@ watch(
</script> </script>
<template> <template>
<!-- 1:{{ inputSearch }}
<br />
2:{{ inputSearchProductAndService }} -->
<ButtonAddComponent <ButtonAddComponent
hide-icon hide-icon
v-if="actionDisplay && !currentNoAction" v-if="actionDisplay && !currentNoAction"
@ -3248,7 +3246,7 @@ watch(
:close=" :close="
() => { () => {
dialogTotalProduct = false; dialogTotalProduct = false;
inputSearchProductAndService = ''; inputSearchWorkProduct = '';
} }
" "
> >
@ -3267,7 +3265,7 @@ watch(
<q-checkbox <q-checkbox
:label="$t('general.selectAll')" :label="$t('general.selectAll')"
:model-value=" :model-value="
!!inputSearchProductAndService !!inputSearchWorkProduct
? selectProduct.length === ? selectProduct.length ===
resultSearchProduct?.filter((i) => { resultSearchProduct?.filter((i) => {
if (i.status === 'INACTIVE') { if (i.status === 'INACTIVE') {
@ -3286,7 +3284,7 @@ watch(
@click=" @click="
() => { () => {
if ( if (
!!inputSearchProductAndService !!inputSearchWorkProduct
? selectProduct.length === ? selectProduct.length ===
resultSearchProduct?.filter((i) => { resultSearchProduct?.filter((i) => {
if (i.status === 'INACTIVE') { if (i.status === 'INACTIVE') {
@ -3304,7 +3302,7 @@ watch(
) { ) {
selectProduct = []; selectProduct = [];
} else { } else {
!!inputSearchProductAndService !!inputSearchWorkProduct
? resultSearchProduct && selectAllProduct(resultSearchProduct) ? resultSearchProduct && selectAllProduct(resultSearchProduct)
: productIsAdd && selectAllProduct(productIsAdd); : productIsAdd && selectAllProduct(productIsAdd);
} }
@ -3317,7 +3315,7 @@ watch(
dense dense
:label="$t('general.search')" :label="$t('general.search')"
:bg-color="$q.dark.isActive ? 'dark' : 'white'" :bg-color="$q.dark.isActive ? 'dark' : 'white'"
v-model="inputSearchProductAndService" v-model="inputSearchWorkProduct"
debounce="500" debounce="500"
@update:model-value="searchProduct()" @update:model-value="searchProduct()"
> >
@ -3343,7 +3341,7 @@ watch(
<div v-else class="row q-col-gutter-md full-width"> <div v-else class="row q-col-gutter-md full-width">
<div <div
class="col-md-3 col-sm-6 col-12" class="col-md-3 col-sm-6 col-12"
v-for="i in (!!inputSearchProductAndService v-for="i in (!!inputSearchWorkProduct
? resultSearchProduct ? resultSearchProduct
: productIsAdd : productIsAdd
)?.filter((i) => { )?.filter((i) => {