no message

This commit is contained in:
setthawutttty 2023-07-05 10:00:36 +07:00
parent e344e5845e
commit dd6ae8c04d
5 changed files with 132 additions and 115 deletions

View file

@ -33,73 +33,73 @@ const columns = ref<QTableProps["columns"]>([
style: "font-size: 14px",
},
{
name: "name",
name: "examRound",
align: "left",
label: "รอบการสอบ",
sortable: true,
field: "name",
field: "examRound",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "round",
name: "examOrder",
align: "left",
label: "ครั้งที่",
sortable: true,
field: "round",
field: "examOrder",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "year",
name: "fiscalYear",
align: "left",
label: "ปีงบประมาณ",
sortable: true,
field: "year",
field: "fiscalYear",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "number",
name: "numberOfCandidates",
align: "left",
label: "จำนวนผู้สอบได้",
sortable: false,
field: "number",
field: "numberOfCandidates",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "placementType",
name: "examTypeName",
align: "left",
label: "ประเภทการสอบ",
sortable: false,
field: "placementType",
field: "examTypeName",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "startDate",
name: "accountStartDate",
align: "left",
label: "วันที่เริ่มคำสั่ง",
sortable: true,
field: "startDate",
field: "accountStartDate",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "endDate",
name: "accountExpirationDate",
align: "left",
label: "วันที่บัญชีหมดอายุ",
sortable: true,
field: "endDate",
field: "accountExpirationDate",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
@ -111,23 +111,23 @@ const columns = ref<QTableProps["columns"]>([
const rows = ref<FormPlacementMainData[]>([
{
id: 0,
name: "",
round:0 ,
year: 0,
number: 0,
placementType: 0,
startDate: "",
endDate: "",
examRound: "",
examOrder: 0,
fiscalYear: 0,
numberOfCandidates: 0,
examTypeValue:"",
examTypeName: "",
accountStartDate: "",
accountExpirationDate: "",
},
]);
let OriginalData = ref<FormPlacementMainData[]>([]);
let UpdataData = ref<FormPlacementMainData[]>([]);
const OriginalDataFetch = async () => {
const OriginalDataFetch = async (year: number) => {
await http
.get(config.API.MainDetail())
.get(config.API.MainDetail(year)) // API
.then(async (res: any) => {
console.log("🚀 ~ file: Main.vue:160 ~ .then ~ res:", res.data.result);
await DataStore.DataMain(res.data.result);
@ -141,12 +141,12 @@ const OriginalDataFetch = async () => {
};
onMounted(async () => {
await OriginalDataFetch();
fiscalYearFilter();
await fiscalYearFilter(); // await fiscalYearFilter()
await OriginalDataFetch(fiscalyear.value); // fiscalyear OriginalDataFetch()
examTimeFilter();
examTypeFilter();
await expiredAccountFilter();
searchFilterTable();
await examTypeFilter();
expiredAccountFilter();
await searchFilterTable();
});
//
@ -156,25 +156,30 @@ const redirectToPage = (examId?: number) => {
};
//
const fiscalyear = ref<number | null>(0);
const fiscalyearOP = reactive<DataOption[]>([{ id: 0, name: "ทั้งหมด" }]);
const fiscalyear = ref<number>(0);
const fiscalyearOP = reactive<DataOption[]>([{ id: "", name: "ทั้งหมด" }]);
const addedfiscalYearValues: number[] = [];
const fiscalYearFilter = async () => {
// API
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);
if (data.id > maxYear) {
maxYear = data.id; // maxYear
}
}
// DataStore.DataMainYearSet(rows.value);
// fiscalyearOP.value = DataStore.DataMainYearGet;
})
.catch((e: any) => {
messageError($q, e);
})
.finally(async () => {});
.finally(async () => {
// fiscalyear
fiscalyear.value = maxYear;
});
};
// API
@ -202,14 +207,15 @@ const resetFilter = () => {
const attrs = ref<any>(useAttrs());
const visibleColumns = ref<any[]>([
"id",
"name",
"round",
"year",
"number",
"placementType",
"startDate",
"endDate",
"id",
"examRound",
"examOrder",
"fiscalYear",
"numberOfCandidates",
"examTypeValue",
"examTypeName",
"accountStartDate",
"accountExpirationDate",
]); //
//
@ -217,38 +223,48 @@ const examTime = ref<number | null>(null);
const examTimeOP = ref<number[]>([]);
const examTimeFilter = async () => {
for (let data of OriginalData.value) {
if (!examTimeOP.value.includes(data.round)) {
examTimeOP.value.push(data.round);
if (!examTimeOP.value.includes(data.examOrder)) {
examTimeOP.value.push(data.examOrder);
}
}
examTimeOP.value.sort((a, b) => a - b); //
};
//
const examType = ref<number | null>(0);
const examTypeOP = reactive<DataOption[]>([{ id: 0, name: "ทั้งหมด" }]);
const addedexamTypeValues: number[] = [];
const examTypeFilter = async () => {
for (let data of OriginalData.value) {
const examTypeValue = data.placementType;
if (examTypeValue == 1 && !addedexamTypeValues.includes(1)) {
examTypeOP.push({ id: 1, name: "คัดเลือก" });
addedexamTypeValues.push(1);
} else if (examTypeValue == 2 && !addedexamTypeValues.includes(2)) {
examTypeOP.push({ id: 2, name: "สอบแข่งขัน" });
addedexamTypeValues.push(2);
const examType = ref<string | null>("");
const examTypeOP = reactive<DataOption[]>([
{ id: "", name: "ทั้งหมด" },
]);
const addedExamTypeValues: Set<string> = new Set();
const examTypeFilter = async () => {
for (const data of OriginalData.value) {
const examTypeName = data.examTypeName;
const examTypeValue = data.examTypeValue;
if (
examTypeName &&
!addedExamTypeValues.has(examTypeName)
) {
examTypeOP.push({
id: examTypeValue,
name: examTypeName,
});
addedExamTypeValues.add(examTypeName);
}
}
};
const searchFilterTable = async () => {
// console.log('Input value changed:', examTime.value, examType.value, expiredAccount.value);
await DataStore.DataUpdateMain(
examTime.value,
examType.value,
expiredAccount.value
);
UpdataData.value = DataStore.DataMainUpdate;
if (examType.value !== undefined && examType.value !== null) {
await DataStore.DataUpdateMain(
examTime.value,
examType.value,
expiredAccount.value
);
UpdataData.value = DataStore.DataMainUpdate;
}
};
//
@ -256,7 +272,7 @@ const expiredAccount = ref<boolean>(false);
const expiredAccountFilter = async () => {
const currentDate = new Date();
const updatedRows = OriginalData.value.map((data) => {
let expirationDate = new Date(data.endDate);
let expirationDate = new Date(data.accountExpirationDate);
let isExpired = expirationDate < currentDate;
return { ...data, isExpired };
@ -366,9 +382,9 @@ const paginationLabel = (start: string, end: string, total: string) => {
dense
emit-value
map-options
option-label="name"
option-label="examTypeName"
:options="examTypeOP"
option-value="id"
option-value="examTypeValue"
lazy-rules
hide-bottom-space
:readonly="false"
@ -421,28 +437,28 @@ const paginationLabel = (start: string, end: string, total: string) => {
@click="redirectToPage(props.row.id)"
>
<q-td key="id" :props="props">
{{ props.rowIndex+1 }}
{{ props.rowIndex + 1 }}
</q-td>
<q-td key="name" :props="props">
{{ props.row.name }}
<q-td key="examRound" :props="props">
{{ props.row.examRound }}
</q-td>
<q-td key="round" :props="props">
{{ props.row.round }}
<q-td key="examOrder" :props="props">
{{ props.row.examOrder }}
</q-td>
<q-td key="year" :props="props">
{{ props.row.year + 543 }}
<q-td key="fiscalYear" :props="props">
{{ props.row.fiscalYear }}
</q-td>
<q-td key="number" :props="props">
{{ props.row.number }}
<q-td key="numberOfCandidates" :props="props">
{{ props.row.numberOfCandidates }}
</q-td>
<q-td key="placementType" :props="props">
{{ props.row.placementType == 1 ? "คัดเลือก" : "สอบแข่งขัน" }}
<q-td key="examTypeName" :props="props">
{{ props.row.examTypeName }}
</q-td>
<q-td key="startDate" :props="props">
{{ textDate(props.row.startDate) }}
<q-td key="accountStartDate" :props="props">
{{ textDate(props.row.accountStartDate) }}
</q-td>
<q-td key="endDate" :props="props">
{{ textDate(props.row.endDate) }}
<q-td key="accountExpirationDate" :props="props">
{{ textDate(props.row.accountExpirationDate) }}
</q-td>
</q-tr>
</template>