index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614
  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. <saveform
  15. ref="searchForm"
  16. :model.sync="searchForm"
  17. inline
  18. style="margin-top: 20px"
  19. >
  20. <el-form-item prop="search">
  21. <el-input
  22. v-model="searchForm.search"
  23. @submit="submit"
  24. @reset="reset"
  25. @keyup.enter.native="
  26. e => {
  27. e.target.blur();
  28. $refs.searchForm.save();
  29. submit();
  30. }
  31. "
  32. clearable
  33. placeholder="伴奏编号/伴奏名称"
  34. />
  35. </el-form-item>
  36. <el-form-item prop="categoriesId">
  37. <el-cascader
  38. ref="myCascader"
  39. popper-class="myCascader"
  40. @change="changeCategor"
  41. :show-all-levels="true"
  42. clearable
  43. v-model="searchForm.categoriesId"
  44. style="width: 100%"
  45. :options="tree"
  46. placeholder="请选择分类"
  47. :props="treeProps"
  48. ></el-cascader>
  49. </el-form-item>
  50. <el-form-item prop="subjectId">
  51. <el-select
  52. v-model="searchForm.subjectId"
  53. clearable
  54. placeholder="请选择声部"
  55. >
  56. <el-option
  57. v-for="item in selects.subjects"
  58. :value="item.id"
  59. :label="item.name"
  60. :key="item.id"
  61. ></el-option>
  62. </el-select>
  63. </el-form-item>
  64. <el-form-item prop="rankType">
  65. <el-select
  66. v-model="searchForm.rankType"
  67. clearable
  68. filterable
  69. placeholder="请选择是否收费"
  70. >
  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
  77. v-model="searchForm.showFlag"
  78. clearable
  79. filterable
  80. placeholder="请选择伴奏状态"
  81. >
  82. <el-option :value="1" label="启用"></el-option>
  83. <el-option :value="0" label="停用"></el-option>
  84. </el-select>
  85. </el-form-item> -->
  86. <el-form-item>
  87. <el-button @click="submit" type="primary">搜索</el-button>
  88. <el-button @click="reset" type="danger">重置</el-button>
  89. <!-- <el-button
  90. @click="onExport"
  91. type="primary"
  92. v-permission="'export/exportMusicScoreList'"
  93. >导出</el-button
  94. > -->
  95. </el-form-item>
  96. </saveform>
  97. <el-table
  98. style="width: 100%"
  99. :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
  100. :data="tableList"
  101. >
  102. <el-table-column align="center" prop="id" label="编号" width="120px">
  103. <template slot-scope="scope">
  104. <div>
  105. <copy-text>{{ scope.row.id }}</copy-text>
  106. </div>
  107. </template>
  108. </el-table-column>
  109. <el-table-column align="center" prop="name" label="名称" width="180px">
  110. <template slot-scope="scope">
  111. <div>
  112. <copy-text>{{ scope.row.name }}</copy-text>
  113. </div>
  114. </template>
  115. </el-table-column>
  116. <el-table-column
  117. align="center"
  118. prop="subjectName"
  119. label="所属声部"
  120. width="180px"
  121. >
  122. <template slot-scope="scope">
  123. <div>
  124. <Tooltip :content="scope.row.subjectName" />
  125. </div>
  126. </template>
  127. </el-table-column>
  128. <el-table-column align="center" prop="type" label="类型">
  129. <template slot-scope="scope">
  130. {{ scope.row.type | songUseTypeFormat }}
  131. </template>
  132. </el-table-column>
  133. <el-table-column
  134. align="center"
  135. prop="categoriesName"
  136. label="分类"
  137. width="180px"
  138. />
  139. <el-table-column align="center" label="是否收费">
  140. <template slot-scope="scope">
  141. {{ scope.row.rankIds ? "收费" : "免费" }}
  142. </template>
  143. </el-table-column>
  144. <el-table-column align="center" label="状态">
  145. <template slot-scope="scope">
  146. {{ scope.row.showFlag ? "启用" : "停用" }}
  147. </template>
  148. </el-table-column>
  149. <el-table-column align="center" prop="createUserName" label="上传人" />
  150. <el-table-column align="center" prop="createTime" label="上传时间" />
  151. <el-table-column
  152. align="center"
  153. width="180px"
  154. label="操作"
  155. fixed="right"
  156. >
  157. <template slot-scope="scope">
  158. <el-button type="text" @click="looker(scope.row, 1)"
  159. >预览</el-button
  160. >
  161. <el-button type="text" @click="changeStatus(scope.row)">{{
  162. scope.row.showFlag ? "停用" : "启用"
  163. }}</el-button>
  164. <!-- <el-button
  165. type="text"
  166. @click="transcod(scope.row)"
  167. :disabled="!!scope.row.showFlag"
  168. v-permission="'sysMusicScore/transcod'"
  169. >转码</el-button
  170. > -->
  171. <el-button
  172. type="text"
  173. @click="edit(scope.row)"
  174. :disabled="!!scope.row.showFlag"
  175. v-permission="'sysMusicScore/update'"
  176. >修改</el-button
  177. >
  178. <!-- <el-button
  179. type="text"
  180. @click="remove(scope.row)"
  181. v-permission="'sysMusicScore/del'"
  182. >删除</el-button
  183. > -->
  184. </template>
  185. </el-table-column>
  186. </el-table>
  187. <pagination
  188. sync
  189. :total.sync="rules.total"
  190. :page.sync="rules.page"
  191. :limit.sync="rules.limit"
  192. :page-sizes="rules.page_size"
  193. @pagination="FetchList"
  194. />
  195. </div>
  196. <el-dialog :title="title" :visible.sync="visible" width="1100px">
  197. <EditMusic
  198. v-if="visible"
  199. :tree="this.tree"
  200. @close="visible = false"
  201. @getList="FetchList"
  202. />
  203. </el-dialog>
  204. <el-dialog title="修改曲谱" :visible.sync="muiscVisible" width="500px">
  205. <EditExtra
  206. v-if="muiscVisible"
  207. :tree="this.tree"
  208. :detail="detail"
  209. @close="muiscVisible = false"
  210. @getList="FetchList"
  211. />
  212. </el-dialog>
  213. <el-dialog
  214. v-if="lookVisible"
  215. width="667px"
  216. class="lookForm"
  217. :visible.sync="lookVisible"
  218. title="预览"
  219. >
  220. <template slot="title">
  221. <span style="color: #fff;">预览</span>
  222. <el-select
  223. v-model="selectPart"
  224. placeholder="请选择分谱"
  225. @change="onPartChange"
  226. >
  227. <el-option
  228. v-for="(item, index) in parts"
  229. :key="item"
  230. :label="item"
  231. :value="index"
  232. >
  233. </el-option>
  234. </el-select>
  235. </template>
  236. <iframe
  237. id="iframe"
  238. v-if="lookVisible"
  239. style="width: 667px; height: 386px"
  240. ref="iframe"
  241. :src="accompanyUrl"
  242. />
  243. <div class="iframe_back"></div>
  244. <div class="iframe_help"></div>
  245. <div class="iframe_header_back"></div>
  246. </el-dialog>
  247. </div>
  248. </template>
  249. <script>
  250. import saveform from "@/components/save-form";
  251. import pagination from "@/components/Pagination/index";
  252. import { songUseType } from "@/constant";
  253. import {
  254. QueryPage,
  255. Del,
  256. api_sysMusicScoreState,
  257. queryTree,
  258. Transcod,
  259. musicSheetApplicationExtendStatus
  260. } from "./api";
  261. import form from "./modals/form";
  262. import EditMusic from "./modals/edit-music";
  263. import EditExtra from "./modals/edit-extra";
  264. import { vaildTeachingUrl } from "@/utils/validate";
  265. import { getToken } from "@/utils/auth";
  266. import deepClone from "@/helpers/deep-clone/";
  267. import Tooltip from "@/components/Tooltip/index";
  268. import { Export } from "@/utils/downLoadFile";
  269. import qs from "qs";
  270. import cleanDeep from "clean-deep";
  271. export default {
  272. name: "accompaniment",
  273. components: {
  274. saveform,
  275. pagination,
  276. "submit-form": form,
  277. Tooltip,
  278. EditMusic,
  279. EditExtra
  280. },
  281. data() {
  282. return {
  283. parts: [],
  284. selectPart: 0,
  285. tabName: "first",
  286. type: "",
  287. activeUrl: "",
  288. songUseType,
  289. lookVisible: false,
  290. lookNum: 0,
  291. lookRow: {},
  292. accompanyUrl: null, // 预览地址
  293. accompanyUrl2: null, // 预览地址
  294. tableList: [],
  295. searchForm: {
  296. search: "",
  297. // type: "",
  298. subjectId: "",
  299. categoriesId: [],
  300. clientType: "",
  301. rankType: null,
  302. showFlag: null
  303. },
  304. rules: {
  305. // 分页规则
  306. limit: 10, // 限制显示条数
  307. page: 1, // 当前页
  308. total: 0, // 总条数
  309. page_size: [10, 20, 40, 50] // 选择限制显示条数
  310. },
  311. detail: null,
  312. visible: false,
  313. muiscVisible: false,
  314. tree: [],
  315. treeProps: {
  316. value: "id",
  317. label: "name",
  318. children: "sysMusicScoreCategoriesList",
  319. checkStrictly: true,
  320. expandTrigger: "hover"
  321. }
  322. };
  323. },
  324. computed: {
  325. title() {
  326. const t1 = this.detail ? "修改" : "添加";
  327. // let t2 = this.type === "COMMON" ? "公用" : "个人";
  328. // if (this.detail) {
  329. // t2 = this.detail.type === "COMMON" ? "公用" : "个人";
  330. // }
  331. return t1 + "曲目";
  332. }
  333. },
  334. async mounted() {
  335. const { query, params } = this.$route;
  336. await this.FetchTree();
  337. if (params.categoriesId) {
  338. // console.log(this.tree)
  339. // console.log(this.formatParentId(params.categoriesId, this.tree))
  340. this.searchForm.categoriesId = this.formatParentId(
  341. params.categoriesId,
  342. this.tree
  343. );
  344. }
  345. this.$store.dispatch("setSubjects");
  346. this.$store.dispatch("setBranchs");
  347. await this.FetchList();
  348. // 点击Cascader label选中
  349. },
  350. methods: {
  351. formatParentId(id, list, ids = []) {
  352. for (const item of list) {
  353. if (item.sysMusicScoreCategoriesList) {
  354. const cIds = this.formatParentId(
  355. id,
  356. item.sysMusicScoreCategoriesList,
  357. [...ids, item.id]
  358. );
  359. if (cIds.includes(id)) {
  360. return cIds;
  361. }
  362. }
  363. if (item.id === id) {
  364. return [...ids, id];
  365. }
  366. }
  367. return ids;
  368. },
  369. async FetchTree() {
  370. try {
  371. const res = await queryTree();
  372. this.tree = res.data;
  373. this.formatTree(this.tree);
  374. } catch (error) {}
  375. },
  376. formatTree(data) {
  377. for (let i of data) {
  378. if (
  379. i.sysMusicScoreCategoriesList &&
  380. i.sysMusicScoreCategoriesList.length > 0
  381. ) {
  382. this.formatTree(i.sysMusicScoreCategoriesList, i);
  383. } else {
  384. i.sysMusicScoreCategoriesList = null;
  385. }
  386. }
  387. },
  388. async FetchList() {
  389. try {
  390. let { categoriesId, organId, ...search } = deepClone(this.searchForm);
  391. const res = await QueryPage({
  392. ...search,
  393. categoriesId:
  394. categoriesId && categoriesId.length > 0 ? categoriesId.pop() : null,
  395. page: this.rules.page,
  396. rows: this.rules.limit
  397. });
  398. this.tableList = res.data.rows;
  399. this.$set(this.rules, "total", res.data.total);
  400. } catch (error) {}
  401. },
  402. submit() {
  403. this.$set(this.rules, "page", 1);
  404. this.$refs.searchForm.validate(valid => {
  405. if (valid) {
  406. this.FetchList();
  407. }
  408. });
  409. },
  410. reset() {
  411. this.$refs.searchForm.resetFields();
  412. this.FetchList();
  413. },
  414. getPartListNames(xml) {
  415. if (!xml) return [];
  416. const xmlParse = new DOMParser().parseFromString(xml, "text/xml");
  417. const partList =
  418. xmlParse
  419. .getElementsByTagName("part-list")?.[0]
  420. ?.getElementsByTagName("score-part") || [];
  421. const partListNames = Array.from(partList).map(
  422. item => item.getElementsByTagName("part-name")?.[0].textContent || ""
  423. );
  424. this.xmlFirstSpeed =
  425. xmlParse.getElementsByTagName("per-minute")?.[0]?.textContent || "";
  426. return partListNames.filter(
  427. text => text.toLocaleUpperCase() !== "COMMON"
  428. );
  429. },
  430. async looker(row, num) {
  431. try {
  432. this.selectPart = 0;
  433. const res = await fetch(row.xmlUrl);
  434. const text = await res.text();
  435. this.parts = this.getPartListNames(text);
  436. } catch (error) {
  437. this.parts = [];
  438. this.selectPart = 0;
  439. }
  440. let url = location.origin + "/accompany-web/";
  441. if (/dayaedu.com/.test(location.origin)) {
  442. url = location.origin + "/accompany/";
  443. }
  444. url = "https://test.gym.lexiaoya.cn/accompany-web/";
  445. this.accompanyUrl =
  446. url +
  447. "?Authorization=" +
  448. getToken() +
  449. "&platform=web" +
  450. "#/detail/" +
  451. row.id +
  452. "?part-index=" +
  453. this.selectPart +
  454. "&isMove=1";
  455. this.lookVisible = true;
  456. this.lookNum = num;
  457. this.lookRow = row;
  458. // this.$nextTick(() => {
  459. // console.log(this.$refs.iframe)
  460. // let iframe = this.$refs.iframe
  461. // iframe.onload = function() {
  462. // console.log('完成', iframe)
  463. // iframe.contentWindow.document.querySelector('#tips-step-0').style.display = 'none'
  464. // }
  465. // })
  466. },
  467. onPartChange(val) {
  468. let url = location.origin + "/accompany-web/";
  469. if (/dayaedu.com/.test(location.origin)) {
  470. url = location.origin + "/accompany/";
  471. }
  472. // url +
  473. this.accompanyUrl =
  474. url +
  475. "?Authorization=" +
  476. getToken() +
  477. "&platform=web&isOpenMetronome=" +
  478. this.lookNum +
  479. "&t=" +
  480. new Date().getTime() +
  481. "#/detail/" +
  482. this.lookRow.id +
  483. "?part-index=" +
  484. val +
  485. "&isMove=1";
  486. },
  487. async changeStatus(row) {
  488. try {
  489. let status = row.showFlag ? "停用" : "启用";
  490. await this.$confirm("是否确认" + status + "此曲目?", "提示", {
  491. type: "warning"
  492. });
  493. await api_sysMusicScoreState(row.id);
  494. this.$message.success(status + "成功");
  495. this.FetchList();
  496. } catch (error) {}
  497. },
  498. edit(row) {
  499. this.detail = row;
  500. this.muiscVisible = true;
  501. },
  502. async transcod(row) {
  503. try {
  504. const res = await Transcod(row);
  505. console.log(res);
  506. } catch (error) {}
  507. },
  508. open(type) {
  509. this.type = type;
  510. this.detail = null;
  511. this.visible = true;
  512. },
  513. async remove(row) {
  514. try {
  515. await this.$confirm("是否确认删除此伴奏?", "提示", {
  516. type: "warning"
  517. });
  518. await Del(row.id);
  519. this.$message.success("删除成功");
  520. this.FetchList();
  521. } catch (error) {}
  522. },
  523. changeCategor(e) {
  524. this.$refs.myCascader.dropDownVisible = false;
  525. },
  526. onExport() {
  527. let { categoriesId, organId, ...search } = deepClone(this.searchForm);
  528. Export(
  529. this,
  530. {
  531. url: "/api-web/export/exportMusicScoreList",
  532. params: {
  533. ...search,
  534. categoriesId:
  535. categoriesId && categoriesId.length > 0
  536. ? categoriesId.pop()
  537. : null
  538. },
  539. fileName: `教学伴奏导出.xls`,
  540. method: "get"
  541. },
  542. "确定导出教学伴奏"
  543. );
  544. }
  545. }
  546. };
  547. </script>
  548. <style lang="less" scoped>
  549. .myCascader {
  550. .el-radio {
  551. width: 100%;
  552. height: 100%;
  553. z-index: 10;
  554. position: absolute;
  555. top: 10px;
  556. right: 10px;
  557. }
  558. .el-radio__input {
  559. visibility: hidden;
  560. }
  561. .el-cascader-node__postfix {
  562. top: 10px;
  563. }
  564. }
  565. ::v-deep .el-dropdown {
  566. margin-right: 10px;
  567. color: #14928a;
  568. }
  569. .remark {
  570. display: inline;
  571. overflow: hidden;
  572. white-space: pre;
  573. }
  574. .lookForm {
  575. ::v-deep .el-dialog__body {
  576. padding: 0;
  577. }
  578. }
  579. .iframe_back {
  580. width: 195px;
  581. height: 45px;
  582. position: absolute;
  583. bottom: 50px;
  584. background: transparent;
  585. left: 50%;
  586. z-index: 99;
  587. margin-left: -100px;
  588. }
  589. .iframe_help {
  590. position: absolute;
  591. background: transparent;
  592. width: 50px;
  593. height: 120px;
  594. top: 50%;
  595. right: 0;
  596. margin-top: -35px;
  597. }
  598. .iframe_header_back {
  599. background: transparent;
  600. width: 225px;
  601. height: 50px;
  602. position: absolute;
  603. top: 65px;
  604. left: 20px;
  605. }
  606. </style>