hrms-mgt/src/modules/06_retirement/components/03_resignEmp/ResignByid.vue
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 a561e2e3e5 fix:Permission_Update
2026-01-06 16:53:20 +07:00

1736 lines
56 KiB
Vue

<script setup lang="ts">
import { ref, onMounted, computed } from "vue";
import axios from "axios";
import { useRouter, useRoute } from "vue-router";
import { useQuasar, QForm } from "quasar";
import http from "@/plugins/http";
import config from "@/app.config";
import genReport from "@/plugins/genreport";
import { useCounterMixin } from "@/stores/mixin";
import { useRetirementDataStore } from "@/modules/06_retirement/store/Main";
import { useRoleWorkflowDataStore } from "@/stores/roleWorkflow";
import { checkPermission } from "@/utils/permissions";
import type {
TypeFile,
rowFile,
FileList,
} from "@/modules/06_retirement/interface/response/Main";
import type { QTableProps } from "quasar";
import type { DataProfile } from "@/modules/05_placement/interface/index/Main";
import type {
RowsType,
SeqTypeRow,
} from "@/modules/06_retirement/interface/response/Main";
import DialogHeader from "@/components/DialogHeader.vue";
import PopupPersonal from "@/components/Dialogs/PopupPersonalNew.vue";
import CardProfile from "@/components/CardProfile.vue";
import DialogAddCommander from "@/modules/06_retirement/components/DialogAddCommander.vue";
import DialogFormResign from "@/modules/06_retirement/components/DialogFormResign.vue";
/** Use */
const $q = useQuasar();
const route = useRoute();
const router = useRouter();
const store = useRetirementDataStore();
const { fetchDataCheckIsoffice } = useRoleWorkflowDataStore();
const { convertStatusText } = store;
const checkRoutePermisson = ref<boolean>(route.name == "resignDetailbyidEMP");
const mixin = useCounterMixin();
const {
messageError,
date2Thai,
showLoader,
hideLoader,
success,
dialogConfirm,
dialogRemove,
convertDateToAPI,
} = mixin;
/** ตัวแปร */
const modalPersonal = ref<boolean>(false);
const personId = ref<string>("");
const roleUser = ref<string>("");
const dataProfile = ref<DataProfile>();
const approveStep = ref<string>("");
const idCheck = computed(() => {
if (
typeAdd.value == "COMMANDER" &&
rowsApprover.value?.commanders &&
rowsApprover.value?.commanders.length > 0
) {
return rowsApprover.value?.commanders.map(
(items: SeqTypeRow) => items.profileId
);
} else if (
typeAdd.value == "APPROVER" &&
rowsApprover.value?.approvers &&
rowsApprover.value?.approvers.length > 0
) {
return rowsApprover.value?.approvers.map(
(items: SeqTypeRow) => items.profileId
);
}
});
const isOfficer = ref<boolean>(false);
const isStaff = ref<boolean>(false);
const profileType = ref<string>("");
const keycloakUserId = ref<string>("");
const keycloakId = ref<string>("");
const modalAdd = ref<boolean>(false);
const typeAdd = ref<string>("");
const statusCheck = ref<string>("");
const rowsApprover = ref<RowsType>();
const columnsCommanders = ref<QTableProps["columns"]>([
{
name: "no",
align: "left",
label: "ลำดับ",
sortable: true,
field: "no",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "fullName",
align: "left",
label: "ชื่อ-นามสกุล",
sortable: true,
field: "fullName",
format(val, row) {
return `${row.prefix}${row.firstName} ${row.lastName}`;
},
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "positionName",
align: "left",
label: "ตำแหน่ง",
sortable: true,
field: "positionName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "approveStatus",
align: "left",
label: "สถานะ",
sortable: true,
field: "approveStatus",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "comment",
align: "left",
label: "ความคิดเห็นและเหตุผล",
field: "comment",
sortable: true,
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "rejectDate",
align: "left",
label: "วันสุดท้ายที่ยับยั้ง",
field: "rejectDate",
format(val, row) {
return date2Thai(val);
},
sortable: true,
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
]);
const id = ref<string>(route.params.id.toString());
const myForm = ref<QForm | null>(null);
const edit = ref<boolean>(false);
const conditions = ref<boolean>(false);
const dataDetail = ref<any>({
datetext: "",
activeDate: new Date(),
createdAt: new Date(),
firstName: "",
id: "",
isActive: true,
lastName: "",
location: "",
organizationPositionOld: "",
positionLevelOld: "",
positionNumberOld: "",
positionTypeOld: "",
prefix: "",
profileId: "",
reason: "",
salary: 0,
sendDate: new Date(),
status: "",
statustext: "",
fullname: "",
statusMain: "",
cancelReason: "",
remark: "",
reasonResign: "",
});
const organizationPositionOld = ref<string>("");
const positionTypeOld = ref<string>("");
const positionLevelOld = ref<string>("");
const posNo = ref<string>("");
const salary = ref<number>(0);
const date = ref<Date | null>(null);
const dateLeave = ref<Date | null>(null);
const reason = ref<string>("");
const location = ref<string>("");
const status = ref<string>("");
const remarkHorizontal = ref<string>("");
const modal = ref<boolean>(false);
const actionPass = ref<boolean>(false);
const reasonReign = ref<string>("");
const dateBreak = ref<Date | null>(null);
/** คอลัมน์ */
const rows = ref<TypeFile[]>([]);
const columns = ref<QTableProps["columns"]>([
{
name: "no",
align: "left",
label: "ลำดับ",
sortable: true,
field: "no",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "fileName",
align: "left",
label: "ชื่อไฟล์",
sortable: true,
field: "fileName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "btnMicrosoft",
align: "right",
label: "ปุ่ม",
sortable: true,
field: "btnMicrosoft",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
]);
const modalFormResign = ref<boolean>(false);
/**ฟังก์ชันปิด popup อนุญาตการลาออก,ยับยั้งการลาออก*/
function closeModal() {
modal.value = false;
}
const file = ref<any>(null);
const fileList = ref<FileList[]>([]);
const isNoDebt = ref<boolean>(false);
const isNoBurden = ref<boolean>(false);
const isDiscipline = ref<boolean>(false);
// เอกสารดาวน์โหลด
const rowsFileDownload = ref<rowFile[]>([
{
fileName: "แบบฟอร์มหนังสือขอลาออกจากราชการ",
pathName: "",
},
]);
/** ฟังก์ชันคำนวนวันที่ขอลาออกจากราชการ*/
function diffDate() {
if (date.value !== null && dateLeave.value !== null) {
const time = dateLeave.value.getTime() - date.value.getTime();
//วันที่ขอลาออกจากราชการ - วันที่ยื่นขอลาออกจากราชการ
const day = time / (1000 * 3600 * 24);
if (day < 30) {
return true;
}
return false;
}
return false;
}
/**
* ฟังก์ชันดึงข้อมูลรายละเอียดการลาออก
* @param id รายการลาออก
*/
async function fetchData(id: string) {
await http
.get(config.API.resingByidEMP(id))
.then(async (res) => {
const data = await res.data.result;
dataProfile.value = data as DataProfile;
let list: TypeFile[] = [];
if (data.docs.length > 0) {
data.docs.map((doc: TypeFile) => {
list.push({
pathName: doc.pathName ?? "",
fileName: doc.fileName ?? "",
});
});
}
rows.value = list;
dataDetail.value = data;
organizationPositionOld.value = data.organizationPositionOld ?? "";
positionTypeOld.value = data.positionTypeOld ?? "";
positionLevelOld.value = data.positionLevelOld ?? "";
posNo.value = data.positionNumberOld ?? "";
salary.value = data.salary ? data.salary : 0;
date.value = data.sendDate ? new Date(data.sendDate) : null;
dateLeave.value = data.activeDate ? new Date(data.activeDate) : null;
reason.value = data.reasonResign ?? "";
location.value = data.location ?? "";
status.value = data.status ?? "";
remarkHorizontal.value = data.remarkHorizontal ?? "-";
isNoDebt.value = data.isNoDebt;
isNoBurden.value = data.isNoBurden;
isDiscipline.value = data.isDiscipline;
approveStep.value = data.approveStep;
statusCheck.value = data.status;
profileType.value = data.profileType;
keycloakUserId.value = data.keycloakUserId;
rowsApprover.value = {
commanders: data.commanders,
approvers: data.approvers,
};
})
.catch((e) => {
messageError($q, e);
});
}
/**
* ฟังก์ชันเปิด popup อนุญาต,ยับยั้ง
* @param action อนุญาต, ยับยั้ง
* @param type ผู้บังคับบัญชา, ผู้มีอำนาจ
*/
function popUp(action: "pass" | "passNot", type: string) {
reasonReign.value = "";
dateBreak.value = null;
actionPass.value = action === "pass";
roleUser.value = type;
modal.value = true;
}
/** ฟังก์ชันบันทึกผลการพิจารณา*/
function onSubmit() {
if (roleUser.value === "commander" && actionPass.value) {
confirmpopUp("/comander");
} else if (roleUser.value === "commander" && !actionPass.value) {
rejectpopUp("/comander");
} else if (roleUser.value === "oligarch" && actionPass.value) {
confirmpopUp("");
} else if (roleUser.value === "oligarch" && !actionPass.value) {
rejectpopUp("");
}
}
/**
* ฟังก์ชันยืนยันการอนุญาตผลการพิจารณา
* @param path ประเภทของผู้พิจารณา comander === 'บังคับบัญชา', '' === 'ผู้มีอำนาจ'
*/
async function confirmpopUp(path: string) {
dialogConfirm(
$q,
async () => {
showLoader();
const body = {
reason: reasonReign.value,
};
await http
.put(
config.API.commanderApproveRetirement(
"-employee",
id.value,
"approve",
path
),
body
)
.then(async () => {
await fetchData(id.value);
closeModal();
success($q, "การอนุญาตสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
},
"ยืนยันการอนุญาต",
"ต้องการยืนยันการอนุญาตการลานี้หรือไม่ ?"
);
}
/**
ฟังก์ชันยืนยันการยับยั้งผลการพิจารณา
* @param path ประเภทของผู้พิจารณา comander === 'บังคับบัญชา', '' === 'ผู้มีอำนาจ'
*/
async function rejectpopUp(path: string) {
dialogConfirm(
$q,
async () => {
showLoader();
const body = {
reason: reasonReign.value,
date: dateBreak.value,
};
await http
.put(
config.API.commanderApproveRetirement(
"-employee",
id.value,
"reject",
path
),
body
)
.then(async () => {
await fetchData(id.value);
closeModal();
success($q, "การยับยั้งสำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
},
"ยืนยันการยับยั้ง",
"ต้องการยืนยันการยับยั้งนี้หรือไม่ ?"
);
}
/** ฟังก์ชันยกเลิกการแก้ไขข้อมูลเพื่อลงบัญชีแนบท้าย*/
async function clickCancel() {
edit.value = false;
const data = dataDetail.value;
if (data) {
organizationPositionOld.value = data.organizationPositionOld ?? "";
positionTypeOld.value = data.positionTypeOld ?? "";
positionLevelOld.value = data.positionLevelOld ?? "";
posNo.value = data.positionNumberOld ?? "";
salary.value = data.salary ? data.salary : 0;
date.value = data.sendDate ? new Date(data.sendDate) : null;
dateLeave.value = data.activeDate ? new Date(data.activeDate) : null;
reason.value = data.reasonResign ?? "";
location.value = data.location ?? "";
status.value = data.status ?? "";
remarkHorizontal.value = data.remarkHorizontal ?? "-";
isNoDebt.value = data.isNoDebt;
isNoBurden.value = data.isNoBurden;
isDiscipline.value = data.isDiscipline;
}
myForm.value?.resetValidation();
}
/** ฟังก์ขันยกเลิกการแก้ไขเงื่อนไขต่างๆ*/
async function clickCancelConditions() {
const data = dataDetail.value;
if (data) {
isNoDebt.value = data.isNoDebt;
isNoBurden.value = data.isNoBurden;
isDiscipline.value = data.isDiscipline;
conditions.value = false;
}
}
/** ฟังก์ชันบันทึกรายการตรวจสอบเงื่อนไขต่างๆ*/
function onSubmitConditions() {
dialogConfirm($q, async () => {
showLoader();
await http
.put(config.API.resignConditionsEMP(id.value), {
isNoDebt: isNoDebt.value,
isNoBurden: isNoBurden.value,
isDiscipline: isDiscipline.value,
})
.then(async () => {
await fetchData(id.value);
success($q, "บันทึกเงื่อนไขต่างๆ สำเร็จ");
conditions.value = false;
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
});
}
/** ฟังก์ชันบันทึกข้อมูลเพื่อลงบัญชีแนบท้าย*/
function onSubmitAttached() {
dialogConfirm($q, () => {
const formData = new FormData();
const send = convertDateToAPI(date.value) ?? "";
const activeDate = convertDateToAPI(dateLeave.value) ?? "";
formData.append("Location", location.value);
formData.append("SendDate", send);
formData.append("ActiveDate", activeDate);
formData.append("Reason", reason.value);
formData.append("OrganizationPositionOld", organizationPositionOld.value);
formData.append("PositionTypeOld", positionTypeOld.value);
formData.append("PositionLevelOld", positionLevelOld.value);
formData.append("PositionNumberOld", posNo.value);
formData.append("AmountOld", salary.value.toString());
formData.append("remarkHorizontal", remarkHorizontal.value);
showLoader();
http
.put(config.API.resingByidEMP(id.value), formData)
.then(async () => {
await fetchData(id.value);
success($q, "บันทึกข้อมูลสำเร็จ");
edit.value = false;
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
});
}
/**
* ฟังก์ชัน Class เวลา Edit
* @param val เมื่อเป็นEdit จะเปลี่ยน Class
*/
function getClass(val: boolean) {
return {
"full-width inputgreen cursor-pointer": val,
"full-width cursor-pointer": !val,
};
}
/**
* ฟังก์ชันดาว์นโหลดไฟล์
* @param type นามสกุลไฟล์
* @param fileName ชื่อไฟล์ที่ต้องการโหลด
*/
async function fileDownload(type: string, fileName: string) {
showLoader();
await http
.get(config.API.reportResignList(type, id.value))
.then(async (res) => {
const data = res.data.result;
await genReport(data, `${fileName}`, type);
})
.catch(async (e) => {
messageError($q, JSON.parse(await e.response.data.text()));
})
.finally(() => {
hideLoader();
});
}
/**
* ฟังก์ชันอัปเดท modal ของ popup ทะเบียนประวัติ
* @param modal modal
*/
function updatemodalPersonal(modal: boolean) {
modalPersonal.value = modal;
}
/** ฟังก์ชันดึงข้อมูลไฟล์*/
async function fetchFile() {
await http
.get(config.API.file("พ้นจากราชการ", "หลักฐานลาออก", id.value))
.then(async (res) => {
fileList.value = await res.data;
})
.catch((e) => {
messageError($q, e);
});
}
/** ฟังก์ชันสร้าง Path ที่เก็บไฟล์*/
function uploadFiles() {
showLoader();
http
.post(config.API.file("พ้นจากราชการ", "หลักฐานลาออก", id.value), {
replace: true,
fileList: [
{
fileName: file.value.name,
},
],
})
.then(async (res) => {
const foundKey: string | undefined = Object.keys(res.data).find(
(key) =>
res.data[key]?.fileName !== undefined &&
res.data[key]?.fileName !== ""
);
foundKey && (await uploadFileURL(res.data[foundKey]?.uploadUrl));
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
}
/**
* ฟังก์ชันอัปโหลดไฟล์
* @param uploadUrl ที่อยู่ที่เก็บไฟล์
*/
async function uploadFileURL(uploadUrl: string) {
const Data = new FormData();
Data.append("file", file.value);
showLoader();
await axios
.put(uploadUrl, file.value, {
headers: {
"Content-Type": file.value.type,
},
})
.then(async () => {
await fetchFile();
success($q, "อัปโหลดไฟล์สำเร็จ");
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
file.value = null;
});
}
/**
* ฟังก์ชันโหลดไฟล์
* @param fileName ชื่อไฟล์ที่ต้องการโหลด
*/
async function downloadFiles(fileName: string) {
showLoader();
await http
.get(
config.API.fileByFile("พ้นจากราชการ", "หลักฐานลาออก", id.value, fileName)
)
.then(async (res) => {
const data = await res.data.downloadUrl;
window.open(data, "_blank");
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
});
}
/**
* ฟังก์ชันลบไฟล์
* @param fileName ชื่อไฟล์ที่ต้องการลบ
*/
function removeFile(fileName: string) {
dialogRemove($q, async () => {
showLoader();
await http
.delete(
config.API.fileByFile(
"พ้นจากราชการ",
"หลักฐานลาออก",
id.value,
fileName
)
)
.then(async () => {
setTimeout(async () => {
await fetchFile();
success($q, `ลบไฟล์สำเร็จ`);
}, 1000);
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
});
}
/**
* ฟังก์ชันแปลงเหตุผลที่ลาออก
* @param val เหตุผลที่ลาออก
*/
function convertStatus(val: string) {
if (/^[A-Za-z]+$/.test(val)) {
switch (val) {
case "CAREER":
return "ประกอบอาชีพอื่น";
case "MOVE":
return "รับราชการสังกัดอื่น";
case "FAMILY":
return "ดูแลบิดามารดา";
case "EDUCATION":
return "ศึกษาต่อ";
case "OTHER":
return "อื่น ๆ";
}
} else return val;
}
/**
* ฟังกฺชันเปิด pop up เพิ่มรายชื่อพิจารณา
* @param type COMMANDER === ผู้บังคับบัญชา, APPROVER === ผู้มีอำนาจ
*/
function onAddPerson(type: string) {
modalAdd.value = true;
typeAdd.value = type;
}
/** ฟังก์ชันดึงข้อมูลสิทธ์ของผู้ใช่*/
async function checkOfficer() {
try {
const data = await fetchDataCheckIsoffice("SYS_RESIGN_EMP");
isOfficer.value = data.isOfficer;
isStaff.value = data.isStaff;
} catch (err) {
messageError($q, err);
}
}
/** ฟังก์ชันยืนยันการส่งไปพิจารณา*/
function onSend() {
dialogConfirm(
$q,
() => {
showLoader();
http
.get(config.API.sendApproveRetirement("-employee", id.value))
.then(async () => {
await fetchData(id.value);
success($q, "ส่งไปพิจารณา");
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
},
"ยืนยันการส่งไปพิจารณา",
"ต้องการส่งไปพิจารณาใช่หรือไม่"
);
}
/** ฟังก์ชันดึงข้อมูลตำแหน่งจาก Keycloak*/
async function fetchKeycloakPosition() {
if (keycloakId.value == "") {
await http
.get(config.API.keycloakPosition())
.then(async (res) => {
const data = await res.data.result;
keycloakId.value = data.profileId;
})
.catch((err) => {
messageError($q, err);
});
}
}
/** Hook */
onMounted(async () => {
showLoader();
await Promise.all([
fetchData(id.value),
fetchKeycloakPosition(),
fetchFile(),
checkOfficer(),
]).finally(() => {
hideLoader();
});
});
</script>
<template>
<div class="q-pa-sm">
<div class="toptitle text-dark col-12 row items-center">
<q-btn
icon="mdi-arrow-left"
unelevated
round
dense
flat
color="primary"
class="q-mr-sm"
@click="router.push('/retirement/resign-employee')"
/>
รายละเอยดการลาออก
{{
dataDetail.prefix + dataDetail.firstName + " " + dataDetail.lastName
}}
<span v-if="dataDetail.statusMain === 'CANCELING'" class="text-red">
&nbsp;(อยู่ระหว่างการขอยกเลิกลาออก)
</span>
</div>
<CardProfile :type="'employee'" :data="dataProfile as DataProfile" />
<!-- ข้อมูลการลาออก -->
<q-card bordered class="row col-12 text-dark q-mt-sm">
<div class="bg-grey-1 q-pa-sm col-12 row items-center text-primary">
<div class="q-pl-sm text-weight-bold text-dark">ข้อมูลการลาออก</div>
<q-space />
<div
v-if="
isStaff &&
status === 'WAITTING' &&
checkPermission($route)?.attrIsUpdate
"
>
<q-btn
outline
color="primary"
dense
icon-right="mdi-file-edit-outline"
class="q-px-sm"
label="แก้ไข"
@click="modalFormResign = !modalFormResign"
/>
</div>
</div>
<div class="col-12"><q-separator /></div>
<div class="row col-12 q-pa-md">
<div class="col-12 row bg-white q-col-gutter-md">
<div class="col-xs-6 col-sm-3 row items-start">
<div class="col-12">
<div class="col-12 text-top">สถานที่ยื่นขอลาออกจากราชการ</div>
<div class="col-12 text-detail">{{ dataDetail.location }}</div>
</div>
</div>
<div class="col-xs-6 col-sm-3 row items-start">
<div class="col-12">
<div class="col-12 text-top">วันที่ยื่นขอลาออกจากราชการ</div>
<div class="col-12 text-detail">
{{ date2Thai(dataDetail.sendDate) }}
</div>
</div>
</div>
<div class="col-xs-6 col-sm-3 row items-start">
<div class="col-12">
<div class="col-12 text-top">เหตุผลที่ลาออกจากราชการ</div>
<div class="col-12 text-detail">
{{
`${convertStatus(dataDetail.reason)} ${
dataDetail.remark ? `(${dataDetail.remark})` : ""
}`
}}
</div>
</div>
</div>
<div class="col-xs-6 col-sm-3 row items-start">
<div class="col-12">
<div class="col-12 text-top">วันที่ขอลาออกจากราชการ</div>
<div
:class="
diffDate()
? 'col-12 text-detail text-red text-bold'
: 'col-12 text-detail'
"
>
{{ date2Thai(dataDetail.activeDate) }}
</div>
<div
:class="
diffDate()
? 'col-12 text-detail text-red text-bold'
: 'col-12 text-detail'
"
>
{{ diffDate() ? "(ยื่นขอลาออกน้อยกว่า 30 วัน)" : "" }}
</div>
</div>
</div>
<div
class="col-xs-12 col-sm-12 row items-start"
v-if="dataDetail.statusMain === 'CANCEL'"
>
<div class="col-12">
<div class="col-12 text-top">เหตุผลการขอยกเลิก</div>
<div class="col-12 text-detail text-red">
{{ dataDetail.cancelReason }}
</div>
</div>
</div>
</div>
</div>
</q-card>
<!-- เอกสารเพิ่มเติม -->
<q-card
v-if="rows.length > 0"
bordered
class="row col-12 text-dark q-mt-sm"
>
<div class="bg-grey-1 q-pa-sm col-12 row items-center text-primary">
<div class="q-pl-sm text-weight-bold text-dark">เอกสารเพิ่มเติม</div>
</div>
<div class="col-12"><q-separator /></div>
<div class="col-12">
<d-table
:rows="rows"
:columns="columns"
row-key="fileName"
hide-header
hide-bottom
>
<template v-slot:body="props">
<q-tr :props="props" class="cursor-pointer">
<q-td key="no" :props="props">
{{ props.rowIndex + 1 }}
</q-td>
<q-td key="fileName" :props="props">
{{ props.row.fileName }}
</q-td>
<q-td key="btnMicrosoft" :props="props">
<q-btn
type="a"
target="_blank"
:href="props.row.pathName"
flat
dense
round
color="red"
icon="picture_as_pdf"
>
<q-tooltip>ไฟล์ PDF</q-tooltip>
</q-btn>
</q-td>
</q-tr>
</template>
</d-table>
</div>
</q-card>
<!-- เอกสารดาวน์โหลด -->
<q-card bordered class="row col-12 text-dark q-mt-sm">
<div class="bg-grey-1 q-pa-sm col-12 row items-center text-primary">
<div class="q-pl-sm text-weight-bold text-dark">เอกสารดาวน์โหลด</div>
</div>
<div class="col-12"><q-separator /></div>
<div class="col-12">
<d-table
:rows="rowsFileDownload"
:columns="columns"
row-key="fileName"
hide-header
hide-bottom
>
<template v-slot:body="props">
<q-tr :props="props" class="cursor-pointer">
<q-td key="fileName" :props="props">
{{ props.row.fileName }}
</q-td>
<q-td key="btnMicrosoft" :props="props">
<q-btn
flat
dense
round
color="red"
icon="picture_as_pdf"
@click="fileDownload('pdf', props.row.fileName)"
>
<q-tooltip>ไฟล์ PDF</q-tooltip>
</q-btn>
<q-btn
flat
dense
round
color="blue"
icon="mdi-file-word"
@click="fileDownload('docx', props.row.fileName)"
>
<q-tooltip>ไฟล์ WORD</q-tooltip>
</q-btn>
</q-td>
</q-tr>
</template>
</d-table>
</div>
</q-card>
<!-- รายการตรวจสอบเงื่อนไขต่างๆ -->
<q-card bordered class="row col-12 text-dark q-mt-sm">
<div class="bg-grey-1 q-pa-sm col-12 row items-center text-primary">
<div class="q-pl-sm text-weight-bold text-dark">
รายการตรวจสอบเงื่อนไขต่างๆ
</div>
</div>
<div class="col-12"><q-separator /></div>
<div class="row col-12 q-pa-sm q-col-gutter-sm">
<div class="col-6">
<q-card bordered class="row col-12 text-dark q-mt-sm">
<div class="bg-grey-1 q-pa-sm col-12 row items-center text-primary">
<div class="q-pl-sm text-weight-bold text-dark">
เงื่อนไขต่างๆ
</div>
<q-space />
<div
v-if="!checkRoutePermisson && isStaff && approveStep === 'st1'"
>
<div v-if="!conditions">
<q-btn
outline
color="primary"
dense
icon-right="mdi-file-edit-outline"
class="q-px-sm"
label="แก้ไข"
style="width: 80px"
@click="conditions = !conditions"
/>
</div>
<div v-else class="q-gutter-x-sm">
<q-btn
outline
color="public"
dense
class="q-px-sm"
label="บันทึก"
style="width: 80px"
@click="onSubmitConditions"
/>
<q-btn
outline
color="red"
dense
class="q-px-sm"
label="ยกเลิก"
style="width: 80px"
@click="clickCancelConditions"
/>
</div>
</div>
</div>
<div class="col-12"><q-separator /></div>
<div class="col-12">
<q-checkbox
v-model="isNoDebt"
label="ไม่เป็นหนี้สหกรณ์"
color="teal"
:disable="!conditions"
/>
</div>
<div class="col-12">
<q-checkbox
v-model="isNoBurden"
label="ไม่มีภาระผูกพันค้ำประกันทุนการศึกษา"
color="teal"
:disable="!conditions"
/>
</div>
<div class="col-12">
<q-checkbox
v-model="isDiscipline"
label="ไม่มีพฤติการณ์ทางวินัย"
color="teal"
:disable="!conditions"
/>
</div>
</q-card>
</div>
<div class="col-6">
<q-card bordered class="row col-12 text-dark q-mt-sm">
<div class="bg-grey-1 q-pa-sm col-12 row items-center text-primary">
<div class="q-pl-sm text-weight-bold text-dark">
เอกสารหลักฐานต่างๆ
</div>
</div>
<div class="col-12"><q-separator /></div>
<div class="row col-12 q-col-gutter-y-sm q-pa-sm">
<div class="col-12 row">
<q-file
v-if="
!checkRoutePermisson &&
isStaff &&
dataDetail.statusMain === 'WAITTING'
"
class="col-12"
for="#evidenceFiles"
outlined
dense
v-model="file"
label="อัปโหลดเอกสารหลักฐานต่างๆ"
hide-bottom-space
>
<template v-slot:prepend>
<q-icon name="attach_file" color="primary" />
</template>
<template v-slot:after>
<q-btn
v-if="file"
size="14px"
flat
round
dense
color="primary"
icon="mdi-upload"
@click="uploadFiles"
><q-tooltip>อัปโหลดเอกสาร</q-tooltip></q-btn
>
</template>
</q-file>
</div>
<div v-if="fileList.length > 0" class="col-xs-12 row">
<q-list class="full-width rounded-borders" bordered separator>
<q-item
v-for="File in fileList"
:key="File.id"
clickable
v-ripple
>
<q-item-section>{{ File.title }}</q-item-section>
<q-item-section avatar>
<div class="row">
<div>
<q-btn
dense
flat
round
size="12px"
color="blue"
icon="mdi-download-outline"
@click="downloadFiles(File.fileName)"
>
<q-tooltip>ดาวน์โหลดไฟล์</q-tooltip>
</q-btn>
</div>
<div>
<q-btn
v-if="
!checkRoutePermisson &&
isStaff &&
dataDetail.statusMain === 'WAITTING'
"
dense
flat
round
size="12px"
color="red"
icon="mdi-delete-outline"
@click="removeFile(File.fileName)"
><q-tooltip>ลบไฟล์</q-tooltip></q-btn
>
</div>
</div>
</q-item-section>
</q-item>
</q-list>
</div>
<div class="col-12" v-else>
<q-card class="q-pa-sm" bordered> ไม่มีรายการเอกสาร </q-card>
</div>
</div>
</q-card>
</div>
</div>
</q-card>
<!-- ผลการพิจารณาของผู้บังคับบัญชา -->
<q-card bordered class="row col-12 text-dark q-mt-sm">
<div class="bg-grey-1 q-pa-sm col-12 row items-center text-primary">
<div class="q-pl-sm text-weight-bold text-dark">
ผลการพิจารณาของผู้บังคับบัญชา
</div>
<q-btn
v-if="!checkRoutePermisson && isStaff && approveStep === 'st1'"
flat
round
icon="add"
color="primary"
dense
class="q-ml-xs"
@click="onAddPerson('COMMANDER')"
>
<q-tooltip>เพิ่มรายชื่อผู้บังคับบัญชา</q-tooltip>
</q-btn>
<q-space />
</div>
<div class="col-12"><q-separator /></div>
<div class="col-12 q-pa-sm">
<d-table
ref="table"
:columns="columnsCommanders"
:rows="rowsApprover?.commanders ?? []"
row-key="key"
flat
bordered
:paging="true"
dense
:rows-per-page-options="[10, 25, 50, 100]"
>
<template v-slot:header="props">
<q-tr :props="props">
<q-th v-for="col in props.cols" :key="col.name" :props="props">
<span class="text-weight-medium">{{ col.label }}</span>
</q-th>
</q-tr>
</template>
<template v-slot:body="props">
<q-tr :props="props" class="cursor-pointer">
<q-td v-for="col in props.cols" :key="col.name" :props="props">
<div v-if="col.name == 'no'">
{{ props.rowIndex + 1 }}
</div>
<div v-else-if="col.name == 'comment'">
<div
class="q-gutter-x-xs"
v-if="
dataDetail.statusMain === 'PENDING' &&
props.row.approveStatus == 'PENDING' &&
props.row.comment == '' &&
approveStep === 'st2'
"
>
<q-btn
v-if="
props.row.profileId === keycloakId &&
approveStep === 'st2'
"
outline
dense
color="primary"
icon-right="check"
class="q-px-sm"
label="อนุญาต"
@click="popUp('pass', 'commander')"
/>
<q-btn
v-if="
props.row.profileId === keycloakId &&
approveStep === 'st2'
"
outline
color="red"
dense
icon-right="close"
class="q-px-sm"
label="ยับยั้ง"
@click="popUp('passNot', 'commander')"
/>
</div>
<div v-else>
{{ props.row.comment ? props.row.comment : "-" }}
</div>
</div>
<div v-else-if="col.name == 'approveStatus'">
{{
props.row.approveStatus
? convertStatusText(props.row.approveStatus, "ยับยั้ง")
: "-"
}}
</div>
<div v-else>
{{ col.value ? col.value : "-" }}
</div>
</q-td>
</q-tr>
</template>
</d-table>
</div>
</q-card>
<!-- ผลการพิจารณาของผู้มีอำนาจ -->
<q-card bordered class="row col-12 text-dark q-mt-sm">
<div class="bg-grey-1 q-pa-sm col-12 row items-center text-primary">
<div class="q-pl-sm text-weight-bold text-dark">
ผลการพิจารณาของผู้มีอำนาจ
</div>
<q-btn
v-if="!checkRoutePermisson && isStaff && approveStep === 'st1'"
flat
round
icon="add"
color="primary"
dense
class="q-ml-xs"
@click="onAddPerson('APPROVER')"
>
<q-tooltip>เพิ่มรายชื่อผู้มีอำนาจ</q-tooltip>
</q-btn>
<q-space />
<div
class="q-gutter-x-sm"
v-if="
dataDetail.statusMain === 'PENDING' &&
rowsApprover &&
rowsApprover.approvers &&
rowsApprover.approvers[0]?.profileId == keycloakId &&
rowsApprover.approvers[0]?.approveStatus == 'PENDING' &&
approveStep === 'st3'
"
>
<q-btn
outline
color="primary"
dense
icon-right="check"
class="q-px-sm"
label="อนุญาต"
@click="popUp('pass', 'oligarch')"
/>
<q-btn
outline
color="red"
dense
icon-right="close"
class="q-px-sm"
label="ยับยั้ง"
@click="popUp('passNot', 'oligarch')"
/>
</div>
</div>
<div class="col-12"><q-separator /></div>
<div class="row col-12 q-pa-md">
<div class="col-12 row bg-white q-col-gutter-md">
<div class="col-xs-6 row items-start">
<div class="col-12 text-top">ชื่อ - นามสกุล</div>
<div class="col-12 text-detail">
{{
rowsApprover &&
rowsApprover.approvers &&
rowsApprover.approvers[0]?.firstName
? `${rowsApprover?.approvers[0].prefix}${rowsApprover?.approvers[0].firstName} ${rowsApprover?.approvers[0].lastName}`
: "-"
}}
</div>
</div>
<div class="col-xs-6 row items-start">
<div class="col-12 text-top">สถานะ</div>
<div class="col-12 text-detail">
{{
rowsApprover &&
rowsApprover.approvers &&
rowsApprover.approvers[0]?.approveStatus
? convertStatusText(
rowsApprover?.approvers[0].approveStatus,
"ยับยั้ง"
)
: "-"
}}
</div>
</div>
<div class="col-xs-6 row items-start">
<div class="col-12 text-top">วันสุดท้ายที่ยับยั้ง</div>
<div class="col-12 text-detail">
{{
rowsApprover &&
rowsApprover.approvers &&
rowsApprover.approvers[0]?.rejectDate
? date2Thai(rowsApprover?.approvers[0].rejectDate)
: "-"
}}
</div>
</div>
<div class="col-xs-12 row items-start">
<div class="col-12 text-top">ความคิดเห็นและเหตุผล</div>
<div class="col-12 text-detail">
{{
rowsApprover &&
rowsApprover.approvers &&
rowsApprover.approvers[0]?.comment
? rowsApprover?.approvers[0].comment
: "-"
}}
</div>
</div>
</div>
</div>
</q-card>
<!-- ส่งไปพิจารณา -->
<q-card
bordered
class="row col-12 text-dark q-mt-sm q-pa-sm"
v-if="!checkRoutePermisson && isStaff && approveStep === 'st1'"
>
<q-btn
@click="onSend"
:disable="
rowsApprover?.approvers.length == 0 ||
rowsApprover?.commanders.length == 0
"
label="ส่งไปพิจารณา"
color="secondary"
class="q-ml-auto"
><q-tooltip>คลิกเพื่อส่งไปพิจารณา</q-tooltip></q-btn
>
</q-card>
<!-- แก้ไขข้อมูลเพื่อลงบัญชีแนบท้าย -->
<q-card bordered class="row col-12 text-dark q-mt-sm">
<q-form
ref="myForm"
greedy
@submit.prevent
@validation-success="onSubmitAttached"
class="full-width"
>
<div class="bg-grey-1 q-pa-sm col-12 row items-center text-primary">
<div class="q-pl-sm text-weight-bold text-dark">
แก้ไขข้อมูลเพื่อลงบัญชีแนบท้าย
</div>
<q-space />
<div
v-if="
!checkRoutePermisson &&
(dataDetail.statusMain === 'APPROVE' ||
dataDetail.statusMain === 'REJECT') &&
isStaff
"
>
<div class="q-gutter-sm" v-if="!edit">
<q-btn
outline
color="primary"
dense
icon-right="mdi-file-edit-outline"
class="q-px-sm"
label="แก้ไข"
style="width: 80px"
@click="edit = !edit"
v-if="!(status == 'REPORT' || status == 'DONE')"
/>
</div>
<div class="q-gutter-sm" v-else>
<q-btn
outline
color="public"
dense
class="q-px-sm"
label="บันทึก"
style="width: 80px"
type="submit"
/>
<q-btn
outline
color="red"
dense
class="q-px-sm"
label="ยกเลิก"
style="width: 80px"
@click="clickCancel"
/>
</div>
</div>
</div>
<div class="col-12"><q-separator /></div>
<div class="row col-12 q-pa-md">
<div class="col-12 row bg-white q-col-gutter-md">
<div class="col-xs-12 row items-center">
<div class="col-12">
<q-input
:class="getClass(edit)"
:outlined="edit"
dense
lazy-rules
:readonly="!edit"
:borderless="!edit"
v-model="organizationPositionOld"
:rules="[(val:string) => !!val || `${'กรุณากรอกตำแหน่ง/สังกัดเดิม'}`]"
hide-bottom-space
:label="`${'ตำแหน่ง/สังกัดเดิม'}`"
type="textarea"
/>
</div>
</div>
<div class="col-xs-6 col-sm-4 row">
<div class="col-12">
<q-input
:class="getClass(edit)"
:outlined="edit"
dense
lazy-rules
:readonly="!edit"
:borderless="!edit"
v-model="positionTypeOld"
:rules="[(val:string) => !!val || `${'กรุณากรอกกลุ่มงาน'}`]"
hide-bottom-space
:label="`${'กลุ่มงาน'}`"
/>
</div>
</div>
<div class="col-xs-6 col-sm-4 row">
<div class="col-12">
<q-input
:class="getClass(edit)"
:outlined="edit"
dense
lazy-rules
:readonly="!edit"
:borderless="!edit"
v-model="positionLevelOld"
:rules="[(val:string) => !!val || `${'กรุณากรอกระดับชั้นงาน'}`]"
hide-bottom-space
:label="`${'ระดับชั้นงาน'}`"
/>
</div>
</div>
<div class="col-xs-6 col-sm-4 row">
<div class="col-12">
<q-input
:class="getClass(edit)"
:outlined="edit"
dense
lazy-rules
:readonly="!edit"
:borderless="!edit"
v-model="posNo"
:rules="[(val:string) => !!val || `${'กรุณากรอกตำแหน่งเลขที่'}`]"
hide-bottom-space
:label="`${'ตำแหน่งเลขที่'}`"
/>
</div>
</div>
<div class="col-12"><q-separator /></div>
<div class="col-xs-4 row">
<div class="col-12">
<q-input
:class="getClass(edit)"
:outlined="edit"
dense
lazy-rules
:readonly="!edit"
:borderless="!edit"
v-model="location"
:rules="[
(val:string) => !!val || `${'กรุณากรอกสถานที่ยื่นขอลาออกจากราชการ'}`,
]"
hide-bottom-space
:label="`${'สถานที่ยื่นขอลาออกจากราชการ'}`"
/>
</div>
</div>
<div class="col-xs-4 row">
<div class="col-12">
<datepicker
:readonly="!edit"
v-model="date"
:locale="'th'"
autoApply
:enableTimePicker="false"
week-start="0"
>
<template #year="{ year }">{{ year + 543 }}</template>
<template #year-overlay-value="{ value }">{{
parseInt(value + 543)
}}</template>
<template #trigger>
<q-input
:readonly="!edit"
:class="getClass(edit)"
:outlined="edit"
dense
:borderless="!edit"
:model-value="date !== null ? date2Thai(date) : null"
:rules="edit ? [
(val:string) =>
!!val || `${'กรุณาเลือก วันที่ยื่นขอลาออกจากราชการ'}`,
] : []"
hide-bottom-space
:label="`${' วันที่ยื่นขอลาออกจากราชการ'}`"
>
<template v-slot:prepend>
<q-icon
name="event"
class="cursor-pointer"
:style="
edit
? 'color: var(--q-primary)'
: 'color: var(--q-grey)'
"
>
</q-icon>
</template>
</q-input>
</template>
</datepicker>
</div>
</div>
<div class="col-12">
<q-input
:class="getClass(edit)"
:outlined="edit"
dense
lazy-rules
:readonly="!edit"
:borderless="!edit"
v-model="reason"
:rules="[
(val:string) => !!val || `${'กรุณากรอกเหตุผลที่ลาออกจากราชการ'}`,
]"
hide-bottom-space
:label="`${'เหตุผลที่ลาออกจากราชการ (หมายเหตุแนวตั้ง)'}`"
type="textarea"
/>
</div>
<div class="col-12">
<q-input
:class="getClass(edit)"
:outlined="edit"
dense
lazy-rules
:readonly="!edit"
:borderless="!edit"
v-model="remarkHorizontal"
:rules="[(val:string) => !!val || `${'กรุณากรอกหมายเหตุแนวนอน '}`]"
hide-bottom-space
:label="`${'หมายเหตุแนวนอน '}`"
type="textarea"
/>
</div>
</div>
</div>
</q-form>
</q-card>
</div>
<!-- popup อนุญาตการลาออก,ยับยั้งการลาออก -->
<q-dialog v-model="modal" persistent>
<q-card style="width: 800px">
<q-form greedy @submit.prevent @validation-success="onSubmit">
<DialogHeader
:tittle="`${actionPass ? 'อนุญาตการลาออก' : 'ยับยั้งการลาออก'}`"
:close="closeModal"
/>
<q-separator />
<q-card-section class="q-p-sm q-gutter-md">
<div class="col-xs-12 col-sm-12 col-md-12">
<q-input
hide-bottom-space
dense
outlined
lazy-rules
:rules=" !actionPass ? [(val:string) => !!val || 'กรุณากรอกความคิดเห็น/เหตุผล'] :[]"
v-model="reasonReign"
:label="`${'กรอกความคิดเห็น/เหตุผล'}`"
type="textarea"
class="inputgreen"
/>
</div>
<div class="col-xs-12 col-sm-12 col-md-12" v-if="!actionPass">
<datepicker
menu-class-name="modalfix"
v-model="dateBreak"
:locale="'th'"
autoApply
:enableTimePicker="false"
week-start="0"
>
<template #year="{ year }">{{ year + 543 }}</template>
<template #year-overlay-value="{ value }">{{
parseInt(value + 543)
}}</template>
<template #trigger>
<q-input
outlined
dense
class="inputgreen"
:model-value="
dateBreak !== null ? date2Thai(dateBreak) : null
"
hide-bottom-space
:label="`${' วันสุดท้ายที่ยับยั้ง'}`"
:rules="[(val:string) => !!val || 'กรุณาเลือกวันที่']"
>
<template v-slot:prepend>
<q-icon
name="event"
class="cursor-pointer"
color="primary"
:style="
edit
? 'color: var(--q-primary)'
: 'color: var(--q-grey)'
"
>
</q-icon>
</template>
</q-input>
</template>
</datepicker>
</div>
</q-card-section>
<q-separator />
<q-card-actions align="right" class="bg-white text-teal">
<q-btn label="บันทึก" color="secondary" type="submit"
><q-tooltip>นทกขอม</q-tooltip></q-btn
>
</q-card-actions>
<!-- <DialogFooter :editvisible="true" :save="conditionPopup" /> -->
</q-form>
</q-card>
</q-dialog>
<PopupPersonal
:modal="modalPersonal"
:id="personId"
@update:modal="updatemodalPersonal"
/>
<DialogAddCommander
v-model:modal="modalAdd"
:type="typeAdd"
:profileType="'-employee'"
:get-data="fetchData"
:id-check="idCheck"
:keycloak-user-id="keycloakUserId"
/>
<DialogFormResign
v-model:modal="modalFormResign"
:data="dataDetail"
:fetch-data="fetchData"
/>
</template>
<style lang="scss" scope>
.q-img {
border-radius: 5px;
height: 70px;
}
.text-top {
color: gray;
font-weight: 400;
padding-bottom: 3px;
}
.text-detail {
font-weight: 500;
}
</style>