Home.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. <template>
  2. <el-row class="container">
  3. <el-col :span="24" class="header">
  4. <el-col :span="10" class="logo" :class="collapsed?'logo-collapse-width':'logo-width'">
  5. {{collapsed?'':sysName}}
  6. </el-col>
  7. <el-col :span="10">
  8. <div class="tools" @click.prevent="collapse">
  9. <i class="fa fa-align-justify"></i>
  10. </div>
  11. </el-col>
  12. <el-col :span="4" class="userinfo">
  13. <el-dropdown trigger="hover">
  14. <span class="el-dropdown-link userinfo-inner"><img :src="this.sysUserAvatar" /> {{sysUserName}}</span>
  15. <el-dropdown-menu slot="dropdown">
  16. <el-dropdown-item>修改密码</el-dropdown-item>
  17. <el-dropdown-item divided @click.native="logout">退出登录</el-dropdown-item>
  18. </el-dropdown-menu>
  19. </el-dropdown>
  20. </el-col>
  21. </el-col>
  22. <el-col :span="24" class="main">
  23. <aside :class="collapsed?'menu-collapsed':'menu-expanded'">
  24. <!--导航菜单-->
  25. <el-menu :default-active="$route.path" class="el-menu-vertical-demo" @open="handleopen" @close="handleclose" @select="handleselect" unique-opened router v-if="!collapsed">
  26. <template v-for="(item,index) in $router.options.routes" v-if="!item.hidden">
  27. <el-submenu :index="index+''" v-if="!item.leaf">
  28. <template slot="title"><i :class="item.iconCls"></i><span class="itemName">{{item.name}}</span></template>
  29. <el-menu-item v-for="child in item.children" :index="child.path" :key="child.path" v-if="!child.hidden">{{child.name}}</el-menu-item>
  30. </el-submenu>
  31. <el-menu-item v-if="item.leaf&&item.children.length>0" :index="item.children[0].path"><i :class="item.iconCls"></i>{{item.children[0].name}}</el-menu-item>
  32. </template>
  33. </el-menu>
  34. <!--导航菜单-折叠后-->
  35. <ul class="el-menu el-menu-vertical-demo collapsed" v-if="collapsed" ref="menuCollapsed">
  36. <li v-for="(item,index) in $router.options.routes" v-if="!item.hidden" class="el-submenu item" :style="{overflow:!item.leaf?'':'hidden'}">
  37. <template v-if="!item.leaf">
  38. <div class="el-submenu__title" style="padding-left: 20px;" @mouseover="showMenu(index,true)" @mouseout="showMenu(index,false)"><i :class="item.iconCls"></i></div>
  39. <ul class="el-menu submenu" :class="'submenu-hook-'+index" @mouseover="showMenu(index,true)" @mouseout="showMenu(index,false)">
  40. <li v-for="child in item.children" v-if="!child.hidden" :key="child.path" class="el-menu-item" style="padding-left: 40px;" :class="$route.path==child.path?'is-active':''" @click="$router.push(child.path)">{{child.name}}</li>
  41. </ul>
  42. </template>
  43. <template v-else>
  44. <li class="el-submenu">
  45. <div class="el-submenu__title el-menu-item" style="padding-left: 20px;height: 56px;line-height: 56px;padding: 0 20px;" :class="$route.path==item.children[0].path?'is-active':''" @click="$router.push(item.children[0].path)"><i :class="item.iconCls"></i></div>
  46. </li>
  47. </template>
  48. </li>
  49. </ul>
  50. </aside>
  51. <section class="content-container">
  52. <div class="grid-content bg-purple-light">
  53. <!-- <el-col :span="24" class="breadcrumb-container">
  54. <strong class="title">{{$route.name}}</strong>
  55. <el-breadcrumb separator="/" class="breadcrumb-inner">
  56. <el-breadcrumb-item v-for="item in $route.matched" :key="item.path">
  57. {{ item.name }}
  58. </el-breadcrumb-item>
  59. </el-breadcrumb>
  60. </el-col> -->
  61. <el-col :span="24" class="content-wrapper">
  62. <transition name="fade" mode="out-in">
  63. <router-view></router-view></router-view>
  64. </transition>
  65. </el-col>
  66. </div>
  67. </section>
  68. </el-col>
  69. </el-row>
  70. </template>
  71. <script>
  72. export default {
  73. data() {
  74. return {
  75. sysName:'云塑网后台管理系统',
  76. collapsed:false,
  77. sysUserName: '',
  78. sysUserAvatar: '',
  79. form: {
  80. name: '',
  81. region: '',
  82. date1: '',
  83. date2: '',
  84. delivery: false,
  85. type: [],
  86. resource: '',
  87. desc: ''
  88. }
  89. }
  90. },
  91. methods: {
  92. onSubmit() {
  93. console.log('submit!');
  94. },
  95. handleopen() {
  96. //console.log('handleopen');
  97. },
  98. handleclose() {
  99. //console.log('handleclose');
  100. },
  101. handleselect: function (a, b) {
  102. },
  103. //退出登录
  104. logout: function () {
  105. var _this = this;
  106. this.$confirm('确认退出吗?', '提示', {
  107. //type: 'warning'
  108. }).then(() => {
  109. sessionStorage.removeItem('user');
  110. _this.$router.push('/login');
  111. }).catch(() => {
  112. });
  113. },
  114. //折叠导航栏
  115. collapse:function(){
  116. this.collapsed=!this.collapsed;
  117. },
  118. showMenu(i,status){
  119. this.$refs.menuCollapsed.getElementsByClassName('submenu-hook-'+i)[0].style.display=status?'block':'none';
  120. }
  121. },
  122. mounted() {
  123. var user = sessionStorage.getItem('user');
  124. if (user) {
  125. user = JSON.parse(user);
  126. this.sysUserName = user.name || '';
  127. this.sysUserAvatar = user.avatar || '';
  128. }
  129. }
  130. }
  131. </script>
  132. <style scoped lang="scss">
  133. @import '~scss_vars';
  134. .el-menu-vertical-demo i {
  135. margin-right: 10px;
  136. }
  137. .container {
  138. position: absolute;
  139. top: 0px;
  140. bottom: 0px;
  141. width: 100%;
  142. .header {
  143. height: 60px;
  144. line-height: 60px;
  145. background: $color-primary;
  146. color:#fff;
  147. .userinfo {
  148. text-align: right;
  149. padding-right: 35px;
  150. float: right;
  151. .userinfo-inner {
  152. cursor: pointer;
  153. color:#fff;
  154. img {
  155. width: 40px;
  156. height: 40px;
  157. border-radius: 20px;
  158. margin: 10px 10px 10px 10px;
  159. // float: right;
  160. float: left;
  161. }
  162. }
  163. }
  164. .logo {
  165. //width:230px;
  166. height:60px;
  167. font-size: 21px;
  168. padding-left:20px;
  169. padding-right:20px;
  170. border-color: rgba(238,241,146,0.3);
  171. border-right-width: 1px;
  172. border-right-style: solid;
  173. img {
  174. width: 40px;
  175. float: left;
  176. margin: 10px 10px 10px 18px;
  177. }
  178. .txt {
  179. color:#fff;
  180. }
  181. }
  182. .logo-width{
  183. width:230px;
  184. }
  185. .logo-collapse-width{
  186. width:60px
  187. }
  188. .tools{
  189. padding: 0px 23px;
  190. width:14px;
  191. height: 60px;
  192. line-height: 60px;
  193. cursor: pointer;
  194. }
  195. }
  196. .main {
  197. display: flex;
  198. // background: #324057;
  199. position: absolute;
  200. top: 60px;
  201. bottom: 0px;
  202. overflow: hidden;
  203. aside {
  204. flex:0 0 230px;
  205. width: 230px;
  206. // position: absolute;
  207. // top: 0px;
  208. // bottom: 0px;
  209. .el-menu{
  210. height: 100%;
  211. }
  212. .collapsed{
  213. width:60px;
  214. .item{
  215. position: relative;
  216. }
  217. .submenu{
  218. position:absolute;
  219. top:0px;
  220. left:60px;
  221. z-index:99999;
  222. height:auto;
  223. display:none;
  224. }
  225. }
  226. }
  227. .menu-collapsed{
  228. flex:0 0 60px;
  229. width: 60px;
  230. }
  231. .menu-expanded{
  232. flex:0 0 230px;
  233. width: 230px;
  234. }
  235. .content-container {
  236. // background: #f8f8f8;
  237. //f1f2f7
  238. flex:1;
  239. // position: absolute;
  240. // right: 0px;
  241. // top: 0px;
  242. // bottom: 0px;
  243. // left: 230px;
  244. // overflow-y: scroll;
  245. padding: 20px;
  246. .breadcrumb-container {
  247. //margin-bottom: 15px;
  248. .title {
  249. width: 200px;
  250. float: left;
  251. color: #475669;
  252. }
  253. .breadcrumb-inner {
  254. float: right;
  255. }
  256. }
  257. .content-wrapper {
  258. background-color: #fff;
  259. box-sizing: border-box;
  260. }
  261. }
  262. }
  263. }
  264. </style>