diff --git a/src/modules/05_placement/components/Main.vue b/src/modules/05_placement/components/Main.vue index a0af21bff..a44c64441 100644 --- a/src/modules/05_placement/components/Main.vue +++ b/src/modules/05_placement/components/Main.vue @@ -3,7 +3,7 @@ import { onMounted, reactive, ref, useAttrs } from "vue"; import type { QTableProps } from "quasar"; import { useQuasar } from "quasar"; import type { FormPlacementMainData } from "@/modules/05_placement/interface/request/Main"; -import type { DataOption } from "@/modules/05_placement/interface/index/Main"; +import type { DataOption,DataOption1 } from "@/modules/05_placement/interface/index/Main"; import { useCounterMixin } from "@/stores/mixin"; import { usePlacementDataStore } from "@/modules/05_placement/store"; import router from "@/router"; @@ -132,12 +132,13 @@ const OriginalDataFetch = async (year: number) => { console.log("🚀 ~ file: Main.vue:160 ~ .then ~ res:", apiData); await DataStore.DataMain(apiData); OriginalData.value = await DataStore.DataMainOrig; - UpdataData.value = OriginalData.value; + UpdataData.value = OriginalData.value.filter((data) => data.fiscalYear === year); // ใช้ค่า fiscalYear ในการกรองข้อมูล } catch (error) { messageError($q, error); } }; + onMounted(async () => { await fiscalYearFilter(); await OriginalDataFetch(fiscalyear.value); @@ -154,43 +155,63 @@ const redirectToPage = (examId?: number) => { //-------------------|เลือกปีงบประมาณ|-----------------------// const fiscalyear = ref(0); -const fiscalyearOP = reactive([{ id: null, name: "ทั้งหมด" }]); +const fiscalyearOP = reactive([{ id: 0, name: "ทั้งหมด" }]); const addedfiscalYearValues: number[] = []; const fiscalYearFilter = async () => { - let maxYear = 0; // เพิ่มตัวแปร maxYear - await http - .get(config.API.yearOptions()) - .then((res: any) => { - console.log("🚀 ", res.data.result); - for (let data of res.data.result) { - fiscalyearOP.push(data); + let maxYear = 0; + try { + const response = await http.get(config.API.yearOptions()); + const dataOptions = response.data.result; + console.log("🚀 ", dataOptions); + for (let data of dataOptions) { + fiscalyearOP.push(data); - if (data.id > maxYear) { - maxYear = data.id; // อัพเดตค่า maxYear ถ้าพบปีที่มากกว่า - } + if (data.id > maxYear) { + maxYear = data.id; } - }) - .catch((e: any) => { - messageError($q, e); - }) - .finally(async () => { - // ตั้งค่า fiscalyear เป็นค่าหลักปีที่มากที่สุด - fiscalyear.value = maxYear; - }); + } + fiscalyear.value = maxYear; + console.log("Selected Year:", fiscalyear.value); + await OriginalDataFetch(fiscalyear.value); // เรียกใช้งานฟังก์ชันที่ดึงข้อมูลใหม่เมื่อมีการเลือกใน fiscalyear + } catch (e) { + messageError($q, e); + } }; + //-------------------|เลือกปีงบประมาณตาม API|--------------------// +interface YearOption { + id: number; + name: number; +} + const searchfiscalyear = async () => { - // API - await http - .get(config.API.yearOptions()) - .then((res: any) => {}) - .catch((e: any) => { - messageError($q, e); - }) - .finally(async () => {}); + try { + const response = await http.get(config.API.yearOptions()); + const dataOptions: YearOption[] = response.data.result; + console.log("🚀 ~ file: Main.vue:189 ~ .then ~ dataOptions:", dataOptions); + + if (fiscalyear.value === 0) { + // Perform any desired operations for selecting "ทั้งหมด" option + // เช่นตัวอย่างข้างล่างนี้ ที่แสดงผลลัพธ์ทั้งหมดใน console.log + console.log("All Year Objects:", dataOptions); + } else { + // Find the selected object based on the chosen year + const selectedYearObject = dataOptions.find((option: YearOption) => option.id === fiscalyear.value); + if (selectedYearObject) { + console.log("Selected Year Object:", selectedYearObject); + // Perform any desired operations with the selected object here + } else { + console.log("No Selected Year Object"); + } + } + } catch (e) { + messageError($q, e); + } }; + + //-------------------|ค้นหาในตาราง|-----------------// const filterKeyword = ref(""); const filterRef = ref(null); @@ -214,7 +235,7 @@ const visibleColumns = ref([ //-------------------|ครั้งที่สอบ|------------------------------// const examTime = ref("all"); -const examTimeOP = reactive([]); +const examTimeOP = reactive([]); const addedExamTimeValues: Set = new Set(); const examTimeFilter = async () => { @@ -236,7 +257,7 @@ const examTimeFilter = async () => { // ประเภทการสอบ const examType = ref("all"); -const examTypeOP = ref([{ id: "all", name: "ทั้งหมด" }]); +const examTypeOP = ref([{ id: "all", name: "ทั้งหมด" }]); const addedExamTypeValues: Set = new Set(); const examTypeFilter = () => { for (const data of OriginalData.value) { diff --git a/src/modules/05_placement/interface/index/Main.ts b/src/modules/05_placement/interface/index/Main.ts index 9a87a2ece..657fbfbd7 100644 --- a/src/modules/05_placement/interface/index/Main.ts +++ b/src/modules/05_placement/interface/index/Main.ts @@ -1,10 +1,14 @@ import type { zipCodeOption } from "../../components/PersonalDetail/profileType"; interface DataOption { + id: number|null; + name:string|null; + disable?: boolean; +} +interface DataOption1 { id: string|null; name:string|null; disable?: boolean; } - interface DataOptionInsignia { id: string; name: string; @@ -61,6 +65,7 @@ export type { AddressOps, Pagination, EduOps, + DataOption1, InsigniaOps, CheckboxItem, }; diff --git a/src/modules/05_placement/interface/request/placement.ts b/src/modules/05_placement/interface/request/placement.ts index b03008bdd..fe67f39a5 100644 --- a/src/modules/05_placement/interface/request/placement.ts +++ b/src/modules/05_placement/interface/request/placement.ts @@ -1,6 +1,5 @@ interface TableName { personalId: string; - profileID: string; position: number; fullName: string; dateOfBirth: string; @@ -8,14 +7,20 @@ interface TableName { ExamOrder: number; unitId: string; UnitGroup: string; + positionNumber:string; + positionPath:string; Unit: string; - ReportingDate: string; //วันที่รายงานตัว - BMAOfficer: string; - Status: string; + reportingDate: string; //วันที่รายงานตัว + bmaOfficer: string; + statusId: string; checkList: any; address: string; university: string; degree: string; + disclaim: string; + profilePhoto:string; + organizationName:string; + organizationShortName:string; major: string; remark: string; number: number; @@ -32,5 +37,18 @@ interface TableName { examResult: string; }; } - -export type { TableName }; \ No newline at end of file +interface PartialTableName { + personalId: string; + fullName: string; + idCard: string; + profilePhoto: string; + organizationName: string; + organizationShortName: string; + positionNumber: string; + positionPath: string; + reportingDate: string; + bmaOfficer: string; + statusId: string; + disclaim: string; +} +export type { TableName ,PartialTableName}; \ No newline at end of file