var $url="/settings/administratorsAccessTokens",data=utils.init({tokens:null,adminNames:null,scopes:null,adminName:null,panel:!1,form:{}}),methods={apiGet:function(){var t=this;utils.loading(this,!0),$api.get($url).then(function(i){var n=i.data;t.tokens=n.tokens,t.adminNames=n.adminNames,t.scopes=n.scopes,t.adminName=n.adminName}).catch(function(t){utils.error(t)}).then(function(){utils.loading(t,!1)})},apiDelete:function(t){var i=this;utils.loading(this,!0),$api.delete($url,{data:{id:t.id}}).then(function(t){var n=t.data;i.tokens=n.tokens}).catch(function(t){utils.error(t)}).then(function(){utils.loading(i,!1)})},apiSubmit:function(){var t=this;utils.loading(this,!0),$api.post($url,this.form).then(function(i){var n=i.data;t.tokens=n.tokens,utils.success(t.form.id>0?"API密钥修改成功！":"API密钥添加成功！"),t.panel=!1}).catch(function(t){utils.error(t)}).then(function(){utils.loading(t,!1)})},getDocsUrl:function(t){return cloud.getDocsUrl(t)},getItemScopes:function(t){if(!t.scopes)return"";for(var i=t.scopes,n=[],e=0;e<this.scopes.length;e++)-1!==i.indexOf(this.scopes[e])&&n.push(this.scopes[e]);return n.join(",")},btnSubmitClick:function(){var t=this;this.$refs.form.validate(function(i){i&&t.apiSubmit()})},btnViewClick:function(t){utils.openLayer({title:"获取密钥",url:utils.getSettingsUrl("administratorsAccessTokensLayerView",{id:t.id}),width:550,height:410})},btnDeleteClick:function(t){var i=this;utils.alertDelete({title:"删除API密钥",text:"此操作将删除API密钥 "+t.title+"，确定吗？",callback:function(){i.apiDelete(t)}})},btnEditClick:function(t){this.form={id:t.id,title:t.title,adminName:t.adminName?t.adminName:this.adminName,scopes:t.scopes},this.panel=!0},btnCancelClick:function(){this.panel=!1},btnAddClick:function(){this.form={id:0,title:"",adminName:"",scopes:[]},this.panel=!0}},$vue=new Vue({el:"#main",data:data,methods:methods,created:function(){this.apiGet()}});