import{A as e,D as t,M as n,N as r,O as i,S as a,T as o,_ as s,a as c,b as l,c as u,h as d,j as f,k as p,m,o as h,s as g,u as _,v,w as y,x as b,y as x}from"./index-jy40eMQa.js";import{t as S}from"./admin-CqpMrZ_s.js";import{r as C,t as w}from"./types-WIP_Oieg.js";var T={class:`user-list`},E={class:`search-bar`},D={class:`user-cell`},O={class:`user-info`},k={class:`user-name`},A={class:`user-email`},j={class:`pagination`},M=h(l({__name:`UserListView`,setup(r){let l=c(),h=e(!1),M=e([]),N=e(0),P=p({page:1,pageSize:20,search:``,status:void 0});b(()=>{F()});async function F(){h.value=!0;try{let e=await S.getUsers(P);e.success&&e.data&&(M.value=e.data.items,N.value=e.data.total)}finally{h.value=!1}}function I(){P.page=1,F()}function L(e){P.page=e,F()}function R(e){l.push(`/users/${e.id}`)}function z(e){l.push(`/users/${e.id}/bookmarks`)}async function B(e){let t=e.status===C.Normal,n=t?`禁用`:`启用`;try{await g.confirm(`确定要${n}用户 "${e.userName}" 吗？`,`${n}确认`,{confirmButtonText:`确定`,cancelButtonText:`取消`,type:`warning`}),(await S.setUserStatus(e.id,t)).success&&(u.success(`${n}成功`),F())}catch{}}function V(e){return e?new Date(e).toLocaleString(`zh-CN`):`-`}function H(e){return{[w.User]:`普通用户`,[w.Admin]:`管理员`,[w.SuperAdmin]:`超级管理员`}[e]||`未知`}function U(e){return{[w.User]:`info`,[w.Admin]:`warning`,[w.SuperAdmin]:`danger`}[e]||`info`}return(e,r)=>{let c=y(`Search`),l=y(`el-icon`),u=y(`el-input`),p=y(`el-option`),g=y(`el-select`),b=y(`el-button`),S=y(`el-avatar`),w=y(`el-table-column`),F=y(`el-tag`),W=y(`el-table`),G=y(`el-pagination`),K=o(`loading`);return a(),s(`div`,T,[r[6]||=m(`div`,{class:`page-header`},[m(`h2`,null,`用户管理`)],-1),m(`div`,E,[x(u,{modelValue:P.search,"onUpdate:modelValue":r[0]||=e=>P.search=e,placeholder:`搜索用户邮箱或用户名`,clearable:``,style:{width:`300px`},onKeyup:_(I,[`enter`])},{prefix:t(()=>[x(l,null,{default:t(()=>[x(c)]),_:1})]),_:1},8,[`modelValue`]),x(g,{modelValue:P.status,"onUpdate:modelValue":r[1]||=e=>P.status=e,placeholder:`用户状态`,clearable:``,style:{width:`150px`},onChange:I},{default:t(()=>[x(p,{label:`正常`,value:f(C).Normal},null,8,[`value`]),x(p,{label:`禁用`,value:f(C).Disabled},null,8,[`value`])]),_:1},8,[`modelValue`]),x(b,{type:`primary`,onClick:I},{default:t(()=>[...r[3]||=[v(`搜索`,-1)]]),_:1})]),i((a(),d(W,{data:M.value,class:`user-table`},{default:t(()=>[x(w,{label:`用户`,"min-width":`200`},{default:t(({row:e})=>[m(`div`,D,[x(S,{size:40,src:e.avatar},{default:t(()=>[v(n(e.userName?.[0]||`U`),1)]),_:2},1032,[`src`]),m(`div`,O,[m(`div`,k,n(e.userName),1),m(`div`,A,n(e.email),1)])])]),_:1}),x(w,{label:`角色`,width:`120`},{default:t(({row:e})=>[x(F,{type:U(e.role),size:`small`},{default:t(()=>[v(n(H(e.role)),1)]),_:2},1032,[`type`])]),_:1}),x(w,{label:`状态`,width:`100`},{default:t(({row:e})=>[x(F,{type:e.status===f(C).Normal?`success`:`danger`,size:`small`},{default:t(()=>[v(n(e.status===f(C).Normal?`正常`:`禁用`),1)]),_:2},1032,[`type`])]),_:1}),x(w,{label:`设备数`,width:`80`,align:`center`},{default:t(({row:e})=>[v(n(e.deviceCount),1)]),_:1}),x(w,{label:`书签数`,width:`80`,align:`center`},{default:t(({row:e})=>[v(n(e.bookmarkCount),1)]),_:1}),x(w,{label:`注册时间`,width:`180`},{default:t(({row:e})=>[v(n(V(e.createdAt)),1)]),_:1}),x(w,{label:`最后登录`,width:`180`},{default:t(({row:e})=>[v(n(V(e.lastLoginAt)),1)]),_:1}),x(w,{label:`操作`,width:`220`,fixed:`right`},{default:t(({row:e})=>[x(b,{size:`small`,onClick:t=>R(e)},{default:t(()=>[...r[4]||=[v(` 详情 `,-1)]]),_:1},8,[`onClick`]),x(b,{size:`small`,onClick:t=>z(e)},{default:t(()=>[...r[5]||=[v(` 书签 `,-1)]]),_:1},8,[`onClick`]),x(b,{size:`small`,type:e.status===f(C).Normal?`danger`:`success`,onClick:t=>B(e)},{default:t(()=>[v(n(e.status===f(C).Normal?`禁用`:`启用`),1)]),_:2},1032,[`type`,`onClick`])]),_:1})]),_:1},8,[`data`])),[[K,h.value]]),m(`div`,j,[x(G,{"current-page":P.page,"onUpdate:currentPage":r[2]||=e=>P.page=e,"page-size":P.pageSize,total:N.value,layout:`total, prev, pager, next`,onCurrentChange:L},null,8,[`current-page`,`page-size`,`total`])])])}}}),[[`__scopeId`,`data-v-a21164e0`]]);export{M as default};