Home.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <style lang="scss">
  2. @import '../style/home.scss';
  3. .siteTitle{
  4. width:300px;
  5. margin:0 auto;
  6. }
  7. </style>
  8. <template>
  9. <el-container>
  10. <el-header>
  11. <div class="header">
  12. <!-- <img class="logo" src="../assets/logo.png" alt=""> -->
  13. <!-- <div class="siteTitle">中科院期刊微信公众号集中管理平台</div> -->
  14. </div>
  15. <div class="nav">
  16. <!-- <router-link :class="act?'active':''" to="/index/index" @click.native='active(1)'>首页</router-link>
  17. <router-link to="/journal/journal" @click.native='active(2)'>刊群导览</router-link>
  18. <router-link to="/learning/activity" @click.native='active(3)'>学术交流</router-link>
  19. <router-link to="/article/article" @click.native='active(4)'>精品导读</router-link>
  20. <router-link to="/conference/conference" @click.native='active(5)'>会议系统</router-link>
  21. <router-link to="/message/message" @click.native='active(6)'>信息管理</router-link>
  22. <router-link to="/system/account" @click.native='active(7)'>系统管理</router-link> -->
  23. <router-link v-for='(item,index) in inDate' :key='index' :class="item.act?'active':''" :to="item.to" @click.native='active(index)'>
  24. {{item.name}}
  25. </router-link>
  26. <div class="setting">
  27. <i class="el-icon-message-solid"></i>
  28. <el-dropdown>
  29. <span class="el-dropdown-link">
  30. {{info.name}}<i class="el-icon-arrow-down el-icon--right"></i>
  31. </span>
  32. <el-dropdown-menu slot="dropdown">
  33. <el-dropdown-item>修改密码</el-dropdown-item>
  34. </el-dropdown-menu>
  35. </el-dropdown>
  36. <span class="logout" @click="logout">退出登陆</span>
  37. </div>
  38. </div>
  39. </el-header>
  40. <el-container class="main">
  41. <!-- 左侧菜单 -->
  42. <el-aside class="left-aside" width="210px">
  43. <el-menu background-color='#ffffff' text-color='#666666' :unique-opened='false' :default-active="'/'+ $route.path.split('/')[1]+'/'+ $route.path.split('/')[2]" router class="left-menue" active-text-color="#3895FE">
  44. <template v-for="(item, index) in $router.options.routes" >
  45. <el-menu-item v-if='item.show&&item.isLeaf' :index="item.path" :key='index'>
  46. <i :class="item.icon"></i>
  47. <span slot="title">{{item.name}}</span>
  48. </el-menu-item>
  49. <!-- <el-submenu v-if='item.show&&!item.isLeaf' :index="'index_'+index" :key='index'>
  50. <template slot="title" >
  51. <i :class="item.icon"></i>
  52. <span>{{item.name}}</span>
  53. </template>
  54. <el-menu-item-group>
  55. <el-menu-item class="child" v-for="(child,idx) in item.children" :key="index+'_'+idx" :index="child.path" v-show='!child.hide'>
  56. {{child.name}}
  57. </el-menu-item>
  58. </el-menu-item-group>
  59. </el-submenu> -->
  60. </template>
  61. </el-menu>
  62. </el-aside>
  63. <!-- 右侧内容 -->
  64. <el-container>
  65. <el-main>
  66. <transition name="fade" mode="out-in">
  67. <router-view :info='info' :community='community' v-if='isShow'></router-view>
  68. </transition>
  69. </el-main>
  70. <!-- <el-footer>Footer</el-footer> -->
  71. </el-container>
  72. </el-container>
  73. </el-container>
  74. </template>
  75. <script>
  76. import Router from 'vue-router'
  77. export default {
  78. name: 'home',
  79. watch:{
  80. $route(to,from){
  81. let mod = to.path.split("/")[1];
  82. this.$router.options.routes.forEach((element,i) => {
  83. if(element.path.indexOf(mod)==-1){
  84. element.show = 0
  85. }else{
  86. element.show = 1
  87. }
  88. });
  89. }
  90. },
  91. data() {
  92. return {
  93. inDate:"",
  94. checkedCompany:'',
  95. menuList:[],
  96. path:'',
  97. info:{},
  98. community_list:[],
  99. community:{},
  100. menu:[],
  101. now:(new Date()).toLocaleDateString()+" "+(new Date()).toLocaleTimeString(),
  102. isShow:true
  103. };
  104. },
  105. methods: {
  106. getDate(){
  107. this.now=(new Date()).toLocaleDateString()+" "+(new Date()).toLocaleTimeString()
  108. },
  109. logout(){
  110. this.$api.logout().then(res=>{
  111. // this.$router.push({path:'/login'})
  112. this.$router.push({path:'/'})
  113. })
  114. },
  115. // permission(name){
  116. // let permissions=this.info.permissions||[];
  117. // let list=[];
  118. // for(let i=0;i<permissions.length;i++){
  119. // list.push(permissions[i].name)
  120. // }
  121. // if(list.indexOf(name)<0){
  122. // return false;
  123. // }else{
  124. // return true;
  125. // }
  126. // },
  127. getData(){
  128. this.$api.getAccountInfo().then(res=>{
  129. if(!res.code){
  130. this.info = res.data.data
  131. }
  132. })
  133. },
  134. active(i){
  135. let that = this;
  136. that.inDate.forEach( (item,index,arr) => {
  137. if(i != index) return item.act = false;
  138. item.act = true;
  139. })
  140. },
  141. initNav(){
  142. let data = [
  143. { act: true, to: '/index/index', name: '首页' },
  144. { act: false, to: '/journal/journal', name: '刊群导览' },
  145. { act: false, to: '/learning/activity', name: '学术交流' },
  146. { act: false, to: '/article/article', name: '精品导读' },
  147. { act: false, to: '/conference/conference', name: '会议系统' },
  148. { act: false, to: '/message/message', name: '信息管理' },
  149. { act: false, to: '/system/account', name: '系统管理' },
  150. ];
  151. let mod = this.$route.path.split("/")[1];
  152. this.$router.options.routes.forEach((element,i) => {
  153. if(element.path.indexOf(mod)==-1){
  154. element.show = 0
  155. }else{
  156. element.show = 1
  157. }
  158. });
  159. data.forEach(item =>{
  160. if(mod == item.to.split("/")[1]) return item.act = true;
  161. item.act = false;
  162. })
  163. this.inDate = data;
  164. },
  165. },
  166. created(){
  167. this.initNav()
  168. this.getData()
  169. }
  170. };
  171. </script>