From 8e248152c8e18d351b8c8c3091c295b54c711c6f Mon Sep 17 00:00:00 2001 From: Net <93821485+somnetsak123@users.noreply.github.com> Date: Mon, 10 Jun 2024 16:02:14 +0700 Subject: [PATCH] =?UTF-8?q?feat:=20=E0=B9=80=E0=B8=9E=E0=B8=B4=E0=B9=88?= =?UTF-8?q?=E0=B8=A1=E0=B9=81=E0=B8=81=E0=B9=89=E0=B9=84=E0=B8=82=20?= =?UTF-8?q?=E0=B8=82=E0=B8=AD=E0=B8=87Branch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/03_customer-management/MainPage.vue | 264 +++++++++++++++++- 1 file changed, 259 insertions(+), 5 deletions(-) diff --git a/src/pages/03_customer-management/MainPage.vue b/src/pages/03_customer-management/MainPage.vue index e48c2609..d861341d 100644 --- a/src/pages/03_customer-management/MainPage.vue +++ b/src/pages/03_customer-management/MainPage.vue @@ -49,6 +49,7 @@ const { fetchListById, createBranch, deleteBranchById, + editBranchById, } = userCustomer; const formData = ref({ status: 'CREATED', @@ -85,6 +86,8 @@ const formData = ref({ wageRate: 0, }, ], + image: null, +}); const inputSearch = ref(''); const fieldSelectedCustomer = ref<{ label: string; value: string }>({ @@ -136,6 +139,7 @@ const dialogInputCustomerBranchForm = ref(false); const currentCustomer = ref(); const branch = ref(); +const currentBranchId = ref(''); const currentCustomerName = ref(''); const currentCustomerUrlImage = ref(''); @@ -217,6 +221,8 @@ const dialogCustomerType = ref(false); const dialogInputForm = ref(false); const dialogEmployee = ref(false); +const infoDrawerBranch = ref(false); + const selectorLabel = ref(''); const selectorList = computed(() => [ { @@ -259,6 +265,14 @@ function openDialogInputForm(action: 'FORM' | 'INFO' = 'FORM', id?: string) { function onClose() { infoDrawer.value = false; + infoDrawerEdit.value = false; + dialogInputForm.value = false; + clearForm(); +} + +function onCloseBranch() { + infoDrawerBranch.value = false; + infoDrawerEdit.value = false; dialogInputForm.value = false; clearForm(); } @@ -301,7 +315,7 @@ function clearForm() { wageRate: 0, }, ], - image: new File([''], 'dummy.jpg'), + image: null, }; } @@ -310,9 +324,7 @@ async function onSubmit() { ...formData.value, customerType: customerType.value === 'customerLegalEntity' ? 'CORP' : 'PERS', - image: (profileSubmit.value - ? profileFile.value ?? new File([''], 'dummy.jpg') - : new File([''], 'dummy.jpg')) as File, + image: profileSubmit.value ? profileFile.value ?? null : null, }); clearForm(); const resultList = await fetchList({ includeBranch: true }); @@ -339,6 +351,19 @@ async function onSubmitCustomerBranch() { } } +const resultSearch = ref<(Customer & { branch: CustomerBranch[] })[]>(); + +async function searchCustomer() { + const resultList = await fetchList({ + query: inputSearch.value, + includeBranch: true, + }); + + if (resultList) { + resultSearch.value = resultList.result; + } +} + async function onSubmitEdit(id: string) { if (!formData.value) return; @@ -355,6 +380,23 @@ async function onSubmitEdit(id: string) { clearForm(); } +async function submitBranch() { + if (formData.value.customerBranch?.[0]) { + await editBranchById(currentBranchId.value, { + ...formData.value.customerBranch[0], + customerId: currentCustomerId.value, + }); + + const result = await fetchListById(currentCustomerId.value); + + if (result) { + branch.value = result.branch; + } + } + infoDrawerBranch.value = false; + clearForm(); +} + function undo() { infoDrawerEdit.value = false; } @@ -367,7 +409,7 @@ async function assignFormData(data: Customer & { branch: CustomerBranch[] }) { customerNameEN: data.customerNameEN, taxNo: data.taxNo, customerBranch: [], - image: new File([''], 'dummy.jpg'), + image: null, }; data.branch.forEach((v) => { @@ -679,6 +721,22 @@ watch(locale, () => { :customer-id="currentCustomerId" @back="isMainPage = true" @dialog="dialogInputCustomerBranchForm = true" + @viewDetail=" + (v) => { + infoDrawerBranch = true; + + console.log(v); + + currentCustomerId = v.id; + currentBranchId = v.branch[0].id; + + customerType = + v.customerType === 'CORP' + ? 'customerLegalEntity' + : 'customerNaturalPerson'; + assignFormData(v); + } + " v-model:branch="branch" v-model:currentCustomerName="currentCustomerName" v-model:currentCustomerUrlImage="currentCustomerUrlImage" @@ -1063,6 +1121,8 @@ watch(locale, () => { + + { indexTab !== undefined && formData.customerBranch?.[indexTab] " + :type-customer="customerType" + v-model:customer-name="formData.customerBranch[indexTab].name" + v-model:customer-english-name=" + formData.customerBranch[indexTab].nameEN + " + v-model:authorized-capital=" + formData.customerBranch[indexTab].authorizedCapital + " + v-model:register-name=" + formData.customerBranch[indexTab].registerName + " + v-model:register-date=" + formData.customerBranch[indexTab].registerDate + " + dense + outlined + bordered + separator + :readonly="!infoDrawerEdit" + /> + + + + + + + + + + + + +