index.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. <!-- 音频管理 猫王精选电台 -->
  2. <template>
  3. <div class="app-container">
  4. <!-- 搜索 -->
  5. <el-form inline size="mini">
  6. <el-form-item label="电台名称:">
  7. <el-input v-model="form.name" placeholder="请输入电台名称" clearable />
  8. </el-form-item>
  9. <el-form-item label="当前状态:">
  10. <el-select v-model="form.status" placeholder="请选择当前状态">
  11. <el-option
  12. v-for="item in onOrOffOptions"
  13. :key="item.value"
  14. :label="item.label"
  15. :value="item.value"
  16. clearable
  17. />
  18. </el-select>
  19. </el-form-item>
  20. <el-form-item>
  21. <el-button type="primary" icon="el-icon-search" @click="getSearch"
  22. >搜索</el-button
  23. >
  24. <el-button icon="el-icon-refrash" @click="getRefrash">重置</el-button>
  25. <el-button
  26. type="primary"
  27. plain
  28. icon="el-icon-plus"
  29. @click="getDetail()"
  30. v-hasPermi="['music:choiceness:add']"
  31. >新增</el-button
  32. >
  33. </el-form-item>
  34. </el-form>
  35. <!-- 列表 -->
  36. <el-table :data="tableData" v-loading="loading">
  37. <el-table-column type="index" label="序号" align="center" />
  38. <el-table-column
  39. label="电台ID"
  40. prop="id"
  41. align="center"
  42. show-overflow-tooltip
  43. />
  44. <el-table-column label="电台名称" prop="name" align="center" />
  45. <el-table-column label="电台封面" align="center" width="100px">
  46. <template slot-scope="scope">
  47. <el-image v-if="scope.row.thumb" :src="scope.row.thumb" />
  48. </template>
  49. </el-table-column>
  50. <el-table-column
  51. label="资源平台"
  52. prop="platformId"
  53. align="center"
  54. :formatter="platformFormatter"
  55. />
  56. <el-table-column
  57. label="当前状态"
  58. prop="status"
  59. align="center"
  60. :formatter="statusFormatter"
  61. />
  62. <el-table-column label="更新时间" align="center">
  63. <template slot-scope="scope">
  64. <span>{{
  65. parseTime(scope.row.updateTime, "{y}-{m}-{d} {h}:{i}:{s}")
  66. }}</span>
  67. </template>
  68. </el-table-column>
  69. <el-table-column label="操作" align="center">
  70. <template slot-scope="scope">
  71. <el-button type="text" @click="getDetail(scope.row.id, true)"
  72. >查看</el-button
  73. >
  74. <el-button
  75. v-if="scope.row.status === 1"
  76. type="text"
  77. @click="getChange(scope.row, 2)"
  78. v-hasPermi="['music:choiceness:down']"
  79. >下架</el-button
  80. >
  81. <span v-else>
  82. <el-button
  83. type="text"
  84. style="margin-left: 10px"
  85. @click="getDetail(scope.row.id)"
  86. v-hasPermi="['music:choiceness:edit']"
  87. >编辑</el-button
  88. >
  89. <el-button
  90. type="text"
  91. @click="getChange(scope.row, 1)"
  92. v-hasPermi="['music:choiceness:up']"
  93. >
  94. 上架
  95. </el-button>
  96. <el-button
  97. type="delete"
  98. @click="getDelete(scope.row)"
  99. v-hasPermi="['music:choiceness:delete']"
  100. >
  101. 删除
  102. </el-button>
  103. </span>
  104. </template>
  105. </el-table-column>
  106. </el-table>
  107. <pagination
  108. v-show="total > 0"
  109. :total="total"
  110. :page.sync="form.pageNum"
  111. :limit.sync="form.pageSize"
  112. @pagination="getList"
  113. />
  114. </div>
  115. </template>
  116. <script>
  117. import { change, list, remove } from "@/api/music/choiceness";
  118. import { onOrOffMixin, platformMixin } from "@/mixin/index";
  119. import { dialogCallBack } from "@/utils/DialogUtil";
  120. export default {
  121. name:"MusicChoiceness",
  122. mixins: [onOrOffMixin, platformMixin],
  123. data() {
  124. return {
  125. // 遮罩层
  126. loading: false,
  127. // 表单
  128. form: {
  129. pageNum: 1,
  130. pageSize: 10,
  131. },
  132. total: 0,
  133. // 列表
  134. tableData: [],
  135. };
  136. },
  137. mounted() {
  138. this.getList();
  139. this.getPlatform({});
  140. },
  141. methods: {
  142. // 列表
  143. getList() {
  144. this.loading = true;
  145. list(this.form).then((res) => {
  146. if (res.code === 0) {
  147. this.tableData = res.data.records;
  148. this.total = res.data.total;
  149. this.loading = false;
  150. }
  151. });
  152. },
  153. // 搜索
  154. getSearch() {
  155. this.form.pageNum = 1;
  156. this.getList();
  157. },
  158. // 重置
  159. getRefrash() {
  160. this.form = {
  161. pageNum: 1,
  162. pageSize: 10,
  163. };
  164. this.getList();
  165. },
  166. // 详情
  167. getDetail(id, boolean) {
  168. this.$router.push({
  169. path: `/music/choiceness/detail`,
  170. query: {
  171. id: id,
  172. disabled: boolean,
  173. },
  174. });
  175. },
  176. // 上下架
  177. getChange(row, status) {
  178. let title = status === 1 ? "上架" : "下架";
  179. this.$confirm(`是否${title}${row.name}?`, "提示", {
  180. type: "warning",
  181. }).then(() => {
  182. change(row.id, status).then((res) => {
  183. if (res.code === 0) {
  184. this.$message.success(`${title}成功!`);
  185. this.getList();
  186. }
  187. });
  188. });
  189. },
  190. // 删除
  191. getDelete(row) {
  192. var that = this;
  193. dialogCallBack(that, function () {
  194. that
  195. .$confirm(`是否删除${row.name}?`, "提示", {
  196. type: "warning",
  197. })
  198. .then(() => {
  199. remove(row.id).then((res) => {
  200. if (res.code === 0) {
  201. that.$message.success(`删除成功!`);
  202. that.getList();
  203. }
  204. });
  205. });
  206. });
  207. },
  208. // 字典翻译
  209. platformFormatter(row) {
  210. return this.selectDictLabel(this.platformTypeOptions, row.platformId);
  211. },
  212. statusFormatter(row) {
  213. return this.selectDictLabel(this.onOrOffOptions, row.status);
  214. },
  215. },
  216. };
  217. </script>
  218. <style lang="scss" scoped></style>