import{a as F,r as d,q as G,aj as c,c as w,o as g,b as k,J as V,S as t,K as r,Y as C,P as E,R as N,a9 as U}from"./vue.D1BjjNmv.js";import{a as M}from"./api.JeMNPeN4.js";import{G as Y}from"./api.Bh9dYQll.js";import{S as b,L as h}from"./index.Df8UJ10K.js";import{_ as j}from"./_plugin-vue_export-helper.DlAUqK2U.js";const q={class:"ranking-panel"},z={class:"panel-header"},J={key:1,class:"empty-tip"},T="borrow_ranking_filters",O=F({__name:"BorrowRankingList",setup(P){const p=d("all"),i=d(null),x=d(""),_=d([]),o=d([]),n=d(!1),A=()=>{n.value?(o.value=[],n.value=!1):(o.value=u.value.map(a=>a.id),n.value=!0),v()},S=()=>{const a=u.value.map(e=>e.id);n.value=o.value.length===a.length&&a.every(e=>o.value.includes(e)),v()},v=async()=>{const a={type:p.value};i.value&&(a.start=i.value[0],a.end=i.value[1]),x.value&&(a.keyword=x.value),o.value.length&&(a.tag_id=o.value);const e=await M(a);e.code===2e3?_.value=e.data.device_rankings.borrow_count_ranking:_.value=[],I()},u=d([]),R=async()=>{const a=await Y({page:1,page_size:20});if(a.code===2e3)if(u.value=a.data,!o.value.length&&Array.isArray(u.value)&&u.value.length)o.value=u.value.map(e=>e.id),n.value=!0,v();else{const e=u.value.map(l=>l.id);n.value=o.value.length===e.length&&e.every(l=>o.value.includes(l))}},I=()=>{try{const a=b.get("userInfo");if(!(a!=null&&a.username))return;const e={borrowType:p.value,dateRange:i.value,deviceTagIds:o.value,isSelectAll:n.value,timestamp:Date.now(),version:"1.0"},l=`${T}_${a.username}`;h.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=`${T}_${a.username}`,l=h.get(e);if(!l)return;const f=Date.now(),m=7*24*60*60*1e3;if(l.timestamp&&f-l.timestamp>m){h.remove(e),console.log("筛选条件已过期，已清除本地数据");return}l.borrowType&&(p.value=l.borrowType),l.dateRange&&(i.value=l.dateRange),l.deviceTagIds&&Array.isArray(l.deviceTagIds)&&(o.value=l.deviceTagIds),typeof l.isSelectAll=="boolean"&&(n.value=l.isSelectAll),console.log("筛选条件已从本地存储恢复")}catch(a){console.error("恢复筛选条件失败:",a);const e=b.get("userInfo");if(e!=null&&e.username){const l=`${T}_${e.username}`;h.remove(l)}}};return G(()=>{B(),v(),b.get("userInfo").username!="平台管理员"&&R()}),(a,e)=>{const l=c("el-option"),f=c("el-select"),m=c("el-col"),L=c("el-date-picker"),$=c("el-checkbox"),K=c("el-row"),y=c("el-table-column"),D=c("el-table");return g(),w("div",q,[e[5]||(e[5]=k("div",{class:"panel-title"},[k("div",{class:"title"},"单台设备累计借用次数排名")],-1)),k("div",z,[t(K,{gutter:16},{default:r(()=>[t(m,{span:4},{default:r(()=>[t(f,{modelValue:p.value,"onUpdate:modelValue":e[0]||(e[0]=s=>p.value=s),clearable:"",placeholder:"借用类型",style:{width:"100%"},onChange:v},{default:r(()=>[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:10},{default:r(()=>[t(L,{modelValue:i.value,"onUpdate:modelValue":e[1]||(e[1]=s=>i.value=s),type:"daterange","start-placeholder":"开始日期","end-placeholder":"结束日期",clearable:"",onChange:v,style:{width:"100%"}},null,8,["modelValue"])]),_:1}),t(m,{span:10},{default:r(()=>[t(f,{multiple:"",modelValue:o.value,"onUpdate:modelValue":e[3]||(e[3]=s=>o.value=s),placeholder:"标签名",style:{width:"270px"},onChange:S,class:"select-tags"},{default:r(()=>[t(l,{value:"selectAll",onClick:C(A,["stop"])},{default:r(()=>[t($,{"model-value":n.value,onChange:A,onClick:e[2]||(e[2]=C(()=>{},["stop"]))},{default:r(()=>e[4]||(e[4]=[E(" 全选 ")])),_:1},8,["model-value"])]),_:1}),(g(!0),w(N,null,U(u.value,s=>(g(),V(l,{key:s.id,label:s.name,value:s.id},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])]),_:1})]),_:1})]),_.value.length?(g(),V(D,{key:0,data:_.value,style:{width:"100%","margin-top":"20px",height:"350px"},"max-height":"500"},{default:r(()=>[t(y,{type:"index",label:"排名",width:"60"}),t(y,{prop:"device_name",label:"设备名"}),t(y,{prop:"device_code",label:"设备编号"}),t(y,{prop:"borrow_count",label:"借用次数"})]),_:1},8,["data"])):(g(),w("div",J,"暂无数据"))])}}}),ee=j(O,[["__scopeId","data-v-7105afe2"]]);export{ee as default};
