|
@@ -1,125 +1,87 @@
|
|
|
<template>
|
|
|
<div class="app-container">
|
|
|
<!-- 搜索 -->
|
|
|
- <el-form inline label-width="100px" size="mini">
|
|
|
+ <el-form inline size="mini">
|
|
|
+ <el-form-item label="主播名称:">
|
|
|
+ <el-input v-model="form.nickname" placeholder="请输入主播名称" clearable />
|
|
|
+ </el-form-item>
|
|
|
<el-form-item label="资源平台:">
|
|
|
- <el-select v-model="listForm.platformId" placeholder="请选择资源平台">
|
|
|
- <el-option v-for="item in platformOptions" :key="item.id" :label="item.name" :value="item.id" />
|
|
|
+ <el-select v-model="form.platformId" placeholder="请选择资源平台" clearable>
|
|
|
+ <el-option v-for="item in platformOptions" :key="item.value" :value="item.value"
|
|
|
+ :label="item.label" />
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="主播名称:">
|
|
|
- <el-input v-model="listForm.nickname" placeholder="请输入主播名称"></el-input>
|
|
|
+ <el-form-item label="当前状态:">
|
|
|
+ <el-select v-model="form.status" placeholder="请选择当前状态" clearable>
|
|
|
+ <el-option v-for="item in onOrOffOptions" :key="item.value" :value="item.value"
|
|
|
+ :label="item.label" />
|
|
|
+ </el-select>
|
|
|
</el-form-item>
|
|
|
<el-form-item>
|
|
|
<el-button type="primary" icon="el-icon-search" @click="getSearch">搜索</el-button>
|
|
|
<el-button icon="el-icon-refresh" @click="getRefresh">重置</el-button>
|
|
|
- <el-button type="primary" icon="el-icon-plus" plain @click="getDialog()">新增</el-button>
|
|
|
+ <el-button type="primary" plain icon="el-icon-plus" @click="getDetail()">新增</el-button>
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
<!-- 列表 -->
|
|
|
<el-table :data="tableData" v-loading="loading">
|
|
|
- <el-table-column prop="id" label="主播ID" align="center" />
|
|
|
- <el-table-column prop="nickname" label="主播名称" align="center" />
|
|
|
- <el-table-column prop="img" label="主播头像" align="center" width="100px">
|
|
|
+ <el-table-column label="ID" prop="id" align="center" />
|
|
|
+ <el-table-column label="主播名称" prop="nickname" align="center" />
|
|
|
+ <el-table-column label="主播头像" align="center" width="100px">
|
|
|
<template slot-scope="scope">
|
|
|
- <el-image :src="scope.row.avatar" />
|
|
|
+ <el-image v-if="scope.row.avatar" :src="scope.row.avatar" />
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
- <el-table-column prop="platformName" label="资源平台" align="center" />
|
|
|
+ <el-table-column label="资源平台" prop="platformId" align="center" :formatter="platformFormatter" />
|
|
|
+ <el-table-column label="当前状态" prop="status" align="center" :formatter="statusFormatter" />
|
|
|
<el-table-column label="操作" align="center">
|
|
|
<template slot-scope="scope">
|
|
|
- <el-button type="text" @click="getDialog(scope.row, '查看')">查看</el-button>
|
|
|
- <el-button v-if="scope.row.platformName !== '蜻蜓' && scope.row.platformName !== 'qq音乐'" type="text"
|
|
|
- @click="getDialog(scope.row, '编辑')">编辑</el-button>
|
|
|
- <el-button type="delete" @click="getDelete(scope.row)">删除</el-button>
|
|
|
+ <el-button type="text" @click="getDetail(scope.row.id, true)">查看</el-button>
|
|
|
+ <span v-if="scope.row.status === 2" style="margin: 0 10px">
|
|
|
+ <el-button type="text" @click="getDetail(scope.row.id)">编辑</el-button>
|
|
|
+ <el-button type="text" @click="getChange(scope.row, 1)">上架</el-button>
|
|
|
+ <el-button type="delete" @click="getDelete(scope.row)">删除</el-button>
|
|
|
+ </span>
|
|
|
+ <el-button v-else type="text" @click="getChange(scope.row, 2)">下架</el-button>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
|
- <!-- 分页 -->
|
|
|
- <pagination v-show="total>0" :total="total" :page.sync="listForm.pageIndex"
|
|
|
- :limit.sync="listForm.pageSize" @pagination="getList" />
|
|
|
- <!-- 弹窗 -->
|
|
|
- <el-dialog :title="title" :visible.sync="dialogVisible" width="600px">
|
|
|
- <el-form :model="submitForm" ref="submitForm" label-width="100px" :disabled="title === '查看'">
|
|
|
- <el-row>
|
|
|
- <el-col :span="12">
|
|
|
- <el-form-item label="主播头像:">
|
|
|
- <Upload listType="picture-card" :url="submitForm.avatar" @upload="getUpload"
|
|
|
- :disabled="title === '查看'" />
|
|
|
- </el-form-item>
|
|
|
- </el-col>
|
|
|
- <el-col :span="12">
|
|
|
- <el-form-item label="主播名称:">
|
|
|
- <el-input v-model="submitForm.nickname" placeholder="请输入主播名称" />
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="资源平台:">
|
|
|
- <el-select v-model="submitForm.platformId" placeholder="请选择资源平台">
|
|
|
- <el-option v-for="item in platformOptions" :key="item.id" :label="item.name" :value="item.id"
|
|
|
- :disabled="item.disabled" />
|
|
|
- </el-select>
|
|
|
- </el-form-item>
|
|
|
- </el-col>
|
|
|
- </el-row>
|
|
|
- <el-form-item label="主播简介:">
|
|
|
- <el-input v-model="submitForm.description" type="textarea" placeholder="请输入主播简介" rows="4">
|
|
|
- </el-input>
|
|
|
- </el-form-item>
|
|
|
- </el-form>
|
|
|
- <div slot="footer">
|
|
|
- <el-button @click="dialogVisible = false">取消</el-button>
|
|
|
- <el-button v-show="title !== '查看'" type="primary" @click="getSubmit">确定</el-button>
|
|
|
- </div>
|
|
|
- </el-dialog>
|
|
|
+ <pagination v-show="total>0" :total="total" :page.sync="form.pageNum" :limit.sync="form.pageSize"
|
|
|
+ @pagination="getList" />
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { getPlatformPage } from '@/api/music/platform'
|
|
|
-import { getPage, getAdd, getEdit, getDetail, getDelete } from '@/api/music/anchor'
|
|
|
-import Upload from "@/components/Upload/index";
|
|
|
+import { list, change } from '@/api/music/anchor'
|
|
|
+import { platformMixin, onOrOffMixin } from '@/mixin/index'
|
|
|
export default {
|
|
|
- components: {
|
|
|
- Upload,
|
|
|
- },
|
|
|
+ name: 'Anchor',
|
|
|
+ mixins: [platformMixin, onOrOffMixin],
|
|
|
data() {
|
|
|
return {
|
|
|
// 遮罩层
|
|
|
loading: false,
|
|
|
+ // 音频类型
|
|
|
+ audioType: 12,
|
|
|
// 表单
|
|
|
- listForm: {
|
|
|
- pageIndex: 1,
|
|
|
+ form: {
|
|
|
+ pageNum: 1,
|
|
|
pageSize: 10
|
|
|
},
|
|
|
+ // 总数据
|
|
|
total: 0,
|
|
|
// 列表
|
|
|
- tableData: [],
|
|
|
- // 弹窗
|
|
|
- dialogVisible: false,
|
|
|
- title: '',
|
|
|
- // 表单
|
|
|
- submitForm: {},
|
|
|
- // 资源平台
|
|
|
- platformOptions: [],
|
|
|
- };
|
|
|
+ tableData: []
|
|
|
+ }
|
|
|
},
|
|
|
- async mounted() {
|
|
|
- // 资源平台列表
|
|
|
- getPlatformPage({
|
|
|
- pageIndex: 1,
|
|
|
- pageSize: 10
|
|
|
- }).then(res => {
|
|
|
- if (res.code === 0) {
|
|
|
- this.platformOptions = res.data.records
|
|
|
- this.platformOptions.find(i => i.name === '蜻蜓').disabled = true
|
|
|
- this.platformOptions.find(i => i.name === 'qq音乐').disabled = true
|
|
|
- }
|
|
|
- })
|
|
|
- await this.getList()
|
|
|
+ mounted() {
|
|
|
+ this.getList()
|
|
|
},
|
|
|
methods: {
|
|
|
+ // 列表
|
|
|
getList() {
|
|
|
this.loading = true
|
|
|
- getPage(this.listForm).then(res => {
|
|
|
+ list(this.form).then(res => {
|
|
|
if (res.code === 0) {
|
|
|
this.tableData = res.data.records
|
|
|
this.total = res.data.total
|
|
@@ -128,69 +90,73 @@ export default {
|
|
|
})
|
|
|
},
|
|
|
|
|
|
- // 打开弹窗
|
|
|
- getDialog(e, key) {
|
|
|
- this.dialogVisible = true;
|
|
|
- key ? this.title = key : [this.title = '新增', this.submitForm = {}]
|
|
|
- if (e) {
|
|
|
- getDetail({ id: e.id }).then(res => {
|
|
|
- if (res.code === 0) {
|
|
|
- this.submitForm = res.data
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- },
|
|
|
-
|
|
|
// 搜索
|
|
|
getSearch() {
|
|
|
- this.listForm.pageIndex = 1
|
|
|
+ this.form.pageNum = 1
|
|
|
this.getList()
|
|
|
},
|
|
|
|
|
|
// 重置
|
|
|
getRefresh() {
|
|
|
- this.listForm = {
|
|
|
- pageIndex: 1,
|
|
|
+ this.form = {
|
|
|
+ pageNum: 1,
|
|
|
pageSize: 10
|
|
|
}
|
|
|
this.getList()
|
|
|
},
|
|
|
|
|
|
- // 上传
|
|
|
- getUpload(e) {
|
|
|
- this.submitForm.avatar = e.file
|
|
|
- },
|
|
|
-
|
|
|
- // 删除
|
|
|
- getDelete(row) {
|
|
|
- getDelete({ id: row.id }).then(res => {
|
|
|
- if (res.code === 0) {
|
|
|
- this.$message.success('删除成功!')
|
|
|
- this.getList()
|
|
|
+ // 新增 查看 编辑
|
|
|
+ getDetail(id, boolean) {
|
|
|
+ this.$router.push({
|
|
|
+ path: `/music/anchor/detail`,
|
|
|
+ query: {
|
|
|
+ id: id,
|
|
|
+ disabled: boolean
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
|
|
|
- // 确定
|
|
|
- getSubmit() {
|
|
|
- if (this.title === '新增') {
|
|
|
- getAdd(this.submitForm).then(res => {
|
|
|
+ // 上下架
|
|
|
+ getChange(row, status) {
|
|
|
+ let title = status === 1 ? '上架' : '下架'
|
|
|
+ this.$confirm(`是否${title}${row.nickname}?`, '提示', {
|
|
|
+ type: 'warning'
|
|
|
+ }).then(() => {
|
|
|
+ change(row.id, status).then(res => {
|
|
|
if (res.code === 0) {
|
|
|
- this.$message.success('新增成功!')
|
|
|
- this.dialogVisible = false
|
|
|
+ this.$message.success(`${title}成功!`)
|
|
|
this.getList()
|
|
|
}
|
|
|
})
|
|
|
- } else {
|
|
|
- getEdit(this.submitForm).then(res => {
|
|
|
+ }).catch(() => { })
|
|
|
+ },
|
|
|
+
|
|
|
+ // 删除
|
|
|
+ getDelete(row) {
|
|
|
+ this.$confirm(`是否删除${row.nickname}?`, '提示', {
|
|
|
+ type: 'warning'
|
|
|
+ }).then(() => {
|
|
|
+ remove(row.id).then(res => {
|
|
|
if (res.code === 0) {
|
|
|
- this.$message.success('修改成功!')
|
|
|
- this.dialogVisible = false
|
|
|
+ this.$message.success('删除成功!')
|
|
|
this.getList()
|
|
|
}
|
|
|
})
|
|
|
- }
|
|
|
+ }).catch(() => { })
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+ // 字典翻译
|
|
|
+ platformFormatter(row) {
|
|
|
+ return this.selectDictLabel(this.platformOptions, row.platformId)
|
|
|
+ },
|
|
|
+
|
|
|
+ statusFormatter(row) {
|
|
|
+ return this.selectDictLabel(this.onOrOffOptions, row.status)
|
|
|
}
|
|
|
- },
|
|
|
-};
|
|
|
-</script>
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+</style>
|