You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

347 lines
11 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<template>
<div>
<xy-dialog ref="dialog" :width="50" :is-show.sync="isShow" :type="'form'" :title="$route.meta.title" :form="form"
:rules='rules' @submit="submit">
<template v-slot:title>
<div class="xy-table-item">
<div class="xy-table-item-label" style="font-weight: bold">
<span style="color: red;font-weight: bold;padding-right: 4px;">*</span>Title
</div>
<div class="xy-table-item-content">
<el-input placeholder="Please Input" style="width:100%" v-model="form.title"></el-input>
</div>
</div>
</template>
<template v-slot:date>
<div class="xy-table-item">
<div class="xy-table-item-label" style="font-weight: bold">
<span style="color: red;font-weight: bold;padding-right: 4px;"></span>Release Time
</div>
<div class="xy-table-item-content">
<el-date-picker v-model="form.date" style="width:100%" format="yyyy-MM-dd HH:mm:ss" value-format="yyyy-MM-dd HH:mm:ss"
type="datetime" placeholder="Please Select">
</el-date-picker>
</div>
</div>
</template>
<template v-slot:picture>
<div class="xy-table-item">
<div class="xy-table-item-label" style="font-weight: bold">
<span style="color: red;font-weight: bold;padding-right: 4px;"></span>Picture
</div>
<div class="xy-table-item-content">
<!-- <el-upload :action="action" :limit='1' class='upload-demo' :file-list="filesList"
ref="pictureUpload" :auto-upload="true" :data="uploadOther" :on-success="handlesuccess"
:on-remove="handleRemove">
<el-button size="small" type="primary">upload</el-button>
</el-upload> -->
<el-upload :action="action" class='upload-demo' :limit="1" list-type="picture-card"
accept=".PNG,.jpg,.jpeg,.bmp,.svg" :data="uploadOther" :file-list="filesList" ref="pictureUpload" :auto-upload="true"
:on-success="handlesuccess" :on-remove="handleRemove">
<i class="el-icon-plus"></i>
</el-upload>
</div>
</div>
</template>
<template v-slot:video_pics>
<div class="xy-table-item">
<div class="xy-table-item-label" style="font-weight: bold">
<span style="color: red;font-weight: bold;padding-right: 4px;"></span>Video Picture
</div>
<div class="xy-table-item-content">
<!-- <el-upload :action="action" class='upload-demo' :file-list="videosPicList"
ref="pictureUpload" :auto-upload="true" :data="uploadOther" :on-success="handlesuccessVp"
:on-remove="handleRemoveVp">
<el-button size="small" type="primary">upload</el-button>
</el-upload> -->
<el-upload :action="action" class='upload-demo' list-type="picture-card"
accept=".PNG,.jpg,.jpeg,.bmp,.svg" :data="uploadOther" :file-list="videosPicList" ref="pictureUpload" :auto-upload="true"
:on-success="handlesuccessVp" :on-remove="handleRemoveVp">
<i class="el-icon-plus"></i>
</el-upload>
</div>
</div>
</template>
<template v-slot:videos>
<div class="xy-table-item">
<div class="xy-table-item-label" style="font-weight: bold">
<span style="color: red;font-weight: bold;padding-right: 4px;"></span>Video
</div>
<div class="xy-table-item-content">
<el-upload :action="action" :limit='1' class='upload-demo' :file-list="videosList"
accept=".mp4,.ogg,.flv,.avi,.wmv,.rmvb,.mov"
ref="pictureUpload" :auto-upload="true" :data="uploadOther" :on-success="handlesuccessV"
:on-remove="handleRemoveV">
<el-button size="small" type="primary">upload</el-button>
</el-upload>
</div>
</div>
</template>
<template v-slot:introduction>
<div class="xy-table-item">
<div class="xy-table-item-label" style="font-weight: bold">
<span style="color: red;font-weight: bold;padding-right: 4px;"></span>Introduction
</div>
<div class="xy-table-item-content">
<el-input placeholder="Please Input" type="textarea" style="width:100%"
v-model="form.introduction"></el-input>
</div>
</div>
</template>
<template v-slot:content>
<div class="xy-table-item">
<div class="xy-table-item-label" style="font-weight: bold">
<span style="color: red;font-weight: bold;padding-right: 4px;"></span>Content
</div>
<div class="xy-table-item-content">
<!-- <wangEditor :isShow="isShow" v-show="showWang" :value="form.content" @change="changeEditor"></wangEditor> -->
<my-tinymce v-if="showWang" @input="changeEditor" :value="form.content"></my-tinymce>
</div>
</div>
</template>
</xy-dialog>
</div>
</template>
<script>
import {
save,
show
} from "@/api/system/baseForm.js"
import {
getToken
} from '@/utils/auth'
export default {
data() {
return {
table_name: 'webinars',
isShow: false,
showWang: false,
id: '',
type: 'add',
uploadOther: {
token: ""
},
action: `${process.env.VUE_APP_UPLOAD_API}`,
filesList: [],
videosList:[],
videosPicList:[],
form: {
title: "",
date:'',
picture: [],
video_pics:[],
videos:[],
introduction: "",
content: ''
},
rules: {
title: [{
required: true,
message: 'Please Input'
}]
}
}
},
created() {
this.uploadOther.token = getToken();
},
methods: {
changeEditor(e) {
this.form.content = e
},
handleRemove(file, fileList) {
this.filesList = fileList
},
handlesuccess(response, file, fileList) {
if (response && response.hasOwnProperty('errcode')) {
this.$Message.warning(response.errmsg || '')
this.filesList = []
return
}
this.filesList = fileList
},
handleRemoveV(file, fileList) {
this.videosList = fileList
},
handlesuccessV(response, file, fileList) {
if (response && response.hasOwnProperty('errcode')) {
this.$Message.warning(response.errmsg || '')
this.videosList = []
return
}
this.videosList = fileList
},
handleRemoveVp(file, fileList) {
this.videosPicList = fileList
},
handlesuccessVp(response, file, fileList) {
if (response && response.hasOwnProperty('errcode')) {
this.$Message.warning(response.errmsg || '')
this.videosPicList = []
return
}
this.videosPicList = fileList
},
submit() {
if (this.id) {
this.form.id = this.id
} else {
this.form.id = ''
}
let _files = []
if (this.filesList.length > 0) {
for (var h of this.filesList) {
if (h.response) {
_files.push(h.response.id)
} else {
_files.push(h.id)
}
}
this.form.picture = _files
} else {
this.form.picture = []
}
let v_files = []
if (this.videosList.length > 0) {
for (var v of this.videosList) {
if (v.response) {
v_files.push(v.response.id)
} else {
v_files.push(v.id)
}
}
this.form.videos = v_files
} else {
this.form.videos = []
}
let vp_files = []
if (this.videosPicList.length > 0) {
for (var v of this.videosPicList) {
if (v.response) {
vp_files.push(v.response.id)
} else {
vp_files.push(v.id)
}
}
this.form.video_pics = vp_files
} else {
this.form.video_pics = []
}
console.log("this.form", this.form)
// return
save({
table_name: this.table_name,
...this.form
}).then(res => {
this.$message({
type: 'success',
message: 'Success'
})
this.isShow = false
this.$emit('refresh')
})
},
getDetail() {
show({
table_name: this.table_name,
id: this.id,
json_data_fields: ['picture']
}).then(res => {
this.form = this.base.requestToForm(res, this.form)
this.form.date = res.date?res.date:this.$moment().format('YYYY-MM-DD HH:mm:ss')
this.form.content = res.content ? res.content : ''
this.showWang = true
if (res.picture_details && res.picture_details.length > 0) {
this.filesList = []
res.picture_details.map(item => {
this.filesList.push({
name: item.original_name,
id: item.id,
url: item.url
})
})
}
if (res.videos_details && res.videos_details.length > 0) {
this.videosList = []
res.videos_details.map(item => {
this.videosList.push({
name: item.original_name,
id: item.id,
url: item.url
})
})
}
if (res.video_pics_details && res.video_pics_details.length > 0) {
this.videosPicList = []
res.video_pics_details.map(item => {
this.videosPicList.push({
name: item.original_name,
id: item.id,
url: item.url
})
})
}
})
}
},
watch: {
isShow(newVal) {
if (newVal) {
if (this.type === 'editor') {
this.getDetail()
}else{
this.form.date = this.$moment().format('YYYY-MM-DD HH:mm:ss')
}
this.showWang = true
} else {
this.id = ''
this.showWang = false
this.filesList = []
this.videosList = []
this.videosPicList = []
this.form = {
title: "",
date:'',
picture: [],
video_pics:[],
videos:[],
introduction: "",
content: ''
}
this.$refs['dialog'].reset()
}
},
}
}
</script>
<style scoped lang="scss">
::v-deep .title,
::v-deep .date,
::v-deep .picture,
::v-deep .video_pics,
::v-deep .introduction,
::v-deep .content {
flex-basis: 100%;
}
</style>