From 7fad5e81d83cd4fb9aa8ca44e02d07b58caa9233 Mon Sep 17 00:00:00 2001 From: Net <93821485+somnetsak123@users.noreply.github.com> Date: Fri, 19 Apr 2024 13:53:05 +0700 Subject: [PATCH] =?UTF-8?q?fix:=20=20=E0=B9=81=E0=B8=81=E0=B9=89=E0=B9=84?= =?UTF-8?q?=E0=B8=82=E0=B8=A5=E0=B8=B9=E0=B8=81=20=E0=B9=84=E0=B8=A1?= =?UTF-8?q?=E0=B9=88=E0=B9=84=E0=B8=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/01_branch-management/MainPage.vue | 32 +++++++++++++++++---- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/src/pages/01_branch-management/MainPage.vue b/src/pages/01_branch-management/MainPage.vue index d2c2e660..923fe6aa 100644 --- a/src/pages/01_branch-management/MainPage.vue +++ b/src/pages/01_branch-management/MainPage.vue @@ -271,9 +271,11 @@ function triggerCreate(type: string, id?: string, code?: string) { openDialog(); } -function triggerEdit(type: string, id: string, code?: string) { - fetchBranchById(id); +async function triggerEdit(type: string, id: string, code?: string) { + await fetchBranchById(id); + if (id && code && type === 'headOffice') { + formTypeBranch.value = 'headOffice'; codeHq.value = { id: id, code: code, @@ -281,8 +283,22 @@ function triggerEdit(type: string, id: string, code?: string) { } if (type === 'subBranch' && id && code) { formTypeBranch.value = 'subBranch'; - } else { - formTypeBranch.value = 'headOffice'; + codeHq.value = { + id: id, + code: code, + }; + } + + const currentRecord = branchData.value.result.find((x) => x.id === id); + + if (!currentRecord) return; + + const currentRecordHead = branchData.value.result.find( + (x) => x.id === currentRecord.headOfficeId, + ); + + if (currentRecordHead) { + codeHq.value.code = currentRecordHead.code; } formType.value = 'edit'; @@ -333,9 +349,13 @@ async function onSubmit() { cancel: () => {}, }); } else { + const { status, ...payload } = formData.value; + await branchStore.editById( codeHq.value.id, - formData.value, + { + ...payload, + }, profileFile.value, profileFileImg.value, ); @@ -628,6 +648,8 @@ watch(locale, () => { " @click=" async () => { + console.log('dddgdfg'); + const res = await branchStore.editById( node.id, {