import{Fr as e,Lt as t,M as n,P as r,Tr as i,Xn as a,Yn as o,br as s,er as c,fr as l,jr as u,rr as d,t as f,tr as p,ur as m}from"./index-BK7IqYFO.js";import{a as h}from"./VSelectionControl-DfqKEOBG.js";import{t as g}from"./VSpacer-iEyUcuqg.js";import{t as _}from"./useSnackbar-D7YOfKok.js";import{t as v}from"./VChip-BiQSOiSv.js";import{t as y}from"./VSelect-DUDHUuZi.js";import{t as b}from"./VDataTableServer-CWRB8rfU.js";import{a as x,n as S,r as C,t as w}from"./auditNormalize-BHJPJFP9.js";var T={class:`font-weight-medium`},E={class:`text-body-2`},D={class:`text-body-2 text-medium-emphasis text-truncate`,style:{"max-width":`300px`,display:`inline-block`}},O={class:`text-caption text-medium-emphasis`},k={class:`text-caption text-medium-emphasis`},A=d({__name:`AuditPage`,setup(d){let A=_(),j=i(!1),M=i([]),N=i(0),P=i(1),F=i(null),I=i(``),L=i(``),R=S,z=[{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 B(){j.value=!0;try{let e=(P.value-1)*50,n=await t.get(`/audit/`,{limit:50,offset:e,action:F.value||void 0,admin_username:I.value||void 0,date_from:L.value||void 0});M.value=w(n.items||[]),N.value=n.total||0}catch{M.value=[],A(`加载审计日志失败`,`error`)}finally{j.value=!1}}function V(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 m(()=>B()),(t,i)=>(l(),a(h,{fluid:``,class:`pa-6`},{default:s(()=>[p(n,{elevation:`0`,border:``,rounded:`lg`},{default:s(()=>[p(r,{class:`d-flex align-center`},{default:s(()=>[i[7]||=c(` 审计日志 `,-1),p(g),p(y,{modelValue:F.value,"onUpdate:modelValue":[i[0]||=e=>F.value=e,i[1]||=e=>{P.value=1,B()}],items:u(R),"item-title":`label`,"item-value":`value`,label:`操作类型`,variant:`outlined`,density:`compact`,"hide-details":``,style:{"max-width":`200px`},clearable:``},null,8,[`modelValue`,`items`]),p(f,{modelValue:I.value,"onUpdate:modelValue":[i[2]||=e=>I.value=e,i[3]||=e=>{P.value=1,B()}],"prepend-inner-icon":`mdi-account`,label:`用户`,variant:`outlined`,density:`compact`,"hide-details":``,style:{"max-width":`140px`},class:`ml-3`,clearable:``},null,8,[`modelValue`]),p(f,{modelValue:L.value,"onUpdate:modelValue":[i[4]||=e=>L.value=e,i[5]||=e=>{P.value=1,B()}],"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}),p(b,{items:M.value,headers:z,"items-length":N.value,loading:j.value,page:P.value,"items-per-page":50,hover:``,density:`compact`,"onUpdate:page":i[6]||=e=>{P.value=e,B()}},{"item.action":s(({item:t})=>[p(v,{color:V(t.action),size:`small`,variant:`tonal`,label:``},{default:s(()=>[c(e(u(C)(t.action)),1)]),_:2},1032,[`color`])]),"item.admin_username":s(({item:t})=>[o(`span`,T,e(t.admin_username),1)]),"item.target":s(({item:t})=>[o(`span`,E,e(u(x)(t.resource_type))+e(t.resource_id?` #${t.resource_id}`:``),1)]),"item.detail":s(({item:t})=>[o(`span`,D,e(t.detail||`—`),1)]),"item.ip_address":s(({item:t})=>[o(`span`,O,e(t.ip_address||`—`),1)]),"item.created_at":s(({item:t})=>[o(`span`,k,e(t.created_at),1)]),"no-data":s(()=>[...i[8]||=[o(`div`,{class:`text-center text-medium-emphasis py-6`},`暂无数据`,-1)]]),_:1},8,[`items`,`items-length`,`loading`,`page`])]),_:1})]),_:1}))}});export{A as default};