Home.vue 4.0 KB

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