dev_sync_trustie
杨树林 5 years ago
parent c16c96e348
commit aab802807e

@ -5,11 +5,28 @@ import competition from './comcss/competition.css';
class CompetitionMaxImg extends React.Component {
constructor(props) {
super(props)
this.state = {
GetenrollmentAPI: undefined
}
}
componentDidMount() {
}
componentDidUpdate = (prevProps) => {
if (prevProps.GetenrollmentAPI != this.props.GetenrollmentAPI) {
// console.log("团队竞赛报名大图componentDidUpdate");
// console.log(this.props);
// console.log(this.props.GetenrollmentAPI);
this.setState({
GetenrollmentAPI: this.props.GetenrollmentAPI,
})
}
}
render() {
let {type, pint} = this.props
let {type, pint} = this.props;
return (
<div>
{

@ -20,6 +20,13 @@ import PersonModal from './competmodal/PersonModal';
import PersonalModalteam from './competmodal/PersonalModalteam';
// 团队竞赛报名无报名
class Registration extends React.Component {
/***
*"personal": false, // 是否为个人赛
*"enroll_ended": false, // 报名是否截止
*"enrolled: false, // 是否已经报名
*"teacher_staff": { // 为空表示不支持老师报名
*"member_staff": { // 为空表示不支持学生报名
* **/
constructor(props) {
super(props)
this.state = {
@ -36,16 +43,46 @@ class Registration extends React.Component {
per_page: 20,
data: [],
count: 0,
GetenrollmentAPI: undefined,
personal: false,
enroll_ended: false,
enrolled: false,
teacher_staff: null,
member_staff: null
}
}
componentDidMount() {
// console.log("componentDidMount ");
// console.log("调用子组件 ");
// console.log(this.props);
// console.log(this.props.isAdmin())
// //console.log("componentDidMount ");
// //console.log("调用子组件 ");
// //console.log(this.props);
// //console.log(this.props.isAdmin())
const {keyword, page, per_page} = this.state;
this.Getdata(keyword, page, per_page);
this.GetenrollmentAPI();
}
//获取报名配置API
GetenrollmentAPI = () => {
const url = `/competitions/${"gcc-course-2019"}/competition_staff.json`;
axios.get((url)).then((result) => {
if (result) {
if (result.data) {
//console.log("获取报名配置API");
//console.log(result);
this.setState({
GetenrollmentAPI: result.data,
personal: result.data.personal,
enroll_ended: result.data.enroll_ended,
enrolled: result.data.enrolled,
teacher_staff: result.data.teacher_staff,
member_staff: result.data.member_staff,
})
}
}
}).catch((error) => {
//console.log(error);
})
}
Getdata = (keyword, page, per_page) => {
@ -61,7 +98,7 @@ class Registration extends React.Component {
axios.get((url), {params: datas}).then((result) => {
if (result) {
if (result.data) {
console.log(result);
//console.log(result);
if (result.data.count === 0) {
this.setState({
type: 1,
@ -78,7 +115,7 @@ class Registration extends React.Component {
}
}).catch((error) => {
console.log(error);
//console.log(error);
})
}
paginationonChangestwo = (pageNumber) => {
@ -100,9 +137,36 @@ class Registration extends React.Component {
* 创建战队
**/
Createateam = () => {
this.setState({
tmodalsType: true
})
if (this.state.enrolled === true) {
//已经报名
return;
}
if (this.state.enroll_ended === true) {
//报名截止
return
}
if (this.props.isAdmin() === true) {
//老师
if (this.state.teacher_staff === null) {
//禁止老师
return;
}
this.setState({
tmodalsType: true
})
} else {
//学生
if (this.state.member_staff === null) {
//禁止学生
return;
}
this.setState({
tmodalsType: true
})
}
}
@ -144,6 +208,7 @@ class Registration extends React.Component {
const listItems = test.map((item, index) =>
<RegisListviewdata></RegisListviewdata>
);
return (
<div className="newMain clearfix ">
@ -174,6 +239,7 @@ class Registration extends React.Component {
</div>
{/*大图*/}
<CompetitionMaxImg type={type} Jointheteam={() => this.Jointheteam()}
{...this.props} {...this.state}
Createateam={() => this.Createateam()}></CompetitionMaxImg>
{/*大图结尾*/}
{/*没数据*/}

@ -12,6 +12,14 @@ const {Search} = Input;
//创建战队
class PersonModal extends Component {
//导师是搜索 和学生搜索都会添加到下面框中
/**
* mydatas最下面列表显示的参数
* booltech 控制老师是否重复添加的参数
* myuser 创建者的信息
* teacher_idss 老师数组
* member_ids 学生数组
* polls_nametest 战队名字
* **/
constructor(props) {
super(props);
@ -37,15 +45,91 @@ class PersonModal extends Component {
name: "",
teacher_idss: [],
member_ids: [],
myuser: undefined,
mydatas: [],
booltech: false,
boolstud: false,
polls_nametest: "",
myteaherdata: [],
myshtudentdata: [],
}
}
componentDidMount() {
}
componentDidUpdate = (prevProps) => {
if (prevProps.user != this.props.user) {
//console.log("Registration.js componentDidUpdate");
//console.log(this.props);
//console.log(prevProps);
//identity职场称
//user_school学校
//real_name姓名
//type 类型
var data = [];
var datas = {
enrollable: false,
id: undefined,
name: this.props.user.real_name,
school_name: this.props.user.user_school,
student_id: null,
identity: this.props.user.user_identity,
type: "创建者",
};
data.push(datas);
this.setState({
myuser: this.props.user,
mydatas: data,
})
}
};
//创建战队
Createateam = () => {
const {polls_nametest, mydatas} = this.state;
var myteaherdata = [];
var myshtudentdata = [];
for (var a = 0; a < mydatas.length; a++) {
if (mydatas[a].type === "导师") {
var objectt = {
enrollable: mydatas[a].enrollable,
id: mydatas[a].id,
identity: mydatas[a].identity,
name: mydatas[a].name,
school_name: mydatas[a].school_name,
}
myteaherdata.push(objectt);
} else if (mydatas[a].type === "队员") {
var objectts = {
enrollable: mydatas[a].enrollable,
id: mydatas[a].id,
name: mydatas[a].name,
school_name: mydatas[a].school_name,
student_id: mydatas[a].student_id,
}
myshtudentdata.push(objectts);
}
}
let url = `/competitions/${"gcc-course-2019"}/competition_teams.json`;
axios.post(url, {
name: polls_nametest,
teacher_ids: myteaherdata,
member_ids: myshtudentdata,
}).then((result) => {
//console.log("获取到创建战队的数据");
//console.log(result);
if (result) {
if (result.data) {
this.props.Tmoconfirm1(true);
}
}
}).catch((error) => {
//console.log(error)
});
}
creident = (name, teacher_ids, member_ids) => {
let collaborators = `/competitions/${"gcc-course-2019"}/competition_teams.json`;
axios.post(collaborators, {
@ -60,18 +144,19 @@ class PersonModal extends Component {
}
}
}).catch((error) => {
console.log(error)
//console.log(error)
});
}
Getteacherdata = (keywordteachers, team_idteachers, teacher_ids) => {
this.setState({
person1: true,
person2: false,
})
//老师姓名 keyword
//当前战队ID team_id
//当前老师ID数组 teacher_ids
console.log("搜索的老师");
//console.log("搜索的老师");
const datas = {
keyword: keywordteachers,
team_id: team_idteachers,
@ -81,24 +166,25 @@ class PersonModal extends Component {
axios.get((url), {params: datas}).then((result) => {
if (result) {
if (result.data) {
console.log(result);
//console.log(result);
this.setState({
teacher_ids: result.data.teachers
})
}
}
}).catch((error) => {
console.log(error);
//console.log(error);
})
};
Getstudentsdata = (keywordstudents, team_idstudents, student_ids) => {
this.setState({
person1: false,
person2: true,
})
//学生姓名 keyword
//当前战队ID team_id
//当前队员ID数组 student_ids
console.log("搜索的学生");
//console.log("搜索的学生");
const datas = {
keyword: keywordstudents,
team_id: team_idstudents,
@ -108,7 +194,7 @@ class PersonModal extends Component {
axios.get((url), {params: datas}).then((result) => {
if (result) {
if (result.data) {
console.log(result);
//console.log(result);
this.setState({
member_ids: result.data.teachers
})
@ -116,99 +202,177 @@ class PersonModal extends Component {
}
}
}).catch((error) => {
console.log(error);
//console.log(error);
})
};
//老师输入框事件
teacheronChange = (e) => {
console.log(e.target.value);
console.log("老师输入框事件|||||||||||123123123");
try {
if (e.target.value.length > 0) {
this.setState({
person1: true,
person2: false,
keywordteachers: e.target.value
})
} else {
this.setState({
person1: false,
person2: false,
keywordteachers: e.target.value
})
}
} catch (e) {
this.setState({
person1: true,
person2: false,
keywordteachers: e.target.value
})
}
try {
const {team_idteachers, teacher_ids} = this.state;
this.Getteacherdata(e.target.value, team_idteachers, teacher_ids);
} catch (e) {
}
//console.log(e.target.value);
//console.log("老师输入框事件|||||||||||123123123");
this.setState({
keywordteachers: e.target.value,
booltech: false
})
// try {
// if (e.target.value.length > 0) {
// this.setState({
// person1: true,
// person2: false,
// keywordteachers: e.target.value
// })
// } else {
// this.setState({
// person1: false,
// person2: false,
// keywordteachers: e.target.value
// })
// }
// } catch (e) {
// this.setState({
// person1: true,
// person2: false,
// keywordteachers: e.target.value
// })
// }
// try {
// const {team_idteachers, teacher_ids} = this.state;
// this.Getteacherdata(e.target.value, team_idteachers, teacher_ids);
// } catch (e) {
//
// }
};
//学生输入框事件
studentsonChange = (e) => {
console.log("学生输入框事件");
console.log(e);
try {
if (e.target.value.length > 0) {
this.setState({
person2: true,
person1: false,
keywordstudents: e.target.value
});
} else {
this.setState({
person2: false,
person1: false,
keywordstudents: e.target.value
});
//console.log("学生输入框事件");
//console.log(e);
this.setState({
keywordstudents: e.target.value,
boolstud: false,
});
// try {
// if (e.target.value.length > 0) {
// this.setState({
// person2: true,
// person1: false,
// keywordstudents: e.target.value
// });
// } else {
// this.setState({
// person2: false,
// person1: false,
// keywordstudents: e.target.value
// });
// }
// } catch (e) {
// this.setState({
// person2: true,
// person1: false,
// keywordstudents: e.target.value
// });
// }
// try {
// const {team_idstudents, student_ids} = this.state;
// this.Getstudentsdata(e.target.value, team_idstudents, student_ids);
// } catch (e) {
//
// }
}
//点击获取老师数据
getdatacpersondiv1Items = (object) => {
var datas = {
enrollable: object.enrollable,
id: object.id,
name: object.name,
school_name: object.school_name,
student_id: null,
identity: object.identity,
type: "导师",
};
var fordabool = false;
var forda = this.state.mydatas;
//console.log("点击获取老师数据");
//console.log(object);
//console.log(forda);
for (var i = 0; i < forda.length; i++) {
if (forda[i].id) {
if (forda[i].id === object.id) {
fordabool = true;
break
}
}
} catch (e) {
}
if (fordabool) {
this.setState({
person2: true,
person1: false,
keywordstudents: e.target.value
});
}
try {
const {team_idstudents, student_ids} = this.state;
this.Getstudentsdata(e.target.value, team_idstudents, student_ids);
} catch (e) {
keywordteachers: object.name,
booltech: true,
})
} else {
forda.push(datas);
this.setState({
person1: false,
keywordteachers: object.name,
mydatas: forda,
booltech: false,
})
}
}
//点击获取老师数据
getdatacpersondiv1Items = (object) => {
console.log("点击获取老师数据");
console.log(object);
this.setState({
person1: false,
keywordteachers: object.name
})
}
//点击获取学生数据2
getdatacpersondiv1Items2 = (object) => {
console.log("点击获取学生数据2");
console.log(object);
this.setState({
person2: false,
keywordstudents: object.name
})
var datas = {
enrollable: object.enrollable,
id: object.id,
name: object.name,
school_name: object.school_name,
student_id: object.student_id,
identity: "学生",
type: "队员",
};
var fordabool = false;
var forda = this.state.mydatas;
//console.log("点击获取学生数据2");
//console.log(object);
//console.log(forda);
for (var i = 0; i < forda.length; i++) {
if (forda[i].id) {
// //console.log(true);
// //console.log(forda[i].id);
// //console.log(object.id);
if (forda[i].id === object.id) {
fordabool = true;
break
}
}
}
if (fordabool) {
this.setState({
person2: false,
keywordstudents: object.name,
boolstud: true
})
} else {
forda.push(datas);
this.setState({
person2: false,
keywordstudents: object.name,
mydatas: forda,
boolstud: false
})
}
}
//输入框事件
changeTopicName = (e) => {
// console.log("调用了changeTopicName");
// //console.log("调用了changeTopicName");
let num = parseInt(e.target.value.length);
if (num > 60) {
return;
@ -223,86 +387,94 @@ class PersonModal extends Component {
//onSearchsou
onSearch = (value) => {
console.log("搜索的数据" + value);
//console.log("搜索的数据" + value);
};
handleInfiniteOnLoad = () => {
this.setState({
loading: true,
})
const test3 = this.state.test;
this.state.test2.forEach(function (item) {
test3.push(item)
});
setTimeout(() => {
this.setState({
test: test3,
hasMore: true,
loading: false,
});
}, 1000)
// this.setState({
// loading: true,
// })
// const test3 = this.state.test;
// this.state.test2.forEach(function (item) {
// test3.push(item)
// });
// setTimeout(() => {
// this.setState({
// test: test3,
// hasMore: true,
// loading: false,
// });
// }, 1000)
}
handleInfiniteOnLoad1 = () => {
console.log("调用了方法1111");
this.setState({
loading1: true,
})
setTimeout(() => {
console.log("调用了方法11112");
this.setState({
loading1: false,
hasMore: true,
});
}, 1000)
// //console.log("调用了方法1111");
// this.setState({
// loading1: true,
// })
// setTimeout(() => {
// //console.log("调用了方法11112");
// this.setState({
// loading1: false,
// hasMore: true,
// });
// }, 1000)
}
handleInfiniteOnLoad2 = () => {
console.log("调用了方法1111");
this.setState({
loading2: true,
})
setTimeout(() => {
console.log("调用了方法11113");
this.setState({
hasMore: true,
loading2: false,
});
}, 1000)
// //console.log("调用了方法1111");
// this.setState({
// loading2: true,
//
// })
// setTimeout(() => {
// //console.log("调用了方法11113");
// this.setState({
// hasMore: true,
// loading2: false,
// });
// }, 1000)
}
inputOnBlur = (e) => {
console.log("inputOnBlur");
console.log(e);
//console.log("inputOnBlur");
//console.log(e);
this.setState({
person1: false
})
}
inputOnBlur2 = (e) => {
console.log("inputOnBlur");
console.log(e);
//console.log("inputOnBlur");
//console.log(e);
this.setState({
person2: false
})
}
startSearch = (e) => {
console.log("startSearch");
console.log(e);
//console.log("startSearch");
//console.log(e);
this.setState({
person1: true,
person2: false,
})
const {keywordteachers, team_idteachers, teacher_ids} = this.state;
this.Getteacherdata(keywordteachers, team_idteachers, teacher_ids);
}
startSearch2 = (e) => {
console.log("startSearch2");
console.log(e);
//console.log("startSearch2");
//console.log(e);
this.setState({
person1: false,
person2: true,
})
const {keywordstudents, team_idstudents, student_ids} = this.state;
this.Getstudentsdata(keywordstudents, team_idstudents, student_ids);
}
inputOnFocus = (e) => {
console.log("inputOnFocus");
console.log(e);
//console.log("inputOnFocus");
//console.log(e);
try {
if (this.state.keywordteachers && this.state.keywordteachers.length > 0) {
this.setState({
@ -326,8 +498,8 @@ class PersonModal extends Component {
}
inputOnFocus2 = (e) => {
console.log("inputOnFocus2");
console.log(e);
//console.log("inputOnFocus2");
//console.log(e);
try {
if (this.state.keywordstudents && this.state.keywordstudents.length > 0) {
this.setState({
@ -352,8 +524,8 @@ class PersonModal extends Component {
}
inputOnFocus3 = (e) => {
console.log("inputOnFocus3");
console.log(e);
//console.log("inputOnFocus3");
//console.log(e);
this.setState({
person2: false,
person1: false,
@ -365,7 +537,7 @@ class PersonModal extends Component {
addonAfter, test, test3, Numberofteammentors, Thecurrentnumber, person1, person2,
keywordteachers, team_idteachers, teacher_ids,
keywordstudents, team_idstudents, student_ids,
member_ids
member_ids, mydatas, booltech, boolstud
} = this.state;
//Modal
//keyboard是否支持键盘 esc 关闭
@ -374,7 +546,7 @@ class PersonModal extends Component {
//destroyOnClose 关闭时销毁 Modal 里的子元素
//centered 垂直居中展示 Modal
//visible 弹出框是否显示
const listItems = test.map((item, index) =>
const listItems = mydatas.map((item, index) =>
<div className="reglistviewdivss2 " style={{
width: "100%",
display: "flex",
@ -386,27 +558,27 @@ class PersonModal extends Component {
style={{
textAlign: "center",
}}
>陈明</p>
>{item.name === undefined || item.name === null || item.name === "" ? "--" : item.name}</p>
<p className=" reglistviewdivss4p"
style={{
textAlign: "center",
}}
>导师创建者</p>
>{item.type === undefined || item.type === null || item.type === "" ? "--" : item.type}</p>
<p className=" reglistviewdivss5p"
style={{
textAlign: "center",
}}
>国防科技大学</p>
>{item.school_name === undefined || item.school_name === null || item.school_name === "" ? "--" : item.school_name}</p>
<p className=" reglistviewdivss2p"
style={{
textAlign: "center",
}}
>职称教授</p>
>{item.identity === undefined || item.identity === null || item.identity === "" ? "--" : item.identity}</p>
<p className=" reglistviewdivss33p"
style={{
textAlign: "center",
}}
><i className="iconfont icon-guanbi font-12"/></p>
>{item.type && item.type === "创建者" ? "" : <i className="iconfont icon-guanbi font-12"/>}</p>
</div>
);
var cpersondiv1Items = [];
@ -494,7 +666,7 @@ class PersonModal extends Component {
<p className=" cpersondiv1Items"
style={{
textAlign: "center",
width: "90px"
width: "85px"
}}
>{item.identity === undefined || item.identity === null || item.identity === "" ? "--" : item.identity}</p>
<p className=" cpersondiv1Items"
@ -668,12 +840,19 @@ class PersonModal extends Component {
</Dropdown>
{/*</div>*/}
</div>
{
booltech === true ?
<p style={{marginLeft: "53px", color: "#FF954C", minHeight: "14px"}}>该老师已添加</p>
:
<div style={{marginLeft: "53px", minHeight: "14px", height: "14px"}}></div>
}
{/*队员*/}
<div style={{
display: "flex",
flexDirection: "initial",
marginTop: "14px",
}}>
<p style={{
width: "59px",
@ -720,9 +899,14 @@ class PersonModal extends Component {
</div>
{
boolstud === true ?
<p style={{marginLeft: "53px", color: "#FF954C", minHeight: "18px"}}>该队员已添加</p>
:
<div style={{marginLeft: "53px", minHeight: "18px", height: "18px"}}></div>
}
{/*表格*/}
<div style={{marginTop: "18px", marginLeft: "53px", border: "1px solid #E0E0E0"}}>
<div style={{marginLeft: "53px", border: "1px solid #E0E0E0"}}>
{/*<PersonModaltion ></PersonModaltion>*/}
<div>
<div className="reglistviewdivss2 " style={{
@ -763,14 +947,15 @@ class PersonModal extends Component {
>操作</p>
</div>
</div>
<Spin spinning={this.state.loading}>
<Spin spinning={false}>
<div className="demo-infinite-container">
<InfiniteScroll
initialLoad={false}
pageStart={0}
loadMore={() => this.handleInfiniteOnLoad()}
hasMore={!this.state.loading && this.state.hasMore}
// hasMore={!this.state.loading && this.state.hasMore}
hasMore={false}
useWindow={false}
>
{listItems}
@ -803,7 +988,7 @@ class PersonModal extends Component {
<p onClick={() => this.props.Tmoconfirm1(false)}> 取消</p>
</div>
<div className="personbut2">
<p onClick={() => this.props.Tmoconfirm1(true)}>确定</p>
<p onClick={() => this.Createateam()}>确定</p>
</div>
</div>
</div>

Loading…
Cancel
Save