yifengyide/public/dist/assets/news_edit-14dccd83.js

2 lines
7.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import{s as a,n}from"./index-2b234fd0.js";import{a as l,u as d}from"./index.esm-41c14e67.js";const m={components:{Editor:l,Toolbar:d},data(){return{visible:!1,infoMode:!1,ser:{news_title:"",gory_id:""},addForm:{news_title:"",news_titleshort:"",gory_id:null,news_auto:"",news_source:"",news_content:"",news_image:"",news_image_show:[],showtime:"",news_hits:0,wx_url:""},addMode:!1,isEdit:!1,editID:0,gory_list:[],editor:null,toolbarConfig:{showLinkImg:!1,uploadImgShowBase64:!0,excludeKeys:["insertVideo","insertImage","insertLink","insertTable","codeBlock"]},editorConfig:{placeholder:"",readOnly:!1,autoFocus:!0,MENU_CONF:{uploadImage:{maxFileSize:1*1024*1024,server:a.state.user.apiUrl+"/api/common/upload",fieldName:"file",meta:{association_id:0},customInsert(e,o){console.log(e),o(e.data.fullurl,"","")},onError:(e,o,t)=>{console.log(o),o.message.indexOf("exceeds maximum allowed size")!==-1&&this.$message.error("图片限制为1M请调整好再上传",2e3)}},uploadVideo:{maxFileSize:50*1024*1024,server:a.state.user.apiUrl+"/api/common/upload",fieldName:"file",customInsert(e,o){console.log(e),o(e.data.fullurl,"","")},onError:(e,o,t)=>{console.log(o),o.message.indexOf("exceeds maximum allowed size")!==-1&&this.$message.error("视频限制为50M请调整好再上传",2e3)}}}}}},beforeDestroy(){const e=this.editor;e!=null&&e.destroy()},mounted(){typeof a.state.user.association=="object"?this.association=a.state.user.association:this.association=JSON.parse(a.state.user.association),this.editorConfig.MENU_CONF.uploadImage.meta.association_id=this.association.id,this.getGory(),typeof this.$route.query.id<"u"&&(console.log(this.$route.query),this.editID=this.$route.query.id,this.getNewsInfo())},methods:{getNewsInfo(){this.$request.post("/news/find",{news_id:this.editID}).then(e=>{this.edit(e.data)}).catch(e=>{console.log(e)})},formatResponse(e){return console.log(e),this.addForm.news_image=e.data.url,{url:e.data.fullurl}},onCreated(e){this.editor=Object.seal(e)},edit(e){console.log(e),this.addForm.news_id=e.news_id,this.addForm.news_title=e.news_title,this.addForm.news_titleshort=e.news_titleshort,this.addForm.news_image_show=[{url:a.state.user.apiUrl+e.news_image}],this.addForm.news_image=e.news_image,this.addForm.gory_id=e.gory_id,this.addForm.news_auto=e.news_auto,this.addForm.news_source=e.news_source,this.addForm.news_content=e.news_content,this.addForm.showtime=e.showtime,this.addForm.news_hits=e.news_hits,this.addForm.wx_url=e.wx_url,this.addMode=!0,this.isEdit=!0},getGory(){this.$request.post("/gory/index").then(e=>{console.log(e),e.code==1&&(this.gory_list=e.data)}).catch(e=>{console.log(e)})},onSubmit(){if(console.log(this.addForm),this.addForm.news_title==""){this.$message.error("新闻标题不能为空");return}if(this.addForm.news_titleshort==""){this.$message.error("简短标题不能为空");return}if(this.addForm.gory_id==null){this.$message.error("请选择新闻分类");return}if(this.addForm.news_auto==""){this.$message.error("作者不能为空");return}if(this.addForm.news_source==""){this.$message.error("来源不能为空");return}if(this.addForm.news_image==""){this.$message.error("新闻主图不能为空");return}if(this.addForm.showtime==""){this.$message.error("展示时间不能为空");return}var e="/news/update";this.$request.post(e,this.addForm).then(o=>{console.log(o),o.code==1?(this.$message.success(o.msg),setTimeout(()=>{this.$router.push({path:"/news/news_index"},500)})):this.$message.error(o.msg)}).catch(o=>{console.log(o)})},onCloseMy(){this.addMode=!1,this.infoMode=!1}}};var u=function(){var e=this,o=e.$createElement,t=e._self._c||o;return t("t-card",{attrs:{title:"编辑新闻",bordered:!1}},[t("div",{staticClass:"form-step-container"},[t("t-form",[t("t-form-item",{attrs:{label:"文章标题",name:"news_title"}},[t("t-input",{attrs:{size:"large",placeholder:"请输入文章标题"},model:{value:e.addForm.news_title,callback:function(s){e.$set(e.addForm,"news_title",s)},expression:"addForm.news_title"}})],1),t("t-form-item",{attrs:{label:"简短标题",name:"news_titleshort"}},[t("t-input",{attrs:{size:"large",placeholder:"请输入简短标题"},model:{value:e.addForm.news_titleshort,callback:function(s){e.$set(e.addForm,"news_titleshort",s)},expression:"addForm.news_titleshort"}})],1),t("t-form-item",{attrs:{label:"所属类目",name:"activity_location"}},[t("t-select",{attrs:{size:"large"},model:{value:e.addForm.gory_id,callback:function(s){e.$set(e.addForm,"gory_id",s)},expression:"addForm.gory_id"}},e._l(e.gory_list,function(s,r){return t("t-option",{key:r,attrs:{label:s.name,value:s.id}})}),1)],1),t("t-form-item",{attrs:{label:"作者",name:"news_auto"}},[t("t-input",{attrs:{size:"large",placeholder:"请输入作者"},model:{value:e.addForm.news_auto,callback:function(s){e.$set(e.addForm,"news_auto",s)},expression:"addForm.news_auto"}})],1),t("t-form-item",{attrs:{label:"来源",name:"news_source"}},[t("t-input",{attrs:{size:"large",placeholder:"请输入来源"},model:{value:e.addForm.news_source,callback:function(s){e.$set(e.addForm,"news_source",s)},expression:"addForm.news_source"}})],1),t("t-form-item",{attrs:{label:"点击量",name:"news_source"}},[t("t-input",{attrs:{size:"large",placeholder:"请输入自定义点击量"},model:{value:e.addForm.news_hits,callback:function(s){e.$set(e.addForm,"news_hits",s)},expression:"addForm.news_hits"}})],1),t("t-form-item",{attrs:{label:"微信文章链接",name:"wx_url"}},[t("t-input",{attrs:{size:"large",placeholder:"请输入微信文章链接"},model:{value:e.addForm.wx_url,callback:function(s){e.$set(e.addForm,"wx_url",s)},expression:"addForm.wx_url"}})],1),t("t-form-item",{attrs:{label:"新闻内容",name:"news_content"}},[t("div",{staticStyle:{border:"1px solid #ccc","z-index":"99"}},[t("Toolbar",{staticStyle:{"border-bottom":"1px solid #ccc"},attrs:{mode:"default",editor:e.editor,defaultConfig:e.toolbarConfig}}),t("Editor",{staticStyle:{height:"400px"},attrs:{defaultConfig:e.editorConfig,mode:"default"},on:{onCreated:function(s){return e.onCreated(s)}},model:{value:e.addForm.news_content,callback:function(s){e.$set(e.addForm,"news_content",s)},expression:"addForm.news_content"}})],1)]),t("t-form-item",{attrs:{label:"新闻主图"}},[t("t-upload",{attrs:{action:e.$store.state.user.apiUrl+"/api/common/upload",theme:"image",tips:"请选择单张图片文件上传",accept:"image/*","format-response":e.formatResponse,sizeLimit:{size:500,unit:"KB",message:"图片大小不超过500KB"}},model:{value:e.addForm.news_image_show,callback:function(s){e.$set(e.addForm,"news_image_show",s)},expression:"addForm.news_image_show"}})],1),t("t-form-item",{attrs:{label:"展示时间",name:"days"}},[t("t-date-picker",{style:{width:"200px"},attrs:{size:"large",clearable:!0,placeholder:"展示时间",enableTimePicker:!0,"allow-input":!1},model:{value:e.addForm.showtime,callback:function(s){e.$set(e.addForm,"showtime",s)},expression:"addForm.showtime"}})],1)],1),t("div",{staticStyle:{padding:"50px 0px","text-align":"center"}},[t("t-button",{attrs:{size:"large"},on:{click:e.onSubmit}},[e._v("提交")])],1)],1)])},c=[];const i={};var _=n(m,u,c,!1,h,null,null,null);function h(e){for(let o in i)this[o]=i[o]}const g=function(){return _.exports}();export{g as default};