feat: ลบ Branch

This commit is contained in:
Net 2024-06-10 16:17:38 +07:00
parent e83282aafa
commit f294a20161

View file

@ -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)"
/>
</div>
</template>
@ -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);
}
"
>
<template #info>
<InfoForm>
@ -1324,6 +1350,7 @@ watch(locale, () => {
:isEdit="infoDrawerEdit"
:close="() => onCloseBranch()"
:editData="() => (infoDrawerEdit = true)"
:deleteData="() => deleteBranchId(currentBranchId)"
:data="currentCustomer"
:submit="
() => {