813788fb by renchao@pashanhoo.com

style:系统通知

1 parent 6f68f042
1 <template> 1 <template>
2 <dialogBox :title="title" @submitForm="submitForm" saveButton="保存" :isFullscreen="false" width="50%" 2 <el-form ref="ruleForm" :model="ruleForm" label-width="100px" :rules="rules">
3 @closeDialog="closeDialog" v-model="value" :isButton="isButtonFlag"> 3 <el-row>
4 <el-form ref="ruleForm" :model="ruleForm" label-width="100px" :rules="rules"> 4 <el-col :span="24">
5 <el-row> 5 <el-form-item label="通知标题:" prop="noticeTitle">
6 <el-col :span="24"> 6 <el-input v-model="ruleForm.noticeTitle" class="width100"></el-input>
7 <el-form-item label="通知标题:" prop="noticeTitle"> 7 </el-form-item>
8 <el-input v-model="ruleForm.noticeTitle" class="width100"></el-input> 8 </el-col>
9 </el-form-item> 9 </el-row>
10 </el-col> 10 <el-row>
11 </el-row> 11 <el-col :span="24">
12 <el-row> 12 <el-form-item label="通知来源:" prop="noticeSource">
13 <el-col :span="24"> 13 <el-input v-model="ruleForm.noticeSource" class="width100"></el-input>
14 <el-form-item label="通知来源:" prop="noticeSource">
15 <el-input v-model="ruleForm.noticeSource" class="width100"></el-input>
16 </el-form-item>
17 </el-col>
18 </el-row>
19 <el-row>
20 <el-form-item label="通知内容:" prop="noticeContent">
21 <quill-editor v-model="ruleForm.noticeContent" class="editor ql-editor" ref="myQuillEditor"
22 :options="editorOption" @blur="onEditorBlur($event)" @focus="onEditorFocus($event)"
23 @change="onEditorChange($event)" @ready="onEditorReady($event)"></quill-editor>
24 </el-form-item> 14 </el-form-item>
25 </el-row> 15 </el-col>
26 <!-- <el-row> 16 </el-row>
17 <el-row>
18 <el-form-item label="通知内容:" prop="noticeContent">
19 <quill-editor v-model="ruleForm.noticeContent" class="editor ql-editor" ref="myQuillEditor"
20 :options="editorOption" @blur="onEditorBlur($event)" @focus="onEditorFocus($event)"
21 @change="onEditorChange($event)" @ready="onEditorReady($event)"></quill-editor>
22 </el-form-item>
23 </el-row>
24 <!-- <el-row>
27 <el-col :span="8"> 25 <el-col :span="8">
28 <el-form-item label="附件:" prop="noticeFileUrl"> 26 <el-form-item label="附件:" prop="noticeFileUrl">
29 <el-upload action multiple :auto-upload="false" :limit="1" :on-change="handleChange" 27 <el-upload action multiple :auto-upload="false" :limit="1" :on-change="handleChange"
...@@ -34,16 +32,19 @@ ...@@ -34,16 +32,19 @@
34 </el-form-item> 32 </el-form-item>
35 </el-col> 33 </el-col>
36 </el-row> --> 34 </el-row> -->
37 <!-- 隐藏上传按钮 用于代替触发富文本上传事件 --> 35 <!-- 隐藏上传按钮 用于代替触发富文本上传事件 -->
38 <div v-show="false"> 36 <div v-show="false">
39 <el-upload action multiple :auto-upload="false" :on-change="RichTexthandleChange" :before-upload="beforeUpload" 37 <el-upload action multiple :auto-upload="false" :on-change="RichTexthandleChange" :before-upload="beforeUpload"
40 class="richUpload"> 38 class="richUpload">
41 <el-button icon="el-icon-upload" type="primary">上传</el-button> 39 <el-button icon="el-icon-upload" type="primary">上传</el-button>
42 <div slot="tip" class="el-upload__tip">文件大小不超过20MB</div> 40 <div slot="tip" class="el-upload__tip">文件大小不超过20MB</div>
43 </el-upload> 41 </el-upload>
44 </div> 42 </div>
45 </el-form> 43 <el-form-item v-if="formData.isButtonFlag" class="text-center">
46 </dialogBox> 44 <el-button @click="closeDialog">取消</el-button>
45 <el-button type="primary" @click="submitForm" plain>确定</el-button>
46 </el-form-item>
47 </el-form>
47 </template> 48 </template>
48 <script> 49 <script>
49 import { addSysNotice, updateSysNotice } from "@/api/system.js"; 50 import { addSysNotice, updateSysNotice } from "@/api/system.js";
...@@ -51,9 +52,10 @@ import { upload } from "@/api/system.js"; ...@@ -51,9 +52,10 @@ import { upload } from "@/api/system.js";
51 import { quillEditor } from "vue-quill-editor"; 52 import { quillEditor } from "vue-quill-editor";
52 export default { 53 export default {
53 props: { 54 props: {
54 value: { type: Boolean, default: false }, 55 formData: {
55 isButtonFlag: { type: Boolean, default: true }, 56 type: Object,
56 title: { type: String, default: '新增系统通知' } 57 default: () => { }
58 }
57 }, 59 },
58 components: { quillEditor }, 60 components: { quillEditor },
59 data () { 61 data () {
...@@ -113,38 +115,35 @@ export default { ...@@ -113,38 +115,35 @@ export default {
113 } 115 }
114 }; 116 };
115 }, 117 },
116 watch: { 118 mounted () {
117 value (val) { 119 this.$nextTick(() => {
118 if (val) { 120 //创建富文本粘贴事件监听
119 let that = this 121 let quill = this.$refs.myQuillEditor.quill;
120 this.$nextTick(() => { 122 this.$forceUpdate();
121 //创建富文本粘贴事件监听 123 quill.root.addEventListener(
122 let quill = this.$refs.myQuillEditor.quill; 124 "paste",
123 this.$forceUpdate(); 125 evt => {
124 quill.root.addEventListener( 126 if (
125 "paste", 127 evt.clipboardData &&
126 evt => { 128 evt.clipboardData.files &&
127 if ( 129 evt.clipboardData.files.length
128 evt.clipboardData && 130 ) {
129 evt.clipboardData.files && 131 evt.preventDefault();
130 evt.clipboardData.files.length 132 [].forEach.call(evt.clipboardData.files, file => {
131 ) { 133 if (!file.type.match(/^image\/(gif|jpe?g|a?png|bmp)/i)) {
132 evt.preventDefault(); 134 return;
133 [].forEach.call(evt.clipboardData.files, file => {
134 if (!file.type.match(/^image\/(gif|jpe?g|a?png|bmp)/i)) {
135 return;
136 }
137 that.clipboardPictureChange(file);
138 });
139 } 135 }
140 }, 136 that.clipboardPictureChange(file);
141 false 137 });
142 ); 138 }
143 }); 139 },
144 } 140 false
141 )
142 })
143 if (this.formData) {
144 this.getDetailInfo(this.formData)
145 } 145 }
146 }, 146 },
147 mounted () { },
148 methods: { 147 methods: {
149 submitForm () { 148 submitForm () {
150 let that = this; 149 let that = this;
...@@ -156,14 +155,13 @@ export default { ...@@ -156,14 +155,13 @@ export default {
156 that.addNotice(); 155 that.addNotice();
157 } 156 }
158 } else { 157 } else {
159 // console.log('error submit!!');
160 return false; 158 return false;
161 } 159 }
162 }); 160 });
163 }, 161 },
164 //关闭窗口 162 //关闭窗口
165 closeDialog () { 163 closeDialog () {
166 this.$emit("input", false); 164 this.$popupCacel()
167 this.resetRuleForm(); 165 this.resetRuleForm();
168 }, 166 },
169 //新增通知 167 //新增通知
...@@ -171,7 +169,7 @@ export default { ...@@ -171,7 +169,7 @@ export default {
171 addSysNotice(this.ruleForm).then(res => { 169 addSysNotice(this.ruleForm).then(res => {
172 if (res.code == 200) { 170 if (res.code == 200) {
173 this.$message.success("保存成功"); 171 this.$message.success("保存成功");
174 this.$emit("input", false); 172 this.$popupCacel()
175 this.resetRuleForm(); 173 this.resetRuleForm();
176 this.$parent.queryClick(); 174 this.$parent.queryClick();
177 } else { 175 } else {
...@@ -184,7 +182,7 @@ export default { ...@@ -184,7 +182,7 @@ export default {
184 updateSysNotice(this.ruleForm).then(res => { 182 updateSysNotice(this.ruleForm).then(res => {
185 if (res.code == 200) { 183 if (res.code == 200) {
186 this.$message.success("编辑成功"); 184 this.$message.success("编辑成功");
187 this.$emit("input", false); 185 this.$popupCacel()
188 this.resetRuleForm(); 186 this.resetRuleForm();
189 this.$parent.queryClick(); 187 this.$parent.queryClick();
190 } else { 188 } else {
...@@ -201,7 +199,6 @@ export default { ...@@ -201,7 +199,6 @@ export default {
201 noticeSource: "", 199 noticeSource: "",
202 noticeType: "1" 200 noticeType: "1"
203 } 201 }
204 this.isButtonFlag = true;
205 }, 202 },
206 beforeUpload (file) { 203 beforeUpload (file) {
207 return true; 204 return true;
...@@ -239,7 +236,6 @@ export default { ...@@ -239,7 +236,6 @@ export default {
239 quill.insertEmbed(length, "image", res.message); 236 quill.insertEmbed(length, "image", res.message);
240 // 调整光标到最后 237 // 调整光标到最后
241 quill.setSelection(length + 1); 238 quill.setSelection(length + 1);
242 //that.quillUpdateImg = false;
243 }); 239 });
244 }, 240 },
245 onSubmit () { 241 onSubmit () {
...@@ -267,6 +263,7 @@ export default { ...@@ -267,6 +263,7 @@ export default {
267 </script> 263 </script>
268 <style scoped lang="scss"> 264 <style scoped lang="scss">
269 @import "~@/styles/dialogBoxheader.scss"; 265 @import "~@/styles/dialogBoxheader.scss";
266
270 .quill-editor { 267 .quill-editor {
271 padding: 0; 268 padding: 0;
272 } 269 }
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
19 </el-col> 19 </el-col>
20 <el-col :span="14" class="btnColRight"> 20 <el-col :span="14" class="btnColRight">
21 <el-form-item> 21 <el-form-item>
22 <el-button type="primary" @click="handleSearch">查询</el-button> 22 <el-button type="primary" @click="handleSearch">查询</el-button>
23 <el-button type="primary" @click="openDialog()">新增</el-button> 23 <el-button type="primary" @click="openDialog()">新增</el-button>
24 </el-form-item> 24 </el-form-item>
25 </el-col> 25 </el-col>
...@@ -86,16 +86,10 @@ export default { ...@@ -86,16 +86,10 @@ export default {
86 //打开新增弹窗 86 //打开新增弹窗
87 openDialog (item) { 87 openDialog (item) {
88 if (item) { 88 if (item) {
89 this.$nextTick(() => { 89 this.$popupDialog("系统通知详情", "system/xttz/components/addDialog", { ...item, "isButtonFlag": false }, "50%")
90 this.isButtonFlag = false;
91 this.$refs.addDialog.getDetailInfo(item);
92 this.dialogTitle = '系统通知详情'
93 })
94 } else { 90 } else {
95 this.isButtonFlag = true; 91 this.$popupDialog("新增系统通知", "system/xttz/components/addDialog", { "isButtonFlag": true }, "50%")
96 this.dialogTitle = '新增系统通知'
97 } 92 }
98 this.isDialog = true;
99 }, 93 },
100 //删除 94 //删除
101 delNotice (item) { 95 delNotice (item) {
......