index.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <template>
  2. <div id="index">
  3. <el-row>
  4. <el-col :span="24" class="style">
  5. <el-col :span="24" class="top">
  6. <nav-bar v-show="navShow" :title="title" :isleftarrow="isleftarrow"> </nav-bar>
  7. </el-col>
  8. <el-col :span="24" class="main">
  9. <span v-if="this.user.type === '1'">
  10. <teaClass :classList="classList"></teaClass>
  11. </span>
  12. <span v-else>
  13. <questionnaire-info :questionnaireList="questionnaireList"></questionnaire-info>
  14. </span>
  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 teaClass from '@/layout/question/teaClass.vue';
  27. import questionnaireInfo from '@question/src/views/index.vue';
  28. import { mapState, createNamespacedHelpers } from 'vuex';
  29. const { mapActions: termquest } = createNamespacedHelpers('termquest');
  30. const { mapActions: questionnaire } = createNamespacedHelpers('questionnaire');
  31. const { mapActions: mapClass } = createNamespacedHelpers('classes');
  32. const { mapActions: mapStudent } = createNamespacedHelpers('student');
  33. export default {
  34. name: 'index',
  35. props: {},
  36. components: {
  37. NavBar, //头部导航
  38. footInfo, //底部导航
  39. questionnaireInfo, //问卷调查
  40. teaClass, //班主任班级名单
  41. },
  42. data: () => ({
  43. questionnaireList: [],
  44. classList: [],
  45. title: '',
  46. isleftarrow: '',
  47. navShow: true,
  48. }),
  49. created() {
  50. this.search();
  51. this.searchInfo();
  52. },
  53. computed: {
  54. ...mapState(['user']),
  55. },
  56. mounted() {
  57. this.title = this.$route.meta.title;
  58. this.isleftarrow = this.$route.meta.isleftarrow;
  59. },
  60. watch: {
  61. $route(to, from) {
  62. this.title = to.meta.title;
  63. this.isleftarrow = to.meta.isleftarrow;
  64. },
  65. },
  66. methods: {
  67. ...termquest(['query']),
  68. ...questionnaire({ getQuestList: 'query', getQuestMerge: 'mergeRequest' }),
  69. ...mapClass({ classinfo: 'query' }),
  70. ...mapStudent({ stuQuery: 'query', stuFetch: 'fetch' }),
  71. // 查询问卷调查列表
  72. async search() {
  73. let res = await this.query({ termid: this.user.termid });
  74. if (this.$checkRes(res)) {
  75. let ids = _.flattenDeep(res.data.map(i => i.questionnaireid));
  76. let quest = await this.getQuestMerge({ method: 'fetch', data: ids });
  77. this.$set(this, `questionnaireList`, quest);
  78. }
  79. },
  80. // 班主任查询管理班级列表
  81. async searchInfo({ ...info } = {}) {
  82. const res = await this.classinfo({ ...info });
  83. var result = res.data.filter(item => item.headteacherid === this.user.userid);
  84. this.$set(this, `classList`, result);
  85. },
  86. },
  87. };
  88. </script>
  89. <style lang="less" scoped>
  90. .style {
  91. width: 100%;
  92. min-height: 667px;
  93. position: relative;
  94. background-color: #f9fafc;
  95. }
  96. .top {
  97. height: 46px;
  98. overflow: hidden;
  99. position: relative;
  100. z-index: 999;
  101. }
  102. .main {
  103. min-height: 570px;
  104. margin: 0 0 50px 0;
  105. }
  106. </style>