From e2e24b7717ae54fc70b8788d319eaad9772dda9c Mon Sep 17 00:00:00 2001 From: setthawutttty Date: Wed, 7 May 2025 22:08:48 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=A3=E0=B8=B2=E0=B8=A2=E0=B8=81=E0=B8=B2?= =?UTF-8?q?=E0=B8=A3=E0=B8=A5=E0=B8=B2=E0=B8=AD=E0=B8=AD=E0=B8=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/06_retirement/api.retirement.ts | 6 + .../components/02_resign/ResignByid.vue | 119 ++++++++++++------ .../components/02_resign/ResignReject.vue | 54 +++++--- .../components/03_resignEmp/ResignByid.vue | 93 ++++++-------- .../components/03_resignEmp/ResignReject.vue | 54 +++++--- .../components/DialogAddCommander.vue | 6 +- .../06_retirement/interface/response/Main.ts | 1 + src/modules/06_retirement/store/Main.ts | 16 ++- src/modules/06_retirement/store/resignMain.ts | 14 ++- 9 files changed, 231 insertions(+), 132 deletions(-) diff --git a/src/api/06_retirement/api.retirement.ts b/src/api/06_retirement/api.retirement.ts index fffee4246..e901aaa7e 100644 --- a/src/api/06_retirement/api.retirement.ts +++ b/src/api/06_retirement/api.retirement.ts @@ -76,4 +76,10 @@ export default { //รายงาน retirementReport: `${report}`, + + addResign: (profileType:string,type: string, id: string) => + `${retirement}/resign${profileType}/officer/add-resign/${type}/${id}`, + + sendApproveRetirement:(type:string,id:string)=>`${retirement}/resign${type}/admin/approve/officer/${id}`, + commanderApproveRetirement:(type:string,id:string,typeApprove:string,path:string)=>`${retirement}/resign${type}/admin/${typeApprove}${path}/${id}` }; diff --git a/src/modules/06_retirement/components/02_resign/ResignByid.vue b/src/modules/06_retirement/components/02_resign/ResignByid.vue index eddbfc52c..bd5cbc862 100644 --- a/src/modules/06_retirement/components/02_resign/ResignByid.vue +++ b/src/modules/06_retirement/components/02_resign/ResignByid.vue @@ -9,6 +9,7 @@ import config from "@/app.config"; import genReport from "@/plugins/genreport"; import { useCounterMixin } from "@/stores/mixin"; import { checkPermission } from "@/utils/permissions"; +import { useRetirementDataStore } from "@/modules/06_retirement/store/Main"; import DialogHeader from "@/components/DialogHeader.vue"; @@ -31,6 +32,9 @@ import DialogAddCommander from "@/modules/06_retirement/components/DialogAddComm const $q = useQuasar(); const route = useRoute(); const router = useRouter(); + +const store = useRetirementDataStore(); +const { convertStatusText } = store; const checkRoutePermisson = ref(route.name == "resignDetailbyid"); const mixin = useCounterMixin(); const { @@ -49,11 +53,14 @@ const modalPersonal = ref(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" + (commander) => + commander.approveStatus === "APPROVE" || + commander.approveStatus === "REJECT" ) ?? false ); }); @@ -97,7 +104,9 @@ const approvePendingCheck = computed(() => { const previousApproved = commanders .slice(0, index) - .every((c) => c.approveStatus === "APPROVE"); + .every( + (c) => c.approveStatus === "APPROVE" || c.approveStatus === "REJECT" + ); return previousApproved; }); const isOfficer = ref(false); @@ -141,20 +150,11 @@ const columnsCommanders = ref([ style: "font-size: 14px", }, { - name: "org", - align: "left", - label: "สังกัด", - sortable: true, - field: "org", - headerStyle: "font-size: 14px", - style: "font-size: 14px", - }, - { - name: "สถานะ", + name: "approveStatus", align: "left", label: "สถานะ", sortable: true, - field: "สถานะ", + field: "approveStatus", headerStyle: "font-size: 14px", style: "font-size: 14px", }, @@ -175,6 +175,9 @@ const columnsCommanders = ref([ sortable: true, headerStyle: "font-size: 14px", style: "font-size: 14px", + format(val, row) { + return `${row.rejectDate ? date2Thai(row.rejectDate) : "-"}`; + }, }, ]); const id = ref(route.params.id.toString()); @@ -341,7 +344,8 @@ async function fetchData(id: string) { isNoDebt.value = data.isNoDebt; isNoBurden.value = data.isNoBurden; isDiscipline.value = data.isDiscipline; - + statusCheck.value = data.status; + approveStep.value = data.approveStep; profileType.value = data.profileType; keycloakUserId.value = data.keycloakUserId; rowsApprover.value = { @@ -367,16 +371,24 @@ function popUp(action: "pass" | "passNot", type: string) { } //เงื่อนไขpop up -function onSubmit() { +function onSubmit(type: string) { if (actionPass.value) { - confirmpopUp(); + if (type !== "approver") { + confirmpopUp("/comander"); + } else { + confirmpopUp(""); + } } else { - rejectpopUp(); + if (type !== "approver") { + rejectpopUp("/comander"); + } else { + rejectpopUp(""); + } } } //pop up ยืนยันการอนุญาต -async function confirmpopUp() { +async function confirmpopUp(path: string) { dialogConfirm( $q, async () => { @@ -385,7 +397,10 @@ async function confirmpopUp() { reason: reasonReign.value, }; await http - .put(config.API.resignConfirm(roleUser.value, id.value), body) + .put( + config.API.commanderApproveRetirement("", id.value, "approve", path), + body + ) .then(async () => { await fetchData(id.value); closeModal(); @@ -404,7 +419,7 @@ async function confirmpopUp() { } //pop up การยับยั้งสำเร็จ -async function rejectpopUp() { +async function rejectpopUp(path: string) { dialogConfirm( $q, async () => { @@ -414,7 +429,10 @@ async function rejectpopUp() { date: dateBreak.value, }; await http - .put(config.API.resignReject(roleUser.value, id.value), body) + .put( + config.API.commanderApproveRetirement("", id.value, "reject", path), + body + ) .then(async () => { await fetchData(id.value); closeModal(); @@ -717,10 +735,10 @@ function onSend() { () => { showLoader(); http - .get(config.API.sendApprove(id.value)) + .get(config.API.sendApproveRetirement("", id.value)) .then(async (res) => { - await fetchData(id.value); await fetchFile(); + await fetchData(id.value); success($q, "ส่งไปพิจารณา"); }) .catch((e) => { @@ -733,11 +751,26 @@ function onSend() { ); } +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([ await fetchData(id.value), + await fetchKeycloakPosition(), await checkOfficer(), fetchFile(), ]).finally(() => { @@ -1202,7 +1235,7 @@ onMounted(async () => { { props.row.approveStatus == 'PENDING' && props.row.comment == '' " + class="q-gutter-x-xs" > +
+ {{ + props.row.approveStatus + ? convertStatusText(props.row.approveStatus) + : "-" + }} +
{{ col.value ? col.value : "-" }}
@@ -1340,9 +1381,8 @@ onMounted(async () => {
ผลการพิจารณาของผู้มีอำนาจ
- { class="q-gutter-x-sm" v-if=" checkPermission($route)?.attrIsUpdate && - dataDetail.oligarchReject === null && - dataDetail.statusMain === 'WAITTING' && + approveStep == 'st3' && rowsApprover && rowsApprover.approvers && rowsApprover.approvers[0]?.profileId == keycloakId && @@ -1408,8 +1447,10 @@ onMounted(async () => {
สถานะ
{{ - dataDetail.oligarchReject !== null - ? statusOrder(dataDetail.oligarchReject) + rowsApprover && + rowsApprover.approvers && + rowsApprover.approvers[0]?.approveStatus + ? convertStatusText(rowsApprover?.approvers[0].approveStatus) : "-" }}
@@ -1418,8 +1459,10 @@ onMounted(async () => {
วันสุดท้ายที่ยับยั้ง
{{ - dataDetail.oligarchRejectDate !== null - ? date2Thai(dataDetail.oligarchRejectDate) + rowsApprover && + rowsApprover.approvers && + rowsApprover.approvers[0]?.rejectDate + ? date2Thai(rowsApprover?.approvers[0].rejectDate) : "-" }}
@@ -1428,9 +1471,11 @@ onMounted(async () => {
ความคิดเห็นและเหตุผล
{{ - dataDetail.oligarchReject - ? dataDetail.oligarchRejectReason - : dataDetail.oligarchApproveReason + rowsApprover && + rowsApprover.approvers && + rowsApprover.approvers[0]?.comment + ? rowsApprover?.approvers[0].comment + : "-" }}
@@ -1441,7 +1486,7 @@ onMounted(async () => { { - + (route.name == "resignDetailReject"); const mixin = useCounterMixin(); const { @@ -129,21 +132,13 @@ const columnsCommanders = ref([ 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: "สถานะ", + name: "approveStatus", align: "left", label: "สถานะ", sortable: true, - field: "สถานะ", + field: "approveStatus", headerStyle: "font-size: 14px", style: "font-size: 14px", }, @@ -275,6 +270,7 @@ async function fetchData(id: string) { isNoBurden.value = data.isNoBurden; isDiscipline.value = data.isDiscipline; + statusCheck.value = data.status; profileType.value = data.profileType; keycloakUserId.value = data.keycloakUserId; rowsApprover.value = { @@ -428,7 +424,7 @@ function onSend() { () => { showLoader(); http - .get(config.API.sendApprove(id.value)) + .get(config.API.sendApproveRetirement("", id.value)) .then(async (res) => { await fetchData(id.value); success($q, "ส่งไปพิจารณา"); @@ -443,9 +439,24 @@ function onSend() { ); } +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 () => { await fetchData(id.value); + await fetchKeycloakPosition() await checkOfficer(); }); @@ -566,7 +577,7 @@ onMounted(async () => { ผลการพิจารณาของผู้บังคับบัญชา { {{ props.row.comment ? props.row.comment : "-" }} +
+ {{ + props.row.approveStatus + ? convertStatusText(props.row.approveStatus) + : "-" + }} +
{{ col.value ? col.value : "-" }}
@@ -705,7 +723,7 @@ onMounted(async () => { ผลการพิจารณาของผู้มีอำนาจ {
สถานะ
{{ - dataDetail.oligarchReject !== null - ? statusOrder(dataDetail.oligarchReject) + rowsApprover && + rowsApprover.approvers && + rowsApprover.approvers[0]?.approveStatus + ? convertStatusText(rowsApprover?.approvers[0].approveStatus) : "-" }}
@@ -803,7 +823,7 @@ onMounted(async () => { (route.name == "resignDetailbyidEMP"); const mixin = useCounterMixin(); const { @@ -142,21 +145,13 @@ const columnsCommanders = ref([ 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: "สถานะ", + name: "approveStatus", align: "left", label: "สถานะ", sortable: true, - field: "สถานะ", + field: "approveStatus", headerStyle: "font-size: 14px", style: "font-size: 14px", }, @@ -345,6 +340,7 @@ async function fetchData(id: string) { isNoBurden.value = data.isNoBurden; isDiscipline.value = data.isDiscipline; + statusCheck.value = data.status; profileType.value = data.profileType; keycloakUserId.value = data.keycloakUserId; rowsApprover.value = { @@ -388,7 +384,7 @@ async function confirmpopUp() { reason: reasonReign.value, }; await http - .put(config.API.resignConfirmEMP(roleUser.value, id.value), body) + .put(config.API.commanderApproveRetirement("-employee", id.value,'approve'), body) .then(async () => { await fetchData(id.value); closeModal(); @@ -417,7 +413,7 @@ async function rejectpopUp() { date: dateBreak.value, }; await http - .put(config.API.resignRejectEMP(roleUser.value, id.value), body) + .put(config.API.commanderApproveRetirement('-employee', id.value,'reject'), body) .then(async () => { await fetchData(id.value); closeModal(); @@ -720,7 +716,7 @@ function onSend() { () => { showLoader(); http - .get(config.API.sendApprove(id.value)) + .get(config.API.sendApproveRetirement("-employee", id.value)) .then(async (res) => { await fetchData(id.value); success($q, "ส่งไปพิจารณา"); @@ -735,11 +731,26 @@ function onSend() { ); } +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([ await fetchData(id.value), + await fetchKeycloakPosition(), fetchFile(), await checkOfficer(), ]).finally(() => { @@ -1205,7 +1216,7 @@ onMounted(async () => { ผลการพิจารณาของผู้บังคับบัญชา { {{ props.row.comment ? props.row.comment : "-" }} +
+ {{ + props.row.approveStatus + ? convertStatusText(props.row.approveStatus) + : "-" + }} +
{{ col.value ? col.value : "-" }}
@@ -1335,41 +1353,6 @@ onMounted(async () => { - -
-
-
-
สถานะ
-
- {{ - dataDetail.commanderReject !== null - ? statusOrder(dataDetail.commanderReject) - : "-" - }} -
-
-
-
วันสุดท้ายที่ยับยั้ง
-
- {{ - dataDetail.commanderRejectDate !== null - ? date2Thai(dataDetail.commanderRejectDate) - : "-" - }} -
-
-
-
ความคิดเห็นและเหตุผล
-
- {{ - dataDetail.commanderReject - ? dataDetail.commanderRejectReason - : dataDetail.commanderApproveReason - }} -
-
-
-
@@ -1379,7 +1362,7 @@ onMounted(async () => { ผลการพิจารณาของผู้มีอำนาจ {
สถานะ
{{ - dataDetail.oligarchReject !== null - ? statusOrder(dataDetail.oligarchReject) + rowsApprover && + rowsApprover.approvers && + rowsApprover.approvers[0]?.approveStatus + ? convertStatusText(rowsApprover?.approvers[0].approveStatus) : "-" }}
@@ -1475,7 +1460,7 @@ onMounted(async () => { (route.name == "resignDetailRejectEMP"); const mixin = useCounterMixin(); const { @@ -139,20 +142,11 @@ const columnsCommanders = ref([ style: "font-size: 14px", }, { - name: "org", - align: "left", - label: "สังกัด", - sortable: true, - field: "org", - headerStyle: "font-size: 14px", - style: "font-size: 14px", - }, - { - name: "สถานะ", + name: "approveStatus", align: "left", label: "สถานะ", sortable: true, - field: "สถานะ", + field: "approveStatus", headerStyle: "font-size: 14px", style: "font-size: 14px", }, @@ -281,6 +275,7 @@ async function fetchData(id: string) { status.value = data.status ?? ""; remarkHorizontal.value = data.remarkHorizontal ?? "-"; isNoDebt.value = data.isNoDebt; + statusCheck.value = data.status; isNoBurden.value = data.isNoBurden; isDiscipline.value = data.isDiscipline; }) @@ -446,7 +441,7 @@ function onSend() { () => { showLoader(); http - .get(config.API.sendApprove(id.value)) + .get(config.API.sendApproveRetirement("-employee", id.value)) .then(async (res) => { await fetchData(id.value); success($q, "ส่งไปพิจารณา"); @@ -461,9 +456,23 @@ function onSend() { ); } +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 () => { - await Promise.all([fetchData(id.value), checkOfficer()]); + await Promise.all([await fetchKeycloakPosition(),fetchData(id.value), checkOfficer()]); }); @@ -581,7 +590,7 @@ onMounted(async () => { ผลการพิจารณาของผู้บังคับบัญชา { {{ props.row.comment ? props.row.comment : "-" }} +
+ {{ + props.row.approveStatus + ? convertStatusText(props.row.approveStatus) + : "-" + }} +
{{ col.value ? col.value : "-" }}
@@ -719,7 +735,7 @@ onMounted(async () => { ผลการพิจารณาของผู้มีอำนาจ {
สถานะ
{{ - dataDetail.oligarchReject !== null - ? statusOrder(dataDetail.oligarchReject) + rowsApprover && + rowsApprover.approvers && + rowsApprover.approvers[0]?.approveStatus + ? convertStatusText(rowsApprover?.approvers[0].approveStatus) : "-" }}
@@ -816,7 +834,7 @@ onMounted(async () => { { const statusText = (val: string) => { switch (val) { case "WAITTING": - return "รอดำเนินการ"; + return "ใหม่"; case "PENDING": - return "เลือกตำแหน่งแล้ว"; + return "รอดำเนินการ"; case "APPROVE": return "อนุมัติ"; case "REJECT": @@ -28,7 +28,19 @@ export const useRetirementDataStore = defineStore("retirement", () => { } }; + function convertStatusText(val: string) { + switch (val) { + case "PENDING": + return "รอดำเนินการ"; + case "APPROVE": + return "อนุญาต"; + case "REJECT": + return "ยับยั้ง"; + } + } + return { statusText, + convertStatusText }; }); diff --git a/src/modules/06_retirement/store/resignMain.ts b/src/modules/06_retirement/store/resignMain.ts index b165e3c05..3ab0dcc5d 100644 --- a/src/modules/06_retirement/store/resignMain.ts +++ b/src/modules/06_retirement/store/resignMain.ts @@ -8,10 +8,15 @@ export const useDataStore = defineStore("resign", () => { const mainTabsEMP = ref("1"); const baseOptionStatus = ref([ { - name: "รอดำเนินการ", + name: "ใหม่", value: "WAITTING", group: "1", }, + { + name: "รอดำเนินการ", + value: "PENDING", + group: "1", + }, { name: "อนุมัติแล้ว", value: "APPROVE", @@ -39,10 +44,15 @@ export const useDataStore = defineStore("resign", () => { group: "1", }, { - name: "รอดำเนินการ", + name: "ใหม่", value: "WAITTING", group: "2", }, + { + name: "รอดำเนินการ", + value: "PENDING", + group: "2", + }, { name: "อนุมัติแล้ว", value: "APPROVE",