StudentCourseSlides.vue 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <template>
  2. <tab-side-component>
  3. <back-title>{{course.name}}</back-title>
  4. <div class="sub-title">课件列表</div>
  5. <div class="no-content-warning" v-if="slides === null">
  6. <div class="no-content-warning-tip">加载中...</div>
  7. </div>
  8. <div class="no-content-warning" v-else-if="slides.length === 0">
  9. <div class="no-content-warning-tip">本课程尚无课件~</div>
  10. </div>
  11. <template v-for="slide of slides">
  12. <slide-card :key="slide.id" :slide="slide" :click-handler="handleSlideCardClick"></slide-card>
  13. </template>
  14. <c-button class="full-width secondary mt-16" @click="handleToManager">管理课程</c-button>
  15. </tab-side-component>
  16. </template>
  17. <script>
  18. import TabSideComponent from '@/components/TabSideComponent'
  19. import BackTitle from '@/components/BackTitle'
  20. import SlideCard from '@/components/SlideCard'
  21. import CButton from '@/components/CButton'
  22. import { studentGetSlidesByCourse } from '@/server/slide'
  23. import { SET_SLIDE_INFO } from '@/store/types/pdf-types'
  24. import { SET_COURSE } from '@/store/types/main-types'
  25. import { mapState } from 'vuex'
  26. export default {
  27. components: { CButton, SlideCard, BackTitle, TabSideComponent },
  28. data () {
  29. return {
  30. slides: null
  31. }
  32. },
  33. watch: {
  34. $route () {
  35. this.init()
  36. }
  37. },
  38. computed: {
  39. ...mapState({
  40. course: state => state.main.courseInfo
  41. })
  42. },
  43. mounted () {
  44. this.init()
  45. },
  46. methods: {
  47. init () {
  48. studentGetSlidesByCourse({ courseId: this.course.id, size: 100, sort: 'name' }).then(res => {
  49. this.slides = res.data
  50. }).catch(err => {
  51. this.$setErrorMessage('获取课程课件列表过程中:' + err.response.data.msg)
  52. })
  53. },
  54. handleSlideCardClick (slide) {
  55. this.$store.commit(SET_SLIDE_INFO, { slideInfo: slide })
  56. this.$router.push({ name: 'student-explore-slide-detail', params: { slideId: slide.id } })
  57. },
  58. handleToManager () {
  59. this.$store.commit(SET_COURSE, { courseInfo: this.course })
  60. this.$router.push({ name: 'student-course-detail', params: { courseId: this.course.id } })
  61. }
  62. }
  63. }
  64. </script>
  65. <style lang="scss" scoped>
  66. .c-input {
  67. margin-bottom: 24px;
  68. }
  69. .no-content-warning {
  70. height: unset;
  71. }
  72. </style>