hrms-mgt/src/modules/09_leave/stores/WorkTimeStore.ts

119 lines
3.2 KiB
TypeScript
Raw Normal View History

import { defineStore } from "pinia";
import { ref } from "vue";
import type { QTableProps } from "quasar";
2024-09-03 11:28:01 +07:00
import type { workingTimeDataRowType } from "@/modules/09_leave/interface/request/workTime";
export const useWorkTimeStore = defineStore("WorkTimeStore", () => {
2024-09-03 11:28:01 +07:00
const rows = ref<workingTimeDataRowType[]>([]);
2024-09-03 11:28:01 +07:00
const visibleColumns = ref<string[]>([
"round",
"morning",
"morningEnd",
"afternoon",
"afternoonEnd",
"reason",
"status",
]); //ค้นหา คอลัมน์ คอลัมน์ที่แสดง
2024-09-03 11:28:01 +07:00
// หัวตาราง
const columns = ref<QTableProps["columns"]>([
{
name: "round",
align: "left",
label: "รอบ",
sortable: true,
field: "round",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "morning",
align: "left",
label: "รอบเช้า",
sortable: true,
field: "morning",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "morningEnd",
align: "left",
label: "รอบออก",
sortable: true,
field: "morningEnd",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "afternoon",
align: "left",
label: "รอบบ่าย",
sortable: true,
field: "afternoon",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "afternoonEnd",
align: "left",
label: "รอบออก",
sortable: true,
field: "afternoonEnd",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "reason",
align: "left",
label: "คำอธิบาย",
sortable: true,
field: "reason",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
sort: (a: string, b: string) =>
a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" }),
},
{
name: "status",
align: "center",
label: "สถานะการใช้งาน",
sortable: false,
field: "status",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
]);
function fecthList(data: workingTimeDataRowType[]) {
let datalist: workingTimeDataRowType[] = data.map(
(e: workingTimeDataRowType) => {
return {
round: `${e.morning}-${e.afternoonEnd}`,
morning: e.morning,
morningEnd: e.morningEnd,
afternoon: e.afternoon,
afternoonEnd: e.afternoonEnd,
reason: e.reason === "" ? "-" : e.reason,
status: e.status,
};
}
);
rows.value = datalist;
}
2024-09-03 11:28:01 +07:00
return {
fecthList,
rows,
visibleColumns,
columns,
};
});