68 lines
1.8 KiB
TypeScript
68 lines
1.8 KiB
TypeScript
import { defineStore } from "pinia";
|
|
import { ref } from "vue";
|
|
import type { ChannelRows } from "@/modules/11_discipline/interface/response/channel";
|
|
import type { QTableProps } from "quasar";
|
|
|
|
// store ระบบวินัย >> ข้อมูลพื้นฐาน >> กรรมการ
|
|
export const useDisciplineChannelDataStore = defineStore(
|
|
"disciplineChannel",
|
|
() => {
|
|
//ค้นหา คอลัมน์ คอลัมน์ที่แสดง
|
|
const visibleColumns = ref<string[]>([
|
|
"no",
|
|
"name",
|
|
"interrogated",
|
|
"fault",
|
|
"status",
|
|
]); //ค้นหา คอลัมน์ คอลัมน์ที่แสดง
|
|
|
|
// หัวตาราง
|
|
const columns = ref<QTableProps["columns"]>([
|
|
{
|
|
name: "no",
|
|
align: "center",
|
|
label: "ลำดับ",
|
|
sortable: false,
|
|
field: "no",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px;width:100px;",
|
|
},
|
|
{
|
|
name: "name",
|
|
align: "left",
|
|
label: "ชื่อช่องทาง",
|
|
sortable: true,
|
|
field: "name",
|
|
headerStyle: "font-size: 14px",
|
|
style: "font-size: 14px",
|
|
},
|
|
]);
|
|
const type = ref<string>("");
|
|
// ข้อมูลในตาราง
|
|
function getType(data: string) {
|
|
type.value = "";
|
|
type.value = data;
|
|
}
|
|
const rows = ref<ChannelRows[]>([]);
|
|
const rowsData = ref<ChannelRows[]>([]);
|
|
|
|
/**
|
|
* รับค่าจาก API เก็บไว้ใน rows
|
|
* @param data ค่าจาก API
|
|
*/
|
|
function fetchData(data: ChannelRows[]) {
|
|
rows.value = data;
|
|
rowsData.value = data;
|
|
}
|
|
|
|
return {
|
|
visibleColumns,
|
|
columns,
|
|
rows,
|
|
rowsData,
|
|
fetchData,
|
|
type,
|
|
getType,
|
|
};
|
|
}
|
|
);
|