var $url="/settings/sites",data=utils.init({siteTypes:null,sites:null,rootSiteId:null,tableNames:null,site:null,editPanel:!1,editForm:null,editLoading:!1,editRules:{siteName:[{required:!0,message:"请输入站点名称",trigger:"blur"}],siteDir:[{required:!0,message:"请输入文件夹名称",trigger:"blur"}],taxis:[{required:!0,message:"请输入正确的站点排序",trigger:"blur"}]},deletePanel:!1,deleteForm:null,deleteLoading:!1}),methods={getSiteType:function(t){return(t=this.siteTypes.find(function(e){return e.id===t}))?t.text:"网站"},apiGet:function(){var t=this;$api.get($url).then(function(e){var i=e.data;t.siteTypes=i.siteTypes,t.sites=i.sites,t.rootSiteId=i.rootSiteId,t.tableNames=i.tableNames}).catch(function(t){utils.error(t)}).then(function(){utils.loading(t,!1)})},apiDelete:function(){var t=this;$api.delete($url,{data:this.deleteForm}).then(function(e){var i=e.data;t.sites=i.sites,t.deletePanel=!1,setTimeout(function(){window.top.location.href=utils.getIndexUrl()},1500)}).catch(function(t){utils.error(t)}).then(function(){t.deleteLoading=!1})},apiEdit:function(){var t=this;$api.put($url,this.editForm).then(function(e){var i=e.data;t.sites=i.sites,t.editPanel=!1}).catch(function(t){utils.error(t)}).then(function(){t.editLoading=!1})},btnAddClick:function(){utils.addTab("创建新站点",utils.getSettingsUrl("sitesAdd"))},btnSaveClick:function(t){utils.addTab("保存站点模板",utils.getSettingsUrl("sitesSave",{siteId:t.id}))},btnChangeClick:function(t){var e=t.root?"转移到子目录":"转移到根目录";utils.addTab(e,utils.getSettingsUrl("sitesChangeRoot",{siteId:t.id}))},btnEditClick:function(t){this.editForm={siteId:t.id,root:t.root,siteName:t.siteName,siteType:t.siteType,siteDir:t.siteDir,parentId:t.parentId,taxis:t.taxis,tableRule:"Choose",tableChoose:t.tableName,tableHandWrite:""},this.editPanel=!0},btnEditCancelClick:function(){this.editPanel=!1,this.editLoading=!1},btnEditSubmitClick:function(){var t=this;this.$refs.editForm.validate(function(e){e&&(t.editLoading=!0,t.apiEdit())})},btnDeleteClick:function(t){var e=t;this.deleteForm={siteId:e.id,siteName:e.siteName,dir:e.siteDir,siteDir:null,deleteFiles:!0},this.deletePanel=!0},btnDeleteCancelClick:function(){this.deletePanel=!1,this.deleteLoading=!1},btnDeleteSubmitClick:function(){var t=this;this.$refs.deleteForm.validate(function(e){e&&(t.deleteLoading=!0,t.apiDelete())})}},$vue=new Vue({el:"#main",data:data,methods:methods,created:function(){this.apiGet()}});