Commit dff493f7 by 匡雅琴

富文本框图片

1 parent 0b5eb58e
...@@ -426,6 +426,7 @@ export default { ...@@ -426,6 +426,7 @@ export default {
// 提交 // 提交
handleSubmit() { handleSubmit() {
this.$refs.materialAddForm.validate(valid => { this.$refs.materialAddForm.validate(valid => {
console.log(this.textBoxContent, 'text');
if (valid) { if (valid) {
var params = this.getParams() var params = this.getParams()
params.status = 0 params.status = 0
......
...@@ -20,6 +20,7 @@ export default { ...@@ -20,6 +20,7 @@ export default {
}, },
methods: { methods: {
getEdit() { getEdit() {
const _this = this;
this.editor = new E('#div-demo') this.editor = new E('#div-demo')
this.editor.config.uploadImgShowBase64 = true this.editor.config.uploadImgShowBase64 = true
this.editor.config.showMenuTooltips = true this.editor.config.showMenuTooltips = true
...@@ -33,6 +34,34 @@ export default { ...@@ -33,6 +34,34 @@ export default {
this.content = html // 绑定当前逐渐地值 this.content = html // 绑定当前逐渐地值
this.$emit('change', this.content) // 将内容同步到父组件中 this.$emit('change', this.content) // 将内容同步到父组件中
} }
this.editor.config.customUploadImg = function (resultFiles, insertImgFn) {
console.log(resultFiles)
var file = resultFiles[0]
var reader = new FileReader()
// 默认1MB
const limitSize = 10
const isLt = file.size / 1024 / 1024 < limitSize
if (!isLt) {
_this.$message.error('上传图片大小不能超过' + limitSize + 'MB!')
return true
}
reader.readAsDataURL(file)
reader.onload = e => {
const imgFile = e.target.result
const base64 = file.name.split('.')[1] + '@' + imgFile.split(',')[1]
_this.$apis.common.pictureUpload({ file: base64 }).then(res => {
if (res) {
// console.log(res)
insertImgFn(res)
}
})
// resultFiles 是 input 中选中的文件列表
// insertImgFn 是获取图片 url 后,插入到编辑器的方法
// 上传图片,返回结果,将图片插入到编辑器中
}
}
this.editor.config.onchangeTimeout = 5000 this.editor.config.onchangeTimeout = 5000
this.editor.create() this.editor.create()
}, },
...@@ -59,6 +88,6 @@ export default { ...@@ -59,6 +88,6 @@ export default {
</style> </style>
<style> <style>
.w-e-text-container { .w-e-text-container {
z-index: 1!important; z-index: 1 !important;
} }
</style> </style>
\ No newline at end of file \ No newline at end of file
...@@ -525,6 +525,7 @@ export default { ...@@ -525,6 +525,7 @@ export default {
} }
.material-content { .material-content {
display: flex; display: flex;
align-items: center;
justify-content: space-between; justify-content: space-between;
.hide-content { .hide-content {
display: inline-block; display: inline-block;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!