var $url="/common/form/layerImageUpload",data=utils.init({attributeName:utils.getQueryString("attributeName"),no:utils.getQueryInt("no"),editorAttributeName:utils.getQueryString("editorAttributeName"),uploadUrl:null,dialogImageUrl:"",dialogVisible:!1,form:{siteId:utils.getQueryInt("siteId"),isEditor:!1,isMaterial:!0,isThumb:!1,thumbWidth:500,thumbHeight:500,isLinkToOriginal:!0,filePaths:[]}}),methods={parentInsert:function(i,t){var e=parent.$vue;if(e.runFormLayerImageUploadText&&e.runFormLayerImageUploadText(this.attributeName,i,t.imageVirtualUrl),e.runFormLayerImageUploadEditor&&this.editorAttributeName&&this.form.isEditor){var r='<img src="'+t.imageUrl+'" style="border: 0; max-width: 100%" />';if(t.previewUrl){var a='<el-image src="'+t.imageUrl+'" style="border: 0; max-width: 100%"></el-image>';r='<img data-vue="'+encodeURIComponent(a)+'" src="'+t.imageUrl+'" style="border: 0; max-width: 100%" />'}e.runFormLayerImageUploadEditor(this.editorAttributeName,r)}},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.isEditor=e.isEditor,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 r=0;r<e.length;r++){var a=e[r];i.parentInsert(i.no+r,a)}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=>!!(i.size/1024/1024<10)||(utils.error("上传图片大小不能超过 10MB!"),!1),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()}});