webpackJsonp([59],{KGN2:function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o=i("uAC3"),l=i.n(o),a=(i("D9hl"),i("crgx")),r=i.n(a),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,title:"",content:"",pubTime:""},dataRule:{title:[{required:!0,message:"必填项不能为空",trigger:"blur"}],content:[{validator:function(e,i,o){t.quillEditor.getLength()<=1?o(new Error("必填项不能为空")):o()},trigger:"blur"}],pubTime:[{required:!0,message:"必填项不能为空",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.getNewsInfo()})},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="+l.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,i){t&&0===t.code&&this.quillEditor.insertEmbed(this.quillEditor.getSelection().index,"image",t.data.src)},getNewsInfo:function(){var t=this;this.$http.get(window.SITE_CONFIG.baseURL+"/demo/news/info/"+this.dataForm.id).then(function(e){e&&0===e.code&&(t.dataForm.title=e.news.title,t.quillEditor.root.innerHTML=e.news.content,t.dataForm.pubTime=e.news.pubTime)})},dataFormSubmit:function(){var t=this;this.$refs.dataForm.validate(function(e){e&&t.$http.post(window.SITE_CONFIG.baseURL+"/demo/news/"+(t.dataForm.id?"update":"save"),{id:t.dataForm.id||void 0,title:t.dataForm.title,content:t.quillEditor.root.innerHTML,pubTime:t.dataForm.pubTime},{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")}})})})}}},d={render:function(){var t=this,e=t.$createElement,i=t._self._c||e;return i("el-dialog",{attrs:{title:t.dataForm.id?"修改":"新增","close-on-click-modal":!1,visible:t.visible},on:{"update:visible":function(e){t.visible=e}}},[i("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()}}},[i("el-form-item",{attrs:{label:"标题",prop:"title"}},[i("el-input",{attrs:{placeholder:"标题"},model:{value:t.dataForm.title,callback:function(e){t.$set(t.dataForm,"title",e)},expression:"dataForm.title"}})],1),t._v(" "),i("el-form-item",{attrs:{label:"内容",prop:"content"}},[i("div",{attrs:{id:"J_quillEditor"}}),t._v(" "),i("el-upload",{staticStyle:{display:"none"},attrs:{action:t.uploadUrl,"show-file-list":!1,"before-upload":t.uploadBeforeUploadHandle,"on-success":t.uploadSuccessHandle}},[i("el-button",{ref:"uploadBtn",attrs:{size:"small",type:"primary"}},[t._v("点击上传")])],1)],1),t._v(" "),i("el-form-item",{attrs:{label:"发布时间",prop:"pubTime"}},[i("el-date-picker",{attrs:{type:"datetime","value-format":"yyyy-MM-dd HH:mm:ss",placeholder:"选择日期时间"},model:{value:t.dataForm.pubTime,callback:function(e){t.$set(t.dataForm,"pubTime",e)},expression:"dataForm.pubTime"}})],1)],1),t._v(" "),i("span",{staticClass:"dialog-footer",attrs:{slot:"footer"},slot:"footer"},[i("el-button",{on:{click:function(e){t.visible=!1}}},[t._v("取消")]),t._v(" "),i("el-button",{attrs:{type:"primary"},on:{click:function(e){t.dataFormSubmit()}}},[t._v("确定")])],1)],1)},staticRenderFns:[]},s=i("C7Lr")(n,d,!1,null,null,null);e.default=s.exports}});