feat:ต่อ api ลบ
This commit is contained in:
parent
39254568e7
commit
97b37e1808
1 changed files with 43 additions and 4 deletions
|
|
@ -13,6 +13,7 @@ import CardDetailsComponent from 'src/components/01_branch-management/CardDetail
|
||||||
import DetailBranchDrawerComponent from 'src/components/01_branch-management/DetailBranchDrawerComponent.vue';
|
import DetailBranchDrawerComponent from 'src/components/01_branch-management/DetailBranchDrawerComponent.vue';
|
||||||
import FormDialog from 'src/components/FormDialog.vue';
|
import FormDialog from 'src/components/FormDialog.vue';
|
||||||
import TableCardComponent from 'src/components/01_branch-management/TableCardComponent.vue';
|
import TableCardComponent from 'src/components/01_branch-management/TableCardComponent.vue';
|
||||||
|
import { dialog } from 'src/stores/utils';
|
||||||
|
|
||||||
import { BranchContactCreate } from 'src/stores/branch-contact/types';
|
import { BranchContactCreate } from 'src/stores/branch-contact/types';
|
||||||
|
|
||||||
|
|
@ -135,6 +136,7 @@ function clearData() {
|
||||||
};
|
};
|
||||||
|
|
||||||
profileFile.value = undefined;
|
profileFile.value = undefined;
|
||||||
|
urlQrCode.value = false;
|
||||||
}
|
}
|
||||||
function openDialog() {
|
function openDialog() {
|
||||||
modal.value = true;
|
modal.value = true;
|
||||||
|
|
@ -208,7 +210,19 @@ function triggerDeleteSubBranch(id: string) {
|
||||||
formType.value = 'delete';
|
formType.value = 'delete';
|
||||||
typeBranch.value = 'subBranch';
|
typeBranch.value = 'subBranch';
|
||||||
formData.value.headOfficeId = id;
|
formData.value.headOfficeId = id;
|
||||||
openDialog();
|
dialog({
|
||||||
|
color: 'negative',
|
||||||
|
icon: 'mdi-alert',
|
||||||
|
title: 'ยืนยังการลบข้อมูล',
|
||||||
|
actionText: 'ตกลง',
|
||||||
|
persistent: true,
|
||||||
|
message: 'ท่านต้องการลบข้อมูลหรือมั้ย',
|
||||||
|
action: async () => {
|
||||||
|
await deleteForm(id);
|
||||||
|
await getTree();
|
||||||
|
},
|
||||||
|
cancel: () => {},
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function triggerCreateHeadOffice() {
|
function triggerCreateHeadOffice() {
|
||||||
|
|
@ -228,11 +242,26 @@ function triggerEditHeadOffice(id: string) {
|
||||||
openDialog();
|
openDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
function triggerDeleteHeadOffice() {
|
function triggerDeleteHeadOffice(id: string) {
|
||||||
clearData();
|
clearData();
|
||||||
formType.value = 'delete';
|
formType.value = 'delete';
|
||||||
typeBranch.value = 'headOffice';
|
typeBranch.value = 'headOffice';
|
||||||
openDialog();
|
|
||||||
|
dialog({
|
||||||
|
color: 'negative',
|
||||||
|
icon: 'mdi-alert',
|
||||||
|
title: 'ยืนยังการลบข้อมูล',
|
||||||
|
actionText: 'ตกลง',
|
||||||
|
persistent: true,
|
||||||
|
message: 'ท่านต้องการลบข้อมูลหรือมั้ย',
|
||||||
|
action: async () => {
|
||||||
|
await deleteForm(id);
|
||||||
|
await getTree();
|
||||||
|
},
|
||||||
|
cancel: () => {},
|
||||||
|
});
|
||||||
|
|
||||||
|
// openDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchFormEditBranch(id: string) {
|
async function fetchFormEditBranch(id: string) {
|
||||||
|
|
@ -257,6 +286,15 @@ async function fetchFormEditBranch(id: string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function deleteForm(idBranch: string) {
|
||||||
|
await fetchFormEditBranchContact(idBranch);
|
||||||
|
await branchContactStore.deleteById(
|
||||||
|
idBranch,
|
||||||
|
currentBranchContactIdEdit.value,
|
||||||
|
);
|
||||||
|
await branchStore.deleteById(idBranch);
|
||||||
|
}
|
||||||
|
|
||||||
async function fetchFormEditBranchContact(id: string) {
|
async function fetchFormEditBranchContact(id: string) {
|
||||||
const result = await branchContactStore.fetchList(id);
|
const result = await branchContactStore.fetchList(id);
|
||||||
|
|
||||||
|
|
@ -330,6 +368,7 @@ async function submitForm(
|
||||||
currentBranchIdEdit.value,
|
currentBranchIdEdit.value,
|
||||||
currentBranchContactIdEdit.value,
|
currentBranchContactIdEdit.value,
|
||||||
inputBranchContactCreate,
|
inputBranchContactCreate,
|
||||||
|
profileFile.value ? profileFile.value : undefined,
|
||||||
);
|
);
|
||||||
getTree();
|
getTree();
|
||||||
modal.value = false;
|
modal.value = false;
|
||||||
|
|
@ -604,7 +643,7 @@ onMounted(async () => {
|
||||||
clickable
|
clickable
|
||||||
v-close-popup
|
v-close-popup
|
||||||
dense
|
dense
|
||||||
@click="triggerDeleteHeadOffice()"
|
@click="triggerDeleteHeadOffice(prop.node.id)"
|
||||||
>
|
>
|
||||||
<q-item-section avatar class="q-py-sm">
|
<q-item-section avatar class="q-py-sm">
|
||||||
<q-icon
|
<q-icon
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue