import{d as R,r as v,v as S,a as j,G as A,E as u,g as s,J as G,z as y,k as x,w as r,K as J,e as o,b as F,I as k,t as C,x as K,_ as M}from"./index-CUnFTKV2.js";import{a as O,u as T,c as $}from"./prizelevel-DnmTpVNC.js";const H=R({__name:"PrizeLevelFormDialog",props:{modelValue:{type:Boolean},levelId:{}},emits:["update:modelValue","success"],setup(_,{emit:D}){const n=_,V=D,m=v(),p=v(!1),c=v(!1),f=S(()=>!!n.levelId),l=j({title:"",pro:0,imgUrl:"",color:"",specialImgUrl:"",sort:0}),z={title:[{required:!0,message:"请输入等级名称",trigger:"blur"}],pro:[{required:!0,message:"请输入概率",trigger:"blur"}]};A(()=>n.modelValue,async t=>{t&&(n.levelId?await L():U())});const L=async()=>{if(n.levelId){p.value=!0;try{const t=await O(n.levelId);Object.assign(l,{title:t.data.title,pro:t.data.pro,imgUrl:t.data.imgUrl||"",color:t.data.color||"",specialImgUrl:t.data.specialImgUrl||"",sort:t.data.sort})}catch(t){console.error("获取等级详情失败:",t),u.error("获取等级详情失败")}finally{p.value=!1}}},U=()=>{var t;l.title="",l.pro=0,l.imgUrl="",l.color="",l.specialImgUrl="",l.sort=0,(t=m.value)==null||t.resetFields()},g=()=>{V("update:modelValue",!1),U()},B=async()=>{var e;if(await((e=m.value)==null?void 0:e.validate())){c.value=!0;try{f.value&&n.levelId?(await T(n.levelId,l),u.success("保存成功")):(await $(l),u.success("添加成功")),V("success"),g()}catch(i){console.error("保存失败:",i),u.error(i.message||"保存失败")}finally{c.value=!1}}};return(t,e)=>{const i=s("el-input"),d=s("el-form-item"),b=s("el-input-number"),P=s("el-color-picker"),w=s("el-col"),h=s("el-row"),E=s("el-form"),I=s("el-button"),N=s("el-dialog"),q=G("loading");return x(),y(N,{"model-value":_.modelValue,title:f.value?"编辑奖品等级":"添加奖品等级",width:"600px","onUpdate:modelValue":e[7]||(e[7]=a=>t.$emit("update:modelValue",a)),onClose:g},{footer:r(()=>[o(I,{onClick:g},{default:r(()=>[...e[10]||(e[10]=[C("取消",-1)])]),_:1}),o(I,{type:"primary",onClick:B,loading:c.value},{default:r(()=>[C(K(f.value?"保存":"添加"),1)]),_:1},8,["loading"])]),default:r(()=>[J((x(),y(E,{ref_key:"formRef",ref:m,model:l,rules:z,"label-width":"100px"},{default:r(()=>[o(d,{label:"等级名称",prop:"title"},{default:r(()=>[o(i,{modelValue:l.title,"onUpdate:modelValue":e[0]||(e[0]=a=>l.title=a),placeholder:"请输入等级名称，如：A赏、B赏"},null,8,["modelValue"])]),_:1}),o(d,{label:"概率",prop:"pro"},{default:r(()=>[o(b,{modelValue:l.pro,"onUpdate:modelValue":e[1]||(e[1]=a=>l.pro=a),min:0,max:100,precision:2,step:.1,placeholder:"请输入概率"},null,8,["modelValue"]),e[8]||(e[8]=F("span",{class:"unit"},"%",-1))]),_:1}),o(d,{label:"等级颜色",prop:"color"},{default:r(()=>[o(P,{modelValue:l.color,"onUpdate:modelValue":e[2]||(e[2]=a=>l.color=a),"show-alpha":""},null,8,["modelValue"]),o(i,{modelValue:l.color,"onUpdate:modelValue":e[3]||(e[3]=a=>l.color=a),placeholder:"#FFFFFF",style:{width:"120px","margin-left":"10px"}},null,8,["modelValue"])]),_:1}),o(h,{gutter:20},{default:r(()=>[o(w,{span:12},{default:r(()=>[o(d,{label:"等级图标",prop:"imgUrl"},{default:r(()=>[o(k,{modelValue:l.imgUrl,"onUpdate:modelValue":e[4]||(e[4]=a=>l.imgUrl=a),placeholder:"点击上传图标",width:80,height:80},null,8,["modelValue"])]),_:1})]),_:1}),o(w,{span:12},{default:r(()=>[o(d,{label:"特殊图片",prop:"specialImgUrl"},{default:r(()=>[o(k,{modelValue:l.specialImgUrl,"onUpdate:modelValue":e[5]||(e[5]=a=>l.specialImgUrl=a),placeholder:"点击上传特殊图片",width:80,height:80},null,8,["modelValue"])]),_:1})]),_:1})]),_:1}),o(d,{label:"排序",prop:"sort"},{default:r(()=>[o(b,{modelValue:l.sort,"onUpdate:modelValue":e[6]||(e[6]=a=>l.sort=a),min:0,max:9999},null,8,["modelValue"]),e[9]||(e[9]=F("span",{class:"hint"},"数值越小越靠前",-1))]),_:1})]),_:1},8,["model"])),[[q,p.value]])]),_:1},8,["model-value","title"])}}}),X=M(H,[["__scopeId","data-v-48e8ccaa"]]);export{X as default};
