59 lines
1.5 KiB
TypeScript
59 lines
1.5 KiB
TypeScript
import { defineStore } from "pinia";
|
|
import { ref } from "vue";
|
|
|
|
/**
|
|
* importType
|
|
*/
|
|
import type {
|
|
ListMenu,
|
|
ChildLevelTree,
|
|
DataPermissions,
|
|
} from "@/interface/response/main";
|
|
|
|
export const useMenuDataStore = defineStore("menuUse", () => {
|
|
/****************** เมนู **************************/
|
|
/** รายการเมนู*/
|
|
const menuList = ref<ListMenu[]>([]);
|
|
|
|
/**
|
|
* function เรียกรายการเมนูทั้งหมด
|
|
* @param data ข้อมูลรายการทั้งหมด
|
|
*/
|
|
function fetchListMenu(data: ListMenu[]) {
|
|
if (data) {
|
|
menuList.value = [
|
|
{
|
|
id: "dashboard",
|
|
order: 0,
|
|
icon: "mdi-home-variant-outline",
|
|
sysName: "หน้าแรก",
|
|
sysDescription: "หน้าแรก",
|
|
path: "dashboard",
|
|
parentId: null,
|
|
children: [],
|
|
},
|
|
...data,
|
|
];
|
|
}
|
|
}
|
|
|
|
/****************** สิทธิ์ **************************/
|
|
const permissions = ref<DataPermissions>();
|
|
|
|
/**
|
|
* function เรียก
|
|
* @param data ข้อมูลสิทธิ์
|
|
*/
|
|
function fetchDataPermission(data: DataPermissions) {
|
|
permissions.value = data;
|
|
}
|
|
|
|
return {
|
|
/****************** เมนู **************************/
|
|
fetchListMenu,
|
|
menuList,
|
|
/****************** สิทธิ์ **************************/
|
|
fetchDataPermission,
|
|
permissions,
|
|
};
|
|
});
|