|
@ -1,6 +1,7 @@ |
|
|
<template> |
|
|
<template> |
|
|
<div id="tinymceContainer" ref="ceshi" class="tinymce-editor"> |
|
|
<div id="tinymceContainer" ref="ceshi" class="tinymce-editor"> |
|
|
<editor v-if="isshow" :id="'myEditor' + editorIDName" v-model="myValue" :init="init" :disabled="disabled" @onClick="onClick" /> |
|
|
|
|
|
|
|
|
<editor v-if="isshow" :id="'myEditor' + editorIDName" v-model="myValue" :init="init" :disabled="disabled" |
|
|
|
|
|
@onClick="onClick" /> |
|
|
</div> |
|
|
</div> |
|
|
</template> |
|
|
</template> |
|
|
|
|
|
|
|
@ -21,6 +22,7 @@ import 'tinymce/plugins/code' |
|
|
import 'tinymce/plugins/print' |
|
|
import 'tinymce/plugins/print' |
|
|
import 'tinymce/plugins/anchor' |
|
|
import 'tinymce/plugins/anchor' |
|
|
import 'tinymce/plugins/quickbars' |
|
|
import 'tinymce/plugins/quickbars' |
|
|
|
|
|
import 'tinymce/plugins/link' |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 自定义部分 |
|
|
* 自定义部分 |
|
@ -36,8 +38,10 @@ import './tinymce/plugins/hm_button' |
|
|
import './tinymce/plugins/hm_indent2em/plugin' |
|
|
import './tinymce/plugins/hm_indent2em/plugin' |
|
|
|
|
|
|
|
|
import { isInclude } from './tinymce/plugins/hm_utils' |
|
|
import { isInclude } from './tinymce/plugins/hm_utils' |
|
|
|
|
|
|
|
|
|
|
|
import urlAddress from '@/mixins/urlAddress' |
|
|
|
|
|
import Cookies from 'js-cookie' |
|
|
export default { |
|
|
export default { |
|
|
|
|
|
mixins: [urlAddress], |
|
|
components: { |
|
|
components: { |
|
|
Editor |
|
|
Editor |
|
|
}, |
|
|
}, |
|
@ -60,12 +64,12 @@ export default { |
|
|
}, |
|
|
}, |
|
|
plugins: { |
|
|
plugins: { |
|
|
type: [String, Array], |
|
|
type: [String, Array], |
|
|
default: 'hminput hmcheckbox hmradio hmbutton quickbars print hmpreview lists image media table code letterspacing indent2em anchor'// paste contextmenu colorpicker textcolor |
|
|
|
|
|
|
|
|
default: 'hminput hmcheckbox hmradio hmbutton quickbars link print hmpreview lists image media table code letterspacing indent2em anchor'// paste contextmenu colorpicker textcolor |
|
|
}, |
|
|
}, |
|
|
toolbar: { |
|
|
toolbar: { |
|
|
type: [String, Array], |
|
|
type: [String, Array], |
|
|
default: |
|
|
default: |
|
|
`undo redo | image | bold italic forecolor backcolor | letterspacing | fontsizeselect | fontselect| lineheight | |
|
|
|
|
|
|
|
|
`undo redo | image | media | link | bold italic forecolor backcolor | letterspacing | fontsizeselect | fontselect| lineheight | |
|
|
alignleft aligncenter alignright alignjustify | |
|
|
alignleft aligncenter alignright alignjustify | |
|
|
bullist numlist outdent indent indent2em| hmpreview code` |
|
|
bullist numlist outdent indent indent2em| hmpreview code` |
|
|
}, |
|
|
}, |
|
@ -111,19 +115,86 @@ export default { |
|
|
paste_data_images: true, |
|
|
paste_data_images: true, |
|
|
// images_upload_url: "/demo/eUpload.php", |
|
|
// images_upload_url: "/demo/eUpload.php", |
|
|
images_upload_base_path: '', // "/demo/" |
|
|
images_upload_base_path: '', // "/demo/" |
|
|
|
|
|
// 三个参数分别对应三个插件【link,image,media】,如果要屏蔽某个插件的上传,就去掉对应参数 |
|
|
|
|
|
file_picker_types: 'file image media', |
|
|
// forced_root_block: '', // 删除首尾自动添加的P标签 |
|
|
// forced_root_block: '', // 删除首尾自动添加的P标签 |
|
|
images_upload_handler: function(blobInfo, succFun, failFun) { |
|
|
|
|
|
// 自定义插入图片函数 |
|
|
|
|
|
// blobInfo: 本地图片blob对象 |
|
|
|
|
|
// succFun(url|string): 成功回调(插入图片链接到文本中) |
|
|
|
|
|
// failFun(string):失败回调 |
|
|
|
|
|
|
|
|
images_upload_handler: function (blobInfo, succFun, failFun) { |
|
|
|
|
|
// 自定义插入图片函数 |
|
|
|
|
|
// blobInfo: 本地图片blob对象 |
|
|
|
|
|
// succFun(url|string): 成功回调(插入图片链接到文本中) |
|
|
|
|
|
// failFun(string):失败回调 |
|
|
var file = blobInfo.blob() |
|
|
var file = blobInfo.blob() |
|
|
var reader = new FileReader() |
|
|
var reader = new FileReader() |
|
|
reader.onload = function(e) { |
|
|
|
|
|
|
|
|
reader.onload = function (e) { |
|
|
succFun(e.target.result) |
|
|
succFun(e.target.result) |
|
|
} |
|
|
} |
|
|
reader.readAsDataURL(file) |
|
|
reader.readAsDataURL(file) |
|
|
}, |
|
|
}, |
|
|
|
|
|
//be used to add custom file picker to those dialogs that have it. |
|
|
|
|
|
file_picker_callback: (callback, value, meta)=> { |
|
|
|
|
|
let that = this |
|
|
|
|
|
//文件分类 |
|
|
|
|
|
var filetype = '.pdf, .txt, .zip, .rar, .7z, .doc, .docx, .xls, .xlsx, .ppt, .pptx, .mp3, .mp4'; |
|
|
|
|
|
//后端接收上传文件的地址 |
|
|
|
|
|
var upurl = 'http://192.168.0.35:8028/hz_quguang/sys/user/saveUserImg'; |
|
|
|
|
|
//为不同插件指定文件类型及后端地址 |
|
|
|
|
|
switch (meta.filetype) { |
|
|
|
|
|
// case 'image': |
|
|
|
|
|
// filetype = '.jpg, .jpeg, .png, .gif'; |
|
|
|
|
|
// upurl = 'upimg.php'; |
|
|
|
|
|
// break; |
|
|
|
|
|
case 'media': |
|
|
|
|
|
filetype = '.mp3, .mp4'; |
|
|
|
|
|
upurl = this.url + '/hz_quguang/upload/uploadFile'; |
|
|
|
|
|
break; |
|
|
|
|
|
case 'file': |
|
|
|
|
|
default: |
|
|
|
|
|
} |
|
|
|
|
|
//模拟出一个input用于添加本地文件 |
|
|
|
|
|
var input = document.createElement('input'); |
|
|
|
|
|
input.setAttribute('type', 'file'); |
|
|
|
|
|
input.setAttribute('accept', filetype); |
|
|
|
|
|
input.click(); |
|
|
|
|
|
input.onchange = function () { |
|
|
|
|
|
var file = this.files[0]; |
|
|
|
|
|
var xhr, formData; |
|
|
|
|
|
console.log(file.name); |
|
|
|
|
|
xhr = new XMLHttpRequest(); |
|
|
|
|
|
xhr.withCredentials = false; |
|
|
|
|
|
xhr.open('POST', upurl); |
|
|
|
|
|
console.log('token',Cookies.get('qg-token')); |
|
|
|
|
|
xhr.setRequestHeader('Authorization', 'Bearer ' + Cookies.get('qg-token')); // 在请求头中加上token |
|
|
|
|
|
console.log('getAllResponseHeaders',xhr.getAllResponseHeaders()); // 输出请求头,确认是否包含Authorization |
|
|
|
|
|
xhr.onload = function () { |
|
|
|
|
|
var json; |
|
|
|
|
|
if (xhr.status != 200) { |
|
|
|
|
|
console.log('HTTP Error: ' + xhr.status); |
|
|
|
|
|
// failure('HTTP Error: ' + xhr.status); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
json = JSON.parse(xhr.responseText); |
|
|
|
|
|
if (!json || typeof json.location != 'string') { |
|
|
|
|
|
console.log('Invalid JSON: ' + xhr.responseText); |
|
|
|
|
|
// failure('Invalid JSON: ' + xhr.responseText); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
callback(json.location); |
|
|
|
|
|
}; |
|
|
|
|
|
formData = new FormData(); |
|
|
|
|
|
formData.append('file', file, file.name); |
|
|
|
|
|
// that.$http({ |
|
|
|
|
|
// method: 'post', |
|
|
|
|
|
// url: 'http://192.168.0.35:8028/hz_quguang/upload/uploadFile', |
|
|
|
|
|
// headers: { |
|
|
|
|
|
// 'Content-Type': 'multipart/form-data' |
|
|
|
|
|
// }, |
|
|
|
|
|
// data: formData |
|
|
|
|
|
// }).then((res) => { |
|
|
|
|
|
|
|
|
|
|
|
// }) |
|
|
|
|
|
xhr.send(formData); |
|
|
|
|
|
}; |
|
|
|
|
|
}, |
|
|
content_css: '/static/css/hmcrf.css', |
|
|
content_css: '/static/css/hmcrf.css', |
|
|
setup: (editor) => { |
|
|
setup: (editor) => { |
|
|
editor.on('click', e => { |
|
|
editor.on('click', e => { |
|
@ -164,16 +235,16 @@ export default { |
|
|
}, |
|
|
}, |
|
|
mounted() { |
|
|
mounted() { |
|
|
// Cookies.set('qg-token', '9def6f4db676363e9f01990d56e62929') |
|
|
// Cookies.set('qg-token', '9def6f4db676363e9f01990d56e62929') |
|
|
this.$http.get(`/quguang/sys/table/dict/getList`, { |
|
|
|
|
|
params: { |
|
|
|
|
|
isCrf: 1 |
|
|
|
|
|
} |
|
|
|
|
|
}).then(({ data: res }) => { |
|
|
|
|
|
if (res.code === 0) { |
|
|
|
|
|
const data = res.data |
|
|
|
|
|
window.localStorage.setItem('dictField', JSON.stringify(data)) |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
// this.$http.get(`/hz_quguang/sys/table/dict/getList`, { |
|
|
|
|
|
// params: { |
|
|
|
|
|
// isCrf: 1 |
|
|
|
|
|
// } |
|
|
|
|
|
// }).then(({ data: res }) => { |
|
|
|
|
|
// if (res.code === 0) { |
|
|
|
|
|
// const data = res.data |
|
|
|
|
|
// window.localStorage.setItem('dictField', JSON.stringify(data)) |
|
|
|
|
|
// } |
|
|
|
|
|
// }) |
|
|
|
|
|
|
|
|
this.$nextTick(() => { |
|
|
this.$nextTick(() => { |
|
|
}) |
|
|
}) |
|
|