index.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. <template>
  2. <div class='m-container'>
  3. <h2>
  4. <div class="squrt"></div>教学伴奏
  5. </h2>
  6. <div class="m-core">
  7. <el-button @click="open('COMMON')" type="primary" v-permission="'sysMusicScore/add'">添加公用伴奏</el-button>
  8. <!-- <el-button @click="open('PERSON')" type="primary" v-permission="'sysMusicScore/add'">添加个人伴奏</el-button> -->
  9. <saveform ref="searchForm" :model.sync="searchForm" inline style="margin-top: 20px">
  10. <el-form-item prop="search">
  11. <el-input v-model="searchForm.search" clearable placeholder="伴奏编号/伴奏名称"/>
  12. </el-form-item>
  13. <el-form-item prop="type">
  14. <el-select v-model="searchForm.type" clearable placeholder="请选择类型">
  15. <el-option
  16. v-for="(item, key) in songUseType"
  17. :key="key"
  18. :label="item"
  19. :value="key"
  20. ></el-option>
  21. </el-select>
  22. </el-form-item>
  23. <!-- <el-form-item prop="subjectId">
  24. <el-select v-model="searchForm.subjectId" clearable filterable placeholder="请选择声部">
  25. <el-option v-for="item in selects.subjects" :value="item.id" :label="item.name" :key="item.id"></el-option>
  26. </el-select>
  27. </el-form-item> -->
  28. <el-button @click="submit" type="primary">搜索</el-button>
  29. <el-button @click="reset" type="danger">重置</el-button>
  30. </saveform>
  31. <el-table
  32. style="width: 100%"
  33. :header-cell-style="{background:'#EDEEF0',color:'#444'}"
  34. :data="tableList"
  35. >
  36. <el-table-column
  37. align="center"
  38. prop="id"
  39. label="编号"
  40. >
  41. <template slot-scope="scope">
  42. <div>
  43. <copy-text>{{ scope.row.id }}</copy-text>
  44. </div>
  45. </template>
  46. </el-table-column>
  47. <el-table-column
  48. align="center"
  49. prop="name"
  50. label="名称"
  51. width="180px"
  52. >
  53. <template slot-scope="scope">
  54. <div>
  55. <copy-text>{{ scope.row.name }}</copy-text>
  56. </div>
  57. </template>
  58. </el-table-column>
  59. <el-table-column
  60. align="center"
  61. prop="type"
  62. label="类型"
  63. >
  64. <template slot-scope="scope">
  65. {{scope.row.type | songUseTypeFormat}}
  66. </template>
  67. </el-table-column>
  68. <!-- <el-table-column
  69. align="center"
  70. prop="subjectNames"
  71. label="声部"
  72. width="180px"
  73. >
  74. <template slot-scope="scope">
  75. <el-tooltip class="item" effect="dark" :content="scope.row.subjectNames">
  76. <div class="remark">{{scope.row.subjectNames}}</div>
  77. </el-tooltip>
  78. </template>
  79. </el-table-column>
  80. <el-table-column
  81. align="center"
  82. prop="speed"
  83. label="速度"
  84. /> -->
  85. <el-table-column
  86. align="center"
  87. prop="categoriesName"
  88. label="分类"
  89. width="180px"
  90. />
  91. <el-table-column
  92. align="center"
  93. prop="createUserName"
  94. label="上传人"
  95. width="180px"
  96. />
  97. <el-table-column
  98. align="center"
  99. prop="createTime"
  100. label="上传时间"
  101. width="180px"
  102. />
  103. <el-table-column
  104. align="center"
  105. width="180px"
  106. label="操作"
  107. fixed="right"
  108. >
  109. <template slot-scope="scope">
  110. <el-button type="text"
  111. @click="player(scope.row)"
  112. :disabled="!scope.row.url"
  113. >播放</el-button>
  114. <el-button type="text"
  115. @click="edit(scope.row)"
  116. v-permission="'sysMusicScore/update'"
  117. >修改</el-button>
  118. <el-button type="text"
  119. @click="remove(scope.row)"
  120. v-permission="'sysMusicScore/del'"
  121. >删除</el-button>
  122. </template>
  123. </el-table-column>
  124. </el-table>
  125. <pagination
  126. sync
  127. :total.sync="rules.total"
  128. :page.sync="rules.page"
  129. :limit.sync="rules.limit"
  130. :page-sizes="rules.page_size"
  131. @pagination="FetchList"
  132. />
  133. </div>
  134. <el-dialog v-if="audioVisible" width="400px" :visible.sync="audioVisible" title="播放伴奏">
  135. <audio style="display: block; margin: auto" controls :src="activeUrl"/>
  136. </el-dialog>
  137. <el-dialog
  138. :title="title"
  139. :visible.sync="visible"
  140. width="700px"
  141. v-if="visible"
  142. >
  143. <submit-form
  144. :detail="detail"
  145. :type="type"
  146. @submited="FetchList"
  147. @close="visible = false"
  148. />
  149. </el-dialog>
  150. </div>
  151. </template>
  152. <script>
  153. import saveform from '@/components/save-form'
  154. import pagination from '@/components/Pagination/index'
  155. import { songUseType } from '@/constant'
  156. import { QueryPage, Del } from './api'
  157. import form from './modals/form'
  158. export default {
  159. name: 'accompaniment',
  160. components: {
  161. saveform,
  162. pagination,
  163. 'submit-form': form
  164. },
  165. data() {
  166. return {
  167. type: '',
  168. activeUrl: '',
  169. songUseType,
  170. audioVisible: false,
  171. tableList: [],
  172. searchForm: {
  173. search: '',
  174. type: '',
  175. subjectId: ''
  176. },
  177. rules: {
  178. // 分页规则
  179. limit: 10, // 限制显示条数
  180. page: 1, // 当前页
  181. total: 0, // 总条数
  182. page_size: [10, 20, 40, 50] // 选择限制显示条数
  183. },
  184. detail: null,
  185. visible: false,
  186. }
  187. },
  188. computed: {
  189. title() {
  190. const t1 = this.detail ? '修改' : '添加'
  191. let t2 = this.type === 'COMMON' ? '公用' : '个人'
  192. if (this.detail) {
  193. t2 = this.detail.type === 'COMMON' ? '公用' : '个人'
  194. }
  195. return t1 + t2 + '伴奏'
  196. },
  197. },
  198. mounted() {
  199. this.$store.dispatch('setSubjects')
  200. this.FetchList()
  201. },
  202. methods: {
  203. async FetchList() {
  204. try {
  205. const res = await QueryPage({
  206. ...this.searchForm,
  207. page: this.rules.page,
  208. rows: this.rules.limit,
  209. })
  210. this.tableList = res.data.rows
  211. this.$set(this.rules, 'total', res.data.total)
  212. } catch (error) {}
  213. },
  214. submit() {
  215. this.$set(this.rules, 'page', 1)
  216. this.$refs.searchForm.validate(valid => {
  217. if (valid) {
  218. this.FetchList()
  219. }
  220. })
  221. },
  222. reset() {
  223. this.$refs.searchForm.resetFields()
  224. this.FetchList()
  225. },
  226. player(row) {
  227. this.activeUrl = row.url
  228. this.audioVisible = true
  229. },
  230. edit(row) {
  231. this.detail = row
  232. this.visible = true
  233. },
  234. open(type) {
  235. this.type = type
  236. this.detail = null
  237. this.visible = true
  238. },
  239. async remove(row) {
  240. try {
  241. await this.$confirm('是否确认删除此伴奏?', '提示', {
  242. type: 'warning',
  243. })
  244. await Del(row.id)
  245. this.$message.success('删除成功')
  246. this.FetchList()
  247. } catch (error) {}
  248. },
  249. }
  250. }
  251. </script>
  252. <style lang="less" scoped>
  253. .remark{
  254. display: inline;
  255. overflow: hidden;
  256. white-space: pre;
  257. }
  258. </style>