var $url="/common/editor/layerImage",data=utils.init({attributeName:utils.getQueryString("attributeName"),uploadList:[],dialogImageUrl:"",dialogVisible:!1,form:{siteId:utils.getQueryInt("siteId"),isMaterial:!0,isThumb:!1,thumbWidth:500,thumbHeight:500,isLinkToOriginal:!0,filePaths:[]}}),methods={insert:function(i){if(parent.$vue.runEditorLayerImage){var t='<img src="'+i.imageUrl+'" style="border: 0; max-width: 100%" />';if(i.previewUrl){var e='<el-image src="'+i.imageUrl+'" style="border: 0; max-width: 100%"></el-image>';t='<img data-vue="'+encodeURIComponent(e)+'" src="'+i.imageUrl+'" style="border: 0; max-width: 100%" />'}parent.$vue.runEditorLayerImage(this.attributeName,t)}},apiGet:function(){var i=this;utils.loading(this,!0),$api.get($url,{params:{siteId:this.form.siteId}}).then(function(t){var e=t.data;i.form.isMaterial=e.isMaterial,i.form.isThumb=e.isThumb,i.form.thumbWidth=e.thumbWidth,i.form.thumbHeight=e.thumbHeight,i.form.isLinkToOriginal=e.isLinkToOriginal}).catch(function(i){utils.error(i)}).then(function(){utils.loading(i,!1)})},apiSubmit:function(){var i=this;utils.loading(this,!0),$api.post($url,this.form).then(function(t){var e=t.data;if(e&&e.length>0)for(var a=0;a<e.length;a++){var r=e[a];i.insert(r)}utils.closeLayer()}).catch(function(i){utils.error(i)}).then(function(){utils.loading(i,!1)})},btnSubmitClick:function(){if(0===this.form.filePaths.length)return utils.error("请选择需要插入的图片文件！"),!1;this.apiSubmit()},btnCancelClick:function(){utils.closeLayer()},uploadBefore:i=>!0,uploadProgress:function(){utils.loading(this,!0)},uploadSuccess:function(i){this.form.filePaths.push(i.path),utils.loading(this,!1)},uploadError:function(i){utils.loading(this,!1);var t=JSON.parse(i.message);utils.error(t.message)},uploadRemove(i){i.response&&this.form.filePaths.splice(this.form.filePaths.indexOf(i.response.path),1)},uploadPictureCardPreview(i){this.dialogImageUrl=i.url,this.dialogVisible=!0}},$vue=new Vue({el:"#main",data:data,methods:methods,created:function(){this.uploadUrl=$apiUrl+$url+"/actions/upload?siteId="+this.form.siteId,this.apiGet()}});