From f294a2016143a3f128572248f0655899647c432b Mon Sep 17 00:00:00 2001 From: Net <93821485+somnetsak123@users.noreply.github.com> Date: Mon, 10 Jun 2024 16:17:38 +0700 Subject: [PATCH] =?UTF-8?q?feat:=20=E0=B8=A5=E0=B8=9A=20=20Branch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/03_customer-management/MainPage.vue | 69 +++++++++++++------ 1 file changed, 48 insertions(+), 21 deletions(-) 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); + } + " >