MainLayout.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <template>
  2. <el-container>
  3. <el-header style="height: 50px">
  4. <header-element></header-element>
  5. </el-header>
  6. <el-container>
  7. <el-aside width="250px">
  8. <side-menu @setRouterName="setRouterName"></side-menu>
  9. </el-aside>
  10. <el-main>
  11. <div class="box_header">
  12. <div class="line" :style="{ backgroundColor: color}"></div>
  13. <span style="padding-left: 8px">{{routerName}}</span>
  14. <div class="button-right">
  15. <el-button size="mini" icon="el-icon-refresh" @click="refresh">刷新</el-button>
  16. </div>
  17. </div>
  18. <div class="operant" id="operant">
  19. <!-- 没有绑定不让其进去 -->
  20. <template v-if="hasPerm(routerSite + ':look')">
  21. <router-view></router-view>
  22. </template>
  23. <template v-else>
  24. <el-empty :image-size="200" description="暂无权限查看,请联系管理员"></el-empty>
  25. </template>
  26. </div>
  27. </el-main>
  28. </el-container>
  29. </el-container>
  30. </template>
  31. <script>
  32. import HeaderElement from "../components/HeaderElement";
  33. import SideMenu from "../components/SideMenu";
  34. import { findOne } from '../utils/api';
  35. import { mapActions, mapState } from 'vuex';
  36. export default {
  37. name: "MainLayout",
  38. components: {
  39. HeaderElement,
  40. SideMenu
  41. },
  42. data() {
  43. return {
  44. menuList: [],
  45. routerName: '',
  46. routerSite: '',
  47. }
  48. },
  49. computed: {
  50. ...mapState(['color'])
  51. },
  52. methods: {
  53. ...mapActions(['setModeAsync', 'setColorAsync', 'GetButtons', 'GetFarm', 'setUserNameAsync', 'setUserTypeAsync']),
  54. init() {
  55. let params = {
  56. id: localStorage.getItem('gold_UserId'),
  57. }
  58. findOne(params).then(res => {
  59. if(res.code === 10000) {
  60. console.log(res);
  61. this.setModeAsync(res.data.mode);
  62. this.setColorAsync(res.data.color);
  63. this.setUserNameAsync(res.data.userName)
  64. this.setUserTypeAsync(res.data.type)
  65. }
  66. })
  67. },
  68. setRouterName(data) {
  69. this.routerName = data.name;
  70. this.routerSite = data.router;
  71. },
  72. refresh() {
  73. location.reload();
  74. }
  75. },
  76. mounted() {
  77. this.routerName = this.$route.meta.title;
  78. this.routerSite = this.$route.meta.permission;
  79. console.log(this.routerSite)
  80. this.GetButtons();
  81. this.GetFarm();
  82. this.init();
  83. }
  84. }
  85. </script>
  86. <style scoped>
  87. /deep/.el-header{
  88. padding: 0;
  89. margin: 0;
  90. }
  91. /deep/.el-main {
  92. padding: 0;
  93. margin: 0;
  94. }
  95. .box_header {
  96. box-sizing: border-box;
  97. width: 100%;
  98. height: 50px;
  99. line-height: 50px;
  100. border-bottom: 1px solid #ddd;
  101. background-color: #F3F3F3;
  102. padding: 0 20px;
  103. }
  104. .line {
  105. width: 5px;
  106. height: 18px;
  107. float: left;
  108. margin-top: 16px;
  109. }
  110. .button-right {
  111. float: right;
  112. }
  113. .operant {
  114. width: 100%;
  115. height: calc(100vh - 120px);
  116. overflow-y: auto;
  117. background-color: #F9F9F9;
  118. }
  119. .operant::-webkit-scrollbar {
  120. width: 6px;
  121. height: 6px;
  122. }
  123. .operant::-webkit-scrollbar-track {
  124. -webkit-box-shadow: inset 0 0 3px rgba(0,0,0,0.2);
  125. -webkit-border-radius: 6px;
  126. border-radius: 6px;
  127. }
  128. .operant::-webkit-scrollbar-thumb {
  129. -webkit-border-radius: 6px;
  130. border-radius: 6px;
  131. background: rgba(153,153,153,0.4);
  132. -webkit-box-shadow: inset 0 0 3px rgba(0,0,0,0.3);
  133. }
  134. </style>