123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465 |
- <template>
- <div class="m-container">
- <h2>
- <div class="squrt"></div>
- 教学伴奏
- </h2>
- <div class="m-core">
- <el-button
- @click="open('COMMON')"
- type="primary"
- v-permission="'sysMusicScore/add'"
- >添加公用伴奏</el-button
- >
- <!-- <el-button @click="open('PERSON')" type="primary" v-permission="'sysMusicScore/add'">添加个人伴奏</el-button> -->
- <saveform
- ref="searchForm"
- :model.sync="searchForm"
- inline
- style="margin-top: 20px"
- >
- <el-form-item prop="search">
- <el-input
- v-model="searchForm.search"
- clearable
- placeholder="伴奏编号/伴奏名称"
- />
- </el-form-item>
- <el-form-item prop="type">
- <el-select
- v-model="searchForm.type"
- clearable
- placeholder="请选择类型"
- >
- <el-option
- v-for="(item, key) in songUseType"
- :key="key"
- :label="item"
- :value="key"
- ></el-option>
- </el-select>
- </el-form-item>
- <el-form-item prop="clientType">
- <el-select v-model="searchForm.clientType" clearable filterable placeholder="请选择客户端类型">
- <el-option value="NETWORK_ROOM" label="网络教室" ></el-option>
- <el-option value="SMART_PRACTICE" label="智能陪练" ></el-option>
- </el-select>
- </el-form-item>
- <el-form-item prop="categoriesId">
- <el-cascader v-model="searchForm.categoriesId"
- style="width:100%"
- :options="tree"
- placeholder="请选择分类"
- clearable
- :show-all-levels="true"
- :props="treeProps"></el-cascader>
- </el-form-item>
- <!-- <el-form-item
- prop="subjectId"
- >
- <el-select v-model="searchForm.subjectId" clearable placeholder="请选择声部">
- <el-option
- v-for="item in selects.subjects"
- :value="item.id"
- :label="item.name"
- :key="item.id"
- ></el-option>
- </el-select>
- </el-form-item> -->
- <el-form-item prop="rankType">
- <el-select v-model="searchForm.rankType" clearable filterable placeholder="请选择是否收费">
- <el-option :value="0" label="免费"></el-option>
- <el-option :value="1" label="收费"></el-option>
- </el-select>
- </el-form-item>
- <el-form-item prop="showFlag">
- <el-select v-model="searchForm.showFlag" clearable filterable placeholder="请选择伴奏状态">
- <el-option :value="1" label="启用"></el-option>
- <el-option :value="0" label="停用"></el-option>
- </el-select>
- </el-form-item>
- <el-form-item>
- <el-button @click="submit" type="primary">搜索</el-button>
- <el-button @click="reset" type="danger">重置</el-button>
- </el-form-item>
- </saveform>
- <el-table
- style="width: 100%"
- :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
- :data="tableList"
- >
- <el-table-column align="center" prop="id" label="编号">
- <template slot-scope="scope">
- <div>
- <copy-text>{{ scope.row.id }}</copy-text>
- </div>
- </template>
- </el-table-column>
- <el-table-column align="center" prop="name" label="名称" width="180px">
- <template slot-scope="scope">
- <div>
- <copy-text>{{ scope.row.name }}</copy-text>
- </div>
- </template>
- </el-table-column>
- <el-table-column align="center" prop="type" label="类型">
- <template slot-scope="scope">
- {{ scope.row.type | songUseTypeFormat }}
- </template>
- </el-table-column>
- <!-- <el-table-column
- align="center"
- prop="subjectNames"
- label="声部"
- width="180px"
- >
- <template slot-scope="scope">
- <el-tooltip class="item" effect="dark" :content="scope.row.subjectNames">
- <div class="remark">{{scope.row.subjectNames}}</div>
- </el-tooltip>
- </template>
- </el-table-column>
- <el-table-column
- align="center"
- prop="speed"
- label="速度"
- /> -->
- <el-table-column
- align="center"
- prop="categoriesName"
- label="分类"
- width="180px"
- />
- <el-table-column
- align="center"
- label="是否收费"
- width="180px"
- >
- <template slot-scope="scope">
- {{ scope.row.rankIds ? '收费' : '免费' }}
- </template>
- </el-table-column>
- <el-table-column
- align="center"
- label="节拍器"
- width="180px"
- >
- <template slot-scope="scope">
- {{ scope.row.isOpenMetronome ? '播放' : '不播放' }}
- </template>
- </el-table-column>
- <el-table-column
- align="center"
- label="伴奏状态"
- width="180px"
- >
- <template slot-scope="scope">
- {{ scope.row.showFlag ? '启用' : '停用' }}
- </template>
- </el-table-column>
- <el-table-column
- align="center"
- prop="categoriesName"
- label="客户端类型"
- width="180px"
- >
- <template slot-scope="scope">
- <div>
- {{scope.row.clientType | clientType}}
- </div>
- </template>
- </el-table-column>
- <!-- clientType -->
- <el-table-column
- align="center"
- prop="createUserName"
- label="上传人"
- width="180px"
- />
- <el-table-column
- align="center"
- prop="createTime"
- label="上传时间"
- width="180px"
- />
- <el-table-column
- align="center"
- width="180px"
- label="操作"
- fixed="right"
- >
- <template slot-scope="scope">
- <el-button
- type="text"
- @click="looker(scope.row)"
- :disabled="!scope.row.url || scope.row.clientType != 'SMART_PRACTICE'"
- >预览</el-button
- >
- <el-button
- type="text"
- @click="player(scope.row)"
- :disabled="!scope.row.url"
- >播放</el-button
- >
- <el-button
- type="text"
- @click="changeStatus(scope.row)"
- >{{ scope.row.showFlag ? '停用' : '启用' }}</el-button>
- <el-button
- type="text"
- @click="edit(scope.row)"
- :disabled="!!scope.row.showFlag"
- v-permission="'sysMusicScore/update'"
- >修改</el-button
- >
- <el-button
- type="text"
- @click="remove(scope.row)"
- v-permission="'sysMusicScore/del'"
- >删除</el-button
- >
- </template>
- </el-table-column>
- </el-table>
- <pagination
- sync
- :total.sync="rules.total"
- :page.sync="rules.page"
- :limit.sync="rules.limit"
- :page-sizes="rules.page_size"
- @pagination="FetchList"
- />
- </div>
- <el-dialog
- v-if="audioVisible"
- width="400px"
- :visible.sync="audioVisible"
- title="播放伴奏"
- >
- <audio style="display: block; margin: auto" controls :src="activeUrl" />
- </el-dialog>
- <el-dialog
- :title="title"
- :visible.sync="visible"
- width="740px"
- v-if="visible"
- >
- <submit-form
- :detail="detail"
- :type="type"
- @submited="FetchList"
- @close="visible = false"
- />
- </el-dialog>
- <el-dialog
- v-if="lookVisible"
- width="667px"
- class="lookForm"
- :visible.sync="lookVisible"
- title="预览"
- >
- <iframe id="iframe" v-if="lookVisible" style="width: 667px; height: 386px" ref="iframe" :src="accompanyUrl" />
- <div class="iframe_back"></div>
- <div class="iframe_help"></div>
- <div class="iframe_header_back"></div>
- </el-dialog>
- </div>
- </template>
- <script>
- import saveform from "@/components/save-form";
- import pagination from "@/components/Pagination/index";
- import { songUseType } from "@/constant";
- import { QueryPage, Del, Show, queryTree } from "./api";
- import form from "./modals/form";
- import { vaildTeachingUrl } from '@/utils/validate'
- import { getToken } from '@/utils/auth'
- import deepClone from '@/helpers/deep-clone/'
- export default {
- name: "accompaniment",
- components: {
- saveform,
- pagination,
- "submit-form": form,
- },
- data() {
- return {
- type: "",
- activeUrl: "",
- songUseType,
- lookVisible: false,
- accompanyUrl: null, // 预览地址
- audioVisible: false,
- tableList: [],
- searchForm: {
- search: "",
- type: "",
- subjectId: "",
- categoriesId: null,
- clientType:'',
- rankType: null,
- showFlag: null
- },
- rules: {
- // 分页规则
- limit: 10, // 限制显示条数
- page: 1, // 当前页
- total: 0, // 总条数
- page_size: [10, 20, 40, 50], // 选择限制显示条数
- },
- detail: null,
- visible: false,
- tree: [],
- treeProps: {
- value: 'id',
- label: 'name',
- children: 'sysMusicScoreCategoriesList',
- checkStrictly: true
- }
- };
- },
- computed: {
- title() {
- const t1 = this.detail ? "修改" : "添加";
- let t2 = this.type === "COMMON" ? "公用" : "个人";
- if (this.detail) {
- t2 = this.detail.type === "COMMON" ? "公用" : "个人";
- }
- return t1 + t2 + "伴奏";
- },
- },
- async mounted() {
- const { query,params } = this.$route;
- if(params.categoriesId){
- this.searchForm.categoriesId = [params.categoriesId];
- }
- this.$store.dispatch("setSubjects");
- await this.FetchTree()
- await this.FetchList();
- },
- methods: {
- async FetchTree() {
- try {
- const res = await queryTree()
- this.tree = res.data
- } catch (error) {
- }
- },
- async FetchList() {
- try {
- let { categoriesId, ...search } = deepClone(this.searchForm)
- const res = await QueryPage({
- ...search,
- categoriesId: categoriesId && categoriesId.length > 0 ? categoriesId.pop() : null,
- page: this.rules.page,
- rows: this.rules.limit,
- });
- this.tableList = res.data.rows;
- this.$set(this.rules, "total", res.data.total);
- } catch (error) {}
- },
- submit() {
- this.$set(this.rules, "page", 1);
- this.$refs.searchForm.validate((valid) => {
- if (valid) {
- this.FetchList();
- }
- });
- },
- reset() {
- this.$refs.searchForm.resetFields();
- this.FetchList();
- },
- looker(row) {
- this.accompanyUrl = vaildTeachingUrl() + '/accompany?Authorization=' + getToken() + '&platform=web#/detail/' + row.id
- this.lookVisible = true
- // this.$nextTick(() => {
- // console.log(this.$refs.iframe)
- // let iframe = this.$refs.iframe
- // iframe.onload = function() {
- // console.log('完成', iframe)
- // iframe.contentWindow.document.querySelector('#tips-step-0').style.display = 'none'
- // }
- // })
- },
- player(row) {
- this.activeUrl = row.url;
- this.audioVisible = true;
- },
- async changeStatus(row) {
- try {
- let status = row.showFlag ? '停用' : '启用'
- await this.$confirm("是否确认"+ status +"此伴奏?", "提示", {
- type: "warning",
- });
- await Show({
- sysMusicScoreId: row.id,
- showFlag: row.showFlag ? 0 : 1
- })
- this.$message.success(status + "成功");
- this.FetchList();
- } catch (error) {}
- },
- edit(row) {
- this.detail = row;
- this.visible = true;
- },
- open(type) {
- this.type = type;
- this.detail = null;
- this.visible = true;
- },
- async remove(row) {
- try {
- await this.$confirm("是否确认删除此伴奏?", "提示", {
- type: "warning",
- });
- await Del(row.id);
- this.$message.success("删除成功");
- this.FetchList();
- } catch (error) {}
- },
- },
- };
- </script>
- <style lang="less" scoped>
- .remark {
- display: inline;
- overflow: hidden;
- white-space: pre;
- }
- .lookForm {
- /deep/.el-dialog__body {
- padding: 0;
- }
- }
- .iframe_back {
- width: 195px;
- height: 45px;
- position: absolute;
- bottom: 50px;
- background: transparent;
- left: 50%;
- z-index: 99;
- margin-left: -100px;
- }
- .iframe_help {
- position: absolute;
- background: transparent;
- width: 50px;
- height: 120px;
- top: 50%;
- right: 0;
- margin-top: -35px;
- }
- .iframe_header_back {
- background: transparent;
- width: 225px;
- height: 50px;
- position: absolute;
- top: 65px;
- left: 20px;
- }
- </style>
|