import"./default.76e08716.js";import{M as R}from"./index.cef07818.js";import"./index.0857d90f.js";import{I as T,_ as O,F as S}from"./index.0e96b1ad.js";import"./index.b2c65497.js";import"./index.5ec54e89.js";import{_ as B}from"./index.b49a664b.js";import{u as C,a as y,r as j,H as E,o as k,b as P,e as t,w as n,aE as x,f as b,a$ as z,d0 as D,d1 as H,d2 as N,d3 as V,cI as $}from"./index.ab0d47a4.js";import{g as A}from"./role.efebb491.js";import{u as G}from"./useModal.67c34fed.js";import{_ as J}from"./Password.ee3cd4fa.js";const ne=[{title:"ID",dataIndex:"id",key:"id"},{title:"\u7528\u6237\u540D",dataIndex:"username",key:"username"},{title:"\u6635\u79F0",dataIndex:"nickname",key:"nickname"},{title:"\u72B6\u6001",dataIndex:"status",key:"status"},{title:"\u521B\u5EFA\u65F6\u95F4",dataIndex:"created",key:"created"},{title:"\u66F4\u65B0\u65F6\u95F4",dataIndex:"modified",key:"modified"},{title:"\u64CD\u4F5C",key:"action"}],K={username:[{required:!0,message:"\u8BF7\u8F93\u5165\u7528\u6237\u540D",trigger:"blur"},{min:5,max:20,message:"5~20",trigger:"blur"}],password:[{required:!0,message:"\u8BF7\u8F93\u5165\u5BC6\u7801",trigger:"blur"},{min:6,max:12,message:"6~12",trigger:"blur"}],nickname:[{required:!0,message:"\u8BF7\u8F93\u5165\u6635\u79F0",trigger:"blur"},{min:5,max:20,message:"5~20",trigger:"blur"}],roles:[{required:!0,message:"\u8BF7\u914D\u7F6E\u89D2\u8272",trigger:"blur"}]},L={password:[{required:!0,message:"\u8BF7\u8F93\u5165\u5BC6\u7801",trigger:"blur"},{min:6,max:12,message:"6~12",trigger:"blur"}],nickname:[{required:!0,message:"\u8BF7\u8F93\u5165\u6635\u79F0",trigger:"blur"},{min:5,max:20,message:"5~20",trigger:"blur"}],roles:[{required:!0,message:"\u8BF7\u914D\u7F6E\u89D2\u8272",trigger:"blur"}]},Q={class:"modal"},W={__name:"user-modal",props:{modalTitle:{type:String},modalType:{type:String,default:"create"}},setup(g,{expose:U}){const I=g,w=C(),{showModal:o,updateId:f,formRef:m}=G(),s=y({username:"",nickname:"",password:"",roles:[]}),l=y({nickname:"",password:"",roles:[]}),v=j([]);E(o,async()=>{if(o.value){const u=await A({limit:100});v.value=u.data.items.map(e=>({label:e.name,value:e.id}))}});const q=async u=>{o.value=!o.value,f.value=u.id;const e=await D(u.id);l.roles=e.data.roles.map(i=>i.id),l.nickname=e.data.nickname,l.password="\u52A0\u5BC6\u4E4B\u540E\u7684\u5BC6\u7801"},F=()=>{m.value.validateFields().then(async()=>{let u,e=!1;if(I.modalType==="create")s.roles=s.roles.map((i,r)=>({rid:i,status:r===0?5:1})),u=await H(s);else{const{nickname:i,password:r,roles:d}=l;let p=d.map((c,_)=>({rid:c,status:_===0?5:1}));u=await N(f.value,{nickname:i,password:r,roles:p}),f.value===w.userInfo.id&&(V.warning("\u4FEE\u6539\u767B\u5F55\u7528\u6237\u4FE1\u606F\uFF0C\u91CD\u65B0\u767B\u5F55\u751F\u6548."),e=!0)}e||$(u),m.value.resetFields(),o.value=!o.value,w.isPush=!0})},M=()=>{m.value.resetFields()};return U({showModal:o,openModal:q}),(u,e)=>{const i=T,r=O,d=J,p=B,c=S,_=R;return k(),P("div",Q,[t(_,{visible:b(o),"onUpdate:visible":e[7]||(e[7]=a=>z(o)?o.value=a:null),title:g.modalTitle,"ok-text":"\u786E\u8BA4","cancel-text":"\u53D6\u6D88",onOk:F,onCancel:M},{default:n(()=>[g.modalType==="create"?(k(),x(c,{key:0,ref_key:"formRef",ref:m,model:s,rules:b(K)},{default:n(()=>[t(r,{name:"username",label:"\u8D26\u53F7"},{default:n(()=>[t(i,{value:s.username,"onUpdate:value":e[0]||(e[0]=a=>s.username=a),placeholder:"\u7528\u4E8E\u767B\u5F55"},null,8,["value"])]),_:1}),t(r,{name:"nickname",label:"\u6635\u79F0"},{default:n(()=>[t(i,{value:s.nickname,"onUpdate:value":e[1]||(e[1]=a=>s.nickname=a)},null,8,["value"])]),_:1}),t(r,{name:"password",label:"\u5BC6\u7801"},{default:n(()=>[t(d,{value:s.password,"onUpdate:value":e[2]||(e[2]=a=>s.password=a),autocomplete:"on"},null,8,["value"])]),_:1}),t(r,{name:"roles",label:"\u89D2\u8272"},{default:n(()=>[t(p,{value:s.roles,"onUpdate:value":e[3]||(e[3]=a=>s.roles=a),mode:"multiple",style:{width:"100%"},placeholder:"\u9ED8\u8BA4\u6FC0\u6D3B\u7B2C\u4E00\u4E2A\u89D2\u8272",options:v.value},null,8,["value","options"])]),_:1})]),_:1},8,["model","rules"])):(k(),x(c,{key:1,ref_key:"formRef",ref:m,model:l,rules:b(L)},{default:n(()=>[t(r,{name:"nickname",label:"\u6635\u79F0"},{default:n(()=>[t(i,{value:l.nickname,"onUpdate:value":e[4]||(e[4]=a=>l.nickname=a)},null,8,["value"])]),_:1}),t(r,{name:"password",label:"\u5BC6\u7801"},{default:n(()=>[t(d,{value:l.password,"onUpdate:value":e[5]||(e[5]=a=>l.password=a),autocomplete:"on"},null,8,["value"])]),_:1}),t(r,{name:"roles",label:"\u89D2\u8272"},{default:n(()=>[t(p,{value:l.roles,"onUpdate:value":e[6]||(e[6]=a=>l.roles=a),mode:"multiple",style:{width:"100%"},placeholder:"\u9ED8\u8BA4\u6FC0\u6D3B\u7B2C\u4E00\u4E2A\u89D2\u8272",options:v.value},null,8,["value","options"])]),_:1})]),_:1},8,["model","rules"]))]),_:1},8,["visible","title"])])}}},ue=Object.freeze(Object.defineProperty({__proto__:null,default:W},Symbol.toStringTag,{value:"Module"}));export{W as _,ne as c,ue as u};
