diff --git a/src/modules/04_registryNew/views/detailView.vue b/src/modules/04_registryNew/views/detailView.vue index 39cf1c172..05b45bc7b 100644 --- a/src/modules/04_registryNew/views/detailView.vue +++ b/src/modules/04_registryNew/views/detailView.vue @@ -12,6 +12,15 @@ import avatar from "@/assets/avatar_user.jpg"; import TabMain from "@/modules/04_registryNew/components/detail/TabMain.vue"; import UploadFile from "@/modules/11_discipline/components/UploadFile.vue"; import { ResponseObject } from "../interface/response/Profile"; +import DialogHeader from "@/components/DialogHeader.vue"; +/** ถึงเเก่กรรม */ +const dialogPassaway = ref(false); +const placeDeathCertificate = ref(""); +const deathCertificateNo = ref(""); +const dateDeath = ref(new Date()); +const filePassaway = ref(null); +const reasonDeath = ref(""); + const mixin = useCounterMixin(); const $q = useQuasar(); const router = useRouter(); @@ -24,6 +33,7 @@ const { messageError, success, date2Thai, + dateToISO } = mixin; const profileId = ref(route.params.id.toString()); @@ -151,52 +161,187 @@ function onClickDownloadKp7(type: string) { window.open(config.API.profileKp7ShortId(profileId.value)); } } + +/** ช่วยราชการ */ +async function helpPost() { + const formData = new FormData(); + formData.append("id", profileId.value); + dialogConfirm($q, async () => { + showLoader(); + await http + .post(config.API.placemenHelpGov, formData) + .then(() => { + success($q, "ดำเนินการสำเร็จ"); + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + hideLoader(); + router.push("/help-government"); + }); + }); +}; + +/** ส่งตัวกลับ */ +async function repatriationPost() { + const formData = new FormData(); + formData.append("id", profileId.value); + dialogConfirm($q, async () => { + showLoader(); + await http + .post(config.API.placemenRepatriation, formData) + .then(() => { + success($q, "ดำเนินการสำเร็จ"); + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + hideLoader(); + router.push("/repatriate"); + }); + }); +}; + +/** แต่งตังเลื่อน */ +async function appointPost() { + const formData = new FormData(); + formData.append("id", profileId.value); + dialogConfirm($q, async () => { + showLoader(); + await http + .post(config.API.placemenAppointment, formData) + .then(() => { + success($q, "ดำเนินการสำเร็จ"); + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + hideLoader(); + router.push("/appoint-promote"); + }); + }); +}; + +/** ถึงเเก่กรรม */ +async function clickPassaway() { + dialogPassaway.value = true; +}; + +/** ให้ออกจากราชการ */ +async function outPost() { + const formData = new FormData(); + formData.append("id", profileId.value); + dialogConfirm($q, async () => { + showLoader(); + await http + .post(config.API.retirementOut, formData) + .then(() => { + success($q, "ดำเนินการสำเร็จ"); + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + hideLoader(); + router.push("/dismiss-order"); + }); + }); +}; + +/** อื่นๆ */ +async function otherPost(){ + const formData = new FormData(); + formData.append("id", profileId.value); + dialogConfirm($q, async () => { + showLoader(); + await http + .post(config.API.placemenOther, formData) + .then(() => { + success($q, "ดำเนินการสำเร็จ"); + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + hideLoader(); + router.push("/other"); + }); + }); +}; + +function closePassaway() { + dialogPassaway.value = false; +}; + +async function clickSaveDeceased() { + const formData = new FormData(); + formData.append("File", filePassaway.value); + formData.append("Number", deathCertificateNo.value); + formData.append("Date", dateToISO(dateDeath.value)); + formData.append("Location", placeDeathCertificate.value); + formData.append("Reason", reasonDeath.value); + formData.append("ProfileId", profileId.value); + + $q.dialog({ + title: "ยืนยันการบันทึกข้อมูล", + message: "ต้องการบันทึกข้อมูลนี้ใช่หรือไม่?", + cancel: { + flat: true, + color: "negative", + }, + persistent: true, + }) + .onOk(async () => { + showLoader(); + await http + .post(config.API.listDeceased(), formData) + .then(() => { + success($q, "บันทึกข้อมูลสำเร็จ"); + router.push("/deceased"); + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => { + hideLoader(); + }); + }) + .onCancel(() => { }) + .onDismiss(() => { }); +}; + onMounted(async () => { fileName.value = `profile-${profileId.value}`; fetchProfile(profileId.value); fetchDataPersonal(); }); +