diff --git a/src/modules/07_insignia/components/2_Manage/listManage.vue b/src/modules/07_insignia/components/2_Manage/listManage.vue index d86a05ecb..ddc28e172 100644 --- a/src/modules/07_insignia/components/2_Manage/listManage.vue +++ b/src/modules/07_insignia/components/2_Manage/listManage.vue @@ -57,7 +57,11 @@ const fecthlistRound = async () => { if (optionRound.value.length !== 0) { DataStore.optionRound = optionRound.value; const lastValue = optionRound.value[0]; - round.value = lastValue.id.toString(); + if (DataStore.roundId) { + round.value = DataStore.roundId; + } else { + round.value = lastValue.id.toString(); + } DataStore.roundId = round.value; roundName.value = lastValue.name; await fecthStat(round.value); 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/store.ts b/src/modules/07_insignia/store.ts index ebd234f03..29d88e41c 100644 --- a/src/modules/07_insignia/store.ts +++ b/src/modules/07_insignia/store.ts @@ -85,14 +85,16 @@ export const useInsigniaDataStore = defineStore("insignia", () => { } } else typeinsigniaOptions.value = [{ id: "all", name: "ทั้งหมด" }]; }; - const searchDataTable = async (type: string, employeeClass: string) => { - if (type !== 'all' && employeeClass !== 'all') { - rows.value = listinsignia.value.filter((e: any) => e.insigniaSend === type && e.employeeType === profileType(employeeClass)) - } else if (type !== 'all' && employeeClass === 'all') { + const searchDataTable = async (type: string, employeeClasstype: string) => { + typeinsignia.value = type + employeeClass.value = employeeClasstype + if (type !== 'all' && employeeClasstype !== 'all') { + rows.value = listinsignia.value.filter((e: any) => e.insigniaSend === type && e.employeeType === profileType(employeeClasstype)) + } else if (type !== 'all' && employeeClasstype === 'all') { rows.value = listinsignia.value.filter((e: any) => e.insigniaSend === type) - } else if (type === 'all' && employeeClass !== 'all') { - rows.value = listinsignia.value.filter((e: any) => e.employeeType === profileType(employeeClass)) - } else if (type === 'all' && employeeClass === 'all') { + } else if (type === 'all' && employeeClasstype !== 'all') { + rows.value = listinsignia.value.filter((e: any) => e.employeeType === profileType(employeeClasstype)) + } else if (type === 'all' && employeeClasstype === 'all') { rows.value = listinsignia.value } 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,