From f4474c26241c8d061b79ab8e9f664c33d31a9a5e Mon Sep 17 00:00:00 2001 From: Net Date: Fri, 20 Sep 2024 18:00:06 +0700 Subject: [PATCH] fix: Unable to create service point --- src/pages/01_branch-management/MainPage.vue | 22 ++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/pages/01_branch-management/MainPage.vue b/src/pages/01_branch-management/MainPage.vue index f9299e19..e71465df 100644 --- a/src/pages/01_branch-management/MainPage.vue +++ b/src/pages/01_branch-management/MainPage.vue @@ -366,7 +366,9 @@ const defaultFormData = { const formDialogRef = ref(); const formType = ref<'create' | 'edit' | 'delete' | 'view'>('create'); -const formTypeBranch = ref<'headOffice' | 'subBranch'>('headOffice'); +const formTypeBranch = ref<'headOffice' | 'subBranch' | 'branchVirtual'>( + 'headOffice', +); const currentHq = ref<{ id: string; code: string }>({ id: '', code: '', @@ -520,13 +522,13 @@ watch(modalDrawer, () => { }); function triggerCreate( - type: 'headOffice' | 'subBranch', + type: 'headOffice' | 'subBranch' | 'branchVirtual', id?: string, code?: string, ) { formTypeBranch.value = type; - if (type === 'subBranch' && id && code) { + if ((type === 'subBranch' || type === 'branchVirtual') && id && code) { isSubCreate.value = true; formData.value.headOfficeId = id; formData.value.code = code; @@ -845,12 +847,14 @@ async function onSubmit(submitSelectedItem?: boolean) { function changeTitle( formType: 'edit' | 'create' | 'delete' | 'view', - typeBranch: 'headOffice' | 'subBranch', + typeBranch: 'headOffice' | 'subBranch' | 'branchVirtual', ) { const _type = - typeBranch === 'headOffice' - ? 'branch.card.branchHQLabel' - : 'branch.card.branchLabel'; + { + headOffice: 'branch.card.branchHQLabel', + subBranch: 'branch.card.branchLabel', + branchVirtual: 'branch.card.branchVirtual', + }[typeBranch] || ''; return formType === 'create' ? t('form.title.create', { name: t(_type) }) @@ -2652,14 +2656,14 @@ watch(currentHq, () => { () => { modelCreateTypeBranch = false; - if (value.text === $t('branch.card.branchVirtual')) { + if (value.text === 'branch.card.branchVirtual') { formData.virtual = true; } else { formData.virtual = false; } triggerCreate( - 'subBranch', + formData.virtual ? 'branchVirtual' : 'subBranch', currentEdit.id || currentHq.id, currentEdit.code || currentHq.code, );