|
@@ -0,0 +1,312 @@
|
|
|
+<template>
|
|
|
+ <div>
|
|
|
+ <el-dialog
|
|
|
+ :title="exData.id ? '编辑': '新增'"
|
|
|
+ :visible.sync="dialog"
|
|
|
+ width="900px"
|
|
|
+ :close-on-click-modal="false"
|
|
|
+ top="50px">
|
|
|
+ <el-form
|
|
|
+ ref="form"
|
|
|
+ :model="form"
|
|
|
+ :rules="formRules"
|
|
|
+ label-width="120px">
|
|
|
+ <el-form-item
|
|
|
+ prop="video_name"
|
|
|
+ :rules="formRules.required"
|
|
|
+ label="视频名称:">
|
|
|
+ <el-input
|
|
|
+ v-model="form.video_name"
|
|
|
+ placeholder="请输入视频名称"
|
|
|
+ clearable></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item
|
|
|
+ prop="video_introduce"
|
|
|
+ :rules="formRules.required"
|
|
|
+ label="视频简介:">
|
|
|
+ <el-input
|
|
|
+ type="textarea"
|
|
|
+ :rows="4"
|
|
|
+ placeholder="请输入视频简介"
|
|
|
+ v-model="form.video_introduce">
|
|
|
+ </el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item
|
|
|
+ prop="video_cover_url"
|
|
|
+ :rules="formRules.uploadImgs"
|
|
|
+ label="视频封面:">
|
|
|
+ <el-upload
|
|
|
+ :on-remove="(file) => {handleRemove(file, 'video_cover_url')}"
|
|
|
+ :on-success="(file) => {handleAvatarSuccess(file, 'video_cover_url')}"
|
|
|
+ :before-upload="beforeAvatarUpload"
|
|
|
+ :on-exceed="hadnleExceed"
|
|
|
+ :accept="'image/*'"
|
|
|
+ :limit="1"
|
|
|
+ :file-list="video_cover_url"
|
|
|
+ list-type="picture-card"
|
|
|
+ action="/api/upload/img"
|
|
|
+ multiple
|
|
|
+ ref="video_cover_url">
|
|
|
+ <i class="el-icon-plus"></i>
|
|
|
+ <div slot="tip" class="el-upload__tip">只能上传jpg/png文件,且不超过5M</div>
|
|
|
+ </el-upload>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item
|
|
|
+ prop="video_url"
|
|
|
+ :rules="formRules.uploadImgs"
|
|
|
+ label="视频:">
|
|
|
+ <el-upload
|
|
|
+ :on-remove="(file) => {handleRemove(file, 'video_url')}"
|
|
|
+ :on-success="(file) => {handleAvatarSuccess(file, 'video_url')}"
|
|
|
+ :accept="'video/mp4'"
|
|
|
+ :limit="1"
|
|
|
+ :file-list="video_url"
|
|
|
+ action="/api/upload/img"
|
|
|
+ :multiple="false"
|
|
|
+ :show-file-list="false"
|
|
|
+ ref="video_url">
|
|
|
+ <el-button
|
|
|
+ icon="el-icon-plus"
|
|
|
+ type="text"
|
|
|
+ slot="trigger"
|
|
|
+ v-if="form.video_url.length < 1">选择视频
|
|
|
+ </el-button>
|
|
|
+ <template v-if="form.video_url.length > 0">
|
|
|
+ <el-button
|
|
|
+ icon="el-icon-video-play"
|
|
|
+ type="text"
|
|
|
+ slot="tip"
|
|
|
+ @click="showVideoPlayDialog">视频预览
|
|
|
+ </el-button>
|
|
|
+ <el-button
|
|
|
+ style="margin-left: 20px;"
|
|
|
+ icon="el-icon-delete"
|
|
|
+ type="text"
|
|
|
+ slot="tip"
|
|
|
+ @click="resetVideoUrl">删除
|
|
|
+ </el-button>
|
|
|
+ </template>
|
|
|
+ </el-upload>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item
|
|
|
+ prop="video_auther"
|
|
|
+ :rules="formRules.required"
|
|
|
+ label="出镜人员:">
|
|
|
+ <el-input
|
|
|
+ type="textarea"
|
|
|
+ :rows="4"
|
|
|
+ placeholder="请输入出镜人员"
|
|
|
+ v-model="form.video_auther">
|
|
|
+ </el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item
|
|
|
+ prop="lunbo_status"
|
|
|
+ :rules="formRules.select"
|
|
|
+ label="置顶推荐:">
|
|
|
+ <el-select
|
|
|
+ style="width: 100%;"
|
|
|
+ v-model="form.lunbo_status"
|
|
|
+ filterable
|
|
|
+ clearable
|
|
|
+ placeholder="请选择是否置顶推荐">
|
|
|
+ <el-option
|
|
|
+ :label="item.name"
|
|
|
+ :value="item.value"
|
|
|
+ v-for="item in arrRecommend"
|
|
|
+ :key="item.value"></el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item
|
|
|
+ prop="video_status"
|
|
|
+ :rules="formRules.select"
|
|
|
+ label="状态:">
|
|
|
+ <el-select
|
|
|
+ style="width: 100%;"
|
|
|
+ v-model="form.video_status"
|
|
|
+ filterable
|
|
|
+ clearable
|
|
|
+ placeholder="请选择状态">
|
|
|
+ <el-option
|
|
|
+ :label="item.name"
|
|
|
+ :value="item.value"
|
|
|
+ v-for="item in arrLunboStatus"
|
|
|
+ :key="item.value"></el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <div slot="footer" class="dialog-footer text-center">
|
|
|
+ <el-button @click="dialog = false">取 消</el-button>
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ :disabled="booLock"
|
|
|
+ @click="handleSubmit">确 定
|
|
|
+ </el-button>
|
|
|
+ </div>
|
|
|
+ </el-dialog>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+export default {
|
|
|
+ props: {
|
|
|
+ value: {
|
|
|
+ type: Boolean,
|
|
|
+ default: true
|
|
|
+ },
|
|
|
+ exData: {
|
|
|
+ type: Object,
|
|
|
+ default: function () {
|
|
|
+ return {}
|
|
|
+ }
|
|
|
+ },
|
|
|
+ arrRecommend: {
|
|
|
+ type: Array,
|
|
|
+ default: function () {
|
|
|
+ return []
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ dialog: !!this.value,
|
|
|
+ form: {
|
|
|
+ 'video_name': '', // 视频名称
|
|
|
+ 'video_introduce': '', // 视频简介
|
|
|
+ 'video_cover_url': [], // 封面地址
|
|
|
+ 'video_url': [], // 视频地址
|
|
|
+ 'video_type_id': 1, // 类别ID todo
|
|
|
+ 'video_type_name': 'sd', // 类别名称 todo
|
|
|
+ 'video_auther': '', // 出境人
|
|
|
+ 'lunbo_status': '0', // 置顶推荐(0否1是)
|
|
|
+ 'video_status': '0' // 视频状态(0未审核1审核通过2审核拒绝) todo
|
|
|
+ },
|
|
|
+ video_cover_url: [],
|
|
|
+ video_url: [],
|
|
|
+ booLock: false
|
|
|
+ }
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ arrLunboStatus() {
|
|
|
+ return this.$store.state.common.arrLunboStatus
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ beforeAvatarUpload(file) {
|
|
|
+ const isLt2M = file.size / 1024 / 1024 < 5
|
|
|
+ if (!isLt2M) {
|
|
|
+ this.$message.error('上传图片大小不能超过 5MB!')
|
|
|
+ }
|
|
|
+ return isLt2M
|
|
|
+ },
|
|
|
+ hadnleExceed(files, fileList) {
|
|
|
+ this.$message({
|
|
|
+ message: '最多上传一张',
|
|
|
+ type: 'warning'
|
|
|
+ })
|
|
|
+ },
|
|
|
+ handleRemove(file, formKey) {
|
|
|
+ let path = file.url
|
|
|
+ if (file.response && file.response.data) {
|
|
|
+ path = file.response.data.path
|
|
|
+ }
|
|
|
+ this.form[formKey] = this.form[formKey].filter(item => item !== path)
|
|
|
+ },
|
|
|
+ handleAvatarSuccess(res, formKey) {
|
|
|
+ if (res.code === 200) {
|
|
|
+ const { path } = res.data
|
|
|
+ this.form[formKey].push(path)
|
|
|
+ } else {
|
|
|
+ this.$message.error('图片上传失败')
|
|
|
+ }
|
|
|
+ },
|
|
|
+ handleSubmit() {
|
|
|
+ const url = this.exData.id ? '/api/admin/video/modify' : '/api/admin/video/add'
|
|
|
+ this.$refs.form.validate(async valid => {
|
|
|
+ if (valid) {
|
|
|
+ const formData = JSON.parse(JSON.stringify(this.form))
|
|
|
+ const postData = {
|
|
|
+ ...formData,
|
|
|
+ video_cover_url: formData.video_cover_url[0],
|
|
|
+ video_url: formData.video_url[0]
|
|
|
+ }
|
|
|
+ this.booLock = true
|
|
|
+ const data = await this.$fetch(url, postData)
|
|
|
+ this.booLock = false
|
|
|
+ if (data.code === 200) {
|
|
|
+ this.$message.success('提交成功')
|
|
|
+ this.$emit('success')
|
|
|
+ this.dialog = false
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ showVideoPlayDialog() {
|
|
|
+ this.$store.commit('common/SET_VIDEOPLAYDIALOG', {
|
|
|
+ src: this.form.video_url[0],
|
|
|
+ show: true
|
|
|
+ })
|
|
|
+ },
|
|
|
+ resetVideoUrl() {
|
|
|
+ this.form.video_url.splice(0, 1)
|
|
|
+ this.video_url.splice(0, 1)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ mounted() {
|
|
|
+ if (this.exData.id) {
|
|
|
+ this.$set(this.form, 'id', this.exData.id)
|
|
|
+ this.video_cover_url = [
|
|
|
+ {
|
|
|
+ name: '',
|
|
|
+ url: this.exData.video_cover_url
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ this.video_url = [
|
|
|
+ {
|
|
|
+ name: '',
|
|
|
+ url: this.exData.video_url
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ for (const key in this.exData) {
|
|
|
+ if (this.form.hasOwnProperty(key)) {
|
|
|
+ let value = this.exData[key]
|
|
|
+ if ((Array.isArray(value) && value.length >= 1) || (Object.prototype.toString.call(value) === '[object Object]') || (typeof value === 'string' && value) || typeof value === 'number') {
|
|
|
+ if (key === 'video_cover_url' || key === 'video_url') {
|
|
|
+ value = [value]
|
|
|
+ }
|
|
|
+ if (key === 'lunbo_status' || key === 'video_status') {
|
|
|
+ value = value + ''
|
|
|
+ }
|
|
|
+ this.$set(this.form, key, value)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ dialog(val) {
|
|
|
+ if (!val) this.$emit('input', val)
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+.top-tip {
|
|
|
+ margin-top: -20px;
|
|
|
+ margin-bottom: 20px;
|
|
|
+}
|
|
|
+
|
|
|
+.af-put-line-radio {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+
|
|
|
+ p.lalel {
|
|
|
+ padding: 0 10px;
|
|
|
+ }
|
|
|
+
|
|
|
+ p {
|
|
|
+ padding: 0;
|
|
|
+ margin: 0;
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|