diff --git a/src/pages/01_branch-management/MainPage.vue b/src/pages/01_branch-management/MainPage.vue index d9e67e80..49472c85 100644 --- a/src/pages/01_branch-management/MainPage.vue +++ b/src/pages/01_branch-management/MainPage.vue @@ -13,6 +13,7 @@ import CardDetailsComponent from 'src/components/01_branch-management/CardDetail import DetailBranchDrawerComponent from 'src/components/01_branch-management/DetailBranchDrawerComponent.vue'; import FormDialog from 'src/components/FormDialog.vue'; import TableCardComponent from 'src/components/01_branch-management/TableCardComponent.vue'; +import { dialog } from 'src/stores/utils'; import { BranchContactCreate } from 'src/stores/branch-contact/types'; @@ -135,6 +136,7 @@ function clearData() { }; profileFile.value = undefined; + urlQrCode.value = false; } function openDialog() { modal.value = true; @@ -208,7 +210,19 @@ function triggerDeleteSubBranch(id: string) { formType.value = 'delete'; typeBranch.value = 'subBranch'; formData.value.headOfficeId = id; - openDialog(); + dialog({ + color: 'negative', + icon: 'mdi-alert', + title: 'ยืนยังการลบข้อมูล', + actionText: 'ตกลง', + persistent: true, + message: 'ท่านต้องการลบข้อมูลหรือมั้ย', + action: async () => { + await deleteForm(id); + await getTree(); + }, + cancel: () => {}, + }); } function triggerCreateHeadOffice() { @@ -228,11 +242,26 @@ function triggerEditHeadOffice(id: string) { openDialog(); } -function triggerDeleteHeadOffice() { +function triggerDeleteHeadOffice(id: string) { clearData(); formType.value = 'delete'; typeBranch.value = 'headOffice'; - openDialog(); + + dialog({ + color: 'negative', + icon: 'mdi-alert', + title: 'ยืนยังการลบข้อมูล', + actionText: 'ตกลง', + persistent: true, + message: 'ท่านต้องการลบข้อมูลหรือมั้ย', + action: async () => { + await deleteForm(id); + await getTree(); + }, + cancel: () => {}, + }); + + // openDialog(); } async function fetchFormEditBranch(id: string) { @@ -257,6 +286,15 @@ async function fetchFormEditBranch(id: string) { } } +async function deleteForm(idBranch: string) { + await fetchFormEditBranchContact(idBranch); + await branchContactStore.deleteById( + idBranch, + currentBranchContactIdEdit.value, + ); + await branchStore.deleteById(idBranch); +} + async function fetchFormEditBranchContact(id: string) { const result = await branchContactStore.fetchList(id); @@ -330,6 +368,7 @@ async function submitForm( currentBranchIdEdit.value, currentBranchContactIdEdit.value, inputBranchContactCreate, + profileFile.value ? profileFile.value : undefined, ); getTree(); modal.value = false; @@ -604,7 +643,7 @@ onMounted(async () => { clickable v-close-popup dense - @click="triggerDeleteHeadOffice()" + @click="triggerDeleteHeadOffice(prop.node.id)" >