fix: แก้ขนาดการแสดงสินค้าและบริการ

This commit is contained in:
Net 2024-06-24 13:07:00 +07:00
parent d15c306605
commit 8185a47da6
2 changed files with 70 additions and 40 deletions

View file

@ -43,7 +43,7 @@ withDefaults(
no-padding no-padding
bordered bordered
:class="{ 'is-add-product': isAddProduct }" :class="{ 'is-add-product': isAddProduct }"
style="box-shadow: var(--shadow-3); width: 240px; height: 286px" style="box-shadow: var(--shadow-3); min-height: 300px"
@click="$emit('select', data)" @click="$emit('select', data)"
> >
<div class="q-pa-sm"> <div class="q-pa-sm">

View file

@ -132,6 +132,7 @@ const productMode = ref<'group' | 'type' | 'service' | 'product'>('group');
const productGroup = ref<ProductGroup[]>(); const productGroup = ref<ProductGroup[]>();
const productType = ref<ProductGroup[]>(); const productType = ref<ProductGroup[]>();
const product = ref<ProductList[]>(); const product = ref<ProductList[]>();
const resultSearchProduct = ref<ProductList[]>();
const service = ref<Service[]>(); const service = ref<Service[]>();
const productAndServiceTab = ref<string>('all'); const productAndServiceTab = ref<string>('all');
@ -231,6 +232,16 @@ async function searchGroup() {
} }
} }
async function searchProductAndService() {}
async function searchProduct() {
const result = await fetchListProduct({ query: searchTotalProduct.value });
if (result) {
resultSearchProduct.value = result.result;
}
}
async function fetchListType() { async function fetchListType() {
const res = await fetchListProductServiceType({ const res = await fetchListProductServiceType({
productGroupId: currentId.value, productGroupId: currentId.value,
@ -669,7 +680,10 @@ onMounted(async () => {
await fetchListGroups(); await fetchListGroups();
}); });
watch(productMode, () => (inputSearch.value = '')); watch(productMode, () => {
inputSearch.value = '';
currentStatus.value = 'All';
});
watch(currentStatus, async () => { watch(currentStatus, async () => {
if (productMode.value === 'group') { if (productMode.value === 'group') {
@ -1122,21 +1136,21 @@ watch(currentStatus, async () => {
<q-item <q-item
clickable clickable
class="flex items-center" class="flex items-center"
@click="console.log('test')" @click="currentStatus = 'All'"
> >
{{ $t('all') }} {{ $t('all') }}
</q-item> </q-item>
<q-item <q-item
clickable clickable
class="flex items-center" class="flex items-center"
@click="console.log('test')" @click="currentStatus = 'ACTIVE'"
> >
{{ $t('statusACTIVE') }} {{ $t('statusACTIVE') }}
</q-item> </q-item>
<q-item <q-item
clickable clickable
class="flex items-center" class="flex items-center"
@click="console.log('test')" @click="currentStatus = 'INACTIVE'"
> >
{{ $t('statusINACTIVE') }} {{ $t('statusINACTIVE') }}
</q-item> </q-item>
@ -1156,20 +1170,26 @@ watch(currentStatus, async () => {
<div <div
v-if="product && product.length > 0" v-if="product && product.length > 0"
class="flex q-pa-md" class="row q-col-gutter-md flex q-pa-md"
style="
min-height: 70vh;
background-color: var(--surface-2);
grid-template-columns: repeat(4, 1fr);
gap: var(--size-3);
"
> >
<div <div
v-if=" :class="`${$q.screen.gt.sm ? 'col-3' : $q.screen.gt.xs ? 'col-6' : 'col-12'}`"
productAndServiceTab === 'all' || v-for="i in productAndServiceTab === 'all' ||
productAndServiceTab === 'product' productAndServiceTab === 'product'
" ? product?.filter((i) => {
v-for="i in product" if (currentStatus === 'All') {
return true;
}
if (currentStatus === 'ACTIVE') {
return i.status === 'ACTIVE' || i.status === 'CREATED';
}
if (currentStatus === 'INACTIVE') {
return i.status === 'INACTIVE';
}
})
: []"
:key="i.id" :key="i.id"
> >
<TotalProductCardComponent <TotalProductCardComponent
@ -1181,7 +1201,7 @@ watch(currentStatus, async () => {
:id="i.id" :id="i.id"
typeProduct="product" typeProduct="product"
:title="i.name" :title="i.name"
:status="i.status === 'INACTIVE' ? true : false" :isDisabled="i.status === 'INACTIVE' ? true : false"
@menuViewDetail=" @menuViewDetail="
() => { () => {
currentIdProduct = i.id; currentIdProduct = i.id;
@ -1209,11 +1229,23 @@ watch(currentStatus, async () => {
</div> </div>
<div <div
v-if=" :class="`${$q.screen.gt.sm ? 'col-3' : $q.screen.gt.xs ? 'col-6' : 'col-12'}`"
productAndServiceTab === 'all' || v-for="i in productAndServiceTab === 'all' ||
productAndServiceTab === 'service' productAndServiceTab === 'service'
" ? service?.filter((i) => {
v-for="i in service" if (currentStatus === 'All') {
return true;
}
if (currentStatus === 'ACTIVE') {
return i.status === 'ACTIVE' || i.status === 'CREATED';
}
if (currentStatus === 'INACTIVE') {
return i.status === 'INACTIVE';
}
})
: []"
:key="i.id" :key="i.id"
> >
<TotalProductCardComponent <TotalProductCardComponent
@ -1221,7 +1253,7 @@ watch(currentStatus, async () => {
:code="i.code" :code="i.code"
:id="i.id" :id="i.id"
:title="i.name" :title="i.name"
:status="i.status === 'INACTIVE' ? true : false" :isDisabled="i.status === 'INACTIVE' ? true : false"
:created-at="i.createdAt" :created-at="i.createdAt"
@menuViewDetail=" @menuViewDetail="
() => { () => {
@ -1337,7 +1369,11 @@ watch(currentStatus, async () => {
selectProduct = []; selectProduct = [];
} }
" "
:close="() => {}" :close="
() => {
searchTotalProduct = '';
}
"
> >
<div <div
style=" style="
@ -1348,7 +1384,7 @@ watch(currentStatus, async () => {
gap: var(--size-3); gap: var(--size-3);
" "
> >
<div class="row items-center"> <div class="row items-center" style="max-height: 20%">
<q-space /> <q-space />
<q-input <q-input
outlined outlined
@ -1357,7 +1393,7 @@ watch(currentStatus, async () => {
:bg-color="$q.dark.isActive ? 'dark' : 'white'" :bg-color="$q.dark.isActive ? 'dark' : 'white'"
v-model="searchTotalProduct" v-model="searchTotalProduct"
debounce="500" debounce="500"
@update:model-value="" @update:model-value="searchProduct()"
> >
<template v-slot:prepend> <template v-slot:prepend>
<q-icon name="mdi-magnify" /> <q-icon name="mdi-magnify" />
@ -1365,19 +1401,13 @@ watch(currentStatus, async () => {
</q-input> </q-input>
</div> </div>
<AppBox <AppBox class="row q-gutter-md" no-padding>
class="row full-width"
no-padding
style="
width: 75vw;
display: grid;
background: none;
grid-template-columns: repeat(4, 1fr);
gap: var(--size-3);
"
>
<div <div
v-for="i in product?.filter((i) => { class="co-2"
v-for="i in (!!searchTotalProduct
? resultSearchProduct
: product
)?.filter((i) => {
if (i.status === 'INACTIVE') { if (i.status === 'INACTIVE') {
return false; return false;
} }
@ -1486,7 +1516,7 @@ watch(currentStatus, async () => {
<!-- edit product --> <!-- edit product -->
<FormDialog <FormDialog
edit :edit="!(formDataProduct.status === 'INACTIVE')"
:isEdit="infoProductEdit" :isEdit="infoProductEdit"
v-model:modal="dialogProductEdit" v-model:modal="dialogProductEdit"
noAddress noAddress