import{d as q,r as f,w as C,j as O,ai as d,aq as z,P as N,u as i,o as c,M as w,O as y,a as s,U as g,D as R,c as D,a8 as V,T as h,S as B,a2 as U,R as $,F as E}from"./vue.1RczIYhx.js";import{c as L,d as T}from"./api.DGelHC0B.js";import{D as u,z as j,h as Y}from"./elementPlus.CXoFsoPv.js";/* empty css                   */import{_ as F}from"./_plugin-vue_export-helper.DlAUqK2U.js";import"./index.fM6cvGYs.js";const S={class:"header-container"},A={class:"stat-overview"},I={class:"stat-label"},P={class:"stat-value"},G=q({__name:"Overview",setup(H){const r=f(!1),t=f([u().startOf("month").format("YYYY-MM-DD"),u().format("YYYY-MM-DD")]),m=f([]),M=[{label:"监控商品数",field:"monitor_goods_count"},{label:"监控竞品数",field:"monitor_competitors_count"},{label:"总评论数",field:"total_review_count"},{label:"新增好评数",field:"good_review_count"},{label:"新增中评数",field:"mid_review_count"},{label:"新增差评数",field:"bad_review_count"},{label:"在售商品数",field:"sale_goods_count"},{label:"停售商品数",field:"discontinued_goods_count"}];async function b(){r.value=!0;const a={query_start_date:t.value[0],query_end_date:t.value[1]};try{const{data:e}=await L(a);m.value=M.map(l=>({label:l.label,value:e[l.field]||0})),r.value=!1}catch{console.error("获取数据时出错:",error)}}async function k(a){r.value=!0;const e={总评论数:0,新增好评数:1,新增中评数:2,新增差评数:3}[a];try{const l={download_type:e,query_start_date:t.value[0],query_end_date:t.value[1]},_=`${t.value[0]}至${t.value[1]}${a}.xlsx`,p=await T(l),v=window.URL.createObjectURL(p.data),n=document.createElement("a");n.href=v,n.setAttribute("download",_),document.body.appendChild(n),n.click(),Y.success("下载成功"),r.value=!1}catch{Y.error("error")}}return C(t,(a,e)=>{a!==e&&(t.value[0]=u(a[0]).format("YYYY-MM-DD"),t.value[1]=u(a[1]).format("YYYY-MM-DD"),b())}),O(()=>{b()}),(a,e)=>{const l=d("el-date-picker"),_=d("el-button"),p=d("el-tooltip"),v=d("el-card"),n=z("loading");return N((c(),w(v,{shadow:"hover",class:"border-none",style:{"margin-bottom":"10px",height:"155px"}},{default:y(()=>[s("div",S,[e[2]||(e[2]=s("span",{style:{"font-size":"16px","font-weight":"500"}},"统计概览",-1)),s("div",null,[e[1]||(e[1]=s("span",{style:{"font-size":"14px",color:"#95969a"}},"时间选择：",-1)),g(l,{modelValue:i(t),"onUpdate:modelValue":e[0]||(e[0]=o=>R(t)?t.value=o:null),clearable:!1,type:"daterange"},null,8,["modelValue"])])]),s("div",A,[(c(!0),D(E,null,V(i(m),(o,x)=>(c(),D("div",{key:x,class:"stat-item"},[s("div",I,h(o.label),1),s("div",P,[B(h(o.value)+" ",1),g(p,{content:"下载",placement:"top"},{default:y(()=>[o.label==="总评论数"||o.label==="新增好评数"||o.label==="新增中评数"||o.label==="新增差评数"?(c(),w(_,{key:0,icon:i(j),size:a.mini,class:"stat-button",type:"text",onClick:U(J=>k(o.label),["stop"])},null,8,["icon","size","onClick"])):$("",!0)]),_:2},1024)])]))),128))])]),_:1})),[[n,i(r)]])}}}),te=F(G,[["__scopeId","data-v-d1a18dc1"]]);export{te as default};
