resource-edit-new.b2bbf1d82d1977cc1958.js 6.58 KB
webpackJsonp([7],{132:function(t,e,a){"use strict";var o=a(11),i=a.n(o),s=a(27),n=a.n(s),l=a(4),r=a(10),d=a(45),c=a(101),m=a(130);e.a={name:"resourceEditNew",components:{Divide:m.a,bannerEditor:d.a,SmartFloor:c.a},data:function(){return{title:"",list:[],floorList:[],modalInfo:{modalType:0,modalTitle:"",resContentId:0,floorIndex:-1,template_intro:"",template_name:""},singleData:{data:{0:{alt:"",bgColor:"",imgId:"0",src:"",url:{action:"go.h5",url:""}}},type:3,template_intro:"一张图",template_name:"singleImage",resContentId:0},twoData:{data:{0:{alt:"",bgColor:"",imgId:"0",src:"",url:{action:"go.h5",url:""}},1:{alt:"",bgColor:"",imgId:"0",src:"",url:{action:"go.h5",url:""}}},type:4,template_intro:"两张图",template_name:"twoPicture",resContentId:0},resId:null,bg:"",show:!1,modalData:[],uploadData:{id:l.a.getQueryString("id"),items:[]}}},mounted:function(){this.resId=l.a.getQueryString("id"),this.title=l.a.getQueryString("name"),this.resourceService=new r.a,this.getResourceDetailList()},methods:{getResourceDetailList:function(){var t=this;this.resourceService.info(this.resId).then(function(e){console.log(e),t.list=e,t.manageAllData(e),t.manageFloorList(e)})},manageAllData:function(t){this.uploadData.items=[];for(var e=0;e<t.length;e++){var a={id:t[e].resContentId,contentName:t[e].name,templateKey:"123",contentData:t[e].data,type:t[e].type};this.uploadData.items.push(a)}},manageFloorList:function(t){this.floorList=[];for(var e=0;e<t.length;e++){var a=JSON.parse(t[e].data);a.resContentId=t[e].resContentId,a.type=t[e].type,this.floorList.push(a),console.log("floorList:",this.floorList)}},showModal:function(t,e,a){console.log(e,a);var o=0,i="";for(var s in e.data){var n=e.data[s];this.modalData.push(n)}switch(console.log("modalData:",this.modalData),t){case"singleImage":o=3,i="一张图";break;case"twoPicture":o=4,i="两张图"}o&&(this.modalInfo.modalType=o,this.modalInfo.modalTitle=i,this.modalInfo.resContentId=e.resContentId,this.modalInfo.template_intro=e.template_intro,this.modalInfo.template_name=e.template_name,this.modalInfo.floorIndex=a,this.show=!0),console.log("ModalInfo:",this.modalInfo)},showDeleteModal:function(t){var e=this;this.$Modal.confirm({title:"删除确认!",content:'<p style="color: red">是否确认删除该楼层?</p>',width:300,onOk:function(){e.uploadData.items.splice(t,1),e.resourceService.addOrUpdateResourceDetail(e.uploadData).then(function(t){t&&200===t.code?(e.$Message.success(t.message||"修改成功!"),e.getResourceDetailList(),e.modalData=[],e.modalInfo={modalType:0,modalTitle:"",resContentId:0,floorIndex:-1,template_intro:"",template_name:""}):(console.log(t),e.$Message.error(t.message||"修改失败!"))})}})},onOk:function(){var t=this,e=this.$refs.addEditor.getValue();for(var a in e)if(""===e[a].url.url)return this.modalData=[],void this.$Message.error("请填写所有信息后再提交!");var o={id:this.modalInfo.resContentId,contentName:"楼层"+(this.floorList.length+1),templateKey:"123",contentData:n()({template_name:this.modalInfo.template_name,template_intro:this.modalInfo.template_intro,data:e}),type:this.modalInfo.modalType};-1===this.modalInfo.floorIndex?this.uploadData.items.push(o):(o=i()(o,{contentName:this.uploadData.items[this.modalInfo.floorIndex].contentName}),this.uploadData.items[this.modalInfo.floorIndex]=o),console.log("uploadData:",this.uploadData),this.resourceService.addOrUpdateResourceDetail(this.uploadData).then(function(e){console.log(e),e&&200===e.code?(t.$Message.success(e.message||"修改成功!"),t.getResourceDetailList(),t.modalData=[],t.modalInfo={modalType:0,modalTitle:"",resContentId:0,floorIndex:-1,template_intro:"",template_name:""},t.show=!1):(console.log(e),t.$Message.error(e.message||"修改失败!"))})},onCancel:function(){this.modalData=[],this.modalInfo={modalType:0,modalTitle:"",resContentId:0,floorIndex:-1,template_intro:"",template_name:""},this.show=!1}}}},336:function(t,e,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o=a(337),i=a(15);Object(i.a)(o.a)},337:function(t,e,a){"use strict";function o(t){n||a(338)}var i=a(132),s=a(339),n=!1,l=a(0),r=o,d=l(i.a,s.a,!1,r,null,null);d.options.__file="src/views/resource-edit-new/index.vue",e.a=d.exports},338:function(t,e){},339:function(t,e,a){"use strict";var o=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("LayoutContent",{attrs:{breads:[{url:"resource-list.html",title:"资源位列表"},{title:"资源位编辑"}]}},[o("div",{staticClass:"main"},[o("div",{staticClass:"editor-container"},[o("Card",[o("p",{attrs:{slot:"title"},slot:"title"},[t._v(t._s(t.title))]),t._v(" "),t._l(t.floorList,function(e,i){return[o("div",{staticClass:"floor-item"},["singleImage"===e.template_name?o("div",{staticClass:"floor-image"},[o("img",{staticStyle:{width:"100%"},attrs:{src:e.data[0].src.split("?")[0]||a(32)}}),t._v(" "),o("div",{staticClass:"floor-mask"},[o("div",{staticClass:"floor-edit-buttons"},[o("a",{attrs:{href:"javascript:void(0)"},on:{click:function(a){t.showModal("singleImage",e,i)}}},[t._v("编 辑")]),t._v(" "),o("a",{staticStyle:{"background-color":"red"},attrs:{href:"javascript:void(0)"},on:{click:function(e){t.showDeleteModal(i)}}},[t._v("删 除")])])])]):t._e(),t._v(" "),"twoPicture"===e.template_name?o("div",{staticClass:"floor-image"},[o("img",{staticStyle:{width:"50%",height:"120px"},attrs:{src:e.data[0].src.split("?")[0]||a(32)}}),t._v(" "),o("img",{staticStyle:{width:"50%",height:"120px"},attrs:{src:e.data[1].src.split("?")[0]||a(32)}}),t._v(" "),o("div",{staticClass:"floor-mask"},[o("div",{staticClass:"floor-edit-buttons"},[o("a",{attrs:{href:"javascript:void(0)"},on:{click:function(a){t.showModal("twoPicture",e,i)}}},[t._v("编 辑")]),t._v(" "),o("a",{staticStyle:{"background-color":"red"},attrs:{href:"javascript:void(0)"},on:{click:function(e){t.showDeleteModal(i)}}},[t._v("删 除")])])])]):t._e()]),t._v(" "),o("divide")]})],2)],1),t._v(" "),o("div",{staticClass:"button-container"},[o("Button",{attrs:{type:"primary"},on:{click:function(e){t.showModal("singleImage",t.singleData,-1)}}},[t._v("一张图")]),t._v(" "),o("Button",{attrs:{type:"primary"},on:{click:function(e){t.showModal("twoPicture",t.twoData,-1)}}},[t._v("两张图")])],1),t._v(" "),o("Modal",{attrs:{title:t.modalInfo.modalTitle,width:"650"},on:{"on-ok":t.onOk,"on-cancel":t.onCancel},model:{value:t.show,callback:function(e){t.show=e},expression:"show"}},[o("banner-editor",{ref:"addEditor",attrs:{hideAddButton:!0,hideDeleteButton:!0},model:{value:t.modalData,callback:function(e){t.modalData=e},expression:"modalData"}})],1)],1)])},i=[];o._withStripped=!0;var s={render:o,staticRenderFns:i};e.a=s},5:function(t,e){t.exports=iview},9:function(t,e){t.exports=Vue}},[336]);