api ปลดออก ไล่ออก ให้ออก

เพิ่ม form / q dialogmassage delete
This commit is contained in:
AnandaTon 2023-08-16 17:12:32 +07:00
parent df7364f7b8
commit 9ab5d441e2
7 changed files with 630 additions and 195 deletions

View file

@ -26,7 +26,14 @@ const router = useRouter();
const mixin = useCounterMixin();
const transferStore = useTransferDataStore();
const { date2Thai, messageError, showLoader, hideLoader, success } = mixin;
const {
date2Thai,
messageError,
showLoader,
hideLoader,
success,
dialogMessage,
} = mixin;
const { statusText } = transferStore;
const modal = ref<boolean>(false);
@ -36,7 +43,6 @@ const visibleColumns = ref<string[]>([
"position",
"positionLevel",
"organizationPositionOld",
"organization",
"statustext",
]);
const visibleColumns2 = ref<string[]>([
@ -45,7 +51,6 @@ const visibleColumns2 = ref<string[]>([
"position",
"positionLevel",
"organizationPositionOld",
"organization",
"statustext",
]); //
const filterKeyword = ref<string>("");
@ -109,15 +114,6 @@ const columns = ref<QTableProps["columns"]>([
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "organization",
align: "left",
label: "หน่วยงานที่ขอโอนไป",
sortable: true,
field: "organization",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "statustext",
align: "left",
@ -174,15 +170,6 @@ const columns2 = ref<QTableProps["columns"]>([
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "organization",
align: "left",
label: "หน่วยงานที่ขอโอนไป",
sortable: true,
field: "organization",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "statustext",
align: "left",
@ -254,33 +241,32 @@ const getData = async () => {
});
};
const clickDelete = (id: string) => {
$q.dialog({
title: "ยืนยันการลบข้อมูล",
message: "ต้องการลบข้อมูลนี้ใช่หรือไม่?",
cancel: {
flat: true,
color: "negative",
},
persistent: true,
})
.onOk(async () => {
showLoader();
await http
.delete(config.API.outByid(id))
.then((res) => {
success($q, "ลบข้อมูลสำเร็จ");
getData();
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
const clickDelete = async (name: string, id: string) => {
dialogMessage(
$q,
`ลบข้อมูล`,
`ต้องการทำการลบข้อมูลนี้ใช่หรือไม่?`,
"delete",
"ยืนยัน",
"red",
async () => await deleteData(id),
async () => await getData()
);
};
const deleteData = async (id: string) => {
await http
.delete(config.API.outByid(id))
.then((res) => {
success($q, "ลบข้อมูลสำเร็จ");
console.log(res);
})
.onCancel(() => {})
.onDismiss(() => {});
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
await getData();
});
};
const saveOrder = async () => {