From 3910af2a4a7319ba5557f57607aecbcd7249c764 Mon Sep 17 00:00:00 2001 From: Net <93821485+somnetsak123@users.noreply.github.com> Date: Thu, 18 Apr 2024 14:13:57 +0700 Subject: [PATCH] =?UTF-8?q?feat:=20=E0=B8=95=E0=B9=88=E0=B8=AD=20=20api=20?= =?UTF-8?q?=E0=B8=AA=E0=B8=A3=E0=B9=89=E0=B8=B2=E0=B8=87=20=E0=B8=A5?= =?UTF-8?q?=E0=B8=B9=E0=B8=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/01_branch-management/MainPage.vue | 34 ++++++++++++++++----- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/src/pages/01_branch-management/MainPage.vue b/src/pages/01_branch-management/MainPage.vue index b5ffcace..f3d60952 100644 --- a/src/pages/01_branch-management/MainPage.vue +++ b/src/pages/01_branch-management/MainPage.vue @@ -132,7 +132,7 @@ const defaultFormData = { const formDialogRef = ref(); const formType = ref<'create' | 'edit' | 'delete'>('create'); const formTypeBranch = ref<'headOffice' | 'subBranch'>('headOffice'); -const codeHq = ref(''); +const codeHq = ref<{ id: string; code: string }>({ id: '', code: '' }); const formData = ref>( structuredClone(defaultFormData), ); @@ -141,15 +141,18 @@ function openDialog() { modal.value = true; } -function triggerCreate(type: string, code?: string) { +function triggerCreate(type: string, id?: string, code?: string) { clearData(); - if (code) { - codeHq.value = code; - } - if (type === 'subBranch') { + + if (type === 'subBranch' && id && code) { formTypeBranch.value = 'subBranch'; + codeHq.value = { + id: id, + code: code, + }; } else { formTypeBranch.value = 'headOffice'; + codeHq.value = { id: '', code: '' }; } formType.value = 'create'; @@ -168,6 +171,14 @@ async function onSubmit() { } } else if (formTypeBranch.value === 'subBranch') { if (formType.value === 'create' && profileFile.value) { + formData.value.headOfficeId = codeHq.value.id; + + await branchStore.create({ + ...formData.value, + qrCodeImage: profileFile.value, + }); + await branchStore.fetchList({ pageSize: 99999 }); + modal.value = false; } } } @@ -293,7 +304,14 @@ function changeTitle( > {{ node.name }}
- + @@ -519,7 +537,7 @@ function changeTitle( >