import{E as C}from"./index.D6H9PPaW.js";import{b}from"./api.JeMNPeN4.js";import{S as i,L as r}from"./index.Df8UJ10K.js";import{u as B,a as T,h as $,c as k,d as x,j as R,f as S}from"./echarts.Bm4fHez2.js";import{a as D,r as p,w as E,q as F,f as v,c as n,o as l,b as c,R as A,a9 as K,G as L,Q as G,S as z,u as N}from"./vue.D1BjjNmv.js";import{_ as O}from"./_plugin-vue_export-helper.DlAUqK2U.js";const V={class:"chart-container"},W={class:"filter-bar"},j=["onClick"],q={key:0},I={key:1,class:"empty-tip"},d="borrow_trends_filters",M=D({__name:"BorrowTrendsChart",setup(Q){B([T,$,k,x,R,S]);const h=[{label:"周",value:"week"},{label:"月",value:"month"},{label:"年",value:"year"}],o=p("week"),s=p([]),u=async()=>{const t=await b(o.value);t.code===2e3?s.value=t.data.trends:s.value=[],_()},_=()=>{try{const t=i.get("userInfo");if(!(t!=null&&t.username))return;const a={selectedRange:o.value,timestamp:Date.now(),version:"1.0",component:"BorrowTrendsChart"},e=`${d}_${t.username}`;r.set(e,a),console.log("BorrowTrendsChart筛选条件已保存到本地存储",a)}catch(t){console.error("保存BorrowTrendsChart筛选条件失败:",t)}},f=()=>{try{const t=i.get("userInfo");if(!(t!=null&&t.username))return;const a=`${d}_${t.username}`,e=r.get(a);if(!e)return;const m=Date.now(),y=7*24*60*60*1e3;if(e.timestamp&&m-e.timestamp>y){r.remove(a),console.log("BorrowTrendsChart筛选条件已过期，已清除本地数据");return}if(e.component&&e.component!=="BorrowTrendsChart"){console.warn("检测到非BorrowTrendsChart组件的数据，跳过恢复");return}e.selectedRange&&["week","month","year"].includes(e.selectedRange)&&(o.value=e.selectedRange,console.log("BorrowTrendsChart筛选条件已从本地存储恢复:",e.selectedRange))}catch(t){console.error("恢复BorrowTrendsChart筛选条件失败:",t);const a=i.get("userInfo");if(a!=null&&a.username){const e=`${d}_${a.username}`;r.remove(e)}}};E(o,u),F(()=>{f(),u()});const g=v(()=>s.value.length>0),w=v(()=>{const t=s.value.map(e=>e.date),a=s.value.map(e=>e.borrow_count);return s.value.map(e=>e.total_duration),{tooltip:{trigger:"axis"},legend:{data:["借用次数"]},xAxis:{type:"category",data:t,axisTick:{alignWithLabel:!0}},yAxis:{type:"value",name:"数量"},series:[{name:"借用次数",type:"bar",data:a,barWidth:"40%",itemStyle:{color:"#409EFF"}}]}});return(t,a)=>(l(),n("div",V,[a[0]||(a[0]=c("div",{class:"panel-title"},[c("div",{class:"title"},"整体设备借用次数趋势")],-1)),c("div",W,[(l(),n(A,null,K(h,e=>c("button",{key:e.value,class:L({active:o.value===e.value}),onClick:m=>o.value=e.value},G(e.label),11,j)),64))]),g.value?(l(),n("div",q,[z(N(C),{option:w.value,autoresize:"",style:{height:"360px"}},null,8,["option"])])):(l(),n("div",I,"暂无数据"))]))}}),Z=O(M,[["__scopeId","data-v-563e934b"]]);export{Z as default};
