From 7c2ce069981075d5b1cbcd8631c3c61f673d9c00 Mon Sep 17 00:00:00 2001 From: "DESKTOP-1R2VSQH\\Lenovo ThinkPad E490" Date: Fri, 15 Sep 2023 17:22:58 +0700 Subject: [PATCH] =?UTF-8?q?filter=20=E0=B9=80=E0=B8=84=E0=B8=A3=E0=B8=B7?= =?UTF-8?q?=E0=B9=88=E0=B8=AD=E0=B8=87=E0=B8=A3=E0=B8=B2=E0=B8=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/4_Allocate/Main.vue | 33 ++++++++++++++----- src/modules/07_insignia/storeAllocate.ts | 11 +++++-- 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/src/modules/07_insignia/components/4_Allocate/Main.vue b/src/modules/07_insignia/components/4_Allocate/Main.vue index 22395ddd2..c7395766d 100644 --- a/src/modules/07_insignia/components/4_Allocate/Main.vue +++ b/src/modules/07_insignia/components/4_Allocate/Main.vue @@ -64,8 +64,18 @@ const fecthRound = async () => { name: "รอบการเสนอขอพระราชทานเครื่องราชปี" + " " + (e.year + 543), year: e.year, })); - selectRound.value = data[0].id; - roundYear.value = data[0].year; + if (DataStore.roundId && DataStore.roundYear) { + selectRound.value = DataStore.roundId; + roundYear.value = DataStore.roundYear; + } else { + selectRound.value = data[0].id; + roundYear.value = data[0].year; + } + if (selectRound.value) { + DataStore.roundId = selectRound.value; + } + + // roundYear.value = data[0].year; if (roundYear.value) { await fecthInsigniaType(); } @@ -94,8 +104,6 @@ const fecthInsignia = async () => { }; const fecthInsigniaType = async () => { - console.log(DataStore.mainTab); - await http(config.API.insigniaType) .then((res) => { let data = res.data.result; @@ -171,14 +179,21 @@ watch(tab, () => { insigniaOp.value = DataStore.insigniaOp.filter( (x: any) => x.type == tab.value || x.type === "" ); - DataStore.insignia = ""; + let a = insigniaOp.value.find((e: any) => e.id == DataStore.insignia); + if (!a) { + DataStore.insignia = ""; + } fecthlistInsignia(); }); -const selectorRound = (round: string) => { +const selectorRound = (round: string | undefined) => { selectRound.value = round; + if (selectRound.value) { + DataStore.roundId = selectRound.value; + } const yearFilter = selectRoundOption.value.find((x: any) => x.id == round); roundYear.value = yearFilter?.year; + DataStore.roundYear = roundYear.value; fecthlistInsignia(); }; @@ -362,8 +377,10 @@ const resetFilter = () => { option-value="id" :readonly="false" :borderless="false" - style="min-width: 150px" - @update:model-value="DataStore.selectInsignia" + style="min-width: 200px" + @update:model-value=" + DataStore.selectInsignia(DataStore.insignia) + " /> diff --git a/src/modules/07_insignia/storeAllocate.ts b/src/modules/07_insignia/storeAllocate.ts index 40b3127a8..0faf10c32 100644 --- a/src/modules/07_insignia/storeAllocate.ts +++ b/src/modules/07_insignia/storeAllocate.ts @@ -8,6 +8,8 @@ const { } = mixin; export const useAllocateDataStore = defineStore("insigniaallocate", () => { + const roundId = ref('') + const roundYear = ref() const insigniaName = ref('') const insignia = ref('') const insigniaOp = ref([{ name: "ทั้งหมด", id: "", type: "" }]) @@ -17,7 +19,7 @@ export const useAllocateDataStore = defineStore("insigniaallocate", () => { const mainTab = ref("") const fetchDatainsignia = async (data: any) => { - insignia.value = '' + // insignia.value = '' insigniaOp.value = [{ name: "ทั้งหมด", id: "", type: "" }] data.forEach((e: any) => { insigniaOp.value.push({ name: e.name, id: e.id, type: e.insigniaType.id }) @@ -41,9 +43,10 @@ export const useAllocateDataStore = defineStore("insigniaallocate", () => { })) rows.value = list listInsignia.value = list + selectInsignia(insignia.value) } - const selectInsignia = () => { - console.log(insignia.value); + const selectInsignia = (type: string) => { + insignia.value = type if (insignia.value !== "") { rows.value = listInsignia.value.filter((e: any) => e.insigniaId === insignia.value) } else rows.value = listInsignia.value @@ -58,6 +61,8 @@ export const useAllocateDataStore = defineStore("insigniaallocate", () => { } } return { + roundId, + roundYear, rows, insignia, insigniaOp,