no message
This commit is contained in:
parent
dc5ea784a3
commit
c296bdfc48
8 changed files with 219 additions and 174 deletions
|
|
@ -1,16 +1,20 @@
|
|||
<script setup lang="ts">
|
||||
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 { useCounterMixin } from "@/stores/mixin";
|
||||
import { usePlacementDataStore } from "@/modules/05_placement/store";
|
||||
import router from "@/router";
|
||||
|
||||
const DataStore = usePlacementDataStore();
|
||||
import http from "@/plugins/http";
|
||||
import config from "@/app.config";
|
||||
|
||||
const DataStore = usePlacementDataStore();
|
||||
const $q = useQuasar();
|
||||
const mixin = useCounterMixin();
|
||||
const { dateText } = mixin;
|
||||
const { dateText, messageError } = mixin;
|
||||
|
||||
// แปลงเวลา ค.ศ ให้เป็น พ.ศ
|
||||
const textDate = (value: Date) => {
|
||||
|
|
@ -29,62 +33,73 @@ const columns = ref<QTableProps["columns"]>([
|
|||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "examRound",
|
||||
name: "name",
|
||||
align: "left",
|
||||
label: "รอบการสอบ",
|
||||
sortable: true,
|
||||
field: "examRound",
|
||||
field: "name",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
sort: (a: string, b: string) =>
|
||||
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
||||
},
|
||||
{
|
||||
name: "examOrder",
|
||||
name: "round",
|
||||
align: "left",
|
||||
label: "ครั้งที่",
|
||||
sortable: true,
|
||||
field: "examOrder",
|
||||
field: "round",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "fiscalYear",
|
||||
name: "year",
|
||||
align: "left",
|
||||
label: "ปีงบประมาณ",
|
||||
sortable: true,
|
||||
field: "fiscalYear",
|
||||
field: "year",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
},
|
||||
{
|
||||
name: "numberofCandidates",
|
||||
name: "number",
|
||||
align: "left",
|
||||
label: "จำนวนผู้สอบได้",
|
||||
sortable: false,
|
||||
field: "numberofCandidates",
|
||||
field: "number",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
sort: (a: string, b: string) =>
|
||||
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
||||
},
|
||||
{
|
||||
name: "examType",
|
||||
name: "placementType",
|
||||
align: "left",
|
||||
label: "ประเภทการสอบ",
|
||||
sortable: false,
|
||||
field: "examType",
|
||||
field: "placementType",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
sort: (a: string, b: string) =>
|
||||
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
||||
},
|
||||
{
|
||||
name: "accountExpirationDate",
|
||||
name: "startDate",
|
||||
align: "left",
|
||||
label: "วันที่เริ่มคำสั่ง",
|
||||
sortable: true,
|
||||
field: "startDate",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
sort: (a: string, b: string) =>
|
||||
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
||||
},
|
||||
{
|
||||
name: "endDate",
|
||||
align: "left",
|
||||
label: "วันที่บัญชีหมดอายุ",
|
||||
sortable: true,
|
||||
field: "accountExpirationDate",
|
||||
field: "endDate",
|
||||
headerStyle: "font-size: 14px",
|
||||
style: "font-size: 14px",
|
||||
sort: (a: string, b: string) =>
|
||||
|
|
@ -95,74 +110,34 @@ const columns = ref<QTableProps["columns"]>([
|
|||
// ข้อมูลตาราง (จำลอง)
|
||||
const rows = ref<FormPlacementMainData[]>([
|
||||
{
|
||||
id: 1,
|
||||
examRound:
|
||||
"การสอบแข่งขันเพื่อรับบุคคลทั่วไปเข้ารับราชการ ส่วนการจัดการทั่วไป",
|
||||
examOrder: 3,
|
||||
fiscalYear: 2023,
|
||||
numberofCandidates: 8,
|
||||
examType: 1,
|
||||
accountExpirationDate: "2023-02-28T14:47:04.1785384Z",
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
examRound:
|
||||
"การสอบแข่งขันเพื่อรับบุคคลทั่วไปเข้ารับราชการ ส่วนการจัดการทั่วไป",
|
||||
examOrder: 2,
|
||||
fiscalYear: 2023,
|
||||
numberofCandidates: 12,
|
||||
examType: 1,
|
||||
accountExpirationDate: "2023-02-28T14:47:04.1785384Z",
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
examRound:
|
||||
"การสอบแข่งขันเพื่อรับบุคคลทั่วไปเข้ารับราชการ ส่วนการจัดการทั่วไป",
|
||||
examOrder: 2,
|
||||
fiscalYear: 2023,
|
||||
numberofCandidates: 20,
|
||||
examType: 1,
|
||||
accountExpirationDate: "2023-01-31T14:47:04.1785384Z",
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
examRound:
|
||||
"การสอบแข่งขันเพื่อรับบุคคลทั่วไปเข้ารับราชการ ส่วนการจัดการทั่วไป",
|
||||
examOrder: 2,
|
||||
fiscalYear: 2022,
|
||||
numberofCandidates: 16,
|
||||
examType: 2,
|
||||
accountExpirationDate: "2023-11-30T14:47:04.1785384Z",
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
examRound:
|
||||
"การสอบแข่งขันเพื่อรับบุคคลทั่วไปเข้ารับราชการ ส่วนการจัดการทั่วไป",
|
||||
examOrder: 1,
|
||||
fiscalYear: 2021,
|
||||
numberofCandidates: 20,
|
||||
examType: 2,
|
||||
accountExpirationDate: "2024-05-21T14:47:04.1785384Z",
|
||||
id: 0,
|
||||
name: "",
|
||||
round:0 ,
|
||||
year: 0,
|
||||
number: 0,
|
||||
placementType: 0,
|
||||
startDate: "",
|
||||
endDate: "",
|
||||
},
|
||||
|
||||
]);
|
||||
|
||||
let OriginalData = ref<FormPlacementMainData[]>([]);
|
||||
let UpdataData = ref<FormPlacementMainData[]>([]);
|
||||
|
||||
const OriginalDataFetch = async () => {
|
||||
// API
|
||||
// await http
|
||||
// .get(config.API.// ตัวอย่าง)
|
||||
// .then((res: any) => {
|
||||
// })
|
||||
// .catch((e: any) => {
|
||||
// messageError($q, e);
|
||||
// })
|
||||
// .finally(async () => {
|
||||
// });
|
||||
await DataStore.DataMain(rows.value);
|
||||
OriginalData.value = await DataStore.DataMainOrig;
|
||||
UpdataData.value = OriginalData.value;
|
||||
await http
|
||||
.get(config.API.MainDetail())
|
||||
.then(async (res: any) => {
|
||||
console.log("🚀 ~ file: Main.vue:160 ~ .then ~ res:", res.data.result);
|
||||
await DataStore.DataMain(res.data.result);
|
||||
OriginalData.value = await DataStore.DataMainOrig;
|
||||
UpdataData.value = OriginalData.value;
|
||||
})
|
||||
.catch((e: any) => {
|
||||
messageError($q, e);
|
||||
})
|
||||
.finally(async () => {});
|
||||
};
|
||||
|
||||
onMounted(async () => {
|
||||
|
|
@ -175,9 +150,9 @@ onMounted(async () => {
|
|||
});
|
||||
|
||||
// ดูรายการสอบแข่งขัน หน้าต่อไป
|
||||
const redirectToPage = (id?: number) => {
|
||||
const redirectToPage = (examId?: number) => {
|
||||
// router.push({ name: 'placementDetail'});
|
||||
router.push(`/placement/detail`);
|
||||
router.push(`/placement/pass/${examId}`);
|
||||
};
|
||||
|
||||
// เลือกปีงบประมาณ
|
||||
|
|
@ -186,44 +161,35 @@ const fiscalyearOP = reactive<DataOption[]>([{ id: 0, name: "ทั้งหม
|
|||
const addedfiscalYearValues: number[] = [];
|
||||
const fiscalYearFilter = async () => {
|
||||
// API
|
||||
// await http
|
||||
// .get(config.API.// ตัวอย่าง)
|
||||
// .then((res: any) => {
|
||||
// DataStore.DataMainYearSet(rows.value);
|
||||
// fiscalyearOP.value = DataStore.DataMainYearGet;
|
||||
// })
|
||||
// .catch((e: any) => {
|
||||
// messageError($q, e);
|
||||
// })
|
||||
// .finally(async () => {
|
||||
// });
|
||||
for (let data of OriginalData.value) {
|
||||
const year = data.fiscalYear + 543;
|
||||
|
||||
if (fiscalyear.value === null || year > fiscalyear.value) {
|
||||
fiscalyear.value = year;
|
||||
}
|
||||
|
||||
if (!addedfiscalYearValues.includes(year)) {
|
||||
fiscalyearOP.push({ id: year, name: year.toString() });
|
||||
addedfiscalYearValues.push(year);
|
||||
}
|
||||
}
|
||||
await http
|
||||
.get(config.API.yearOptions())
|
||||
.then((res: any) => {
|
||||
console.log("🚀 ", res.data.result);
|
||||
for (let data of res.data.result) {
|
||||
fiscalyearOP.push(data);
|
||||
}
|
||||
// DataStore.DataMainYearSet(rows.value);
|
||||
// fiscalyearOP.value = DataStore.DataMainYearGet;
|
||||
})
|
||||
.catch((e: any) => {
|
||||
messageError($q, e);
|
||||
})
|
||||
.finally(async () => {});
|
||||
};
|
||||
|
||||
// เลือกปีงบประมาณตาม API
|
||||
const searchfiscalyear = () => {
|
||||
const searchfiscalyear = async () => {
|
||||
console.log("Input value changed:", fiscalyear.value);
|
||||
// API
|
||||
// await http
|
||||
// .get(config.API.// ตัวอย่าง)
|
||||
// .then((res: any) => {
|
||||
// })
|
||||
// .catch((e: any) => {
|
||||
// messageError($q, e);
|
||||
// })
|
||||
// .finally(async () => {
|
||||
// });
|
||||
await http
|
||||
.get(config.API.yearOptions())
|
||||
.then((res: any) => {
|
||||
console.log("🚀date", res);
|
||||
})
|
||||
.catch((e: any) => {
|
||||
messageError($q, e);
|
||||
})
|
||||
.finally(async () => {});
|
||||
};
|
||||
|
||||
// ค้นหาในตาราง
|
||||
|
|
@ -235,14 +201,15 @@ const resetFilter = () => {
|
|||
};
|
||||
|
||||
const attrs = ref<any>(useAttrs());
|
||||
const visibleColumns = ref<string[]>([
|
||||
"id",
|
||||
"examRound",
|
||||
"examOrder",
|
||||
"fiscalYear",
|
||||
"numberofCandidates",
|
||||
"examType",
|
||||
"accountExpirationDate",
|
||||
const visibleColumns = ref<any[]>([
|
||||
"id",
|
||||
"name",
|
||||
"round",
|
||||
"year",
|
||||
"number",
|
||||
"placementType",
|
||||
"startDate",
|
||||
"endDate",
|
||||
]); //ค้นหา คอลัมน์ คอลัมน์ที่แสดง
|
||||
|
||||
// ครั้งที่สอบ
|
||||
|
|
@ -250,8 +217,8 @@ const examTime = ref<number | null>(null);
|
|||
const examTimeOP = ref<number[]>([]);
|
||||
const examTimeFilter = async () => {
|
||||
for (let data of OriginalData.value) {
|
||||
if (!examTimeOP.value.includes(data.examOrder)) {
|
||||
examTimeOP.value.push(data.examOrder);
|
||||
if (!examTimeOP.value.includes(data.round)) {
|
||||
examTimeOP.value.push(data.round);
|
||||
}
|
||||
}
|
||||
examTimeOP.value.sort((a, b) => a - b); // เรียงลำดับ
|
||||
|
|
@ -263,7 +230,7 @@ const examTypeOP = reactive<DataOption[]>([{ id: 0, name: "ทั้งหมด
|
|||
const addedexamTypeValues: number[] = [];
|
||||
const examTypeFilter = async () => {
|
||||
for (let data of OriginalData.value) {
|
||||
const examTypeValue = data.examType;
|
||||
const examTypeValue = data.placementType;
|
||||
if (examTypeValue == 1 && !addedexamTypeValues.includes(1)) {
|
||||
examTypeOP.push({ id: 1, name: "คัดเลือก" });
|
||||
addedexamTypeValues.push(1);
|
||||
|
|
@ -289,7 +256,7 @@ const expiredAccount = ref<boolean>(false);
|
|||
const expiredAccountFilter = async () => {
|
||||
const currentDate = new Date();
|
||||
const updatedRows = OriginalData.value.map((data) => {
|
||||
let expirationDate = new Date(data.accountExpirationDate);
|
||||
let expirationDate = new Date(data.endDate);
|
||||
let isExpired = expirationDate < currentDate;
|
||||
|
||||
return { ...data, isExpired };
|
||||
|
|
@ -298,7 +265,7 @@ const expiredAccountFilter = async () => {
|
|||
};
|
||||
|
||||
const paging = ref<boolean>(true);
|
||||
const pagination = ref({
|
||||
const pagination = ref({
|
||||
sortBy: "desc",
|
||||
descending: false,
|
||||
page: 1,
|
||||
|
|
@ -454,25 +421,28 @@ const paginationLabel = (start: string, end: string, total: string) => {
|
|||
@click="redirectToPage(props.row.id)"
|
||||
>
|
||||
<q-td key="id" :props="props">
|
||||
{{ props.row.id }}
|
||||
{{ props.rowIndex+1 }}
|
||||
</q-td>
|
||||
<q-td key="examRound" :props="props">
|
||||
{{ props.row.examRound }}
|
||||
<q-td key="name" :props="props">
|
||||
{{ props.row.name }}
|
||||
</q-td>
|
||||
<q-td key="examOrder" :props="props">
|
||||
{{ props.row.examOrder }}
|
||||
<q-td key="round" :props="props">
|
||||
{{ props.row.round }}
|
||||
</q-td>
|
||||
<q-td key="fiscalYear" :props="props">
|
||||
{{ props.row.fiscalYear + 543 }}
|
||||
<q-td key="year" :props="props">
|
||||
{{ props.row.year + 543 }}
|
||||
</q-td>
|
||||
<q-td key="numberofCandidates" :props="props">
|
||||
{{ props.row.numberofCandidates }}
|
||||
<q-td key="number" :props="props">
|
||||
{{ props.row.number }}
|
||||
</q-td>
|
||||
<q-td key="examType" :props="props">
|
||||
{{ props.row.examType == 1 ? "คัดเลือก" : "สอบแข่งขัน" }}
|
||||
<q-td key="placementType" :props="props">
|
||||
{{ props.row.placementType == 1 ? "คัดเลือก" : "สอบแข่งขัน" }}
|
||||
</q-td>
|
||||
<q-td key="accountExpirationDate" :props="props">
|
||||
{{ textDate(props.row.accountExpirationDate) }}
|
||||
<q-td key="startDate" :props="props">
|
||||
{{ textDate(props.row.startDate) }}
|
||||
</q-td>
|
||||
<q-td key="endDate" :props="props">
|
||||
{{ textDate(props.row.endDate) }}
|
||||
</q-td>
|
||||
</q-tr>
|
||||
</template>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue