diff --git a/public/react/src/modules/competition/Registration.js b/public/react/src/modules/competition/Registration.js index a4c557573..0e4bd62d3 100644 --- a/public/react/src/modules/competition/Registration.js +++ b/public/react/src/modules/competition/Registration.js @@ -123,19 +123,23 @@ class Registration extends React.Component { if (result) { if (result.data) { //// //console.log(result); - if (result.data.count === 0) { + if (result.data.my_teams.length === 0) { // 没有创建数据的 if (admin === true) { //管理员 this.setState({ type: 4, count: result.data.count, + data: result.data.my_teams, + competition_teams: result.data.competition_teams }) } else { //普通账号 this.setState({ type: 1, count: result.data.count, + data: result.data.my_teams, + competition_teams: result.data.competition_teams }) } } else { @@ -186,16 +190,86 @@ class Registration extends React.Component { this.setState({ type: 4, count: 0, + competition_teams: [], + data: [], }) } else { //普通账号 this.setState({ type: 1, count: 0, + competition_teams: [], + data: [], + }) + } + }) + } + + Getdatatype5 = (keyword, page, per_page, admin) => { + //搜索关键字 keyword + //页数 page + //分页 per_page + const datas = { + keyword: keyword, + page: page, + per_page: per_page, + }; + let url = `/competitions/${"gcc-course-2019"}/competition_teams.json`; + axios.get((url), {params: datas}).then((result) => { + if (result) { + if (result.data) { + //// //console.log(result); + if (result.data.my_teams.length === 0) { + // 没有创建数据的 + //管理员 + this.setState({ + type: 4, + count: result.data.count, + competition_teams: result.data.competition_teams, + data: result.data.my_teams, + }) + } else { + //有数据的 + if (result.data.my_teams[0].manage_permission === true) { + this.setState({ + type: 5, + data: result.data.my_teams, + count: result.data.count, + competition_teams: result.data.competition_teams + + }) + } else { + this.setState({ + type: 4, + data: result.data.my_teams, + count: result.data.count, + competition_teams: result.data.competition_teams + }) + } + } + } + } + }).catch((error) => { + if (admin === true) { + //管理员 + this.setState({ + count: 0, + competition_teams: [], + data: [], + }) + } else { + //普通账号 + this.setState({ + count: 0, + competition_teams: [], + data: [], }) } }) } + + + paginationonChangestwo = (pageNumber) => { this.setState({ pages: pageNumber, @@ -394,7 +468,16 @@ class Registration extends React.Component { }) } } - + //搜索战队 + RegistrationSearchvalue = (value) => { + console.log("RegistrationSearchvalue"); + console.log(this.props.user.admin); + this.setState({ + pages: 1, + limit: 20, + }) + this.Getdata(value, 1, 20, this.props.user.admin); + } render() { const {test, page, pages, limit, type, tmodalsType, tmodalsTypes, data, count, competition_teams} = this.state; var listItems = ""; @@ -459,7 +542,8 @@ class Registration extends React.Component { { type === 4 || type === 5 ? - + this.RegistrationSearchvalue(value)}> : "" } {/**/} diff --git a/public/react/src/modules/competition/RegistrationSearch.js b/public/react/src/modules/competition/RegistrationSearch.js index 79f820f9d..28fdd2b9d 100644 --- a/public/react/src/modules/competition/RegistrationSearch.js +++ b/public/react/src/modules/competition/RegistrationSearch.js @@ -24,15 +24,22 @@ class RegistrationSearch extends React.Component { this.setState({ keywords: e.target.value }) + }; setdatafuns = (value) => { - //console.log("点击了搜索"); + console.log("setdatafuns点击了搜索"); + console.log(value); this.setState({ keywords: value }) - + this.props.RegistrationSearchvalue(value); }; + myonPressEnter = (e) => { + console.log("点击了回车setdatafunsval点击了搜索"); + console.log(e.target.value); + this.props.RegistrationSearchvalue(e.target.value); + } render() { return (
@@ -42,7 +49,9 @@ class RegistrationSearch extends React.Component { value={this.state.keywords} enterButton={搜索} onInput={(e) => this.setdatafunsval(e)} - onSearch={(value) => this.setdatafuns(value)}/> + onSearch={(value) => this.setdatafuns(value)} + onPressEnter={(e) => this.myonPressEnter(e)} + />

战队总数:{this.props.count}