Bläddra i källkod

修改权限和日志监控问题

吴朋磊 1 vecka sedan
förälder
incheckning
c1c9e6e57d

+ 42 - 21
src/layout/components/SiderBar.vue

@@ -53,32 +53,53 @@ const menuItems = ref<menuItem[]>()
 
 onMounted(() => {
   const menuListStr = localStorage.getItem('menuList')
+  const userInfoStr = localStorage.getItem('userInfo')
 
   if (menuListStr) {
     menuItems.value = JSON.parse(menuListStr)
 
-    let additionalMenuList = [
-      {
-        icon: "icon_xuexiaoguanli",
-        route: "/main/logMonitor",
-        title: "日志监控",
-        label:'',
-      },
-      {
-        icon: "icon_xuexiaoguanli",
-        route: "/main/performanceMonitor",
-        title: "业务监控",
-        label:'',
-      },
-    ]
+    // 运维人员只显示学校管理和用户查询,不显示日志监控和业务监控
+    // 先过滤掉后端可能返回的日志监控和业务监控
+    menuItems.value = menuItems.value?.filter(menu =>
+      menu.route !== '/main/logMonitor' && menu.route !== '/main/performanceMonitor'
+    )
 
-    // 只追加 menuList 中不存在的菜单项,避免重复
-    additionalMenuList.forEach(item => {
-      const exists = menuItems.value?.some(menu => menu.route === item.route)
-      if (!exists) {
-        menuItems.value?.push(item)
-      }
-    })
+    // 通过 userInfo 判断是否为运维人员
+    // 如果是运维账号(没有管理员相关菜单或特定字段),则不添加日志监控和业务监控
+    const userInfo = userInfoStr ? JSON.parse(userInfoStr) : {}
+    const isOpsUser = userInfo?.userType === 'ops' || userInfo?.roleType === 'ops'
+
+    // 判断是否为管理员账号(有运维管理或联考管理菜单)
+    const hasAdminMenu = menuItems.value?.some(menu =>
+      menu.route === '/main/manager' || menu.route === '/main/examination'
+    )
+
+    console.log('isOpsUser:', isOpsUser, 'hasAdminMenu:', hasAdminMenu)
+
+    if (!isOpsUser && hasAdminMenu) {
+      // 非运维人员且有管理员菜单,添加日志监控和业务监控
+      const additionalMenuList = [
+        {
+          icon: "icon_xuexiaoguanli",
+          route: "/main/logMonitor",
+          title: "日志监控",
+          label:'',
+        },
+        {
+          icon: "icon_xuexiaoguanli",
+          route: "/main/performanceMonitor",
+          title: "业务监控",
+          label:'',
+        },
+      ]
+
+      additionalMenuList.forEach(item => {
+        const exists = menuItems.value?.some(menu => menu.route === item.route)
+        if (!exists) {
+          menuItems.value?.push(item)
+        }
+      })
+    }
   }
 
 });

+ 1 - 1
src/views/performanceMonitor/index.vue

@@ -196,7 +196,7 @@ const handleCustomDateChange = (val: [string, string] | null) => {
 }
 
 // ==================== 图表数据 ====================
-const timeHours = ['0时','1时','2时','3时','4时','5时','6时','7时','8时','9时','10时','11时','12时','13时','14时','15时','16时','17时','18时','19时','20时','21时','22时','23时']
+const timeHours = ['1时','2时','3时','4时','5时','6时','7时','8时','9时','10时','11时','12时','13时','14时','15时','16时','17时','18时','19时','20时','21时','22时','23时','24时']
 
 const mainLineChartData = reactive({
     datax: [] as string[],

+ 11 - 1
src/views/userSearch/formSearchGroup.ts

@@ -1,5 +1,15 @@
 import { ref } from "vue";
-import type { SearchItem } from "@/baseComponents/formSearchGroup";
+
+interface SearchItem {
+    key: string;
+    type: 'input' | 'select' | 'datePicker' | 'radio';
+    placeholder: string;
+    hidden: boolean;
+    defaultValue: string | number;
+    label?: string;
+    options?: Array<{ label: string; value: string | number }>;
+    disabled?: boolean;
+}
 
 export const searchList = ref<SearchItem[]>([
     {

+ 3 - 3
src/views/userSearch/index.vue

@@ -75,7 +75,7 @@ const GetUserInfo = async ()=>{
     }
 }
 // 处理搜索项变化
-const HandleUserSearchChange = async (params,key)=>{
+const HandleUserSearchChange = async (params:any,key:any)=>{
     console.log('查询参数',params)
     console.log('查询key',key)
     searchParams.value = {...params}
@@ -83,7 +83,7 @@ const HandleUserSearchChange = async (params,key)=>{
 }
 
 // 处理分页变化
-const HandlePaginationChange = async (params)=>{
+const HandlePaginationChange = async (params:any)=>{
     const {type,val} = params
     if(type == 'currentPage'){
         currentPage.value = val
@@ -93,7 +93,7 @@ const HandlePaginationChange = async (params)=>{
 
 
 // 用户身份类型状态转换
-const IdentityTypeNumToName = (type)=>{
+const IdentityTypeNumToName = (type:any)=>{
     switch(type){
         case 0:
             return {