2023-10-16 18:07:42 +07:00
|
|
|
import { defineStore } from "pinia";
|
|
|
|
|
import { ref } from "vue";
|
|
|
|
|
|
2023-10-17 17:49:31 +07:00
|
|
|
import type { DataOption } from "../interface/index/Main";
|
|
|
|
|
|
2023-10-16 18:07:42 +07:00
|
|
|
export const useComplainstDataStore = defineStore("complainst", () => {
|
|
|
|
|
const rows = ref<any>([])
|
2023-10-17 17:49:31 +07:00
|
|
|
const optionListName = ref<any>([{}])
|
|
|
|
|
|
2023-10-16 18:07:42 +07:00
|
|
|
|
|
|
|
|
function fectComplainst(data: any) {
|
|
|
|
|
let datalist = data.map((e: any) => ({
|
|
|
|
|
subject: e.subject,
|
|
|
|
|
detail: e.detail,
|
|
|
|
|
complainant: e.complainant,
|
|
|
|
|
offenseDescription: e.offenseDescription,
|
|
|
|
|
creationDate: e.creationDate,
|
|
|
|
|
considerationLevel: e.considerationLevel,
|
|
|
|
|
considerationDeadlineDate: e.considerationDeadlineDate,
|
|
|
|
|
}))
|
|
|
|
|
rows.value = datalist
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function selectComplainantTpye(list: any) {
|
|
|
|
|
optionListName.value = list
|
|
|
|
|
}
|
2023-10-17 17:49:31 +07:00
|
|
|
|
|
|
|
|
const complainantoptionsMain = ref<DataOption[]>()
|
|
|
|
|
const complainantoptions = ref<DataOption[]>()
|
|
|
|
|
const agencytoptionsMain = ref<DataOption[]>()
|
|
|
|
|
const agencytoptions = ref<DataOption[]>()
|
|
|
|
|
function fectOptioin(complainantoptions: any, agencytoptions: any) {
|
|
|
|
|
complainantoptionsMain.value = complainantoptions
|
|
|
|
|
agencytoptionsMain.value = agencytoptions
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
function filterSelector(val: any, update: Function, type: string) {
|
|
|
|
|
console.log(val, type);
|
|
|
|
|
let data: DataOption[] | undefined = undefined;
|
|
|
|
|
let filter: DataOption[] | undefined = undefined;
|
|
|
|
|
if (type == "filtercomplainantType") {
|
|
|
|
|
data = complainantoptionsMain.value
|
|
|
|
|
} else if (type == "filteragencytoptions") {
|
|
|
|
|
data = agencytoptionsMain.value
|
|
|
|
|
}
|
|
|
|
|
if (val == "") {
|
|
|
|
|
update(() => {
|
|
|
|
|
filter = data;
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
update(() => {
|
|
|
|
|
if (data) {
|
|
|
|
|
filter = data.filter(
|
|
|
|
|
(e) => e.name.search(val) !== -1
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
if (filter) {
|
|
|
|
|
if (type == "filtercomplainantType") {
|
|
|
|
|
complainantoptions.value = filter
|
|
|
|
|
} else if (type = "filteragencytoptions") {
|
|
|
|
|
agencytoptions.value = filter
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
2023-10-16 18:07:42 +07:00
|
|
|
return {
|
|
|
|
|
rows,
|
|
|
|
|
optionListName,
|
|
|
|
|
fectComplainst,
|
2023-10-17 17:49:31 +07:00
|
|
|
selectComplainantTpye,
|
|
|
|
|
filterSelector,
|
|
|
|
|
fectOptioin,
|
|
|
|
|
complainantoptions,
|
|
|
|
|
agencytoptions,
|
2023-10-16 18:07:42 +07:00
|
|
|
}
|
|
|
|
|
})
|