diff --git a/src/modules/06_retirement/components/02_resign/ResignByid.vue b/src/modules/06_retirement/components/02_resign/ResignByid.vue index 5cdf9cb3e..eddbfc52c 100644 --- a/src/modules/06_retirement/components/02_resign/ResignByid.vue +++ b/src/modules/06_retirement/components/02_resign/ResignByid.vue @@ -8,12 +8,16 @@ import http from "@/plugins/http"; import config from "@/app.config"; import genReport from "@/plugins/genreport"; import { useCounterMixin } from "@/stores/mixin"; +import { checkPermission } from "@/utils/permissions"; + import DialogHeader from "@/components/DialogHeader.vue"; import type { TypeFile, rowFile, FileList, + RowsType, + SeqTypeRow, } from "@/modules/06_retirement/interface/response/Main"; import type { QTableProps } from "quasar"; import type { DataProfile } from "@/modules/05_placement/interface/index/Main"; @@ -21,6 +25,7 @@ import type { DataProfile } from "@/modules/05_placement/interface/index/Main"; import PopupPersonal from "@/components/Dialogs/PopupPersonal.vue"; import CardProfile from "@/components/CardProfile.vue"; import WorkFlow from "@/components/Workflow/Main.vue"; +import DialogAddCommander from "@/modules/06_retirement/components/DialogAddCommander.vue"; /** Use */ const $q = useQuasar(); @@ -45,6 +50,133 @@ const personId = ref(""); const roleUser = ref(""); const dataProfile = ref(); +const approveCheck = computed(() => { + return ( + rowsApprover.value?.commanders?.every( + (commander) => commander.approveStatus === "APPROVE" + ) ?? false + ); +}); +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 approvePendingCheck = computed(() => { + const commanders = rowsApprover.value?.commanders || []; + const index = commanders.findIndex((c) => c.profileId === keycloakId.value); + + if (index === -1) { + return false; + } + + const currentCommander = commanders[index]; + + if (currentCommander.approveStatus !== "PENDING") { + return false; + } + + if (index === 0) { + return true; + } + + const previousApproved = commanders + .slice(0, index) + .every((c) => c.approveStatus === "APPROVE"); + return previousApproved; +}); +const isOfficer = ref(false); +const isStaff = ref(false); +const profileType = ref(""); +const keycloakUserId = ref(""); +const keycloakId = ref(""); +const modalAdd = ref(false); +const typeAdd = ref(""); +const statusCheck = ref(""); +const rowsApprover = ref(); +const columnsCommanders = ref([ + { + 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: "org", + align: "left", + label: "สังกัด", + sortable: true, + field: "org", + headerStyle: "font-size: 14px", + style: "font-size: 14px", + }, + { + name: "สถานะ", + align: "left", + label: "สถานะ", + sortable: true, + field: "สถานะ", + 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", + sortable: true, + headerStyle: "font-size: 14px", + style: "font-size: 14px", + }, +]); const id = ref(route.params.id.toString()); const myForm = ref(null); const edit = ref(false); @@ -209,6 +341,13 @@ async function fetchData(id: string) { isNoDebt.value = data.isNoDebt; isNoBurden.value = data.isNoBurden; isDiscipline.value = data.isDiscipline; + + profileType.value = data.profileType; + keycloakUserId.value = data.keycloakUserId; + rowsApprover.value = { + commanders: data.commanders, + approvers: data.approvers, + }; }) .catch((e) => { messageError($q, e); @@ -552,10 +691,56 @@ function convertStatus(val: string) { } } else return val; } + +/** เปิด POP UP */ +function onAddPerson(type: string) { + modalAdd.value = true; + typeAdd.value = type; +} + +async function checkOfficer() { + http + .get(config.API.checkIsofficer + `SYS_RESIGN`) + .then(async (res) => { + isOfficer.value = await res.data.result.isOfficer; + isStaff.value = await res.data.result.isStaff; + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => {}); +} + +function onSend() { + dialogConfirm( + $q, + () => { + showLoader(); + http + .get(config.API.sendApprove(id.value)) + .then(async (res) => { + await fetchData(id.value); + await fetchFile(); + success($q, "ส่งไปพิจารณา"); + }) + .catch((e) => { + messageError($q, e); + }) + .finally(() => {}); + }, + "ยืนยันการส่งไปพิจารณา", + "ต้องการส่งไปพิจารณาใช่หรือไม่" + ); +} + /** Hook */ onMounted(async () => { showLoader(); - await Promise.all([fetchData(id.value), fetchFile()]).finally(() => { + await Promise.all([ + await fetchData(id.value), + await checkOfficer(), + fetchFile(), + ]).finally(() => { hideLoader(); }); }); @@ -1015,10 +1200,23 @@ onMounted(async () => {
ผลการพิจารณาของผู้บังคับบัญชา
+ + + เพิ่มรายชื่อผู้บังคับบัญชา + -
-
+ -->
-
-
-
-
สถานะ
-
- {{ - dataDetail.commanderReject !== null - ? statusOrder(dataDetail.commanderReject) - : "-" - }} -
-
-
-
วันสุดท้ายที่ยับยั้ง
-
- {{ - dataDetail.commanderRejectDate !== null - ? date2Thai(dataDetail.commanderRejectDate) - : "-" - }} -
-
-
-
ความคิดเห็นและเหตุผล
-
- {{ - dataDetail.commanderReject - ? dataDetail.commanderRejectReason - : dataDetail.commanderApproveReason - }} -
-
-
+
+ + + +
@@ -1089,14 +1340,33 @@ onMounted(async () => {
ผลการพิจารณาของผู้มีอำนาจ
+ + + เพิ่มรายชื่อผู้มีอำนาจ +
{
+
+
ชื่อ - นามสกุล
+
+ {{ + rowsApprover && + rowsApprover.approvers && + rowsApprover.approvers[0]?.firstName + ? `${rowsApprover?.approvers[0].prefix}${rowsApprover?.approvers[0].firstName} ${rowsApprover?.approvers[0].lastName}` + : "-" + }} +
+
สถานะ
@@ -1156,6 +1438,23 @@ onMounted(async () => {
+ + คลิกเพื่อส่งไปพิจารณา + { :id="personId" @update:modal="updatemodalPersonal" /> + +