diff --git a/src/modules/09_leave/components/05_Leave/DetailLeavePage.vue b/src/modules/09_leave/components/05_Leave/DetailLeavePage.vue index 4f4b2ee46..b74df44e6 100644 --- a/src/modules/09_leave/components/05_Leave/DetailLeavePage.vue +++ b/src/modules/09_leave/components/05_Leave/DetailLeavePage.vue @@ -150,21 +150,41 @@ const rows = ref(); // เช็คสิทธิ์การอนุมัติ const idCheck = computed(() => { if (typeAdd.value == "COMMANDER") { - return rows.value?.commanders.map((items: SeqTypeRow) => items.profileId); + return rows.value?.commanders.map((items: SeqTypeRow) => items.keyId); } else if (typeAdd.value == "APPROVER") { - return rows.value?.approvers.map((items: SeqTypeRow) => items.profileId); + return rows.value?.approvers.map((items: SeqTypeRow) => items.keyId); } }); // เช็คสิทธิ์การเลือกผู้มีอำนาจ const commanderList = computed(() => { - if (typeAdd.value == "COMMANDER") { - return rows.value?.approvers.map((items: SeqTypeRow) => items.profileId); - } else if (typeAdd.value == "APPROVER") { - return rows.value?.commanders.map((items: SeqTypeRow) => items.profileId); + if (typeAdd.value === "COMMANDER") { + return rows.value?.approvers.map((items: SeqTypeRow) => ({ + profileId: items.profileId, + isAct: items.isAct, + })); + } else if (typeAdd.value === "APPROVER") { + return rows.value?.commanders.map((items: SeqTypeRow) => ({ + profileId: items.profileId, + isAct: items.isAct, + })); } + return []; }); +// +const isAct = computed(() => { + if (typeAdd.value === "COMMANDER") { + return rows.value?.commanders && rows.value.commanders.length > 0 + ? rows.value.commanders[0].isAct + : false; + } else if (typeAdd.value === "APPROVER") { + return rows.value?.approvers && rows.value.approvers.length > 0 + ? rows.value.approvers[0].isAct + : false; + } + return false; +}); // เช็คว่าผู้ใช้มีสิทธิ์อนุมัติหรือไม่ const approveCheck = computed(() => { const commanders = rows.value?.commanders; @@ -1272,5 +1292,6 @@ onMounted(async () => { :id-check="idCheck" :keycloak-user-id="keycloakUserId" :commanders-list="commanderList" + :commanders-is-act="isAct" /> diff --git a/src/modules/09_leave/components/05_Leave/Dialog/DialogAddCommander.vue b/src/modules/09_leave/components/05_Leave/Dialog/DialogAddCommander.vue index c3eac2353..f3c2e682f 100644 --- a/src/modules/09_leave/components/05_Leave/Dialog/DialogAddCommander.vue +++ b/src/modules/09_leave/components/05_Leave/Dialog/DialogAddCommander.vue @@ -30,6 +30,7 @@ const props = defineProps({ fetchDetailLeave: Function, idCheck: Array, commandersList: Array, + commandersIsAct: Boolean, }); const pageId = ref(route.params.id as string); @@ -117,7 +118,7 @@ async function getData() { total.value = data.total; rows.value = data.data; selected.value = data.data.filter((items: any) => { - return props.idCheck?.some((i: any) => i === items.id); + return props.idCheck?.some((i: any) => i === items.key); }); }) .catch((err) => { @@ -153,10 +154,14 @@ function onSubmit() { ] .filter(Boolean) .join(" "), + isAct: isAct.value, + keyId: items.key, })); const hasCommander = selected.value.some((e) => - props.commandersList?.some((i: any) => i === e.id) + props.commandersList?.some( + (i: any) => i.profileId === e.id && i.isAct === isAct.value + ) ); if (hasCommander) { @@ -205,6 +210,7 @@ watch( () => modal.value, () => { if (modal.value) { + isAct.value = props.commandersIsAct ?? false; getSearch(); } } @@ -233,6 +239,7 @@ watch( label="ค้นหา" v-model="keyword" style="width: 300px" + @keydown.enter.prevent="onSearchData()" >