no message
This commit is contained in:
parent
2ff53b5fa6
commit
07976376bb
3 changed files with 82 additions and 38 deletions
|
|
@ -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<number>(0);
|
||||
const fiscalyearOP = reactive<DataOption[]>([{ id: null, name: "ทั้งหมด" }]);
|
||||
const fiscalyearOP = reactive<DataOption[]>([{ 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<string>("");
|
||||
const filterRef = ref<any>(null);
|
||||
|
|
@ -214,7 +235,7 @@ const visibleColumns = ref<any[]>([
|
|||
|
||||
//-------------------|ครั้งที่สอบ|------------------------------//
|
||||
const examTime = ref<number | string>("all");
|
||||
const examTimeOP = reactive<DataOption[]>([]);
|
||||
const examTimeOP = reactive<DataOption1[]>([]);
|
||||
const addedExamTimeValues: Set<number> = new Set();
|
||||
|
||||
const examTimeFilter = async () => {
|
||||
|
|
@ -236,7 +257,7 @@ const examTimeFilter = async () => {
|
|||
|
||||
// ประเภทการสอบ
|
||||
const examType = ref<string | null>("all");
|
||||
const examTypeOP = ref<DataOption[]>([{ id: "all", name: "ทั้งหมด" }]);
|
||||
const examTypeOP = ref<DataOption1[]>([{ id: "all", name: "ทั้งหมด" }]);
|
||||
const addedExamTypeValues: Set<string> = new Set();
|
||||
const examTypeFilter = () => {
|
||||
for (const data of OriginalData.value) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue