Relation.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. <template>
  2. <div class="course">
  3. <el-card class="box-card">
  4. <div slot="header" class="clearfix">
  5. <el-select v-model="channelValue" placeholder="请选择渠道" @change="selectChange">
  6. <el-option
  7. v-for="item in channeList.list"
  8. :key="item.id"
  9. :label="item.title"
  10. :value="item.id">
  11. </el-option>
  12. </el-select>
  13. <el-button style="float: right; padding: 3px 0" type="text" @click="add">增加</el-button>
  14. </div>
  15. <el-table
  16. :data="relationList.list"
  17. style="width: 100%"
  18. height="700">
  19. <el-table-column
  20. label="课程 CODE"
  21. prop="code">
  22. </el-table-column>
  23. <el-table-column
  24. label="课程名称"
  25. prop="title">
  26. </el-table-column>
  27. <el-table-column
  28. label="课程图片"
  29. prop="iconImg">
  30. </el-table-column>
  31. <el-table-column
  32. label="关键字"
  33. prop="keyWords">
  34. </el-table-column>
  35. <el-table-column
  36. label="短标题"
  37. prop="subTitle">
  38. </el-table-column>
  39. <el-table-column
  40. label="播放状态">
  41. <template slot-scope="scope">
  42. {{scope.row.continuity == 'CONTINUOUS' ? '连续' : '重复'}}
  43. </template>
  44. </el-table-column>
  45. <el-table-column
  46. label="模板"
  47. prop="template">
  48. </el-table-column>
  49. <el-table-column label="操作">
  50. <template slot-scope="scope">
  51. <el-button
  52. size="mini"
  53. @click="remove(scope.row)">删除</el-button>
  54. </template>
  55. </el-table-column>
  56. </el-table>
  57. <el-pagination
  58. v-if="relationList.totalSize"
  59. background
  60. layout="prev, pager, next"
  61. :total="relationList.totalSize"
  62. @current-change="changePage">
  63. </el-pagination>
  64. </el-card>
  65. <el-dialog
  66. title="增加课程"
  67. :visible.sync="dialogVisible"
  68. width="70%"
  69. center>
  70. <el-form label-position="left">
  71. <el-table
  72. :data="courseList.list"
  73. style="width: 100%"
  74. height="500">
  75. <el-table-column
  76. label="课程 CODE"
  77. prop="code">
  78. </el-table-column>
  79. <el-table-column
  80. label="课程名称"
  81. prop="title">
  82. </el-table-column>
  83. <el-table-column
  84. label="课程图片"
  85. prop="iconImg">
  86. </el-table-column>
  87. <el-table-column
  88. label="关键字"
  89. prop="keyWords">
  90. </el-table-column>
  91. <el-table-column
  92. label="短标题"
  93. prop="subTitle">
  94. </el-table-column>
  95. <el-table-column
  96. label="播放状态">
  97. <template slot-scope="scope">
  98. {{scope.row.continuity == 'CONTINUOUS' ? '连续' : '重复'}}
  99. </template>
  100. </el-table-column>
  101. <el-table-column
  102. label="模板"
  103. prop="template">
  104. </el-table-column>
  105. <el-table-column label="操作">
  106. <template slot-scope="scope">
  107. <el-button
  108. size="mini"
  109. @click="addEdit(scope.row, scope.$index)">选择</el-button>
  110. </template>
  111. </el-table-column>
  112. </el-table>
  113. <el-pagination
  114. background
  115. layout="prev, pager, next"
  116. :total="courseList.totalSize"
  117. @current-change="changePageEdit">
  118. </el-pagination>
  119. </el-form>
  120. </el-dialog>
  121. </div>
  122. </template>
  123. <script>
  124. import { mapGetters } from 'vuex';
  125. export default {
  126. data() {
  127. return {
  128. dialogVisible: false,
  129. channelValue: '',
  130. page: 1,
  131. pageEdit: 1,
  132. channelId: ''
  133. }
  134. },
  135. computed: {
  136. ...mapGetters({
  137. courseList: 'courseList',
  138. channeList: 'channeList',
  139. relationList: 'relationList'
  140. })
  141. },
  142. created () {
  143. this.$store.dispatch('getChannelList', {pageNo: '', pageSize: '' })
  144. },
  145. methods: {
  146. // 选择渠道
  147. selectChange(e) {
  148. this.channelId = e;
  149. this.$store.dispatch('getRelationList', {channelId: e, pageNo: 1, pageSize: 10 })
  150. },
  151. // 渠道增加课程
  152. add () {
  153. if (!this.channelId) {
  154. this.$message.error('请选择渠道');
  155. return false;
  156. }
  157. this.dialogVisible = true;
  158. this.$store.dispatch('getCourseList', {channelId: this.channelId, pageNo: 1, pageSize: 10, key: ''})
  159. },
  160. // 选择课程
  161. addEdit (row, index) {
  162. this.$store.dispatch('addRelationList', {
  163. data: {channelId: this.channelId, courseIds: [ row.id ]},
  164. params: {channelId: this.channelId, pageNo: 1, pageSize: 10 }
  165. }).then(res => {
  166. if(res.code == 200) {
  167. this.$store.dispatch('getCourseList', {channelId: this.channelId, pageNo: 1, pageSize: 10, key: ''})
  168. }
  169. })
  170. },
  171. // 渠道下课程分页
  172. changePage (e) {
  173. this.page = e;
  174. this.$store.dispatch('getRelationList', {channelId: this.channelId, pageNo: e, pageSize: 10 })
  175. },
  176. // 添加分页
  177. changePageEdit (e) {
  178. this.pageEdit = e;
  179. this.$store.dispatch('getCourseList', {pageNo: e, pageSize: 10, key: ''})
  180. },
  181. // 删除课件
  182. remove (row) {
  183. this.$store.dispatch('removeRelationList', {
  184. data: {channelId: this.channelId, courseIds: [ row.id ]},
  185. params: {channelId: this.channelId, pageNo: this.page, pageSize: 10 }
  186. })
  187. }
  188. },
  189. }
  190. </script>
  191. <style lang="less">
  192. .el-pagination {
  193. text-align: center;
  194. margin-top: 20px;
  195. }
  196. .el-form-item__content {
  197. width: 50%;
  198. }
  199. </style>