From 8eed6589d1c8a9c8bc892cf1419fca60f8ba2782 Mon Sep 17 00:00:00 2001 From: setthawutttty Date: Tue, 22 Oct 2024 09:45:42 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=9B=E0=B8=A5=E0=B8=B1=E0=B8=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/02_organizational/api.organization.ts | 1 + .../components/DialogFormAgency.vue | 59 +++++++++++++++++++ .../02_organization/interface/index/Main.ts | 1 + 3 files changed, 61 insertions(+) diff --git a/src/api/02_organizational/api.organization.ts b/src/api/02_organizational/api.organization.ts index f61dfbb26..4c7c93594 100644 --- a/src/api/02_organizational/api.organization.ts +++ b/src/api/02_organizational/api.organization.ts @@ -135,6 +135,7 @@ export default { orgPermissionsSys: `${organization}/permission`, checkIsOfficer: (id: string) => `${organization}/check/child1/${id}`, + checkIsDeputys: (id: string) => `${organization}/check/root/${id}`, orgPosReport:`${orgPos}/report/draft`, /** diff --git a/src/modules/02_organization/components/DialogFormAgency.vue b/src/modules/02_organization/components/DialogFormAgency.vue index 8fd9ae553..318bac59a 100644 --- a/src/modules/02_organization/components/DialogFormAgency.vue +++ b/src/modules/02_organization/components/DialogFormAgency.vue @@ -81,6 +81,7 @@ const formData = reactive({ orgLevelSub: "", responsibility: "", isOfficer: false, + isDeputy: false, }); /** @@ -124,6 +125,13 @@ function onSubmit() { formData.responsibility != null ? formData.responsibility : "", }; + if (type === "Root") { + body = { + ...body, + isDeputy: + formData.isDeputy !== undefined ? String(formData.isDeputy) : "", + }; + } if (type === "Child1") { body = { ...body, @@ -276,6 +284,8 @@ const tittleName = computed(() => { }); const checkIsOfficer = ref(false); // เช็คว่าในโครงสร้างแบบร่างมีการเลือก สกจ. ไหม true = มี false = ไม่มี +const checkIsDeputy = ref(false); // เช็คว่าในโครงสร้างแบบร่างมีการเลือก สำนักปลัด ไหม true = มี false = ไม่มี + /** ฟังก์ชั่นเช็คว่าในโครงสร้างแบบร่างมีการเลือก สกจ. หรือยัง */ async function checkOfficer() { await http @@ -291,6 +301,21 @@ async function checkOfficer() { }); } +/** ฟังก์ชั่นเช็คว่าในโครงสร้างแบบร่างมีการเลือก สกจ. หรือยัง */ +async function onCheckIsDeputy() { + await http + .get(config.API.checkIsDeputys(store.draftId ?? "")) + .then((res) => { + checkIsDeputy.value = res.data.result; + }) + .catch((err) => { + messageError($q, err); + }) + .finally(() => { + hideLoader(); + }); +} + /** * callback function ทำงานเมื่อ props.modal เป็น true */ @@ -301,7 +326,10 @@ watch( // ถ้าเป็นการเพิ่มข้อมูล if (actionType.value === "ADD") { props.dataNode?.orgLevel === 0 && checkOfficer(); + props.dataNode?.orgLevel === 0 && onCheckIsDeputy(); + if (props.dataNode) { + formData.isDeputy = false; formData.orgCode = props?.dataNode?.orgLevel !== 0 ? props?.dataNode.orgTreeCode @@ -336,6 +364,7 @@ watch( formData.orgLevelSub = props.dataNode.orgTreeRankSub; formData.responsibility = props.dataNode.responsibility; formData.isOfficer = props.dataNode.isOfficer ?? false; + formData.isDeputy = props.dataNode.isDeputy ?? false; orgLevelOption.value = props.dataNode.orgTreeRank === "DEPARTMENT" ? orgLevelOptionMain.value @@ -359,6 +388,19 @@ function onChangeIsOfficer() { ); } } + +/** ถ้ามีการเลือก สำนักปลัด และเคยมีเลือกไปแล้วระบบจะถามและให้ยืนยันการเลือกสำนักปลัด */ +function onChangeIsDeputy() { + if (formData.isDeputy == true && checkIsDeputy.value == true) { + dialogConfirm( + $q, + () => (formData.isDeputy = true), + "ยืนยันการแก้ไข", + "คุณต้องการแก้ไข สำนักปลัด เป็นส่วนราชการนี้ใช่หรือไม่?", + () => (formData.isDeputy = false) + ); + } +}