2 lines
4.6 KiB
JavaScript
2 lines
4.6 KiB
JavaScript
import{s as i,n}from"./index-2b234fd0.js";const d={data(){return{visible:!1,infoMode:!1,addForm:{type:null,image:"",news_image_show:[],showtime:"",weight:0},addMode:!1,isEdit:!1,editID:0,list:[],columns:[{colKey:"weight",title:"排序",align:"center"},{colKey:"image",title:"图片",align:"center"},{colKey:"type",title:"类别",align:"center"},{colKey:"url",title:"跳转链接",align:"center"},{colKey:"select",title:"操作",width:200,align:"center"}],association:{}}},mounted(){typeof i.state.user.association=="object"?this.association=i.state.user.association:this.association=JSON.parse(i.state.user.association),this.getList()},methods:{formatResponse(t){return console.log(t),this.addForm.image=t.data.url,{url:t.data.fullurl,name:t.data.url}},del(t){console.log(t),this.$request.post("/carousel/del",{id:t.id}).then(s=>{s.code==1?(this.$message.success(s.msg),this.getList()):this.$message.error(s.msg),console.log(s)}).catch(s=>{console.log(s)})},add(){this.addMode=!0,this.isEdit=!1,this.addForm={news_image_show:[],image:"",url:"",weight:"",type:null}},edit(t){console.log(t),this.addForm.news_image_show=[{url:i.state.user.apiUrl+t.image,name:t.image}],this.addForm.image=t.image,this.addForm.id=t.id,this.addForm.url=t.url,this.addForm.weight=t.weight,this.addForm.type=t.type,this.addMode=!0,this.isEdit=!0},getList(){this.$request.post("/carousel").then(t=>{console.log(t),t.code==1&&(this.list=t.data)}).catch(t=>{console.log(t)})},onSubmit(){if(console.log(this.addForm),this.addForm.type==null){this.$message.error("轮播图类型不能为空!");return}if(this.addForm.image==""){this.$message.error("轮播图内容不能为空");return}var t="/carousel/add";this.isEdit&&(t="/carousel/update"),this.$request.post(t,this.addForm).then(s=>{console.log(s),s.code==1?(this.$message.success(s.msg),this.addMode=!1,this.getList()):this.$message.error(s.msg)}).catch(s=>{console.log(s)})},onCloseMy(){this.addMode=!1,this.infoMode=!1}}};var c=function(){var t=this,s=t.$createElement,e=t._self._c||s;return e("t-card",{attrs:{title:"轮播图管理",bordered:!1}},[e("div",{staticClass:"form-step-container"},[e("t-button",{on:{click:t.add}},[t._v("新增")]),e("t-table",{attrs:{rowKey:"index",data:t.list,columns:t.columns,stripe:!1,bordered:!1,hover:!0,size:"large","table-layout":"auto",cellEmptyContent:"-"},scopedSlots:t._u([{key:"image",fn:function(a){var o=a.row;return[o.type==1?e("div",[e("img",{staticStyle:{height:"200px"},attrs:{src:t.$store.state.user.apiUrl+o.image}})]):t._e(),o.type==2?e("div",[e("video",{staticStyle:{height:"200px"},attrs:{src:t.$store.state.user.apiUrl+o.image,autoplay:!1,controls:"controls"}})]):t._e()]}},{key:"type",fn:function(a){var o=a.row;return[o.type==1?e("t-tag",[t._v("图片")]):t._e(),o.type==2?e("t-tag",{attrs:{theme:"primary"}},[t._v("视频")]):t._e()]}},{key:"select",fn:function(a){var o=a.row;return[e("t-space",{attrs:{size:"24px"}},[e("t-button",{attrs:{theme:"warning"},on:{click:function(l){return t.edit(o)}}},[t._v("编辑")]),e("t-popconfirm",{attrs:{content:"确认删除吗"},on:{confirm:function(l){return t.del(o)}}},[e("t-button",{attrs:{theme:"danger"}},[t._v("删除")])],1)],1)]}}])})],1),e("t-dialog",{attrs:{header:t.isEdit?"编辑":"新增",visible:t.addMode,onClose:t.onCloseMy,width:"45%",top:"20px"},on:{confirm:t.onSubmit}},[e("t-form",[e("t-form-item",{attrs:{label:"轮播类型",name:"type"}},[e("t-select",{model:{value:t.addForm.type,callback:function(a){t.$set(t.addForm,"type",a)},expression:"addForm.type"}},[e("t-option",{attrs:{label:"图片",value:"1"}}),e("t-option",{attrs:{label:"视频",value:"2"}})],1)],1),e("t-form-item",{attrs:{label:"跳转链接",name:"url"}},[e("t-input",{attrs:{placeholder:"请输入跳转链接"},model:{value:t.addForm.url,callback:function(a){t.$set(t.addForm,"url",a)},expression:"addForm.url"}})],1),e("t-form-item",{attrs:{label:"排序",name:"weight"}},[e("t-input",{attrs:{placeholder:"请输入排序"},model:{value:t.addForm.weight,callback:function(a){t.$set(t.addForm,"weight",a)},expression:"addForm.weight"}})],1),e("t-form-item",{attrs:{label:"轮播图片"}},[e("t-upload",{attrs:{action:t.$store.state.user.apiUrl+"/api/common/upload",tips:"请选择单张图片",accept:"image/*",data:{association_id:this.association.association_id},showImageFileName:!0,"format-response":t.formatResponse,sizeLimit:{size:500,unit:"KB",message:"图片大小不超过500KB"}},model:{value:t.addForm.news_image_show,callback:function(a){t.$set(t.addForm,"news_image_show",a)},expression:"addForm.news_image_show"}})],1)],1)],1)],1)},m=[];const r={};var u=n(d,c,m,!1,h,null,null,null);function h(t){for(let s in r)this[s]=r[s]}const p=function(){return u.exports}();export{p as default};
|