index.vue 5.0 KB

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