import{$ as e,L as t,P as n,V as r,Wt as i,_ as a,d as o,f as s,h as c,i as l,lt as u,p as d,st as f,u as p,v as m,z as h}from"./runtime-core.esm-bundler-DbRZbT7v.js";import{i as g,s as _}from"./index-ZRE77JpD.js";import{t as v}from"./axios-Cty4xAHp.js";var y={class:`min-h-screen bg-gradient-to-br from-pink-50 to-purple-50 flex items-center justify-center p-4`},b={class:`bg-white rounded-3xl shadow-xl w-full max-w-md p-8`},x={key:0,class:`text-gray-400 text-xs ml-2`},S={class:`text-center mt-6 text-sm text-gray-400`},C={__name:`index`,setup(C){let w=g(),T=u(!1),E=u(!1),D=u([]),O=u([]),k=f({store_id:``,registration_package_id:``,username:``,password:``,name:``,phone:``}),A=u(null),j={store_id:[{required:!0,message:`请选择门店`,trigger:`change`}],registration_package_id:[{required:!0,message:`请选择岗位套餐`,trigger:`change`}],username:[{required:!0,message:`请输入登录账号`,trigger:`blur`},{min:2,max:50,message:`2-50个字符`,trigger:`blur`}],password:[{required:!0,message:`请输入密码`,trigger:`blur`},{min:6,message:`密码不少于6位`,trigger:`blur`}],name:[{required:!0,message:`请输入真实姓名`,trigger:`blur`}],phone:[{required:!0,message:`请输入手机号`,trigger:`blur`},{pattern:/^1[3-9]\d{9}$/,message:`手机号格式不正确`,trigger:`blur`}]};async function M(){try{O.value=(await v.get(`/api/v1/auth/stores`)).data?.data||[]}catch{}}async function N(){if(k.store_id){E.value=!0,k.registration_package_id=``;try{D.value=(await v.get(`/api/v1/auth/register/packages`,{params:{store_id:k.store_id}})).data?.data||[]}catch{D.value=[]}finally{E.value=!1}}}async function P(){A.value&&await A.value.validate(async e=>{if(e){T.value=!0;try{await v.post(`/api/v1/auth/register`,k),_.success(`注册成功！请等待管理员审核后登录`),setTimeout(()=>w.push(`/login`),1500)}catch(e){let t=e.response?.data?.message||`注册失败，请稍后重试`;_.error(t)}finally{T.value=!1}}})}return n(M),(n,u)=>{let f=r(`el-option`),g=r(`el-select`),_=r(`el-form-item`),v=r(`el-input`),C=r(`el-col`),w=r(`el-row`),M=r(`el-button`),F=r(`el-form`),I=r(`router-link`);return t(),d(`div`,y,[p(`div`,b,[u[10]||=p(`div`,{class:`text-center mb-8`},[p(`div`,{class:`text-3xl mb-1`},`🏠`),p(`h1`,{class:`text-2xl font-bold text-gray-800`},`宫中有喜`),p(`p`,{class:`text-sm text-gray-400 mt-1`},`月子会所管理系统 · 员工注册`)],-1),m(F,{ref_key:`formRef`,ref:A,model:k,rules:j,"label-position":`top`},{default:e(()=>[m(_,{label:`所属门店`,prop:`store_id`},{default:e(()=>[m(g,{modelValue:k.store_id,"onUpdate:modelValue":u[0]||=e=>k.store_id=e,placeholder:`请选择门店`,style:{width:`100%`},onChange:N},{default:e(()=>[(t(!0),d(l,null,h(O.value,e=>(t(),o(f,{key:e.id,label:e.name,value:e.id},null,8,[`label`,`value`]))),128))]),_:1},8,[`modelValue`])]),_:1}),m(_,{label:`申请岗位`,prop:`registration_package_id`},{default:e(()=>[m(g,{modelValue:k.registration_package_id,"onUpdate:modelValue":u[1]||=e=>k.registration_package_id=e,placeholder:`请先选择门店`,style:{width:`100%`},loading:E.value,disabled:!k.store_id},c({default:e(()=>[(t(!0),d(l,null,h(D.value,n=>(t(),o(f,{key:n.id,label:n.name,value:n.id},{default:e(()=>[p(`span`,null,i(n.name),1),n.description?(t(),d(`span`,x,i(n.description),1)):s(``,!0)]),_:2},1032,[`label`,`value`]))),128))]),_:2},[D.value.length===0&&k.store_id&&!E.value?{name:`empty`,fn:e(()=>[u[6]||=p(`div`,{class:`text-center py-4 text-gray-400 text-sm`},`该门店暂无可用套餐`,-1)]),key:`0`}:void 0]),1032,[`modelValue`,`loading`,`disabled`])]),_:1}),m(w,{gutter:12},{default:e(()=>[m(C,{span:12},{default:e(()=>[m(_,{label:`登录账号`,prop:`username`},{default:e(()=>[m(v,{modelValue:k.username,"onUpdate:modelValue":u[2]||=e=>k.username=e,placeholder:`字母/数字`},null,8,[`modelValue`])]),_:1})]),_:1}),m(C,{span:12},{default:e(()=>[m(_,{label:`登录密码`,prop:`password`},{default:e(()=>[m(v,{modelValue:k.password,"onUpdate:modelValue":u[3]||=e=>k.password=e,type:`password`,placeholder:`不少于6位`,"show-password":``},null,8,[`modelValue`])]),_:1})]),_:1})]),_:1}),m(w,{gutter:12},{default:e(()=>[m(C,{span:12},{default:e(()=>[m(_,{label:`真实姓名`,prop:`name`},{default:e(()=>[m(v,{modelValue:k.name,"onUpdate:modelValue":u[4]||=e=>k.name=e,placeholder:`请输入姓名`},null,8,[`modelValue`])]),_:1})]),_:1}),m(C,{span:12},{default:e(()=>[m(_,{label:`手机号`,prop:`phone`},{default:e(()=>[m(v,{modelValue:k.phone,"onUpdate:modelValue":u[5]||=e=>k.phone=e,placeholder:`11位手机号`},null,8,[`modelValue`])]),_:1})]),_:1})]),_:1}),m(M,{type:`primary`,style:{width:`100%`,"margin-top":`8px`},loading:T.value,onClick:P},{default:e(()=>[...u[7]||=[a(` 提交注册申请 `,-1)]]),_:1},8,[`loading`])]),_:1},8,[`model`]),p(`div`,S,[u[9]||=a(` 已有账号？ `,-1),m(I,{to:`/login`,class:`text-blue-500 hover:underline`},{default:e(()=>[...u[8]||=[a(`立即登录`,-1)]]),_:1})]),u[11]||=p(`div`,{class:`mt-4 p-3 bg-amber-50 rounded-xl text-xs text-amber-600 leading-relaxed`},` ⚠️ 注册后需管理员审核，审核通过后方可登录系统 `,-1)])])}}};export{C as default};