hrms-mgt/src/modules/11_discipline/store/AppealComplainStore.ts

96 lines
3.8 KiB
TypeScript

import { defineStore } from "pinia";
import { ref } from "vue";
import { useCounterMixin } from "@/stores/mixin";
import type { QTableProps } from "quasar";
import type { DataOption } from '@/modules/11_discipline/interface/index/Main'
import type { MainList, RowList } from '@/modules/11_discipline/interface/response/appealComplain'
export const useAppealComplainStore = defineStore(
"AppealComplainStore",
() => {
const rows = ref<RowList[]>([]);
const visibleColumns = ref<string[]>([]);
const columns = ref<QTableProps["columns"]>([]);
const mixin = useCounterMixin()
const { date2Thai } = mixin
function fetchAppealComplain(data: MainList[]) {
let dataList: RowList[] = data.map((e: MainList) => ({
id: e.id,
type: e.type,
title: e.title,
name: `${e.prefix}${e.firstName} ${e.lastName}`,
prefix: e.prefix,
firstName: e.firstName,
lastName: e.lastName,
idCard: e.idCard,
caseType: e.caseType,
caseNo: e.caseNo,
dateEdit: date2Thai(e.dateEdit),
status: statusTothai(e.status),
}));
rows.value = dataList;
}
const statusTothai = (val: string) => {
switch (val) {
case "NEW":
return "ใหม่";
case "STOP":
return "ยุติเรื่อง";
case "SEND_INVESTIGATE":
return "มีมูลส่งไปสืบสวนแล้ว";
default:
return "-";
}
};
const typeOptions = ref<DataOption[]>([
{ id: "APPEAL", name: "อุทธรณ์" },
{ id: "COMPLAIN", name: "ร้องทุกข์" },
]);
const fiscalyearOP = ref<DataOption[]>([
{ id: "0", name: "ทั้งหมด" },
])
const statusOptions = ref<DataOption[]>([
{ id: "NEW", name: "ใหม่" },
{ id: "xx1", name: "ได้รับเอกสารแล้ว" },
{ id: "xx2", name: "รับอุทธรณ์/ร้องทุกข์" },
{ id: "xx3", name: "ไม่รับอุทธรณ์/ร้องทุกข์" },
{ id: "xx4", name: "ตั้งองค์คณะวินิจฉัย" },
{ id: "xx5", name: "สรุปผลการพิจารณา" },
{ id: "xx6", name: "ปิดคำร้อง" },
]);
// function filterSelector(val: string, update: Function, type: string) {
// update(() => {
// const needle = val.toLowerCase();
// if (type === "yearSelect") {
// complainantoptions.value = mainStore.complainantoptionsMain.filter(
// (v: any) => v.name.toLowerCase().indexOf(needle) > -1
// );
// } else if (type === "filteragencytoptions") {
// agencytoptions.value = consideredAgencytoptions.value.filter(
// (v: any) => v.name.toLowerCase().indexOf(needle) > -1
// );
// } else if (type === "filtercomplainantOP") {
// optionListName.value = optionListNameMain.value.filter(
// (v: any) => v.name.toLowerCase().indexOf(needle) > -1
// );
// }
// });
// }
return {
rows,
visibleColumns,
columns,
fetchAppealComplain,
// filterSelector,
typeOptions,
statusOptions,
fiscalyearOP,
};
}
);