feat(): add handleDelete director meeting

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2026-04-01 13:40:50 +07:00
parent a6018507c9
commit 546942f8fb
2 changed files with 69 additions and 4 deletions

View file

@ -9,7 +9,7 @@ import config from "@/app.config";
/** importType*/
import type { QTableProps } from "quasar";
import type { Director } from "@/modules/11_discipline/interface/request/Disciplinary";
import type { Director } from "@/modules/11_discipline/interface/request/disciplinary";
import type { Directors } from "@/modules/12_evaluatePersonal/interface/response/Main";
/** importComponents*/
@ -20,7 +20,14 @@ import DialogDuty from "@/modules/12_evaluatePersonal/components/Detail/viewTab2
const $q = useQuasar();
const route = useRoute();
const mixin = useCounterMixin();
const { showLoader, hideLoader, messageError, dialogConfirm, success } = mixin;
const {
showLoader,
hideLoader,
messageError,
dialogConfirm,
success,
dialogRemove,
} = mixin;
const props = defineProps({
data: {
@ -201,6 +208,21 @@ function onEditDuty(data: Director) {
modalDuty.value = true;
}
function handleDelete(id: string) {
dialogRemove($q, async () => {
showLoader();
try {
await http.delete(config.API.evaluateDirectorMain() + `/admin/${id}`);
await props.fetchData();
await success($q, "ลบสำเร็จ");
} catch (error) {
messageError($q, error);
} finally {
hideLoader();
}
});
}
/**
* ทำงานเม props.data การเปลยนแปลง
*/
@ -268,17 +290,30 @@ watch(
</template>
<template v-slot:body="props">
<q-tr :props="props">
<q-td>
<q-td auto-width>
<q-btn
v-if="checkPermission($route)?.attrIsUpdate"
flat
round
denes
dense
icon="edit"
color="edit"
@click.stop.prevent="onEditDuty(props.row)"
>
<q-tooltip>แกไขหนาท</q-tooltip>
</q-btn>
<q-btn
v-if="checkPermission($route)?.attrIsDelete"
flat
round
dense
icon="delete"
color="red"
@click="handleDelete(props.row.id)"
>
<q-tooltip>ลบ</q-tooltip>
</q-btn>
</q-td>
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'no'">

View file

@ -27,6 +27,7 @@ const {
dialogConfirm,
date2Thai,
success,
dialogRemove,
} = mixin;
/** props*/
@ -208,6 +209,21 @@ async function getList() {
});
}
function handleDelete(id: string) {
dialogRemove($q, async () => {
showLoader();
try {
await http.delete(config.API.meeting() + `/admin/${id}`);
await props.fetchData();
await success($q, "ลบสำเร็จ");
} catch (error) {
messageError($q, error);
} finally {
hideLoader();
}
});
}
watch(
() => props.data,
() => {
@ -265,6 +281,7 @@ watch(
>
<template v-slot:header="props">
<q-tr :props="props">
<q-th auto-width />
<q-th v-for="col in props.cols" :key="col.name" :props="props">
<span class="text-weight-medium">{{ col.label }}</span>
</q-th>
@ -272,6 +289,19 @@ watch(
</template>
<template v-slot:body="props">
<q-tr :props="props">
<q-th auto-width>
<q-btn
v-if="checkPermission($route)?.attrIsUpdate"
flat
round
dense
icon="delete"
color="red"
@click="handleDelete(props.row.id)"
>
<q-tooltip>ลบ</q-tooltip>
</q-btn>
</q-th>
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'no'">
{{ props.rowIndex + 1 }}