Commit 7be1662e by FE

Merge branch 'student-register' into dev

parents f157cd93 40fe659e
...@@ -32,7 +32,7 @@ class StudentRoot extends PureComponent { ...@@ -32,7 +32,7 @@ class StudentRoot extends PureComponent {
isCollege: false, isCollege: false,
list: [], list: [],
schoolList: [], schoolList: [],
collegeList: [], schoolName: '',
}; };
} }
...@@ -100,18 +100,24 @@ class StudentRoot extends PureComponent { ...@@ -100,18 +100,24 @@ class StudentRoot extends PureComponent {
} }
changeToCollege = (school = '') => { changeToCollege = (school = '') => {
const { list } = this.state;
const data = list.filter(item => item['school'] === school);
if(data.length > 0) {
this.setState({ this.setState({
collegeList: data[0]['colleges'] schoolName: school
}); });
} }
fetchCollegeInfo = () => {
const { list, schoolName } = this.state;
const data = list.filter(item => item['school'] === schoolName);
if(data.length > 0) {
return data[0]['colleges']
}
return [];
} }
render() { render() {
const { country } = this.props; const { country } = this.props;
const { validate, captchaInstance, isSchool, isCollege, schoolList, collegeList } = this.state; const { validate, captchaInstance, isSchool, isCollege, schoolList, schoolName } = this.state;
const collegeList = this.fetchCollegeInfo();
return ( return (
<> <>
<HeaderBar title={'助学计划'} arrow={true}/> <HeaderBar title={'助学计划'} arrow={true}/>
...@@ -202,9 +208,7 @@ class StudentRoot extends PureComponent { ...@@ -202,9 +208,7 @@ class StudentRoot extends PureComponent {
<VeriCodeInput <VeriCodeInput
{...field} {...field}
className={'student-form__code'} className={'student-form__code'}
icon={<i className={'iconfont iconduanxin'} icon={<i className={'iconfont iconduanxin'} style={{fontSize: '20px', left: '12px'}}/>}
style={{fontSize: '20px', left: '12px'}}
/>}
tel={props.values.tel} tel={props.values.tel}
challenge={validate} challenge={validate}
errors={props.errors} errors={props.errors}
...@@ -220,6 +224,7 @@ class StudentRoot extends PureComponent { ...@@ -220,6 +224,7 @@ class StudentRoot extends PureComponent {
<StudentSelect <StudentSelect
name="school" name="school"
value={props.values.school} value={props.values.school}
schoolName={schoolName}
data={{ data={{
key: 'isSchool', key: 'isSchool',
val: isSchool val: isSchool
...@@ -227,7 +232,9 @@ class StudentRoot extends PureComponent { ...@@ -227,7 +232,9 @@ class StudentRoot extends PureComponent {
options={schoolList} options={schoolList}
placeholder="请选择" placeholder="请选择"
onChange={props.setFieldValue} onChange={props.setFieldValue}
clearToCollege={() => props.setFieldValue('college', '')} clearToCollege={() => {
props.setFieldValue('college', '')
}}
selectSwitch={this.selectSwitch} selectSwitch={this.selectSwitch}
changeToCollege={this.changeToCollege} changeToCollege={this.changeToCollege}
/> />
...@@ -246,7 +253,6 @@ class StudentRoot extends PureComponent { ...@@ -246,7 +253,6 @@ class StudentRoot extends PureComponent {
placeholder="请先选择学校" placeholder="请先选择学校"
onChange={props.setFieldValue} onChange={props.setFieldValue}
selectSwitch={this.selectSwitch} selectSwitch={this.selectSwitch}
changeToCollege={this.changeToCollege}
/> />
</div> </div>
<div className="student-form__item"> <div className="student-form__item">
...@@ -277,6 +283,7 @@ const StudentSelect = (props) => { ...@@ -277,6 +283,7 @@ const StudentSelect = (props) => {
const { const {
options = [], options = [],
data: { key = '' , val = false }, data: { key = '' , val = false },
schoolName,
isClick = true, isClick = true,
name, name,
value, value,
...@@ -302,25 +309,21 @@ const StudentSelect = (props) => { ...@@ -302,25 +309,21 @@ const StudentSelect = (props) => {
val && val &&
<ul className="student-select__list"> <ul className="student-select__list">
{ {
options.length > 0 options.length > 0 && options.map((item, index) => (
? (<>
{
options.map((item, index) => (
<li <li
className="student-select__option" className="student-select__option"
key={index} key={index}
onClick={() => { onClick={() => {
selectSwitch(key, false); selectSwitch(key, false);
onChange(name, item); onChange(name, item);
typeof clearToCollege === 'function' && clearToCollege(); if(schoolName !== item && typeof clearToCollege === 'function') {
changeToCollege(item); clearToCollege();
}
typeof changeToCollege === 'function' && changeToCollege(item);
}} }}
>{item}</li> >{item}</li>
)) ))
} }
</>)
: <li className="student-select__option">暂无数据</li>
}
</ul> </ul>
} }
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment