permissionsMenu

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-07-24 16:40:43 +07:00
parent cc36f52e55
commit 007df38109
4 changed files with 204 additions and 73 deletions

115
src/stores/menuList.ts Normal file
View file

@ -0,0 +1,115 @@
import { defineStore } from "pinia";
import { ref } from "vue";
import type {
ListMenu,
ChildLevelTree,
ChildConfig,
} from "@/interface/response/main";
export const useMenuDataStore = defineStore("menuUse", () => {
const menuList = ref<ListMenu[]>([
{
id: "dashboard",
order: 0,
icon: "mdi-home-variant-outline",
sysName: "หน้าแรก",
sysDescription: "หน้าแรก",
path: "dashboard",
parentId: null,
children: [],
},
]);
const childLevelTree = ref<ChildLevelTree>({
SYS_EVA_INDICATOR: [
{
sysName: "ตามแผน",
path: "KPIIndicatorByPlan",
},
{
sysName: "ตามตำแหน่ง",
path: "KPIIndicatorByRole",
},
{
sysName: "งานที่ได้รับมอบหมาย",
path: "KPIAssignment",
},
],
SYS_EXAM_CONTEST: [
{
sysName: "จัดการรอบสอบแข่งขัน",
path: "competePeriod",
},
{
sysName: "สถิติสมัครสอบแข่งขัน",
path: "competePeriodStat",
},
],
SYS_EXAM_SELECT: [
{
sysName: "จัดการรอบคัดเลือก",
path: "qualifyPeriod",
},
{
sysName: "จัดการรอบคัดเลือกคนพิการ",
path: "disablePeriod",
},
{
sysName: "จัดการรายชื่อคัดเลือก",
path: "manage",
},
{
sysName: "สถิติสมัครคัดเลือก",
path: "qualifyPeriodStat",
},
{
sysName: "สถิติสมัครคัดเลือกคนพิการ",
path: "qualifyPeriodStatDisable",
},
],
SYS_DISCIPLINE_INFO: [
{
sysName: "กรรมการ",
path: "disciplineDirector",
},
{
sysName: "ช่องทางการร้องเรียน",
path: "disciplineChannel",
},
],
SYS_EVA_INFO: [
{
sysName: "กรรมการ",
path: "evaluateDirector",
},
{
sysName: "การประชุม",
path: "evaluateMeeting",
},
],
});
function fetchListMenu(data: ListMenu[]) {
data.forEach((item) => {
if (item.children && item.children.length !== 0) {
item.children.forEach((q: ListMenu) => {
const config: any = childLevelTree.value[q.id];
if (config) {
if (!q.children) {
q.children = [];
}
// เพิ้ม ข้อมูลเลเวล 3
q.children.push(...config);
}
});
}
});
menuList.value.push(...data);
}
return {
fetchListMenu,
menuList,
};
});