index.vue 6.0 KB

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