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

94 lines
2.3 KiB
TypeScript
Raw Normal View History

import { defineStore } from "pinia";
import { ref } from "vue";
import type { dataRowRound } from "@/modules/09_leave/interface/response/round.ts";
import type { QTableProps } from "quasar";
// store ลา >> รอบการปฏิบัติงาน
export const useRoundDataStore = defineStore(
"disciplineDirector",
() => {
//ค้นหา คอลัมน์ คอลัมน์ที่แสดง
const visibleColumns = ref<string[]>([
"round",
"am",
"amOut",
"pm",
"pmOut",
"note",
"status"
]);
// หัวตาราง
const columns = ref<QTableProps["columns"]>([
{
name: "round",
align: "left",
label: "รอบ",
sortable: true,
field: "round",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "am",
align: "left",
label: "ช่วงเช้า",
sortable: true,
field: "am",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "pm",
align: "left",
label: "ช่วงบ่าย",
sortable: true,
field: "pm",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "note",
align: "left",
label: "คำอธิบาย",
sortable: true,
field: "note",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
{
name: "status",
align: "center",
label: "สถานะการใช้งาน",
sortable: true,
field: "status",
headerStyle: "font-size: 14px",
style: "font-size: 14px",
},
]);
// ข้อมูลในตาราง
const rows = ref<dataRowRound[]>([]);
function fetchData(data: dataRowRound[]) {
let datalist: dataRowRound[] = data.map((e: dataRowRound) => {
return {
round:`${e.am}-${e.pmOut}`,
2023-10-31 12:09:24 +07:00
am: `${e.am}-${e.amOut}`,
pm: `${e.pm}-${e.pmOut}`,
note: e.note === '' ? '-':e.note,
status: e.status,
2023-10-31 12:09:24 +07:00
isDefault: e.isDefault,
};
});
rows.value = datalist;
}
return {
visibleColumns,
columns,
rows,
fetchData
};
}
);