119 lines
3.9 KiB
Vue
119 lines
3.9 KiB
Vue
<template>
|
|
<el-dialog :title="title" :visible.sync="Visible" width="700px" center class="ac-dialog" :close-on-click-modal="false" @close="close">
|
|
<el-form :inline="true" :model="form" :rules="rules" ref="ruleForm" class="demo-form-inline" label-width="90px" label-position="right">
|
|
<el-row :gutter="24">
|
|
<el-col :xs="12" :sm="12" :md="12" :lg="12" :xl="12">
|
|
<el-form-item label="漫画id" prop="comicsId">
|
|
<el-input v-model.number="form.comicsId" placeholder="请输入漫画id" />
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col :xs="12" :sm="12" :md="12" :lg="12" :xl="12">
|
|
<el-form-item label="视频id" prop="mediaId">
|
|
<el-input v-model.number="form.mediaId" placeholder="请输入视频id" />
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col :xs="12" :sm="12" :md="12" :lg="12" :xl="12">
|
|
<el-form-item label="第几集" prop="num">
|
|
<el-input v-model.number="form.num" placeholder="请输入第几集" />
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col :xs="12" :sm="12" :md="12" :lg="12" :xl="12">
|
|
<el-form-item label="排序" prop="rank">
|
|
<el-input v-model.number="form.rank" placeholder="请输入排序" />
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col :xs="12" :sm="12" :md="12" :lg="12" :xl="12">
|
|
<el-form-item label="是否启用" prop="status">
|
|
<el-switch v-model="form.status" active-color="#13ce66" inactive-color="#ff4949" active-text="开启" inactive-text="关闭"></el-switch>
|
|
</el-form-item>
|
|
</el-col>
|
|
</el-row>
|
|
</el-form>
|
|
<div slot="footer" class="dialog-footer">
|
|
<el-button @click="Visible = false"> 取 消 </el-button>
|
|
<el-button type="primary" @click="submit('ruleForm')"> 确 定 </el-button>
|
|
</div>
|
|
</el-dialog>
|
|
</template>
|
|
<script>
|
|
import { comicsmediaAdd, comicsmediaUpdate } from '@/api/comicsManagement/comicsVideo'
|
|
import UploadImg from '@/components/UploadImg/index'
|
|
export default {
|
|
name: 'AddOrEdit',
|
|
props: ['data'],
|
|
components: {
|
|
UploadImg
|
|
},
|
|
data() {
|
|
return {
|
|
Visible: true,
|
|
title: '',
|
|
// 表单数据
|
|
form: {
|
|
comicsId: undefined, // 漫画id
|
|
mediaId: undefined, // 视频id,
|
|
num: undefined, // 第几集,
|
|
rank: undefined, // 排序,
|
|
status: undefined // 是否启用
|
|
},
|
|
rules: {}
|
|
}
|
|
},
|
|
|
|
mounted() {
|
|
this.title = this.data.title
|
|
if (this.title === '编辑') {
|
|
this.form = { ...this.data.data }
|
|
}
|
|
},
|
|
methods: {
|
|
add(data) {
|
|
comicsmediaAdd(data).then((res) => {
|
|
if (res.code === 200) {
|
|
this.$message.success('新增成功')
|
|
this.Visible = false
|
|
} else {
|
|
this.$message.error('新增失败')
|
|
}
|
|
})
|
|
},
|
|
update(data) {
|
|
comicsmediaUpdate(data).then((res) => {
|
|
if (res.code === 200) {
|
|
this.$message.success('更新成功')
|
|
this.Visible = false
|
|
} else {
|
|
this.$message.error('更新失败')
|
|
}
|
|
})
|
|
},
|
|
changeCoverImg(data) {
|
|
this.form.avatar = data
|
|
},
|
|
onRemove(data) {
|
|
this.form[data] = undefined
|
|
},
|
|
// 提交按钮
|
|
submit(formName) {
|
|
this.$refs[formName].validate((valid) => {
|
|
if (valid) {
|
|
if (this.title === '新增') {
|
|
this.add(this.form)
|
|
} else if (this.title === '编辑') {
|
|
this.update(this.form)
|
|
}
|
|
} else {
|
|
return false
|
|
}
|
|
})
|
|
},
|
|
|
|
// 关闭编辑
|
|
close() {
|
|
this.$emit('close')
|
|
},
|
|
},
|
|
}
|
|
</script>
|
|
|
|
|