index.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <template>
  2. <div class="page">
  3. <el-header>
  4. <p-header :username="getUserName" @collapse="collapsed"></p-header>
  5. </el-header>
  6. <el-container style="height: 100%">
  7. <el-aside>
  8. <p-menu :data="getMenus"></p-menu>
  9. </el-aside>
  10. <el-container style="background-color: #E8E8E8">
  11. <el-main style="height: 100%">
  12. <div class="tab">
  13. <p-tabs :list="getTabList"></p-tabs>
  14. </div>
  15. <div class="views" :style="vieWidth">
  16. <transition name="el-fade-in">
  17. <keep-alive>
  18. <router-view v-if="$route.meta.keepAlive" />
  19. </keep-alive>
  20. </transition>
  21. <transition name="el-fade-in">
  22. <router-view v-if="!$route.meta.keepAlive" />
  23. </transition>
  24. </div>
  25. </el-main>
  26. </el-container>
  27. </el-container>
  28. </div>
  29. </template>
  30. <script>
  31. export default {
  32. data() {
  33. return {
  34. vieWidth: {
  35. width: "calc(100vw - 210px)",
  36. },
  37. };
  38. },
  39. mounted() {
  40. if (this.getMenus == undefined || this.$isEmptyJSON(this.getMenus)) {
  41. let token = window.sessionStorage.agileauthtoken;
  42. if (token != "undefined") {
  43. if (!window.sessionStorage.menus) {
  44. this.$notify.error({
  45. title: "提示",
  46. message: "登录超时",
  47. });
  48. this.$router.push("/login");
  49. return;
  50. }
  51. let menuList = JSON.parse(sessionStorage.menus);
  52. this.$store.commit("setMenus", menuList);
  53. this.$store.commit(
  54. "setUserInfo",
  55. JSON.parse(this.$cookie.get("userInfo"))
  56. );
  57. } else {
  58. this.$notify.error({
  59. title: "提示",
  60. message: "登录超时",
  61. });
  62. this.$router.push("/login");
  63. return;
  64. }
  65. }
  66. if (this.getMenus instanceof Array && this.getMenus.length == 0) {
  67. this.$notify.error({
  68. message: "当前用户无权限,请联系超管分配权限",
  69. });
  70. this.$router.push("/login");
  71. return;
  72. }
  73. },
  74. computed: {
  75. getTabList() {
  76. return this.$store.state.tabList;
  77. },
  78. getUserName() {
  79. let userInfo = JSON.parse(sessionStorage.getItem("userInfo"));
  80. return userInfo.loginName;
  81. // if (this.$store.state.userInfo || userInfo) {
  82. // return this.$store.state.userInfo
  83. // ? this.$store.state.userInfo.loginName
  84. // : userInfo.loginName;
  85. // } else {
  86. // return "";
  87. // }
  88. },
  89. getMenus() {
  90. return this.$store.state.menus;
  91. },
  92. getCacheList() {
  93. return this.$store.state.pages;
  94. },
  95. collapse() {
  96. return this.$store.state.collapse;
  97. },
  98. },
  99. methods: {
  100. collapsed() {
  101. if (this.collapse) {
  102. this.vieWidth.width = "calc(100vw - 74px)";
  103. } else {
  104. this.vieWidth.width = "calc(100vw - 210px)";
  105. }
  106. },
  107. },
  108. };
  109. </script>
  110. <style scoped="scoped" lang="scss">
  111. .el-aside {
  112. width: auto !important;
  113. }
  114. .views {
  115. height: calc(100% - 97px);
  116. div{
  117. border-radius: 5px;
  118. }
  119. }
  120. .el-main {
  121. padding: 0px !important;
  122. }
  123. // ::v-deep .font-ui {
  124. // display: inline-block;
  125. // font-weight: bold;
  126. // color: #8eb7e4;
  127. // text-shadow: 0 0 1px currentColor, -1px -1px 1px #000, 0 -1px 1px #000,
  128. // 1px -1px 1px #000, 1px 0 1px #000, 1px 1px 1px #000, 0 1px 1px #000,
  129. // -1px 1px 1px #000, -1px 0 1px #000;
  130. // -webkit-filter: url(#diff1);
  131. // filter: url(#diff1); /*background:#def;padding:0 .2em*/
  132. // font-size: 20px;
  133. // }
  134. </style>