import{d as t,a as e,r as l,o as a,e as s,f as r,h as o,m as n,F as i,G as c,l as d,i as g,p as x,z as v,n as f}from"./index-ip5gDR6L.js";/* empty css               */import{f as p,a as u}from"./operations-Cj-RMt0B.js";import{E as m}from"./index-D1xXI5gl.js";import"./use-form-common-props-BwBs_jod.js";const b={class:"art-card h-140 p-5 mb-5 max-sm:mb-4"},h={class:"h-[calc(100%-40px)]"},y={class:"grid grid-cols-4 gap-4 mb-6"},w={class:"text-center p-3 bg-blue-50 rounded-lg"},C={class:"text-2xl font-bold text-blue-600"},R={class:"text-center p-3 bg-green-50 rounded-lg"},S={class:"text-2xl font-bold text-green-600"},j={class:"text-center p-3 bg-yellow-50 rounded-lg"},P={class:"text-2xl font-bold text-yellow-600"},$={class:"text-center p-3 bg-purple-50 rounded-lg"},k={class:"text-2xl font-bold text-purple-600"},T={class:"h-60 mb-4"},_={class:"overflow-auto"},A={class:"w-full text-sm"},F={class:"py-2"},W={class:"flex items-center"},z={class:"py-2"},E={class:"py-2"},G={class:"py-2"},L={class:"py-2"},N=t({__name:"activity-lottery",setup(t){const N=e(),B=l({totalActivities:0,totalParticipants:0,totalDraws:0,winnerCount:0,overallWinRate:0,costControl:0}),D=l([]),M=e(!1),O=t=>t.winRate>2?"success":t.winRate>1?"warning":"info",q=t=>t.winRate>2?"高中奖率":t.winRate>1?"中等中奖率":"低中奖率",H=(t,e)=>({1:`rgba(251, 191, 36, ${e})`,2:`rgba(156, 163, 175, ${e})`,3:`rgba(251, 146, 60, ${e})`,4:`rgba(96, 165, 250, ${e})`,5:`rgba(52, 211, 153, ${e})`}[t]||`rgba(156, 163, 175, ${e})`),I=()=>{return t=this,e=null,l=function*(){M.value=!0;try{const[t,e]=yield Promise.all([p("7d"),u("7d")]);Object.assign(B,t),D.splice(0,D.length,...e),f(()=>{(()=>{if(!N.value||0===D.length)return;const t=N.value,e=t.getContext("2d");if(!e)return;e.clearRect(0,0,t.width,t.height);const l=40,a=t.width-80,s=t.height-80,r=Math.max(...D.map(t=>t.winnerCount)),o=a/D.length*.6,n=a/D.length*.4;D.forEach((t,a)=>{const i=l+a*(o+n)+n/2,c=t.winnerCount/r*s,d=l+s-c,g=e.createLinearGradient(i,d+c,i,d);g.addColorStop(0,H(t.level,.8)),g.addColorStop(1,H(t.level,1)),e.fillStyle=g,e.fillRect(i,d,o,c),e.fillStyle="#333",e.font="12px sans-serif",e.textAlign="center",e.fillText(t.winnerCount.toString(),i+o/2,d-5),e.fillText(t.levelName,i+o/2,l+s+20)}),e.strokeStyle="#e0e0e0",e.lineWidth=1,e.beginPath(),e.moveTo(l,l),e.lineTo(l,l+s),e.lineTo(l+a,l+s),e.stroke()})()})}catch(t){}finally{M.value=!1}},new Promise((a,s)=>{var r=t=>{try{n(l.next(t))}catch(e){s(e)}},o=t=>{try{n(l.throw(t))}catch(e){s(e)}},n=t=>t.done?a(t.value):Promise.resolve(t.value).then(r,o);n((l=l.apply(t,e)).next())});var t,e,l};return a(()=>{I()}),(t,e)=>{const l=m;return r(),s("div",b,[e[5]||(e[5]=o("div",{class:"art-card-header"},[o("div",{class:"title"},[o("h4",null,"活动抽奖效果分析"),o("p",null,"优化中奖概率，控制活动成本")])],-1)),o("div",h,[o("div",y,[o("div",w,[o("div",C,n(B.totalActivities),1),e[0]||(e[0]=o("div",{class:"text-sm text-g-500"},"活动总数",-1))]),o("div",R,[o("div",S,n((a=B.totalParticipants,a>=1e4?(a/1e4).toFixed(1)+"w":a>=1e3?(a/1e3).toFixed(1)+"k":a.toString())),1),e[1]||(e[1]=o("div",{class:"text-sm text-g-500"},"参与人数",-1))]),o("div",j,[o("div",P,n(B.overallWinRate)+"%",1),e[2]||(e[2]=o("div",{class:"text-sm text-g-500"},"整体中奖率",-1))]),o("div",$,[o("div",k,n(B.costControl)+"%",1),e[3]||(e[3]=o("div",{class:"text-sm text-g-500"},"成本控制",-1))])]),o("div",T,[o("canvas",{ref_key:"chartRef",ref:N,width:"400",height:"240"},null,512)]),o("div",_,[o("table",A,[e[4]||(e[4]=o("thead",null,[o("tr",{class:"border-b border-g-200"},[o("th",{class:"text-left py-2"},"奖级"),o("th",{class:"text-left py-2"},"中奖人数"),o("th",{class:"text-left py-2"},"中奖率"),o("th",{class:"text-left py-2"},"成本"),o("th",{class:"text-left py-2"},"状态")])],-1)),o("tbody",null,[(r(!0),s(i,null,c(D,t=>{return r(),s("tr",{key:t.level,class:"border-b border-g-100 hover:bg-g-50"},[o("td",F,[o("div",W,[o("span",{class:g(["w-6 h-6 rounded-full flex items-center justify-center text-white text-xs font-bold mr-2",(e=t.level,{1:"bg-gradient-to-r from-yellow-400 to-yellow-300",2:"bg-gradient-to-r from-gray-400 to-gray-300",3:"bg-gradient-to-r from-orange-400 to-orange-300",4:"bg-gradient-to-r from-blue-400 to-blue-300",5:"bg-gradient-to-r from-green-400 to-green-300"}[e]||"bg-gradient-to-r from-gray-400 to-gray-300")])},n(t.level),3),d(" "+n(t.levelName),1)])]),o("td",z,n(t.winnerCount)+"人",1),o("td",E,n(t.winRate)+"%",1),o("td",G,"¥"+n(t.cost.toLocaleString()),1),o("td",L,[x(l,{type:O(t),size:"small"},{default:v(()=>[d(n(q(t)),1)]),_:2},1032,["type"])])]);var e}),128))])])])])]);var a}}});export{N as default};
