hrms-mgt/src/stores/menuList.ts

60 lines
1.5 KiB
TypeScript
Raw Normal View History

2024-07-24 16:40:43 +07:00
import { defineStore } from "pinia";
import { ref } from "vue";
/**
* importType
*/
import type {
ListMenu,
ChildLevelTree,
DataPermissions,
} from "@/interface/response/main";
2024-07-24 16:40:43 +07:00
export const useMenuDataStore = defineStore("menuUse", () => {
/****************** เมนู **************************/
/** รายการเมนู*/
2024-08-08 16:44:31 +07:00
const menuList = ref<ListMenu[]>([]);
2024-07-24 16:40:43 +07:00
/**
* function
* @param data
*/
2024-07-24 16:40:43 +07:00
function fetchListMenu(data: ListMenu[]) {
if (data) {
2024-08-08 16:44:31 +07:00
menuList.value = [
{
id: "dashboard",
order: 0,
icon: "mdi-home-variant-outline",
sysName: "หน้าแรก",
sysDescription: "หน้าแรก",
path: "dashboard",
parentId: null,
children: [],
},
...data,
];
}
2024-07-24 16:40:43 +07:00
}
/****************** สิทธิ์ **************************/
2024-07-31 09:48:33 +07:00
const permissions = ref<DataPermissions>();
/**
* function
* @param data
*/
function fetchDataPermission(data: DataPermissions) {
2024-07-31 09:48:33 +07:00
permissions.value = data;
}
2024-07-24 16:40:43 +07:00
return {
/****************** เมนู **************************/
2024-07-24 16:40:43 +07:00
fetchListMenu,
menuList,
/****************** สิทธิ์ **************************/
fetchDataPermission,
2024-07-31 09:48:33 +07:00
permissions,
2024-07-24 16:40:43 +07:00
};
});