var $url="/settings/users",$urlExport=$url+"/actions/export",$urlUpload=$apiUrl+"/settings/users/actions/import",data=utils.init({items:null,count:null,groups:null,formInline:{state:"",groupId:-1,order:"",lastActivityDate:0,keyword:"",currentPage:1,offset:0,limit:30},uploadPanel:!1,uploadLoading:!1,uploadList:[]}),methods={apiGet:function(){var t=this;$api.get($url,{params:this.formInline}).then(function(i){var n=i.data;t.items=n.users,t.count=n.count,t.groups=n.groups}).catch(function(t){utils.error(t)}).then(function(){utils.loading(t,!1)})},getGroupName:function(t){var i=_.find(this.groups,function(i){return i.id===t});return i?i.groupName:"默认用户组"},btnViewClick:function(t){utils.openLayer({title:"查看资料",url:utils.getCommonUrl("userLayerView",{userId:t})})},btnAddClick:function(){utils.openLayer({title:"添加用户",url:utils.getSettingsUrl("usersLayerProfile")})},btnEditClick:function(t){utils.openLayer({title:"编辑用户",url:utils.getSettingsUrl("usersLayerProfile",{userId:t.id})})},btnPasswordClick:function(t){utils.openLayer({title:"更改密码",url:utils.getSettingsUrl("usersLayerPassword",{userId:t.id})})},btnExportClick:function(){var t=this;utils.loading(this,!0),$api.post($urlExport).then(function(t){var i=t.data;window.open(i.value)}).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(n){n.data;i.items.splice(i.items.indexOf(t),1)}).catch(function(t){utils.error(t)}).then(function(){utils.loading(i,!1)})},btnDeleteClick:function(t){var i=this;utils.alertDelete({title:"删除用户",text:"此操作将删除用户 "+t.userName+"，确定吗？",callback:function(){i.apiDelete(t)}})},apiCheck:function(t){var i=this;utils.loading(this,!0),$api.post($url+"/actions/check",{id:t.id}).then(function(i){i.data;t.checked=!0}).catch(function(t){utils.error(t)}).then(function(){utils.loading(i,!1)})},btnCheckClick:function(t){var i=this;utils.alertWarning({title:"审核用户",text:"此操作将设置用户 "+t.userName+" 的状态为审核通过，确定吗？",callback:function(){i.apiCheck(t)}})},apiLock:function(t){var i=this;utils.loading(this,!0),$api.post($url+"/actions/lock",{id:t.id}).then(function(i){i.data;t.locked=!0}).catch(function(t){utils.error(t)}).then(function(){utils.loading(i,!1)})},btnLockClick:function(t){var i=this;utils.alertWarning({title:"锁定用户",text:"此操作将锁定用户 "+t.userName+"，确定吗？",callback:function(){i.apiLock(t)}})},apiUnLock:function(t){var i=this;utils.loading(this,!0),$api.post($url+"/actions/unLock",{id:t.id}).then(function(i){i.data;t.locked=!1}).catch(function(t){utils.error(t)}).then(function(){utils.loading(i,!1)})},btnUnLockClick:function(t){var i=this;utils.alertWarning({title:"解锁用户",text:"此操作将解锁用户 "+t.userName+"，确定吗？",callback:function(){i.apiUnLock(t)}})},btnSearchClick(){var t=this;utils.loading(this,!0),$api.get($url,{params:this.formInline}).then(function(i){var n=i.data;t.items=n.users,t.count=n.count}).catch(function(t){utils.error(t)}).then(function(){utils.loading(t,!1)})},handleCurrentChange:function(t){this.formInline.currentValue=t,this.formInline.offset=this.formInline.limit*(t-1),this.btnSearchClick()},btnImportClick:function(){this.uploadPanel=!0},uploadBefore(t){var i=-1!==t.name.indexOf(".xlsx",t.name.length-".xlsx".length);return i||utils.error("用户导入文件只能是 Excel 格式!"),i},uploadProgress:function(){utils.loading(this,!0)},uploadSuccess:function(t,i){this.uploadPanel=!1;var n=t.success,e=t.failure,u=t.errorMessage,r=this;$api.get($url,{params:this.formInline}).then(function(t){var i=t.data;r.items=i.users,r.count=i.count,r.groups=i.groups}).catch(function(t){utils.error(t)}).then(function(){n&&utils.success("成功导入 "+n+" 名用户！"),u&&utils.error(e+" 名用户导入失败："+u),utils.loading(r,!1)})},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()}});