video_course.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <template>
  2. <div :class="{'video_contianer':!nestedMode}">
  3. <el-card>
  4. <mx-condition ref="condition" :query-params="queryParams" :require-fields="requireFields" @query="handleQuery"
  5. @invalid="handleInvalidQuery"></mx-condition>
  6. </el-card>
  7. <!-- 视频主体 -->
  8. <el-card class="video_content" v-if="videoList.length > 0">
  9. <div slot="header">
  10. <mx-search-group justify="end" :span="6" v-model="sectionName" placeholder="请输入搜索内容" @search="searchVideo">
  11. <el-col v-if="isFrontTeacher" :span="18" style="margin-bottom: 0"><span class="f-warning">*收藏后方可发布作业</span>
  12. </el-col>
  13. </mx-search-group>
  14. </div>
  15. <el-row :gutter="20">
  16. <el-col :span="6" class="video_item" v-for="item in videoList" :key="item.id">
  17. <img :src="item.img" alt="" @click="
  18. toVideoDetail(
  19. item.pack_id,
  20. item.chapter_id,
  21. item.id,
  22. item.section_aliId,
  23. item.aliIdType
  24. )
  25. "
  26. />
  27. <p class="fx-row jc-between ai-center">
  28. <span class="text-ellipsis"> {{ item.section_name }} </span>
  29. <!-- 老师才能收藏 -->
  30. <span v-if="role" @click="toCollect(item)" class="pointer iconfont icon-shoucang"
  31. :class="{'f-primary':item.isCollect}"></span>
  32. </p>
  33. </el-col>
  34. </el-row>
  35. <!-- 分页 -->
  36. <div class="split_page">
  37. <pagination v-show="total > 0" :total="total" :page.sync="pageForm.pageNum" :limit.sync="pageForm.pageSize"
  38. :pageSizes="[16,32]" @pagination="getVideoList"/>
  39. </div>
  40. </el-card>
  41. <evaluation-empty v-if="videoList.length == 0"/>
  42. </div>
  43. </template>
  44. <script>
  45. import { collectVideoCourse, videoList } from '@/api/webApi/webVideo'
  46. import MxSearchGroup from '@/components/MxSearch/mx-search-group'
  47. import MxCondition from '@/components/MxCondition/mx-condition'
  48. import { checkRole } from '@/utils/permission'
  49. import { mapGetters } from 'vuex'
  50. export default {
  51. name: 'video-course',
  52. components: { MxSearchGroup, MxCondition },
  53. props: { 'nestedMode': { type: Boolean, default: false } },
  54. data() {
  55. return {
  56. pageForm: {
  57. pageNum: 1,
  58. pageSize: 16
  59. },
  60. role: checkRole(['frontTeacher', 'frontHeadteacher']),
  61. sectionName: '',
  62. queryParams: {
  63. videoType: '',
  64. videoCourse: '',
  65. videoGrade: '',
  66. videoVersion: '',
  67. videoPack: ''
  68. },
  69. requireFields: [
  70. 'videoType',
  71. 'videoCourse',
  72. 'videoGrade',
  73. 'videoVersion',
  74. 'videoPack'
  75. ],
  76. total: 0,
  77. packNewList: [],
  78. videoList: [] // 视频列表
  79. }
  80. },
  81. computed: {
  82. ...mapGetters(['isFrontTeacher'])
  83. },
  84. methods: {
  85. handleInvalidQuery() {
  86. },
  87. toVideoDetail(id, chapter_id, childrenId, section_aliId, aliIdType) {
  88. this.$router.push({
  89. path: '/video_course/detail', query: {
  90. packId: id,
  91. chapter_id: chapter_id,
  92. childrenId: childrenId,
  93. section_aliId,
  94. aliIdType: aliIdType
  95. }
  96. })
  97. },
  98. handleQuery() {
  99. this.getVideoList()
  100. },
  101. searchVideo() {
  102. this.getVideoList()
  103. },
  104. toCollect(item) {
  105. collectVideoCourse({
  106. isCollect: !item.isCollect,
  107. id: item.id
  108. }).then(res => {
  109. item.isCollect = !item.isCollect
  110. }).catch(_ => {
  111. })
  112. },
  113. // 获取视频列表
  114. getVideoList() {
  115. videoList({
  116. course: this.queryParams.videoCourse, // 科目
  117. subject: this.queryParams.videoType, // 大类
  118. grade: this.queryParams.videoGrade, // 年级
  119. version: this.queryParams.videoVersion, // 版本
  120. pack: this.queryParams.videoPack,
  121. ...this.pageForm,
  122. sectionName: this.sectionName
  123. }).then((res) => {
  124. this.total = res.total
  125. this.videoList = res.rows
  126. })
  127. }
  128. }
  129. }
  130. </script>
  131. <style scoped>
  132. .el-card {
  133. margin-bottom: 32px;
  134. }
  135. .video_contianer {
  136. padding: 20px;
  137. }
  138. .video_item > img {
  139. cursor: pointer;
  140. }
  141. .video_content .el-col {
  142. margin-bottom: 42px;
  143. }
  144. .video_item {
  145. border-radius: 4px;
  146. }
  147. .video_item > img {
  148. width: 100%;
  149. }
  150. .video_item > p {
  151. padding: 5px 10px;
  152. box-shadow: 0px 1px 4px 0px rgba(47, 78, 154, 0.14);
  153. }
  154. </style>