import{d as F,q as y,r as m,w as R,j as T,p as q,a8 as l,ae as O,H as U,o as v,c as I,M as d,G as c,a as o,F as A,$ as G,E as P,W as H,u as S,K as k,J,L as x,z as K,ap as W,aq as Q}from"./vue.95e072e2.js";import{e as X,a as Y,h as D}from"./elementPlus.59866ea5.js";import{i as Z}from"./echarts.2703a7ac.js";import{e as n}from"./emitter.f846b410.js";import{c as ee,d as te}from"./api.bbdcdb62.js";import{_ as ae}from"./_plugin-vue_export-helper.c27b6911.js";import"./index.ad090ffd.js";const oe=u=>(W("data-v-acca4de6"),u=u(),Q(),u),se={class:"out-container"},ce={class:"scrollbar-flex-content"},le=["id"],ne={class:"custom-popoer"},re={class:"left-part-container"},ie={class:"product-line-name"},de={class:"custom-part"},ue={class:"total-sales"},pe=oe(()=>o("span",{class:"label"},"总销售额",-1)),_e=F({__name:"ProductSelectCard",setup(u){n.on("ProductList-updateCardData",e=>{e.isUpdate&&(r.value.splice(0),p())}),n.on("TopFilters-selectValue",e=>{const t=r.value.findIndex(a=>a.productlineId===e.selectValue);t!==-1&&(g.value=t)});const $=y("profile"),h=y("dateRange"),C=m(!1),r=m([]),B=m([]),g=m(0);async function p(){try{const{data:e}=await ee({profileId:$.value.profile_id,startDate:h.value[0],endDate:h.value[1]});r.value=e}catch(e){console.log("error:",e)}}function L(){r.value.forEach((e,t)=>{const a=`chart${t}-${e.productlineId}`,_=document.getElementById(a);if(_){const i=Z(_),b={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}}]}]};i.setOption(b),B.value[a]=i}})}function V(e,t){g.value=e;const a=t.productlineId;n.emit("ProductSelectCard-cardId",{productlineId:a})}function z(e){n.emit("ProductTab-editProductCard",{isVisible:!0,data:e})}async function N(e){const t={productlineId:e.productlineId};try{(await te(t)).data.code=="success"?(D({message:"已删除",type:"success"}),await p(),n.emit("ProductSelectCard-reloading",{reloading:!0})):D({message:"删除失败",type:"error"})}catch(a){console.log("error:",a)}}return R(h,async()=>{C.value=!0,await p(),C.value=!1}),T(async()=>{await p(),L()}),q(()=>{n.all.clear()}),(e,t)=>{const a=l("Setting"),_=l("el-icon"),i=l("el-button"),b=l("el-popover"),E=l("el-card"),M=l("el-scrollbar"),j=O("loading");return U((v(),I("div",se,[d(M,null,{default:c(()=>[o("div",ce,[(v(!0),I(A,null,G(r.value,(s,f)=>(v(),P(E,{key:s.productlineId,"body-style":"padding: 0;box-sizing: border-box; position: relative; width: 100%;",class:K(["scrollbar-demo-item",{selected:g.value===f}]),onClick:w=>V(f,s)},{default:c(()=>[o("div",{class:"pct-chart",id:`chart${f}-${s.productlineId}`},null,8,le),f!==0?(v(),P(b,{key:0,placement:"bottom",width:150,trigger:"click"},{reference:c(()=>[d(_,{class:"custom-icon",onClick:t[0]||(t[0]=H(()=>{},["stop"]))},{default:c(()=>[d(a)]),_:1})]),default:c(()=>[o("div",ne,[d(i,{icon:S(X),text:"",size:"small",onClick:w=>z(s)},{default:c(()=>[k("编辑")]),_:2},1032,["icon","onClick"]),d(i,{icon:S(Y),text:"",size:"small",onClick:w=>N(s),style:{"margin-left":"0"}},{default:c(()=>[k("删除")]),_:2},1032,["icon","onClick"])])]),_:2},1024)):J("",!0),o("div",re,[o("div",ie,x(s.productlineName),1),o("div",de,[o("div",ue,"$"+x(s.totalSales),1),pe])])]),_:2},1032,["class","onClick"]))),128))])]),_:1})])),[[j,C.value]])}}});const we=ae(_e,[["__scopeId","data-v-acca4de6"]]);export{we as default};