ปลัด

This commit is contained in:
setthawutttty 2024-10-22 09:45:42 +07:00
parent 9d3601f23f
commit 8eed6589d1
3 changed files with 61 additions and 0 deletions

View file

@ -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`,
/**

View file

@ -81,6 +81,7 @@ const formData = reactive<FormDataAgency>({
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<boolean>(false); // . true = false =
const checkIsDeputy = ref<boolean>(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)
);
}
}
</script>
<template>
@ -547,6 +589,23 @@ function onChangeIsOfficer() {
@update:model-value="onChangeIsOfficer"
/>
</div>
<div
v-if="
(actionType === 'ADD' && props.dataNode?.orgLevel === 0) ||
(actionType === 'EDIT' && props.dataNode?.orgLevel === 0)
"
class="col-12"
>
<q-checkbox
keep-color
color="primary"
dense
v-model="formData.isDeputy"
label="สำนักปลัด"
class="q-ml-sm"
@update:model-value="onChangeIsDeputy"
/>
</div>
</div>
</q-card-section>
<q-separator />

View file

@ -30,6 +30,7 @@ interface FormDataAgency {
orgLevelSub: string;
responsibility: string;
isOfficer?: boolean;
isDeputy?: boolean;
}
interface FormDataPosition {