浏览代码

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

guhongwei 2 年之前
父节点
当前提交
ffb4fe3bf5

+ 1 - 1
src/components/studio-one-green copy/homeParts/header-1.vue

@@ -43,7 +43,7 @@ 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: '' });
 const toDrop = () => {};
 const modulePath = (value: any) => {
-  console.log(value);
+  // console.log(value);
 };
 </script>
 

+ 1 - 1
src/components/studio-one-green copy/parts/header-1.vue

@@ -42,7 +42,7 @@ 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: '' });
 const toDrop = () => {};
 const modulePath = (value: any) => {
-  console.log(value);
+  // console.log(value);
 };
 </script>
 

+ 8 - 0
src/components/studio-one-green/home-3.vue

@@ -0,0 +1,8 @@
+<template>
+  <div id="home-3">
+    <router-view></router-view>
+  </div>
+</template>
+<script setup lang="ts"></script>
+
+<style scoped lang="scss"></style>

+ 2 - 2
src/components/studio-one-green/home.vue

@@ -2,7 +2,7 @@
   <div id="home">
     <home1 v-if="type == '1'"></home1>
     <home2 v-else-if="type == '2'"></home2>
-    <!--  <home3 v-else-if="type == '3'"></home3> -->
+    <home3 v-else-if="type == '3'"></home3>
   </div>
 </template>
 
@@ -12,7 +12,7 @@
 import store from '@/stores/counter';
 import home1 from './home-1.vue';
 import home2 from './home-2.vue';
-// import home3 from './home-3.vue';
+import home3 from './home-3.vue';
 import type { Ref } from 'vue';
 import { ref, onMounted } from 'vue';
 import { ElMessage } from 'element-plus';

+ 25 - 19
src/components/studio-one-green/homeParts1/header-1.vue

@@ -7,17 +7,11 @@
           <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>
+            <el-button type="danger" plain size="large">
               {{ user && user._id ? user.name || user.unit_name || user.nick_name : '暂无昵称' }}
               <el-icon class="el-icon--right"> <ArrowDown /></el-icon>
             </el-button>
@@ -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>

+ 11 - 7
src/layout/site.ts

@@ -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',
   },
 ];
 // 菜单