import{l as f}from"./monitor-wjQIzRk9.js";import{d as M,u as q,a as A,v as E,o as F,c as H,b as e,w as a,f as r,g as C,e as b,h as x,i as _,j as i,N as K,B as d,k as c,H as G,K as J,z as Q,t as W,n as z,L as X}from"./index-CkzfmDGw.js";import{S as Y}from"./SearchOutline-BKr0yDBJ.js";import{R as Z}from"./RefreshOutline-DXhpU5zO.js";import{T as $}from"./TrashOutline-DHG1tVXU.js";const ee={class:"page-container"},te={class:"search-form"},ae={class:"table-toolbar"},ne={class:"pagination-container",style:{display:"flex","justify-content":"flex-end","margin-top":"12px"}},de=M({__name:"index",setup(oe){const y=q(),v=A(),S=E(),h=t=>S.hasPermission(t),l=C({username:"",status:null}),N=[{label:"成功",value:0},{label:"失败",value:1}],k=b([]),p=b(!1),o=C({page:1,pageSize:10,itemCount:0}),T=[{title:"ID",key:"id",width:80},{title:"用户名",key:"username",width:120},{title:"IP地址",key:"ipaddr",width:140},{title:"登录地点",key:"loginLocation",width:150},{title:"浏览器",key:"browser",width:200},{title:"操作系统",key:"os",width:300},{title:"状态",key:"status",width:80,render(t){return z(X,{type:t.status===0?"success":"error",size:"small"},{default:()=>t.status===0?"成功":"失败"})}},{title:"提示信息",key:"msg",ellipsis:{tooltip:!0}},{title:"登录时间",key:"loginTime",width:180},{title:"操作",key:"actions",width:80,fixed:"right",render(t){return h("sys:loginlog:delete")?z(d,{size:"small",type:"error",onClick:()=>U(t)},{default:()=>"删除"}):"-"}}];async function u(){p.value=!0;try{const t=await f.page({page:o.page,pageSize:o.pageSize,...l});k.value=t.list,o.itemCount=Number(t.total)}finally{p.value=!1}}function w(){o.page=1,u()}function P(){l.username="",l.status=null,w()}function B(t){o.page=t,u()}function D(t){o.pageSize=t,o.page=1,u()}function U(t){v.warning({title:"提示",content:"确定要删除该日志吗？",positiveText:"确定",negativeText:"取消",onPositiveClick:async()=>{await f.delete(t.id),y.success("删除成功"),u()}})}function O(){v.warning({title:"提示",content:"确定要清空所有登录日志吗？",positiveText:"确定",negativeText:"取消",onPositiveClick:async()=>{await f.clean(),y.success("清空成功"),u()}})}return F(()=>u()),(t,n)=>{const V=r("n-input"),m=r("n-form-item"),j=r("n-select"),g=r("n-icon"),L=r("n-form"),R=r("n-data-table"),I=r("n-card");return x(),H("div",ee,[e(I,{class:"page-layout"},{default:a(()=>[_("div",te,[e(L,{inline:"",model:l,"label-placement":"left"},{default:a(()=>[e(m,{label:"用户名"},{default:a(()=>[e(V,{value:l.username,"onUpdate:value":n[0]||(n[0]=s=>l.username=s),placeholder:"请输入用户名",clearable:""},null,8,["value"])]),_:1}),e(m,{label:"状态"},{default:a(()=>[e(j,{value:l.status,"onUpdate:value":n[1]||(n[1]=s=>l.status=s),placeholder:"请选择状态",options:N,clearable:"",style:{width:"120px"}},null,8,["value"])]),_:1}),e(m,null,{default:a(()=>[e(i(K),null,{default:a(()=>[e(i(d),{type:"primary",onClick:w},{icon:a(()=>[e(g,null,{default:a(()=>[e(i(Y))]),_:1})]),default:a(()=>[n[4]||(n[4]=c(" 搜索 ",-1))]),_:1}),e(i(d),{onClick:P},{icon:a(()=>[e(g,null,{default:a(()=>[e(i(Z))]),_:1})]),default:a(()=>[n[5]||(n[5]=c(" 重置 ",-1))]),_:1})]),_:1})]),_:1})]),_:1},8,["model"])]),_("div",ae,[h("sys:loginlog:delete")?(x(),G(i(d),{key:0,type:"error",onClick:O},{icon:a(()=>[e(g,null,{default:a(()=>[e(i($))]),_:1})]),default:a(()=>[n[6]||(n[6]=c(" 清空日志 ",-1))]),_:1})):J("",!0)]),e(R,{columns:T,data:k.value,loading:p.value,"row-key":s=>s.id,remote:""},null,8,["data","loading","row-key"]),_("div",ne,[e(i(Q),{page:o.page,"onUpdate:page":[n[2]||(n[2]=s=>o.page=s),B],"page-size":o.pageSize,"onUpdate:pageSize":[n[3]||(n[3]=s=>o.pageSize=s),D],"item-count":o.itemCount,"page-sizes":[10,20,50,100],"show-size-picker":"","show-quick-jumper":""},{prefix:a(()=>[c(" 共 "+W(o.itemCount)+" 条 ",1)]),_:1},8,["page","page-size","item-count"])])]),_:1})])}}});export{de as default};
