style.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. var html = '<div class="rich-text-list">';
  2. html += '<div v-bind:id="id" style="width:100%;height:320px;padding-left: 10px; box-sizing: border-box;"></div>';
  3. html += '<div class="template-edit-title">';
  4. html += '<h3>其他设置</h3>';
  5. html += '<i class="layui-icon layui-icon-down" onclick="closeBox(this)"></i>';
  6. html += '</div>';
  7. html += '<div class="template-edit-wrap">';
  8. html += '<color v-bind:data="{ field : \'backgroundColor\', \'label\' : \'背景颜色\' }"></color>';
  9. html += '<slide v-bind:data="{ field : \'marginTop\', label : \'页面边距\' }"></slide>';
  10. html += '</div>';
  11. html += '</div>';
  12. Vue.component("rich-text", {
  13. template: html,
  14. data: function () {
  15. return {
  16. data : this.$parent.data,
  17. id: get_math_rant(10),
  18. editor : null,
  19. padding : this.$parent.data.padding,
  20. }
  21. },
  22. created: function () {
  23. if(!this.$parent.data.verify) this.$parent.data.verify = [];
  24. this.$parent.data.verify.push(this.verify);//加载验证方法
  25. var self = this;
  26. setTimeout(function () {
  27. self.editor = UE.getEditor(self.id, {
  28. toolbars: [
  29. [
  30. 'source', //源代码
  31. 'undo', //撤销
  32. 'redo', //重做
  33. 'bold', //加粗
  34. 'indent', //首行缩进
  35. 'italic', //斜体
  36. 'underline', //下划线
  37. 'strikethrough', //删除线
  38. 'forecolor', //字体颜色
  39. 'subscript', //下标
  40. 'superscript', //上标
  41. 'formatmatch', //格式刷
  42. 'blockquote', //引用
  43. 'pasteplain', //纯文本粘贴模式
  44. 'selectall', //全选
  45. 'preview', //预览
  46. 'horizontal', //分隔线
  47. 'removeformat', //清除格式
  48. 'unlink', //取消链接
  49. 'inserttitle', //插入标题
  50. 'cleardoc', //清空文档
  51. 'fontfamily', //字体
  52. 'fontsize', //字号
  53. 'paragraph', //段落格式
  54. 'simpleupload', //单图上传
  55. 'insertimage', //多图上传
  56. 'link', //超链接
  57. 'emotion', //表情
  58. 'spechars', //特殊字符
  59. 'fontborder', //字符边框
  60. 'searchreplace', //查询替换
  61. 'insertvideo', //视频
  62. 'help', //帮助
  63. 'justifyleft', //居左对齐
  64. 'justifyright', //居右对齐
  65. 'justifycenter', //居中对齐
  66. 'justifyjustify', //两端对齐
  67. 'fullscreen', //全屏
  68. 'imagenone', //默认
  69. 'imageleft', //左浮动
  70. 'imageright', //右浮动
  71. 'imagecenter', //居中
  72. 'lineheight', //行间距
  73. 'edittip ', //编辑提示
  74. 'touppercase', //字母大写
  75. 'tolowercase', //字母小写
  76. 'music'//音乐
  77. ]
  78. ],
  79. serverUrl: "/Common/ueditor/php/controller.php",
  80. scaleEnabled:true
  81. });
  82. self.editor.ready(function () {
  83. if(self.$parent.data.html) self.editor.setContent(self.$parent.data.html);
  84. });
  85. self.editor.addListener("contentChange",function(){
  86. self.$parent.data.html = self.editor.getContent();
  87. });
  88. }, 10);
  89. },
  90. methods:{
  91. verify : function () {
  92. var res = {code: true, message: ""};
  93. if (this.$parent.data.html == "") {
  94. res.code = false;
  95. res.message = "请输入富文本内容";
  96. }
  97. return res;
  98. }
  99. }
  100. });