290 lines
8 KiB
TypeScript
290 lines
8 KiB
TypeScript
import { defineStore } from "pinia";
|
|
import { ref } from "vue";
|
|
import type { QTableProps } from "quasar";
|
|
import type {
|
|
DataOption,
|
|
directorType,
|
|
} from "@/modules/11_discipline/interface/index/Main";
|
|
import type {
|
|
DataResult,
|
|
DataResultList,
|
|
} from "@/modules/11_discipline/interface/response/result";
|
|
import { useCounterMixin } from "@/stores/mixin";
|
|
|
|
import { useDisciplineMainStore } from "@/modules/11_discipline/store/main";
|
|
const mixin = useCounterMixin();
|
|
const storeMain = useDisciplineMainStore();
|
|
const { date2Thai } = mixin;
|
|
|
|
export const useDisciplineResultStore = defineStore(
|
|
"disciplineResultStore",
|
|
() => {
|
|
const tabMenu = ref<string>("result");
|
|
const rows = ref<DataResultList[]>([]);
|
|
const rows2 = ref<directorType[]>([]);
|
|
const selected = ref<directorType[]>([]);
|
|
|
|
const complainantoptions = ref<DataOption[]>(
|
|
storeMain.complainantoptionsMain
|
|
);
|
|
|
|
const visibleColumns = ref<String[]>([
|
|
"no",
|
|
"title",
|
|
"respondentType",
|
|
"offenseDetails",
|
|
"disciplinaryFaultLevel",
|
|
"disciplinaryCaseFault",
|
|
"createdAt",
|
|
"disciplineType",
|
|
"titleType",
|
|
"oc",
|
|
"status",
|
|
]);
|
|
|
|
const columns = ref<QTableProps["columns"]>([
|
|
{
|
|
name: "no",
|
|
align: "center",
|
|
label: "ลำดับ",
|
|
sortable: false,
|
|
field: "no",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
},
|
|
{
|
|
name: "title",
|
|
align: "left",
|
|
label: "เรื่องร้องเรียน",
|
|
sortable: true,
|
|
field: "title",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
},
|
|
{
|
|
name: "respondentType",
|
|
align: "left",
|
|
label: "ผู้ถูกสอบสวน",
|
|
sortable: true,
|
|
field: "respondentType",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
sort: (a: string, b: string) =>
|
|
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
|
},
|
|
{
|
|
name: "offenseDetails",
|
|
align: "left",
|
|
label: "ลักษณะความผิด",
|
|
sortable: true,
|
|
field: "offenseDetails",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
sort: (a: string, b: string) =>
|
|
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
|
},
|
|
{
|
|
name: "disciplinaryFaultLevel",
|
|
align: "left",
|
|
label: "ระดับโทษความผิด",
|
|
sortable: true,
|
|
field: "disciplinaryFaultLevel",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
sort: (a: string, b: string) =>
|
|
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
|
},
|
|
{
|
|
name: "disciplinaryCaseFault",
|
|
align: "left",
|
|
label: "กรณีความผิด",
|
|
sortable: true,
|
|
field: "disciplinaryCaseFault",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
sort: (a: string, b: string) =>
|
|
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
|
},
|
|
{
|
|
name: "createdAt",
|
|
align: "left",
|
|
label: "วันที่สอบสวน",
|
|
sortable: true,
|
|
field: "createdAt",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
},
|
|
{
|
|
name: "disciplineType",
|
|
align: "left",
|
|
label: "ประเภทวินัย",
|
|
sortable: true,
|
|
field: "disciplineType",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
},
|
|
{
|
|
name: "titleType",
|
|
align: "left",
|
|
label: "ประเภทของเรื่อง",
|
|
sortable: true,
|
|
field: "titleType",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
},
|
|
{
|
|
name: "oc",
|
|
align: "left",
|
|
label: "หน่วยงาน/ส่วนราชการ",
|
|
sortable: true,
|
|
field: "oc",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
},
|
|
{
|
|
name: "status",
|
|
align: "left",
|
|
label: "สถานะ",
|
|
sortable: true,
|
|
field: "status",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
},
|
|
]);
|
|
|
|
const visibleColumnsDirector = ref<String[]>([
|
|
"no",
|
|
"name",
|
|
"position",
|
|
"duty",
|
|
"email",
|
|
"telephone",
|
|
"role",
|
|
]);
|
|
|
|
const columnsDirector = ref<QTableProps["columns"]>([
|
|
{
|
|
name: "no",
|
|
align: "left",
|
|
label: "ลำดับ",
|
|
sortable: false,
|
|
field: "no",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
},
|
|
{
|
|
name: "name",
|
|
align: "left",
|
|
label: "ชื่อ - นามสกุล",
|
|
sortable: true,
|
|
field: "name",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
},
|
|
{
|
|
name: "position",
|
|
align: "left",
|
|
label: "ตำแหน่ง",
|
|
sortable: true,
|
|
field: "position",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
},
|
|
{
|
|
name: "duty",
|
|
align: "left",
|
|
label: "หน้าที่",
|
|
sortable: true,
|
|
field: "duty",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
},
|
|
{
|
|
name: "email",
|
|
align: "left",
|
|
label: "อีเมล",
|
|
sortable: true,
|
|
field: "email",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
},
|
|
{
|
|
name: "telephone",
|
|
align: "left",
|
|
label: "เบอร์โทรศัพท์",
|
|
sortable: true,
|
|
field: "telephone",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
},
|
|
{
|
|
name: "role",
|
|
align: "left",
|
|
label: "จำนวนเรื่องสืบสวน",
|
|
sortable: true,
|
|
field: "role",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
},
|
|
]);
|
|
|
|
function filterSelector(val: string, update: Function, type: string) {
|
|
update(() => {
|
|
const needle = val.toLowerCase();
|
|
if (type === "filterrespondentType") {
|
|
complainantoptions.value = storeMain.complainantoptionsMain.filter(
|
|
(v: any) => v.name.toLowerCase().indexOf(needle) > -1
|
|
);
|
|
}
|
|
});
|
|
}
|
|
|
|
async function fetchList(data: DataResult[]) {
|
|
const datalist: DataResultList[] = data.map((e: DataResult) => ({
|
|
id: e.id,
|
|
title: e.title,
|
|
respondentType: e.respondentType
|
|
? storeMain.convertComplaintType(e.respondentType)
|
|
: "-",
|
|
offenseDetails: e.offenseDetails
|
|
? storeMain.convertFault(e.offenseDetails)
|
|
: "-",
|
|
disciplinaryFaultLevel: e.disciplinaryFaultLevel
|
|
? e.disciplinaryFaultLevel
|
|
: "-",
|
|
disciplinaryCaseFault: e.disciplinaryCaseFault
|
|
? e.disciplinaryCaseFault
|
|
: "-",
|
|
status: e.status && convertStatus(e.status),
|
|
createdAt: e.createdAt && date2Thai(e.createdAt),
|
|
disciplineType: e.disciplineType ? e.disciplineType:'-' ,
|
|
titleType: e.titleType ? e.titleType:'-' ,
|
|
oc: e.oc ? e.oc:'-'
|
|
}));
|
|
rows.value = datalist;
|
|
}
|
|
|
|
/** function สถานะ*/
|
|
function convertStatus(val: string) {
|
|
switch (val) {
|
|
case "DONE":
|
|
return "กำลังสรุปผลการพิจารณา";
|
|
case "REPORT":
|
|
return "ส่งไปออกคำสั่ง";
|
|
}
|
|
}
|
|
|
|
return {
|
|
tabMenu,
|
|
fetchList,
|
|
rows,
|
|
rows2,
|
|
visibleColumns,
|
|
columns,
|
|
visibleColumnsDirector,
|
|
columnsDirector,
|
|
complainantoptions,
|
|
filterSelector,
|
|
};
|
|
}
|
|
);
|