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