เพื่มลบ

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-12-25 11:48:36 +07:00
parent b6146fb532
commit bc86ba31f0
16 changed files with 566 additions and 35 deletions

View file

@ -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"