จัดโค้ดบรรจุ รายชื่อผู้สอบผ่าน
This commit is contained in:
parent
eb80e5e267
commit
9f9879202e
9 changed files with 527 additions and 411 deletions
|
|
@ -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>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue