webpackJsonp([64],{"9w8g":function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=a("uAC3"),o=a.n(i),l=(a("D9hl"),a("crgx")),r=a.n(l),n={data:function(){var t=this;return{visible:!1,quillEditor:null,quillEditorToolbarOptions:[["bold","italic","underline","strike"],["blockquote","code-block","image"],[{header:1},{header:2}],[{list:"ordered"},{list:"bullet"}],[{script:"sub"},{script:"super"}],[{indent:"-1"},{indent:"+1"}],[{direction:"rtl"}],[{size:["small",!1,"large","huge"]}],[{header:[1,2,3,4,5,6,!1]}],[{color:[]},{background:[]}],[{font:[]}],[{align:[]}],["clean"]],uploadUrl:"",dataForm:{id:0,name:"",subject:"",content:""},dataRule:{name:[{required:!0,message:"必填项不能为空",trigger:"blur"}],subject:[{required:!0,message:"必填项不能为空",trigger:"blur"}],content:[{validator:function(e,a,i){t.quillEditor.getLength()<=1?i(new Error("必填项不能为空")):i()},trigger:"blur"}]}}},methods:{init:function(){var t=this;this.visible=!0,this.$nextTick(function(){t.quillEditor?t.quillEditor.deleteText(0,t.quillEditor.getLength()):t.quillEditorHandle(),t.$refs.dataForm.resetFields(),t.dataForm.id&&t.getTemplateInfo()})},quillEditorHandle:function(){var t=this;this.quillEditor=new r.a("#J_quillEditor",{modules:{toolbar:this.quillEditorToolbarOptions},theme:"snow"}),this.uploadUrl=window.SITE_CONFIG.baseURL+"/sys/oss/upload?token="+o.a.get("token"),this.quillEditor.getModule("toolbar").addHandler("image",function(){t.$refs.uploadBtn.$el.click()})},uploadBeforeUploadHandle:function(t){if("image/jpg"!==t.type&&"image/jpeg"!==t.type&&"image/png"!==t.type&&"image/gif"!==t.type)return this.$message.error("只支持jpg、png、gif格式的图片！"),!1},uploadSuccessHandle:function(t,e,a){t&&0===t.code&&this.quillEditor.insertEmbed(this.quillEditor.getSelection().index,"image",t.data.src)},getTemplateInfo:function(){var t=this;this.$http.get(window.SITE_CONFIG.baseURL+"/sys/mailtemplate/info/"+this.dataForm.id).then(function(e){e&&0===e.code&&(t.dataForm.name=e.template.name,t.dataForm.subject=e.template.subject,t.quillEditor.root.innerHTML=e.template.content)})},dataFormSubmit:function(){var t=this;this.$refs.dataForm.validate(function(e){e&&t.$http.post(window.SITE_CONFIG.baseURL+"/sys/mailtemplate/"+(t.dataForm.id?"update":"save"),{id:t.dataForm.id||void 0,name:t.dataForm.name,subject:t.dataForm.subject,content:t.quillEditor.root.innerHTML},{headers:{"content-type":"application/x-www-form-urlencoded"}}).then(function(e){e&&0===e.code&&t.$message({message:"操作成功",type:"success",duration:1500,onClose:function(){t.visible=!1,t.$emit("refreshDataList")}})})})}}},s={render:function(){var t=this,e=t.$createElement,a=t._self._c||e;return a("el-dialog",{attrs:{title:t.dataForm.id?"修改":"新增","close-on-click-modal":!1,visible:t.visible},on:{"update:visible":function(e){t.visible=e}}},[a("el-form",{ref:"dataForm",attrs:{model:t.dataForm,rules:t.dataRule,"label-width":"80px"},nativeOn:{keyup:function(e){if(!("button"in e)&&t._k(e.keyCode,"enter",13,e.key,"Enter"))return null;t.dataFormSubmit()}}},[a("el-form-item",{attrs:{label:"模板名称",prop:"name"}},[a("el-input",{attrs:{placeholder:"模板名称"},model:{value:t.dataForm.name,callback:function(e){t.$set(t.dataForm,"name",e)},expression:"dataForm.name"}})],1),t._v(" "),a("el-form-item",{attrs:{label:"主题",prop:"subject"}},[a("el-input",{attrs:{placeholder:"主题"},model:{value:t.dataForm.subject,callback:function(e){t.$set(t.dataForm,"subject",e)},expression:"dataForm.subject"}})],1),t._v(" "),a("el-form-item",{attrs:{label:"内容",prop:"content"}},[a("div",{attrs:{id:"J_quillEditor"}}),t._v(" "),a("el-upload",{staticStyle:{display:"none"},attrs:{action:t.uploadUrl,"show-file-list":!1,"before-upload":t.uploadBeforeUploadHandle,"on-success":t.uploadSuccessHandle}},[a("el-button",{ref:"uploadBtn",attrs:{size:"small",type:"primary"}},[t._v("点击上传")])],1)],1)],1),t._v(" "),a("span",{staticClass:"dialog-footer",attrs:{slot:"footer"},slot:"footer"},[a("el-button",{on:{click:function(e){t.visible=!1}}},[t._v("取消")]),t._v(" "),a("el-button",{attrs:{type:"primary"},on:{click:function(e){t.dataFormSubmit()}}},[t._v("确定")])],1)],1)},staticRenderFns:[]},d=a("C7Lr")(n,s,!1,null,null,null);e.default=d.exports}});