fix: แก้ แบ่งหน้าตอนค้นหาของ กลุ่ม และ ประเภท
This commit is contained in:
parent
d0316ac468
commit
7876a51d29
1 changed files with 26 additions and 48 deletions
|
|
@ -200,7 +200,7 @@ const maxPageGroup = ref<number>(1);
|
||||||
const pageSizeGroup = ref<number>(30);
|
const pageSizeGroup = ref<number>(30);
|
||||||
const currentPageType = ref<number>(1);
|
const currentPageType = ref<number>(1);
|
||||||
const maxPageType = ref<number>(1);
|
const maxPageType = ref<number>(1);
|
||||||
const pageSizeType = ref<number>(30);
|
const pageSizeType = ref<number>(1);
|
||||||
const currentPageServiceAndProduct = ref<number>(1);
|
const currentPageServiceAndProduct = ref<number>(1);
|
||||||
const maxPageServiceAndProduct = ref<number>(1);
|
const maxPageServiceAndProduct = ref<number>(1);
|
||||||
const pageSizeServiceAndProduct = ref<number>(30);
|
const pageSizeServiceAndProduct = ref<number>(30);
|
||||||
|
|
@ -219,9 +219,6 @@ const currentIdProduct = ref<string>('');
|
||||||
|
|
||||||
const currentStatus = ref<Status | 'All'>('All');
|
const currentStatus = ref<Status | 'All'>('All');
|
||||||
|
|
||||||
const resultSearchGroup = ref<ProductGroup[]>();
|
|
||||||
const resultSearchType = ref<(ProductGroup & { productGroupId: string })[]>();
|
|
||||||
|
|
||||||
const inputFile = (() => {
|
const inputFile = (() => {
|
||||||
const element = document.createElement('input');
|
const element = document.createElement('input');
|
||||||
element.type = 'file';
|
element.type = 'file';
|
||||||
|
|
@ -242,17 +239,6 @@ const inputFile = (() => {
|
||||||
return element;
|
return element;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
async function searchGroup() {
|
|
||||||
const resultList = await fetchListProductService({
|
|
||||||
query: inputSearch.value,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (resultList) {
|
|
||||||
resultSearchGroup.value = resultList.result;
|
|
||||||
}
|
|
||||||
flowStore.rotate();
|
|
||||||
}
|
|
||||||
|
|
||||||
async function searchProductAndService() {
|
async function searchProductAndService() {
|
||||||
const res = await fetchListProductAndService({
|
const res = await fetchListProductAndService({
|
||||||
query: inputSearchProductAndService.value,
|
query: inputSearchProductAndService.value,
|
||||||
|
|
@ -322,6 +308,7 @@ async function fetchListType() {
|
||||||
const res = await fetchListProductServiceType({
|
const res = await fetchListProductServiceType({
|
||||||
page: currentPageType.value,
|
page: currentPageType.value,
|
||||||
pageSize: pageSizeType.value,
|
pageSize: pageSizeType.value,
|
||||||
|
query: !!inputSearch.value ? inputSearch.value : undefined,
|
||||||
productGroupId: currentId.value,
|
productGroupId: currentId.value,
|
||||||
status:
|
status:
|
||||||
currentStatus.value === 'All'
|
currentStatus.value === 'All'
|
||||||
|
|
@ -342,6 +329,7 @@ async function fetchListGroups() {
|
||||||
const res = await fetchListProductService({
|
const res = await fetchListProductService({
|
||||||
page: currentPageGroup.value,
|
page: currentPageGroup.value,
|
||||||
pageSize: pageSizeGroup.value,
|
pageSize: pageSizeGroup.value,
|
||||||
|
query: !!inputSearch.value ? inputSearch.value : undefined,
|
||||||
status:
|
status:
|
||||||
currentStatus.value === 'All'
|
currentStatus.value === 'All'
|
||||||
? undefined
|
? undefined
|
||||||
|
|
@ -382,6 +370,9 @@ async function fetchListOfProduct(productTypeId: string) {
|
||||||
const res = await fetchListProduct({
|
const res = await fetchListProduct({
|
||||||
page: currentPageProduct.value,
|
page: currentPageProduct.value,
|
||||||
pageSize: pageSizeProduct.value,
|
pageSize: pageSizeProduct.value,
|
||||||
|
query: !!inputSearchProductAndService.value
|
||||||
|
? inputSearchProductAndService.value
|
||||||
|
: undefined,
|
||||||
status:
|
status:
|
||||||
currentStatus.value === 'INACTIVE'
|
currentStatus.value === 'INACTIVE'
|
||||||
? 'INACTIVE'
|
? 'INACTIVE'
|
||||||
|
|
@ -407,6 +398,9 @@ async function fetchListOfProduct(productTypeId: string) {
|
||||||
async function fetchListOfService() {
|
async function fetchListOfService() {
|
||||||
const res = await fetchListService({
|
const res = await fetchListService({
|
||||||
page: currentPageService.value,
|
page: currentPageService.value,
|
||||||
|
query: !!inputSearchProductAndService.value
|
||||||
|
? inputSearchProductAndService.value
|
||||||
|
: undefined,
|
||||||
pageSize: pageSizeService.value,
|
pageSize: pageSizeService.value,
|
||||||
status:
|
status:
|
||||||
currentStatus.value === 'INACTIVE'
|
currentStatus.value === 'INACTIVE'
|
||||||
|
|
@ -429,17 +423,6 @@ async function fetchListOfService() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function searchType() {
|
|
||||||
const res = await fetchListProductServiceType({
|
|
||||||
query: inputSearch.value,
|
|
||||||
productGroupId: currentId.value,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (res) {
|
|
||||||
resultSearchType.value = res.result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function submitType() {
|
async function submitType() {
|
||||||
if (drawerInfo.value) {
|
if (drawerInfo.value) {
|
||||||
await editProductServiceType(currentIdType.value, {
|
await editProductServiceType(currentIdType.value, {
|
||||||
|
|
@ -1037,6 +1020,16 @@ watch(currentPageService, async () => {
|
||||||
await fetchListOfService();
|
await fetchListOfService();
|
||||||
flowStore.rotate();
|
flowStore.rotate();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
watch(inputSearch, async () => {
|
||||||
|
if (productMode.value === 'group') {
|
||||||
|
await fetchListGroups();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (productMode.value === 'type') {
|
||||||
|
await fetchListType();
|
||||||
|
}
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
@ -1212,13 +1205,6 @@ watch(currentPageService, 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'
|
|
||||||
? searchType()
|
|
||||||
: ''
|
|
||||||
"
|
|
||||||
>
|
>
|
||||||
<template v-slot:prepend>
|
<template v-slot:prepend>
|
||||||
<q-icon name="mdi-magnify" />
|
<q-icon name="mdi-magnify" />
|
||||||
|
|
@ -1276,13 +1262,9 @@ watch(currentPageService, async () => {
|
||||||
<div class="row q-col-gutter-lg">
|
<div class="row q-col-gutter-lg">
|
||||||
<div
|
<div
|
||||||
: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 !!inputSearch
|
v-for="(v, i) in productMode === 'type'
|
||||||
? productMode === 'group'
|
? productType
|
||||||
? resultSearchGroup
|
: productGroup"
|
||||||
: resultSearchType
|
|
||||||
: productMode === 'type'
|
|
||||||
? productType
|
|
||||||
: productGroup"
|
|
||||||
:key="i"
|
:key="i"
|
||||||
>
|
>
|
||||||
<ProductCardComponent
|
<ProductCardComponent
|
||||||
|
|
@ -1329,8 +1311,6 @@ watch(currentPageService, async () => {
|
||||||
pathTypeName = v.name;
|
pathTypeName = v.name;
|
||||||
currentIdType = v.id;
|
currentIdType = v.id;
|
||||||
productMode = 'service';
|
productMode = 'service';
|
||||||
// await fetchListOfProduct(currentIdType);
|
|
||||||
// await fetchListOfService();
|
|
||||||
|
|
||||||
await featchStatsService();
|
await featchStatsService();
|
||||||
await featchStatsProduct();
|
await featchStatsProduct();
|
||||||
|
|
@ -1390,18 +1370,16 @@ watch(currentPageService, async () => {
|
||||||
<div
|
<div
|
||||||
v-if="
|
v-if="
|
||||||
(productMode === 'type' && productType?.length === 0) ||
|
(productMode === 'type' && productType?.length === 0) ||
|
||||||
(productGroup?.length === 0 && productMode === 'group') ||
|
(productGroup?.length === 0 && productMode === 'group')
|
||||||
resultSearchGroup?.length === 0 ||
|
|
||||||
resultSearchType?.length === 0
|
|
||||||
"
|
"
|
||||||
class="flex justify-center items-center q-mt-lg"
|
class="flex justify-center items-center q-mt-lg"
|
||||||
style="min-height: 70vh; background-color: var(--surface-2)"
|
style="min-height: 70vh; background-color: var(--surface-2)"
|
||||||
>
|
>
|
||||||
<NoData notFound />
|
<NoData :not-found="!!inputSearch" />
|
||||||
</div>
|
</div>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<div
|
<div
|
||||||
v-if="productMode === 'group' && !inputSearch"
|
v-if="productMode === 'group'"
|
||||||
class="flex justify-center q-pt-xl"
|
class="flex justify-center q-pt-xl"
|
||||||
>
|
>
|
||||||
<q-pagination
|
<q-pagination
|
||||||
|
|
@ -1415,7 +1393,7 @@ watch(currentPageService, async () => {
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
v-if="productMode === 'type' && !inputSearch"
|
v-if="productMode === 'type'"
|
||||||
class="flex justify-center q-pt-xl"
|
class="flex justify-center q-pt-xl"
|
||||||
>
|
>
|
||||||
<q-pagination
|
<q-pagination
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue