updated structure check isOfficer

This commit is contained in:
Warunee Tamkoo 2024-09-13 15:11:15 +07:00
parent 41359b8c81
commit 32d8a11956
2 changed files with 40 additions and 1 deletions

View file

@ -125,4 +125,6 @@ export default {
*/
orgPermissions: `${organization}/permission/menu`,
orgPermissionsSys: `${organization}/permission`,
checkIsOfficer: (id: string) => `${organization}/check/child1/${id}`,
};

View file

@ -268,6 +268,22 @@ const tittleName = computed(() => {
return name;
});
const checkIsOfficer = ref<boolean>(false); // . true = false =
/** ฟังก์ชั่นเช็คว่าในโครงสร้างแบบร่างมีการเลือก สกจ. หรือยัง */
async function checkOfficer() {
await http
.get(config.API.checkIsOfficer(store.draftId ?? ""))
.then((res) => {
checkIsOfficer.value = res.data.result;
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
}
/**
* callback function ทำงานเม props.modal เป true
*/
@ -275,7 +291,9 @@ watch(
() => props.modal,
() => {
if (props.modal === true) {
//
if (actionType.value === "ADD") {
props.dataNode?.orgLevel === 0 && checkOfficer();
if (props.dataNode) {
formData.orgCode =
props?.dataNode?.orgLevel !== 0
@ -296,7 +314,10 @@ watch(
}
formData.orgLevel == "DEPARTMENT" ? selectOrgLevele("DEPARTMENT") : "";
} else {
}
//
else {
props.dataNode?.orgLevel === 1 && checkOfficer();
if (props.dataNode) {
formData.orgName = props.dataNode.orgTreeName;
formData.orgShortName = props.dataNode.orgTreeShortName;
@ -318,6 +339,22 @@ watch(
}
}
);
/** ถ้ามีการเลือก สกจ. และเคยมีเลือกไปแล้วระบบจะถามและให้ยืนยันการเลือกสกจ. */
watch(
() => formData.isOfficer,
(newData, oldData) => {
if (newData === true && checkIsOfficer.value === true) {
dialogConfirm(
$q,
() => (formData.isOfficer = true),
"ยืนยันการแก้ไข",
"คุณต้องการแก้ไข สกจ. เป็นส่วนราชการนี้ใช่หรือไม่?",
() => (formData.isOfficer = false)
);
}
}
);
</script>
<template>