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") {
roundMainOp.value = list;
if (data.length === 0) {
round.value = "";
rows.value = [];
} else {
round.value = roundMainOp.value[0].id;
await fetchList();
}
} else {
roundDialgOp.value = list;
formRound.kpiPeriodId = { id: "", name: "", isClosed: false };

View file

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