2023-10-16 18:07:42 +07:00
|
|
|
import { defineStore } from "pinia";
|
|
|
|
|
import { ref } from "vue";
|
|
|
|
|
|
2023-10-19 15:39:18 +07:00
|
|
|
import type { DataOption } from "@/modules/11_discipline/interface/index/Main";
|
|
|
|
|
import type { DataList } from "@/modules/11_discipline/interface/response/complaint"
|
2023-10-18 14:41:11 +07:00
|
|
|
|
2023-10-17 17:49:31 +07:00
|
|
|
|
2023-10-19 15:39:18 +07:00
|
|
|
export const useComplainstDataStore = defineStore("DisciplineComplainst", () => {
|
|
|
|
|
const rows = ref<DataList[]>([])
|
|
|
|
|
function fetchComplainst(data: DataList[]) {
|
|
|
|
|
let datalist = data.map((e: DataList) => ({
|
2023-10-16 18:07:42 +07:00
|
|
|
subject: e.subject,
|
|
|
|
|
detail: e.detail,
|
|
|
|
|
complainant: e.complainant,
|
|
|
|
|
offenseDescription: e.offenseDescription,
|
|
|
|
|
creationDate: e.creationDate,
|
|
|
|
|
considerationLevel: e.considerationLevel,
|
|
|
|
|
considerationDeadlineDate: e.considerationDeadlineDate,
|
|
|
|
|
}))
|
|
|
|
|
rows.value = datalist
|
|
|
|
|
}
|
2023-10-17 17:49:31 +07:00
|
|
|
const complainantoptionsMain = ref<DataOption[]>()
|
|
|
|
|
const complainantoptions = ref<DataOption[]>()
|
|
|
|
|
const agencytoptionsMain = ref<DataOption[]>()
|
|
|
|
|
const agencytoptions = ref<DataOption[]>()
|
2023-10-18 14:41:11 +07:00
|
|
|
const optionListNameMain = ref<DataOption[]>([])
|
|
|
|
|
const optionListName = ref<DataOption[]>([])
|
2023-10-19 15:39:18 +07:00
|
|
|
function fetchOptioin(complainantoptions: any, agencytoptions: any) {
|
2023-10-17 17:49:31 +07:00
|
|
|
complainantoptionsMain.value = complainantoptions
|
|
|
|
|
agencytoptionsMain.value = agencytoptions
|
2023-10-18 14:41:11 +07:00
|
|
|
}
|
|
|
|
|
function selectComplainantTpye(list: any) {
|
|
|
|
|
optionListNameMain.value = list
|
|
|
|
|
optionListName.value = list
|
2023-10-17 17:49:31 +07:00
|
|
|
}
|
2023-10-19 15:39:18 +07:00
|
|
|
function filterSelector(val: string, update: Function, type: string) {
|
2023-10-18 14:41:11 +07:00
|
|
|
update(() => {
|
|
|
|
|
if (type === "filtercomplainantType" && complainantoptionsMain.value) {
|
|
|
|
|
complainantoptions.value = complainantoptionsMain.value.filter(
|
|
|
|
|
(e) => e.name.search(val) !== -1
|
|
|
|
|
);
|
|
|
|
|
} else if (type === "filteragencytoptions" && agencytoptionsMain.value) {
|
|
|
|
|
agencytoptions.value = agencytoptionsMain.value.filter(
|
|
|
|
|
(e) => e.name.search(val) !== -1
|
|
|
|
|
);
|
|
|
|
|
} else if (type === "filtercomplainantOP" && optionListNameMain.value) {
|
|
|
|
|
optionListName.value = optionListNameMain.value.filter(
|
|
|
|
|
(e) => e.name.search(val) !== -1
|
|
|
|
|
);
|
2023-10-17 17:49:31 +07:00
|
|
|
}
|
|
|
|
|
|
2023-10-18 14:41:11 +07:00
|
|
|
})
|
2023-10-17 17:49:31 +07:00
|
|
|
}
|
2023-10-16 18:07:42 +07:00
|
|
|
return {
|
|
|
|
|
rows,
|
|
|
|
|
optionListName,
|
2023-10-19 15:39:18 +07:00
|
|
|
fetchComplainst,
|
2023-10-17 17:49:31 +07:00
|
|
|
selectComplainantTpye,
|
|
|
|
|
filterSelector,
|
2023-10-19 15:39:18 +07:00
|
|
|
fetchOptioin,
|
2023-10-17 17:49:31 +07:00
|
|
|
complainantoptions,
|
|
|
|
|
agencytoptions,
|
2023-10-16 18:07:42 +07:00
|
|
|
}
|
|
|
|
|
})
|