From aba1d61e01a7e3bd6f0c63ca171946f4ea33d01d Mon Sep 17 00:00:00 2001 From: oat_dev Date: Mon, 10 Jun 2024 12:00:16 +0700 Subject: [PATCH] feat: customer branch dialog UI + function submit + define emit --- .../CustomerInfoComponent.vue | 14 +- src/pages/03_customer-management/MainPage.vue | 158 +++++++++++++++++- 2 files changed, 166 insertions(+), 6 deletions(-) diff --git a/src/components/03_customer-management/CustomerInfoComponent.vue b/src/components/03_customer-management/CustomerInfoComponent.vue index dffc31d5..1c95e05b 100644 --- a/src/components/03_customer-management/CustomerInfoComponent.vue +++ b/src/components/03_customer-management/CustomerInfoComponent.vue @@ -10,10 +10,10 @@ const userCustomer = useCustomerStore(); const { fetchListById } = userCustomer; const inputSearch = ref(''); -const branch = ref(); -const currentCustomerName = ref(''); -const currentCustomerUrlImage = ref(''); +const branch = defineModel('branch'); +const currentCustomerName = defineModel('currentCustomerName'); +const currentCustomerUrlImage = defineModel('currentCustomerUrlImage'); const prop = withDefaults( defineProps<{ @@ -25,6 +25,12 @@ const prop = withDefaults( }, ); +defineEmits<{ + (e: 'back'): void; + (e: 'viewDetail'): void; + (e: 'dialog'): void; +}>(); + onMounted(async () => { const result = await fetchListById(prop.customerId); if (result) { @@ -84,7 +90,7 @@ onMounted(async () => { unelevated :label="'+ ' + $t('formDialogTitleCreateSubBranch')" padding="4px 16px" - @click="console.log('add')" + @click="$emit('dialog')" style="background-color: var(--cyan-6); color: white" /> diff --git a/src/pages/03_customer-management/MainPage.vue b/src/pages/03_customer-management/MainPage.vue index 0852bc13..e67e2a67 100644 --- a/src/pages/03_customer-management/MainPage.vue +++ b/src/pages/03_customer-management/MainPage.vue @@ -38,7 +38,8 @@ import FormEmployeeHealthCheck from 'src/components/03_customer-management/FormE import { dialog } from 'src/stores/utils'; const userCustomer = useCustomerStore(); -const { create, getStatsCustomer, fetchList, editById } = userCustomer; +const { create, getStatsCustomer, fetchList, editById, fetchListById } = + userCustomer; const formData = ref({ status: 'CREATED', customerType: 'CORP', @@ -117,8 +118,12 @@ const infoDrawerEdit = ref(false); const isMainPage = ref(true); const statsCustomerType = ref(); const currentCustomerId = ref(''); - +const dialogInputCustomerBranchForm = ref(false); const currentCustomer = ref(); +const branch = ref(); + +const currentCustomerName = ref(''); +const currentCustomerUrlImage = ref(''); const inputFile = (() => { const element = document.createElement('input'); @@ -295,6 +300,17 @@ async function onSubmit() { if (resultList) listCustomer.value = resultList.result; } +async function onSubmitCustomerBranch() { + dialogInputCustomerBranchForm.value = false; + clearForm(); + const result = await fetchListById(currentCustomerId.value); + if (result) { + currentCustomerName.value = result.customerName; + currentCustomerUrlImage.value = result.imageUrl; + branch.value = result.branch; + } +} + async function onSubmitEdit(id: string) { if (!formData.value) return; @@ -449,6 +465,7 @@ onMounted(async () => { { @@ -806,6 +827,132 @@ onMounted(async () => { + + + + { .customer-row { display: grid; gap: var(--size-6); + transition: 0.3s ease-in-out; +} + +.hover-card:hover { + cursor: pointer; + border-radius: 10px; + box-shadow: var(--shadow-3); }