import{$n as e,Dr as t,Jn as n,Lt as r,M as i,P as a,Qn as o,_r as s,cr as c,jr as l,qn as u,t as d,tr as f,ur as p,xr as m}from"./index-BoMYDb15.js";import{a as h}from"./VSelectionControl-B5eGceGg.js";import{t as g}from"./VSpacer-WnIlXIFa.js";import{t as _}from"./useSnackbar-D7YOfKok.js";import{t as v}from"./VChip-BNPTE1cg.js";import{t as y}from"./VSelect-rBl6yOEB.js";import{t as b}from"./VDataTableServer-BNLtj0ZC.js";import{i as x,n as S,t as C}from"./auditNormalize-Ce5FSsir.js";var w={class:`font-weight-medium`},T={class:`text-body-2`},E={class:`text-body-2 text-medium-emphasis text-truncate`,style:{"max-width":`300px`,display:`inline-block`}},D={class:`text-caption text-medium-emphasis`},O={class:`text-caption text-medium-emphasis`},k=f({__name:`AuditPage`,setup(f){let k=_(),A=m(!1),j=m([]),M=m(0),N=m(1),P=m(null),F=m(``),I=m(``),L=[{label:`创建`,value:`create`},{label:`更新`,value:`update`},{label:`删除`,value:`delete`},{label:`登录`,value:`login`},{label:`登出`,value:`logout`},{label:`执行`,value:`execute`},{label:`推送`,value:`push`}],R=[{title:`操作`,key:`action`,width:100},{title:`用户`,key:`admin_username`,width:100},{title:`目标`,key:`target`,width:140},{title:`详情`,key:`detail`},{title:`IP`,key:`ip_address`,width:120},{title:`时间`,key:`created_at`,width:160}];async function z(){A.value=!0;try{let e=(N.value-1)*50,t=await r.get(`/audit/`,{limit:50,offset:e,action:P.value||void 0,admin_username:F.value||void 0,date_from:I.value||void 0});j.value=C(t.items||[]),M.value=t.total||0}catch{j.value=[],k(`加载审计日志失败`,`error`)}finally{A.value=!1}}function B(e){return e.startsWith(`create`)||e===`login`?`success`:e.startsWith(`update`)?`info`:e.startsWith(`delete`)||e===`logout`?`error`:e.includes(`execute`)||e.includes(`push`)||e.includes(`retry`)?`warning`:`primary`}return c(()=>z()),(r,c)=>(p(),n(h,{fluid:``,class:`pa-6`},{default:s(()=>[e(i,{elevation:`0`,border:``,rounded:`lg`},{default:s(()=>[e(a,{class:`d-flex align-center`},{default:s(()=>[c[7]||=o(` 审计日志 `,-1),e(g),e(y,{modelValue:P.value,"onUpdate:modelValue":[c[0]||=e=>P.value=e,c[1]||=e=>{N.value=1,z()}],items:L,"item-title":`label`,"item-value":`value`,label:`操作类型`,variant:`outlined`,density:`compact`,"hide-details":``,style:{"max-width":`160px`},clearable:``},null,8,[`modelValue`]),e(d,{modelValue:F.value,"onUpdate:modelValue":[c[2]||=e=>F.value=e,c[3]||=e=>{N.value=1,z()}],"prepend-inner-icon":`mdi-account`,label:`用户`,variant:`outlined`,density:`compact`,"hide-details":``,style:{"max-width":`140px`},class:`ml-3`,clearable:``},null,8,[`modelValue`]),e(d,{modelValue:I.value,"onUpdate:modelValue":[c[4]||=e=>I.value=e,c[5]||=e=>{N.value=1,z()}],"prepend-inner-icon":`mdi-calendar`,label:`日期`,variant:`outlined`,density:`compact`,"hide-details":``,style:{"max-width":`160px`},class:`ml-3`,type:`date`,clearable:``},null,8,[`modelValue`])]),_:1}),e(b,{items:j.value,headers:R,"items-length":M.value,loading:A.value,page:N.value,"items-per-page":50,hover:``,density:`compact`,"onUpdate:page":c[6]||=e=>{N.value=e,z()}},{"item.action":s(({item:n})=>[e(v,{color:B(n.action),size:`small`,variant:`tonal`,label:``},{default:s(()=>[o(l(t(S)(n.action)),1)]),_:2},1032,[`color`])]),"item.admin_username":s(({item:e})=>[u(`span`,w,l(e.admin_username),1)]),"item.target":s(({item:e})=>[u(`span`,T,l(t(x)(e.resource_type))+l(e.resource_id?` #${e.resource_id}`:``),1)]),"item.detail":s(({item:e})=>[u(`span`,E,l(e.detail||`—`),1)]),"item.ip_address":s(({item:e})=>[u(`span`,D,l(e.ip_address||`—`),1)]),"item.created_at":s(({item:e})=>[u(`span`,O,l(e.created_at),1)]),"no-data":s(()=>[...c[8]||=[u(`div`,{class:`text-center text-medium-emphasis py-6`},`暂无数据`,-1)]]),_:1},8,[`items`,`items-length`,`loading`,`page`])]),_:1})]),_:1}))}});export{k as default};