index.vue 7.0 KB

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