import{i as L}from"./echarts.DoXO02ct.js";import{b as z}from"./api.BjxDfFlb.js";/* empty css                   */import{h as D}from"./elementPlus.CXoFsoPv.js";import{d as V,r as d,j as A,A as R,ai as u,aq as B,P as N,o as O,M as j,O as v,a as b,U as o}from"./vue.1RczIYhx.js";const F=V({__name:"LineChart",props:{rowData:Object},setup(h){const _=h,{rowData:l}=_,i=d("8");let n;const f=d(null),r=d(!1);A(()=>{y(),m()}),R(()=>{n&&(n.dispose(),n=null),w()});const s={tooltip:{trigger:"axis",formatter:a=>{let t=a[0].name;for(let e=0,c=a.length;e<c;e++)t+="<br/>"+a[e].marker+" "+a[e].seriesName+" "+(a[e].value*100).toFixed(2)+" %";return t}},grid:{top:"18%",left:"5%",right:"5%",bottom:"5%",containLabel:!0},xAxis:{type:"category",data:[]},yAxis:[{type:"value",name:"NCX Rate",position:"left",axisLine:{show:!0,lineStyle:{color:"#70b6e3"}},axisLabel:{formatter:function(a){return(a*100).toFixed(2)+" %"}}}],series:[{id:0,name:"28 天平均值",type:"line",yAxisIndex:0,itemStyle:{color:"#70b6e3",lineStyle:{color:"#70b6e3"}},data:[]}]};async function m(){await x(),n=L(f.value),n.setOption(s,!0)}async function x(){try{r.value=!0;const a={asin:l.asin,week:i.value,sku:l.sku,channel:l.fulfillment_channel},t=await z(a);t.code===2e3&&t.data&&(s.xAxis.data=t.data.map(e=>e.date),s.series[0].data=t.data.map(e=>e.ncx_rate))}catch{D.error("加载数据失败，请稍后再试")}finally{r.value=!1}}function p(){n.resize()}function y(){window.addEventListener("resize",p)}function w(){window.removeEventListener("resize",p)}return(a,t)=>{const e=u("el-option"),c=u("el-select"),g=u("el-card"),k=B("loading");return N((O(),j(g,{class:"border-none mt-5",shadow:"hover"},{default:v(()=>[t[1]||(t[1]=b("span",{class:"font-semibold italic mr-2"},"时间范围:",-1)),o(c,{modelValue:i.value,"onUpdate:modelValue":t[0]||(t[0]=C=>i.value=C),style:{width:"100px"},onChange:m},{default:v(()=>[o(e,{label:"一周",value:"1"}),o(e,{label:"两周",value:"2"}),o(e,{label:"四周",value:"4"}),o(e,{label:"六周",value:"6"}),o(e,{label:"八周",value:"8"}),o(e,{label:"十二周",value:"12"})]),_:1},8,["modelValue"]),b("div",{ref_key:"chartRef",ref:f,style:{width:"100%",height:"500px",background:"#fff"}},null,512)]),_:1})),[[k,r.value]])}}});export{F as _};
