import{r as b}from"./index-B4LtVBBd.js";import{i as w,L as x}from"./index-Bn9PLWWT.js";import{h as p,q as y,c as k,a as e,e as m,t as f,b as l,w as M,v as R,r as u,o as S}from"./index-CMZBZO_O.js";const D={class:"stat-cards"},V={class:"stat-card purple"},C={class:"value"},Y={class:"stat-card green"},j={class:"value"},L={class:"content-card"},A={class:"card-title"},B={class:"filter-bar",style:{"margin-bottom":"0"}},N={class:"content-card"},F={__name:"RdStats",setup($){const n=p({}),d=p(null);let c=null;const r=p((()=>{const a=new Date,t=new Date;t.setMonth(t.getMonth()-1);const i=o=>String(o).padStart(2,"0"),s=o=>`${o.getFullYear()}-${i(o.getMonth()+1)}-${i(o.getDate())}`;return[s(t),s(a)]})());async function v(){const a={};r.value&&(a.start_date=r.value[0],a.end_date=r.value[1]);const t=await b.getStats(a);n.value=t.data,await R(),h()}function h(){if(!d.value)return;c||(c=w(d.value,"dark"));const a=n.value.projects||[];c.setOption({backgroundColor:"transparent",tooltip:{trigger:"axis",axisPointer:{type:"shadow"}},xAxis:{type:"category",data:a.map(t=>t.client_name),axisLabel:{color:"#94a3b8",interval:0,rotate:30}},yAxis:{type:"value",name:"工时(h)",axisLabel:{color:"#94a3b8"}},series:[{type:"bar",barMaxWidth:60,data:a.map(t=>t.total_hours),itemStyle:{color:new x(0,0,0,1,[{offset:0,color:"#6366f1"},{offset:1,color:"#4338ca"}]),borderRadius:[4,4,0,0]}}]})}return y(v),(a,t)=>{var _;const i=u("el-date-picker"),s=u("el-table-column"),o=u("el-table");return S(),k("div",null,[t[7]||(t[7]=e("div",{class:"page-header"},[e("h1",null,"个人统计"),e("p",null,"查看您的工时分布与月度趋势")],-1)),e("div",D,[e("div",V,[t[2]||(t[2]=e("div",{class:"label"},"参与项目数",-1)),e("div",C,[m(f(((_=n.value.projects)==null?void 0:_.length)||0),1),t[1]||(t[1]=e("span",{class:"unit"},"个",-1))])]),e("div",Y,[t[4]||(t[4]=e("div",{class:"label"},"累计总工时",-1)),e("div",j,[m(f(n.value.total_hours||0),1),t[3]||(t[3]=e("span",{class:"unit"},"小时",-1))])])]),e("div",L,[e("div",A,[t[5]||(t[5]=e("span",null,"各项目工时明细",-1)),e("div",B,[l(i,{modelValue:r.value,"onUpdate:modelValue":t[0]||(t[0]=g=>r.value=g),type:"daterange","range-separator":"至","start-placeholder":"开始日期","end-placeholder":"结束日期","value-format":"YYYY-MM-DD",size:"default",onChange:v},null,8,["modelValue"])])]),l(o,{data:n.value.projects||[],stripe:""},{default:M(()=>[l(s,{prop:"client_name",label:"客户/项目","min-width":"180"}),l(s,{prop:"total_hours",label:"总工时(h)",width:"120"}),l(s,{prop:"work_days",label:"工作天数",width:"110"}),l(s,{prop:"first_date",label:"首次填报",width:"130"}),l(s,{prop:"last_date",label:"最近填报",width:"130"})]),_:1},8,["data"])]),e("div",N,[t[6]||(t[6]=e("div",{class:"card-title"},"各项目工时对比",-1)),e("div",{ref_key:"chartRef",ref:d,class:"chart-container"},null,512)])])}}};export{F as default};
