index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438
  1. <template>
  2. <div class="m-container">
  3. <h2>
  4. <div class="squrt"></div>
  5. 教学伴奏
  6. </h2>
  7. <div class="m-core">
  8. <el-button
  9. @click="open('COMMON')"
  10. type="primary"
  11. v-permission="'sysMusicScore/add'"
  12. >添加公用伴奏</el-button
  13. >
  14. <!-- <el-button @click="open('PERSON')" type="primary" v-permission="'sysMusicScore/add'">添加个人伴奏</el-button> -->
  15. <saveform
  16. ref="searchForm"
  17. :model.sync="searchForm"
  18. inline
  19. style="margin-top: 20px"
  20. >
  21. <el-form-item prop="search">
  22. <el-input
  23. v-model="searchForm.search"
  24. clearable
  25. placeholder="伴奏编号/伴奏名称"
  26. />
  27. </el-form-item>
  28. <el-form-item prop="type">
  29. <el-select
  30. v-model="searchForm.type"
  31. clearable
  32. placeholder="请选择类型"
  33. >
  34. <el-option
  35. v-for="(item, key) in songUseType"
  36. :key="key"
  37. :label="item"
  38. :value="key"
  39. ></el-option>
  40. </el-select>
  41. </el-form-item>
  42. <el-form-item prop="clientType">
  43. <el-select v-model="searchForm.clientType" clearable filterable placeholder="请选择客户端类型">
  44. <el-option value="NETWORK_ROOM" label="网络教室" ></el-option>
  45. <el-option value="SMART_PRACTICE" label="智能陪练" ></el-option>
  46. </el-select>
  47. </el-form-item>
  48. <el-form-item prop="categoriesId">
  49. <el-cascader v-model="searchForm.categoriesId"
  50. style="width:100%"
  51. :options="tree"
  52. placeholder="请选择分类"
  53. clearable
  54. :show-all-levels="true"
  55. :props="treeProps"></el-cascader>
  56. </el-form-item>
  57. <el-form-item prop="rankType">
  58. <el-select v-model="searchForm.rankType" clearable filterable placeholder="请选择是否收费">
  59. <el-option :value="0" label="免费"></el-option>
  60. <el-option :value="1" label="收费"></el-option>
  61. </el-select>
  62. </el-form-item>
  63. <el-form-item prop="showFlag">
  64. <el-select v-model="searchForm.showFlag" clearable filterable placeholder="请选择伴奏状态">
  65. <el-option :value="1" label="启用"></el-option>
  66. <el-option :value="0" label="停用"></el-option>
  67. </el-select>
  68. </el-form-item>
  69. <el-form-item>
  70. <el-button @click="submit" type="primary">搜索</el-button>
  71. <el-button @click="reset" type="danger">重置</el-button>
  72. </el-form-item>
  73. </saveform>
  74. <el-table
  75. style="width: 100%"
  76. :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
  77. :data="tableList"
  78. >
  79. <el-table-column align="center" prop="id" label="编号">
  80. <template slot-scope="scope">
  81. <div>
  82. <copy-text>{{ scope.row.id }}</copy-text>
  83. </div>
  84. </template>
  85. </el-table-column>
  86. <el-table-column align="center" prop="name" label="名称" width="180px">
  87. <template slot-scope="scope">
  88. <div>
  89. <copy-text>{{ scope.row.name }}</copy-text>
  90. </div>
  91. </template>
  92. </el-table-column>
  93. <el-table-column align="center" prop="type" label="类型">
  94. <template slot-scope="scope">
  95. {{ scope.row.type | songUseTypeFormat }}
  96. </template>
  97. </el-table-column>
  98. <!-- <el-table-column
  99. align="center"
  100. prop="subjectNames"
  101. label="声部"
  102. width="180px"
  103. >
  104. <template slot-scope="scope">
  105. <el-tooltip class="item" effect="dark" :content="scope.row.subjectNames">
  106. <div class="remark">{{scope.row.subjectNames}}</div>
  107. </el-tooltip>
  108. </template>
  109. </el-table-column>
  110. <el-table-column
  111. align="center"
  112. prop="speed"
  113. label="速度"
  114. /> -->
  115. <el-table-column
  116. align="center"
  117. prop="categoriesName"
  118. label="分类"
  119. width="180px"
  120. />
  121. <el-table-column
  122. align="center"
  123. label="是否收费"
  124. width="180px"
  125. >
  126. <template slot-scope="scope">
  127. {{ scope.row.rankIds ? '收费' : '免费' }}
  128. </template>
  129. </el-table-column>
  130. <el-table-column
  131. align="center"
  132. label="伴奏状态"
  133. width="180px"
  134. >
  135. <template slot-scope="scope">
  136. {{ scope.row.showFlag ? '启用' : '停用' }}
  137. </template>
  138. </el-table-column>
  139. <el-table-column
  140. align="center"
  141. prop="categoriesName"
  142. label="客户端类型"
  143. width="180px"
  144. >
  145. <template slot-scope="scope">
  146. <div>
  147. {{scope.row.clientType | clientType}}
  148. </div>
  149. </template>
  150. </el-table-column>
  151. <!-- clientType -->
  152. <el-table-column
  153. align="center"
  154. prop="createUserName"
  155. label="上传人"
  156. width="180px"
  157. />
  158. <el-table-column
  159. align="center"
  160. prop="createTime"
  161. label="上传时间"
  162. width="180px"
  163. />
  164. <el-table-column
  165. align="center"
  166. width="180px"
  167. label="操作"
  168. fixed="right"
  169. >
  170. <template slot-scope="scope">
  171. <el-button
  172. type="text"
  173. @click="looker(scope.row)"
  174. :disabled="!scope.row.url || scope.row.clientType != 'SMART_PRACTICE'"
  175. >预览</el-button
  176. >
  177. <el-button
  178. type="text"
  179. @click="player(scope.row)"
  180. :disabled="!scope.row.url"
  181. >播放</el-button
  182. >
  183. <el-button
  184. type="text"
  185. @click="changeStatus(scope.row)"
  186. >{{ scope.row.showFlag ? '停用' : '启用' }}</el-button>
  187. <el-button
  188. type="text"
  189. @click="edit(scope.row)"
  190. :disabled="!!scope.row.showFlag"
  191. v-permission="'sysMusicScore/update'"
  192. >修改</el-button
  193. >
  194. <el-button
  195. type="text"
  196. @click="remove(scope.row)"
  197. v-permission="'sysMusicScore/del'"
  198. >删除</el-button
  199. >
  200. </template>
  201. </el-table-column>
  202. </el-table>
  203. <pagination
  204. sync
  205. :total.sync="rules.total"
  206. :page.sync="rules.page"
  207. :limit.sync="rules.limit"
  208. :page-sizes="rules.page_size"
  209. @pagination="FetchList"
  210. />
  211. </div>
  212. <el-dialog
  213. v-if="audioVisible"
  214. width="400px"
  215. :visible.sync="audioVisible"
  216. title="播放伴奏"
  217. >
  218. <audio style="display: block; margin: auto" controls :src="activeUrl" />
  219. </el-dialog>
  220. <el-dialog
  221. :title="title"
  222. :visible.sync="visible"
  223. width="700px"
  224. v-if="visible"
  225. >
  226. <submit-form
  227. :detail="detail"
  228. :type="type"
  229. @submited="FetchList"
  230. @close="visible = false"
  231. />
  232. </el-dialog>
  233. <el-dialog
  234. v-if="lookVisible"
  235. width="667px"
  236. class="lookForm"
  237. :visible.sync="lookVisible"
  238. title="预览"
  239. >
  240. <iframe id="iframe" v-if="lookVisible" style="width: 667px; height: 386px" ref="iframe" :src="accompanyUrl" />
  241. <div class="iframe_back"></div>
  242. <div class="iframe_help"></div>
  243. <div class="iframe_header_back"></div>
  244. </el-dialog>
  245. </div>
  246. </template>
  247. <script>
  248. import saveform from "@/components/save-form";
  249. import pagination from "@/components/Pagination/index";
  250. import { songUseType } from "@/constant";
  251. import { QueryPage, Del, Show, queryTree } from "./api";
  252. import form from "./modals/form";
  253. import { vaildTeachingUrl } from '@/utils/validate'
  254. import { getToken } from '@/utils/auth'
  255. import deepClone from '@/helpers/deep-clone/'
  256. export default {
  257. name: "accompaniment",
  258. components: {
  259. saveform,
  260. pagination,
  261. "submit-form": form,
  262. },
  263. data() {
  264. return {
  265. type: "",
  266. activeUrl: "",
  267. songUseType,
  268. lookVisible: false,
  269. accompanyUrl: null, // 预览地址
  270. audioVisible: false,
  271. tableList: [],
  272. searchForm: {
  273. search: "",
  274. type: "",
  275. subjectId: "",
  276. categoriesId: null,
  277. clientType:'',
  278. rankType: null,
  279. showFlag: null
  280. },
  281. rules: {
  282. // 分页规则
  283. limit: 10, // 限制显示条数
  284. page: 1, // 当前页
  285. total: 0, // 总条数
  286. page_size: [10, 20, 40, 50], // 选择限制显示条数
  287. },
  288. detail: null,
  289. visible: false,
  290. tree: [],
  291. treeProps: {
  292. value: 'id',
  293. label: 'name',
  294. children: 'sysMusicScoreCategoriesList',
  295. }
  296. };
  297. },
  298. computed: {
  299. title() {
  300. const t1 = this.detail ? "修改" : "添加";
  301. let t2 = this.type === "COMMON" ? "公用" : "个人";
  302. if (this.detail) {
  303. t2 = this.detail.type === "COMMON" ? "公用" : "个人";
  304. }
  305. return t1 + t2 + "伴奏";
  306. },
  307. },
  308. async mounted() {
  309. this.$store.dispatch("setSubjects");
  310. await this.FetchTree()
  311. await this.FetchList();
  312. },
  313. methods: {
  314. async FetchTree() {
  315. try {
  316. const res = await queryTree()
  317. this.tree = res.data
  318. } catch (error) {
  319. }
  320. },
  321. async FetchList() {
  322. try {
  323. let { categoriesId, ...search } = deepClone(this.searchForm)
  324. const res = await QueryPage({
  325. ...search,
  326. categoriesId: categoriesId && categoriesId.length > 0 ? categoriesId.pop() : null,
  327. page: this.rules.page,
  328. rows: this.rules.limit,
  329. });
  330. this.tableList = res.data.rows;
  331. this.$set(this.rules, "total", res.data.total);
  332. } catch (error) {}
  333. },
  334. submit() {
  335. this.$set(this.rules, "page", 1);
  336. this.$refs.searchForm.validate((valid) => {
  337. if (valid) {
  338. this.FetchList();
  339. }
  340. });
  341. },
  342. reset() {
  343. this.$refs.searchForm.resetFields();
  344. this.FetchList();
  345. },
  346. looker(row) {
  347. this.accompanyUrl = vaildTeachingUrl() + '/accompany?Authorization=' + getToken() + '&platform=web#/detail/' + row.id
  348. this.lookVisible = true
  349. // this.$nextTick(() => {
  350. // console.log(this.$refs.iframe)
  351. // let iframe = this.$refs.iframe
  352. // iframe.onload = function() {
  353. // console.log('完成', iframe)
  354. // iframe.contentWindow.document.querySelector('#tips-step-0').style.display = 'none'
  355. // }
  356. // })
  357. },
  358. player(row) {
  359. this.activeUrl = row.url;
  360. this.audioVisible = true;
  361. },
  362. async changeStatus(row) {
  363. try {
  364. let status = row.showFlag ? '停用' : '启用'
  365. await this.$confirm("是否确认"+ status +"此伴奏?", "提示", {
  366. type: "warning",
  367. });
  368. await Show({
  369. sysMusicScoreId: row.id,
  370. showFlag: row.showFlag ? 0 : 1
  371. })
  372. this.$message.success(status + "成功");
  373. this.FetchList();
  374. } catch (error) {}
  375. },
  376. edit(row) {
  377. this.detail = row;
  378. this.visible = true;
  379. },
  380. open(type) {
  381. this.type = type;
  382. this.detail = null;
  383. this.visible = true;
  384. },
  385. async remove(row) {
  386. try {
  387. await this.$confirm("是否确认删除此伴奏?", "提示", {
  388. type: "warning",
  389. });
  390. await Del(row.id);
  391. this.$message.success("删除成功");
  392. this.FetchList();
  393. } catch (error) {}
  394. },
  395. },
  396. };
  397. </script>
  398. <style lang="less" scoped>
  399. .remark {
  400. display: inline;
  401. overflow: hidden;
  402. white-space: pre;
  403. }
  404. .lookForm {
  405. /deep/.el-dialog__body {
  406. padding: 0;
  407. }
  408. }
  409. .iframe_back {
  410. width: 195px;
  411. height: 45px;
  412. position: absolute;
  413. bottom: 50px;
  414. background: transparent;
  415. left: 50%;
  416. z-index: 99;
  417. margin-left: -100px;
  418. }
  419. .iframe_help {
  420. position: absolute;
  421. background: transparent;
  422. width: 50px;
  423. height: 120px;
  424. top: 50%;
  425. right: 0;
  426. margin-top: -35px;
  427. }
  428. .iframe_header_back {
  429. background: transparent;
  430. width: 225px;
  431. height: 50px;
  432. position: absolute;
  433. top: 65px;
  434. left: 20px;
  435. }
  436. </style>