博雅学苑品牌活动-培训活动-新建活动:活动介绍富文本插入图片时新增‘上传图片’tab(同时保留网络图片tab);
This commit is contained in:
@@ -120,6 +120,45 @@ layout("/layouts/platform.html"){
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
initIntroduceEditor(content) {
|
||||
$("#introduce").html("")
|
||||
const editor = new E("#introduce")
|
||||
editor.config.onchange = (html) => {
|
||||
this.formData.introduce = html.replace(/<p\><\/p>/g, '')
|
||||
}
|
||||
editor.config.customUploadImg = (resultFiles, insertImgFn) => {
|
||||
Promise.all(this.uploadIntroduceImages(resultFiles)).then(res => {
|
||||
res.forEach(v => {
|
||||
if (v.code === 0) {
|
||||
insertImgFn(APP_DOMAIN + CREATE_PREVIEW_URL(v.data.filepath))
|
||||
} else {
|
||||
this.$message.warning(v.msg || '图片上传失败')
|
||||
}
|
||||
})
|
||||
}).catch(() => {
|
||||
this.$message.warning('图片上传失败')
|
||||
})
|
||||
}
|
||||
editor.config.showLinkImg = true
|
||||
editor.create()
|
||||
if (content) {
|
||||
editor.txt.html(content)
|
||||
}
|
||||
},
|
||||
uploadIntroduceImages(resultFiles) {
|
||||
return resultFiles.map(file => {
|
||||
const formData = new FormData()
|
||||
formData.append('file', file, file.name)
|
||||
formData.append('folderPath', '/wangEditorImg/')
|
||||
return jQuery.ajax({
|
||||
url: '/file_server/uploadFile',
|
||||
type: 'post',
|
||||
data: formData,
|
||||
processData: false,
|
||||
contentType: false
|
||||
})
|
||||
})
|
||||
},
|
||||
openUserScope() {
|
||||
this.userScopeDialog = true
|
||||
},
|
||||
@@ -491,23 +530,12 @@ layout("/layouts/platform.html"){
|
||||
const type = this.trainTypeList.find(o => o.code === this.formData.trainType)
|
||||
this.trainType = type ? type.name : '培训班'
|
||||
this.$nextTick(() => {
|
||||
$("#introduce").html("")
|
||||
var editor = new E("#introduce")
|
||||
editor.config.onchange = (html) => {
|
||||
this.formData.introduce = html.replace(/<p\><\/p>/g, '')
|
||||
}
|
||||
editor.create()
|
||||
editor.txt.html(resp.data.introduce)
|
||||
this.initIntroduceEditor(resp.data.introduce)
|
||||
})
|
||||
}
|
||||
} else {
|
||||
this.$nextTick(() => {
|
||||
$("#introduce").html("")
|
||||
var editor = new E("#introduce")
|
||||
editor.config.onchange = (html) => {
|
||||
this.formData.introduce = html.replace(/<p\><\/p>/g, '')
|
||||
}
|
||||
editor.create()
|
||||
this.initIntroduceEditor()
|
||||
})
|
||||
}
|
||||
},
|
||||
@@ -684,13 +712,7 @@ layout("/layouts/platform.html"){
|
||||
const type = this.trainTypeList.find(o => o.code === this.formData.trainType)
|
||||
this.trainType = type ? type.name : '培训班'
|
||||
this.$nextTick(() => {
|
||||
$("#introduce").html("")
|
||||
var editor = new E("#introduce")
|
||||
editor.config.onchange = (html) => {
|
||||
this.formData.introduce = html.replace(/<p\><\/p>/g, '')
|
||||
}
|
||||
editor.create()
|
||||
editor.txt.html(resp.data.introduce)
|
||||
this.initIntroduceEditor(resp.data.introduce)
|
||||
})
|
||||
this.formData.id = ''
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user