import { defineStore } from "pinia"; import { ref } from "vue"; import type { investigateDisDataRowType, DataOption, directorType, } from "@/modules/11_discipline/interface/index/Main"; export const useInvestigateDisStore = defineStore( "DisciplineInvestigateDis", () => { const rows = ref([]); const rows2 = ref([]); const selected = ref([]); const optionsTypefault = ref([ { id: "0", name: "ไม่ระบุ" }, { id: "1", name: "ร้ายแรง" }, { id: "2", name: "ไม่ร้ายแรง" }, ]); const optionsfaultLevel = ref([ { id: "0", name: "ไม่ร้ายแรง" }, { id: "1", name: "ภาคทัณฑ์" }, { id: "2", name: "ตัดเงินเดือน" }, { id: "3", name: "ลดขั้นเงินเดือน" }, { id: "4", name: "ร้ายแรง" }, { id: "5", name: "ปลดออก" }, { id: "6", name: "ไล่ออก" }, ]); async function fecthList(data: investigateDisDataRowType[]) { let datalist: any[] = data.map((e: any) => ({ subject: e.subject, interrogated: e.interrogated, fault: convertFault(e.fault), penaltyLevel: convertPenaltyLevel(e.penaltyLevel), caseFault: e.caseFault, dateInvestigate: e.dateInvestigate, status: convertSatatus(e.status), active: activeStatus(e.active), })); rows.value = datalist; } async function fecthDirector(data: directorType[]) { let datalistDirector: any[] = data.map((e: any) => ({ nameDirector: e.nameDirector, position: e.position, duty: e.duty, email: e.email, telephone: e.telephone, })); rows2.value = datalistDirector; selected.value = rows2.value; console.log(rows2.value); } function convertFault(val: string) { switch (val) { case "0": return "ความผิดวินัยยังไม่ระบุ"; case "1": return "ความผิดวินัยไม่ร้ายแรง"; case "2": 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 "ยืนยันผลเเล้ว"; case "2": return "ยืนยันผล"; } } function convertPenaltyLevel(val: string) { switch (val) { case "0": return "ไม่ร้ายแรง"; case "1": return "ภาคทัณฑ์"; case "3": return "ตัดเงินเดือน"; case "4": return "ลดขั้นเงินเดือน"; case "5": return "ร้ายแรง"; case "6": return "ปลดออก"; case "7": return "ไล่ออก"; } } return { fecthList, rows, rows2, optionsTypefault, optionsfaultLevel, fecthDirector, }; } );