import { defineStore } from "pinia"; import type { QTableProps } from "quasar"; import { ref } from "vue"; 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([ { id: "PERSON", name: "บุคคล" }, { id: "ORGANIZATION", name: "หน่วยงาน" }, { id: "BANGKOK", name: "กรุงเทพมหานคร" }, ]); /** option ลักษณะความผิด */ const offenseDetailstOptions = ref([ { id: "NOT_SPECIFIED", name: "ยังไม่ระบุ" }, { id: "NOT_DEADLY", name: "ไม่ร้ายแรง" }, { id: "DEADLY", name: "ร้ายแรง" }, ]); const statusResultOptions = ref([ { id: "NOT_SPECIFIED", name: "ยังไม่ระบุ" }, { id: "HAVE_CAUSE", name: "มีมูล" }, { id: "NO_CAUSE", name: "ไม่มีมูล" }, ]); const causeTextOptions = ref([ { id: "ร้ายแรง", name: "ร้ายแรง" }, { id: "ไม่ร้ายแรง", name: "ไม่ร้ายแรง" }, ]); const rowsAdd = ref([]); const rowsCheck = ref([]); /** หัวตารางผู้ถูกร้องเรียน */ const columnsRespondent = ref([ { 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 visibleColumnsRespondent = ref([ "no", "idcard", "name", "posNo", "position", "positionLevel", "salary", "organization", ]); /** หัวตารางกรรมการ */ const columnsDirector = ref([ { 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([ "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 "ส่งไปสรุปผลการพิจารณาความผิดทางวินัย"; } } /** * แปลง 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 ข้อมูลรายการบุคคล */ function fetchData(data: ArrayPersonAdd[]) { rowsAdd.value = data; } return { complainantoptionsMain, convertFault, convertStatus, columnsRespondent, visibleColumnsRespondent, offenseDetailstOptions, convertOffenseDetailst, convertComplaintType, columnsDirector, visibleColumnsDirector, rowsAdd, fetchData, statusResultOptions, convertStatusResult, rowsCheck, causeTextOptions }; });