fix: คำนวนหน้าผิด

This commit is contained in:
Net 2024-06-12 15:36:36 +07:00
parent dc2507d5a6
commit 069dcce9b6

View file

@ -4,15 +4,11 @@ import AppBox from 'components/app/AppBox.vue';
import BranchCardCustomer from 'components/03_customer-management/BranchCardCustomer.vue'; import BranchCardCustomer from 'components/03_customer-management/BranchCardCustomer.vue';
import { onMounted } from 'vue'; import { onMounted } from 'vue';
import useCustomerStore from 'src/stores/customer'; import useCustomerStore from 'src/stores/customer';
import { import { CustomerBranch, CustomerType } from 'src/stores/customer/types';
CustomerBranch,
Customer,
CustomerType,
} from 'src/stores/customer/types';
import { watch } from 'vue'; import { watch } from 'vue';
const userCustomer = useCustomerStore(); const userCustomer = useCustomerStore();
const { fetchListById, fetchListBranch } = userCustomer; const { fetchListBranch } = userCustomer;
const inputSearch = ref<string>(''); const inputSearch = ref<string>('');
@ -63,19 +59,21 @@ onMounted(async () => {
}); });
if (result) { if (result) {
currentCustomerName.value = 'dasd'; currentCustomerName.value = 'dasd';
maxPageBranch.value = Math.ceil(result.total / pageSizeBranch.value);
branch.value = result.result; branch.value = result.result;
} }
}); });
watch(currentPageBranch, async () => { watch(currentPageBranch, async () => {
const resultList = await fetchListBranch({ const resultList = await fetchListBranch({
customerId: prop.customerId,
page: currentPageBranch.value, page: currentPageBranch.value,
pageSize: pageSizeBranch.value, pageSize: pageSizeBranch.value,
}); });
if (resultList) { if (resultList) {
currentPageBranch.value = resultList.page; currentPageBranch.value = resultList.page;
maxPageBranch.value = Math.ceil(resultList.total / pageSizeBranch.value); maxPageBranch.value = Math.ceil(resultList.total / pageSizeBranch.value);
branch.value = resultList.result; branch.value = resultList.result;
} }