เพื่มลบ
This commit is contained in:
parent
b6146fb532
commit
bc86ba31f0
16 changed files with 566 additions and 35 deletions
|
|
@ -22,6 +22,7 @@ const {
|
|||
success,
|
||||
date2Thai,
|
||||
onSearchDataTable,
|
||||
dialogRemove,
|
||||
} = useCounterMixin();
|
||||
|
||||
/**
|
||||
|
|
@ -106,9 +107,11 @@ async function fetchData() {
|
|||
|
||||
const list = data.map((e: FormDistrict) => ({
|
||||
...e,
|
||||
createdAt: e.createdAt ? date2Thai(new Date(e.createdAt),false,true) : "",
|
||||
createdAt: e.createdAt
|
||||
? date2Thai(new Date(e.createdAt), false, true)
|
||||
: "",
|
||||
lastUpdatedAt: e.lastUpdatedAt
|
||||
? date2Thai(new Date(e.lastUpdatedAt),false,true)
|
||||
? date2Thai(new Date(e.lastUpdatedAt), false, true)
|
||||
: "",
|
||||
}));
|
||||
rows.value = list;
|
||||
|
|
@ -168,6 +171,29 @@ async function editData(id: string) {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* ลบข้อมูลรายการระดับการเขต/อำเภอ
|
||||
* แล้ว fetch ข้อมูลรายการ ข้อมูลรายการระดับการเขต/อำเภอ ใหม่
|
||||
* @param id ข้อมูลรายการระดับการเขต/อำเภอ
|
||||
*/
|
||||
async function onDeleteData(id: string) {
|
||||
dialogRemove($q, async () => {
|
||||
showLoader();
|
||||
await http
|
||||
.delete(config.API.orgDistrict + `/${id}`)
|
||||
.then(async () => {
|
||||
await fetchData();
|
||||
success($q, "ลบข้อมูลสำเร็จ");
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* ไปยังหน้า รายการเแขวง/ตำบลโดย id ของเขต/อำเภอ
|
||||
* @param idSub เขต/อำเภอ
|
||||
|
|
@ -283,7 +309,6 @@ onMounted(async () => {
|
|||
flat
|
||||
dense
|
||||
round
|
||||
class="q-mr-xs"
|
||||
icon="edit"
|
||||
clickable
|
||||
@click.stop="
|
||||
|
|
@ -297,6 +322,16 @@ onMounted(async () => {
|
|||
>
|
||||
<q-tooltip>แก้ไขข้อมูล</q-tooltip>
|
||||
</q-btn>
|
||||
<q-btn
|
||||
color="red"
|
||||
flat
|
||||
dense
|
||||
round
|
||||
icon="delete"
|
||||
@click.stop.prevent="onDeleteData(props.row.id)"
|
||||
>
|
||||
<q-tooltip>ลบข้อมูล</q-tooltip>
|
||||
</q-btn>
|
||||
</q-td>
|
||||
<q-td
|
||||
v-for="col in props.cols"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue