addNotice.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <template>
  2. <div>
  3. <div class="background">
  4. <div class="content">
  5. <el-form
  6. ref="form"
  7. :model="form"
  8. :rules="rules"
  9. label-width="90px"
  10. id="selectForm"
  11. >
  12. <el-form-item label="公告名称:" size="mini" prop="title">
  13. <el-input
  14. v-model="form.name"
  15. placeholder="请输入公告名称"
  16. style="width: 510px"
  17. ></el-input>
  18. </el-form-item>
  19. <el-form-item label="发布时间:" size="mini" prop="time">
  20. <el-time-select placeholder="选择时间"> </el-time-select>
  21. </el-form-item>
  22. <el-form-item label="公告内容:" prop="content">
  23. <quill-editor
  24. class="ql-editor"
  25. v-model="content"
  26. ref="myQuillEditor"
  27. :options="editorOption"
  28. >
  29. </quill-editor>
  30. </el-form-item>
  31. </el-form>
  32. </div>
  33. </div>
  34. </div>
  35. </template>
  36. <script>
  37. import Quill from "quill"; // 引入编辑器
  38. // 自定义字体大小
  39. const Size = Quill.import("attributors/style/size");
  40. Size.whitelist = ["10px", "12px", "16px", "18px", "20px", "30px", "32px"];
  41. Quill.register(Size, true);
  42. // 自定义字体类型
  43. var fonts = [
  44. "SimSun",
  45. "SimHei",
  46. "Microsoft-YaHei",
  47. "KaiTi",
  48. "FangSong",
  49. "Arial",
  50. "sans-serif",
  51. ];
  52. var Font = Quill.import("formats/font");
  53. Font.whitelist = fonts;
  54. Quill.register(Font, true);
  55. export default {
  56. data() {
  57. return {
  58. form: {
  59. name: "",
  60. },
  61. rules: {
  62. title: [{ required: true, message: "请输入公告名称", trigger: "blur" }],
  63. time: [{ required: true, message: "请输入发布时间", trigger: "blur" }],
  64. content: [{ required: true, message: "请输入公告内容", trigger: "blur" }],
  65. },
  66. // 富文本编辑器配置
  67. editorOption: {
  68. modules: {
  69. toolbar: [
  70. ["bold", "italic", "underline", "strike"], // 加粗 斜体 下划线 删除线
  71. ["blockquote", "code-block"], // 引用 代码块
  72. [{ header: 1 }, { header: 2 }], // 1、2 级标题
  73. [{ list: "ordered" }, { list: "bullet" }], // 有序、无序列表
  74. [{ script: "sub" }, { script: "super" }], // 上标/下标
  75. [{ indent: "-1" }, { indent: "+1" }], // 缩进
  76. [{ direction: "rtl" }], // 文本方向
  77. [{ size: ["12px", false, "16px", "18px", "20px", "30px"] }], // 字体大小
  78. [{ header: [1, 2, 3, 4, 5, 6, false] }], // 标题
  79. [{ color: [] }, { background: [] }], // 字体颜色、字体背景颜色
  80. [
  81. {
  82. font: [
  83. false,
  84. "SimSun",
  85. "SimHei",
  86. "Microsoft-YaHei",
  87. "KaiTi",
  88. "FangSong",
  89. "Arial",
  90. ],
  91. },
  92. ], // 字体种类
  93. [{ align: [] }], // 对齐方式
  94. ["clean"], // 清除文本格式
  95. ["link", "image", "video"], // 链接、图片、视频
  96. ],
  97. placeholder: "请输入正文",
  98. },
  99. },
  100. };
  101. },
  102. };
  103. </script>
  104. <style scoped>
  105. .background {
  106. width: 750px;
  107. height: 100%;
  108. position: absolute;
  109. top: 75px;
  110. bottom: 0;
  111. left: 0;
  112. right: 0;
  113. margin: auto;
  114. border: 1px solid #ccc;
  115. border-radius: 5px;
  116. }
  117. .content {
  118. width: 100%;
  119. height: 100%;
  120. padding: 35px;
  121. }
  122. /* 调节form表单中label的字体大小 */
  123. #selectForm >>> .el-form-item__label {
  124. font-size: 12px;
  125. color: #808080;
  126. }
  127. .quill-editor /deep/ .ql-container {
  128. min-height: 220px;
  129. }
  130. .ql-container {
  131. min-height: 230px;
  132. }
  133. .ql-toolbar.ql-snow {
  134. border: 1px solid #ccc;
  135. -webkit-box-sizing: border-box;
  136. box-sizing: border-box;
  137. font-family: "Helvetica Neue", "Helvetica", "Arial", sans-serif;
  138. padding: 8px;
  139. width: 450px;
  140. }
  141. .ql-toolbar.ql-snow + .ql-container.ql-snow {
  142. border-top: 0px;
  143. width: 450px;
  144. }
  145. </style>