1 |
- import{E as C}from"./index.DQ04k8aE.js";import{b}from"./api.D9qkbsDk.js";import{S as i,L as r}from"./index.8VEyMOSu.js";import{u as B,a as T,g as $,c as k,d as x,h as R,f as S}from"./echarts.DTyPNLGI.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.YrNK8sx4.js";import{_ as O}from"./_plugin-vue_export-helper.DlAUqK2U.js";const V={class:"chart-container"},W={class:"filter-bar"},q=["onClick"],I={key:0},M={key:1,class:"empty-tip"},d="borrow_trends_filters",Q=D({__name:"BorrowTrendsChart",setup(Y){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)}},g=()=>{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(()=>{g(),u()});const f=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,q)),64))]),f.value?(l(),n("div",I,[z(N(C),{option:w.value,autoresize:"",style:{height:"360px"}},null,8,["option"])])):(l(),n("div",M,"暂无数据"))]))}}),Z=O(Q,[["__scopeId","data-v-563e934b"]]);export{Z as default};
|