index.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <template>
  2. <div id="index">
  3. <el-row>
  4. <el-col :span="24" class="style">
  5. <el-col :span="24" class="top">
  6. <NavBar v-show="navShow" :title="title" :isleftarrow="isleftarrow"> </NavBar>
  7. </el-col>
  8. <el-col :span="24" class="main">
  9. <el-col :span="24" class="message">
  10. <messageInfo :info="info" :teainfo="teainfo"></messageInfo>
  11. </el-col>
  12. <el-col :span="24" class="clickBtn">
  13. <clickBtn></clickBtn>
  14. </el-col>
  15. </el-col>
  16. <el-col :span="24" class="foot">
  17. <footInfo></footInfo>
  18. </el-col>
  19. </el-col>
  20. </el-row>
  21. </div>
  22. </template>
  23. <script>
  24. import NavBar from '@/layout/common/topInfo.vue';
  25. import footInfo from '@/layout/common/footInfo.vue';
  26. import messageInfo from '@/layout/user/messageInfo.vue';
  27. import clickBtn from '@/layout/user/clickBtn.vue';
  28. import { mapState, createNamespacedHelpers, mapGetters } from 'vuex';
  29. const { mapActions: mapDirectors } = createNamespacedHelpers('director');
  30. const { mapActions: mapStudent } = createNamespacedHelpers('student');
  31. const { mapActions: mapDept } = createNamespacedHelpers('dept');
  32. export default {
  33. name: 'index',
  34. props: {},
  35. components: {
  36. NavBar, //头部导航
  37. footInfo, //底部导航
  38. messageInfo, //个人信息
  39. clickBtn, //功能按钮
  40. },
  41. data: () => ({
  42. info: {},
  43. teainfo: {},
  44. title: '',
  45. isleftarrow: '',
  46. navShow: true,
  47. }),
  48. created() {
  49. this.searchSite();
  50. },
  51. computed: {
  52. ...mapState(['user']),
  53. },
  54. mounted() {
  55. this.title = this.$route.meta.title;
  56. this.isleftarrow = this.$route.meta.isleftarrow;
  57. },
  58. watch: {
  59. $route(to, from) {
  60. this.title = to.meta.title;
  61. this.isleftarrow = to.meta.isleftarrow;
  62. },
  63. },
  64. methods: {
  65. ...mapDirectors({ directorQuery: 'query', directorFetch: 'fetch' }),
  66. ...mapStudent({ studentQuery: 'query', studentFetch: 'fetch' }),
  67. ...mapDept({ deptFetch: 'fetch' }),
  68. // 查询登录用户信息
  69. async searchSite() {
  70. // 1:班主任,4:学生
  71. if (this.user.type === '1') {
  72. const res = await this.directorFetch(this.user.userid);
  73. const arr = await this.deptFetch(res.data.department);
  74. res.data.department = arr.data.name;
  75. this.$set(this, `teainfo`, res.data);
  76. } else if (this.user.type === '4') {
  77. const res = await this.studentFetch(this.user.userid);
  78. this.$set(this, `info`, res.data);
  79. }
  80. },
  81. },
  82. };
  83. </script>
  84. <style lang="less" scoped>
  85. .style {
  86. width: 100%;
  87. min-height: 667px;
  88. position: relative;
  89. background-color: #f9fafc;
  90. }
  91. .top {
  92. height: 46px;
  93. overflow: hidden;
  94. }
  95. .main {
  96. min-height: 570px;
  97. }
  98. .foot {
  99. height: 50px;
  100. overflow: hidden;
  101. }
  102. </style>