feat: ลบ Branch
This commit is contained in:
parent
e83282aafa
commit
f294a20161
1 changed files with 48 additions and 21 deletions
|
|
@ -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="
|
||||
() => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue