index.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <template>
  2. <div class="app-container">
  3. <div class="filter-container">
  4. <div class="filter-container-lt">
  5. <el-form :inline="true" label-position="left" :model="listQuery">
  6. <el-form-item>
  7. <el-input clearable v-model="listQuery.musicCategoryName" placeholder="音乐类目名称"
  8. ></el-input>
  9. </el-form-item>
  10. <el-button type="primary" @click="getList()">搜索</el-button >
  11. <el-button type="primary" @click="add()">新增</el-button >
  12. </el-form>
  13. </div>
  14. </div>
  15. <div class="table-container">
  16. <el-table style="width: 100%" v-loading="listLoading" :key="tableKey" :data="list" row-key="id"
  17. stripe border fit highlight-current-row>
  18. <el-table-column label="序号" type="index" width="60" align="center" />
  19. <el-table-column label="音乐类目名称" min-width="100" align="center" prop="musicCategoryName" />
  20. <el-table-column label="音乐分类" min-width="130" align="center">
  21. <template slot-scope="scope">
  22. {{ scope.row.type == 0 ? '类目' : '音乐' }}
  23. </template>
  24. </el-table-column>
  25. <el-table-column label="类目排序" min-width="100" align="center" prop="musicCategorySort" />
  26. <el-table-column label="操作" align="center" width="160">
  27. <template slot-scope="scope">
  28. <el-tooltip class="item" effect="dark" content="编辑" placement="top">
  29. <el-button type="success" size="mini" icon="el-icon-edit" circle @click="handleEdit(scope.row)" />
  30. </el-tooltip>
  31. <el-tooltip class="more" effect="dark" content="删除" placement="top">
  32. <el-button type="danger" size="mini" icon="el-icon-delete-solid" circle
  33. @click="handleDelete(scope.row)" />
  34. </el-tooltip>
  35. </template>
  36. </el-table-column>
  37. </el-table>
  38. </div>
  39. <!-- 分页 -->
  40. <swPage v-if="total > 0" key="2" :listQuery="listQuery" :total="total" pos="btmRight" @retPage="retPage" />
  41. <MusicLibraryFormModal ref="MusicLibraryFormModal" @confirm="retPage"></MusicLibraryFormModal>
  42. </div>
  43. </template>
  44. <script>
  45. import waves from "@/directive/waves";
  46. import swPage from "@/views/common/swPage";
  47. import { auditStatus } from "@/constants/index";
  48. import { getValueByKey } from "@/utils/index";
  49. import { fetchMusicConfigList, deleteMusicCategoryInfo } from "@/api/musicLibraryManager";
  50. import permission from "@/directive/permission";
  51. import MusicLibraryFormModal from "./components/MusicLibraryFormModal";
  52. export default {
  53. name: "videoCoverManager",
  54. directives: {
  55. waves,
  56. permission
  57. },
  58. components: {
  59. swPage,
  60. MusicLibraryFormModal
  61. },
  62. computed: {
  63. },
  64. data() {
  65. return {
  66. auditStatus,
  67. tableKey: 0,
  68. list: [],
  69. total: 0,
  70. listLoading: false,
  71. downloadingRows: {},
  72. listQuery: {
  73. currentPage: 1,
  74. pageSize: 10,
  75. type: 0,
  76. musicCategoryName: null
  77. }
  78. };
  79. },
  80. //页面创建的时候执行
  81. created() {
  82. this.getList();
  83. },
  84. methods: {
  85. getValueByKey,
  86. getList() {
  87. this.listLoading = true;
  88. const params = this.listQuery
  89. if (!this.listQuery.musicCategoryName) {
  90. delete params.musicCategoryName
  91. }
  92. fetchMusicConfigList(params).then(res => {
  93. if (200 == res.code) {
  94. this.total = res.data.total;
  95. this.list = res.data.rows;
  96. }
  97. this.listLoading = false;
  98. });
  99. },
  100. retPage() {
  101. //分页
  102. this.getList();
  103. },
  104. handleFilter() {
  105. this.listQuery.page = 1;
  106. this.getList();
  107. },
  108. handleEdit(row) {
  109. this.$refs.MusicLibraryFormModal.show(row, 'edit');
  110. },
  111. add() {
  112. this.$refs.MusicLibraryFormModal.show(null, 'add');
  113. },
  114. handleDelete(row) {
  115. //删除
  116. this.$confirm("删除类目该类目下所有音乐都会删除,确定要删除吗?", "提示", {
  117. confirmButtonText: "确定",
  118. cancelButtonText: "取消",
  119. type: "warning"
  120. }).then(() => {
  121. const { id } = row;
  122. deleteMusicCategoryInfo([id]).then(() => {
  123. this.$notify({
  124. title: "成功",
  125. message: "删除成功",
  126. type: "success",
  127. duration: 3000
  128. });
  129. const index = this.list.indexOf(row);
  130. this.list.splice(index, 1);
  131. });
  132. });
  133. }
  134. }
  135. };
  136. </script>
  137. <style rel="stylesheet/scss" lang="scss" scoped>
  138. @import "@/styles/layout.scss";
  139. .button {
  140. .el-button {
  141. margin-bottom: 10px;
  142. &:last-child {
  143. margin-bottom: 0;
  144. }
  145. }
  146. }
  147. </style>