import{a as C}from"./api.BqXdYe8_.js";import{G as S}from"./api.gSJuu3rk.js";import{S as b,L as y}from"./index.BqrqjjTL.js";import{a as $,r as i,q as K,aj as s,c as w,o as v,b as h,J as x,S as t,K as c,R as D,a9 as F}from"./vue.YrNK8sx4.js";import{_ as G}from"./_plugin-vue_export-helper.DlAUqK2U.js";const E={class:"ranking-panel"},U={class:"panel-header"},N={key:1,class:"empty-tip"},k="borrow_ranking_filters",j=$({__name:"BorrowRankingList",setup(q){const u=i("all"),r=i(null),T=i(""),_=i([]),n=i([]),d=async()=>{const a={type:u.value};r.value&&(a.start=r.value[0],a.end=r.value[1]),T.value&&(a.keyword=T.value),n.value.length&&(a.tag_id=n.value);const e=await C(a);e.code===2e3?_.value=e.data.borrow_count_ranking:_.value=[],R()},p=i([]),V=async()=>{const a=await S({page:1,page_size:20});a.code===2e3&&(p.value=a.data,!n.value.length&&Array.isArray(p.value)&&p.value.length&&(n.value=p.value.map(e=>e.id),d()))},R=()=>{try{const a=b.get("userInfo");if(!(a!=null&&a.username))return;const e={borrowType:u.value,dateRange:r.value,deviceTagIds:n.value,timestamp:Date.now(),version:"1.0"},l=`${k}_${a.username}`;y.set(l,e),console.log("筛选条件已保存到本地存储",e)}catch(a){console.error("保存筛选条件失败:",a)}},B=()=>{try{const a=b.get("userInfo");if(!(a!=null&&a.username))return;const e=`${k}_${a.username}`,l=y.get(e);if(!l)return;const g=Date.now(),m=7*24*60*60*1e3;if(l.timestamp&&g-l.timestamp>m){y.remove(e),console.log("筛选条件已过期,已清除本地数据");return}l.borrowType&&(u.value=l.borrowType),l.dateRange&&(r.value=l.dateRange),l.deviceTagIds&&Array.isArray(l.deviceTagIds)&&(n.value=l.deviceTagIds),console.log("筛选条件已从本地存储恢复")}catch(a){console.error("恢复筛选条件失败:",a);const e=b.get("userInfo");if(e!=null&&e.username){const l=`${k}_${e.username}`;y.remove(l)}}};return K(()=>{B(),d(),b.get("userInfo").username!="平台管理员"&&V()}),(a,e)=>{const l=s("el-option"),g=s("el-select"),m=s("el-col"),I=s("el-date-picker"),L=s("el-row"),f=s("el-table-column"),A=s("el-table");return v(),w("div",E,[e[3]||(e[3]=h("div",{class:"panel-title"},[h("div",{class:"title"},"单台设备累计借用次数排名")],-1)),h("div",U,[t(L,{gutter:24},{default:c(()=>[t(m,{span:6},{default:c(()=>[t(g,{modelValue:u.value,"onUpdate:modelValue":e[0]||(e[0]=o=>u.value=o),clearable:"",placeholder:"借用类型",style:{width:"140px"},onChange:d},{default:c(()=>[t(l,{label:"全部",value:"all"}),t(l,{label:"常规借用",value:"regular"}),t(l,{label:"课堂借用",value:"classroom"}),t(l,{label:"特殊借用",value:"special"})]),_:1},8,["modelValue"])]),_:1}),t(m,{span:12},{default:c(()=>[t(I,{modelValue:r.value,"onUpdate:modelValue":e[1]||(e[1]=o=>r.value=o),type:"daterange","start-placeholder":"开始日期","end-placeholder":"结束日期",clearable:"",onChange:d},null,8,["modelValue"])]),_:1}),t(m,{span:6},{default:c(()=>[t(g,{multiple:"",clearable:"",modelValue:n.value,"onUpdate:modelValue":e[2]||(e[2]=o=>n.value=o),placeholder:"标签名","collapse-tags":"",style:{"margin-left":"30%",width:"100px"},onChange:d},{default:c(()=>[(v(!0),w(D,null,F(p.value,o=>(v(),x(l,{key:o.id,label:o.name,value:o.id},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])]),_:1})]),_:1})]),_.value.length?(v(),x(A,{key:0,data:_.value,style:{width:"100%","margin-top":"20px",height:"350px"},"max-height":"500"},{default:c(()=>[t(f,{type:"index",label:"排名",width:"60"}),t(f,{prop:"device_name",label:"设备名"}),t(f,{prop:"device_code",label:"设备编号"}),t(f,{prop:"borrow_count",label:"借用次数"})]),_:1},8,["data"])):(v(),w("div",N,"暂无数据"))])}}}),H=G(j,[["__scopeId","data-v-e3a7b4b3"]]);export{H as default};