feat(): add handleDelete director meeting
This commit is contained in:
parent
a6018507c9
commit
546942f8fb
2 changed files with 69 additions and 4 deletions
|
|
@ -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'">
|
||||
|
|
|
|||
|
|
@ -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 }}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue