จัดโค้ดบรรจุ รายชื่อผู้สอบผ่าน

This commit is contained in:
setthawutttty 2023-11-13 13:32:26 +07:00
parent eb80e5e267
commit 9f9879202e
9 changed files with 527 additions and 411 deletions

View file

@ -1,9 +1,10 @@
<script setup lang="ts">
import { useQuasar, QForm } from "quasar";
import { onMounted, reactive, ref, watch } from "vue";
import { useCounterMixin } from "@/stores/mixin";
import DialogHeader from "@/components/DialogHeader.vue";
import DialogFooter from "@/modules/05_placement/components/PersonalList/DialogFooter.vue";
import { useCounterMixin } from "@/stores/mixin";
import http from "@/plugins/http";
import config from "@/app.config";
@ -28,8 +29,26 @@ const selectedFile = ref<string>("");
const dataRespone = ref<any>();
const search = ref<string>("");
const filterRef = ref<any>(null);
const personal = ref<any>();
const expanded = ref<string[]>([]);
const editDataStatus = ref<boolean>(false);
const placementPosition = ref<any>([]);
const treeData = ref<Array<any>>([]);
// Set form field
//
const posNoOptions = ref<Object[]>([{ label: "", value: "" }]);
//
const positionOptions = ref<Object[]>([{ label: "", value: "" }]);
// /
const positionPathSideOptions = ref<Object[]>([{ label: "", value: "" }]);
//
const positionTypeOptions = ref<Object[]>([{ label: "", value: "" }]);
//
const positionLineOptions = ref<Object[]>([{ label: "", value: "" }]);
//
const positionLevelOptions = ref<Object[]>([{ label: "", value: "" }]);
/** กำหนดตัวแปร เเบบ ออปเจ็ค */
let dataForm = reactive({
personalId: "",
containDate: new Date(),
@ -41,12 +60,8 @@ let dataForm = reactive({
positionTypeId: "",
});
onMounted(async () => {
await fetchPublishFile();
await loadTreeData();
await fetchplacementPosition();
});
const fetchPublishFile = async () => {
/** ฟังชั่น get file*/
async function fetchPublishFile(){
await http
.get(config.API.getPublishFileHistory)
.then((res) => {
@ -61,8 +76,7 @@ const fetchPublishFile = async () => {
});
};
// json
const treeData = ref<Array<any>>([]);
/** โหลดข้อมูลโครงสร้างจาก json */
const loadTreeData = async () => {
expanded.value = [];
await http
@ -83,6 +97,11 @@ const loadTreeData = async () => {
});
};
/**
* งกนกรองขอมลท personId เป null
* @param obj อมลทจะถกกรอง
* @returns {boolean} ผลลพธของการกรองขอม
*/
function filterByPersonIdNull(obj: any) {
if (obj.name === null && obj.isCondition != true) {
return true;
@ -94,9 +113,8 @@ function filterByPersonIdNull(obj: any) {
return false;
}
// position
const placementPosition = ref<any>([]);
const fetchplacementPosition = async () => {
/**get data ตำแหน่งงาน */
async function fetchplacementPosition() {
await http
.get(config.API.placementPosition())
.then((res: any) => {
@ -105,8 +123,9 @@ const fetchplacementPosition = async () => {
.catch((e: any) => {
messageError($q, e);
});
};
}
/** รับค่ามาจาก หน้าหลัก*/
const props = defineProps({
personalId: String,
modal: Boolean,
@ -116,8 +135,14 @@ const props = defineProps({
},
personal: Object,
});
// filter
const myFilterMethod = (node: any, filter: string) => {
/**
* งกนกรองขอมลหนวยงาน
* @param node อมลทจะถกกรอง
* @param filter อความทใชในการกรองขอม
* @returns {boolean} ผลลพธของการกรองขอม
*/
function myFilterMethod(node: any, filter: string) {
const filt = filter;
return (
// ((node.name && node.name == null) || !node.name) &&
@ -139,18 +164,20 @@ const myFilterMethod = (node: any, filter: string) => {
node.executivePositionSide.indexOf(filt) > -1) ||
(node.positionLevel && node.positionLevel.indexOf(filt) > -1)
);
};
}
const validateData = async () => {
/** validate */
async function validateData() {
checkValidate.value = true;
await myFormPosition.value.validate().then((result: boolean) => {
if (result == false) {
checkValidate.value = false;
}
});
};
//
const saveAppoint = async () => {
}
/** ยืนยันการเลือกหน่วยงาน */
async function saveAppoint() {
myFormPosition.value.validate().then(async (result: boolean) => {
if (result) {
const dataAppoint = await {
@ -183,11 +210,10 @@ const saveAppoint = async () => {
});
}
});
};
}
const editDataStatus = ref<boolean>(false);
const closeModal = () => {
/** ปิด dialog */
function closeModal() {
if (editDataStatus.value == true) {
dialogConfirm(
$q,
@ -198,9 +224,9 @@ const closeModal = () => {
} else {
closeAndClear();
}
};
// clean
const closeAndClear = async () => {
}
/** clean ข้อมูล */
async function closeAndClear() {
await props.close();
editDataStatus.value = false;
selected.value = "";
@ -212,51 +238,13 @@ const closeAndClear = async () => {
dataForm.positionLineId = "";
dataForm.positionPathSideId = "";
dataForm.positionTypeId = "";
};
//
const posNoOptions = ref<Object[]>([
{
label: "",
value: "",
},
]);
//
const positionOptions = ref<Object[]>([
{
label: "",
value: "",
},
]);
// /
const positionPathSideOptions = ref<Object[]>([
{
label: "",
value: "",
},
]);
//
const positionTypeOptions = ref<Object[]>([
{
label: "",
value: "",
},
]);
//
const positionLineOptions = ref<Object[]>([
{
label: "",
value: "",
},
]);
//
const positionLevelOptions = ref<Object[]>([
{
label: "",
value: "",
},
]);
//
const selectedPosition = async (data: any) => {
}
/**
* เลอกหนวยงาน
* @param data อมลตำเเหนงงาน
*/
async function selectedPosition(data: any) {
if (data.name == null && selected.value != data.keyId) {
editDataStatus.value = true;
selected.value = data.keyId;
@ -338,43 +326,21 @@ const selectedPosition = async (data: any) => {
dataForm.positionPathSideId = "";
dataForm.positionTypeId = "";
}
};
}
const checkPosition = (val: string) => {
/**
* เชคตำแหน งาน
* @param val id ตำแหน
*/
function checkPosition(val: string) {
const num = placementPosition.value.findIndex((e: string) => e === val);
return num;
};
const personal = ref<any>();
const expanded = ref<string[]>([]);
// props
watch(props, () => {
expanded.value = [];
const dataPersonal = props.personal;
fetchplacementPosition();
if (dataPersonal) {
dataPersonal.map((data: any) => {
personal.value = data;
});
}
if (
personal.value &&
personal.value.draft === false &&
personal.value.positionNumber !== null
) {
let findData: any = null;
dataRespone.value.map((x: any) => {
findData = findByPerson(x);
// expandedTree
if (findData != null) {
selectedPosition(findData);
for (let i = 3; i <= findData.keyId.length; i += 2) {
expanded.value.push(findData.keyId.slice(0, i));
}
}
});
}
});
//
}
/**
* หาหนวยงานทเลอก
* @param element
*/
function findByPerson(element: any): any {
if (
element.positionNumId &&
@ -395,17 +361,19 @@ function findByPerson(element: any): any {
}
return null;
}
//
const clearPosition = () => {
/** ยืนยันการคืนตำแหน่ง */
function clearPosition() {
dialogConfirm(
$q,
async () => postClearPosition(),
"ยืนยันการคืนตำแหน่ง",
"ต้องการยืนยันการคืนตำแหน่งนี้ใช่หรือไม่ ?"
);
};
//
const postClearPosition = async () => {
}
/** คืนตำแหน่ง */
async function postClearPosition() {
showLoader();
await http
.post(config.API.clearPosition(personal.value.personalId), {})
@ -419,7 +387,42 @@ const postClearPosition = async () => {
hideLoader();
await closeAndClear();
});
};
}
/** เมื่อ props เปลี่ยนแปลงจะโหลดหน่วยงาน */
watch(props, () => {
expanded.value = [];
const dataPersonal = props.personal;
fetchplacementPosition();
if (dataPersonal) {
dataPersonal.map((data: any) => {
personal.value = data;
});
}
if (
personal.value &&
personal.value.draft === false &&
personal.value.positionNumber !== null
) {
let findData: any = null;
dataRespone.value.map((x: any) => {
findData = findByPerson(x);
// expandedTree
if (findData != null) {
selectedPosition(findData);
for (let i = 3; i <= findData.keyId.length; i += 2) {
expanded.value.push(findData.keyId.slice(0, i));
}
}
});
}
});
onMounted(async () => {
await fetchPublishFile();
await loadTreeData();
await fetchplacementPosition();
});
</script>
<template>