Home.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <style lang="scss">
  2. @import '../style/home.scss';
  3. .head{
  4. width:30px;
  5. height:30px;
  6. border-radius:50%;
  7. float:left;
  8. margin:10px;
  9. }
  10. </style>
  11. <template>
  12. <el-container>
  13. <el-header class="header">
  14. <h1><img height="60px" src="../images/logo.png" alt=""> <span>
  15. <!-- <el-divider direction="vertical"></el-divider> -->
  16. {{now}}</span></h1>
  17. <!-- <img class="logo" src="../images/logo.png" alt=""> -->
  18. <div class="settings">
  19. <span>
  20. <i class="el-icon-s-custom"></i>
  21. admin
  22. </span>
  23. <span class="logout" @click="logout"><i class="el-icon-switch-button"></i> 退出登录</span>
  24. </div>
  25. </el-header>
  26. <el-container class="main">
  27. <!-- 左侧菜单 -->
  28. <el-aside class="left-aside" width="210px">
  29. <el-menu background-color='#151932' text-color='#ffffff' :unique-opened='true' :default-active="$route.path" router class="left-menue" active-text-color="#ffffff">
  30. <template v-for="(item, index) in $router.options.routes">
  31. <el-menu-item v-if='item.show&&item.isLeaf' :index="item.path" :key='index'>
  32. <i :class="item.icon"></i>
  33. <span slot="title">{{item.name}}</span>
  34. </el-menu-item>
  35. <el-submenu v-if='item.show&&!item.isLeaf' :index="'index_'+index" :key='index'>
  36. <template slot="title">
  37. <i :class="item.icon"></i>
  38. <span>{{item.name}}</span>
  39. </template>
  40. <el-menu-item-group>
  41. <el-menu-item class="child" v-for="(child,idx) in item.children" :key="index+'_'+idx" :index="child.path" v-show='!child.hide'>
  42. {{child.name}}
  43. </el-menu-item>
  44. </el-menu-item-group>
  45. </el-submenu>
  46. </template>
  47. </el-menu>
  48. </el-aside>
  49. <!-- 右侧内容 -->
  50. <el-container>
  51. <el-main>
  52. <transition name="fade" mode="out-in"><router-view :info='info' :community='community'></router-view></transition>
  53. </el-main>
  54. <!-- <el-footer>Footer</el-footer> -->
  55. </el-container>
  56. </el-container>
  57. </el-container>
  58. </template>
  59. <script>
  60. export default {
  61. name: 'home',
  62. data() {
  63. return {
  64. menuList:[],
  65. path:'',
  66. info:{},
  67. community_list:[],
  68. community:{},
  69. menu:[],
  70. now:(new Date()).toLocaleDateString()+" "+(new Date()).toLocaleTimeString()
  71. };
  72. },
  73. methods: {
  74. getDate(){
  75. this.now=(new Date()).toLocaleDateString()+" "+(new Date()).toLocaleTimeString()
  76. },
  77. logout(){
  78. this.$api.logout().then(res=>{
  79. this.$router.push({path:'/login'})
  80. })
  81. },
  82. permission(name){
  83. let permissions=this.info.permissions||''
  84. if(permissions.indexOf(name)<0){
  85. return false;
  86. }else{
  87. return true;
  88. }
  89. },
  90. getData(){
  91. this.$api.getInfo().then(res=>{
  92. this.info=res.data.data
  93. })
  94. this.$api.getSubList().then(res=>{
  95. let data=res.data.data
  96. let routes=this.$route
  97. let path=[]
  98. for(let i=0;i<data.length;i++){
  99. path.push({
  100. path: '/',
  101. name: data[i].name,
  102. icon:'el-icon-s-custom',
  103. children:[
  104. { path: '/new/'+data[i].id, name: '新办'},
  105. { path: '/update/'+data[i].id, name: '复审'},
  106. { path: '/change/'+data[i].id, name: '换证'},
  107. ]
  108. })
  109. }
  110. this.menu=path
  111. })
  112. }
  113. },
  114. created(){
  115. // console.log(this.$route)
  116. // this.getData()
  117. var that=this;
  118. setInterval(function(){
  119. that.getDate();
  120. },1000)
  121. }
  122. };
  123. </script>