var $url="/settings/sitesTemplates",$urlUpload=$apiUrl+"/settings/sitesTemplates/actions/upload",data=utils.init({pageType:null,siteTemplateInfoList:null,fileNameList:null,siteTemplateUrl:null,siteAddPermission:!1,uploadPanel:!1,uploadLoading:!1,uploadList:[]}),error=null,methods={apiGet:function(){var t=this;$api.get($url).then(function(i){var e=i.data;t.siteTemplateInfoList=e.siteTemplateInfoList,t.fileNameList=e.fileNameList,t.siteTemplateUrl=e.siteTemplateUrl,t.siteAddPermission=e.siteAddPermission}).catch(function(t){utils.error(t)}).then(function(){utils.loading(t,!1)})},btnCreateClick:function(t){location.href=utils.getSettingsUrl("sitesAdd",{type:"submit",createType:"local",localDirectoryName:t.directoryName})},btnEditClick:function(t){location.href=utils.getSettingsUrl("administratorsRoleAdd",{roleId:t.id})},btnDownloadClick:function(t){window.open("/"+this.siteTemplateUrl+"/"+t.directoryName+".zip")},btnZipClick:function(t){var i=this;utils.loading(this,!0),$api.post($url+"/actions/zip",{directoryName:t.directoryName}).then(function(i){i.data;utils.success("站点模板压缩成功！"),t.fileExists=!0}).catch(function(t){utils.error(t)}).then(function(){utils.loading(i,!1)})},btnDeleteClick:function(t){var i=this;utils.alertDelete({title:"删除站点模板",text:"此操作将会删除此站点模板“"+t.siteTemplateName+"”，确认吗？",callback:function(){i.apiDelete(t)}})},apiDelete:function(t){var i=this;utils.loading(this,!0),$api.delete($url,{data:{directoryName:t.directoryName}}).then(function(t){t.data;utils.success("站点模板删除成功！"),i.apiGet()}).catch(function(t){utils.error(t)}).then(function(){utils.loading(i,!1)})},btnUnZipClick:function(t){var i=this;utils.loading(this,!0),$api.post($url+"/actions/unZip",{fileName:t}).then(function(t){var e=t.data;i.$notify.success({title:"成功",message:"站点模板解压成功！"}),i.siteTemplateInfoList=e.siteTemplateInfoList,i.fileNameList=e.fileNameList}).catch(function(t){utils.error(t)}).then(function(){utils.loading(i,!1)})},btnDownloadFileClick:function(t){window.open("/"+this.siteTemplateUrl+"/"+t)},btnDeleteFileClick:function(t){var i=this;utils.alertDelete({title:"删除站点模板压缩包",text:"此操作将会删除此站点模板压缩包“"+t+"”，确认吗？",callback:function(){i.apiDeleteFile(t)}})},apiDeleteFile:function(t){var i=this;utils.loading(this,!0),$api.delete($url,{data:{fileName:t}}).then(function(e){e.data;utils.success("站点模板压缩包删除成功！"),i.fileNameList.splice(i.fileNameList.indexOf(t),1)}).catch(function(t){utils.error(t)}).then(function(){utils.loading(i,!1)})},btnUploadClick:function(){this.uploadPanel=!0},uploadBefore(t){var i=-1!==t.name.indexOf(".zip",t.name.length-".zip".length);return i||utils.error("上传站点模板只能是 Zip 格式!"),i},uploadProgress:function(){utils.loading(this,!0)},uploadSuccess:function(t,i){utils.loading(this,!1),this.siteTemplateInfoList=t.siteTemplateInfoList,this.fileNameList=t.fileNameList,this.siteTemplateUrl=t.siteTemplateUrl,this.uploadPanel=!1,utils.success("站点模板上传成功！")},uploadError:function(t){utils.loading(this,!1);var i=JSON.parse(t.message);utils.error(i.message)}},$vue=new Vue({el:"#main",data:data,methods:methods,created:function(){this.apiGet()}});