import{r as C}from"./api-f769484e-1706882452509.js";import{g as G,c as E}from"./contants-5f2c5697-1706882452509.js";import{d as A,b as F,e as g,r as s,p as w,f as a,N as k,g as t,h as f,C as o,w as I,j as b,k as h}from"./index-f5a86b16-1706882452509.js";const S="_updateStudentContainer_aa0c9_1",D="_updateBtnGroup_aa0c9_4",d={updateStudentContainer:S,updateBtnGroup:D},q=A({name:"update-student",props:{row:{type:Object,default:()=>({})}},emits:["close","confirm"],setup(r,{emit:n}){const N=F(),l=g({uploading:!1,gradeList:[],classList:[]}),u=g({phone:null,nickname:null,gender:null,currentGradeNum:null,currentClass:null}),c=s(G()),v=s([...E]),i=s(),B=async()=>{var e;(e=i.value)==null||e.validate(async p=>{if(!p){l.uploading=!0;try{await C({...u,id:r.row.id,schoolId:r.row.schoolId,tenantId:r.row.tenantId}),N.success("修改成功"),n("confirm"),n("close")}catch(m){}l.uploading=!1}})};w(async()=>{const e=r.row;e.id&&(u.nickname=e.nickname,u.phone=e.phone,u.gender=e.gender,u.currentGradeNum=e.currentGradeNum,u.currentClass=e.currentClass),u.currentGradeNum&&c.value.findIndex(m=>m.value===u.currentGradeNum)===-1&&(u.currentGradeNum=null)});const y=e=>!e||/^\d+$/.test(e);return()=>a("div",{class:d.updateStudentContainer},[a(k,{ref:i,model:u,labelAlign:"right",labelWidth:"auto",labelPlacement:"left"},{default:()=>[a(t,{label:"姓名",path:"nickname",rule:{required:!0,message:"请填写学生姓名",trigger:"blur"}},{default:()=>[a(f,{maxlength:15,placeholder:"请填写学生姓名",value:u.nickname,"onUpdate:value":e=>u.nickname=e},null)]}),a(t,{label:"手机号",path:"phone",rule:[{required:!0,message:"请填写学生手机号",trigger:"blur"},{pattern:/^1[3456789]\d{9}$/,message:"手机号格式不正确",trigger:"blur"}]},{default:()=>[a(f,{maxlength:11,allowInput:y,placeholder:"请填写学生手机号",value:u.phone,"onUpdate:value":e=>u.phone=e},null)]}),a(t,{label:"性别",path:"gender",rule:[{required:!0,message:"请选择性别",trigger:"blur",type:"number"}]},{default:()=>[a(o,{class:d.select,clearable:!0,filterable:!0,placeholder:"请选择性别",options:[{label:"男",value:1},{label:"女",value:0}],value:u.gender,"onUpdate:value":e=>u.gender=e},null)]}),a(t,{label:"年级",path:"currentGradeNum",rule:[{required:!0,message:"请选择年级",trigger:"change",type:"number"}]},{default:()=>[a(o,{value:u.currentGradeNum,"onUpdate:value":e=>u.currentGradeNum=e,placeholder:"请选择年级",options:c.value,clearable:!0,filterable:!0},null)]}),a(t,{label:"班级",path:"currentClass",rule:[{required:!0,message:"请选择班级",trigger:"change",type:"number"}]},{default:()=>[a(o,{filterable:!0,value:u.currentClass,"onUpdate:value":e=>u.currentClass=e,placeholder:"请选择班级",clearable:!0,options:v.value},null)]}),a(I,{class:d.updateBtnGroup},{default:()=>[a(b,{strong:!0,type:"default",round:!0,onClick:()=>n("close")},{default:()=>[h("取消")]}),a(b,{strong:!0,type:"primary",round:!0,disabled:l.uploading,loading:l.uploading,onClick:B},{default:()=>[h("确认")]})]})]})])}});export{q as U};
