import{i as F,L as G}from"./echarts.72dc8373.js";import{T as N}from"./index.05a2d588.js";import{g as ue}from"./api.325c96cf.js";import{c as C}from"./dropdowndisable.88660b16.js";import{h as E,i as H,p as q,j as y,m as pe}from"./enum.e566fd6e.js";import{u as de}from"./index.ad3efb29.js";import{_ as ce}from"./_plugin-vue_export-helper.c27b6911.js";import{r as n,B as fe,j as me,w as ve,k as V,ai as w,aq as _e,P as he,o as B,c as J,U as c,O as S,a as f,u as D,D as A,F as ge,a8 as be,M as xe,aF as ye,aG as we}from"./vue.adf17aba.js";import"./elementPlus.4833989a.js";const K=h=>(ye("data-v-9ea9f18c"),h=h(),we(),h),Se={style:{"margin-left":"40%"}},Oe=K(()=>f("span",{style:{background:"#3a83f7",width:"18px",height:"10px","margin-top":"8px",display:"inline-block","border-radius":"3px"}},null,-1)),Ce=K(()=>f("span",{style:{background:"#f19a37",width:"18px",height:"10px","margin-top":"8px","margin-left":"20px",display:"inline-block","border-radius":"3px"}},null,-1)),Ve={__name:"adStruct",setup(h,{expose:Q}){const X=de();let m=n(),v=n();const L=n(),k=n(),g=n(!0),b=fe("dateRange");let s=n(q[0].value),t=n(E[0].value),o=n(H[2].value);me(async()=>{v=F(k.value),m=F(L.value),window.addEventListener("resize",x),setTimeout(()=>{x()},0),await Y(),ie()});let I=null;async function M(){return I=await ue({startDate:b.value[0],endDate:b.value[1],profileId:X.profile.profile_id}),I.data}let z,u,p,P,W,R,T;async function Y(){p=await M(),z=[{value:p.tactic_data[0].Spend,name:"商品"},{value:p.tactic_data[1].Spend,name:"受众"}],u=p.target_data,P=u.map(a=>a.ACOS),W=u.map(a=>a.Spend),R=u.map(a=>a.Name);const e={views:"浏览再营销",audience:"亚马逊人群",category:"品类",purchases:"购买再营销",asin:"商品"};T=R.map(a=>e[a]),g.value=!1}let O=n(),i,d;function Z(e){s.value=e,O.value=s.value,d.series[0].data=[{value:p.tactic_data[0][O.value],name:"商品"},{value:p.tactic_data[1][O.value],name:"受众"}],m.setOption(d)}function $(e){t.value=e,U()}function ee(e){o.value=e,U()}function U(){const e=u.map(r=>r[t.value]),a=u.map(r=>r[o.value]);i.series[0].data=e,i.series[1].data=a,i.series[0].name=y[t.value]||t.value,i.series[1].name=y[o.value]||o.value,v.setOption(i)}ve(b,async()=>{if(b.value){g.value=!0;const e=await M();ae(e),te(e),g.value=!1}});function ae(e){d.series[0].data=[{value:e.tactic_data[0][s.value],name:"商品"},{value:e.tactic_data[1][s.value],name:"受众"}],m.setOption(d)}function te(e){const a=e.target_data.map(_=>_[t.value]),r=e.target_data.map(_=>_[o.value]);i.series[0].data=a,i.series[1].data=r,v.setOption(i)}const oe=V(()=>C(E,o.value,t.value)),le=V(()=>C(H,t.value,o.value)),se=V(()=>C(q,s.value));function ie(){i={tooltip:{trigger:"axis",axisPointer:{type:"shadow"},rich:{b:{color:"#4C5058",fontSize:15,fontWeight:"bold",lineHeight:33}}},toolbox:{feature:{saveAsImage:{yAxisIndex:"none"}}},grid:{top:55,right:60,bottom:55,left:55},xAxis:[{type:"category",boundaryGap:!0,data:T}],yAxis:[{type:"value",axisLine:{show:!0,lineStyle:{color:"#3a83f7"}}},{type:"value",splitLine:{show:!1},axisLine:{show:!0,lineStyle:{color:"#f19a37"}}}],series:[{name:y[t.value],type:"bar",barWidth:15,data:P,yAxisIndex:0,itemStyle:{color:new G(0,0,0,1,[{offset:0,color:"#3a83f7"},{offset:.5,color:"#5a9ef4"},{offset:1,color:"#8ab6f1"}]),borderRadius:[4,4,4,4]}},{name:y[o.value],type:"bar",barWidth:15,data:W,yAxisIndex:1,itemStyle:{color:new G(0,0,0,1,[{offset:0,color:"#f19a37"},{offset:.5,color:"#f7b96c"},{offset:1,color:"rgb(234, 207, 135)"}]),borderRadius:[4,4,4,4]}}]},v.setOption(i),d={tooltip:{show:!1,trigger:"item"},series:[{type:"pie",radius:["20%","45%"],avoidLabelOverlap:!1,itemStyle:{borderWidth:1,borderColor:"#fff"},emphasis:{label:{show:!0,fontWeight:"bold"}},label:{show:!0,position:"outside",formatter:e=>e.name+`
{b|`+pe[s.value]+": }{b|"+e.data.value+`}
`+e.percent+"%",rich:{b:{color:"#4C5058",fontSize:15,fontWeight:"bold",lineHeight:33}}},labelLine:{normal:{show:!0}},data:z}]},m.setOption(d),x()}function x(){v.resize(),m.resize()}return Q({resizeChart:x}),(e,a)=>{const r=w("el-option"),_=w("el-select"),j=w("el-col"),ne=w("el-row"),re=_e("loading");return he((B(),J("div",null,[c(ne,{gutter:5},{default:S(()=>[c(j,{span:7},{default:S(()=>[f("div",null,[c(_,{modelValue:D(s),"onUpdate:modelValue":a[0]||(a[0]=l=>A(s)?s.value=l:s=l),class:"m-2",size:"small",onChange:Z,style:{width:"120px"}},{default:S(()=>[(B(!0),J(ge,null,be(se.value,l=>(B(),xe(r,{key:l.value,label:l.label,value:l.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])]),f("div",{ref_key:"pie",ref:L,style:{height:"400px"}},null,512)]),_:1}),c(j,{span:17},{default:S(()=>[f("div",Se,[Oe,c(N,{modelValue:D(t),"onUpdate:modelValue":a[1]||(a[1]=l=>A(t)?t.value=l:t=l),options:oe.value,onChange:$,style:{"margin-top":"5px","margin-left":"8px"}},null,8,["modelValue","options"]),Ce,c(N,{modelValue:D(o),"onUpdate:modelValue":a[2]||(a[2]=l=>A(o)?o.value=l:o=l),options:le.value,onChange:ee,style:{"margin-top":"5px","margin-left":"8px"}},null,8,["modelValue","options"])]),f("div",{ref_key:"bar",ref:k,style:{height:"400px"}},null,512)]),_:1})]),_:1})])),[[re,g.value]])}}},We=ce(Ve,[["__scopeId","data-v-9ea9f18c"]]);export{We as default};
