index.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <template>
  2. <div class="app-container">
  3. <!-- 搜索 -->
  4. <el-form inline size="mini">
  5. <el-form-item label="主播名称:">
  6. <el-input v-model="form.nickname" placeholder="请输入主播名称" clearable />
  7. </el-form-item>
  8. <el-form-item label="资源平台:">
  9. <el-select v-model="form.platformId" placeholder="请选择资源平台" clearable>
  10. <el-option v-for="item in platformOptions" :key="item.value" :value="item.value"
  11. :label="item.label" />
  12. </el-select>
  13. </el-form-item>
  14. <el-form-item label="当前状态:">
  15. <el-select v-model="form.status" placeholder="请选择当前状态" clearable>
  16. <el-option v-for="item in onOrOffOptions" :key="item.value" :value="item.value"
  17. :label="item.label" />
  18. </el-select>
  19. </el-form-item>
  20. <el-form-item>
  21. <el-button type="primary" icon="el-icon-search" @click="getSearch">搜索</el-button>
  22. <el-button icon="el-icon-refresh" @click="getRefresh">重置</el-button>
  23. <el-button type="primary" plain icon="el-icon-plus" @click="getDetail()"
  24. v-hasPermi="['music:anchor:add']">新增</el-button>
  25. </el-form-item>
  26. </el-form>
  27. <!-- 列表 -->
  28. <el-table :data="tableData" v-loading="loading">
  29. <el-table-column label="主播Id" prop="id" align="center" />
  30. <el-table-column label="主播名称" prop="nickname" align="center" />
  31. <el-table-column label="主播头像" align="center" width="100px">
  32. <template slot-scope="scope">
  33. <el-image v-if="scope.row.avatar" :src="scope.row.avatar" />
  34. </template>
  35. </el-table-column>
  36. <el-table-column label="资源平台" prop="platformId" align="center" :formatter="platformFormatter" />
  37. <el-table-column label="当前状态" prop="status" align="center" :formatter="statusFormatter" />
  38. <el-table-column label="操作" align="center">
  39. <template slot-scope="scope">
  40. <el-button type="text" @click="getDetail(scope.row.id, true)">查看</el-button>
  41. <span v-if="scope.row.status === 2">
  42. <el-button type="text" @click="getDetail(scope.row.id)" v-hasPermi="['music:anchor:edit']"
  43. style="margin-left: 10px">编辑</el-button>
  44. <el-button type="text" @click="getChange(scope.row, 1)" v-hasPermi="['music:anchor:up']">上架
  45. </el-button>
  46. <el-button type="delete" @click="getDelete(scope.row)" v-hasPermi="['music:anchor:delete']">删除
  47. </el-button>
  48. </span>
  49. <el-button v-else type="text" @click="getChange(scope.row, 2)" v-hasPermi="['music:anchor:down']">下架
  50. </el-button>
  51. </template>
  52. </el-table-column>
  53. </el-table>
  54. <pagination v-show="total>0" :total="total" :page.sync="form.pageNum" :limit.sync="form.pageSize"
  55. @pagination="getList" />
  56. </div>
  57. </template>
  58. <script>
  59. import { list, change, remove } from '@/api/music/anchor'
  60. import { platformMixin, onOrOffMixin } from '@/mixin/index'
  61. export default {
  62. mixins: [platformMixin, onOrOffMixin],
  63. data() {
  64. return {
  65. // 遮罩层
  66. loading: false,
  67. // 表单
  68. form: {
  69. pageNum: 1,
  70. pageSize: 10
  71. },
  72. // 总数据
  73. total: 0,
  74. // 列表
  75. tableData: []
  76. }
  77. },
  78. mounted() {
  79. // 获取资源平台
  80. this.getPlatform({
  81. audioType: 12
  82. })
  83. this.getList()
  84. },
  85. methods: {
  86. // 列表
  87. getList() {
  88. this.loading = true
  89. list(this.form).then(res => {
  90. if (res.code === 0) {
  91. this.tableData = res.data.records
  92. this.total = res.data.total
  93. this.loading = false
  94. }
  95. })
  96. },
  97. // 搜索
  98. getSearch() {
  99. this.form.pageNum = 1
  100. this.getList()
  101. },
  102. // 重置
  103. getRefresh() {
  104. this.form = {
  105. pageNum: 1,
  106. pageSize: 10
  107. }
  108. this.getList()
  109. },
  110. // 新增 查看 编辑
  111. getDetail(id, boolean) {
  112. this.$router.push({
  113. path: `/music/anchor/detail`,
  114. query: {
  115. id: id,
  116. disabled: boolean
  117. }
  118. })
  119. },
  120. // 上下架
  121. getChange(row, status) {
  122. let title = status === 1 ? '上架' : '下架'
  123. this.$confirm(`是否${title}${row.nickname}?`, '提示', {
  124. type: 'warning'
  125. }).then(() => {
  126. change(row.id, status).then(res => {
  127. if (res.code === 0) {
  128. this.$message.success(`${title}成功!`)
  129. this.getList()
  130. }
  131. })
  132. }).catch(() => { })
  133. },
  134. // 删除
  135. getDelete(row) {
  136. this.$confirm(`是否删除${row.nickname}?`, '提示', {
  137. type: 'warning'
  138. }).then(() => {
  139. remove(row.id).then(res => {
  140. if (res.code === 0) {
  141. this.$message.success('删除成功!')
  142. this.getList()
  143. }
  144. })
  145. }).catch(() => { })
  146. },
  147. // 字典翻译
  148. platformFormatter(row) {
  149. return this.selectDictLabel(this.platformOptions, row.platformId)
  150. },
  151. statusFormatter(row) {
  152. return this.selectDictLabel(this.onOrOffOptions, row.status)
  153. }
  154. }
  155. }
  156. </script>
  157. <style lang="scss" scoped>
  158. </style>