detail.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. <template>
  2. <div class="app-container">
  3. <!-- 表单 -->
  4. <el-form class="form" label-width="100px" :disabled="isRead">
  5. <el-row>
  6. <el-col :span="12">
  7. <el-form-item label="频道名称:">
  8. <el-input v-model="form.aliasName" placeholder="请输入频道名称" />
  9. </el-form-item>
  10. <el-form-item label="频道属性:">
  11. <el-select v-model="form.channelType" placeholder="请选择频道属性" :disabled="disabled" @change="handleChange">
  12. <el-option v-for="item in channelTypeOptions" :key="item.value" :value="Number(item.value)"
  13. :label="item.label" :disabled="channelDisabled(item.value)" />
  14. </el-select>
  15. </el-form-item>
  16. <el-form-item label="频道封面:">
  17. <Upload listType="picture-card" :url="form.pic" @upload="getUpload" :disabled="isRead" />
  18. </el-form-item>
  19. </el-col>
  20. <el-col :span="12">
  21. <el-form-item label="频道简介:">
  22. <el-input v-model="form.description" type="textarea" rows="12" placeholder="请输入频道简介" />
  23. </el-form-item>
  24. </el-col>
  25. </el-row>
  26. <el-form-item label="频道内容:">
  27. <el-button type="primary" icon="el-icon-plus" @click="getDialog">
  28. 新增内容
  29. </el-button>
  30. <el-table :data="form.list" v-loading="loading">
  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 :src="scope.row.audioPic" />
  36. </template>
  37. </el-table-column>
  38. <el-table-column label="音频作者" align="center" show-overflow-tooltip>
  39. <template slot-scope="scope">
  40. <span>
  41. {{ scope.row.singerName ? scope.row.singerName : '-' }}
  42. </span>
  43. </template>
  44. </el-table-column>
  45. <el-table-column label="专辑名称" prop="songName" align="center" show-overflow-tooltip>
  46. <template slot-scope="scope">
  47. <span>
  48. {{ scope.row.songName ? scope.row.songName : '-' }}
  49. </span>
  50. </template>
  51. </el-table-column>
  52. <el-table-column label="付费类型" prop="isFree" align="center" :formatter="freeFormatter" />
  53. <el-table-column label="资源平台" align="center" :formatter="platfromFormatter" />
  54. <el-table-column label="当前状态" align="center" :formatter="statusFormatter" />
  55. <el-table-column label="操作" align="center">
  56. <template slot-scope="scope">
  57. <el-button type="delete" @click="getDelete(scope.row)">删除</el-button>
  58. </template>
  59. </el-table-column>
  60. </el-table>
  61. </el-form-item>
  62. </el-form>
  63. <!-- 按钮 -->
  64. <div class="form-btn">
  65. <el-button @click="cancel">取消</el-button>
  66. <el-button v-if="!isRead" type="primary" @click="submit">提交</el-button>
  67. </div>
  68. <!-- 弹窗 -->
  69. <Dialog :visible="dialogVisible" :data="form.list" :channelType="form.channelType" @close="close" />
  70. </div>
  71. </template>
  72. <script>
  73. import Dialog from '@/components/Dialog/index.vue'
  74. import { channelDetail, channeledit } from '@/api/operation/channels'
  75. import { platformMixin, isFreeMixin, disabledMixin } from '@/mixin/index'
  76. export default {
  77. mixins: [platformMixin, isFreeMixin, disabledMixin],
  78. components: {
  79. Dialog
  80. },
  81. data() {
  82. return {
  83. // 遮罩层
  84. loading: false,
  85. // 弹窗
  86. dialogVisible: false,
  87. // 表单
  88. form: {},
  89. // 频道1 频道2 的频道属性不可修改
  90. disabled: this.$route.query.index == '1' ? true : false,
  91. channelTypeOptions: [
  92. { value: 2, label: '广播' },
  93. { value: 6, label: '节目' },
  94. { value: 8, label: '专辑' }
  95. ],
  96. // 只读
  97. isRead: Boolean(this.$route.query.boolean)
  98. }
  99. },
  100. mounted() {
  101. this.getDetail()
  102. this.getPlatform({})
  103. },
  104. methods: {
  105. // 频道详情
  106. getDetail() {
  107. channelDetail({
  108. channelId: this.$route.query.channelId
  109. }).then(res => {
  110. if (res.code === 0) {
  111. this.form = res.data
  112. }
  113. })
  114. },
  115. // 修改频道属性
  116. handleChange() {
  117. this.form.list = this.form.audioList = []
  118. },
  119. // 上传频道封面
  120. getUpload(e) {
  121. this.form.pic = e.file
  122. },
  123. // 打开弹窗
  124. getDialog() {
  125. this.dialogVisible = true
  126. },
  127. // 关闭弹窗
  128. close() {
  129. this.dialogVisible = false
  130. },
  131. // 删除
  132. getDelete(row) {
  133. this.form.list = this.form.list.filter(i => i.audioId !== row.audioId)
  134. },
  135. // 提交
  136. submit() {
  137. this.form.audioList = []
  138. this.form.list.map(i => {
  139. this.form.audioList.push({
  140. audioId: i.audioId,
  141. audioType: i.audioType
  142. })
  143. })
  144. channeledit(this.form).then(res => {
  145. if (res.code === 0) {
  146. this.$message.success('修改成功!')
  147. this.getDetail()
  148. }
  149. })
  150. },
  151. // 取消
  152. cancel() {
  153. this.$tab.closeOpenPage('/operation/channels')
  154. },
  155. // 除了2频道都不可以选猫王精选电台
  156. channelDisabled(e){
  157. return this.$route.query.index !== '1' ? e == 17 ? true : false : false
  158. },
  159. // 字典翻译
  160. platfromFormatter(row) {
  161. return this.selectDictLabel(this.platformTypeOptions, row.platformId)
  162. },
  163. freeFormatter(row) {
  164. return this.selectDictLabel(this.freeOptions, row.isFree)
  165. },
  166. statusFormatter(row) {
  167. return this.selectDictLabel(this.disabledOptions, row.status)
  168. }
  169. }
  170. }
  171. </script>
  172. <style lang="scss" scoped>
  173. .el-image {
  174. width: 80px;
  175. height: 80px;
  176. }
  177. ::v-deep .el-dialog__body {
  178. height: 610px;
  179. overflow-y: scroll;
  180. }
  181. </style>