index.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <template>
  2. <!-- 弹窗 -->
  3. <el-dialog :visible.sync="dialogVisible" title="关联内容" width="1400px">
  4. <el-form inline size="mini" style="width:100%">
  5. <el-form-item label="音频类型:">
  6. <el-select v-model="dialogForm.audioType">
  7. <el-option v-for="item in channelOptions[channelType]" :key="item.value" :value="item.value"
  8. :label="item.label" />
  9. </el-select>
  10. </el-form-item>
  11. <el-form-item label="资源平台:">
  12. <el-select v-model="dialogForm.platformId" :disabled="[16, 17].includes(channelType)" clearable>
  13. <el-option v-for="item in platformOptions" :key="item.value" :value="item.value" :label="item.label" />
  14. </el-select>
  15. </el-form-item>
  16. <el-form-item label="付费类型:" v-if="![2, 10, 11].includes(dialogForm.audioType)">
  17. <el-select v-model="dialogForm.isFree" placeholder="请选择付费类型" clearable>
  18. <el-option v-for="item in freeOptions" :key="item.value" :label="item.label" :value="item.value" />
  19. </el-select>
  20. </el-form-item>
  21. <el-form-item label="内容名称:">
  22. <el-input v-model="dialogForm.keyword" placeholder="请输入内容名称" clearable />
  23. </el-form-item>
  24. <el-form-item>
  25. <el-button type="primary" icon="el-icon-search" @click="getSearch">搜索</el-button>
  26. <el-button icon="el-icon-refresh" @click="getRefresh">重置</el-button>
  27. </el-form-item>
  28. </el-form>
  29. <el-table :data="tableData" ref="tableData" :row-key="getRowKey" @selection-change="getChange" v-loading="loading">
  30. <el-table-column type="selection" align="center" :reserve-selection="true" />
  31. <el-table-column label="音频ID" prop="audioId" align="center" show-overflow-tooltip />
  32. <el-table-column label="音频名称" prop="audioName" align="center" show-overflow-tooltip />
  33. <el-table-column label="音频封面" align="center" width="100px">
  34. <template slot-scope="scope">
  35. <el-image v-if="scope.row.audioPic" :src="scope.row.audioPic" />
  36. </template>
  37. </el-table-column>
  38. <el-table-column label="音频作者" prop="singerName" align="center" />
  39. <el-table-column label="专辑名称" prop="songName" align="center" />
  40. <el-table-column label="付费类型" prop="isFree" align="center" :formatter="freeFormatter" />
  41. <el-table-column label="资源平台" align="center" :formatter="platfromFormatter" />
  42. </el-table>
  43. <div slot="footer">
  44. <pagination v-show="total > 0" :total="total" :page.sync="dialogForm.pageNum" :limit.sync="dialogForm.pageSize"
  45. @pagination="getList" />
  46. </div>
  47. </el-dialog>
  48. </template>
  49. <script>
  50. import { list } from '@/api/operation/channel'
  51. import { platformMixin, isFreeMixin, channelMixin } from '@/mixin/index'
  52. export default {
  53. mixins: [platformMixin, isFreeMixin, channelMixin],
  54. props: {
  55. visible: {
  56. type: Boolean,
  57. default: false
  58. },
  59. channelType: {
  60. type: String | Number,
  61. default: ''
  62. },
  63. data: {
  64. type: Array,
  65. default: () => []
  66. }
  67. },
  68. data() {
  69. return {
  70. // 遮罩层
  71. loading: false,
  72. // 总数
  73. total: 0,
  74. dialogForm: {
  75. pageNum: 1,
  76. pageSize: 10,
  77. status: 1,
  78. platformId: null,
  79. audioType: null
  80. },
  81. // 弹窗列表
  82. tableData: [],
  83. }
  84. },
  85. watch: {
  86. dialogVisible(val) {
  87. if (val) {
  88. this.dialogForm.platformId = this.channelType === 16 ? 3 : this.channelType === 17 ? 2 : null
  89. this.getPlatform({
  90. audioType: this.dialogForm.audioType
  91. })
  92. this.getList()
  93. }
  94. },
  95. channelType(val) {
  96. this.dialogForm.audioType = this.channelOptions[val][0].value
  97. },
  98. 'dialogForm.audioType'(val) {
  99. if (this.dialogVisible) {
  100. this.getPlatform({
  101. audioType: val
  102. })
  103. this.getList()
  104. }
  105. }
  106. },
  107. computed: {
  108. // 弹窗
  109. dialogVisible: {
  110. get() {
  111. return this.visible
  112. },
  113. set(val) {
  114. this.$emit('close', val)
  115. }
  116. }
  117. },
  118. methods: {
  119. // 搜索
  120. getSearch() {
  121. this.dialogForm.pageNum = 1
  122. this.getList()
  123. },
  124. // 重置
  125. getRefresh() {
  126. this.dialogForm = {
  127. pageNum: 1,
  128. pageSize: 10,
  129. status: 1,
  130. audioType: this.dialogForm.audioType,
  131. platformId: null,
  132. }
  133. this.getList()
  134. },
  135. // 列表
  136. getList() {
  137. this.loading = true
  138. list(this.dialogForm).then(res => {
  139. if (res.code === 0) {
  140. this.tableData = res.data.records
  141. this.total = res.data.total
  142. this.loading = false
  143. this.$refs.tableData.clearSelection()
  144. if (this.data.length > 0) {
  145. this.data.map(i => {
  146. let row = this.tableData.find(j => j.audioId === i.audioId)
  147. if (row) {
  148. this.$refs.tableData.toggleRowSelection(row, true)
  149. }
  150. })
  151. }
  152. }
  153. })
  154. },
  155. getRowKey(row) {
  156. return row.audioId
  157. },
  158. // 选择
  159. getChange(row) {
  160. if (row.length > 0) {
  161. row.map(i => {
  162. if (this.data.findIndex(j => j.audioId === i.audioId) === -1) {
  163. this.data.push(i)
  164. }
  165. })
  166. }
  167. },
  168. // 字典翻译
  169. freeFormatter(row) {
  170. return this.selectDictLabel(this.freeOptions, row.isFree)
  171. },
  172. platfromFormatter(row) {
  173. return this.selectDictLabel(this.platformOptions, row.platformId)
  174. },
  175. }
  176. }
  177. </script>
  178. <style lang="scss" scoped>
  179. ::v-deep .el-dialog__body {
  180. height: 610px;
  181. overflow-y: scroll;
  182. }
  183. </style>