index.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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"
  14. :label="item.label" />
  15. </el-select>
  16. </el-form-item>
  17. <el-form-item label="付费类型:" v-if="![2, 10, 11].includes(dialogForm.audioType)">
  18. <el-select v-model="dialogForm.isFree" placeholder="请选择付费类型" clearable>
  19. <el-option v-for="item in freeOptions" :key="item.value" :label="item.label" :value="item.value" />
  20. </el-select>
  21. </el-form-item>
  22. <el-form-item label="内容名称:">
  23. <el-input v-model="dialogForm.keyword" placeholder="请输入内容名称" clearable />
  24. </el-form-item>
  25. <el-form-item>
  26. <el-button type="primary" icon="el-icon-search" @click="getSearch">搜索</el-button>
  27. <el-button icon="el-icon-refresh" @click="getRefresh">重置</el-button>
  28. </el-form-item>
  29. </el-form>
  30. <el-table :data="tableData" ref="tableData" :row-key="getRowKey" @selection-change="getChange"
  31. v-loading="loading">
  32. <el-table-column type="selection" align="center" :reserve-selection="true" />
  33. <el-table-column label="音频ID" prop="audioId" align="center" show-overflow-tooltip />
  34. <el-table-column label="音频名称" prop="audioName" align="center" show-overflow-tooltip />
  35. <el-table-column label="音频封面" align="center" width="100px">
  36. <template slot-scope="scope">
  37. <el-image v-if="scope.row.audioPic" :src="scope.row.audioPic" />
  38. </template>
  39. </el-table-column>
  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"
  45. :limit.sync="dialogForm.pageSize" @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.getList()
  90. }
  91. },
  92. channelType(val) {
  93. this.getPlatform({
  94. audioType: this.dialogForm.audioType = this.channelOptions[val][0].value
  95. })
  96. },
  97. },
  98. computed: {
  99. // 弹窗
  100. dialogVisible: {
  101. get() {
  102. return this.visible
  103. },
  104. set(val) {
  105. this.$emit('close', val)
  106. }
  107. }
  108. },
  109. methods: {
  110. // 搜索
  111. getSearch() {
  112. this.dialogForm.pageNum = 1
  113. this.getList()
  114. },
  115. // 重置
  116. getRefresh() {
  117. this.dialogForm = {
  118. pageNum: 1,
  119. pageSize: 10,
  120. status: 1,
  121. audioType: this.dialogForm.audioType,
  122. platformId: null,
  123. }
  124. this.getList()
  125. },
  126. // 列表
  127. getList() {
  128. this.loading = true
  129. list(this.dialogForm).then(res => {
  130. if (res.code === 0) {
  131. this.tableData = res.data.records
  132. this.total = res.data.total
  133. this.loading = false
  134. this.$refs.tableData.clearSelection()
  135. if (this.data.length > 0) {
  136. this.data.map(i => {
  137. let row = this.tableData.find(j => j.audioId === i.audioId)
  138. if (row) {
  139. this.$refs.tableData.toggleRowSelection(row, true)
  140. }
  141. })
  142. }
  143. }
  144. })
  145. },
  146. getRowKey(row) {
  147. return row.audioId
  148. },
  149. // 选择
  150. getChange(row) {
  151. if (row.length > 0) {
  152. row.map(i => {
  153. if (this.data.findIndex(j => j.audioId === i.audioId) === -1) {
  154. this.data.push(i)
  155. }
  156. })
  157. }
  158. },
  159. // 字典翻译
  160. freeFormatter(row) {
  161. return this.selectDictLabel(this.freeOptions, row.isFree)
  162. },
  163. platfromFormatter(row) {
  164. return this.selectDictLabel(this.platformTypeOptions, row.platformId)
  165. },
  166. }
  167. }
  168. </script>
  169. <style lang="scss" scoped>
  170. ::v-deep .el-dialog__body {
  171. height: 610px;
  172. overflow-y: scroll;
  173. }
  174. </style>