var $url="/cms/templates/templatesAssets",data=utils.init({siteId:utils.getQueryInt("siteId"),directories:null,allFiles:null,files:null,siteUrl:null,includeDir:null,cssDir:null,jsDir:null,fileType:utils.getQueryString("fileType")||"All",directoryPaths:[],keyword:"",configPanel:!1,configParent:null,configForm:null}),methods={apiList:function(){var i=this;utils.loading(this,!0),$api.get($url,{params:{siteId:this.siteId,fileType:this.fileType}}).then(function(t){var e=t.data;i.directories=e.directories,i.allFiles=e.files,i.siteUrl=e.siteUrl,i.includeDir=e.includeDir,i.cssDir=e.cssDir,i.jsDir=e.jsDir,i.reload()}).catch(function(i){utils.error(i)}).then(function(){utils.loading(i,!1)})},apiDelete:function(i){var t=this;utils.loading(this,!0),$api.delete($url,{data:{siteId:this.siteId,fileType:this.fileType,directoryPath:i.directoryPath,fileName:i.fileName}}).then(function(e){e.data;t.allFiles.splice(t.allFiles.indexOf(i),1),t.reload(),utils.success("文件删除成功！")}).catch(function(i){utils.error(i)}).then(function(){utils.loading(t,!1)})},apiConfig:function(){var i=this;this.loading=this.$loading(),$api.post($url+"/actions/config",this.configForm).then(function(t){var e=t.data;i.directories=e.directories,i.allFiles=e.files,i.siteUrl=e.siteUrl,i.includeDir=e.includeDir,i.cssDir=e.cssDir,i.jsDir=e.jsDir,i.reload(),i.configPanel=!1,utils.success("文件夹路径设置成功!")}).catch(function(i){utils.error(i)}).then(function(){utils.loading(i,!1)})},getFileType:function(i){return"html"===i?"包含文件":"css"===i?"样式文件":"js"===i?"脚本文件":""},btnDefaultClick:function(i){var t=this;utils.alertWarning({title:"设置默认文件",text:"此操作将把文件 "+i.templateName+" 设为默认"+this.getTemplateType(i.fileType)+"，确认吗？",callback:function(){t.apiDefault(i)}})},btnCopyClick:function(i){var t=this;utils.loading(this,!0),$api.post($url+"/actions/copy",{siteId:this.siteId,templateId:i.id}).then(function(i){var e=i.data;t.directories=e.directories,t.allFiles=e.files,t.reload(),utils.success("快速复制成功！")}).catch(function(i){utils.error(i)}).then(function(){utils.loading(t,!1)})},btnDeleteClick:function(i){var t=this;utils.alertDelete({title:"删除文件",text:"此操作将删除文件 "+i.directoryPath+"/"+i.fileName+"，确认吗？",callback:function(){t.apiDelete(i)}})},btnAddClick:function(i){utils.addTab("新增"+this.getFileType(i),this.getEditorUrl("","",i))},btnEditClick:function(i){utils.addTab("编辑:"+i.directoryPath+"/"+i.fileName,this.getEditorUrl(i.directoryPath,i.fileName,i.fileType))},getEditorUrl:function(i,t,e){return utils.getCmsUrl("templatesAssetsEditor",{siteId:this.siteId,directoryPath:i,fileName:t,fileType:e,tabName:utils.getTabName()})},getPageUrl:function(i){return this.siteUrl+"/"+i},reload:function(){var i=this;this.files=_.filter(this.allFiles,function(t){var e=!0,l=!0,s=!0;if("All"!=i.fileType&&(e=_.endsWith(t.fileName,i.fileType)),i.directoryPaths.length>0){l=!1;for(var n=0;n<i.directoryPaths.length;n++){var r=i.directoryPaths[n][i.directoryPaths[n].length-1];t.directoryPath==r&&(l=!0)}}return i.keyword&&(s=-1!==(t.directoryPath||"").indexOf(i.keyword)||-1!==(t.fileName||"").indexOf(i.keyword)),e&&l&&s})},btnConfigClick:function(){this.configForm={siteId:this.siteId,fileType:this.fileType,includeDir:this.includeDir,cssDir:this.cssDir,jsDir:this.jsDir},this.configPanel=!0},btnConfigCancelClick:function(){this.configPanel=!1},btnConfigSubmitClick:function(){var i=this;this.$refs.configForm.validate(function(t){t&&i.apiConfig()})}},$vue=new Vue({el:"#main",data:data,methods:methods,created:function(){this.apiList()}});