|
|
@@ -53,203 +53,221 @@ export const useCounterStore = defineStore("user", {
|
|
|
async ROLEAdd() {
|
|
|
// 获取菜单权限列表
|
|
|
this.roleList = [];
|
|
|
- let datas = {
|
|
|
- accountId: sessionStorage.getItem("accountId"),
|
|
|
- };
|
|
|
- const res = await https.get(
|
|
|
- "/welcome/api/welcomeAccount/getAccountAuthority",
|
|
|
- "params",
|
|
|
- datas
|
|
|
- ); // 使用封装的 get 方法
|
|
|
- console.log(res, "获取菜单权限列表");
|
|
|
- if (res.code == 200) {
|
|
|
- this.collegeRole = res.data.welcomeOrgList;
|
|
|
- let roles = res.data.welcomeRole;
|
|
|
- this.roleId = res.data.welcomeRole.id;
|
|
|
- let btn = [];
|
|
|
- // 数据总览
|
|
|
- if (roles.dataManagementSetting) {
|
|
|
- let arr = roles.dataManagementSetting.split(",");
|
|
|
- arr.forEach((i) => {
|
|
|
- btn.push(`dataOverview${i}`);
|
|
|
- if (i == 1) {
|
|
|
- this.roleList.push({
|
|
|
- name: "数据总览",
|
|
|
- path: "/dataOverview",
|
|
|
- icon: "dataOverview",
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- // 学生信息设置
|
|
|
- if (roles.studentManagementSetting) {
|
|
|
- let arr = roles.studentManagementSetting.split(",");
|
|
|
- arr.forEach((i) => {
|
|
|
- btn.push(`studentManagementSetting${i}`);
|
|
|
- if (i == 7) {
|
|
|
- this.roleList.push({
|
|
|
- name: "学生信息管理",
|
|
|
- path: "/studentInfo",
|
|
|
- icon: "studentInfo",
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- // 楼栋管理设置
|
|
|
- if (roles.buildingManagementSetting) {
|
|
|
- let arr = roles.buildingManagementSetting.split(",");
|
|
|
- arr.forEach((i) => {
|
|
|
- btn.push(`buildingManagementSetting${i}`);
|
|
|
- if (i == 6) {
|
|
|
- this.roleList.push({
|
|
|
- name: "楼栋信息管理",
|
|
|
- path: "/building",
|
|
|
- icon: "building",
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- // 宿舍管理设置
|
|
|
- if (roles.dormitoryManagementSetting) {
|
|
|
- let arr = roles.dormitoryManagementSetting.split(",");
|
|
|
- arr.forEach((i) => {
|
|
|
- btn.push(`dormitoryManagementSetting${i}`);
|
|
|
- if (i == 10) {
|
|
|
- this.roleList.push({
|
|
|
- name: "寝室信息管理",
|
|
|
- path: "/dormitory",
|
|
|
- icon: "dormitory",
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- // 床位管理设置
|
|
|
- if (roles.bedManagementSetting) {
|
|
|
- let arr = roles.bedManagementSetting.split(",");
|
|
|
- arr.forEach((i) => {
|
|
|
- btn.push(`bedManagementSetting${i}`);
|
|
|
- if (i == 13) {
|
|
|
- this.roleList.push({
|
|
|
- name: "床位信息管理",
|
|
|
- path: "/bed",
|
|
|
- icon: "bed",
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- // 学生住宿设置
|
|
|
- if (roles.studentAccommodationSetting) {
|
|
|
- let arr = roles.studentAccommodationSetting.split(",");
|
|
|
- arr.forEach((i) => {
|
|
|
- btn.push(`studentAccommodationSetting${i}`);
|
|
|
- if (i == 2) {
|
|
|
- this.roleList.push({
|
|
|
- name: "学生住宿信息",
|
|
|
- path: "/student",
|
|
|
- icon: "student",
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- // 住宿信息统计
|
|
|
- if (roles.accommodationStatisticsSetting) {
|
|
|
- let arr = roles.accommodationStatisticsSetting.split(",");
|
|
|
- arr.forEach((i) => {
|
|
|
- btn.push(`accommodationStatisticsSetting${i}`);
|
|
|
- if (i == 2) {
|
|
|
- this.roleList.push({
|
|
|
- name: "住宿信息统计",
|
|
|
- path: "/quarterage",
|
|
|
- icon: "quarterage",
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- // 访客信息管理
|
|
|
- if (roles.visitorManagementSetting) {
|
|
|
- let arr = roles.visitorManagementSetting.split(",");
|
|
|
- arr.forEach((i) => {
|
|
|
- btn.push(`visitorManagementSetting${i}`);
|
|
|
- if (i == 5) {
|
|
|
- this.roleList.push({
|
|
|
- name: "访客信息管理 ",
|
|
|
- path: "/caller",
|
|
|
- icon: "caller",
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- // 选宿舍金额设置
|
|
|
- if (roles.dormitoryMoneySetting) {
|
|
|
- let arr = roles.dormitoryMoneySetting.split(",");
|
|
|
- arr.forEach((i) => {
|
|
|
- btn.push(`dormitoryMoneySetting${i}`);
|
|
|
- if (i == 6) {
|
|
|
- this.roleList.push({
|
|
|
- name: "选宿舍金额设置 ",
|
|
|
- path: "/moneySetting",
|
|
|
- icon: "moneySetting",
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- // 用户管理
|
|
|
- if (roles.accountManagementSetting) {
|
|
|
- let arr = roles.accountManagementSetting.split(",");
|
|
|
- arr.forEach((i) => {
|
|
|
- btn.push(`accountManagementSetting${i}`);
|
|
|
- if (i == 4) {
|
|
|
- this.roleList.push({
|
|
|
- name: "用户管理 ",
|
|
|
- path: "/user",
|
|
|
- icon: "user",
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- // 角色管理
|
|
|
- if (roles.roleManagementSetting) {
|
|
|
- let arr = roles.roleManagementSetting.split(",");
|
|
|
- arr.forEach((i) => {
|
|
|
- btn.push(`roleManagementSetting${i}`);
|
|
|
- if (i == 4) {
|
|
|
- this.roleList.push({
|
|
|
- name: "角色管理 ",
|
|
|
- path: "/role",
|
|
|
- icon: "role",
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- // 系统设置
|
|
|
- if (roles.settingManagementSetting) {
|
|
|
- let arr = roles.settingManagementSetting.split(",");
|
|
|
- arr.forEach((i) => {
|
|
|
- btn.push(`settingManagementSetting${i}`);
|
|
|
- if (i == 2) {
|
|
|
- this.roleList.push({
|
|
|
- name: "系统设置 ",
|
|
|
- path: "/system",
|
|
|
- icon: "system",
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- // sessionStorage.setItem("btnRole", btn.toString());
|
|
|
- this.btnRole = btn;
|
|
|
- const modules = import.meta.glob("../views/**/*.vue");
|
|
|
- let roleList = this.roleList;
|
|
|
- if (roleList) {
|
|
|
- roleList.forEach((item) => {
|
|
|
- let arr = {
|
|
|
- path: item.path,
|
|
|
- name: item.path,
|
|
|
- meta: { isAuth: true, title: item.name, showHeader: true },
|
|
|
- component: modules[`../views${item.path}${item.path}.vue`],
|
|
|
- };
|
|
|
- router.addRoute(arr);
|
|
|
+ if (sessionStorage.getItem("accountId")) {
|
|
|
+ let datas = {
|
|
|
+ accountId: sessionStorage.getItem("accountId"),
|
|
|
+ };
|
|
|
+ const res = await https.get(
|
|
|
+ "/welcome/api/welcomeAccount/getAccountAuthority",
|
|
|
+ "params",
|
|
|
+ datas
|
|
|
+ ); // 使用封装的 get 方法
|
|
|
+ console.log(res, "获取菜单权限列表");
|
|
|
+ if (res.code == 200) {
|
|
|
+ this.collegeRole = res.data.welcomeOrgList;
|
|
|
+ let roles = res.data.welcomeRole;
|
|
|
+ this.roleId = res.data.welcomeRole.id;
|
|
|
+ let btn = [];
|
|
|
+ // 数据总览
|
|
|
+ if (roles.dataManagementSetting) {
|
|
|
+ let arr = roles.dataManagementSetting.split(",");
|
|
|
+ arr.forEach((i) => {
|
|
|
+ btn.push(`dataOverview${i}`);
|
|
|
+ if (i == 1) {
|
|
|
+ this.roleList.push({
|
|
|
+ name: "数据总览",
|
|
|
+ path: "/dataOverview",
|
|
|
+ icon: "dataOverview",
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ // 学生信息设置
|
|
|
+ if (roles.studentManagementSetting) {
|
|
|
+ let arr = roles.studentManagementSetting.split(",");
|
|
|
+ arr.forEach((i) => {
|
|
|
+ btn.push(`studentManagementSetting${i}`);
|
|
|
+ if (i == 7) {
|
|
|
+ this.roleList.push({
|
|
|
+ name: "学生信息管理",
|
|
|
+ path: "/studentInfo",
|
|
|
+ icon: "studentInfo",
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ // 楼栋管理设置
|
|
|
+ if (roles.buildingManagementSetting) {
|
|
|
+ let arr = roles.buildingManagementSetting.split(",");
|
|
|
+ arr.forEach((i) => {
|
|
|
+ btn.push(`buildingManagementSetting${i}`);
|
|
|
+ if (i == 6) {
|
|
|
+ this.roleList.push({
|
|
|
+ name: "楼栋信息管理",
|
|
|
+ path: "/building",
|
|
|
+ icon: "building",
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ // 宿舍管理设置
|
|
|
+ if (roles.dormitoryManagementSetting) {
|
|
|
+ let arr = roles.dormitoryManagementSetting.split(",");
|
|
|
+ arr.forEach((i) => {
|
|
|
+ btn.push(`dormitoryManagementSetting${i}`);
|
|
|
+ if (i == 10) {
|
|
|
+ this.roleList.push({
|
|
|
+ name: "寝室信息管理",
|
|
|
+ path: "/dormitory",
|
|
|
+ icon: "dormitory",
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ // 床位管理设置
|
|
|
+ if (roles.bedManagementSetting) {
|
|
|
+ let arr = roles.bedManagementSetting.split(",");
|
|
|
+ arr.forEach((i) => {
|
|
|
+ btn.push(`bedManagementSetting${i}`);
|
|
|
+ if (i == 13) {
|
|
|
+ this.roleList.push({
|
|
|
+ name: "床位信息管理",
|
|
|
+ path: "/bed",
|
|
|
+ icon: "bed",
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ // 学生住宿设置
|
|
|
+ if (roles.studentAccommodationSetting) {
|
|
|
+ let arr = roles.studentAccommodationSetting.split(",");
|
|
|
+ arr.forEach((i) => {
|
|
|
+ btn.push(`studentAccommodationSetting${i}`);
|
|
|
+ if (i == 2) {
|
|
|
+ this.roleList.push({
|
|
|
+ name: "学生住宿信息",
|
|
|
+ path: "/student",
|
|
|
+ icon: "student",
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ // 住宿信息统计
|
|
|
+ if (roles.accommodationStatisticsSetting) {
|
|
|
+ let arr = roles.accommodationStatisticsSetting.split(",");
|
|
|
+ arr.forEach((i) => {
|
|
|
+ btn.push(`accommodationStatisticsSetting${i}`);
|
|
|
+ if (i == 2) {
|
|
|
+ this.roleList.push({
|
|
|
+ name: "住宿信息统计",
|
|
|
+ path: "/quarterage",
|
|
|
+ icon: "quarterage",
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ // 访客信息管理
|
|
|
+ if (roles.visitorManagementSetting) {
|
|
|
+ let arr = roles.visitorManagementSetting.split(",");
|
|
|
+ arr.forEach((i) => {
|
|
|
+ btn.push(`visitorManagementSetting${i}`);
|
|
|
+ if (i == 5) {
|
|
|
+ this.roleList.push({
|
|
|
+ name: "访客信息管理 ",
|
|
|
+ path: "/caller",
|
|
|
+ icon: "caller",
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ // 选宿舍金额设置
|
|
|
+ if (roles.dormitoryMoneySetting) {
|
|
|
+ let arr = roles.dormitoryMoneySetting.split(",");
|
|
|
+ arr.forEach((i) => {
|
|
|
+ btn.push(`dormitoryMoneySetting${i}`);
|
|
|
+ if (i == 6) {
|
|
|
+ this.roleList.push({
|
|
|
+ name: "选宿舍金额设置 ",
|
|
|
+ path: "/moneySetting",
|
|
|
+ icon: "moneySetting",
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ // 用户管理
|
|
|
+ if (roles.accountManagementSetting) {
|
|
|
+ let arr = roles.accountManagementSetting.split(",");
|
|
|
+ arr.forEach((i) => {
|
|
|
+ btn.push(`accountManagementSetting${i}`);
|
|
|
+ if (i == 4) {
|
|
|
+ this.roleList.push({
|
|
|
+ name: "用户管理 ",
|
|
|
+ path: "/user",
|
|
|
+ icon: "user",
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ // 角色管理
|
|
|
+ if (roles.roleManagementSetting) {
|
|
|
+ let arr = roles.roleManagementSetting.split(",");
|
|
|
+ arr.forEach((i) => {
|
|
|
+ btn.push(`roleManagementSetting${i}`);
|
|
|
+ if (i == 4) {
|
|
|
+ this.roleList.push({
|
|
|
+ name: "角色管理 ",
|
|
|
+ path: "/role",
|
|
|
+ icon: "role",
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ // 系统设置
|
|
|
+ if (roles.settingManagementSetting) {
|
|
|
+ let arr = roles.settingManagementSetting.split(",");
|
|
|
+ arr.forEach((i) => {
|
|
|
+ btn.push(`settingManagementSetting${i}`);
|
|
|
+ if (i == 2) {
|
|
|
+ this.roleList.push({
|
|
|
+ name: "系统设置 ",
|
|
|
+ path: "/system",
|
|
|
+ icon: "system",
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ // sessionStorage.setItem("btnRole", btn.toString());
|
|
|
+ this.btnRole = btn;
|
|
|
+ const modules = import.meta.glob("../views/**/*.vue");
|
|
|
+ let roleList = this.roleList;
|
|
|
+ if (roleList) {
|
|
|
+ roleList.forEach((item) => {
|
|
|
+ let arr = {
|
|
|
+ path: item.path,
|
|
|
+ name: item.path,
|
|
|
+ meta: { isAuth: true, title: item.name, showHeader: true },
|
|
|
+ component: modules[`../views${item.path}${item.path}.vue`],
|
|
|
+ };
|
|
|
+ router.addRoute(arr);
|
|
|
+ });
|
|
|
+ router.addRoute({
|
|
|
+ path: "/404",
|
|
|
+ name: "NotFound",
|
|
|
+ component: () => import("@/views/404/404.vue"),
|
|
|
+ });
|
|
|
+ router.addRoute({
|
|
|
+ path: "/:pathMatch(.*)*",
|
|
|
+ redirect: "/404",
|
|
|
+ });
|
|
|
+ console.log("动态添加路由");
|
|
|
+ }
|
|
|
+
|
|
|
+ router.push({
|
|
|
+ path: roleList[0].path,
|
|
|
});
|
|
|
+ } else {
|
|
|
+ console.log("动态添加路由失败");
|
|
|
router.addRoute({
|
|
|
path: "/404",
|
|
|
name: "NotFound",
|
|
|
@@ -259,23 +277,7 @@ export const useCounterStore = defineStore("user", {
|
|
|
path: "/:pathMatch(.*)*",
|
|
|
redirect: "/404",
|
|
|
});
|
|
|
- console.log("动态添加路由");
|
|
|
}
|
|
|
-
|
|
|
- router.push({
|
|
|
- path: roleList[0].path,
|
|
|
- });
|
|
|
- } else {
|
|
|
- console.log("动态添加路由失败");
|
|
|
- router.addRoute({
|
|
|
- path: "/404",
|
|
|
- name: "NotFound",
|
|
|
- component: () => import("@/views/404/404.vue"),
|
|
|
- });
|
|
|
- router.addRoute({
|
|
|
- path: "/:pathMatch(.*)*",
|
|
|
- redirect: "/404",
|
|
|
- });
|
|
|
}
|
|
|
},
|
|
|
BtnRole(flag) {
|