index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456
  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.showFlag ? '启用' : '停用' }}
  149. </template>
  150. </el-table-column>
  151. <el-table-column
  152. align="center"
  153. prop="categoriesName"
  154. label="客户端类型"
  155. width="180px"
  156. >
  157. <template slot-scope="scope">
  158. <div>
  159. {{scope.row.clientType | clientType}}
  160. </div>
  161. </template>
  162. </el-table-column>
  163. <!-- clientType -->
  164. <el-table-column
  165. align="center"
  166. prop="createUserName"
  167. label="上传人"
  168. width="180px"
  169. />
  170. <el-table-column
  171. align="center"
  172. prop="createTime"
  173. label="上传时间"
  174. width="180px"
  175. />
  176. <el-table-column
  177. align="center"
  178. width="180px"
  179. label="操作"
  180. fixed="right"
  181. >
  182. <template slot-scope="scope">
  183. <el-button
  184. type="text"
  185. @click="looker(scope.row)"
  186. :disabled="!scope.row.url || scope.row.clientType != 'SMART_PRACTICE'"
  187. >预览</el-button
  188. >
  189. <el-button
  190. type="text"
  191. @click="player(scope.row)"
  192. :disabled="!scope.row.url"
  193. >播放</el-button
  194. >
  195. <el-button
  196. type="text"
  197. @click="changeStatus(scope.row)"
  198. >{{ scope.row.showFlag ? '停用' : '启用' }}</el-button>
  199. <el-button
  200. type="text"
  201. @click="edit(scope.row)"
  202. :disabled="!!scope.row.showFlag"
  203. v-permission="'sysMusicScore/update'"
  204. >修改</el-button
  205. >
  206. <el-button
  207. type="text"
  208. @click="remove(scope.row)"
  209. v-permission="'sysMusicScore/del'"
  210. >删除</el-button
  211. >
  212. </template>
  213. </el-table-column>
  214. </el-table>
  215. <pagination
  216. sync
  217. :total.sync="rules.total"
  218. :page.sync="rules.page"
  219. :limit.sync="rules.limit"
  220. :page-sizes="rules.page_size"
  221. @pagination="FetchList"
  222. />
  223. </div>
  224. <el-dialog
  225. v-if="audioVisible"
  226. width="400px"
  227. :visible.sync="audioVisible"
  228. title="播放伴奏"
  229. >
  230. <audio style="display: block; margin: auto" controls :src="activeUrl" />
  231. </el-dialog>
  232. <el-dialog
  233. :title="title"
  234. :visible.sync="visible"
  235. width="700px"
  236. v-if="visible"
  237. >
  238. <submit-form
  239. :detail="detail"
  240. :type="type"
  241. @submited="FetchList"
  242. @close="visible = false"
  243. />
  244. </el-dialog>
  245. <el-dialog
  246. v-if="lookVisible"
  247. width="667px"
  248. class="lookForm"
  249. :visible.sync="lookVisible"
  250. title="预览"
  251. >
  252. <iframe id="iframe" v-if="lookVisible" style="width: 667px; height: 386px" ref="iframe" :src="accompanyUrl" />
  253. <div class="iframe_back"></div>
  254. <div class="iframe_help"></div>
  255. <div class="iframe_header_back"></div>
  256. </el-dialog>
  257. </div>
  258. </template>
  259. <script>
  260. import saveform from "@/components/save-form";
  261. import pagination from "@/components/Pagination/index";
  262. import { songUseType } from "@/constant";
  263. import { QueryPage, Del, Show, queryTree } from "./api";
  264. import form from "./modals/form";
  265. import { vaildTeachingUrl } from '@/utils/validate'
  266. import { getToken } from '@/utils/auth'
  267. import deepClone from '@/helpers/deep-clone/'
  268. export default {
  269. name: "accompaniment",
  270. components: {
  271. saveform,
  272. pagination,
  273. "submit-form": form,
  274. },
  275. data() {
  276. return {
  277. type: "",
  278. activeUrl: "",
  279. songUseType,
  280. lookVisible: false,
  281. accompanyUrl: null, // 预览地址
  282. audioVisible: false,
  283. tableList: [],
  284. searchForm: {
  285. search: "",
  286. type: "",
  287. subjectId: "",
  288. categoriesId: null,
  289. clientType:'',
  290. rankType: null,
  291. showFlag: null
  292. },
  293. rules: {
  294. // 分页规则
  295. limit: 10, // 限制显示条数
  296. page: 1, // 当前页
  297. total: 0, // 总条数
  298. page_size: [10, 20, 40, 50], // 选择限制显示条数
  299. },
  300. detail: null,
  301. visible: false,
  302. tree: [],
  303. treeProps: {
  304. value: 'id',
  305. label: 'name',
  306. children: 'sysMusicScoreCategoriesList',
  307. checkStrictly: true
  308. }
  309. };
  310. },
  311. computed: {
  312. title() {
  313. const t1 = this.detail ? "修改" : "添加";
  314. let t2 = this.type === "COMMON" ? "公用" : "个人";
  315. if (this.detail) {
  316. t2 = this.detail.type === "COMMON" ? "公用" : "个人";
  317. }
  318. return t1 + t2 + "伴奏";
  319. },
  320. },
  321. async mounted() {
  322. const { query,params } = this.$route;
  323. if(params.categoriesId){
  324. this.searchForm.categoriesId = [params.categoriesId];
  325. }
  326. this.$store.dispatch("setSubjects");
  327. await this.FetchTree()
  328. await this.FetchList();
  329. },
  330. methods: {
  331. async FetchTree() {
  332. try {
  333. const res = await queryTree()
  334. this.tree = res.data
  335. } catch (error) {
  336. }
  337. },
  338. async FetchList() {
  339. try {
  340. let { categoriesId, ...search } = deepClone(this.searchForm)
  341. const res = await QueryPage({
  342. ...search,
  343. categoriesId: categoriesId && categoriesId.length > 0 ? categoriesId.pop() : null,
  344. page: this.rules.page,
  345. rows: this.rules.limit,
  346. });
  347. this.tableList = res.data.rows;
  348. this.$set(this.rules, "total", res.data.total);
  349. } catch (error) {}
  350. },
  351. submit() {
  352. this.$set(this.rules, "page", 1);
  353. this.$refs.searchForm.validate((valid) => {
  354. if (valid) {
  355. this.FetchList();
  356. }
  357. });
  358. },
  359. reset() {
  360. this.$refs.searchForm.resetFields();
  361. this.FetchList();
  362. },
  363. looker(row) {
  364. this.accompanyUrl = vaildTeachingUrl() + '/accompany?Authorization=' + getToken() + '&platform=web#/detail/' + row.id
  365. this.lookVisible = true
  366. // this.$nextTick(() => {
  367. // console.log(this.$refs.iframe)
  368. // let iframe = this.$refs.iframe
  369. // iframe.onload = function() {
  370. // console.log('完成', iframe)
  371. // iframe.contentWindow.document.querySelector('#tips-step-0').style.display = 'none'
  372. // }
  373. // })
  374. },
  375. player(row) {
  376. this.activeUrl = row.url;
  377. this.audioVisible = true;
  378. },
  379. async changeStatus(row) {
  380. try {
  381. let status = row.showFlag ? '停用' : '启用'
  382. await this.$confirm("是否确认"+ status +"此伴奏?", "提示", {
  383. type: "warning",
  384. });
  385. await Show({
  386. sysMusicScoreId: row.id,
  387. showFlag: row.showFlag ? 0 : 1
  388. })
  389. this.$message.success(status + "成功");
  390. this.FetchList();
  391. } catch (error) {}
  392. },
  393. edit(row) {
  394. this.detail = row;
  395. this.visible = true;
  396. },
  397. open(type) {
  398. this.type = type;
  399. this.detail = null;
  400. this.visible = true;
  401. },
  402. async remove(row) {
  403. try {
  404. await this.$confirm("是否确认删除此伴奏?", "提示", {
  405. type: "warning",
  406. });
  407. await Del(row.id);
  408. this.$message.success("删除成功");
  409. this.FetchList();
  410. } catch (error) {}
  411. },
  412. },
  413. };
  414. </script>
  415. <style lang="less" scoped>
  416. .remark {
  417. display: inline;
  418. overflow: hidden;
  419. white-space: pre;
  420. }
  421. .lookForm {
  422. /deep/.el-dialog__body {
  423. padding: 0;
  424. }
  425. }
  426. .iframe_back {
  427. width: 195px;
  428. height: 45px;
  429. position: absolute;
  430. bottom: 50px;
  431. background: transparent;
  432. left: 50%;
  433. z-index: 99;
  434. margin-left: -100px;
  435. }
  436. .iframe_help {
  437. position: absolute;
  438. background: transparent;
  439. width: 50px;
  440. height: 120px;
  441. top: 50%;
  442. right: 0;
  443. margin-top: -35px;
  444. }
  445. .iframe_header_back {
  446. background: transparent;
  447. width: 225px;
  448. height: 50px;
  449. position: absolute;
  450. top: 65px;
  451. left: 20px;
  452. }
  453. </style>