123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205 |
- <template>
- <div class="app-container">
- <!-- 表单 -->
- <el-form label-width="100px" :disabled="disabled">
- <el-form-item label="场景标题:">
- <el-input v-model="form.name" placeholder="请输入场景标题" />
- </el-form-item>
- <el-form-item label="场景副标题:">
- <el-input v-model="form.subName" placeholder="请输入场景副标题" />
- </el-form-item>
- <el-form-item label="场景封面:">
- <Upload listType="picture-card" :url="form.pic" @upload="upload($event, 'pic')" :disabled="disabled" />
- </el-form-item>
- <el-form-item label="专区背景图:">
- <Upload listType="picture-card" :url="form.backgroundPic" @upload="upload($event, 'backgroundPic')"
- :disabled="disabled" />
- </el-form-item>
- </el-form>
- <div class="form-btn" style="margin-bottom: 40px">
- <el-button @click="cancel">取消</el-button>
- <el-button v-if="!disabled" type="primary" @click="getSubmit">提交</el-button>
- </div>
- <el-form label-width="100px" :disabled="disabled">
- <el-form-item label="专区列表:" style="width: 1200px">
- <el-table :data="tableData" v-loading="loading" :default-sort="{prop: 'sort'}">
- <el-table-column label="排序" prop="sort" align="center" />
- <el-table-column label="标签名称" prop="name" align="center" />
- <el-table-column label="标签封面" align="center" width="100px">
- <template slot-scope="scope">
- <el-image v-if="scope.row.pic" :src="scope.row.pic" />
- </template>
- </el-table-column>
- <el-table-column label="歌单数量" prop="songCount" align="center" />
- <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.id, '查看')">查看</el-button>
- <el-button v-if="scope.row.status === 0" type="text" @click="getChange(scope.row, 1, '禁用')">禁用</el-button>
- <span v-else style="margin-left: 10px">
- <el-button type="text" @click="getDialog(scope.row.id, '编辑')">编辑</el-button>
- <el-button type="text" @click="getChange(scope.row, 0, '启用')">启用</el-button>
- <el-button type="delete" @click="getChange(scope.row, 2, '删除')">删除</el-button>
- </span>
- </template>
- </el-table-column>
- </el-table>
- <pagination v-show="total > 0" :total="total" :page.sync="form.pageNum" :limit.sync="form.pageSize"
- @pagination="getList" />
- </el-form-item>
- </el-form>
- <!-- 弹窗 -->
- <el-dialog :visible.sync="dialogVisible" :title="title" width="600px" :before-close="getClose">
- <el-form :model="dialogForm" ref="dialogForm" label-width="100px" :disabled="title === '查看' ? true : false">
- <el-form-item label="标签名称:" prop="name">
- <el-input v-model="dialogForm.name" placeholder="请输入标签名称" />
- </el-form-item>
- <el-form-item label="标签封面:" prop="pic">
- <Upload listType="picture-card" :url="dialogForm.pic" @upload="upload($event, 'pic')"
- :disabled="title === '查看' ? true : false" />
- </el-form-item>
- <el-form-item label="排序:" prop="sort">
- <el-input-number v-model="dialogForm.sort" step-strictly />
- </el-form-item>
- </el-form>
- <div slot="footer">
- <el-button @click="getClose">取消</el-button>
- <el-button v-if="title === '查看' ? false : true" type="primary" @click="getDetailSubmit">确定</el-button>
- </div>
- </el-dialog>
- </div>
- </template>
- <script>
- import { detail, edit, detailList, change, menuDetail, editMenu } from '@/api/operation/scene'
- import { disabledMixin } from '@/mixin/index'
- export default {
- mixins: [disabledMixin],
- data() {
- return {
- // 遮罩层
- loading: false,
- // 表单
- form: {},
- // 列表
- tableData: [],
- // 专区表单
- listForm: {
- pageNum: 1,
- pageSize: 10
- },
- total: 0,
- // 弹窗
- dialogVisible: false,
- title: '编辑',
- // 弹窗表单
- dialogForm: {},
- // 只读
- disabled: false
- }
- },
- mounted() {
- if (this.$route.query.id) {
- this.form.id = this.listForm.groupId = this.$route.query.id
- this.disabled = Boolean(this.$route.query.boolean)
- this.getDetail()
- this.getList()
- }
- },
- methods: {
- // 详情
- getDetail() {
- detail(this.form.id).then(res => {
- if (res.code === 0) {
- this.form = res.data
- }
- })
- },
- // 上传图片
- upload(e, key) {
- this.dialogVisible ? this.dialogForm[key] = e.file : this.form[key] = e.file
- },
- // 提交
- getSubmit() {
- edit(this.form).then(res => {
- if (res.code === 0) {
- this.$message.success('编辑成功!')
- this.cancel()
- }
- })
- },
- // 取消
- cancel() {
- this.$tab.closeOpenPage('/operation/scene')
- },
- // 专区列表
- getList() {
- this.loading = true
- detailList(this.listForm).then(res => {
- if (res.code === 0) {
- this.tableData = res.data.records
- this.total = res.data.total
- this.loading = false
- }
- })
- },
- // 上下架
- getChange(row, status, title) {
- this.$confirm(`是否${title}${row.name}?`, '提示', {
- type: 'warning'
- }).then(() => {
- change(row.id, 2, status).then(res => {
- if (res.code === 0) {
- this.$message.success(`${title}成功!`)
- this.getList()
- }
- })
- }).catch(() => { })
- },
- // 弹窗
- getDialog(id, title) {
- this.dialogVisible = true
- this.title = title
- menuDetail(id).then(res => {
- if(res.code === 0){
- this.dialogForm = res.data
- }
- })
- },
- // 关闭
- getClose(){
- this.dialogVisible = false
- this.$refs.dialogForm.resetFields()
- },
- // 确定
- getDetailSubmit() {
- editMenu(this.dialogForm).then(res => {
- if (res.code === 0) {
- this.$message.success('编辑成功!')
- this.dialogVisible = false
- this.getList()
- }
- })
- },
- // 字典翻译
- statusFormatter(row) {
- return this.selectDictLabel(this.disabledOptions, row.status)
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .el-form {
- width: 500px;
- }
- </style>
|