import { defineStore } from "pinia"; import { ref } from "vue"; import type { QTableProps } from "quasar"; import type { investigatefactsDataRowType, DataOption } from '@/modules/11_discipline/interface/index/Main' export const useInvestigateFactStore = defineStore("DisciplineInvestigateFact", () => { const rows = ref([]) const faultOp = ref(); const daysExtendOp = ref(); const investigationOp = ref(); const daysExtendOps = ref([ { id: "000", name: "15 วัน" }, { id: "001", name: "30 วัน" }, { id: "002", name: "45 วัน" }, { id: "003", name: "60 วัน" }, ]); const investigationOps = ref([ { id: "001", name: "เเต่งตั้งการสืบสวน" }, { id: "002", name: "สืบสวนทางลับ" }, { id: "003", name: "อื่นๆ" }, ]); const faultOps = ref([ { id: "001", name: "ยังไม่ระบุ" }, { id: "002", name: "ไม่ร้ายเเรง" }, { id: "003", name: "ร้ายเเรง" }, ]); const visibleColumns = ref([ "no", "subject", "interrogated", "fault", "status", ]); //ค้นหา คอลัมน์ คอลัมน์ที่แสดง // หัวตาราง const columns = ref([ { 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", }, ]); function filterFnOptionsType(val: string, update: any, type: string) { update(() => { const needle = val.toLowerCase(); if (type === "faultOp") { faultOp.value = faultOps.value.filter( (v: any) => v.name.toLowerCase().indexOf(needle) > -1 ); } else if (type === "investigationOp") { investigationOp.value = investigationOps.value.filter( (v: any) => v.name.toLowerCase().indexOf(needle) > -1 ); } else if (type === "daysExtendOp") { daysExtendOp.value = daysExtendOps.value.filter( (v: any) => v.name.toLowerCase().indexOf(needle) > -1 ); } }); } 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; } function convertFault(val: string) { switch (val) { case "0": return "ความผิดวินัยไม่ร้ายแรง" case "1": return "ความผิดวินัยร้ายแรง" } } function convertSatatus(val: string) { switch (val) { case "0": return "ยุติเรื่อง" case "1": return "เสร็จสิ้นเเล้ว" } } function activeStatus(val: string) { switch (val) { case "0": return "ยังไม่ได้ยืนยันผล" case "1": return "ยืนยันผลเเล้ว" } } return { fecthList, rows, daysExtendOps, investigationOps, faultOps, filterFnOptionsType, faultOp, daysExtendOp, investigationOp, visibleColumns, columns }; })