OnlinePracticeHome.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <template>
  2. <main-layout>
  3. <Breadcrumb
  4. style="text-align: left; padding-left: 20px; height: 40px; line-height: 40px;
  5. background-color: #fafafa;"
  6. >
  7. 当前所在位置:
  8. <BreadcrumbItem>{{ locationTitle }}</BreadcrumbItem>
  9. </Breadcrumb>
  10. <div class="home">
  11. <div style="text-align: left; margin-bottom: 20px;">
  12. 选择考试批次:
  13. <Select
  14. v-model="examId"
  15. style="width:200px"
  16. filterable
  17. @on-change="fetchList"
  18. >
  19. <Option
  20. v-for="item in examList"
  21. :key="item.id"
  22. :value="item.id"
  23. :label="item.name"
  24. >
  25. </Option>
  26. </Select>
  27. </div>
  28. <OnlinePracticeList
  29. :courses="courses"
  30. :exam-list="examList"
  31. ></OnlinePracticeList>
  32. </div>
  33. </main-layout>
  34. </template>
  35. <script>
  36. import OnlinePracticeList from "./OnlinePracticeList.vue";
  37. import { mapState as globalMapState } from "vuex";
  38. export default {
  39. name: "OnlinePracticeHome",
  40. components: {
  41. OnlinePracticeList,
  42. },
  43. data() {
  44. return {
  45. examId: null,
  46. examList: [],
  47. courses: [],
  48. };
  49. },
  50. computed: {
  51. ...globalMapState(["user", "menus"]),
  52. locationTitle() {
  53. return (
  54. this.menus.find(
  55. v => v.link.toUpperCase() === this.$route.path.toUpperCase()
  56. ) || {}
  57. ).name;
  58. },
  59. },
  60. async mounted() {
  61. window._hmt.push(["_trackEvent", "在线练习列表页面", "进入页面"]);
  62. this.logger({ page: "在线练习列表页面", action: "进入页面" });
  63. if (this.$route.query.examId) {
  64. this.examId = this.$route.query.examId - 0;
  65. try {
  66. await this.fetchList(this.examId);
  67. } catch (error) {
  68. return;
  69. }
  70. }
  71. try {
  72. const res = await this.$http.get(
  73. "/api/ecs_exam_work/exam/queryByNameLike?name=&examTypes=PRACTICE&studentId=" +
  74. this.user.id
  75. );
  76. this.examList = (res.data || []).filter(e => e.enable);
  77. if (this.$route.query.examId === undefined && this.examList[0]) {
  78. const examId = this.examList[0].id;
  79. // this.$router.replace({ query: { examId } });
  80. this.examId = examId;
  81. try {
  82. await this.fetchList(this.examId);
  83. } catch (error) {
  84. return;
  85. }
  86. }
  87. } catch (error) {
  88. this.$Message.error({
  89. content: "查询练习列表失败!",
  90. duration: 15,
  91. closable: true,
  92. });
  93. }
  94. },
  95. methods: {
  96. async fetchList(examId) {
  97. this.$router.replace({ query: { examId } });
  98. try {
  99. const res = await this.$http.get(
  100. "/api/ecs_oe_admin/practice/queryPracticeCourseList?examId=" + examId
  101. );
  102. this.courses = res.data;
  103. } catch (error) {
  104. this.$Message.error({
  105. content: "获取课程列表失败",
  106. duration: 15,
  107. closable: true,
  108. });
  109. }
  110. },
  111. },
  112. };
  113. </script>
  114. <style scoped>
  115. .home {
  116. margin: 20px;
  117. }
  118. </style>