Home.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <style lang="scss">
  2. @import '../style/home.scss';
  3. .siteTitle {
  4. font-size: 20px;
  5. font-weight: 400;
  6. position: relative;
  7. &::before{
  8. content: '|';
  9. position: absolute;
  10. left:-20px;
  11. font-size: 14px;
  12. color: #D2D2D2;
  13. }
  14. }
  15. </style>
  16. <template>
  17. <el-container>
  18. <el-header>
  19. <div class="header">
  20. <span class="logout" @click="logout">退出登陆</span>
  21. <el-dropdown class="logout" v-if='info.name' style="margin-right:10px;">
  22. <span class="el-dropdown-link" style="color:#fff;font-size:16px;">
  23. {{info.name}}<i class="el-icon-arrow-down el-icon--right"></i>
  24. </span>
  25. <el-dropdown-menu slot="dropdown">
  26. <el-dropdown-item @click.native="changePsw">修改密码</el-dropdown-item>
  27. </el-dropdown-menu>
  28. </el-dropdown>
  29. <!-- <img width="128" src="../assets/logo.png" alt=""> -->
  30. <div class="siteTitle">云阅评管理系统</div>
  31. </div>
  32. </el-header>
  33. <el-container class="main">
  34. <!-- 左侧菜单 -->
  35. <el-aside class="left-aside" width="210px">
  36. <el-menu :unique-opened='false'
  37. :default-active="0" router class="left-menue"
  38. active-text-color="#FA0A2F">
  39. <template v-for="(item, index) in $router.options.routes">
  40. <el-menu-item v-if='item.show&&item.isLeaf' :index="item.path" :key='index'>
  41. <i :class="item.icon"></i>
  42. <span slot="title">{{item.name}}</span>
  43. </el-menu-item>
  44. <el-submenu v-if='item.show&&!item.isLeaf' :index="'index_'+index" :key='index'>
  45. <template slot="title">
  46. <i :class="item.icon"></i>
  47. <span>{{item.name}}</span>
  48. </template>
  49. <el-menu-item-group>
  50. <el-menu-item class="child" v-for="(child,idx) in item.children" :key="index+'_'+idx"
  51. :index="child.path" v-show='!child.hide'>
  52. {{child.name}}
  53. </el-menu-item>
  54. </el-menu-item-group>
  55. </el-submenu>
  56. </template>
  57. </el-menu>
  58. </el-aside>
  59. <!-- 右侧内容 -->
  60. <el-container>
  61. <el-main>
  62. <transition name="fade" mode="out-in">
  63. <router-view></router-view>
  64. </transition>
  65. </el-main>
  66. <!-- <el-footer>Footer</el-footer> -->
  67. </el-container>
  68. </el-container>
  69. <el-dialog title="修改密码" :visible.sync="open" width="500px" append-to-body>
  70. <el-form ref="form" :model="form" label-width="80px">
  71. <!-- <el-form-item label="旧密码">
  72. <el-input clearable v-model="form.password" placeholder=""></el-input>
  73. </el-form-item> -->
  74. <el-form-item label="新密码">
  75. <el-input type="password" v-model="form.password" placeholder=""></el-input>
  76. </el-form-item>
  77. <el-form-item label="确认密码">
  78. <el-input type="password" v-model="form.repassword" placeholder=""></el-input>
  79. </el-form-item>
  80. </el-form>
  81. <div slot="footer" class="dialog-footer">
  82. <el-button type="primary" @click="submitForm">确 定</el-button>
  83. <el-button @click="open=false">取 消</el-button>
  84. </div>
  85. </el-dialog>
  86. </el-container>
  87. </template>
  88. <script>
  89. import Router from 'vue-router'
  90. export default {
  91. name: 'home',
  92. data() {
  93. return {
  94. info: {},
  95. open: false,
  96. form: {}
  97. };
  98. },
  99. methods: {
  100. changePsw() {
  101. this.open = true;
  102. },
  103. submitForm() {
  104. if (!this.form.password) {
  105. this.msgError('请输入新密码');
  106. return
  107. }
  108. if (!this.form.repassword) {
  109. this.msgError('请确认密码');
  110. return
  111. }
  112. this.$api.reset(this.form).then(res => {
  113. if (res.data.code == 0) {
  114. this.$router.push({
  115. path: '/'
  116. })
  117. } else {
  118. this.msgError(res.data.message);
  119. }
  120. })
  121. },
  122. logout() {
  123. this.$api.logout().then(res => {
  124. // this.$router.push({path:'/login'})
  125. this.$router.push({
  126. path: '/admin'
  127. })
  128. })
  129. },
  130. // permission(name){
  131. // let permissions=this.info.permissions||[];
  132. // let list=[];
  133. // for(let i=0;i<permissions.length;i++){
  134. // list.push(permissions[i].name)
  135. // }
  136. // if(list.indexOf(name)<0){
  137. // return false;
  138. // }else{
  139. // return true;
  140. // }
  141. // },
  142. getData() {
  143. this.$api.getAccountInfo().then(res => {
  144. if (!res.code) {
  145. this.info = res.data.data
  146. }
  147. })
  148. },
  149. },
  150. created() {
  151. this.getData()
  152. }
  153. };
  154. </script>