From d8425183f91ba6d5ac3f973543b0e5f9553138f4 Mon Sep 17 00:00:00 2001 From: Net <93821485+somnetsak123@users.noreply.github.com> Date: Tue, 11 Jun 2024 11:23:56 +0700 Subject: [PATCH] =?UTF-8?q?feat:=20=E0=B8=97=E0=B8=B3=E0=B9=81=E0=B8=9A?= =?UTF-8?q?=E0=B9=88=E0=B8=87=E0=B8=AB=E0=B8=99=E0=B9=89=E0=B8=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CustomerInfoComponent.vue | 88 +++++++++++++++---- 1 file changed, 71 insertions(+), 17 deletions(-) diff --git a/src/components/03_customer-management/CustomerInfoComponent.vue b/src/components/03_customer-management/CustomerInfoComponent.vue index 9d8f7cef..7f33f4bb 100644 --- a/src/components/03_customer-management/CustomerInfoComponent.vue +++ b/src/components/03_customer-management/CustomerInfoComponent.vue @@ -4,22 +4,34 @@ import AppBox from 'components/app/AppBox.vue'; import BranchCardCustomer from 'components/03_customer-management/BranchCardCustomer.vue'; import { onMounted } from 'vue'; import useCustomerStore from 'src/stores/customer'; -import { CustomerBranch, Customer } from 'src/stores/customer/types'; +import { + CustomerBranch, + Customer, + CustomerType, +} from 'src/stores/customer/types'; +import { watch } from 'vue'; const userCustomer = useCustomerStore(); -const { fetchListById } = userCustomer; +const { fetchListById, fetchListBranch } = userCustomer; const inputSearch = ref(''); const branch = defineModel('branch'); const currentCustomerName = defineModel('currentCustomerName'); -const currentCustomerUrlImage = ref(); -const returnCustomer = ref(); +const currentCustomerUrlImage = defineModel( + 'currentCustomerUrlImage', +); + +const currentPageBranch = ref(1); +const maxPageBranch = ref(1); +const pageSizeBranch = ref(30); + const prop = withDefaults( defineProps<{ color?: 'purple' | 'green'; customerId: string; + customerType: CustomerType; }>(), { color: 'green', @@ -28,21 +40,44 @@ const prop = withDefaults( const emit = defineEmits<{ (e: 'back'): void; - ( - e: 'viewDetail', - returnCustomer: Customer & { branch: CustomerBranch[] }, - ): void; - + (e: 'viewDetail', branch: CustomerBranch[]): void; (e: 'dialog'): void; }>(); +async function searchBranch() { + const resultList = await fetchListBranch({ + query: inputSearch.value, + includeCustomer: true, + }); + + if (resultList) { + branch.value = resultList.result; + } +} + onMounted(async () => { - const result = await fetchListById(prop.customerId); + const result = await fetchListBranch({ + customerId: prop.customerId, + page: 1, + pageSize: pageSizeBranch.value, + }); if (result) { - returnCustomer.value = result; - currentCustomerName.value = result.customerName; - currentCustomerUrlImage.value = result.imageUrl; - branch.value = result.branch; + currentCustomerName.value = 'dasd'; + + branch.value = result.result; + } +}); + +watch(currentPageBranch, async () => { + const resultList = await fetchListBranch({ + page: currentPageBranch.value, + pageSize: pageSizeBranch.value, + }); + + if (resultList) { + currentPageBranch.value = resultList.page; + maxPageBranch.value = Math.ceil(resultList.total / pageSizeBranch.value); + branch.value = resultList.result; } }); @@ -59,6 +94,7 @@ onMounted(async () => { @click="$emit('back')" class="q-mr-md" /> + { -
+
+ +
+ +
- +