Home.vue 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  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="../assets/image/userHead.jpg" /> {{sysUserName}}</span>
  15. <el-dropdown-menu slot="dropdown">
  16. <el-dropdown-item @click.native="reset">修改密码</el-dropdown-item>
  17. <el-dropdown-item divided @click.native="logout">退出登录</el-dropdown-item>
  18. </el-dropdown-menu>
  19. </el-dropdown>
  20. <el-badge is-dot class="itemNew">
  21. <i class="el-icon-message-solid" style="font-size:24px"></i>
  22. </el-badge>
  23. </el-col>
  24. </el-col>
  25. <el-col :span="24" class="main">
  26. <aside :class="collapsed?'menu-collapsed':'menu-expanded'">
  27. <!--导航菜单-->
  28. <el-menu :default-active="$route.path" class="el-menu-vertical-demo" @open="handleopen" @close="handleclose" @select="handleselect" unique-opened router v-if="!collapsed">
  29. <template v-for="(item,index) in $router.options.routes" v-if="!item.hidden">
  30. <el-submenu :index="index+''" v-if="!item.leaf">
  31. <template slot="title"><i :class="item.iconCls"></i><span class="itemName">{{item.name}}</span></template>
  32. <el-menu-item v-for="child in item.children" :index="child.path" :key="child.path" v-if="!child.hidden">{{child.name}}</el-menu-item>
  33. </el-submenu>
  34. <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>
  35. </template>
  36. </el-menu>
  37. <!--导航菜单-折叠后-->
  38. <ul class="el-menu el-menu-vertical-demo collapsed" v-if="collapsed" ref="menuCollapsed">
  39. <li v-for="(item,index) in $router.options.routes" v-if="!item.hidden" class="el-submenu item" :style="{overflow:!item.leaf?'':'hidden'}">
  40. <template v-if="!item.leaf">
  41. <div class="el-submenu__title" style="padding-left: 20px;" @mouseover="showMenu(index,true)" @mouseout="showMenu(index,false)"><i :class="item.iconCls"></i></div>
  42. <ul class="el-menu submenu" :class="'submenu-hook-'+index" @mouseover="showMenu(index,true)" @mouseout="showMenu(index,false)">
  43. <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>
  44. </ul>
  45. </template>
  46. <template v-else>
  47. <li class="el-submenu">
  48. <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>
  49. </li>
  50. </template>
  51. </li>
  52. </ul>
  53. </aside>
  54. <section class="content-container">
  55. <div class="grid-content bg-purple-light">
  56. <!-- <el-col :span="24" class="breadcrumb-container">
  57. <strong class="title">{{$route.name}}</strong>
  58. <el-breadcrumb separator="/" class="breadcrumb-inner">
  59. <el-breadcrumb-item v-for="item in $route.matched" :key="item.path">
  60. {{ item.name }}
  61. </el-breadcrumb-item>
  62. </el-breadcrumb>
  63. </el-col> -->
  64. <el-col :span="24" class="content-wrapper">
  65. <transition name="fade" mode="out-in">
  66. <router-view></router-view>
  67. </transition>
  68. </el-col>
  69. </div>
  70. <!--修改密码-->
  71. <el-dialog title="修改密码" v-if="editPassWord" :visible.sync="editPassWord" :close-on-click-modal="false" customClass='customWidth'>
  72. <el-form :model="addForm" label-width="80px" :rules="passRule" ref="addForm">
  73. <el-form-item label="新密码" prop="password">
  74. <el-input v-model="addForm.password" autocomplete="off" placeholder="请输入新密码" show-password></el-input>
  75. </el-form-item>
  76. </el-form>
  77. <div slot="footer" class="dialog-footer">
  78. <el-button @click.native="editPassWord = false">取消</el-button>
  79. <el-button type="primary" @click.native="resetPwd" :loading="editLoading">提交</el-button>
  80. </div>
  81. </el-dialog>
  82. </section>
  83. </el-col>
  84. </el-row>
  85. </template>
  86. <script>
  87. export default {
  88. data() {
  89. return {
  90. user: sessionStorage.getItem('user'),
  91. sysName:'云塑网后台管理系统',
  92. collapsed:false,
  93. sysUserName: '',
  94. editPassWord: false,
  95. editLoading: false,
  96. addForm: {
  97. password: ''
  98. },
  99. passRule: {
  100. password: [
  101. { required: true, message: '请输入新密码', trigger: 'blur' }
  102. ]
  103. }
  104. }
  105. },
  106. methods: {
  107. onSubmit() {
  108. },
  109. handleopen() {
  110. },
  111. handleclose() {
  112. },
  113. handleselect: function (a, b) {
  114. },
  115. //退出登录
  116. logout: function () {
  117. var _this = this;
  118. this.$confirm('确认退出吗?', '提示', {
  119. //type: 'warning'
  120. }).then(() => {
  121. sessionStorage.removeItem('user');
  122. _this.$router.push('/login');
  123. });
  124. },
  125. //折叠导航栏
  126. collapse:function(){
  127. this.collapsed=!this.collapsed;
  128. },
  129. showMenu(i,status){
  130. this.$refs.menuCollapsed.getElementsByClassName('submenu-hook-'+i)[0].style.display=status?'block':'none';
  131. },
  132. reset() {
  133. this.editPassWord = true;
  134. this.addForm.id = JSON.parse(sessionStorage.getItem('user')).id;
  135. this.addForm.account = JSON.parse(sessionStorage.getItem('user')).account;
  136. },
  137. resetPwd(){
  138. this.$refs.addForm.validate((valid) => {
  139. if (valid) {
  140. this.editLoading = true;
  141. this.http.post(this.port.pwd.resetPwd, this.addForm , res => {
  142. this.editLoading = false;
  143. this.editPassWord = false;
  144. if (res.code == "ok") {
  145. this.$message({
  146. message: '修改成功,请重新登录',
  147. type: 'success'
  148. });
  149. this.$router.push('/login');
  150. } else {
  151. this.$message({
  152. message: res.msg,
  153. type: 'error'
  154. });
  155. }
  156. }, error => {
  157. this.editLoading = false;
  158. this.editPassWord = false;
  159. this.$message({
  160. message: error,
  161. type: 'error'
  162. });
  163. })
  164. }
  165. });
  166. }
  167. },
  168. mounted() {
  169. if (this.user) {
  170. var user = JSON.parse(this.user);
  171. this.user = user;
  172. this.sysUserName = user.username || '';
  173. } else {
  174. this.$router.push('/login');
  175. }
  176. }
  177. }
  178. </script>
  179. <style scoped lang="scss">
  180. @import '~scss_vars';
  181. .el-menu-vertical-demo i {
  182. margin-right: 10px;
  183. }
  184. .itemNew {
  185. height: 25px;
  186. margin-left: 15px;
  187. i {
  188. vertical-align: top;
  189. }
  190. }
  191. .container {
  192. position: absolute;
  193. top: 0px;
  194. bottom: 0px;
  195. width: 100%;
  196. .header {
  197. height: 60px;
  198. line-height: 60px;
  199. background: $color-primary;
  200. color:#fff;
  201. .userinfo {
  202. text-align: right;
  203. padding-right: 35px;
  204. float: right;
  205. .userinfo-inner {
  206. cursor: pointer;
  207. color:#fff;
  208. img {
  209. width: 40px;
  210. height: 40px;
  211. border-radius: 20px;
  212. margin: 10px 10px 10px 10px;
  213. // float: right;
  214. float: left;
  215. }
  216. }
  217. }
  218. .logo {
  219. //width:230px;
  220. height:60px;
  221. font-size: 21px;
  222. padding-left:20px;
  223. padding-right:20px;
  224. border-color: rgba(238,241,146,0.3);
  225. border-right-width: 1px;
  226. border-right-style: solid;
  227. img {
  228. width: 40px;
  229. float: left;
  230. margin: 10px 10px 10px 18px;
  231. }
  232. .txt {
  233. color:#fff;
  234. }
  235. }
  236. .logo-width{
  237. width:230px;
  238. }
  239. .logo-collapse-width{
  240. width:60px
  241. }
  242. .tools{
  243. padding: 0px 23px;
  244. width:14px;
  245. height: 60px;
  246. line-height: 60px;
  247. cursor: pointer;
  248. }
  249. }
  250. .main {
  251. display: flex;
  252. // background: #324057;
  253. position: absolute;
  254. top: 60px;
  255. bottom: 0px;
  256. overflow: hidden;
  257. aside {
  258. flex:0 0 230px;
  259. width: 230px;
  260. // position: absolute;
  261. // top: 0px;
  262. // bottom: 0px;
  263. .el-menu{
  264. height: 100%;
  265. }
  266. .collapsed{
  267. width:60px;
  268. .item{
  269. position: relative;
  270. }
  271. .submenu{
  272. position:absolute;
  273. top:0px;
  274. left:60px;
  275. z-index:99999;
  276. height:auto;
  277. display:none;
  278. }
  279. }
  280. }
  281. .menu-collapsed{
  282. flex:0 0 60px;
  283. width: 60px;
  284. }
  285. .menu-expanded{
  286. flex:0 0 230px;
  287. width: 230px;
  288. }
  289. .content-container {
  290. // background: #f8f8f8;
  291. //f1f2f7
  292. flex:1;
  293. width: 80%;
  294. // position: absolute;
  295. // right: 0px;
  296. // top: 0px;
  297. // bottom: 0px;
  298. // left: 230px;
  299. // overflow-y: scroll;
  300. padding: 20px;
  301. .breadcrumb-container {
  302. //margin-bottom: 15px;
  303. .title {
  304. width: 200px;
  305. float: left;
  306. color: #475669;
  307. }
  308. .breadcrumb-inner {
  309. float: right;
  310. }
  311. }
  312. .content-wrapper {
  313. background-color: #fff;
  314. box-sizing: border-box;
  315. }
  316. }
  317. }
  318. }
  319. </style>