import{d as K,r as p,a as G,o as H,g as s,J as O,c as m,k as u,e as l,w as a,b as g,K as Q,t as i,x as f,z as P,a8 as V,l as W,C as X,E as v,D as Y,_ as Z}from"./index-CUnFTKV2.js";import ee from"./PrizeLevelFormDialog-C5yfmwoq.js";import{b as te,d as le,e as ae}from"./prizelevel-DnmTpVNC.js";const ne={class:"page-container"},oe={class:"card-header"},se={class:"stats-bar"},re={class:"stats-value"},ie={key:1},ce={key:1},de=K({__name:"prize-level",setup(pe){const b=p(!1),x=p([]),w=p(0),S=p({totalProbability:0}),o=G({page:1,pageSize:20,title:""}),_=p(!1),y=p(null),D=n=>{if(!n)return"#333";const e=n.replace("#",""),h=parseInt(e.substr(0,2),16),d=parseInt(e.substr(2,2),16),z=parseInt(e.substr(4,2),16);return(h*299+d*587+z*114)/1e3>128?"#333":"#fff"},c=async()=>{b.value=!0;try{const[n,e]=await Promise.all([te(o),le()]);x.value=n.data.list,w.value=n.data.total,S.value=e.data}catch(n){console.error("获取奖品等级列表失败:",n),v.error("获取奖品等级列表失败")}finally{b.value=!1}},B=()=>{o.page=1,c()},L=()=>{o.title="",o.page=1,c()},U=n=>{o.page=n,c()},I=n=>{o.pageSize=n,o.page=1,c()},E=()=>{y.value=null,_.value=!0},T=n=>{y.value=n.id,_.value=!0},M=async n=>{if(n.prizeCount>0){v.warning("当前等级关联有奖品，不可删除");return}try{await Y.confirm(`确定要删除等级"${n.title}"吗？`,"删除确认",{confirmButtonText:"确定",cancelButtonText:"取消",type:"warning"}),await ae(n.id),v.success("删除成功"),c()}catch(e){e!=="cancel"&&(console.error("删除失败:",e),v.error(e.message||"删除失败"))}},N=()=>{c()};return H(()=>{c()}),(n,e)=>{const h=s("el-icon"),d=s("el-button"),z=s("el-input"),C=s("el-form-item"),R=s("el-form"),k=s("el-tag"),r=s("el-table-column"),$=s("el-image"),A=s("el-table"),F=s("el-pagination"),j=s("el-card"),q=O("loading");return u(),m("div",ne,[l(j,null,{header:a(()=>[g("div",oe,[e[5]||(e[5]=g("span",null,"奖品等级设置",-1)),l(d,{type:"primary",onClick:E},{default:a(()=>[l(h,null,{default:a(()=>[l(W(X))]),_:1}),e[4]||(e[4]=i("添加等级 ",-1))]),_:1})])]),default:a(()=>[l(R,{inline:!0,model:o,class:"search-form"},{default:a(()=>[l(C,{label:"等级名称"},{default:a(()=>[l(z,{modelValue:o.title,"onUpdate:modelValue":e[0]||(e[0]=t=>o.title=t),placeholder:"请输入等级名称",clearable:""},null,8,["modelValue"])]),_:1}),l(C,null,{default:a(()=>[l(d,{type:"primary",onClick:B},{default:a(()=>[...e[6]||(e[6]=[i("搜索",-1)])]),_:1}),l(d,{onClick:L},{default:a(()=>[...e[7]||(e[7]=[i("重置",-1)])]),_:1})]),_:1})]),_:1},8,["model"]),g("div",se,[l(k,{type:"info",size:"large"},{default:a(()=>{var t;return[e[8]||(e[8]=i(" 概率总和: ",-1)),g("span",re,f(((t=S.value.totalProbability)==null?void 0:t.toFixed(2))||"0.00")+"%",1)]}),_:1})]),Q((u(),P(A,{data:x.value,border:"",stripe:""},{default:a(()=>[l(r,{prop:"id",label:"ID",width:"80",align:"center"}),l(r,{prop:"title",label:"等级名称","min-width":"120"},{default:a(({row:t})=>[l(k,{color:t.color,style:V({color:D(t.color)})},{default:a(()=>[i(f(t.title),1)]),_:2},1032,["color","style"])]),_:1}),l(r,{prop:"pro",label:"概率",width:"100",align:"center"},{default:a(({row:t})=>[g("span",null,f(t.pro)+"%",1)]),_:1}),l(r,{label:"等级图标",width:"100",align:"center"},{default:a(({row:t})=>[t.imgUrl?(u(),P($,{key:0,src:t.imgUrl,"preview-src-list":[t.imgUrl],fit:"cover",style:{width:"40px",height:"40px"}},null,8,["src","preview-src-list"])):(u(),m("span",ie,"-"))]),_:1}),l(r,{prop:"color",label:"颜色",width:"100",align:"center"},{default:a(({row:t})=>[t.color?(u(),m("div",{key:0,class:"color-preview",style:V({backgroundColor:t.color})},null,4)):(u(),m("span",ce,"-"))]),_:1}),l(r,{prop:"sort",label:"排序",width:"80",align:"center"}),l(r,{prop:"prizeCount",label:"关联奖品",width:"100",align:"center"},{default:a(({row:t})=>[l(k,{type:"info"},{default:a(()=>[i(f(t.prizeCount),1)]),_:2},1024)]),_:1}),l(r,{prop:"updatedAt",label:"更新时间",width:"180"}),l(r,{label:"操作",width:"150",fixed:"right",align:"center"},{default:a(({row:t})=>[l(d,{type:"primary",link:"",onClick:J=>T(t)},{default:a(()=>[...e[9]||(e[9]=[i("编辑",-1)])]),_:1},8,["onClick"]),l(d,{type:"danger",link:"",onClick:J=>M(t)},{default:a(()=>[...e[10]||(e[10]=[i("删除",-1)])]),_:1},8,["onClick"])]),_:1})]),_:1},8,["data"])),[[q,b.value]]),l(F,{"current-page":o.page,"onUpdate:currentPage":e[1]||(e[1]=t=>o.page=t),"page-size":o.pageSize,"onUpdate:pageSize":e[2]||(e[2]=t=>o.pageSize=t),"page-sizes":[10,20,50,100],total:w.value,layout:"total, sizes, prev, pager, next, jumper",onSizeChange:I,onCurrentChange:U,class:"pagination"},null,8,["current-page","page-size","total"])]),_:1}),l(ee,{modelValue:_.value,"onUpdate:modelValue":e[3]||(e[3]=t=>_.value=t),"level-id":y.value,onSuccess:N},null,8,["modelValue","level-id"])])}}}),me=Z(de,[["__scopeId","data-v-3bc8f690"]]);export{me as default};
