update ฟอร์มสืบสวน สอบสวนวินัย

This commit is contained in:
Warunee Tamkoo 2023-11-23 15:47:14 +07:00
parent 422ea07f4d
commit b5cc5c9cb7
12 changed files with 768 additions and 564 deletions

View file

@ -1,18 +1,23 @@
import { defineStore } from "pinia";
import { ref } from "vue";
import { useCounterMixin } from "@/stores/mixin";
import type { QTableProps } from "quasar";
import type {
investigatefactsDataRowType,
InvestigatefactsDataRowType,
DataOption,
DataNumberOption,
} from "@/modules/11_discipline/interface/index/Main";
import type { ListData } from "@/modules/11_discipline/interface/response/investigate";
const mixin = useCounterMixin();
const { date2Thai } = mixin;
/*** store ของข้อมูลสืบสวนข้อเท็จจริง */
export const useInvestigateFactStore = defineStore(
"DisciplineInvestigateFact",
() => {
const tabMenu = ref<string>("investigatefacts");
const rows = ref<investigatefactsDataRowType[]>([]);
const daysExtendOps = ref<DataNumberOption[]>([
{ id: 15, name: "15 วัน" },
@ -20,15 +25,21 @@ export const useInvestigateFactStore = defineStore(
{ id: 45, name: "45 วัน" },
{ id: 60, name: "60 วัน" },
]);
const offenseDetailsOps = ref<DataOption[]>([
{ id: "NOT_SPECIFIED", name: "ยังไม่ระบุ" },
{ id: "NOT_DEADLY", name: "ไม่ร้ายแรง" },
{ id: "DEADLY", name: "ร้ายแรง" },
]);
const investigationOps = ref<DataOption[]>([
{ id: "001", name: "แต่งตั้งกรรมการสืบสวน" },
{ id: "002", name: "สืบสวนทางลับ" },
{ id: "003", name: "อื่นๆ" },
{ id: "appoint_directors", name: "แต่งตั้งกรรมการสืบสวน" },
{ id: "secret_investigation", name: "สืบสวนทางลับ" },
{ id: "other", name: "อื่นๆ" },
]);
const faultOps = ref<DataOption[]>([
{ id: "001", name: "ยังไม่ระบุ" },
{ id: "002", name: "ไม่ร้ายเเรง" },
{ id: "003", name: "ร้ายเเรง" },
{ id: "new", name: "กำลังสืบสวน" },
{ id: "stop", name: "ยุติเรื่อง" },
{ id: "complete", name: "ส่งไปสอบสวน" },
]);
const statusResultOptions = ref<DataOption[]>([
{ id: "not_specified", name: "ยังไม่ระบุ" },
@ -47,7 +58,10 @@ export const useInvestigateFactStore = defineStore(
"no",
"subject",
"interrogated",
"fault",
"complaintOffenseDetails",
"investigationDetail",
"dateInvestigate",
"statusResult",
"status",
]);
@ -65,7 +79,7 @@ export const useInvestigateFactStore = defineStore(
{
name: "subject",
align: "left",
label: "เรื่อง",
label: "เรื่องร้องเรียน",
sortable: true,
field: "subject",
headerStyle: "font-size: 14px",
@ -83,11 +97,44 @@ export const useInvestigateFactStore = defineStore(
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "fault",
name: "complaintOffenseDetails",
align: "left",
label: "ลักษณะความผิด",
sortable: true,
field: "fault",
field: "complaintOffenseDetails",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "investigationDetail",
align: "left",
label: "ลักษณะการสืบสวน",
sortable: true,
field: "investigationDetail",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "dateInvestigate",
align: "left",
label: "วันที่สืบสวน",
sortable: true,
field: "dateInvestigate",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "statusResult",
align: "left",
label: "ผลการสืบสวน",
sortable: true,
field: "statusResult",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
@ -103,6 +150,7 @@ export const useInvestigateFactStore = defineStore(
style: "font-size: 14px",
},
]);
function filterFnOptionsType(
val: string | number,
update: any,
@ -124,45 +172,51 @@ export const useInvestigateFactStore = defineStore(
}
});
}
function fecthList(data: investigatefactsDataRowType[]) {
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;
const rows = ref<InvestigatefactsDataRowType[]>();
async function fecthList(data: ListData[]) {
rows.value = await data.map((e: ListData) => {
return {
id: e.id,
subject: e.subject,
interrogated: e.interrogated,
complaintOffenseDetails: convertOffenseDetails(
e.complaintOffenseDetails
),
investigationDetail: convertInvestigationDetail(
e.investigationDetail
),
dateInvestigate:
e.startDate && e.endDate
? `${date2Thai(e.startDate)} - ${date2Thai(e.endDate)}`
: "-",
statusResult: activeStatusResult(e.statusResult),
status: convertStatus(e.status),
};
});
}
function convertFault(val: string) {
switch (val) {
case "0":
return "ความผิดวินัยไม่ร้ายแรง";
case "1":
return "ความผิดวินัยร้ายแรง";
}
function convertOffenseDetails(val: string) {
const result = offenseDetailsOps.value.find((x: any) => x.id == val)?.name;
return result ? result : "-";
}
function convertSatatus(val: string) {
switch (val) {
case "0":
return "ยุติเรื่อง";
case "1":
return "เสร็จสิ้นเเล้ว";
}
function convertInvestigationDetail(val: string) {
const result = investigationOps.value.find((x: any) => x.id == val)?.name;
return result ? result : "-";
}
function activeStatus(val: string) {
switch (val) {
case "0":
return "ยังไม่ได้ยืนยันผล";
case "1":
return "ยืนยันผลเเล้ว";
}
function convertStatus(val: string) {
const result = faultOps.value.find((x: any) => x.id == val)?.name;
return result ? result : "-";
}
function activeStatusResult(val: string) {
const result = statusResultOptions.value.find(
(x: any) => x.id == val
)?.name;
return result ? result : "-";
}
return {
tabMenu,
fecthList,