diff --git a/src/pages/03_customer-management/MainPage.vue b/src/pages/03_customer-management/MainPage.vue index 02a88e89..ddd9a899 100644 --- a/src/pages/03_customer-management/MainPage.vue +++ b/src/pages/03_customer-management/MainPage.vue @@ -182,6 +182,7 @@ const { editBranchById, fetchListCustomeBranch, fetchListCustomeBranchById, + deleteBranchById, } = userCustomer; const flowStore = useFlowStore(); const employeeStore = useEmployeeStore(); @@ -1041,6 +1042,25 @@ async function onSubmitEmployee( }); } +async function deleteByIdBranch(id: string, indexTab: number) { + dialog({ + color: 'info', + icon: 'mdi-alert', + title: t('saveConfirmTitle'), + actionText: t('ok'), + persistent: true, + message: t('saveConfirmMessage'), + action: async () => { + await deleteBranchById(id); + + formData.value.customerBranch?.splice(indexTab, 1); + + flowStore.rotate(); + }, + cancel: () => {}, + }); +} + async function onSubmitBasicInformation() { if (selectorLabel.value === 'EMPLOYER') { dialog({ @@ -1085,10 +1105,15 @@ async function onSubmitCustomerBranch(opt: { isClearForm: boolean }) { formData.value.customerBranch !== undefined && formData.value.customerBranch[indexTab.value] !== undefined ) { - await createBranch({ + const res = await createBranch({ ...formData.value.customerBranch[indexTab.value], customerId: currentCustomerId.value, }); + + if (res) { + formData.value.customerBranch[indexTab.value].id = res.id; + formData.value.customerBranch[indexTab.value].statusSave = true; + } } }, cancel: () => {}, @@ -3285,6 +3310,7 @@ watch(isMainPage, () => { v-model:customer-branch="formData.customerBranch" v-model:tab-index="indexTab" @save="() => onSubmitCustomerBranch({ isClearForm: false })" + @remove="(indexTab, id) => deleteByIdBranch(id, indexTab)" >