|
@@ -9,7 +9,25 @@
|
|
|
<el-input :maxlength="30" show-word-limit v-model.trim="courseDeail.name" style="width: 40%" placeholder="输入课程名称,最多30字符"></el-input>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="预览图:" prop="thumb">
|
|
|
- <div style="display: flex;">
|
|
|
+ <uploadOss
|
|
|
+ :headers="$xtoken"
|
|
|
+ :action="$action"
|
|
|
+ :limit="1"
|
|
|
+ list_type="picture-card"
|
|
|
+ :accept="$acceptImg"
|
|
|
+ :multiple="true"
|
|
|
+ ref="clearPicture"
|
|
|
+ coursePath="course"
|
|
|
+ :show-file-list="true"
|
|
|
+ :file-list="courseDeail.thumb"
|
|
|
+ :on-success="handleFilesSuccess2"
|
|
|
+ :on-preview="onFilePreView"
|
|
|
+ :before-upload="beforeUpload"
|
|
|
+ :on-remove="onFileRemove2"
|
|
|
+ >
|
|
|
+ <i class="el-icon-plus"></i>
|
|
|
+ </uploadOss>
|
|
|
+ <!-- <div style="display: flex;">
|
|
|
<div style="cursor: pointer;margin-right: 10px;" @click="showApm(courseDeail.thumb)">
|
|
|
<userImage
|
|
|
v-if="courseDeail.thumb"
|
|
@@ -23,7 +41,7 @@
|
|
|
<div class="cursor" @click="showSelectImg(1)">
|
|
|
<div><i class="el-icon-plus"></i></div>
|
|
|
</div>
|
|
|
- </div>
|
|
|
+ </div> -->
|
|
|
</el-form-item>
|
|
|
<el-form-item label="价格:" prop="price">
|
|
|
<el-input-number
|
|
@@ -135,7 +153,7 @@ export default {
|
|
|
courseDeail: {
|
|
|
name: "",
|
|
|
price: 0,
|
|
|
- thumb: "",
|
|
|
+ thumb: [],
|
|
|
enable: true,
|
|
|
images: [],
|
|
|
sections: [],
|
|
@@ -152,7 +170,8 @@ export default {
|
|
|
{ type:'number',min: 1, message: '价格至少为1', trigger: 'blur' }
|
|
|
],
|
|
|
thumb: [
|
|
|
- { required: true, message: '请选择预览图', trigger: 'change' }
|
|
|
+ { required: true, message: '请选择预览图', trigger: 'change' },
|
|
|
+ {type:'array',trigger:'change'}
|
|
|
],
|
|
|
images: [
|
|
|
{ required: true, message: '请选择介绍图', trigger: 'change' },
|
|
@@ -198,6 +217,17 @@ export default {
|
|
|
});
|
|
|
this.courseDeail.images = fileListData
|
|
|
},
|
|
|
+ // 预览图删除
|
|
|
+ onFileRemove2(file, fileList) {
|
|
|
+ this.courseDeail.thumb = fileList
|
|
|
+ },
|
|
|
+ // 预览图上传
|
|
|
+ handleFilesSuccess2(response, file, fileList) {
|
|
|
+ let fileListData = fileList.filter(e => {
|
|
|
+ return e.url;
|
|
|
+ });
|
|
|
+ this.courseDeail.thumb = fileListData
|
|
|
+ },
|
|
|
//章节信息校验
|
|
|
validateURL() {
|
|
|
let result = false;
|
|
@@ -224,6 +254,11 @@ export default {
|
|
|
arr.push({name:item,url:item})
|
|
|
})
|
|
|
data.images = arr
|
|
|
+ let arr2 = []
|
|
|
+ data.thumb.split(',').forEach(item=>{
|
|
|
+ arr2.push({name:item,url:item})
|
|
|
+ })
|
|
|
+ data.thumb = arr2
|
|
|
return data;
|
|
|
},
|
|
|
//预览图上传成功回调
|
|
@@ -261,6 +296,10 @@ export default {
|
|
|
return item.url
|
|
|
})
|
|
|
data.images = arr.join(',')
|
|
|
+ let arr2 = data.thumb.map(item=>{
|
|
|
+ return item.url
|
|
|
+ })
|
|
|
+ data.thumb = arr2.join(',')
|
|
|
return data;
|
|
|
},
|
|
|
// 添加课程
|
|
@@ -293,7 +332,7 @@ export default {
|
|
|
if (
|
|
|
!this.courseDeail.name == "" &&
|
|
|
this.courseDeail.images.length &&
|
|
|
- !this.courseDeail.thumb == "" &&
|
|
|
+ this.courseDeail.thumb.length &&
|
|
|
this.courseDeail.price &&
|
|
|
this.courseDeail.price !== 0 &&
|
|
|
this.validateURL()
|
|
@@ -365,7 +404,7 @@ export default {
|
|
|
this.courseDeail = {
|
|
|
name: "",
|
|
|
price: 0,
|
|
|
- thumb: "",
|
|
|
+ thumb: [],
|
|
|
enable: true,
|
|
|
images: [],
|
|
|
sections: [],
|