import{d as U,B as k,r as h,w as A,j as q,A as G,ai as n,aq as H,o as r,c as P,P as x,M as g,O as o,a as s,F as J,a8 as K,I as Q,U as p,a2 as W,S as D,u as B,R as w,T as V,V as X,aF as Y,aG as Z}from"./vue.adf17aba.js";import{e as ee,g as te,E as $}from"./elementPlus.4833989a.js";import{i as ae}from"./echarts.72dc8373.js";import{e as i}from"./emitter.c27b7986.js";import{c as oe,d as se}from"./api.20164d48.js";import{_ as le}from"./_plugin-vue_export-helper.c27b6911.js";import"./index.b098562c.js";const z=_=>(Y("data-v-cd4e3abf"),_=_(),Z(),_),ce={class:"out-container"},ne={class:"scrollbar-flex-content"},re=["id"],ie={class:"custom-popoer"},de={class:"left-part-container"},ue={class:"product-line-name"},pe={class:"custom-part"},_e={class:"total-sales"},fe=z(()=>s("span",{class:"label"},"总销售额",-1)),me=z(()=>s("div",{style:{color:"#919398"}},"暂无数据",-1)),ve=U({__name:"ProductSelectCard",setup(_){i.on("ProductList-updateCardData",e=>{e.isUpdate&&(l.value.splice(0),f())}),i.on("TopFilters-selectValue",e=>{const t=l.value.findIndex(a=>a.productlineId===e.selectValue);t!==-1&&(y.value=t)});const L=k("profile"),b=k("dateRange"),d=h(!1),l=h([]),N=h([]),y=h(0);async function f(){d.value=!0;try{const{data:e}=await oe({profileId:L.value.profile_id,startDate:b.value[0],endDate:b.value[1]});l.value=e}catch(e){console.log("error:",e)}finally{d.value=!1}}function E(){l.value.forEach((e,t)=>{const a=`chart${t}-${e.productlineId}`,m=document.getElementById(a);if(m){const u=ae(m),C={animation:!1,series:[{silent:!0,avoidLabelOverlap:!0,label:{show:!0,position:"center",formatter:"{d}%"},emphasis:{disable:!0,scale:!1,shadowBlur:0,hoverAnimation:!1,label:{show:!0,fontSize:12}},labelLine:{show:!1},radius:["75%","100%"],type:"pie",data:[{value:e.salesPercentage,name:e.productlineName},{value:100-e.salesPercentage,name:"",itemStyle:{color:"#f1eff5"},label:{show:!1}}]}]};u.setOption(C),N.value[a]=u}})}function F(e,t){y.value=e;const a=t.productlineId;i.emit("ProductSelectCard-cardId",{productlineId:a})}function M(e){i.emit("ProductTab-editProductCard",{isVisible:!0,data:e})}async function R(e){const t={productlineId:e.productlineId};try{(await se(t)).data.code=="success"?($({message:"已删除",type:"success"}),await f(),i.emit("ProductSelectCard-reloading",{reloading:!0})):$({message:"删除失败",type:"error"})}catch(a){console.log("error:",a)}}return A(b,async()=>{d.value=!0,await f(),d.value=!1}),q(async()=>{await f(),E()}),G(()=>{i.all.clear()}),(e,t)=>{const a=n("Setting"),m=n("el-icon"),u=n("el-button"),C=n("el-popover"),I=n("el-card"),T=n("el-empty"),j=n("el-scrollbar"),O=H("loading");return r(),P("div",ce,[x((r(),g(j,null,{default:o(()=>[x(s("div",ne,[l.value.length!==0?(r(!0),P(J,{key:0},K(l.value,(c,v)=>(r(),g(I,{key:c.productlineId,shadow:"hover","body-style":"padding: 0; box-sizing: border-box; position: relative; width: 100%;",class:Q(["scrollbar-demo-item",{selected:y.value===v}]),onClick:S=>F(v,c)},{default:o(()=>[s("div",{class:"pct-chart",id:`chart${v}-${c.productlineId}`},null,8,re),v!==0?(r(),g(C,{key:0,placement:"bottom",width:150,trigger:"click"},{reference:o(()=>[p(m,{class:"custom-icon",onClick:t[0]||(t[0]=W(()=>{},["stop"]))},{default:o(()=>[p(a)]),_:1})]),default:o(()=>[s("div",ie,[p(u,{icon:B(ee),text:"",size:"small",onClick:S=>M(c)},{default:o(()=>[D("编辑")]),_:2},1032,["icon","onClick"]),p(u,{icon:B(te),text:"",size:"small",onClick:S=>R(c),style:{"margin-left":"0"}},{default:o(()=>[D("删除")]),_:2},1032,["icon","onClick"])])]),_:2},1024)):w("",!0),s("div",de,[s("div",ue,V(c.productlineName),1),s("div",pe,[s("div",_e,"$"+V(c.totalSales),1),fe])])]),_:2},1032,["class","onClick"]))),128)):w("",!0)],512),[[X,l.value]]),l.value.length===0?(r(),g(I,{key:0,shadow:"hover","body-style":"padding: 0;box-sizing: border-box; position: relative; width: 100%;",class:"scrollbar-demo-item"},{default:o(()=>[p(T,{description:" "},{image:o(()=>[me]),_:1})]),_:1})):w("",!0)]),_:1})),[[O,d.value]])])}}});const Se=le(ve,[["__scopeId","data-v-cd4e3abf"]]);export{Se as default};