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