提交 5bc0d055 authored 作者: 钟是志's avatar 钟是志

Merge remote-tracking branch 'origin/master'

...@@ -12,16 +12,15 @@ const queryOptions = async() => { ...@@ -12,16 +12,15 @@ const queryOptions = async() => {
gradeList, gradeList,
institutionList, institutionList,
} }
}; }
export default class Filter extends React.Component{ export default class Filter extends React.Component{
stattic
constructor(props){ constructor(props){
super(props); super(props);
this.state ={ this.state ={
inputValue:'',
formValues: { formValues: {
gradeId: "",
}, },
options: { options: {
gradeList:[], gradeList:[],
...@@ -40,12 +39,9 @@ export default class Filter extends React.Component{ ...@@ -40,12 +39,9 @@ export default class Filter extends React.Component{
const res = await queryOptions(); const res = await queryOptions();
if(!res || !res.gradeList || !res.institutionList) return false; if(!res || !res.gradeList || !res.institutionList) return false;
const gradeList = res.gradeList.map(i=> ({key: i.remark,value: i.id})); const gradeList = res.gradeList.map(i=> ({key: i.name,value: i.id}));
const institutionList = res.institutionList.map(i=> ({key: i.fullName,value: i.id})); const institutionList = res.institutionList.map(i=> ({key: i.fullName,value: i.id}));
this.setState({ this.setState({
formValues:{
gradeId: gradeList[0].value
},
options: { options: {
gradeList, gradeList,
institutionList, institutionList,
...@@ -84,16 +80,22 @@ export default class Filter extends React.Component{ ...@@ -84,16 +80,22 @@ export default class Filter extends React.Component{
formChange = (key,value) => { formChange = (key,value) => {
const { formValues } = this.state; const { formValues } = this.state;
formValues[key] = value; formValues[key] = value;
if(key === 'gradeId') {
delete formValues.institutionId;
delete formValues.majorId;
delete formValues.clazzId;
}
if(key === 'institutionId') { if(key === 'institutionId') {
this.fetchMajorList({institutionId:value}); this.fetchMajorList({institutionId:value});
delete formValues.majorId delete formValues.majorId;
delete formValues.clazzId delete formValues.clazzId;
} }
if(key === 'majorId') { if(key === 'majorId') {
this.fetchClazzList({institutionId: formValues.institutionId, majorId: value,gradeId: formValues.gradeId}); this.fetchClazzList({institutionId: formValues.institutionId, majorId: value,gradeId: formValues.gradeId});
delete formValues.clazzId delete formValues.clazzId;
} }
this.setState({ this.setState({
...@@ -103,8 +105,7 @@ export default class Filter extends React.Component{ ...@@ -103,8 +105,7 @@ export default class Filter extends React.Component{
inputChange = (e) => { inputChange = (e) => {
const { formValues } = this.state; const { formValues } = this.state;
var value = Number(e.targetValue); var value = Number(e.target.value);
if(isNaN(value)){ if(isNaN(value)){
formValues.name = e.target.value; formValues.name = e.target.value;
if(formValues.studentNo) delete formVlaues.studentNo; if(formValues.studentNo) delete formVlaues.studentNo;
...@@ -115,7 +116,8 @@ export default class Filter extends React.Component{ ...@@ -115,7 +116,8 @@ export default class Filter extends React.Component{
} }
this.setState({ this.setState({
formValues formValues,
inputValue: e.target.value,
}) })
} }
...@@ -135,37 +137,36 @@ export default class Filter extends React.Component{ ...@@ -135,37 +137,36 @@ export default class Filter extends React.Component{
search = () =>{ search = () =>{
const { formValues } = this.state; const { formValues } = this.state;
this.props.getPage(formValues); this.props.getPage(formValues);
this.props.Toggle() && this.props.Toggle(); this.props.Toggle && this.props.Toggle();
} }
reset =() => { reset =() => {
this.setState({ this.setState({
formValues: {gradeId: this.state.options.gradeList[0].value} formValues: {}
}) })
} }
render(){ render(){
const { gradeList, institutionList, majorList, clazzList } = this.state.options; const { gradeList, institutionList, majorList, clazzList } = this.state.options;
const { institutionId , majorId } = this.state.formValues; const { gradeId, institutionId , majorId } = this.state.formValues;
const { style } = this.props;
return ( return (
<div className='siderBar' style={style ? style : null}> <div className='siderBar'>
<div className='searchBox'> <div className='searchBox'>
<input type='text' <input type='text'
ref={node => this.input = node} ref={node => this.input = node}
id='searchInput' id='searchInput'
placeholder='请输入姓名/学号' placeholder='请输入姓名/学号'
value={this.state.inputValue} value={this.state.inputValue}
onChange={this.inputChange}></input> onChange={this.inputChange} />
<div id="searchButton" onClick={this.search}><Icon type='search' size='sm'/></div> <div id="searchButton" onClick={this.search}><Icon type='search' size='sm'/></div>
</div> </div>
<div className='mainContent'> <div className='mainContent'>
<WhiteSpace size='lg'/> <WhiteSpace size='lg'/>
<WingBlank size='lg'> <WingBlank size='lg'>
<p style={{color: '#666666'}}>选择</p> <p style={{color: '#666666'}}>选择</p>
{this.generateItem('gradeId',gradeList)} {this.generateItem('gradeId',gradeList)}
<p style={{color: '#666666'}}>学院选择</p> { gradeId ? (<><p style={{color: '#666666'}}>学院选择</p>
{this.generateItem('institutionId',institutionList)} {this.generateItem('institutionId',institutionList)}</>) : null}
{ institutionId ? (<><p style={{color: '#666666'}}>专业选择</p> { institutionId ? (<><p style={{color: '#666666'}}>专业选择</p>
{this.generateItem('majorId',majorList)}</>) : null} {this.generateItem('majorId',majorList)}</>) : null}
{ majorId ? <><p style={{color: '#666666'}}>班级选择</p> { majorId ? <><p style={{color: '#666666'}}>班级选择</p>
...@@ -184,8 +185,7 @@ export default class Filter extends React.Component{ ...@@ -184,8 +185,7 @@ export default class Filter extends React.Component{
Filter.propTypes = { Filter.propTypes = {
getPage: PropTypes.func.isRequired, // 页面刷新方法 getPage: PropTypes.func.isRequired, // 页面刷新方法
toggle: PropTypes.func, // 收回侧边方法 toggle: PropTypes.func, // 收回侧边方法
style: PropTypes.object, // 外框样式
} }
Filter.defaultProps = { Filter.defaultProps = {
getPage: () => {} getPage: () => {}
} }
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论