Browse Source

Merge branch 'master' of http://git.cc-lotus.info/studio_vue3/common

zs 2 years ago
parent
commit
255c0f2291
2 changed files with 37 additions and 27 deletions
  1. 24 18
      src/components/studio-one-green/homeParts1/header-1.vue
  2. 13 9
      src/layout/site.ts

+ 24 - 18
src/components/studio-one-green/homeParts1/header-1.vue

@@ -7,15 +7,9 @@
           <span>{{ webInfo.zhTitle }}</span>
         </el-col>
         <el-col :span="16" class="two">
-          <el-button
-            size="small"
-            plain
-            v-for="(item, index) in moduleList"
-            :key="index"
-            @click="modulePath(item)"
-            :class="[active == item.active ? 'active' : '']"
-            >{{ item.name }}</el-button
-          >
+          <el-button plain v-for="(item, index) in moduleList" :key="index" @click="modulePath(item)" :class="[active == item.active ? 'active' : '']">{{
+            item.name
+          }}</el-button>
           <el-dropdown @command="toDrop">
             <el-button type="danger" plain>
               {{ user && user._id ? user.name || user.unit_name || user.nick_name : '暂无昵称' }}
@@ -40,13 +34,13 @@ import { ArrowDown, User, SwitchButton } from '@element-plus/icons-vue';
 import store from '@/stores/counter';
 import { ref, onMounted } from 'vue';
 import type { Ref } from 'vue';
-import { studio_style_Info } from '../../../layout/site';
-// import { studio_style_Info } from '@common/src/layout/site';
+import { studio_style_Info, project_module_menus } from '../../../layout/site';
 const router = useRouter();
 let webInfo = studio_style_Info.webInfo;
-let active: 3;
+let active: Ref<number> = ref(3);
 let moduleList: Ref<any[]> = ref([]);
-let user: Ref<{ _id: string; name: string; unit_name: string; nick_name: string }> = ref({ _id: '', name: '', unit_name: '', nick_name: '' });
+let user = store.state.user as { _id: string; name: string; unit_name: string; nick_name: string; role_type: string };
+
 const toDrop = (e: string) => {
   if (e == 'logout') {
     localStorage.removeItem('token');
@@ -55,13 +49,25 @@ const toDrop = (e: string) => {
     router.push({ path: '/userInfo/center' });
   }
 };
+
 // 模块跳转
 const modulePath = (e: { path: string }) => {
   window.location.href = `${e.path}`;
 };
-onMounted(async () => {
-  user.value = store.state.user;
+onMounted(() => {
+  search();
 });
+const search = () => {
+  let menu = project_module_menus.filter((i: any) => i.role_type.includes(user.role_type));
+  if (user.role_type == '0' || user.role_type == '1') {
+    console.log('');
+  } else if (user.role_type == '2') {
+    if (user._id != '6417cbe06da906b0e7b19d66') menu = menu.filter((i) => i.path != '/basic');
+  } else if (user.role_type == '3') {
+    if (user._id != '6417cba86da906b0e7b19b5a') menu = menu.filter((i) => i.path != '/basic');
+  }
+  if (menu) moduleList.value = menu;
+};
 </script>
 
 <style lang="scss" scoped>
@@ -91,9 +97,9 @@ onMounted(async () => {
     .el-button {
       margin: 0 0 0 10px;
     }
-    .active {
-      color: #07c4a8;
-    }
   }
 }
+.active {
+  color: #07c4a8;
+}
 </style>

+ 13 - 9
src/layout/site.ts

@@ -3,8 +3,8 @@ export const webInfo = {
   display: true,
   zhTitle: '基础研究动态管理平台',
   enTitle: 'Dynamic management platform for basic research',
-  // logo_url: require('../assets/logo.png'),
-  // user_url: require('../assets/user.png'),
+  logo_url: '/src/assets/logo.png',
+  user_url: '/src/assets/user.png',
   content: 'Copyright  2018-2022 free All Rights Reserved.',
   smallTtitle: '基础研究动态',
   one_title: '鼓励探索、突出原创',
@@ -78,20 +78,23 @@ export const project_module_menus = [
     path: '/admin',
     type: 'basic,project,studio',
     active: '0',
+    role_type: '0,1,2,3',
+  },
+  {
+    icon: 'el-icon-user',
+    name: '省重点实验室',
+    path: '/basic',
+    type: 'admin,project,studio',
+    active: '1',
+    role_type: '0,1,2,3',
   },
-  // {
-  //   icon: 'el-icon-user',
-  //   name: '省重点实验室',
-  //   path: '/basic',
-  //   type: 'admin,project,studio',
-  //   active: '1',
-  // },
   {
     icon: 'el-icon-user',
     name: '项目管理',
     path: '/project',
     type: 'admin,basic,studio',
     active: '2',
+    role_type: '0,1,2,3',
   },
   {
     icon: 'el-icon-user',
@@ -99,6 +102,7 @@ export const project_module_menus = [
     path: '/studio',
     type: 'admin,basic,project',
     active: '3',
+    role_type: '0,1,2,3',
   },
 ];
 // 菜单