index.vue 13 KB

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