diff --git a/src/pages/03_customer-management/MainPage.vue b/src/pages/03_customer-management/MainPage.vue index d861341d..29bee311 100644 --- a/src/pages/03_customer-management/MainPage.vue +++ b/src/pages/03_customer-management/MainPage.vue @@ -319,6 +319,46 @@ function clearForm() { }; } +function deleteCustomerById(id: string) { + dialog({ + color: 'negative', + icon: 'mdi-alert', + title: t('deleteConfirmTitle'), + actionText: t('ok'), + persistent: true, + message: t('deleteConfirmMessage'), + action: async () => { + await userCustomer.deleteById(id); + + const resultList = await fetchList({ includeBranch: true }); + + if (resultList) listCustomer.value = resultList.result; + infoDrawer.value = false; + }, + cancel: () => {}, + }); +} + +function deleteBranchId(id: string) { + dialog({ + color: 'negative', + icon: 'mdi-alert', + title: t('deleteConfirmTitle'), + actionText: t('ok'), + persistent: true, + message: t('deleteConfirmMessage'), + action: async () => { + await userCustomer.deleteBranchById(id); + + const result = await fetchListById(currentCustomerId.value); + + if (result) branch.value = result.branch; + infoDrawerBranch.value = false; + }, + cancel: () => {}, + }); +} + async function onSubmit() { await create({ ...formData.value, @@ -661,28 +701,12 @@ watch(locale, () => { " @view-card=" () => { + currentCustomerId = i.id; assignFormData(i); openDialogInputForm('INFO', i.id); } " - @delete-card=" - dialog({ - color: 'negative', - icon: 'mdi-alert', - title: $t('deleteConfirmTitle'), - actionText: $t('ok'), - persistent: true, - message: $t('deleteConfirmMessage'), - action: async () => { - await userCustomer.deleteById(i.id); - - const resultList = await fetchList({ includeBranch: true }); - - if (resultList) listCustomer = resultList.result; - }, - cancel: () => {}, - }) - " + @delete-card="deleteCustomerById(i.id)" /> @@ -724,9 +748,6 @@ watch(locale, () => { @viewDetail=" (v) => { infoDrawerBranch = true; - - console.log(v); - currentCustomerId = v.id; currentBranchId = v.branch[0].id; @@ -1134,6 +1155,11 @@ watch(locale, () => { :editData="() => (infoDrawerEdit = true)" :data="currentCustomer" :submit="() => onSubmitEdit(currentCustomerId)" + :deleteData=" + () => { + deleteCustomerById(currentCustomerId); + } + " >