fix: แก้แบ่งหน้าตอนค้นหาของสินค้าและบริการ
This commit is contained in:
parent
7876a51d29
commit
88b84396da
1 changed files with 35 additions and 63 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>(1);
|
const pageSizeType = ref<number>(30);
|
||||||
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);
|
||||||
|
|
@ -239,17 +239,6 @@ const inputFile = (() => {
|
||||||
return element;
|
return element;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
async function searchProductAndService() {
|
|
||||||
const res = await fetchListProductAndService({
|
|
||||||
query: inputSearchProductAndService.value,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (res) {
|
|
||||||
productAndService.value = res.result;
|
|
||||||
}
|
|
||||||
flowStore.rotate();
|
|
||||||
}
|
|
||||||
|
|
||||||
async function searchProduct(isAdd: boolean = true) {
|
async function searchProduct(isAdd: boolean = true) {
|
||||||
const res = await fetchListProduct({
|
const res = await fetchListProduct({
|
||||||
query: inputSearchProductAndService.value,
|
query: inputSearchProductAndService.value,
|
||||||
|
|
@ -272,22 +261,6 @@ async function searchProduct(isAdd: boolean = true) {
|
||||||
flowStore.rotate();
|
flowStore.rotate();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function searchService() {
|
|
||||||
const res = await fetchListService({
|
|
||||||
query: inputSearchProductAndService.value,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (res) {
|
|
||||||
service.value = res.result.map((v) => {
|
|
||||||
return {
|
|
||||||
...v,
|
|
||||||
type: 'service',
|
|
||||||
};
|
|
||||||
});
|
|
||||||
}
|
|
||||||
flowStore.rotate();
|
|
||||||
}
|
|
||||||
|
|
||||||
async function featchStatsService() {
|
async function featchStatsService() {
|
||||||
const resStatsService = await fetchStatsService();
|
const resStatsService = await fetchStatsService();
|
||||||
|
|
||||||
|
|
@ -366,7 +339,7 @@ async function fetchListOfProductIsAdd(productTypeId: string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchListOfProduct(productTypeId: string) {
|
async function fetchListOfProduct() {
|
||||||
const res = await fetchListProduct({
|
const res = await fetchListProduct({
|
||||||
page: currentPageProduct.value,
|
page: currentPageProduct.value,
|
||||||
pageSize: pageSizeProduct.value,
|
pageSize: pageSizeProduct.value,
|
||||||
|
|
@ -379,10 +352,11 @@ async function fetchListOfProduct(productTypeId: string) {
|
||||||
: currentStatus.value === 'ACTIVE'
|
: currentStatus.value === 'ACTIVE'
|
||||||
? 'ACTIVE'
|
? 'ACTIVE'
|
||||||
: undefined,
|
: undefined,
|
||||||
productTypeId,
|
productTypeId: currentIdType.value,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (res) {
|
if (res) {
|
||||||
|
totalProduct.value = res.total;
|
||||||
currentPageProduct.value = res.page;
|
currentPageProduct.value = res.page;
|
||||||
maxPageProduct.value = Math.ceil(res.total / pageSizeProduct.value);
|
maxPageProduct.value = Math.ceil(res.total / pageSizeProduct.value);
|
||||||
|
|
||||||
|
|
@ -412,6 +386,7 @@ async function fetchListOfService() {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (res) {
|
if (res) {
|
||||||
|
totalService.value = res.total;
|
||||||
currentPageService.value = res.page;
|
currentPageService.value = res.page;
|
||||||
maxPageService.value = Math.ceil(res.total / pageSizeService.value);
|
maxPageService.value = Math.ceil(res.total / pageSizeService.value);
|
||||||
service.value = res.result.map((v) => {
|
service.value = res.result.map((v) => {
|
||||||
|
|
@ -463,7 +438,7 @@ async function toggleStatusProduct(id: string, status: Status) {
|
||||||
status: status === 'INACTIVE' ? 'ACTIVE' : 'INACTIVE',
|
status: status === 'INACTIVE' ? 'ACTIVE' : 'INACTIVE',
|
||||||
});
|
});
|
||||||
|
|
||||||
await fetchListOfProduct(currentIdType.value);
|
await fetchListOfProduct();
|
||||||
flowStore.rotate();
|
flowStore.rotate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -497,6 +472,9 @@ async function fetchListOfProductAndService() {
|
||||||
const res = await fetchListProductAndService({
|
const res = await fetchListProductAndService({
|
||||||
page: currentPageServiceAndProduct.value,
|
page: currentPageServiceAndProduct.value,
|
||||||
pageSize: pageSizeServiceAndProduct.value,
|
pageSize: pageSizeServiceAndProduct.value,
|
||||||
|
query: !!inputSearchProductAndService.value
|
||||||
|
? inputSearchProductAndService.value
|
||||||
|
: undefined,
|
||||||
status:
|
status:
|
||||||
currentStatus.value === 'INACTIVE'
|
currentStatus.value === 'INACTIVE'
|
||||||
? 'INACTIVE'
|
? 'INACTIVE'
|
||||||
|
|
@ -561,7 +539,7 @@ async function deleteTypeOfProduct(id?: string) {
|
||||||
const res = await deleteProduct(id ?? currentIdProduct.value);
|
const res = await deleteProduct(id ?? currentIdProduct.value);
|
||||||
|
|
||||||
if (productAndServiceTab.value === 'product') {
|
if (productAndServiceTab.value === 'product') {
|
||||||
await fetchListOfProduct(currentIdType.value);
|
await fetchListOfProduct();
|
||||||
}
|
}
|
||||||
if (productAndServiceTab.value === 'all') {
|
if (productAndServiceTab.value === 'all') {
|
||||||
await fetchListOfProductAndService();
|
await fetchListOfProductAndService();
|
||||||
|
|
@ -839,7 +817,7 @@ async function submitProduct() {
|
||||||
await fetchListOfProductAndService();
|
await fetchListOfProductAndService();
|
||||||
}
|
}
|
||||||
if (productAndServiceTab.value === 'product') {
|
if (productAndServiceTab.value === 'product') {
|
||||||
await fetchListOfProduct(currentIdType.value);
|
await fetchListOfProduct();
|
||||||
}
|
}
|
||||||
|
|
||||||
flowStore.rotate();
|
flowStore.rotate();
|
||||||
|
|
@ -929,7 +907,7 @@ async function fetchStatus() {
|
||||||
flowStore.rotate();
|
flowStore.rotate();
|
||||||
}
|
}
|
||||||
if (productAndServiceTab.value === 'product') {
|
if (productAndServiceTab.value === 'product') {
|
||||||
await fetchListOfProduct(currentIdType.value);
|
await fetchListOfProduct();
|
||||||
flowStore.rotate();
|
flowStore.rotate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -939,21 +917,6 @@ async function fetchStatus() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchSearch() {
|
|
||||||
if (productAndServiceTab.value === 'all') {
|
|
||||||
await searchProductAndService();
|
|
||||||
flowStore.rotate();
|
|
||||||
}
|
|
||||||
if (productAndServiceTab.value === 'product') {
|
|
||||||
await searchProduct(false);
|
|
||||||
flowStore.rotate();
|
|
||||||
}
|
|
||||||
if (productAndServiceTab.value === 'service') {
|
|
||||||
await searchService();
|
|
||||||
flowStore.rotate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function cloneData() {
|
function cloneData() {
|
||||||
if (!currentService.value) return;
|
if (!currentService.value) return;
|
||||||
formDataProductService.value = {
|
formDataProductService.value = {
|
||||||
|
|
@ -1012,7 +975,7 @@ watch(currentPageServiceAndProduct, async () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
watch(currentPageProduct, async () => {
|
watch(currentPageProduct, async () => {
|
||||||
await fetchListOfProduct(currentIdType.value);
|
await fetchListOfProduct();
|
||||||
flowStore.rotate();
|
flowStore.rotate();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -1024,10 +987,28 @@ watch(currentPageService, async () => {
|
||||||
watch(inputSearch, async () => {
|
watch(inputSearch, async () => {
|
||||||
if (productMode.value === 'group') {
|
if (productMode.value === 'group') {
|
||||||
await fetchListGroups();
|
await fetchListGroups();
|
||||||
|
flowStore.rotate();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (productMode.value === 'type') {
|
if (productMode.value === 'type') {
|
||||||
await fetchListType();
|
await fetchListType();
|
||||||
|
flowStore.rotate();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
watch(inputSearchProductAndService, async () => {
|
||||||
|
if (productAndServiceTab.value === 'all') {
|
||||||
|
await fetchListOfProductAndService();
|
||||||
|
flowStore.rotate();
|
||||||
|
}
|
||||||
|
if (productAndServiceTab.value === 'product') {
|
||||||
|
await fetchListOfProduct();
|
||||||
|
|
||||||
|
flowStore.rotate();
|
||||||
|
}
|
||||||
|
if (productAndServiceTab.value === 'service') {
|
||||||
|
await fetchListOfService();
|
||||||
|
flowStore.rotate();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
@ -1448,7 +1429,7 @@ watch(inputSearch, async () => {
|
||||||
async () => {
|
async () => {
|
||||||
inputSearchProductAndService = '';
|
inputSearchProductAndService = '';
|
||||||
currentStatus = 'All';
|
currentStatus = 'All';
|
||||||
await fetchListOfProduct(currentIdType);
|
await fetchListOfProduct();
|
||||||
flowStore.rotate();
|
flowStore.rotate();
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
|
|
@ -1518,11 +1499,6 @@ watch(inputSearch, async () => {
|
||||||
:bg-color="$q.dark.isActive ? 'dark' : 'white'"
|
:bg-color="$q.dark.isActive ? 'dark' : 'white'"
|
||||||
v-model="inputSearchProductAndService"
|
v-model="inputSearchProductAndService"
|
||||||
debounce="250"
|
debounce="250"
|
||||||
@update:model-value="
|
|
||||||
async () => {
|
|
||||||
await fetchSearch();
|
|
||||||
}
|
|
||||||
"
|
|
||||||
>
|
>
|
||||||
<template v-slot:prepend>
|
<template v-slot:prepend>
|
||||||
<q-icon name="mdi-magnify" />
|
<q-icon name="mdi-magnify" />
|
||||||
|
|
@ -1591,7 +1567,7 @@ watch(inputSearch, async () => {
|
||||||
class="flex justify-center items-center"
|
class="flex justify-center items-center"
|
||||||
style="min-height: 70vh; background-color: var(--surface-2)"
|
style="min-height: 70vh; background-color: var(--surface-2)"
|
||||||
>
|
>
|
||||||
<NoData />
|
<NoData :not-found="!!inputSearchProductAndService" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
|
|
@ -1658,11 +1634,7 @@ watch(inputSearch, async () => {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
v-if="
|
v-if="productAndServiceTab === 'all' && productAndService.length > 0"
|
||||||
productAndServiceTab === 'all' &&
|
|
||||||
productAndService.length > 0 &&
|
|
||||||
!inputSearchProductAndService
|
|
||||||
"
|
|
||||||
class="row justify-center q-pb-md"
|
class="row justify-center q-pb-md"
|
||||||
>
|
>
|
||||||
<q-pagination
|
<q-pagination
|
||||||
|
|
@ -2250,7 +2222,7 @@ watch(inputSearch, async () => {
|
||||||
dense
|
dense
|
||||||
@addProduct="
|
@addProduct="
|
||||||
async (index) => {
|
async (index) => {
|
||||||
await fetchListOfProduct(currentIdType);
|
await fetchListOfProduct();
|
||||||
currentWorkIndex = index;
|
currentWorkIndex = index;
|
||||||
dialogTotalProduct = true;
|
dialogTotalProduct = true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue