123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 |
- <template>
- <div>
- <div class="background">
- <div class="content">
- <el-form
- ref="form"
- :model="form"
- :rules="rules"
- label-width="90px"
- id="selectForm"
- >
- <el-form-item label="公告名称:" size="mini" prop="title">
- <el-input
- v-model="form.name"
- placeholder="请输入公告名称"
- style="width: 510px"
- ></el-input>
- </el-form-item>
- <el-form-item label="发布时间:" size="mini" prop="time">
- <el-time-select placeholder="选择时间"> </el-time-select>
- </el-form-item>
- <el-form-item label="公告内容:" prop="content">
- <quill-editor
- class="ql-editor"
- v-model="content"
- ref="myQuillEditor"
- :options="editorOption"
- >
- </quill-editor>
- </el-form-item>
- </el-form>
- </div>
- </div>
- </div>
- </template>
-
- <script>
- import Quill from "quill"; // 引入编辑器
- // 自定义字体大小
- const Size = Quill.import("attributors/style/size");
- Size.whitelist = ["10px", "12px", "16px", "18px", "20px", "30px", "32px"];
- Quill.register(Size, true);
- // 自定义字体类型
- var fonts = [
- "SimSun",
- "SimHei",
- "Microsoft-YaHei",
- "KaiTi",
- "FangSong",
- "Arial",
- "sans-serif",
- ];
- var Font = Quill.import("formats/font");
- Font.whitelist = fonts;
- Quill.register(Font, true);
- export default {
- data() {
- return {
- form: {
- name: "",
- },
- rules: {
- title: [{ required: true, message: "请输入公告名称", trigger: "blur" }],
- time: [{ required: true, message: "请输入发布时间", trigger: "blur" }],
- content: [{ required: true, message: "请输入公告内容", trigger: "blur" }],
- },
- // 富文本编辑器配置
- editorOption: {
- modules: {
- toolbar: [
- ["bold", "italic", "underline", "strike"], // 加粗 斜体 下划线 删除线
- ["blockquote", "code-block"], // 引用 代码块
- [{ header: 1 }, { header: 2 }], // 1、2 级标题
- [{ list: "ordered" }, { list: "bullet" }], // 有序、无序列表
- [{ script: "sub" }, { script: "super" }], // 上标/下标
- [{ indent: "-1" }, { indent: "+1" }], // 缩进
- [{ direction: "rtl" }], // 文本方向
- [{ size: ["12px", false, "16px", "18px", "20px", "30px"] }], // 字体大小
- [{ header: [1, 2, 3, 4, 5, 6, false] }], // 标题
- [{ color: [] }, { background: [] }], // 字体颜色、字体背景颜色
- [
- {
- font: [
- false,
- "SimSun",
- "SimHei",
- "Microsoft-YaHei",
- "KaiTi",
- "FangSong",
- "Arial",
- ],
- },
- ], // 字体种类
- [{ align: [] }], // 对齐方式
- ["clean"], // 清除文本格式
- ["link", "image", "video"], // 链接、图片、视频
- ],
- placeholder: "请输入正文",
- },
- },
- };
- },
- };
- </script>
- <style scoped>
- .background {
- width: 750px;
- height: 100%;
- position: absolute;
- top: 75px;
- bottom: 0;
- left: 0;
- right: 0;
- margin: auto;
- border: 1px solid #ccc;
- border-radius: 5px;
- }
- .content {
- width: 100%;
- height: 100%;
- padding: 35px;
- }
- /* 调节form表单中label的字体大小 */
- #selectForm >>> .el-form-item__label {
- font-size: 12px;
- color: #808080;
- }
- .quill-editor /deep/ .ql-container {
- min-height: 220px;
- }
- .ql-container {
- min-height: 230px;
- }
- .ql-toolbar.ql-snow {
- border: 1px solid #ccc;
- -webkit-box-sizing: border-box;
- box-sizing: border-box;
- font-family: "Helvetica Neue", "Helvetica", "Arial", sans-serif;
- padding: 8px;
- width: 450px;
- }
- .ql-toolbar.ql-snow + .ql-container.ql-snow {
- border-top: 0px;
- width: 450px;
- }
- </style>
|