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