import{a as V,c as y,b,i as k,d as l,w as o,r as s,v as _,Q as N,f as g,R as j,g as C,h as v,E as i}from"./index-iUtVMwIO.js";import{s as U}from"./user-W7s1uzfv.js";import"./request-Cj91lFqZ.js";const B={class:"space-y-6"},R={class:"bg-white rounded-xl shadow-sm border border-gray-200 p-6"},q={class:"max-w-lg"},T=Object.assign({name:"Tools"},{__name:"index",setup(E){const a=v(null),u=v(!1),t=C({name:"",jobNumber:"",phone:""}),h={name:[{required:!0,message:"请输入用户名",trigger:"blur"}],jobNumber:[{required:!0,message:"请输入工号",trigger:"blur"}],phone:[{required:!0,message:"请输入手机号",trigger:"blur"},{pattern:/^1[3-9]\d{9}$/,message:"请输入正确的手机号",trigger:"blur"}]},w=async()=>{a.value&&await a.value.validate(async p=>{if(p){u.value=!0;try{const e=await U(t);e.success?(i.success(e.message||"新增用户成功"),m(),await loadUserList()):i.error(e.message||"新增用户失败")}catch(e){console.error("新增用户失败:",e),i.error("新增用户失败")}finally{u.value=!1}}})},m=()=>{a.value&&a.value.resetFields()};return(p,e)=>{const d=s("el-input"),n=s("el-form-item"),c=s("el-icon"),f=s("el-button"),x=s("el-form");return V(),y("div",B,[b("div",R,[e[5]||(e[5]=k('<div class="border-b border-gray-200 pb-4 mb-6"><div class="flex items-center justify-between"><h2 class="text-xl font-semibold text-gray-800 flex items-center gap-2"><svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 text-blue-500" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M18 9v3m0 0v3m0-3h3m-3 0h-3m-2-5a4 4 0 11-8 0 4 4 0 018 0zM3 20a6 6 0 0112 0v1H3v-1z"></path></svg> 新增用户 </h2></div></div>',1)),b("div",q,[l(x,{ref_key:"formRef",ref:a,model:t,rules:h,"label-width":"80px","label-position":"left"},{default:o(()=>[l(n,{label:"用户名",prop:"name"},{default:o(()=>[l(d,{modelValue:t.name,"onUpdate:modelValue":e[0]||(e[0]=r=>t.name=r),placeholder:"请输入用户名",clearable:""},null,8,["modelValue"])]),_:1}),l(n,{label:"工号",prop:"jobNumber"},{default:o(()=>[l(d,{modelValue:t.jobNumber,"onUpdate:modelValue":e[1]||(e[1]=r=>t.jobNumber=r),placeholder:"请输入工号",clearable:""},null,8,["modelValue"])]),_:1}),l(n,{label:"手机号",prop:"phone"},{default:o(()=>[l(d,{modelValue:t.phone,"onUpdate:modelValue":e[2]||(e[2]=r=>t.phone=r),placeholder:"请输入手机号",clearable:""},null,8,["modelValue"])]),_:1}),l(n,null,{default:o(()=>[l(f,{type:"primary",onClick:w,loading:u.value},{default:o(()=>[l(c,null,{default:o(()=>[l(_(N))]),_:1}),e[3]||(e[3]=g(" 提交 ",-1))]),_:1},8,["loading"]),l(f,{onClick:m},{default:o(()=>[l(c,null,{default:o(()=>[l(_(j))]),_:1}),e[4]||(e[4]=g(" 重置 ",-1))]),_:1})]),_:1})]),_:1},8,["model"])])])])}}});export{T as default};
