import{A as e,B as a,a5 as r,a6 as s,e as t,X as l,E as u}from"./vendor-element-DupX9wXy.js";import{ar as o}from"./index-CeAbLubS.js";import{q as d,bI as i,r as n,a2 as m,c as p,S as c,D as v,v as f,E as b,M as y,u as G,t as g,L as h,aq as I,A as _,J as w,K as M}from"./vendor-core-Di0OO4oJ.js";const x={class:"dialog-footer"},N=d({__name:"rate-group-switch-dialog",props:{visible:{type:Boolean},userId:{},currentRateGroupId:{},rateGroups:{}},emits:["update:visible","success"],setup(d,{emit:N}){const{t:V}=i(),R=d,j=N,k=n(!1),q=m({rateGroupId:0}),A=p(()=>R.rateGroups.filter(e=>0!==Number(e.id))),B=p(()=>{var e;return Number(null==(e=A.value[0])?void 0:e.id)||1}),C=p({get:()=>R.visible,set:e=>j("update:visible",e)});c(()=>R.visible,e=>{e&&(q.rateGroupId=Number(R.currentRateGroupId)||B.value)}),c(A,e=>{if(!R.visible||!e.length)return;const a=Number(q.rateGroupId);e.some(e=>Number(e.id)===a)||(q.rateGroupId=B.value)},{immediate:!0});const E=()=>{return e=null,a=null,r=function*(){k.value=!0;try{yield o({id:R.userId,rateGroupId:q.rateGroupId}),u.success(V("system.userManage.switchSuccess")),C.value=!1,j("success")}catch(e){}finally{k.value=!1}},new Promise((s,t)=>{var l=e=>{try{o(r.next(e))}catch(a){t(a)}},u=e=>{try{o(r.throw(e))}catch(a){t(a)}},o=e=>e.done?s(e.value):Promise.resolve(e.value).then(l,u);o((r=r.apply(e,a)).next())});var e,a,r};return(u,o)=>{const d=s,i=r,n=a,m=e,p=t,c=l;return f(),v(c,{modelValue:C.value,"onUpdate:modelValue":o[2]||(o[2]=e=>C.value=e),title:G(V)("system.userManage.switchRateGroup"),width:"400px","align-center":""},{footer:b(()=>[_("div",x,[y(p,{onClick:o[1]||(o[1]=e=>C.value=!1)},{default:b(()=>[w(M(G(V)("system.userManage.cancel")),1)]),_:1}),y(p,{type:"primary",onClick:E,loading:k.value},{default:b(()=>[w(M(G(V)("system.userManage.confirm")),1)]),_:1},8,["loading"])])]),default:b(()=>[y(m,{ref:"formRef",model:q,"label-width":"80px"},{default:b(()=>[y(n,{label:G(V)("system.userManage.rateGroup"),prop:"rateGroupId"},{default:b(()=>[y(i,{modelValue:q.rateGroupId,"onUpdate:modelValue":o[0]||(o[0]=e=>q.rateGroupId=e),placeholder:G(V)("system.userManage.selectRateGroup"),style:{width:"100%"}},{default:b(()=>[(f(!0),g(h,null,I(A.value,e=>(f(),v(d,{key:e.id,label:e.name,value:Number(e.id)},null,8,["label","value"]))),128))]),_:1},8,["modelValue","placeholder"])]),_:1},8,["label"])]),_:1},8,["model"])]),_:1},8,["modelValue","title"])}}});export{N as _};
