504 lines
14 KiB
TypeScript
504 lines
14 KiB
TypeScript
import { ref } from "vue";
|
|
import { defineStore } from "pinia";
|
|
import type { QTableProps } from "quasar";
|
|
|
|
import type { DataOption } from "@/modules/11_discipline/interface/index/Main";
|
|
import type { ArrayPersonAdd } from "@/modules/11_discipline/interface/response/investigate";
|
|
|
|
export const useDisciplineMainStore = defineStore("disciplineMainStore", () => {
|
|
/** option ผู้ถูกสอบสวน*/
|
|
const complainantoptionsMain = ref<DataOption[]>([
|
|
{ id: "PERSON", name: "บุคคล" },
|
|
{ id: "ORGANIZATION", name: "หน่วยงาน" },
|
|
{ id: "BANGKOK", name: "กรุงเทพมหานคร" },
|
|
]);
|
|
|
|
/** option ลักษณะความผิด */
|
|
const offenseDetailstOptions = ref<DataOption[]>([
|
|
{ id: "NOT_SPECIFIED", name: "ยังไม่ระบุ" },
|
|
{ id: "NOT_DEADLY", name: "ไม่ร้ายแรง" },
|
|
{ id: "DEADLY", name: "ร้ายแรง" },
|
|
]);
|
|
|
|
const statusResultOptions = ref<DataOption[]>([
|
|
{ id: "NOT_SPECIFIED", name: "ยังไม่ระบุ" },
|
|
{ id: "HAVE_CAUSE", name: "มีมูล" },
|
|
{ id: "NO_CAUSE", name: "ไม่มีมูล" },
|
|
]);
|
|
|
|
const causeTextOptions = ref<DataOption[]>([
|
|
{ id: "ร้ายแรง", name: "ร้ายแรง" },
|
|
{ id: "ไม่ร้ายแรง", name: "ไม่ร้ายแรง" },
|
|
]);
|
|
const rowsAdd = ref<ArrayPersonAdd[]>([]);
|
|
const rowsSend = ref<ArrayPersonAdd[]>([]);
|
|
const rowsCheck = ref<ArrayPersonAdd[]>([]);
|
|
/** หัวตารางผู้ถูกร้องเรียน */
|
|
const columnsRespondent = ref<QTableProps["columns"]>([
|
|
{
|
|
name: "no",
|
|
align: "center",
|
|
label: "ลำดับ",
|
|
sortable: false,
|
|
field: "no",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
},
|
|
{
|
|
name: "idcard",
|
|
align: "left",
|
|
label: "เลขประจำตัวประชาชน",
|
|
sortable: true,
|
|
field: "idcard",
|
|
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: "posNo",
|
|
align: "left",
|
|
label: "ตำแหน่งเลขที่",
|
|
sortable: true,
|
|
field: "posNo",
|
|
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: "posLevelName",
|
|
align: "left",
|
|
label: "ระดับ",
|
|
sortable: true,
|
|
field: "posLevelName",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
},
|
|
{
|
|
name: "salary",
|
|
align: "left",
|
|
label: "เงินเดือน",
|
|
sortable: true,
|
|
field: "salary",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
},
|
|
{
|
|
name: "organization",
|
|
align: "left",
|
|
label: "หน่วยงาน",
|
|
sortable: true,
|
|
field: "organization",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
},
|
|
]);
|
|
|
|
/** หัวข้อที่เเสดงในตารางผู้ถูกร้องเรียน */
|
|
const visibleColumnsRespondent = ref<string[]>([
|
|
"no",
|
|
"idcard",
|
|
"name",
|
|
"posNo",
|
|
"position",
|
|
"posLevelName",
|
|
"salary",
|
|
"organization",
|
|
]);
|
|
|
|
/** หัวตารางกรรมการ */
|
|
const columnsDirector = ref<QTableProps["columns"]>([
|
|
{
|
|
name: "info",
|
|
align: "left",
|
|
label: "",
|
|
sortable: false,
|
|
field: "info",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
},
|
|
{
|
|
name: "no",
|
|
align: "left",
|
|
label: "ลำดับ",
|
|
sortable: false,
|
|
field: "no",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
},
|
|
{
|
|
name: "idcard",
|
|
align: "left",
|
|
label: "เลขประจำตัวประชาชน",
|
|
sortable: true,
|
|
field: "idcard",
|
|
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: "posNo",
|
|
align: "left",
|
|
label: "ตำแหน่งเลขที่",
|
|
sortable: true,
|
|
field: "posNo",
|
|
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: "positionLevel",
|
|
align: "left",
|
|
label: "ระดับ",
|
|
sortable: true,
|
|
field: "positionLevel",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
},
|
|
{
|
|
name: "salary",
|
|
align: "left",
|
|
label: "เงินเดือน",
|
|
sortable: true,
|
|
field: "salary",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
},
|
|
{
|
|
name: "organization",
|
|
align: "left",
|
|
label: "หน่วยงาน",
|
|
sortable: true,
|
|
field: "organization",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
},
|
|
]);
|
|
|
|
/** หัวข้อที่เเสดงในตารางกรรมการ */
|
|
const visibleColumnsDirector = ref<string[]>([
|
|
"info",
|
|
"no",
|
|
"idcard",
|
|
"name",
|
|
"posNo",
|
|
"position",
|
|
"positionLevel",
|
|
"salary",
|
|
"organization",
|
|
]);
|
|
|
|
/**
|
|
* แปลง option ที่รับมาเป็น ไทย
|
|
* @param val ค่าที่ได้จาก API
|
|
* @returns ส่ง name ที่ id ตรงกันออกไป
|
|
*/
|
|
function convertComplaintType(val: string) {
|
|
const result = complainantoptionsMain.value.find(
|
|
(x: any) => x.id == val
|
|
)?.name;
|
|
return result ? result : "-";
|
|
}
|
|
|
|
/**
|
|
* แปลง status เป็น text
|
|
* @param val status
|
|
* @returns text
|
|
*/
|
|
function convertFault(val: string) {
|
|
switch (val) {
|
|
case "NOT_SPECIFIED":
|
|
return "ความผิดวินัยยังไม่ระบุ";
|
|
case "NOT_DEADLY":
|
|
return "ความผิดวินัยไม่ร้ายแรง";
|
|
case "DEADLY":
|
|
return "ความผิดวินัยร้ายแรง";
|
|
default:
|
|
return "-";
|
|
}
|
|
}
|
|
|
|
/**
|
|
* แปลง status เป็น text
|
|
* @param val status
|
|
* @returns text
|
|
*/
|
|
function convertStatus(val: string) {
|
|
switch (val) {
|
|
case "NEW":
|
|
return "กำลังสอบสวน";
|
|
case "STOP":
|
|
return "ยุติเรื่อง";
|
|
case "SEND_DISCIPLINARY":
|
|
return "ส่งไปสอบสวน";
|
|
case "DONE":
|
|
return "ส่งไปสรุปผลการพิจารณาความผิดทางวินัย";
|
|
}
|
|
}
|
|
|
|
/**
|
|
* แปลง status เป็น text #เรื่องร้องเรียน channal
|
|
* @param val status
|
|
* @returns text
|
|
*/
|
|
function pathComplaintsChannal(val: string) {
|
|
switch (val) {
|
|
case "disciplineChannel":
|
|
return "main";
|
|
case "disciplineComplaintsAdd":
|
|
return "create-complain";
|
|
case "disciplineComplaintsEdit":
|
|
case "disciplineComplaintsDetail":
|
|
return "complain";
|
|
case "disciplineInvestigatefactsEdit":
|
|
case "disciplineInvestigatefactsDetail":
|
|
return "inves";
|
|
case "disciplineDisciplinaryEdit":
|
|
case "disciplineDisciplinaryDetail":
|
|
return "discip";
|
|
case "disciplineEditResult":
|
|
case "disciplineResultDetail":
|
|
return "result";
|
|
}
|
|
}
|
|
/**
|
|
* แปลง status เป็น text #เรื่องร้องเรียน
|
|
* @param val status
|
|
* @returns text
|
|
*/
|
|
function pathComplaints(val: string) {
|
|
switch (val) {
|
|
case "disciplineComplaintsEdit":
|
|
case "disciplineComplaintsDetail":
|
|
return "main";
|
|
case "disciplineInvestigatefactsEdit":
|
|
case "disciplineInvestigatefactsDetail":
|
|
return "inves";
|
|
case "disciplineDisciplinaryEdit":
|
|
case "disciplineDisciplinaryDetail":
|
|
return "discip";
|
|
case "disciplineEditResult":
|
|
case "disciplineResultDetail":
|
|
return "result";
|
|
}
|
|
}
|
|
|
|
/**
|
|
* แปลง status เป็น text #สืบสวนข้อเท็จจริง
|
|
* @param val status
|
|
* @returns text
|
|
*/
|
|
function pathInves(val: string) {
|
|
switch (val) {
|
|
case "disciplineInvestigatefactsEdit":
|
|
case "disciplineInvestigatefactsDetail":
|
|
return "main";
|
|
case "disciplineDisciplinaryEdit":
|
|
case "disciplineDisciplinaryDetail":
|
|
return "discip";
|
|
case "disciplineEditResult":
|
|
case "disciplineResultDetail":
|
|
return "result";
|
|
}
|
|
}
|
|
|
|
/**
|
|
* แปลง status เป็น text #กรรมการ
|
|
* @param val status
|
|
* @returns text
|
|
*/
|
|
function pathDirector(val: string) {
|
|
switch (val) {
|
|
case "disciplineInvestigatefactsEdit":
|
|
case "disciplineInvestigatefactsDetail":
|
|
return "inves";
|
|
case "disciplineDisciplinaryEdit":
|
|
case "disciplineDisciplinaryDetail":
|
|
return "discip";
|
|
case "disciplineDirector":
|
|
return "main";
|
|
}
|
|
}
|
|
|
|
/**
|
|
* แปลง status เป็น text #สอบสวนความผิดทางวินัย
|
|
* @param val status
|
|
* @returns text
|
|
*/
|
|
function pathDiscip(val: string) {
|
|
switch (val) {
|
|
case "disciplineDisciplinaryEdit":
|
|
case "disciplineDisciplinaryDetail":
|
|
return "main";
|
|
case "disciplineEditResult":
|
|
case "disciplineResultDetail":
|
|
return "result";
|
|
}
|
|
}
|
|
|
|
/**
|
|
* แปลง option ที่รับมาเป็น ไทย
|
|
* @param val ค่าที่ได้จาก API
|
|
* @returns ส่ง name ที่ id ตรงกันออกไป
|
|
*/
|
|
function convertOffenseDetailst(val: string) {
|
|
return (
|
|
offenseDetailstOptions.value.find((x: any) => x.id == val)?.name ?? "-"
|
|
);
|
|
}
|
|
|
|
/**
|
|
* แปลง option ที่รับมาเป็น ไทย
|
|
* @param val ค่าที่ได้จาก API
|
|
* @returns ส่ง name ที่ id ตรงกันออกไป
|
|
*/
|
|
function convertStatusResult(val: string) {
|
|
const result = statusResultOptions.value.find(
|
|
(x: any) => x.id == val
|
|
)?.name;
|
|
return result ? result : "-";
|
|
}
|
|
|
|
/**
|
|
* จัดเก็บข้อมูลไว้ เพื่อใช้ใน POPUP
|
|
* @param data ข้อมูลรายการบุคคล
|
|
*/
|
|
async function fetchData(data: ArrayPersonAdd[]) {
|
|
const dataList: any = data.map((item: any) => ({
|
|
id: item.id,
|
|
idcard: item.idcard,
|
|
name: item.name,
|
|
prefix: item.prefix,
|
|
firstName: item.firstName,
|
|
lastName: item.lastName,
|
|
position: item.position,
|
|
positionLevel: item.positionLevel,
|
|
salary: item.salary === null ? "" : item.salary,
|
|
personId: item.personId,
|
|
posNo: item.posNo === null ? "-" : item.posNo,
|
|
organization: item.organization,
|
|
root: item.root,
|
|
rootId: item.rootId,
|
|
rootShortName: item.rootShortName,
|
|
child1: item.child1,
|
|
child1Id: item.child1Id,
|
|
child1ShortName: item.child1ShortName,
|
|
child2: item.child2,
|
|
child2Id: item.child2Id,
|
|
child2ShortName: item.child2ShortName,
|
|
child3: item.child3,
|
|
child3Id: item.child3Id,
|
|
child3ShortName: item.child3ShortName,
|
|
child4: item.child4,
|
|
child4Id: item.child4Id,
|
|
child4ShortName: item.child4ShortName,
|
|
posMasterNo: item.posMasterNo,
|
|
posTypeId: item.posTypeId,
|
|
posTypeName: item.posTypeName,
|
|
posLevelId: item.posLevelId,
|
|
posLevelName: item.posLevelName,
|
|
}));
|
|
rowsAdd.value = dataList;
|
|
}
|
|
|
|
/**
|
|
* จัดเก็บข้อมูลไว้ เพื่อใช้ใน POPUP
|
|
* @param data ข้อมูลรายการบุคคล
|
|
*/
|
|
async function fetchDataRowsSend(data: ArrayPersonAdd[]) {
|
|
const dataList: any = data.map((item: any) => ({
|
|
id: item.id,
|
|
idcard: item.idcard,
|
|
name: item.name,
|
|
prefix: item.prefix,
|
|
firstName: item.firstName,
|
|
lastName: item.lastName,
|
|
position: item.position,
|
|
positionLevel: item.positionLevel,
|
|
salary: item.salary === null ? "" : item.salary,
|
|
personId: item.personId,
|
|
posNo: item.posNo === null ? "-" : item.posNo,
|
|
organization: item.organization,
|
|
root: item.root,
|
|
rootId: item.rootId,
|
|
rootShortName: item.rootShortName,
|
|
child1: item.child1,
|
|
child1Id: item.child1Id,
|
|
child1ShortName: item.child1ShortName,
|
|
child2: item.child2,
|
|
child2Id: item.child2Id,
|
|
child2ShortName: item.child2ShortName,
|
|
child3: item.child3,
|
|
child3Id: item.child3Id,
|
|
child3ShortName: item.child3ShortName,
|
|
child4: item.child4,
|
|
child4Id: item.child4Id,
|
|
child4ShortName: item.child4ShortName,
|
|
posMasterNo: item.posMasterNo,
|
|
posTypeId: item.posTypeId,
|
|
posTypeName: item.posTypeName,
|
|
posLevelId: item.posLevelId,
|
|
posLevelName: item.posLevelName,
|
|
isSend: item.isSend,
|
|
}));
|
|
rowsSend.value = dataList;
|
|
}
|
|
|
|
return {
|
|
complainantoptionsMain,
|
|
convertFault,
|
|
convertStatus,
|
|
columnsRespondent,
|
|
visibleColumnsRespondent,
|
|
offenseDetailstOptions,
|
|
convertOffenseDetailst,
|
|
convertComplaintType,
|
|
|
|
columnsDirector,
|
|
visibleColumnsDirector,
|
|
rowsAdd,
|
|
fetchData,
|
|
statusResultOptions,
|
|
convertStatusResult,
|
|
rowsCheck,
|
|
causeTextOptions,
|
|
rowsSend,
|
|
fetchDataRowsSend,
|
|
pathComplaints,
|
|
pathInves,
|
|
pathDiscip,
|
|
pathComplaintsChannal,
|
|
pathDirector,
|
|
};
|
|
});
|