2023-10-16 18:13:03 +07:00
|
|
|
import { defineStore } from "pinia";
|
|
|
|
|
import { ref } from "vue";
|
2023-10-19 14:36:12 +07:00
|
|
|
import type { QTableProps } from "quasar";
|
2023-11-22 11:26:10 +07:00
|
|
|
import type {
|
|
|
|
|
investigatefactsDataRowType,
|
|
|
|
|
DataOption,
|
|
|
|
|
DataNumberOption,
|
|
|
|
|
} from "@/modules/11_discipline/interface/index/Main";
|
2023-10-16 18:13:03 +07:00
|
|
|
|
2023-11-08 15:25:01 +07:00
|
|
|
/*** store ของข้อมูลสืบสวนข้อเท็จจริง */
|
2023-11-22 11:26:10 +07:00
|
|
|
export const useInvestigateFactStore = defineStore(
|
|
|
|
|
"DisciplineInvestigateFact",
|
|
|
|
|
() => {
|
|
|
|
|
const tabMenu = ref<string>("investigatefacts");
|
|
|
|
|
const rows = ref<investigatefactsDataRowType[]>([]);
|
2023-11-06 17:54:35 +07:00
|
|
|
|
2023-11-08 15:25:01 +07:00
|
|
|
const daysExtendOps = ref<DataNumberOption[]>([
|
2023-11-22 11:26:10 +07:00
|
|
|
{ id: 15, name: "15 วัน" },
|
|
|
|
|
{ id: 30, name: "30 วัน" },
|
|
|
|
|
{ id: 45, name: "45 วัน" },
|
|
|
|
|
{ id: 60, name: "60 วัน" },
|
2023-10-18 11:46:28 +07:00
|
|
|
]);
|
|
|
|
|
const investigationOps = ref<DataOption[]>([
|
2023-11-22 18:05:59 +07:00
|
|
|
{ id: "001", name: "แต่งตั้งกรรมการสืบสวน" },
|
2023-11-22 11:26:10 +07:00
|
|
|
{ id: "002", name: "สืบสวนทางลับ" },
|
|
|
|
|
{ id: "003", name: "อื่นๆ" },
|
2023-10-18 11:46:28 +07:00
|
|
|
]);
|
|
|
|
|
const faultOps = ref<DataOption[]>([
|
2023-11-22 11:26:10 +07:00
|
|
|
{ id: "001", name: "ยังไม่ระบุ" },
|
|
|
|
|
{ id: "002", name: "ไม่ร้ายเเรง" },
|
|
|
|
|
{ id: "003", name: "ร้ายเเรง" },
|
2023-10-18 11:46:28 +07:00
|
|
|
]);
|
2023-11-08 15:25:01 +07:00
|
|
|
const statusResultOptions = ref<DataOption[]>([
|
2023-11-22 11:26:10 +07:00
|
|
|
{ id: "not_specified", name: "ยังไม่ระบุ" },
|
|
|
|
|
{ id: "have_cause", name: "มีมูล" },
|
|
|
|
|
{ id: "no_cause", name: "ไม่มีมูล" },
|
2023-11-08 15:25:01 +07:00
|
|
|
]);
|
|
|
|
|
const causeTextOptions = ref<DataOption[]>([
|
2023-11-22 11:26:10 +07:00
|
|
|
{ id: "ร้ายแรง", name: "ร้ายแรง" },
|
|
|
|
|
{ id: "ไม่ร้ายแรง", name: "ไม่ร้ายแรง" },
|
2023-11-08 15:25:01 +07:00
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
const daysExtendOp = ref<DataNumberOption[]>(daysExtendOps.value);
|
2023-11-06 17:54:35 +07:00
|
|
|
const investigationOp = ref<DataOption[]>(investigationOps.value);
|
|
|
|
|
const faultOp = ref<DataOption[]>(faultOps.value);
|
2023-10-19 14:36:12 +07:00
|
|
|
const visibleColumns = ref<string[]>([
|
2023-11-22 11:26:10 +07:00
|
|
|
"no",
|
|
|
|
|
"subject",
|
|
|
|
|
"interrogated",
|
|
|
|
|
"fault",
|
|
|
|
|
"status",
|
2023-11-14 11:18:52 +07:00
|
|
|
]);
|
2023-10-19 14:36:12 +07:00
|
|
|
|
|
|
|
|
// หัวตาราง
|
|
|
|
|
const columns = ref<QTableProps["columns"]>([
|
2023-11-22 11:26:10 +07:00
|
|
|
{
|
|
|
|
|
name: "no",
|
|
|
|
|
align: "center",
|
|
|
|
|
label: "ลำดับ",
|
|
|
|
|
sortable: false,
|
|
|
|
|
field: "no",
|
|
|
|
|
headerStyle: "font-size: 14px",
|
|
|
|
|
style: "font-size: 14px",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "subject",
|
|
|
|
|
align: "left",
|
|
|
|
|
label: "เรื่อง",
|
|
|
|
|
sortable: true,
|
|
|
|
|
field: "subject",
|
|
|
|
|
headerStyle: "font-size: 14px",
|
|
|
|
|
style: "font-size: 14px",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "interrogated",
|
|
|
|
|
align: "left",
|
|
|
|
|
label: "ผู้ถูกสอบสวน",
|
|
|
|
|
sortable: true,
|
|
|
|
|
field: "interrogated",
|
|
|
|
|
headerStyle: "font-size: 14px",
|
|
|
|
|
style: "font-size: 14px",
|
|
|
|
|
sort: (a: string, b: string) =>
|
|
|
|
|
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "fault",
|
|
|
|
|
align: "left",
|
|
|
|
|
label: "ลักษณะความผิด",
|
|
|
|
|
sortable: true,
|
|
|
|
|
field: "fault",
|
|
|
|
|
headerStyle: "font-size: 14px",
|
|
|
|
|
style: "font-size: 14px",
|
|
|
|
|
sort: (a: string, b: string) =>
|
|
|
|
|
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "status",
|
|
|
|
|
align: "left",
|
|
|
|
|
label: "สถานะ",
|
|
|
|
|
sortable: false,
|
|
|
|
|
field: "status",
|
|
|
|
|
headerStyle: "font-size: 14px",
|
|
|
|
|
style: "font-size: 14px",
|
|
|
|
|
},
|
2023-10-19 14:36:12 +07:00
|
|
|
]);
|
2023-11-22 11:26:10 +07:00
|
|
|
function filterFnOptionsType(
|
|
|
|
|
val: string | number,
|
|
|
|
|
update: any,
|
|
|
|
|
type: string
|
|
|
|
|
) {
|
|
|
|
|
update(() => {
|
|
|
|
|
if (type === "faultOp") {
|
|
|
|
|
faultOp.value = faultOps.value.filter(
|
|
|
|
|
(v: any) => v.name.toLowerCase().indexOf(val) > -1
|
|
|
|
|
);
|
|
|
|
|
} else if (type === "investigationOp") {
|
|
|
|
|
investigationOp.value = investigationOps.value.filter(
|
|
|
|
|
(v: any) => v.name.toLowerCase().indexOf(val) > -1
|
|
|
|
|
);
|
|
|
|
|
} else if (type === "daysExtendOp") {
|
|
|
|
|
daysExtendOp.value = daysExtendOps.value.filter(
|
|
|
|
|
(v: any) => v.id.indexOf(val) > -1
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
});
|
2023-10-18 11:46:28 +07:00
|
|
|
}
|
2023-10-19 14:36:12 +07:00
|
|
|
function fecthList(data: investigatefactsDataRowType[]) {
|
2023-11-22 11:26:10 +07:00
|
|
|
let datalist: investigatefactsDataRowType[] = data.map(
|
|
|
|
|
(e: investigatefactsDataRowType) => {
|
|
|
|
|
return {
|
|
|
|
|
id: e.id,
|
|
|
|
|
subject: e.subject,
|
|
|
|
|
interrogated: e.interrogated,
|
|
|
|
|
fault: e.fault ? convertFault(e.fault) : "-",
|
|
|
|
|
status: e.status ? convertSatatus(e.status) : "-",
|
|
|
|
|
active: e.active ? activeStatus(e.active) : "-",
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
rows.value = datalist;
|
2023-10-16 18:13:03 +07:00
|
|
|
}
|
|
|
|
|
function convertFault(val: string) {
|
2023-11-22 11:26:10 +07:00
|
|
|
switch (val) {
|
|
|
|
|
case "0":
|
|
|
|
|
return "ความผิดวินัยไม่ร้ายแรง";
|
|
|
|
|
case "1":
|
|
|
|
|
return "ความผิดวินัยร้ายแรง";
|
|
|
|
|
}
|
2023-10-16 18:13:03 +07:00
|
|
|
}
|
|
|
|
|
function convertSatatus(val: string) {
|
2023-11-22 11:26:10 +07:00
|
|
|
switch (val) {
|
|
|
|
|
case "0":
|
|
|
|
|
return "ยุติเรื่อง";
|
|
|
|
|
case "1":
|
|
|
|
|
return "เสร็จสิ้นเเล้ว";
|
|
|
|
|
}
|
2023-10-16 18:13:03 +07:00
|
|
|
}
|
|
|
|
|
function activeStatus(val: string) {
|
2023-11-22 11:26:10 +07:00
|
|
|
switch (val) {
|
|
|
|
|
case "0":
|
|
|
|
|
return "ยังไม่ได้ยืนยันผล";
|
|
|
|
|
case "1":
|
|
|
|
|
return "ยืนยันผลเเล้ว";
|
|
|
|
|
}
|
2023-10-16 18:13:03 +07:00
|
|
|
}
|
|
|
|
|
return {
|
2023-11-22 11:26:10 +07:00
|
|
|
tabMenu,
|
|
|
|
|
fecthList,
|
|
|
|
|
rows,
|
|
|
|
|
daysExtendOps,
|
|
|
|
|
investigationOps,
|
|
|
|
|
faultOps,
|
|
|
|
|
filterFnOptionsType,
|
|
|
|
|
faultOp,
|
|
|
|
|
daysExtendOp,
|
|
|
|
|
investigationOp,
|
|
|
|
|
visibleColumns,
|
|
|
|
|
columns,
|
|
|
|
|
statusResultOptions,
|
|
|
|
|
causeTextOptions,
|
2023-10-16 18:13:03 +07:00
|
|
|
};
|
2023-11-22 11:26:10 +07:00
|
|
|
}
|
|
|
|
|
);
|