update by req
This commit is contained in:
parent
71884b950f
commit
3aa9b68b23
4 changed files with 185 additions and 296 deletions
|
|
@ -2,7 +2,6 @@
|
|||
import { onMounted, ref, reactive } from "vue";
|
||||
import type { QTableProps } from "quasar";
|
||||
import { useQuasar } from "quasar";
|
||||
import type { FormPlacementMainData } from "@/modules/05_placement/interface/request/Main";
|
||||
import type {
|
||||
DataOption,
|
||||
DataOption1,
|
||||
|
|
@ -17,7 +16,6 @@ const DataStore = usePlacementDataStore();
|
|||
const $q = useQuasar();
|
||||
const mixin = useCounterMixin();
|
||||
const { showLoader, hideLoader, messageError, date2Thai } = mixin;
|
||||
const selectedFiscalYear = ref(0);
|
||||
|
||||
// หัวตาราง
|
||||
const columns = ref<QTableProps["columns"]>([
|
||||
|
|
@ -84,24 +82,20 @@ const columns = ref<QTableProps["columns"]>([
|
|||
{
|
||||
name: "accountStartDate",
|
||||
align: "left",
|
||||
label: "วันที่เริ่มคำสั่ง",
|
||||
label: "วันที่บัญชีใช้ได้ตั้งแต่",
|
||||
sortable: true,
|
||||
field: "accountStartDate",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
sort: (a: string, b: string) =>
|
||||
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
||||
},
|
||||
{
|
||||
name: "accountExpirationDate",
|
||||
align: "left",
|
||||
label: "วันที่บัญชีหมดอายุ",
|
||||
label: "วันที่บัญชีใช้ได้ถึง",
|
||||
sortable: true,
|
||||
field: "accountExpirationDate",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
sort: (a: string, b: string) =>
|
||||
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
||||
},
|
||||
]);
|
||||
// ข้อมูลตาราง (จำลอง)
|
||||
|
|
@ -128,11 +122,6 @@ const visibleColumns = ref([
|
|||
|
||||
onMounted(async () => {
|
||||
await fetchYearOptions();
|
||||
// await fiscalYearFilter();
|
||||
// examTimeFilter();
|
||||
// await examTypeFilter();
|
||||
// expiredAccountFilter();
|
||||
// await searchFilterTable();
|
||||
});
|
||||
const fetchPlacementData = async (val: number) => {
|
||||
showLoader();
|
||||
|
|
@ -159,12 +148,12 @@ const fetchYearOptions = async () => {
|
|||
.then((res) => {
|
||||
const response = res.data.result;
|
||||
yearOptions.push(...response);
|
||||
const maxNumber = yearOptions.reduce((max, e) => {
|
||||
const maxNumber = yearOptions.reduce((max: any, e: any) => {
|
||||
return e.id > max ? e.id : max;
|
||||
}, "");
|
||||
searchYear.value = maxNumber;
|
||||
DataStore.DataMainYearSet(searchYear.value);
|
||||
DataStore.DataMainYear = yearOptions.value;
|
||||
// DataStore.DataMainYear = yearOptions.value;
|
||||
fetchPlacementData(searchYear.value);
|
||||
})
|
||||
.catch((e) => {
|
||||
|
|
@ -176,83 +165,11 @@ const filterYear = () => {
|
|||
fetchPlacementData(searchYear.value);
|
||||
};
|
||||
|
||||
// watchEffect(() => {
|
||||
// rows.value = OriginalData.value;
|
||||
// });
|
||||
// const OriginalDataFetch = async (year: number) => {
|
||||
// yearValue.value = year;
|
||||
// try {
|
||||
// const response = await http.get(config.API.MainDetail(year));
|
||||
// const apiData = response.data.result;
|
||||
// console.log(`🚀 ข้อมูลจากการ get (${year})`, apiData);
|
||||
// await DataStore.DataMain(apiData);
|
||||
// OriginalData.value = await DataStore.DataMainOrig;
|
||||
// UpdataData.value = OriginalData.value.filter(
|
||||
// (data) => data.fiscalYear === year
|
||||
// );
|
||||
// } catch (error) {
|
||||
// messageError($q, error);
|
||||
// }
|
||||
// };
|
||||
|
||||
// ดูรายการสอบแข่งขัน หน้าต่อไป
|
||||
const redirectToPage = (examId?: number) => {
|
||||
router.push(`/placement/pass/${examId}`);
|
||||
};
|
||||
|
||||
//-------------------|เลือกปีงบประมาณ|-----------------------//
|
||||
const fiscalyear = ref<number>(0);
|
||||
const fiscalyearOP = reactive<DataOption[]>([{ id: 0, name: "ทั้งหมด" }]);
|
||||
const addedfiscalYearValues: number[] = [];
|
||||
// const fiscalYearFilter = async () => {
|
||||
// try {
|
||||
// const response = await http.get(config.API.yearOptions());
|
||||
// const dataOptions = response.data.result;
|
||||
// fiscalyearOP.push(...dataOptions);
|
||||
|
||||
// let maxYear = 0;
|
||||
// for (let data of dataOptions) {
|
||||
// if (data.id > maxYear) {
|
||||
// maxYear = data.id;
|
||||
// }
|
||||
// }
|
||||
|
||||
// fiscalyear.value = maxYear;
|
||||
|
||||
// // อัพเดตค่าของ selectedFiscalYear
|
||||
// selectedFiscalYear.value = fiscalyear.value;
|
||||
|
||||
// // โหลดข้อมูลใหม่เมื่อตัวเลือกปีเปลี่ยนแปลง
|
||||
// await OriginalDataFetch(selectedFiscalYear.value);
|
||||
// } catch (e) {
|
||||
// messageError($q, e);
|
||||
// }
|
||||
// };
|
||||
|
||||
//-------------------|เลือกปีงบประมาณตาม API|--------------------//
|
||||
|
||||
// const searchfiscalyear = async () => {
|
||||
// try {
|
||||
// const res = await http.get(config.API.yearOptions());
|
||||
// const dataOptions: YearOption[] = res.data.result;
|
||||
// if (fiscalyear.value === 0) {
|
||||
// await OriginalDataFetch(0);
|
||||
// } else {
|
||||
// const selectedYearObject = dataOptions.find(
|
||||
// (option: YearOption) => option.id === fiscalyear.value
|
||||
// );
|
||||
// OriginalDataFetch(fiscalyear.value);
|
||||
|
||||
// if (selectedYearObject) {
|
||||
// } else {
|
||||
// console.log("No Selected Year Object");
|
||||
// }
|
||||
// }
|
||||
// } catch (e) {
|
||||
// messageError($q, e);
|
||||
// }
|
||||
// };
|
||||
|
||||
//-------------------|ค้นหาในตาราง|-----------------//
|
||||
const filterKeyword = ref<string>("");
|
||||
const filterRef = ref<any>(null);
|
||||
|
|
@ -286,38 +203,8 @@ const examTimeFilter = async () => {
|
|||
const examType = ref<string | null>("all");
|
||||
const examTypeOP = ref<DataOption1[]>([{ id: "all", name: "ทั้งหมด" }]);
|
||||
const addedExamTypeValues: Set<string> = new Set();
|
||||
const data = [
|
||||
{
|
||||
accountEndDate: "2024-06-21T01:22:59.251572",
|
||||
accountExpirationDate: "2024-06-21T01:22:59.251572",
|
||||
accountStartDate: "2023-06-22T01:22:59.251572",
|
||||
examOrder: "1",
|
||||
examRound:
|
||||
"การสอบแข่งขันเพื่อรับบุคคลทั่วไปเข้ารับราชการ ส่วนการจัดการทั่วไป",
|
||||
examTypeName: "แข่งขัน",
|
||||
examTypeValue: "0a846508-4932-40de-9a9e-5b519492211c",
|
||||
fiscalYear: 2566,
|
||||
id: "0a846508-4932-40de-9a9e-5b519492216c",
|
||||
isExpired: false,
|
||||
numberOfCandidates: 1,
|
||||
},
|
||||
{
|
||||
accountEndDate: "2024-06-21T01:22:59.251572",
|
||||
accountExpirationDate: "2024-06-21T01:22:59.251572",
|
||||
accountStartDate: "2023-06-22T01:22:59.251572",
|
||||
examOrder: "2",
|
||||
examRound:
|
||||
"การสอบแข่งขันเพื่อรับบุคคลทั่วไปเข้ารับราชการ ส่วนการจัดการทั่วไป",
|
||||
examTypeName: "แข่งขัน",
|
||||
examTypeValue: "0a846508-4932-40de-9a9e-5b519492211c",
|
||||
fiscalYear: 2566,
|
||||
id: "0a846508-4932-40de-9a9e-5b519492216c",
|
||||
isExpired: false,
|
||||
numberOfCandidates: 1,
|
||||
},
|
||||
];
|
||||
const examTypeFilter = () => {
|
||||
dataPlacement.value.forEach((item) => {
|
||||
dataPlacement.value.forEach((item: any) => {
|
||||
const examTypeName = item.examTypeName;
|
||||
const examTypeValue = item.examTypeValue;
|
||||
if (examTypeName && !addedExamTypeValues.has(examTypeName)) {
|
||||
|
|
@ -345,7 +232,7 @@ const searchFilterTable = async () => {
|
|||
const expiredAccount = ref<boolean>(false);
|
||||
const expiredAccountFilter = async () => {
|
||||
const currentDate = new Date();
|
||||
const updatedRows = dataPlacement.value.map((data) => {
|
||||
const updatedRows = dataPlacement.value.map((data: any) => {
|
||||
let expirationDate = new Date(data.accountExpirationDate);
|
||||
let isExpired = currentDate > expirationDate;
|
||||
|
||||
|
|
@ -356,7 +243,7 @@ const expiredAccountFilter = async () => {
|
|||
|
||||
const paging = ref<boolean>(true);
|
||||
const pagination = ref({
|
||||
sortBy: "desc",
|
||||
sortBy: "accountStartDate",
|
||||
descending: false,
|
||||
page: 1,
|
||||
rowsPerPage: 10,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue