2023-10-16 18:07:42 +07:00
|
|
|
import { defineStore } from "pinia";
|
|
|
|
|
import { ref } from "vue";
|
2023-10-26 13:47:42 +07:00
|
|
|
import { useCounterMixin } from "@/stores/mixin";
|
2023-10-16 18:07:42 +07:00
|
|
|
|
2023-10-19 15:39:18 +07:00
|
|
|
import type { DataOption } from "@/modules/11_discipline/interface/index/Main";
|
2023-11-14 11:18:52 +07:00
|
|
|
import type { DataList, DataListRow,DataAdd,DataAddResponse } from "@/modules/11_discipline/interface/response/complaint"
|
2023-10-20 10:31:07 +07:00
|
|
|
import type { QTableProps } from "quasar";
|
2023-10-18 14:41:11 +07:00
|
|
|
|
2023-10-26 13:47:42 +07:00
|
|
|
const mixin = useCounterMixin()
|
|
|
|
|
const { date2Thai } = mixin
|
|
|
|
|
|
2023-11-14 11:18:52 +07:00
|
|
|
// id
|
|
|
|
|
// cardId
|
|
|
|
|
// prefix
|
|
|
|
|
// firstName
|
|
|
|
|
// lastName
|
|
|
|
|
// position
|
|
|
|
|
// level
|
|
|
|
|
// oc
|
2023-10-19 15:39:18 +07:00
|
|
|
export const useComplainstDataStore = defineStore("DisciplineComplainst", () => {
|
2023-10-26 13:47:42 +07:00
|
|
|
const rows = ref<DataListRow[]>([])
|
2023-11-14 11:18:52 +07:00
|
|
|
const rowsAdd = ref<DataAdd[]>([])
|
2023-10-20 10:31:07 +07:00
|
|
|
const visibleColumns = ref<string[]>([]);
|
|
|
|
|
const columns = ref<QTableProps["columns"]>([]);
|
2023-11-14 11:18:52 +07:00
|
|
|
|
|
|
|
|
function fetchComplainstAdd(data: DataAddResponse[]) {
|
|
|
|
|
let datalist = data.map((e: DataAddResponse) => ({
|
|
|
|
|
id: e.id,
|
|
|
|
|
cardId: e.cardId,
|
|
|
|
|
fullName:`${e.prefix}${e.firstName} ${e.lastName}`,
|
|
|
|
|
position: e.position,
|
|
|
|
|
level: e.level,
|
|
|
|
|
degree: e.degree,
|
|
|
|
|
oc: e.oc,
|
|
|
|
|
}))
|
|
|
|
|
rowsAdd.value = datalist
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-19 15:39:18 +07:00
|
|
|
function fetchComplainst(data: DataList[]) {
|
|
|
|
|
let datalist = data.map((e: DataList) => ({
|
2023-11-06 17:50:19 +07:00
|
|
|
id: e.id,
|
2023-10-16 18:07:42 +07:00
|
|
|
subject: e.subject,
|
|
|
|
|
detail: e.detail,
|
|
|
|
|
complainant: e.complainant,
|
|
|
|
|
offenseDescription: e.offenseDescription,
|
2023-10-26 13:47:42 +07:00
|
|
|
creationDate: date2Thai(e.creationDate),
|
2023-10-16 18:07:42 +07:00
|
|
|
considerationLevel: e.considerationLevel,
|
2023-10-26 13:47:42 +07:00
|
|
|
considerationDeadlineDate: date2Thai(e.considerationDeadlineDate),
|
2023-10-16 18:07:42 +07:00
|
|
|
}))
|
|
|
|
|
rows.value = datalist
|
|
|
|
|
}
|
2023-10-20 10:31:07 +07:00
|
|
|
// filter options
|
2023-11-06 17:50:19 +07:00
|
|
|
const complainantoptionsMain = ref<DataOption[]>([
|
|
|
|
|
{ id: "0", name: "บุคคล" },
|
2023-11-15 10:53:26 +07:00
|
|
|
{ id: "1", name: "หน่วยงาน" },
|
|
|
|
|
{ id: "2", name: "กรุงเทพมหานคร" },
|
2023-11-06 17:50:19 +07:00
|
|
|
]);
|
|
|
|
|
const complainantoptions = ref<DataOption[]>(complainantoptionsMain.value)
|
|
|
|
|
const agencytoptionsMain = ref<DataOption[]>([
|
|
|
|
|
{ id: "0", name: "หน่ายงานเอ" },
|
|
|
|
|
{ id: "1", name: "หน่ายงานบี" },
|
|
|
|
|
{ id: "2", name: "หน่ายงานชี" },
|
|
|
|
|
]);
|
|
|
|
|
const agencytoptions = ref<DataOption[]>(agencytoptionsMain.value)
|
2023-10-18 14:41:11 +07:00
|
|
|
const optionListNameMain = ref<DataOption[]>([])
|
|
|
|
|
const optionListName = ref<DataOption[]>([])
|
2023-11-06 17:50:19 +07:00
|
|
|
|
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(() => {
|
2023-11-06 17:50:19 +07:00
|
|
|
const needle = val.toLowerCase();
|
|
|
|
|
|
|
|
|
|
if (type === "filtercomplainantType") {
|
2023-10-18 14:41:11 +07:00
|
|
|
complainantoptions.value = complainantoptionsMain.value.filter(
|
2023-11-06 17:50:19 +07:00
|
|
|
(v: any) => v.name.toLowerCase().indexOf(needle) > -1
|
2023-10-18 14:41:11 +07:00
|
|
|
);
|
2023-11-06 17:50:19 +07:00
|
|
|
|
|
|
|
|
} else if (type === "filteragencytoptions") {
|
2023-10-18 14:41:11 +07:00
|
|
|
agencytoptions.value = agencytoptionsMain.value.filter(
|
2023-11-06 17:50:19 +07:00
|
|
|
(v: any) => v.name.toLowerCase().indexOf(needle) > -1
|
2023-10-18 14:41:11 +07:00
|
|
|
);
|
2023-11-06 17:50:19 +07:00
|
|
|
} else if (type === "filtercomplainantOP") {
|
2023-10-18 14:41:11 +07:00
|
|
|
optionListName.value = optionListNameMain.value.filter(
|
2023-11-06 17:50:19 +07:00
|
|
|
(v: any) => v.name.toLowerCase().indexOf(needle) > -1
|
2023-10-18 14:41:11 +07:00
|
|
|
);
|
2023-10-17 17:49:31 +07:00
|
|
|
}
|
|
|
|
|
|
2023-11-06 17:50:19 +07:00
|
|
|
});
|
2023-10-17 17:49:31 +07:00
|
|
|
}
|
2023-10-20 10:31:07 +07:00
|
|
|
|
2023-10-16 18:07:42 +07:00
|
|
|
return {
|
|
|
|
|
rows,
|
2023-11-14 11:18:52 +07:00
|
|
|
rowsAdd,
|
2023-10-20 10:31:07 +07:00
|
|
|
visibleColumns,
|
|
|
|
|
columns,
|
2023-10-19 15:39:18 +07:00
|
|
|
fetchComplainst,
|
2023-10-17 17:49:31 +07:00
|
|
|
selectComplainantTpye,
|
|
|
|
|
filterSelector,
|
|
|
|
|
complainantoptions,
|
|
|
|
|
agencytoptions,
|
2023-10-20 10:31:07 +07:00
|
|
|
optionListName,
|
2023-11-14 11:18:52 +07:00
|
|
|
fetchComplainstAdd
|
2023-10-20 10:31:07 +07:00
|
|
|
|
|
|
|
|
|
2023-10-16 18:07:42 +07:00
|
|
|
}
|
|
|
|
|
})
|