ProductSelectCard.58da98ba.js 3.9 KB

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