import { defineStore } from "pinia";
import { ref } from "vue";

import type { QTableProps } from "quasar";

export const useEvaluateDetailStore = defineStore("evaluateDetailStore", () => {
  const tabMenu = ref<string>("1");
  const step = ref<number>(1);
  const currentStep = ref<number>(1);
  const titel = ref<string[]>([
    "ตรวจสอบคุณสมบัติ",
    "จัดเตรียมเอกสารเล่ม 1",
    "ตรวจสอบเอกสารเล่ม 1",
    "รอตรวจสอบคุณสมบัติ",
    "ประกาศบนเว็บไซต์",
    "จัดเตรียมเอกสารเล่ม 2",
    "ตรวจสอบเอกสารเล่ม 2",
    "รอพิจารณาผลการประเมิน",
    "เสร็จสิ้น",
  ]);

  const tabPanels = ref<string>("1");

  const log = ref<any>(0);
  const urlDownloadFile = ref<string>("");
  const pdfSrcStore = ref<any>();
  const numOfPagesStore = ref<any>();

  /** คอลัมน์ ใบอนุญาตประกอบวิชาชีพ*/
  const columnsCertificates = ref<QTableProps["columns"]>([
    {
      name: "certificateType",
      align: "left",
      label: "ชื่อใบอนุณาต",
      sortable: false,
      field: "certificateType",
      headerStyle: "font-size: 14px",
      style: "font-size: 14px",
    },
    {
      name: "issuer",
      align: "left",
      label: "หน่วยงานผู้ออกใบอนุญาต",
      sortable: true,
      field: "issuer",
      headerStyle: "font-size: 14px",
      style: "font-size: 14px",
    },
    {
      name: "certificateNo",
      align: "left",
      label: "เลขที่ใบอนุญาต",
      sortable: true,
      field: "certificateNo",
      headerStyle: "font-size: 14px",
      style: "font-size: 14px",
    },
    {
      name: "issueDate",
      align: "left",
      label: "วันที่ออกใบอนุญาต",
      sortable: true,
      field: "issueDate",
      headerStyle: "font-size: 14px",
      style: "font-size: 14px",
    },
    {
      name: "expireDate",
      align: "left",
      label: "วันที่หมดอายุ",
      sortable: true,
      field: "expireDate",
      headerStyle: "font-size: 14px",
      style: "font-size: 14px",
    },
  ]);

  /** คอลัมน์ ประวัติการรับราชการ*/
  const columnSalaries = ref<QTableProps["columns"]>([
    {
      name: "date",
      align: "left",
      label: "วัน เดือน ปี",
      sortable: false,
      field: "date",
      headerStyle: "font-size: 14px",
      style: "font-size: 14px",
    },
    {
      name: "oc",
      align: "left",
      label: "สังกัด",
      sortable: true,
      field: "oc",
      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: "posNo",
      align: "left",
      label: "ตำแหน่งเลขที่",
      sortable: true,
      field: "posNo",
      headerStyle: "font-size: 14px",
      style: "font-size: 14px",
    },
    {
      name: "lineWork",
      align: "left",
      label: "สายงาน",
      sortable: true,
      field: "lineWork",
      headerStyle: "font-size: 14px",
      style: "font-size: 14px",
    },
    {
      name: "side",
      align: "left",
      label: "ด้าน/สาขา",
      sortable: true,
      field: "side",
      headerStyle: "font-size: 14px",
      style: "font-size: 14px",
    },
    {
      name: "positionType",
      align: "left",
      label: "ตำแหน่งประเภท",
      sortable: true,
      field: "positionType",
      headerStyle: "font-size: 14px",
      style: "font-size: 14px",
    },
    {
      name: "level",
      align: "left",
      label: "ระดับ",
      sortable: true,
      field: "level",
      headerStyle: "font-size: 14px",
      style: "font-size: 14px",
    },
    {
      name: "positionsAdministrative ",
      align: "left",
      label: "ตำแหน่งทางการบริหาร",
      sortable: true,
      field: "positionsAdministrative",
      headerStyle: "font-size: 14px",
      style: "font-size: 14px",
    },
    {
      name: "aspectAdministrative",
      align: "left",
      label: "ด้านทางการบริหาร",
      sortable: true,
      field: "aspectAdministrative",
      headerStyle: "font-size: 14px",
      style: "font-size: 14px",
    },
  ]);

  /** คอลัมน์ ประวัติการฝึกอบรมดูงาน*/
  const columnTraining = ref<QTableProps["columns"]>([
    {
      name: "name",
      align: "left",
      label: "ชื่อโครงการ/หลักสูตรการฝึกอบรม",
      sortable: false,
      field: "name",
      headerStyle: "font-size: 14px",
      style: "font-size: 14px",
    },
    {
      name: "topic",
      align: "left",
      label: "หัวข้อการฝึกอบรม/ดูงาน",
      sortable: true,
      field: "topic",
      headerStyle: "font-size: 14px",
      style: "font-size: 14px",
    },
    {
      name: "startDate",
      align: "left",
      label: "วันเริ่มต้นการฝึกอบรม/ดูงาน",
      sortable: true,
      field: "startDate",
      headerStyle: "font-size: 14px",
      style: "font-size: 14px",
    },
    {
      name: "endDate",
      align: "left",
      label: "วันสิ้นสุดการฝึกอบรม/ดูงาน",
      sortable: true,
      field: "endDate",
      headerStyle: "font-size: 14px",
      style: "font-size: 14px",
    },
    {
      name: "yearly",
      align: "left",
      label: "ปีที่อบรม/ดูงาน",
      sortable: true,
      field: "yearly",
      headerStyle: "font-size: 14px",
      style: "font-size: 14px",
    },
    {
      name: "duration",
      align: "left",
      label: "รวมระยะเวลาในการฝึกอบรม/ดูงาน",
      sortable: true,
      field: "duration",
      headerStyle: "font-size: 14px",
      style: "font-size: 14px",
    },
    {
      name: "department",
      align: "left",
      label: "หน่วยงานที่รับผิดชอบจัดการฝึกอบรม/ดูงาน",
      sortable: true,
      field: "department",
      headerStyle: "font-size: 14px",
      style: "font-size: 14px",
    },
  ]);

  /** คอลัมน์ ผลงานที่เคยเสนอขอประเมิน*/
  const columnProjectsProposed = ref<QTableProps["columns"]>([
    {
      name: "receivedDate",
      align: "center",
      label: "วันที่ได้รับ",
      sortable: true,
      field: "receivedDate",
      headerStyle: "font-size: 14px",
      style: "font-size: 14px",
    },
    {
      name: "authority",
      align: "left",
      label: "ผู้มีอำนาจลงนาม",
      sortable: true,
      field: "authority",
      headerStyle: "font-size: 14px",
      style: "font-size: 14px",
    },
    {
      name: "datail",
      align: "left",
      label: "รายละเอียด",
      sortable: true,
      field: "detail",
      headerStyle: "font-size: 14px",
      style: "font-size: 14px",
    },
    {
      name: "orderNumber",
      align: "left",
      label: "เลขที่คำสั่ง",
      sortable: true,
      field: "orderNumber",
      headerStyle: "font-size: 14px",
      style: "font-size: 14px",
    },
    {
      name: "doc",
      align: "left",
      label: "เอกสารอ้างอิง",
      sortable: true,
      field: "doc",
      headerStyle: "font-size: 14px",
      style: "font-size: 14px",
    },
  ]);

  return {
    tabMenu,
    step,
    titel,
    tabPanels,
    /** step1*/
    columnsCertificates,
    columnSalaries,
    columnTraining,
    columnProjectsProposed,
    pdfSrcStore,
    urlDownloadFile,
    numOfPagesStore,
    log,
    currentStep,
  };
});
