no message

This commit is contained in:
setthawutttty 2023-07-10 09:03:56 +07:00
parent 2ff53b5fa6
commit 07976376bb
3 changed files with 82 additions and 38 deletions

View file

@ -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) {