From 32dcdc93364033f62b40bf3e9f1aedc6c504d777 Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Thu, 29 May 2025 14:17:39 +0700 Subject: [PATCH] =?UTF-8?q?API=20=E0=B8=81=E0=B8=B2=E0=B8=A3=E0=B8=A5?= =?UTF-8?q?=E0=B8=B2=20=E0=B8=82=E0=B9=89=E0=B8=B2=E0=B8=A3=E0=B8=B2?= =?UTF-8?q?=E0=B8=8A=E0=B8=81=E0=B8=B2=E0=B8=A3,=20=E0=B8=A5=E0=B8=B9?= =?UTF-8?q?=E0=B8=81=E0=B8=88=E0=B9=89=E0=B8=B2=E0=B8=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/06_retirement/api.retirement.ts | 16 + src/modules/02_organization/views/main.vue | 10 +- .../components/PersonalList/TableView.vue | 11 +- .../components/probation/MainAppoint.vue | 12 +- .../components/probation/MainProbation.vue | 10 +- .../05_placement/views/02_transferMain.vue | 12 +- .../05_placement/views/03_receiveMain.vue | 12 +- .../views/04_helpGovernmentMain.vue | 12 +- .../05_placement/views/05_repatriateMain.vue | 12 +- .../views/06_appointPromoteMain.vue | 12 +- .../views/07_appointEmployeeMain.vue | 15 +- .../05_placement/views/08_otherMain.vue | 12 +- .../components/02_resign/ResignByid.vue | 209 +-------- .../components/02_resign/ResignReject.vue | 151 ++----- .../components/02_resign/Table.vue | 12 +- .../components/03_resignEmp/ResignByid.vue | 421 ++++++------------ .../components/03_resignEmp/ResignReject.vue | 311 ++++--------- .../components/03_resignEmp/Table.vue | 21 +- .../components/DialogAddCommander.vue | 35 +- src/modules/06_retirement/store/Main.ts | 10 +- src/modules/06_retirement/store/resignMain.ts | 2 +- .../06_retirement/views/06_dismissOrder.vue | 12 +- .../views/08_dismissOrderEmp.vue | 12 +- .../08_registryEmployee/views/Main.vue | 12 +- .../components/7_ListSuspend/ListsPage.vue | 12 +- .../13_salary/views/04_salaryLists.vue | 10 +- .../views/05_salaryListsEmployee.vue | 5 +- src/modules/17_acting/views/main.vue | 12 +- 28 files changed, 525 insertions(+), 868 deletions(-) diff --git a/src/api/06_retirement/api.retirement.ts b/src/api/06_retirement/api.retirement.ts index e7e3ee1ad..9138047f1 100644 --- a/src/api/06_retirement/api.retirement.ts +++ b/src/api/06_retirement/api.retirement.ts @@ -80,6 +80,9 @@ export default { addResign: (profileType: string, type: string, id: string) => `${retirement}/resign${profileType}/officer/add-resign/${type}/${id}`, + addResignCancel: (profileType: string, type: string, id: string) => + `${retirement}/resign${profileType}/officer-cancel/add-resign/${type}/${id}`, + sendApproveRetirement: (type: string, id: string) => `${retirement}/resign${type}/admin/approve/officer/${id}`, commanderApproveRetirement: ( @@ -88,4 +91,17 @@ export default { typeApprove: string, path: string = "" ) => `${retirement}/resign${type}/admin/${typeApprove}${path}/${id}`, + + // รายการยกเลิกการลาออก + // สำหรับเจ้าหน้าที่ + officerCancelResign: (typeEmp: string, id: string) => + `${retirement}/resign${typeEmp}/admin-cancel/approve/officer/${id}`, + + // สำหรับผู้บังคับบัญชา + comanderCancelResign: (typeEmp: string, action: string, id: string) => + `${retirement}/resign${typeEmp}/admin-cancel/${action}/comander/${id}`, + + // สำหรับผู้มีอำนาจ + approverCancelResign: (typeEmp: string, action: string, id: string) => + `${retirement}/resign${typeEmp}/admin-cancel/${action}/${id}`, }; diff --git a/src/modules/02_organization/views/main.vue b/src/modules/02_organization/views/main.vue index be9eb7fcb..20eee64d8 100644 --- a/src/modules/02_organization/views/main.vue +++ b/src/modules/02_organization/views/main.vue @@ -4,7 +4,11 @@ import { useQuasar } from "quasar"; import http from "@/plugins/http"; import config from "@/app.config"; -import { checkPermission } from "@/utils/permissions"; +import { + checkPermission, + checkPermissionList, + checkPermissionCreate, +} from "@/utils/permissions"; import { useOrganizational } from "@/modules/02_organization/store/organizational"; import { useCounterMixin } from "@/stores/mixin"; @@ -338,7 +342,9 @@ onMounted(async () => { import { ref, useAttrs } from "vue"; import { QTooltip, useQuasar } from "quasar"; -import { checkPermission } from "@/utils/permissions"; +import { + checkPermission, + checkPermissionList, + checkPermissionCreate, +} from "@/utils/permissions"; import type { PropType } from "vue"; import type { optionData } from "@/modules/05_placement/interface/index/Main"; @@ -267,6 +271,11 @@ function filterSelector(val: string, update: Function) { {
{ {
{ เพิ่มข้อมูล {
{ {
{
{ props.row.posTypeName === "อำนวยการ" ? `${props.row.posTypeName}` : "" - }} {{ + }} + {{ props.row.posLevelName !== null ? `(${props.row.posLevelName})` : "" diff --git a/src/modules/05_placement/views/08_otherMain.vue b/src/modules/05_placement/views/08_otherMain.vue index 261b4b555..9ab2ed2bc 100644 --- a/src/modules/05_placement/views/08_otherMain.vue +++ b/src/modules/05_placement/views/08_otherMain.vue @@ -3,7 +3,11 @@ import { ref, onMounted } from "vue"; import { useQuasar } from "quasar"; import { useRouter } from "vue-router"; -import { checkPermission } from "@/utils/permissions"; +import { + checkPermission, + checkPermissionList, + checkPermissionCreate, +} from "@/utils/permissions"; import { useTransferDataStore } from "@/modules/05_placement/store"; import { useCounterMixin } from "@/stores/mixin"; import http from "@/plugins/http"; @@ -353,7 +357,11 @@ onMounted(() => { (); const approveStep = ref(""); const group = ref(""); -// const approveCheck = computed(() => { -// return ( -// rowsApprover.value?.commanders?.every( -// (commander) => -// commander.approveStatus === "APPROVE" || -// commander.approveStatus === "REJECT" -// ) ?? false -// ); -// }); const idCheck = computed(() => { if ( typeAdd.value == "COMMANDER" && @@ -86,31 +75,6 @@ const idCheck = computed(() => { } }); -// const approvePendingCheck = computed(() => { -// const commanders = rowsApprover.value?.commanders || []; -// const index = commanders.findIndex((c) => c.profileId === myProfileId.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" || c.approveStatus === "REJECT" -// ); -// return previousApproved; -// }); const isOfficer = ref(false); const isStaff = ref(false); const profileType = ref(""); @@ -213,7 +177,6 @@ const dataDetail = ref({ reasonResign: "", }); -const workflowRef = ref(null); const organizationPositionOld = ref(""); const positionTypeOld = ref(""); const positionLevelOld = ref(""); @@ -230,20 +193,6 @@ const actionPass = ref(false); const reasonReign = ref(""); const dateBreak = ref(null); -const isCheckData = computed(() => { - if ( - organizationPositionOld.value !== "" && - positionTypeOld.value !== "" && - positionLevelOld.value !== "" && - posNo.value !== "" && - date.value !== null && - dataDetail.value.commanderReject !== null && - dataDetail.value.oligarchReject !== null - ) { - return true; - } else return false; -}); - /** คอลัมน์ */ const rows = ref([]); const columns = ref([ @@ -316,7 +265,6 @@ function diffDate() { * @param id id ของผู้ใช้งาน */ async function fetchData(id: string) { - showLoader(); await http .get(config.API.resingByid(id)) .then(async (res) => { @@ -361,9 +309,6 @@ async function fetchData(id: string) { }) .catch((e) => { messageError($q, e); - }) - .finally(() => { - hideLoader(); }); } @@ -394,19 +339,6 @@ function onSubmit(type: string) { } else if (roleUser.value === "oligarch" && !actionPass.value) { rejectpopUp(""); } - // if (actionPass.value) { - // if (type === "approver") { - // confirmpopUp("/comander"); - // } else { - // confirmpopUp(""); - // } - // } else { - // if (type === "approver") { - // rejectpopUp("/comander"); - // } else { - // rejectpopUp(""); - // } - // } } /** @@ -503,15 +435,20 @@ async function clickCancel() { /** ฟังก์ชันยกเลิกการแก้ไขข้อมูลรายการตรวจสอบเงื่อนไขต่างๆ*/ async function clickCancelConditions() { - await fetchData(id.value); - conditions.value = false; + 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, () => { + dialogConfirm($q, async () => { showLoader(); - http + await http .put(config.API.resignConditions(id.value), { isNoDebt: isNoDebt.value, isNoBurden: isNoBurden.value, @@ -533,7 +470,7 @@ function onSubmitConditions() { /** ฟังก์ชันบันทึกข้อมูลเพื่อลงบัญชีแนบท้าย*/ function onSubmitAttached() { - dialogConfirm($q, () => { + dialogConfirm($q, async () => { const formData = new FormData(); const send = date.value !== null ? new Date(date.value).toUTCString() : ""; const activeDate = @@ -549,7 +486,7 @@ function onSubmitAttached() { formData.append("AmountOld", salary.value.toString()); formData.append("remarkHorizontal", remarkHorizontal.value); showLoader(); - http + await http .put(config.API.resingByid(id.value), formData) .then(async () => { await fetchData(id.value); @@ -598,7 +535,6 @@ function updatemodalPersonal(modal: boolean) { } async function fetchFile() { - showLoader(); await http .get(config.API.file("พ้นจากราชการ", "หลักฐานลาออก", id.value)) .then(async (res) => { @@ -606,13 +542,12 @@ async function fetchFile() { }) .catch((e) => { messageError($q, e); - hideLoader(); }); } -function uploadFiles() { +async function uploadFiles() { showLoader(); - http + await http .post(config.API.file("พ้นจากราชการ", "หลักฐานลาออก", id.value), { replace: true, fileList: [ @@ -683,9 +618,9 @@ async function downloadFiles(fileName: string) { * @param id id file */ function removeFile(fileName: string) { - dialogRemove($q, () => { + dialogRemove($q, async () => { showLoader(); - http + await http .delete( config.API.fileByFile( "พ้นจากราชการ", @@ -694,15 +629,16 @@ function removeFile(fileName: string) { fileName ) ) - .then(() => { + .then(async () => { setTimeout(async () => { await fetchFile(); success($q, `ลบไฟล์สำเร็จ`); - hideLoader(); }, 1000); }) .catch((e) => { messageError($q, e); + }) + .finally(() => { hideLoader(); }); }); @@ -823,39 +759,6 @@ onMounted(async () => {
ข้อมูลการลาออก
-
@@ -1208,51 +1111,6 @@ onMounted(async () => {
- - -
@@ -1278,34 +1136,6 @@ onMounted(async () => { เพิ่มรายชื่อผู้บังคับบัญชา - - -
@@ -1863,12 +1693,11 @@ onMounted(async () => { - + บันทึกข้อมูล -
diff --git a/src/modules/06_retirement/components/02_resign/ResignReject.vue b/src/modules/06_retirement/components/02_resign/ResignReject.vue index fba220479..d032bdbf0 100644 --- a/src/modules/06_retirement/components/02_resign/ResignReject.vue +++ b/src/modules/06_retirement/components/02_resign/ResignReject.vue @@ -7,7 +7,6 @@ import { useQuasar, QForm, type QTableProps } from "quasar"; import http from "@/plugins/http"; import config from "@/app.config"; import { useCounterMixin } from "@/stores/mixin"; -import { checkPermission } from "@/utils/permissions"; import { useRetirementDataStore } from "@/modules/06_retirement/store/Main"; import { useRoleWorkflowDataStore } from "@/stores/roleWorkflow"; @@ -28,8 +27,6 @@ const router = useRouter(); const store = useRetirementDataStore(); const { fetchDataCheckIsoffice } = useRoleWorkflowDataStore(); const { convertStatusText } = store; -const checkRoutePermisson = ref(route.name == "resignDetailReject"); -const mixin = useCounterMixin(); const { messageError, date2Thai, @@ -37,20 +34,16 @@ const { hideLoader, success, dialogConfirm, -} = mixin; +} = useCounterMixin(); + +const checkRoutePermisson = ref(route.name == "resignDetailReject"); /** ตัวแปร */ const roleUser = ref(""); const dataProfile = ref(); const group = ref(""); const approveStep = ref(""); -const approveCheck = computed(() => { - return ( - rowsApprover.value?.commanders?.every( - (commander) => commander.approveStatus === "APPROVE" - ) ?? false - ); -}); + const idCheck = computed(() => { if ( typeAdd.value == "COMMANDER" && @@ -71,29 +64,6 @@ const idCheck = computed(() => { } }); -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(""); @@ -153,15 +123,6 @@ const columnsCommanders = ref([ 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()); @@ -189,6 +150,9 @@ const dataDetail = ref({ statustext: "", fullname: "", statusMain: "", + cancelReason: "", + remark: "", + reasonResign: "", }); const organizationPositionOld = ref(""); @@ -290,16 +254,24 @@ function popUp(action: "pass" | "passNot", type: string) { openModal(); } -/** ฟังก์ชันยืนยันการอนุญาตหรือยับยั้งการยกเลิกการลาออก*/ +/** ฟังก์ชันยืนยันการอนุญาตหรือไม่อนุญาตการยกเลิกการลาออก*/ function onSubmit() { dialogConfirm($q, async () => { showLoader(); const body = { reason: reasonReign.value, - reject: !actionPass.value, + // reject: !actionPass.value, + Date: new Date(), }; + + const action = actionPass.value ? "approve" : "reject"; + + const endpoint = + roleUser.value === "commander" + ? config.API.comanderCancelResign("", action, id.value) + : config.API.approverCancelResign("", action, id.value); await http - .put(config.API.resignReject(`${roleUser.value}-cancel`, id.value), body) + .put(endpoint, body) .then(async () => { await fetchData(id.value); closeModal(); @@ -406,10 +378,10 @@ async function checkOfficer() { function onSend() { dialogConfirm( $q, - () => { + async () => { showLoader(); - http - .get(config.API.sendApproveRetirement("", id.value)) + await http + .get(config.API.officerCancelResign("", id.value)) .then(async () => { await fetchData(id.value); success($q, "ส่งไปพิจารณา"); @@ -479,39 +451,6 @@ onMounted(async () => {
ข้อมูลการลาออก
-
@@ -567,7 +506,7 @@ onMounted(async () => {
- ผลการพิจารณาของผู้บังคับบัญชา {{ group }} + ผลการพิจารณาของผู้บังคับบัญชา
@@ -656,7 +596,7 @@ onMounted(async () => {
{{ props.row.approveStatus - ? convertStatusText(props.row.approveStatus) + ? convertStatusText(props.row.approveStatus, "ไม่อนุญาต") : "-" }}
@@ -693,20 +633,18 @@ onMounted(async () => { เพิ่มรายชื่อผู้มีอำนาจ
-
{ dense icon-right="close" class="q-px-sm" - label="ยับยั้ง" + label="ไม่อนุญาต" @click="popUp('passNot', 'oligarch')" />
@@ -750,28 +688,24 @@ onMounted(async () => { rowsApprover && rowsApprover.approvers && rowsApprover.approvers[0]?.approveStatus - ? convertStatusText(rowsApprover?.approvers[0].approveStatus) + ? convertStatusText( + rowsApprover?.approvers[0].approveStatus, + "ไม่อนุญาต" + ) : "-" }}
- +
ความคิดเห็นและเหตุผล
{{ - dataDetail.oligarchReject - ? dataDetail.oligarchApproveReason - : dataDetail.oligarchApproveReason + rowsApprover && + rowsApprover.approvers && + rowsApprover.approvers[0]?.comment + ? rowsApprover?.approvers[0].comment + : "-" }}
@@ -780,6 +714,7 @@ onMounted(async () => {
+ { @@ -1067,7 +1002,7 @@ onMounted(async () => { - + บันทึกข้อมูล diff --git a/src/modules/06_retirement/components/02_resign/Table.vue b/src/modules/06_retirement/components/02_resign/Table.vue index 4304b9cfb..7cde36b7d 100644 --- a/src/modules/06_retirement/components/02_resign/Table.vue +++ b/src/modules/06_retirement/components/02_resign/Table.vue @@ -6,7 +6,11 @@ import { useRouter } from "vue-router"; import { useCounterMixin } from "@/stores/mixin"; import { useDataStore } from "@/modules/06_retirement/store/resignMain"; import { useRetirementDataStore } from "@/modules/06_retirement/store/Main"; -import { checkPermission } from "@/utils/permissions"; +import { + checkPermission, + checkPermissionList, + checkPermissionCreate, +} from "@/utils/permissions"; import http from "@/plugins/http"; import config from "@/app.config"; @@ -290,7 +294,11 @@ onMounted(async () => { (false); const personId = ref(""); const roleUser = ref(""); const dataProfile = ref(); +const approveStep = ref(""); -const approveCheck = computed(() => { - return ( - rowsApprover.value?.commanders?.every( - (commander) => commander.approveStatus === "APPROVE" - ) ?? false - ); -}); const idCheck = computed(() => { if ( typeAdd.value == "COMMANDER" && @@ -84,29 +76,6 @@ const idCheck = computed(() => { } }); -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(""); @@ -171,6 +140,9 @@ const columnsCommanders = ref([ align: "left", label: "วันสุดท้ายที่ยับยั้ง", field: "rejectDate", + format(val, row) { + return date2Thai(val); + }, sortable: true, headerStyle: "font-size: 14px", style: "font-size: 14px", @@ -208,7 +180,6 @@ const dataDetail = ref({ reasonResign: "", }); -const workflowRef = ref(null); const organizationPositionOld = ref(""); const positionTypeOld = ref(""); const positionLevelOld = ref(""); @@ -225,20 +196,6 @@ const actionPass = ref(false); const reasonReign = ref(""); const dateBreak = ref(null); -const isCheckData = computed(() => { - if ( - organizationPositionOld.value !== "" && - positionTypeOld.value !== "" && - positionLevelOld.value !== "" && - posNo.value !== "" && - date.value !== null && - dataDetail.value.commanderReject !== null && - dataDetail.value.oligarchReject !== null - ) { - return true; - } else return false; -}); - /** คอลัมน์ */ const rows = ref([]); const columns = ref([ @@ -271,13 +228,10 @@ const columns = ref([ }, ]); -/**เปิด-ปิด modal */ +/**ฟังก์ชันปิด popup อนุญาตการลาออก,ยับยั้งการลาออก*/ function closeModal() { modal.value = false; } -function openModal() { - modal.value = true; -} const file = ref(null); const fileList = ref([]); @@ -293,6 +247,7 @@ const rowsFileDownload = ref([ }, ]); +/** ฟังก์ชันคำนวนวันที่ขอลาออกจากราชการ*/ function diffDate() { if (date.value !== null && dateLeave.value !== null) { const time = dateLeave.value.getTime() - date.value.getTime(); @@ -306,9 +261,11 @@ function diffDate() { return false; } -/** นำข้อมูลมาจาก API*/ +/** + * ฟังก์ชันดึงข้อมูลรายละเอียดการลาออก + * @param id รายการลาออก + */ async function fetchData(id: string) { - showLoader(); await http .get(config.API.resingByidEMP(id)) .then(async (res) => { @@ -341,7 +298,7 @@ async function fetchData(id: string) { 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; @@ -352,32 +309,40 @@ async function fetchData(id: string) { }) .catch((e) => { messageError($q, e); - }) - .finally(() => { - hideLoader(); }); } -/**Pop up */ +/** + * ฟังก์ชันเปิด popup อนุญาต,ยับยั้ง + * @param action อนุญาต, ยับยั้ง + * @param type ผู้บังคับบัญชา, ผู้มีอำนาจ + */ function popUp(action: "pass" | "passNot", type: string) { reasonReign.value = ""; dateBreak.value = null; actionPass.value = action === "pass"; roleUser.value = type; - openModal(); + modal.value = true; } -//เงื่อนไขpop up +/** ฟังก์ชันบันทึกผลการพิจารณา*/ function onSubmit() { - if (actionPass.value) { - confirmpopUp(); - } else { - rejectpopUp(); + 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(""); } } -//pop up ยืนยันการอนุญาต -async function confirmpopUp() { +/** + * ฟังก์ชันยืนยันการอนุญาตผลการพิจารณา + * @param path ประเภทของผู้พิจารณา comander === 'บังคับบัญชา', '' === 'ผู้มีอำนาจ' + */ +async function confirmpopUp(path: string) { dialogConfirm( $q, async () => { @@ -390,7 +355,8 @@ async function confirmpopUp() { config.API.commanderApproveRetirement( "-employee", id.value, - "approve" + "approve", + path ), body ) @@ -411,8 +377,11 @@ async function confirmpopUp() { ); } -//pop up การยับยั้งสำเร็จ -async function rejectpopUp() { +/** + ฟังก์ชันยืนยันการยับยั้งผลการพิจารณา + * @param path ประเภทของผู้พิจารณา comander === 'บังคับบัญชา', '' === 'ผู้มีอำนาจ' + */ +async function rejectpopUp(path: string) { dialogConfirm( $q, async () => { @@ -426,7 +395,8 @@ async function rejectpopUp() { config.API.commanderApproveRetirement( "-employee", id.value, - "reject" + "reject", + path ), body ) @@ -447,9 +417,7 @@ async function rejectpopUp() { ); } -/** - * กดยกเลิก - */ +/** ฟังก์ชันยกเลิกการแก้ไขข้อมูลเพื่อลงบัญชีแนบท้าย*/ async function clickCancel() { edit.value = false; const data = dataDetail.value; @@ -470,17 +438,20 @@ async function clickCancel() { isDiscipline.value = data.isDiscipline; } myForm.value?.resetValidation(); - // await fetchData(id.value); -} -/** - * กดยกเลิก - */ -async function clickCancelConditions() { - await fetchData(id.value); - conditions.value = false; } -/** Function บันทึก รายการตรวจสอบเงื่อนไขต่างๆ*/ +/** ฟังก์ขันยกเลิกการแก้ไขเงื่อนไขต่างๆ*/ +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(); @@ -504,7 +475,7 @@ function onSubmitConditions() { }); } -/** Function บันทึก ,แก้ไขข้อมูลเพื่อลงบัญชีแนบท้าย*/ +/** ฟังก์ชันบันทึกข้อมูลเพื่อลงบัญชีแนบท้าย*/ function onSubmitAttached() { dialogConfirm($q, () => { const formData = new FormData(); @@ -538,7 +509,7 @@ function onSubmitAttached() { } /** - * Function เพิ่ม Class เวลา Edit + * ฟังก์ชัน Class เวลา Edit * @param val เมื่อเป็นEdit จะเปลี่ยน Class */ function getClass(val: boolean) { @@ -548,17 +519,11 @@ function getClass(val: boolean) { }; } -/** แปลง StatusOrder */ -function statusOrder(val: boolean) { - switch (val) { - case true: - return "ยับยั้ง"; - case false: - return "อนุญาต"; - } -} - -// ดาว์นโหลดไฟล์ +/** + * ฟังก์ชันดาว์นโหลดไฟล์ + * @param type นามสกุลไฟล์ + * @param fileName ชื่อไฟล์ที่ต้องการโหลด + */ async function fileDownload(type: string, fileName: string) { showLoader(); await http @@ -575,12 +540,16 @@ async function fileDownload(type: string, fileName: string) { }); } +/** + * ฟังก์ชันอัปเดท modal ของ popup ทะเบียนประวัติ + * @param modal modal + */ function updatemodalPersonal(modal: boolean) { modalPersonal.value = modal; } +/** ฟังก์ชันดึงข้อมูลไฟล์*/ async function fetchFile() { - showLoader(); await http .get(config.API.file("พ้นจากราชการ", "หลักฐานลาออก", id.value)) .then(async (res) => { @@ -588,10 +557,10 @@ async function fetchFile() { }) .catch((e) => { messageError($q, e); - hideLoader(); }); } +/** ฟังก์ชันสร้าง Path ที่เก็บไฟล์*/ function uploadFiles() { showLoader(); http @@ -619,6 +588,10 @@ function uploadFiles() { }); } +/** + * ฟังก์ชันอัปโหลดไฟล์ + * @param uploadUrl ที่อยู่ที่เก็บไฟล์ + */ async function uploadFileURL(uploadUrl: string) { const Data = new FormData(); Data.append("file", file.value); @@ -642,6 +615,10 @@ async function uploadFileURL(uploadUrl: string) { }); } +/** + * ฟังก์ชันโหลดไฟล์ + * @param fileName ชื่อไฟล์ที่ต้องการโหลด + */ async function downloadFiles(fileName: string) { showLoader(); await http @@ -661,13 +638,13 @@ async function downloadFiles(fileName: string) { } /** - * ลบไฟล์ - * @param id id file + * ฟังก์ชันลบไฟล์ + * @param fileName ชื่อไฟล์ที่ต้องการลบ */ function removeFile(fileName: string) { - dialogRemove($q, () => { + dialogRemove($q, async () => { showLoader(); - http + await http .delete( config.API.fileByFile( "พ้นจากราชการ", @@ -676,20 +653,25 @@ function removeFile(fileName: string) { fileName ) ) - .then(() => { + .then(async () => { setTimeout(async () => { await fetchFile(); success($q, `ลบไฟล์สำเร็จ`); - hideLoader(); }, 1000); }) .catch((e) => { messageError($q, e); + }) + .finally(() => { hideLoader(); }); }); } +/** + * ฟังก์ชันแปลงเหตุผลที่ลาออก + * @param val เหตุผลที่ลาออก + */ function convertStatus(val: string) { if (/^[A-Za-z]+$/.test(val)) { switch (val) { @@ -707,12 +689,16 @@ function convertStatus(val: string) { } else return val; } -/** เปิด POP UP */ +/** + * ฟังกฺชันเปิด 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"); @@ -723,6 +709,7 @@ async function checkOfficer() { } } +/** ฟังก์ชันยืนยันการส่งไปพิจารณา*/ function onSend() { dialogConfirm( $q, @@ -730,20 +717,23 @@ function onSend() { showLoader(); http .get(config.API.sendApproveRetirement("-employee", id.value)) - .then(async (res) => { + .then(async () => { await fetchData(id.value); success($q, "ส่งไปพิจารณา"); }) .catch((e) => { messageError($q, e); }) - .finally(() => {}); + .finally(() => { + hideLoader(); + }); }, "ยืนยันการส่งไปพิจารณา", "ต้องการส่งไปพิจารณาใช่หรือไม่" ); } +/** ฟังก์ชันดึงข้อมูลตำแหน่งจาก Keycloak*/ async function fetchKeycloakPosition() { if (keycloakId.value == "") { await http @@ -762,10 +752,10 @@ async function fetchKeycloakPosition() { onMounted(async () => { showLoader(); await Promise.all([ - await fetchData(id.value), - await fetchKeycloakPosition(), + fetchData(id.value), + fetchKeycloakPosition(), fetchFile(), - await checkOfficer(), + checkOfficer(), ]).finally(() => { hideLoader(); }); @@ -797,39 +787,6 @@ onMounted(async () => {
ข้อมูลการลาออก
-
@@ -1011,11 +968,7 @@ onMounted(async () => {
{
- - -
@@ -1229,7 +1137,7 @@ onMounted(async () => { ผลการพิจารณาของผู้บังคับบัญชา
{ -
@@ -1299,25 +1180,19 @@ onMounted(async () => {
{ label="อนุญาต" @click="popUp('pass', 'commander')" /> + { @click="popUp('passNot', 'commander')" />
+
{{ props.row.comment ? props.row.comment : "-" }}
@@ -1375,7 +1244,7 @@ onMounted(async () => { ผลการพิจารณาของผู้มีอำนาจ
{ เพิ่มรายชื่อผู้มีอำนาจ +
{
วันสุดท้ายที่ยับยั้ง
{{ - dataDetail.oligarchRejectDate !== null - ? date2Thai(dataDetail.oligarchRejectDate) + rowsApprover && + rowsApprover.approvers && + rowsApprover.approvers[0]?.rejectDate + ? date2Thai(rowsApprover?.approvers[0].rejectDate) : "-" }}
@@ -1461,19 +1331,23 @@ onMounted(async () => {
ความคิดเห็นและเหตุผล
{{ - dataDetail.oligarchReject - ? dataDetail.oligarchRejectReason - : dataDetail.oligarchApproveReason + rowsApprover && + rowsApprover.approvers && + rowsApprover.approvers[0]?.comment + ? rowsApprover?.approvers[0].comment + : "-" }}
+ + { >คลิกเพื่อส่งไปพิจารณา + {
@@ -1612,24 +1488,7 @@ onMounted(async () => { />
- +
@@ -1731,15 +1590,9 @@ onMounted(async () => {
- -
+ @@ -1825,7 +1678,7 @@ onMounted(async () => { (""); const dataProfile = ref(); +const approveStep = ref(""); -const approveCheck = computed(() => { - return ( - rowsApprover.value?.commanders?.every( - (commander) => commander.approveStatus === "APPROVE" - ) ?? false - ); -}); const idCheck = computed(() => { if ( typeAdd.value == "COMMANDER" && @@ -75,29 +65,6 @@ const idCheck = computed(() => { } }); -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 profileType = ref(""); const keycloakUserId = ref(""); @@ -155,15 +122,6 @@ const columnsCommanders = ref([ 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()); @@ -193,7 +151,6 @@ const dataDetail = ref({ statusMain: "", }); -const workflowRef = ref(null); const organizationPositionOld = ref(""); const positionTypeOld = ref(""); const positionLevelOld = ref(""); @@ -210,32 +167,16 @@ const actionPass = ref(false); const reasonReign = ref(""); const dateBreak = ref(null); -const isCheckData = computed(() => { - if ( - organizationPositionOld.value !== "" && - positionTypeOld.value !== "" && - positionLevelOld.value !== "" && - posNo.value !== "" && - date.value !== null && - dataDetail.value.commanderReject !== null && - dataDetail.value.oligarchReject !== null - ) { - return true; - } else return false; -}); - /**เปิด-ปิด modal */ function closeModal() { modal.value = false; } -function openModal() { - modal.value = true; -} const isNoDebt = ref(false); const isNoBurden = ref(false); const isDiscipline = ref(false); +/** ฟังก์ชันคำนวนวันที่ขอลาออกจากราชการ*/ function diffDate() { if (date.value !== null && dateLeave.value !== null) { const time = dateLeave.value.getTime() - date.value.getTime(); @@ -249,9 +190,11 @@ function diffDate() { return false; } -/** นำข้อมูลมาจาก API*/ +/** + * ฟังก์ชันดึงข้อมูลรายละเอียดการยกเลิกลาออก + * @param id รายการยกเลิกลาออก + */ async function fetchData(id: string) { - showLoader(); await http .get(config.API.listResignEMP() + `/cancel/${id}`) .then(async (res) => { @@ -268,43 +211,55 @@ async function fetchData(id: string) { dateLeave.value = data.activeDate ? new Date(data.activeDate) : null; reason.value = data.reason ?? ""; location.value = data.location ?? ""; + approveStep.value = data.approveStep ?? ""; status.value = data.status ?? ""; remarkHorizontal.value = data.remarkHorizontal ?? "-"; isNoDebt.value = data.isNoDebt; statusCheck.value = data.status; 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); - }) - .finally(() => { - hideLoader(); }); } -/**Pop up */ +/** + * ฟังก์ชันเปิด popup อนุญาต,ไม่อนุญาต + * @param action อนุญาต, ไม่อนุญาต + * @param type ผู้บังคับบัญชา, ผู้มีอำนาจ + */ function popUp(action: "pass" | "passNot", type: string) { reasonReign.value = ""; dateBreak.value = null; actionPass.value = action === "pass"; roleUser.value = type; - openModal(); + modal.value = true; } -//เงื่อนไขpop up +/** ฟังก์ชันยืนยันการอนุญาตผลการพิจารณา*/ function onSubmit() { dialogConfirm($q, async () => { showLoader(); const body = { reason: reasonReign.value, - reject: !actionPass.value, + Date: new Date(), }; + const action = actionPass.value ? "approve" : "reject"; + + const endpoint = + roleUser.value === "commander" + ? config.API.comanderCancelResign("-employee", action, id.value) + : config.API.approverCancelResign("-employee", action, id.value); await http - .put( - config.API.resignRejectEMP(`${roleUser.value}-cancel`, id.value), - body - ) + .put(endpoint, body) .then(async () => { await fetchData(id.value); closeModal(); @@ -319,7 +274,7 @@ function onSubmit() { }); } -/** กดยกเลิก*/ +/** ฟังก์ชันยกเลิกการแก้ไขข้อมูลเพื่อลงบัญชีแนบท้าย*/ async function clickCancel() { edit.value = false; const data = dataDetail.value; @@ -342,7 +297,7 @@ async function clickCancel() { myForm.value?.resetValidation(); } -/** Function บันทึก ,แก้ไขข้อมูลเพื่อลงบัญชีแนบท้าย*/ +/** ฟังก์ชันบันทึกข้อมูลเพื่อลงบัญชีแนบท้าย*/ function onSubmitAttached() { dialogConfirm($q, () => { const formData = new FormData(); @@ -377,7 +332,7 @@ function onSubmitAttached() { } /** - * Function เพิ่ม Class เวลา Edit + * ฟังก์ชัน Class เวลา Edit * @param val เมื่อเป็นEdit จะเปลี่ยน Class */ function getClass(val: boolean) { @@ -387,37 +342,18 @@ function getClass(val: boolean) { }; } -/** แปลง StatusOrder */ -function statusOrder(val: boolean) { - switch (val) { - case true: - return "ยับยั้ง"; - case false: - return "อนุญาต"; - } -} - -const isDirector = ref(false); const isStaff = ref(false); -function fetchCheckIsofficer() { - http - .get(config.API.workflowKeycloakSystem("RETIREMENT_CANCEL_EMP")) - .then((res) => { - isStaff.value = res.data.result.isStaff; - isDirector.value = res.data.result.isDirector; - }) - .catch((err) => { - messageError($q, err); - }); -} - -/** เปิด POP UP */ +/** + * ฟังกฺชันเปิด 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"); @@ -428,27 +364,31 @@ async function checkOfficer() { } } +/** ฟังก์ชันยืนยันการส่งไปพิจารณา*/ function onSend() { dialogConfirm( $q, - () => { + async () => { showLoader(); - http - .get(config.API.sendApproveRetirement("-employee", id.value)) - .then(async (res) => { + await http + .get(config.API.officerCancelResign("-employee", id.value)) + .then(async () => { await fetchData(id.value); success($q, "ส่งไปพิจารณา"); }) .catch((e) => { messageError($q, e); }) - .finally(() => {}); + .finally(() => { + hideLoader(); + }); }, "ยืนยันการส่งไปพิจารณา", "ต้องการส่งไปพิจารณาใช่หรือไม่" ); } +/** ฟังก์ชันดึงข้อมูลตำแหน่งจาก Keycloak*/ async function fetchKeycloakPosition() { if (keycloakId.value == "") { await http @@ -465,11 +405,14 @@ async function fetchKeycloakPosition() { /** Hook */ onMounted(async () => { + showLoader(); await Promise.all([ - await fetchKeycloakPosition(), fetchData(id.value), + fetchKeycloakPosition(), checkOfficer(), - ]); + ]).finally(() => { + hideLoader(); + }); }); @@ -487,7 +430,9 @@ onMounted(async () => { @click="router.push('/retirement/resign-employee')" /> รายละเอียดการยกเลิกลาออก - {{ dataDetail.prefix.dataDetail.firstName + " " + dataDetail.lastName }} + {{ + dataDetail.prefix + dataDetail.firstName + " " + dataDetail.lastName + }} @@ -496,39 +441,6 @@ onMounted(async () => {
ข้อมูลการลาออก
-
@@ -587,7 +499,7 @@ onMounted(async () => { ผลการพิจารณาของผู้บังคับบัญชา
{ เพิ่มรายชื่อผู้บังคับบัญชา -
@@ -656,25 +541,19 @@ onMounted(async () => {
{ @click="popUp('pass', 'commander')" />
@@ -711,7 +582,7 @@ onMounted(async () => {
{{ props.row.approveStatus - ? convertStatusText(props.row.approveStatus) + ? convertStatusText(props.row.approveStatus, "ไม่อนุญาต") : "-" }}
@@ -732,7 +603,8 @@ onMounted(async () => { ผลการพิจารณาของผู้มีอำนาจ
{
{ dense icon-right="close" class="q-px-sm" - label="ยับยั้ง" + label="ไม่อนุญาต" @click="popUp('passNot', 'oligarch')" />
@@ -800,28 +670,24 @@ onMounted(async () => { rowsApprover && rowsApprover.approvers && rowsApprover.approvers[0]?.approveStatus - ? convertStatusText(rowsApprover?.approvers[0].approveStatus) + ? convertStatusText( + rowsApprover?.approvers[0].approveStatus, + "ไม่อนุญาต" + ) : "-" }} - +
ความคิดเห็นและเหตุผล
{{ - dataDetail.oligarchReject - ? dataDetail.oligarchApproveReason - : dataDetail.oligarchApproveReason + rowsApprover && + rowsApprover.approvers && + rowsApprover.approvers[0]?.comment + ? rowsApprover?.approvers[0].comment + : "-" }}
@@ -831,7 +697,7 @@ onMounted(async () => { {
@@ -1103,7 +970,7 @@ onMounted(async () => { @@ -1137,7 +1004,7 @@ onMounted(async () => { ([]); @@ -291,7 +290,11 @@ onMounted(async () => { (route.params.id as string); +const routeName = ref(route?.name as string); + const keyword = ref(""); const isAct = ref(false); @@ -114,6 +116,7 @@ async function getData() { keyword: keyword.value, isAct: isAct.value, keycloakId: props.keycloakUserId, + type: props.profileType === "officer" ? props.profileType : "employee", }) .then(async (res) => { const data = res.data.result; @@ -146,17 +149,25 @@ function onSubmit() { keycloakId: items.keycloakId, })); showLoader(); + const profileSuffix = + (props.profileType?.toLocaleLowerCase() as string) === "officer" + ? "" + : "-employee"; + + const apiEndpoint = + routeName.value === "resignReject" || routeName.value === "resignRejectEMP" + ? config.API.addResignCancel( + profileSuffix, + props.type?.toLocaleLowerCase() as string, + pageId.value + ) + : config.API.addResign( + profileSuffix, + props.type?.toLocaleLowerCase() as string, + pageId.value + ); await http - .post( - config.API.addResign( - (props.profileType?.toLocaleLowerCase() as string) == "officer" - ? "" - : "-employee", - props.type?.toLocaleLowerCase() as string, - pageId.value - ), - body - ) + .post(apiEndpoint, body) .then(async () => { await props.getData?.(pageId.value); closeDialog(); @@ -165,7 +176,9 @@ function onSubmit() { .catch((e) => { messageError($q, e); }) - .finally(() => {}); + .finally(() => { + hideLoader(); + }); } else { closeDialog(); } diff --git a/src/modules/06_retirement/store/Main.ts b/src/modules/06_retirement/store/Main.ts index b63e19d50..8898bbdf2 100644 --- a/src/modules/06_retirement/store/Main.ts +++ b/src/modules/06_retirement/store/Main.ts @@ -18,26 +18,26 @@ export const useRetirementDataStore = defineStore("retirement", () => { case "DONE": return "ออกคำสั่งเสร็จสิ้น"; case "DONECANCEL": - return "ยกเลิกการลาออก"; + return "ยกเลิกการลาออกสำเร็จ"; case "CANCEL": - return "ยกเลิกการลาออก"; + return "ยกเลิกการลาออกสำเร็จ"; case "DONEREJECT": return "ออกคำสั่งยกเลิกลาออกเสร็จแล้ว"; case "CANCELING": - return "กำลังดำเนินการยกเลิก"; + return "กำลังดำเนิดการยกเลิกการ"; default: return "-"; } }; - function convertStatusText(val: string) { + function convertStatusText(val: string, rejectText: string = "ไม่อนุมัติ") { switch (val) { case "PENDING": return "รอดำเนินการ"; case "APPROVE": return "อนุญาต"; case "REJECT": - return "ยับยั้ง"; + return rejectText; } } diff --git a/src/modules/06_retirement/store/resignMain.ts b/src/modules/06_retirement/store/resignMain.ts index 3cede1e6d..c09359120 100644 --- a/src/modules/06_retirement/store/resignMain.ts +++ b/src/modules/06_retirement/store/resignMain.ts @@ -54,7 +54,7 @@ export const useDataStore = defineStore("resign", () => { group: "2", }, { - name: "อนุมัติแล้ว", + name: "อนุญาต/ไม่อนุญาต", value: "APPROVE", group: "2", }, diff --git a/src/modules/06_retirement/views/06_dismissOrder.vue b/src/modules/06_retirement/views/06_dismissOrder.vue index 8ef4d3e7c..5c18462c6 100644 --- a/src/modules/06_retirement/views/06_dismissOrder.vue +++ b/src/modules/06_retirement/views/06_dismissOrder.vue @@ -7,7 +7,11 @@ import { useRouter } from "vue-router"; import http from "@/plugins/http"; import config from "@/app.config"; import { useCounterMixin } from "@/stores/mixin"; -import { checkPermission } from "@/utils/permissions"; +import { + checkPermission, + checkPermissionList, + checkPermissionCreate, +} from "@/utils/permissions"; import { useTransferDataStore } from "@/modules/05_placement/store"; import type { DataOption } from "@/modules/06_retirement/interface/index/Main"; @@ -259,7 +263,11 @@ onMounted(async () => {
{
{ เพิ่มข้อมูล {
{ v-if=" (((isOfficer || isStaff) && snapFilter === 'SNAP2') || roundFilter?.shortCode === 'SPECIAL') && - periodLatest?.group1IsClose + periodLatest?.group1IsClose && + checkPermissionList(['COMMAND']) && + checkPermissionCreate('COMMAND') " > { v-if=" (((isOfficer || isStaff) && snapFilter === 'SNAP2') || roundFilter?.shortCode === 'SPECIAL') && - periodLatest?.group1IsClose + periodLatest?.group1IsClose && + checkPermissionList(['COMMAND']) && checkPermissionCreate('COMMAND') " > {