|
@ -81,18 +81,14 @@
|
|
|
</template>
|
|
|
<el-input-number v-else-if="item.type=='inputNumber'" v-model="form[item.id]" :controls-position="item.controlsPosition||''" :placeholder="item.placeholder" :min="item.min||''" :max="item.max"></el-input-number>
|
|
|
<template v-else-if="item.type=='richtext'">
|
|
|
<quill-editor
|
|
|
<QuillEditor
|
|
|
ref="formQuillTextEditor"
|
|
|
v-model="form[item.id]"
|
|
|
@blur="onEditorBlur($event, item)"
|
|
|
@focus="onEditorFocus($event, item)"
|
|
|
:options="resetEditorOption(item.editorOption)"
|
|
|
@ready="onEditorReady($event, item)"
|
|
|
@change="onEditorChange($event, item)">
|
|
|
</quill-editor>
|
|
|
<el-upload style="display:none" :action="UploadUrl" :show-file-list="false" :before-upload='newEditorbeforeupload' :on-success='newEditorSuccess'
|
|
|
ref="uniqueId" id="uniqueId">
|
|
|
</el-upload >
|
|
|
</QuillEditor>
|
|
|
</template>
|
|
|
</template>
|
|
|
</el-form-item>
|
|
@ -104,56 +100,10 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
import 'quill/dist/quill.core.css'
|
|
|
import 'quill/dist/quill.snow.css'
|
|
|
import 'quill/dist/quill.bubble.css'
|
|
|
import {quillEditor, Quill} from 'vue-quill-editor'
|
|
|
import { ImageResize } from 'quill-image-resize-module';
|
|
|
Quill.register('modules/imageResize', ImageResize);
|
|
|
import QuillEditor from '../QuillEditor'
|
|
|
import Upload from './Upload'
|
|
|
import {pickerOptions} from '../js/common'
|
|
|
import Tools from '../../utils/tool'
|
|
|
import defaultEditorOption from './editOptions'
|
|
|
let toolbarTooltips = {
|
|
|
'font': '字体',
|
|
|
'size': '字体大小',
|
|
|
'header': '字体大小',
|
|
|
'bold': '加粗',
|
|
|
'italic': '斜体',
|
|
|
'underline': '下划线',
|
|
|
'strike': '删除线',
|
|
|
'color' : '字体颜色',
|
|
|
'background': '背景颜色',
|
|
|
'script': {
|
|
|
'sub' : 'Subscript',
|
|
|
'super': 'Superscript'
|
|
|
},
|
|
|
'list': {
|
|
|
'ordered':'Numbered list',
|
|
|
'bullet': 'Bulleted list'
|
|
|
},
|
|
|
'indent': {
|
|
|
'-1': '缩进-1',
|
|
|
'+1': '缩进+1'
|
|
|
},
|
|
|
'direction': {
|
|
|
'rtl': 'Text direction (right to left | left to right)',
|
|
|
'ltr': 'Text direction (left ro right | right to left)'
|
|
|
},
|
|
|
'align': '排列',
|
|
|
'link': '插入超链接',
|
|
|
'image': '插入图片',
|
|
|
'video': '插入视频',
|
|
|
'formula': 'Insert a formula',
|
|
|
'clean': 'Clear format',
|
|
|
'add-table': 'Add a new table',
|
|
|
'table-row': 'Add a row to the selected table',
|
|
|
'table-column': 'Add a column to the selected table',
|
|
|
'remove-table': 'Remove selected table',
|
|
|
'help': 'Show help'
|
|
|
};
|
|
|
|
|
|
|
|
|
export default {
|
|
|
props: {
|
|
|
fields: {},
|
|
@ -162,7 +112,7 @@ export default {
|
|
|
},
|
|
|
components:{
|
|
|
Upload,
|
|
|
quillEditor
|
|
|
QuillEditor
|
|
|
},
|
|
|
computed:{
|
|
|
|
|
@ -171,8 +121,6 @@ export default {
|
|
|
return {
|
|
|
rows: "",
|
|
|
pickerOptions,
|
|
|
uploadLoading: false,
|
|
|
UploadUrl: Tools.upload_stream_url
|
|
|
}
|
|
|
},
|
|
|
created(){
|
|
@ -216,99 +164,75 @@ export default {
|
|
|
},
|
|
|
|
|
|
//富文本编辑 新增 start
|
|
|
resetEditorOption(editorOption){
|
|
|
if(editorOption){
|
|
|
return editorOption
|
|
|
}
|
|
|
return defaultEditorOption
|
|
|
},
|
|
|
onEditorBlur(editor) {
|
|
|
// resetEditorOption(editorOption){
|
|
|
// if(editorOption){
|
|
|
// return editorOption
|
|
|
// }
|
|
|
// return defaultEditorOption
|
|
|
// },
|
|
|
onEditorBlur(editor, item) {
|
|
|
this.$emit('onEditorBlur', {editor, item})
|
|
|
},
|
|
|
onEditorFocus(editor) {
|
|
|
onEditorFocus(editor, item) {
|
|
|
this.$emit('onEditorFocus', {editor, item})
|
|
|
},
|
|
|
onEditorReady(editor) {
|
|
|
this.showTooltips();
|
|
|
onEditorReady(editor, item) {
|
|
|
this.$emit('onEditorReady', {editor, item})
|
|
|
},
|
|
|
onEditorChange({editor, html, text}, item) {
|
|
|
this.$emit('onEditorChange', {editor, html, text, item})
|
|
|
},
|
|
|
newEditorbeforeupload(file){
|
|
|
var $uptypes = ["image/jpg", "image/png",'image/jpeg'];
|
|
|
const isJPG = $uptypes.indexOf(file.type) > -1;
|
|
|
const isLt3M = file.size / 1024 / 1024 < 3;
|
|
|
this.uploadLoading = this.$loading({
|
|
|
background: 'rgba(0, 0, 0, 0.2)',
|
|
|
text: '上传中'
|
|
|
})
|
|
|
if (!isJPG) {
|
|
|
this.uploadLoading.close()
|
|
|
this.$message.error("上传头像图片只能是 JPG/PNG 格式!");
|
|
|
}
|
|
|
if (!isLt3M) {
|
|
|
this.uploadLoading.close()
|
|
|
this.$message.error("上传头像图片大小不能超过 3MB!");
|
|
|
}
|
|
|
return isJPG && isLt3M;
|
|
|
// newEditorbeforeupload(file){
|
|
|
// var $uptypes = ["image/jpg", "image/png",'image/jpeg'];
|
|
|
// const isJPG = $uptypes.indexOf(file.type) > -1;
|
|
|
// const isLt3M = file.size / 1024 / 1024 < 3;
|
|
|
// this.uploadLoading = this.$loading({
|
|
|
// background: 'rgba(0, 0, 0, 0.2)',
|
|
|
// text: '上传中'
|
|
|
// })
|
|
|
// if (!isJPG) {
|
|
|
// this.uploadLoading.close()
|
|
|
// this.$message.error("上传头像图片只能是 JPG/PNG 格式!");
|
|
|
// }
|
|
|
// if (!isLt3M) {
|
|
|
// this.uploadLoading.close()
|
|
|
// this.$message.error("上传头像图片大小不能超过 3MB!");
|
|
|
// }
|
|
|
// return isJPG && isLt3M;
|
|
|
|
|
|
},
|
|
|
newEditorSuccess(res, file, fileList){
|
|
|
var vm = this
|
|
|
if(res.status==200){
|
|
|
var image = Tools.formatImgUrl(res.obj.fullUri),
|
|
|
addImgRange = this.$refs.formQuillTextEditor.quill.getSelection()
|
|
|
var length = addImgRange.index,quill = vm.$refs.formQuillTextEditor.quill
|
|
|
quill.insertEmbed(addImgRange != null?length:0, 'image',image)
|
|
|
quill.setSelection(length + 1);
|
|
|
}else{
|
|
|
vm.$message.error("图片上传失败!");
|
|
|
}
|
|
|
if (this.uploadLoading) {
|
|
|
this.uploadLoading.close()
|
|
|
}
|
|
|
},
|
|
|
showTooltips(){
|
|
|
let showTooltip = (which,el) => {
|
|
|
if (which=='button'){
|
|
|
var tool = el.className.replace('ql-', '');
|
|
|
}
|
|
|
else if (which=='span'){
|
|
|
var tool = el.className.replace('ql-','');
|
|
|
tool=tool.substr(0,tool.indexOf(' '));
|
|
|
}
|
|
|
if (tool){
|
|
|
//if element has value attribute.. handling is different
|
|
|
//buttons without value
|
|
|
if (el.value ==''){
|
|
|
if (toolbarTooltips[tool])
|
|
|
el.setAttribute('title',toolbarTooltips[tool]);
|
|
|
}
|
|
|
//buttons with value
|
|
|
else if (typeof el.value !=='undefined'){
|
|
|
if (toolbarTooltips[tool][el.value])
|
|
|
el.setAttribute('title',toolbarTooltips[tool][el.value]);
|
|
|
}
|
|
|
//default
|
|
|
else
|
|
|
el.setAttribute('title',toolbarTooltips[tool]);
|
|
|
}
|
|
|
};
|
|
|
|
|
|
let toolbarElement = document.querySelector('.ql-toolbar');
|
|
|
if (toolbarElement) {
|
|
|
let matchesButtons = toolbarElement.querySelectorAll('button');
|
|
|
for (let el of matchesButtons) {
|
|
|
showTooltip('button',el);
|
|
|
}
|
|
|
//for submenus inside
|
|
|
let matchesSpans = toolbarElement.querySelectorAll('.ql-toolbar > span > span');
|
|
|
for (let el of matchesSpans) {
|
|
|
showTooltip('span',el);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
// },
|
|
|
// newEditorSuccess(res, file, fileList){
|
|
|
// var vm = this
|
|
|
// if(res.status==200){
|
|
|
// var image = Tools.formatImgUrl(res.obj.fullUri),
|
|
|
// addImgRange = this.$refs.formQuillTextEditor.quill.getSelection()
|
|
|
// var length = addImgRange.index,quill = vm.$refs.formQuillTextEditor.quill
|
|
|
// quill.insertEmbed(addImgRange != null?length:0, 'image',image)
|
|
|
// quill.setSelection(length + 1);
|
|
|
// }else{
|
|
|
// vm.$message.error("图片上传失败!");
|
|
|
// }
|
|
|
// if (this.uploadLoading) {
|
|
|
// this.uploadLoading.close()
|
|
|
// }
|
|
|
// },
|
|
|
// addQuillTitle () {
|
|
|
// const oToolBar = document.querySelector('.ql-toolbar')
|
|
|
// const aButton = oToolBar.querySelectorAll('button')
|
|
|
// const aSelect = oToolBar.querySelectorAll('select')
|
|
|
// aButton.forEach(function (item) {
|
|
|
// if (item.className === 'ql-script') {
|
|
|
// item.value === 'sub' ? (item.title = '下标') : (item.title = '上标')
|
|
|
// } else if (item.className === 'ql-indent') {
|
|
|
// item.value === '+1' ? (item.title = '向右缩进') : (item.title = '向左缩进')
|
|
|
// } else {
|
|
|
// item.title = titleConfig[item.classList[0]]
|
|
|
// }
|
|
|
// })
|
|
|
// aSelect.forEach(function (item) {
|
|
|
// item.parentNode.title = titleConfig[item.classList[0]]
|
|
|
// })
|
|
|
// },
|
|
|
//富文本编辑 新增 end
|
|
|
}
|
|
|
}
|