fixing retire condition

This commit is contained in:
Warunee Tamkoo 2025-05-07 23:19:16 +07:00
parent dc14fde9ce
commit d03b161e7b

View file

@ -55,15 +55,15 @@ const roleUser = ref<string>("");
const dataProfile = ref<DataProfile>(); const dataProfile = ref<DataProfile>();
const approveStep = ref<string>(""); const approveStep = ref<string>("");
const approveCheck = computed(() => { // const approveCheck = computed(() => {
return ( // return (
rowsApprover.value?.commanders?.every( // rowsApprover.value?.commanders?.every(
(commander) => // (commander) =>
commander.approveStatus === "APPROVE" || // commander.approveStatus === "APPROVE" ||
commander.approveStatus === "REJECT" // commander.approveStatus === "REJECT"
) ?? false // ) ?? false
); // );
}); // });
const idCheck = computed(() => { const idCheck = computed(() => {
if ( if (
typeAdd.value == "COMMANDER" && typeAdd.value == "COMMANDER" &&
@ -84,36 +84,36 @@ const idCheck = computed(() => {
} }
}); });
const approvePendingCheck = computed(() => { // const approvePendingCheck = computed(() => {
const commanders = rowsApprover.value?.commanders || []; // const commanders = rowsApprover.value?.commanders || [];
const index = commanders.findIndex((c) => c.profileId === keycloakId.value); // const index = commanders.findIndex((c) => c.profileId === myProfileId.value);
if (index === -1) { // if (index === -1) {
return false; // return false;
} // }
const currentCommander = commanders[index]; // const currentCommander = commanders[index];
if (currentCommander.approveStatus !== "PENDING") { // if (currentCommander.approveStatus !== "PENDING") {
return false; // return false;
} // }
if (index === 0) { // if (index === 0) {
return true; // return true;
} // }
const previousApproved = commanders // const previousApproved = commanders
.slice(0, index) // .slice(0, index)
.every( // .every(
(c) => c.approveStatus === "APPROVE" || c.approveStatus === "REJECT" // (c) => c.approveStatus === "APPROVE" || c.approveStatus === "REJECT"
); // );
return previousApproved; // return previousApproved;
}); // });
const isOfficer = ref<boolean>(false); const isOfficer = ref<boolean>(false);
const isStaff = ref<boolean>(false); const isStaff = ref<boolean>(false);
const profileType = ref<string>(""); const profileType = ref<string>("");
const keycloakUserId = ref<string>(""); const keycloakUserId = ref<string>("");
const keycloakId = ref<string>(""); const myProfileId = ref<string>("");
const modalAdd = ref<boolean>(false); const modalAdd = ref<boolean>(false);
const typeAdd = ref<string>(""); const typeAdd = ref<string>("");
const statusCheck = ref<string>(""); const statusCheck = ref<string>("");
@ -371,21 +371,29 @@ function popUp(action: "pass" | "passNot", type: string) {
} }
//pop up //pop up
function onSubmit() { function onSubmit(type: string) {
console.log(roleUser.value); if (roleUser.value === "commander" && actionPass.value) {
if (actionPass.value) { confirmpopUp("/comander");
if (roleUser.value == "commander") { } else if (roleUser.value === "commander" && !actionPass.value) {
confirmpopUp("/comander"); rejectpopUp("/comander");
} else { } else if (roleUser.value === "oligarch" && actionPass.value) {
confirmpopUp(""); confirmpopUp("");
} } else if (roleUser.value === "oligarch" && !actionPass.value) {
} else { rejectpopUp("");
if (roleUser.value == "commander") {
rejectpopUp("/comander");
} else {
rejectpopUp("");
}
} }
// if (actionPass.value) {
// if (type === "approver") {
// confirmpopUp("/comander");
// } else {
// confirmpopUp("");
// }
// } else {
// if (type === "approver") {
// rejectpopUp("/comander");
// } else {
// rejectpopUp("");
// }
// }
} }
//pop up //pop up
@ -753,12 +761,12 @@ function onSend() {
} }
async function fetchKeycloakPosition() { async function fetchKeycloakPosition() {
if (keycloakId.value == "") { if (myProfileId.value == "") {
await http await http
.get(config.API.keycloakPosition()) .get(config.API.keycloakPosition())
.then(async (res) => { .then(async (res) => {
const data = await res.data.result; const data = await res.data.result;
keycloakId.value = data.profileId; myProfileId.value = data.profileId;
}) })
.catch((err) => { .catch((err) => {
messageError($q, err); messageError($q, err);
@ -1313,19 +1321,8 @@ onMounted(async () => {
class="q-gutter-x-xs" class="q-gutter-x-xs"
> >
<q-btn <q-btn
:disable=" v-if="props.row.profileId === myProfileId"
statusCheck == 'NEW' || outline
!approvePendingCheck ||
(props.row.profileId !== keycloakId &&
checkPermission($route)?.attrIsUpdate)
"
:outline="
props.row.profileId !== keycloakId ||
statusCheck == 'NEW' ||
!approvePendingCheck
? false
: true
"
dense dense
color="primary" color="primary"
icon-right="check" icon-right="check"
@ -1334,19 +1331,8 @@ onMounted(async () => {
@click="popUp('pass', 'commander')" @click="popUp('pass', 'commander')"
/> />
<q-btn <q-btn
:disable=" v-if="props.row.profileId === myProfileId"
statusCheck == 'NEW' || outline
!approvePendingCheck ||
(props.row.profileId !== keycloakId &&
checkPermission($route)?.attrIsUpdate)
"
:outline="
props.row.profileId !== keycloakId ||
statusCheck == 'NEW' ||
!approvePendingCheck
? false
: true
"
color="red" color="red"
dense dense
icon-right="close" icon-right="close"
@ -1354,6 +1340,14 @@ onMounted(async () => {
label="ยับยั้ง" label="ยับยั้ง"
@click="popUp('passNot', 'commander')" @click="popUp('passNot', 'commander')"
/> />
<span
v-if="
props.row.comment === '' &&
props.row.profileId !== myProfileId
"
>
-
</span>
</div> </div>
<div v-else> <div v-else>
{{ props.row.comment ? props.row.comment : "-" }} {{ props.row.comment ? props.row.comment : "-" }}
@ -1400,13 +1394,11 @@ onMounted(async () => {
<div <div
class="q-gutter-x-sm" class="q-gutter-x-sm"
v-if=" v-if="
checkPermission($route)?.attrIsUpdate &&
approveStep == 'st3' && approveStep == 'st3' &&
rowsApprover && rowsApprover &&
rowsApprover.approvers && rowsApprover.approvers &&
rowsApprover.approvers[0]?.profileId == keycloakId && rowsApprover.approvers[0]?.profileId == myProfileId &&
rowsApprover.approvers[0]?.approveStatus == 'PENDING' && rowsApprover.approvers[0]?.approveStatus == 'PENDING'
approveCheck
" "
> >
<q-btn <q-btn
@ -1753,7 +1745,7 @@ onMounted(async () => {
<q-dialog v-model="modal" persistent> <q-dialog v-model="modal" persistent>
<q-card style="width: 800px"> <q-card style="width: 800px">
<q-form greedy @submit.prevent @validation-success="onSubmit()"> <q-form greedy @submit.prevent @validation-success="onSubmit('approver')">
<DialogHeader <DialogHeader
:tittle="`${actionPass ? 'อนุญาตการลาออก' : 'ยับยั้งการลาออก'}`" :tittle="`${actionPass ? 'อนุญาตการลาออก' : 'ยับยั้งการลาออก'}`"
:close="closeModal" :close="closeModal"