From 2050ac6b9e21141e8848bfb93b36964698333a83 Mon Sep 17 00:00:00 2001 From: waruneeauy Date: Fri, 1 Aug 2025 10:49:29 +0700 Subject: [PATCH] fix filter kpi --- src/modules/08_KPI/views/main.vue | 9 ++++-- src/modules/08_KPI/views/mainEvaluator.vue | 34 ++++++++++++---------- 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/src/modules/08_KPI/views/main.vue b/src/modules/08_KPI/views/main.vue index 93fbd7c..6a62d27 100644 --- a/src/modules/08_KPI/views/main.vue +++ b/src/modules/08_KPI/views/main.vue @@ -180,8 +180,13 @@ async function fetchRoundOption(type: string) { })); if (type === "main") { roundMainOp.value = list; - round.value = ""; - await fetchList(); + 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 }; diff --git a/src/modules/08_KPI/views/mainEvaluator.vue b/src/modules/08_KPI/views/mainEvaluator.vue index 24692d7..f74d535 100644 --- a/src/modules/08_KPI/views/mainEvaluator.vue +++ b/src/modules/08_KPI/views/mainEvaluator.vue @@ -93,7 +93,7 @@ const maxPage = ref(1); * ดึงข้อมูลรายการขอรับประเมินผลการปฏิบัติราชการระดับบุคคล * @param type */ -async function fetchRoundOption(type: boolean = false) { +async function fetchRoundOption() { showLoader(); await http .get( @@ -101,21 +101,25 @@ 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) => ({ - id: e.id, - name: - e.durationKPI === "OCT" - ? "รอบที่ 2 ตุลาคม" - : e.durationKPI === "APR" - ? "รอบที่ 1 เมษายน" - : "", - })); + const data = res.data.result.data; + const list = + data.map((e: ResRound) => ({ + id: e.id, + name: + e.durationKPI === "OCT" + ? "รอบที่ 2 ตุลาคม" + : 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(); } - 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() " >