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,isThumb:!1,thumbWidth:500,thumbHeight:500,isLinkToOriginal:!0,filePaths:[]}}),methods={parentInsert:function(t,i){var e=parent.$vue;if(e.runFormLayerImageUploadText&&e.runFormLayerImageUploadText(this.attributeName,t,i.imageVirtualUrl),e.runFormLayerImageUploadEditor&&this.editorAttributeName&&this.form.isEditor){var r='<img src="'+i.imageUrl+'" style="border: 0; max-width: 100%" />';if(i.previewUrl){var a='<el-image src="'+i.imageUrl+'" style="border: 0; max-width: 100%"></el-image>';r='<img data-vue="'+encodeURIComponent(a)+'" src="'+i.imageUrl+'" style="border: 0; max-width: 100%" />'}e.runFormLayerImageUploadEditor(this.editorAttributeName,r)}},apiGet:function(){var t=this;utils.loading(this,!0),$api.get($url,{params:{siteId:this.form.siteId}}).then(function(i){var e=i.data;t.form.isEditor=e.isEditor,t.form.isThumb=e.isThumb,t.form.thumbWidth=e.thumbWidth,t.form.thumbHeight=e.thumbHeight,t.form.isLinkToOriginal=e.isLinkToOriginal}).catch(function(t){utils.error(t)}).then(function(){utils.loading(t,!1)})},apiSubmit:function(){var t=this;utils.loading(this,!0),$api.post($url,this.form).then(function(i){var e=i.data;if(e&&e.length>0)for(var r=0;r<e.length;r++){var a=e[r];t.parentInsert(t.no+r,a)}utils.closeLayer()}).catch(function(t){utils.error(t)}).then(function(){utils.loading(t,!1)})},btnSubmitClick:function(){if(0===this.form.filePaths.length)return utils.error("请选择需要插入的图片文件！"),!1;this.apiSubmit()},btnCancelClick:function(){utils.closeLayer()},uploadBefore:t=>!!(t.size/1024/1024<10)||(utils.error("上传图片大小不能超过 10MB!"),!1),uploadProgress:function(){utils.loading(this,!0)},uploadSuccess:function(t){this.form.filePaths.push(t.path),utils.loading(this,!1)},uploadError:function(t){utils.loading(this,!1);var i=JSON.parse(t.message);utils.error(i.message)},uploadRemove(t){t.response&&this.form.filePaths.splice(this.form.filePaths.indexOf(t.response.path),1)},uploadPictureCardPreview(t){this.dialogImageUrl=t.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()}});