fix filter kpi

This commit is contained in:
Warunee Tamkoo 2025-08-01 10:49:29 +07:00
parent 8a13dbe06e
commit 2050ac6b9e
2 changed files with 26 additions and 17 deletions

View file

@ -180,8 +180,13 @@ async function fetchRoundOption(type: string) {
})); }));
if (type === "main") { if (type === "main") {
roundMainOp.value = list; roundMainOp.value = list;
round.value = ""; if (data.length === 0) {
await fetchList(); round.value = "";
rows.value = [];
} else {
round.value = roundMainOp.value[0].id;
await fetchList();
}
} else { } else {
roundDialgOp.value = list; roundDialgOp.value = list;
formRound.kpiPeriodId = { id: "", name: "", isClosed: false }; formRound.kpiPeriodId = { id: "", name: "", isClosed: false };

View file

@ -93,7 +93,7 @@ const maxPage = ref<number>(1);
* งขอมลรายการขอรบประเมนผลการปฏราชการระดบบคคล * งขอมลรายการขอรบประเมนผลการปฏราชการระดบบคคล
* @param type * @param type
*/ */
async function fetchRoundOption(type: boolean = false) { async function fetchRoundOption() {
showLoader(); showLoader();
await http await http
.get( .get(
@ -101,21 +101,25 @@ async function fetchRoundOption(type: boolean = false) {
`?page=${1}&pageSize=${10}&keyword=${""}&year=${store.yearRound}` `?page=${1}&pageSize=${10}&keyword=${""}&year=${store.yearRound}`
) )
.then(async (res) => { .then(async (res) => {
const data = await res.data.result.data; const data = res.data.result.data;
const list = data.map((e: ResRound) => ({ const list =
id: e.id, data.map((e: ResRound) => ({
name: id: e.id,
e.durationKPI === "OCT" name:
? "รอบที่ 2 ตุลาคม" e.durationKPI === "OCT"
: e.durationKPI === "APR" ? "รอบที่ 2 ตุลาคม"
? "รอบที่ 1 เมษายน" : e.durationKPI === "APR"
: "", ? "รอบที่ 1 เมษายน"
})); : "",
})) ?? [];
roundOp.value = list; roundOp.value = list;
if (type) { if (data.length === 0) {
store.formQuery.round = ""; store.formQuery.round = "";
dataListMain.value = [];
} else {
store.formQuery.round = roundOp.value[0].id;
await fetchList();
} }
await fetchList();
}) })
.catch((err) => { .catch((err) => {
messageError($q, err); messageError($q, err);
@ -131,7 +135,7 @@ async function fetchList() {
const body = { const body = {
page: store.formQuery.page, page: store.formQuery.page,
pageSize: store.formQuery.pageSize, pageSize: store.formQuery.pageSize,
kpiPeriodId: store.formQuery.round, kpiPeriodId: store.formQuery.round ?? "",
keyword: store.formQuery.keyword, keyword: store.formQuery.keyword,
year: store.yearRound, year: store.yearRound,
status: status:
@ -226,7 +230,7 @@ onMounted(async () => {
year-picker year-picker
:enableTimePicker="false" :enableTimePicker="false"
@update:model-value=" @update:model-value="
(store.formQuery.page = 1), fetchRoundOption(true) (store.formQuery.page = 1), fetchRoundOption()
" "
> >
<template #year="{ year }">{{ year + 543 }}</template> <template #year="{ year }">{{ year + 543 }}</template>