From 3ac4b9d0a40c1c81d6c18f8b96e076e38a9b5ca7 Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Sat, 22 Jun 2019 15:11:10 +0800 Subject: [PATCH 1/4] isAdminOrTeacher --- public/react/src/modules/courses/members/teacherList.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/public/react/src/modules/courses/members/teacherList.js b/public/react/src/modules/courses/members/teacherList.js index 509bf56c1..478a94ec2 100644 --- a/public/react/src/modules/courses/members/teacherList.js +++ b/public/react/src/modules/courses/members/teacherList.js @@ -28,6 +28,7 @@ const pageSize = 20; function buildColumns(that) { const isAdmin = that.props.isAdmin() const isAdminOrCreator = that.props.isAdminOrCreator(); + const isAdminOrTeacher = that.props.isAdminOrTeacher() const { course_groups } = that.state const columns = [{ title: '', @@ -121,7 +122,7 @@ function buildColumns(that) { ), }) } - if (isAdminOrCreator) { + if (isAdminOrTeacher) { columns.push({ title: '操作', key: 'action', From 8eee96f7c2ed07b82f9346d1bf8205d8785f81b9 Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Sat, 22 Jun 2019 16:13:41 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=88=90=E5=8A=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/courses/members/teacherList.js | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/public/react/src/modules/courses/members/teacherList.js b/public/react/src/modules/courses/members/teacherList.js index 478a94ec2..261bfab85 100644 --- a/public/react/src/modules/courses/members/teacherList.js +++ b/public/react/src/modules/courses/members/teacherList.js @@ -5,6 +5,7 @@ import CourseLayoutcomponent from '../common/CourseLayoutComponent' import Titlesearchsection from '../common/titleSearch/TitleSearchSection' import ColorCountText from '../common/titleSearch/ColorCountText' +import update from 'immutability-helper' import { WordsBtn, ConditionToolTip, on, off } from 'educoder' import axios from 'axios' @@ -71,7 +72,7 @@ function buildColumns(that) { const noGroups = (!course_groups || course_groups.length == 0); return ( - + { arg_course_groups.length == 0 ? '不限' : arg_course_groups.map(item => item.name).join(', ') } { isAdmin && @@ -84,7 +85,7 @@ function buildColumns(that) {

): '' } - that.joinCourseGroup(checkedValues, item)} + that.joinCourseGroup(checkedValues, item, index)} value={arg_course_groups.map(item => item.id)} disabled={!isAdminOrCreator} > @@ -137,11 +138,12 @@ function buildColumns(that) { } else { return ( - that.onDelete(record)} style={'grey'}>删除 - + {record.role != ROLE_ADMIN && that.onDelete(record)} style={'grey'}>删除} + {(record.role == ROLE_TEACHER || record.role == ROLE_TEACHER_ASSISTANT || isAdminOrCreator) && record.role != ROLE_ADMIN + && } { record.role == ROLE_TEACHER ? that.changeToAssistant(record)}>变更为助教 : '' } { record.role == ROLE_TEACHER_ASSISTANT ? that.changeToTeacher(record)}>变更为教师 : '' } - { record.role == ROLE_ADMIN ? that.showChangeAdminModal(record)}>更换管理员 : '' } + { record.role == ROLE_ADMIN && isAdminOrCreator ? that.showChangeAdminModal(record)}>更换管理员 : '' } ) } @@ -238,8 +240,13 @@ class studentsList extends Component{ }) .then((response) => { if (response.data.course_groups && response.data.course_groups.length) { + let course_groups_map = {} + response.data.course_groups.forEach(item => { + course_groups_map[item.id] = item.name + }) this.setState({ course_groups: response.data.course_groups, + course_groups_map }) } else { } @@ -248,7 +255,7 @@ class studentsList extends Component{ console.log(error); }); } - joinCourseGroup = (ids, item) => { + joinCourseGroup = (ids, item, index) => { console.log('join ', ids, item) const courseId = this.props.match.params.coursesId @@ -263,7 +270,12 @@ class studentsList extends Component{ .then((response) => { if (response.data.status == 0) { this.props.showNotification('修改成功') - this.fetchAll() + const newArray = ids.map((item) => {return {id: item, name: this.state.course_groups_map[item]}}); + this.setState( + (prevState) => ({ + teachers : update(prevState.teachers, {[ this.state.page == 1 ? index - this.state.application_list.length : index]: { course_groups: {$set: newArray }}}) + })) + // this.fetchAll() } else { } }) From 71ccf425b68d776e2e5134abc64cd1b0b9847ae5 Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Sat, 22 Jun 2019 16:17:31 +0800 Subject: [PATCH 3/4] hasGraduationModule --- public/react/src/modules/courses/members/teacherList.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/react/src/modules/courses/members/teacherList.js b/public/react/src/modules/courses/members/teacherList.js index 261bfab85..4432ecc60 100644 --- a/public/react/src/modules/courses/members/teacherList.js +++ b/public/react/src/modules/courses/members/teacherList.js @@ -573,7 +573,7 @@ class studentsList extends Component{
  • this.onSortTypeChange(ORDER_BY_NAME)} >姓名排序
  • this.onSortTypeChange(ORDER_BY_DATE)} style={{width: '125px'}}>加入时间排序
  • -
  • this.onSortTypeChange(ORDER_BY_GRADUATION_GROUP)} >答辩组排序
  • + {this.hasGraduationModule() &&
  • this.onSortTypeChange(ORDER_BY_GRADUATION_GROUP)} >答辩组排序
  • }
} From 9011592e755394a40605dba1ce6defb7052a8967 Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Sat, 22 Jun 2019 16:22:46 +0800 Subject: [PATCH 4/4] 0 --- public/react/src/modules/courses/members/teacherList.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/public/react/src/modules/courses/members/teacherList.js b/public/react/src/modules/courses/members/teacherList.js index 4432ecc60..ac9d22119 100644 --- a/public/react/src/modules/courses/members/teacherList.js +++ b/public/react/src/modules/courses/members/teacherList.js @@ -57,7 +57,8 @@ function buildColumns(that) { title: '角色', dataIndex: 'role', key: 'role', - }, { + }] + that.course_groups && that.course_groups.length && columns.push({ title: 管理权限, width: 230, key: 'course_groups', @@ -110,7 +111,7 @@ function buildColumns(that) {
) } , - }]; + }); if (that.hasGraduationModule()) { columns.push({ title: '答辩组',