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,f as d,g as f,h as p,i as m,j as h,m as g,o as _,s as v,v as y,w as b,x,y as S}from"./index-jy40eMQa.js";import{t as C}from"./admin-CqpMrZ_s.js";import{n as w,r as T,t as E}from"./types-WIP_Oieg.js";var D={class:`user-detail`},O={class:`page-header`},k={class:`info-card`},A={class:`card-header`},j={class:`info-grid`},M={class:`info-item`},N={class:`info-item`},P={class:`info-item`},F={class:`info-item`},I={class:`info-item`},L={class:`info-item`},R={class:`info-item`},z={class:`info-card`},B={class:`card-header`},V={key:1},H=_(l({__name:`UserDetailView`,setup(r){let l=m(),_=c(),H=e(!0),U=e(null),W=l.params.id;x(async()=>{try{let e=await C.getUserDetail(W);e.success&&e.data&&(U.value=e.data)}finally{H.value=!1}});async function G(){try{await v.confirm(`确定要重置该用户的密码吗？新密码将显示一次，请妥善保存。`,`重置密码`,{confirmButtonText:`确定`,cancelButtonText:`取消`,type:`warning`});let e=await C.resetUserPassword(W);e.success&&e.data&&v.alert(`新密码: ${e.data}`,`密码已重置`,{confirmButtonText:`我已记录`})}catch{}}async function K(e){try{await v.confirm(`确定要强制设备 "${e.deviceName}" 下线吗？`,`强制下线`,{confirmButtonText:`确定`,cancelButtonText:`取消`,type:`warning`}),(await C.forceDeviceLogout(e.id)).success&&u.success(`已强制下线`)}catch{}}async function q(e){let t=e.status===w.Normal,n=t?`禁用`:`启用`;try{await v.confirm(`确定要${n}设备 "${e.deviceName}" 吗？`,`${n}设备`,{confirmButtonText:`确定`,cancelButtonText:`取消`,type:`warning`}),(await C.setDeviceStatus(e.id,t)).success&&(u.success(`${n}成功`),e.status=t?w.Disabled:w.Normal)}catch{}}function J(e){return e?new Date(e).toLocaleString(`zh-CN`):`-`}function Y(e){return{[E.User]:`普通用户`,[E.Admin]:`管理员`,[E.SuperAdmin]:`超级管理员`}[e]||`未知`}return(e,r)=>{let c=b(`ArrowLeft`),l=b(`el-icon`),u=b(`el-button`),m=b(`el-tag`),v=b(`el-table-column`),x=b(`el-table`),C=o(`loading`);return i((a(),s(`div`,D,[g(`div`,O,[S(u,{onClick:r[0]||=e=>h(_).back()},{default:t(()=>[S(l,null,{default:t(()=>[S(c)]),_:1}),r[1]||=y(` 返回 `,-1)]),_:1}),r[2]||=g(`h2`,null,`用户详情`,-1)]),U.value?(a(),s(d,{key:0},[g(`div`,k,[g(`div`,A,[r[4]||=g(`h3`,null,`基本信息`,-1),S(u,{type:`primary`,onClick:G},{default:t(()=>[...r[3]||=[y(`重置密码`,-1)]]),_:1})]),g(`div`,j,[g(`div`,M,[r[5]||=g(`label`,null,`用户名`,-1),g(`span`,null,n(U.value.userName),1)]),g(`div`,N,[r[6]||=g(`label`,null,`邮箱`,-1),g(`span`,null,n(U.value.email),1)]),g(`div`,P,[r[7]||=g(`label`,null,`角色`,-1),g(`span`,null,n(Y(U.value.role)),1)]),g(`div`,F,[r[8]||=g(`label`,null,`状态`,-1),S(m,{type:U.value.status===h(T).Normal?`success`:`danger`,size:`small`},{default:t(()=>[y(n(U.value.status===h(T).Normal?`正常`:`禁用`),1)]),_:1},8,[`type`])]),g(`div`,I,[r[9]||=g(`label`,null,`注册时间`,-1),g(`span`,null,n(J(U.value.createdAt)),1)]),g(`div`,L,[r[10]||=g(`label`,null,`最后登录`,-1),g(`span`,null,n(J(U.value.lastLoginAt)),1)]),g(`div`,R,[r[11]||=g(`label`,null,`书签数量`,-1),g(`span`,null,n(U.value.bookmarkCount),1)])])]),g(`div`,z,[g(`div`,B,[g(`h3`,null,`设备列表 (`+n(U.value.devices.length)+`)`,1)]),S(x,{data:U.value.devices,class:`device-table`},{default:t(()=>[S(v,{label:`设备名称`,prop:`deviceName`,"min-width":`150`}),S(v,{label:`设备类型`,prop:`deviceType`,"min-width":`150`}),S(v,{label:`管理员设备`,width:`100`,align:`center`},{default:t(({row:e})=>[e.isAdmin?(a(),p(m,{key:0,type:`warning`,size:`small`},{default:t(()=>[...r[12]||=[y(`是`,-1)]]),_:1})):(a(),s(`span`,V,`-`))]),_:1}),S(v,{label:`状态`,width:`100`},{default:t(({row:e})=>[S(m,{type:e.status===h(w).Normal?`success`:`danger`,size:`small`},{default:t(()=>[y(n(e.status===h(w).Normal?`正常`:`禁用`),1)]),_:2},1032,[`type`])]),_:1}),S(v,{label:`最后活跃`,width:`180`},{default:t(({row:e})=>[y(n(J(e.lastActiveAt)),1)]),_:1}),S(v,{label:`操作`,width:`180`},{default:t(({row:e})=>[S(u,{size:`small`,onClick:t=>K(e)},{default:t(()=>[...r[13]||=[y(` 强制下线 `,-1)]]),_:1},8,[`onClick`]),S(u,{size:`small`,type:e.status===h(w).Normal?`danger`:`success`,onClick:t=>q(e)},{default:t(()=>[y(n(e.status===h(w).Normal?`禁用`:`启用`),1)]),_:2},1032,[`type`,`onClick`])]),_:1})]),_:1},8,[`data`])])],64)):f(``,!0)])),[[C,H.value]])}}}),[[`__scopeId`,`data-v-d2de856f`]]);export{H as default};