design.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. var richTextHtml = '<div class="rich-text-list" >';
  2. richTextHtml += '<div :id="id" style="width:100%;height:450px;padding-left:10px;box-sizing:border-box;"></div>';
  3. richTextHtml += '</div>';
  4. Vue.component("rich-text", {
  5. template: richTextHtml,
  6. data: function () {
  7. return {
  8. data : this.$parent.data,
  9. id: ns.gen_non_duplicate(10),
  10. editor : null
  11. }
  12. },
  13. created: function () {
  14. if(!this.$parent.data.verify) this.$parent.data.verify = [];
  15. this.$parent.data.verify.push(this.verify);//加载验证方法
  16. this.$parent.data.ignore = ['elementBgColor','elementAngle','textColor'];//加载忽略内容 -- 其他设置中的属性设置
  17. this.$parent.data.ignoreLoad = true; // 等待忽略数组赋值后加载
  18. if(this.$parent.data.margin.top === 0){
  19. this.$parent.data.margin.top = 10;
  20. this.$parent.data.margin.bottom = 10;
  21. this.$parent.data.margin.both = 10;
  22. }
  23. var self = this;
  24. setTimeout(function () {
  25. self.editor = UE.getEditor(self.id,{
  26. toolbars: [[
  27. 'source', 'undo', 'redo',
  28. 'bold', 'italic', 'underline', '|', 'strikethrough', 'removeformat', 'forecolor', 'backcolor', 'selectall', 'cleardoc',
  29. 'fontsize',
  30. 'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify',
  31. 'horizontal'
  32. ]],
  33. autoHeightEnabled: false,
  34. theme:'gray',
  35. });
  36. self.editor.ready(function () {
  37. if(self.$parent.data.html) self.editor.setContent(self.$parent.data.html);
  38. });
  39. self.editor.addListener("contentChange",function(){
  40. self.$parent.data.html = self.editor.getContent();
  41. });
  42. }, 100);
  43. },
  44. methods:{
  45. verify : function (index) {
  46. var res = {code: true, message: ""};
  47. if (vue.data[index].html === "") {
  48. res.code = false;
  49. res.message = "请输入富文本内容";
  50. }
  51. return res;
  52. }
  53. }
  54. });