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