{text}
@@ -200,6 +213,7 @@ class studentsList extends Component{
this.state={
headIndex:"1",
page:1,
+ sortedInfo: { columnKey: 'role', order: 'ascend'},
totalPage:undefined,
searchValue:"",
order: ORDER_BY_DATE,
@@ -209,7 +223,8 @@ class studentsList extends Component{
checkBoxValues: [],
isSpin:false,
application_list: [],
- checkAllArray: []
+ checkAllArray: [],
+ filterKey: 1, // 1 已审批 2 待审批
}
}
onCheckAllChange = (e, item, index) => {
@@ -339,7 +354,7 @@ class studentsList extends Component{
console.log(error);
});
}
- fetchAll=(argPage)=>{
+ fetchAll = (argPage) => {
this.setState({
isSpin:true
})
@@ -347,9 +362,28 @@ class studentsList extends Component{
if (argPage) {
this.setState({ page: argPage })
}
+
+ const sortedInfo = this.state.sortedInfo;
let page = argPage || this.state.page
- let { order, searchValue }=this.state
- let url=`/courses/${id}/teachers.json?order=${order}&page=${page}`;
+ let { searchValue, filterKey }=this.state
+ let order = 1;
+ if (sortedInfo.columnKey == 'role') {
+ order = 1;
+ } else if (sortedInfo.columnKey == 'name') {
+ order = 2;
+ } else if (sortedInfo.columnKey == 'graduation_group') {
+ order = 3;
+ }
+ let sort = 'desc'
+ if (sortedInfo.order == 'ascend') {
+ sort = 'asc'
+ }
+ let url=`/courses/${id}/teachers.json?order=${order}&page=${page}&sort=${sort}`;
+ if (filterKey == '1') {
+
+ } else if (filterKey == '2') {
+ url = `/courses/${id}/apply_teachers.json?_a=1`
+ }
if(searchValue!=""){
url+='&search='+searchValue;
}
@@ -358,8 +392,17 @@ class studentsList extends Component{
this.setState({
teachers: result.data.teacher_list,
total_count: result.data.teacher_list_size,
- application_list: result.data.application_list,
+ // application_list: result.data.application_list || [],
+ is_admin: result.data.is_admin,
+ apply_size: result.data.apply_size,
+ isSpin:false
+ })
+ } else if (result.data.application_list) {
+ this.setState({
+ total_count: result.data.teacher_list_size,
+ application_list: result.data.application_list || [],
is_admin: result.data.is_admin,
+ apply_size: result.data.apply_size,
isSpin:false
})
}
@@ -529,13 +572,33 @@ class studentsList extends Component{
})
return result && result.length > 0
}
-
+ onTableChange = (pagination, filters, sorter) => {
+ console.log('Various parameters', pagination, filters, sorter);
+ this.setState({
+ sortedInfo: sorter,
+ }, () => {
+ this.fetchAll()
+ });
+ };
+ clearSelection = () => {
+ this.setState({ checkBoxValues: [] })
+ }
+ selectedStatus=(e)=>{
+ this.clearSelection()
+ this.setState({
+ filterKey: e.key,
+ page:1,
+ isSpin:true
+ }, () => {
+ this.fetchAll();
+ })
+ }
render(){
const isAdmin = this.props.isAdmin()
const columns = buildColumns(this)
let {
searchValue, checkBoxValues, checkAllValue,
- groupList, total_count, teachers, order, page
+ groupList, total_count, teachers, order, page, apply_size, filterKey
}=this.state
let currentOrderName = '加入时间排序'
@@ -544,12 +607,13 @@ class studentsList extends Component{
} else if (order == ORDER_BY_GRADUATION_GROUP) {
currentOrderName = '答辩组排序'
}
- const combineArray = teachers.slice(0)
- if (page == 1) {
- this.state.application_list && this.state.application_list.slice(0).reverse().forEach(item => {
- item.isApply = true
- combineArray.unshift(item)
- })
+ let combineArray = teachers.slice(0)
+ if (page == 1 && filterKey == '2') {
+ // this.state.application_list && this.state.application_list.slice(0).reverse().forEach(item => {
+ // item.isApply = true
+ // combineArray.unshift(item)
+ // })
+ combineArray = this.state.application_list
}
const isAdminOrTeacher = this.props.isAdminOrTeacher()
const hasGraduationModule = this.hasGraduationModule()
@@ -585,12 +649,25 @@ class studentsList extends Component{
}
secondRowLeft={
- total_count ? : ''
+ isAdminOrTeacher ?
+
+ :
+ (total_count ? : '')
}
onPressEnter={this.onPressEnter}
>