diff --git a/public/react/src/common/course/WordsBtn.js b/public/react/src/common/course/WordsBtn.js index 58b000338..85a85cfb6 100644 --- a/public/react/src/common/course/WordsBtn.js +++ b/public/react/src/common/course/WordsBtn.js @@ -8,15 +8,21 @@ class WordsBtn extends Component { } render() { - let{to, href,targets}=this.props + let{to, href,targets, style2 }=this.props return( { to==undefined&&targets==undefined ? - {this.props.children}: - targets!=undefined? {this.props.children} + {this.props.children}: + targets!=undefined? {this.props.children} : - {this.props.children} + {this.props.children} } ) diff --git a/public/react/src/modules/courses/css/members.css b/public/react/src/modules/courses/css/members.css index 67524d130..ab7effaa0 100644 --- a/public/react/src/modules/courses/css/members.css +++ b/public/react/src/modules/courses/css/members.css @@ -84,4 +84,8 @@ text-overflow:ellipsis; white-space:nowrap; cursor: default; +} + +.changeRolePop .ant-checkbox-group { + width: 230px !important; } \ No newline at end of file diff --git a/public/react/src/modules/courses/members/ChangeRolePop.js b/public/react/src/modules/courses/members/ChangeRolePop.js new file mode 100644 index 000000000..44dfc28fc --- /dev/null +++ b/public/react/src/modules/courses/members/ChangeRolePop.js @@ -0,0 +1,72 @@ +import React, { useState, useEffect } from 'react' +import { trigger, WordsBtn } from 'educoder' +import { Input, Checkbox, Popconfirm } from "antd"; +import axios from 'axios' + +/** + 角色数组, CREATOR: 创建者, PROFESSOR: 教师, ASSISTANT_PROFESSOR: 助教, STUDENT: 学生 +*/ +function ChangeRolePop({ member_roles = [], record, courseId, onChangeRoleSuccess, showNotification }) { + const [checkBoxRoles, setCheckBoxRoles] = useState(member_roles) + useEffect(() => { + setCheckBoxRoles(member_roles) + }, [member_roles]) + function onCheckBoxChange(val) { + console.log(val) + + const isTeacher = checkBoxRoles.indexOf('PROFESSOR') + const isAssitant = checkBoxRoles.indexOf('ASSISTANT_PROFESSOR') + const isTeacherNew = val.indexOf('PROFESSOR') + const isAssitantNew = val.indexOf('ASSISTANT_PROFESSOR') + if (isTeacherNew > -1 && isTeacher == -1 && isAssitantNew > -1) { + val.splice(isAssitantNew, 1) + } + if (isAssitantNew > -1 && isAssitant == -1 && isTeacherNew > -1) { + val.splice(isTeacherNew, 1) + } + + setCheckBoxRoles(val) + } + function onCancel() { + setCheckBoxRoles(member_roles) + } + const onConfirm = async () => { + if (checkBoxRoles && checkBoxRoles.length == 0) { + showNotification('请至少选择一个角色') + return; + } + const url = `/courses/${courseId}/change_member_role.json` + const response = await axios.post(url, { + roles: checkBoxRoles, + user_id: record.user_id + }) + if (response.data.status == 0) { + onChangeRoleSuccess() + } + console.log(response) + } + const isAdmin = checkBoxRoles.indexOf('CREATOR') != -1 + const isTeacher = checkBoxRoles.indexOf('PROFESSOR') != -1 + const isAssitant = checkBoxRoles.indexOf('ASSISTANT_PROFESSOR') != -1 + const isStudent = checkBoxRoles.indexOf('STUDENT') != -1 + return ( + + {isAdmin && 管理员} + {!isAdmin && 教师} + 助教 + 学生 + + } + > + 修改角色 + + ) +} +export default ChangeRolePop \ No newline at end of file diff --git a/public/react/src/modules/courses/members/studentsList.css b/public/react/src/modules/courses/members/studentsList.css new file mode 100644 index 000000000..49a81fa32 --- /dev/null +++ b/public/react/src/modules/courses/members/studentsList.css @@ -0,0 +1,3 @@ +.stu_table .ant-table-thead > tr > th, .stu_table .ant-table-tbody > tr > td { + padding: 14px 8px; +} \ No newline at end of file diff --git a/public/react/src/modules/courses/members/studentsList.js b/public/react/src/modules/courses/members/studentsList.js index 1b0b19d6f..5f614cfbc 100644 --- a/public/react/src/modules/courses/members/studentsList.js +++ b/public/react/src/modules/courses/members/studentsList.js @@ -1,5 +1,5 @@ import React,{ Component } from "react"; -import { Input,Checkbox,Table, Pagination, Modal,Menu ,Spin, Tooltip , Divider } from "antd"; +import { Input,Checkbox,Table, Pagination, Modal,Menu ,Spin, Tooltip , Divider, Popconfirm } from "antd"; import ClipboardJS from 'clipboard' import '../css/Courses.css' import '../css/members.css' @@ -14,6 +14,8 @@ import _ from 'lodash' import NoneData from "../coursesPublic/NoneData" import DownloadMessageysl from "../../modals/DownloadMessageysl"; import CreateGroupByImportModal from './modal/CreateGroupByImportModal' +import ChangeRolePop from './ChangeRolePop' +import "./studentsList.css" const Search =Input.Search; const TYPE_STUDENTS = 1 @@ -22,6 +24,7 @@ const TYPE_COURSE_GOURP_CHILD = 3 const buildColumns = (that,isParent) => { const { course_groups , sortedInfo } = that.state let showSorter = isParent==true + const courseId = that.props.match.params.coursesId const columns=[{ title: '序号', dataIndex: 'id', @@ -32,19 +35,21 @@ const buildColumns = (that,isParent) => { render: (id, student, index) => { return (that.state.page - 1) * 20 + index + 1 } - }, { - title: '用户id', - dataIndex: 'login', - key: 'login', - align:'center', - width:"10%", - className:"color-grey-6", - render: (login, record) => { - return 10 ? login : ''} - >{login} - } - }, { + }, + // { + // title: '用户id', + // dataIndex: 'login', + // key: 'login', + // align:'center', + // width:"10%", + // className:"color-grey-6", + // render: (login, record) => { + // return 10 ? login : ''} + // >{login} + // } + // }, + { title: '姓名', dataIndex: 'name', key: 'name', @@ -69,14 +74,45 @@ const buildColumns = (that,isParent) => { return 10 ? student_id : ''} style={{maxWidth: '160px'}} >{student_id} } - }]; + } + , { + title: '手机号', + dataIndex: 'user_phone', + key: 'user_phone', + align:'center', + width:"10%", + className:"color-grey-6", + // sorter: true, + // sortDirections: sortDirections, + // sortOrder: sortedInfo.columnKey === 'user_phone' && sortedInfo.order, + render: (user_phone, record) => { + return 10 ? user_phone : ''} + style={{maxWidth: '160px'}} >{user_phone} + } + } + , { + title: '邮箱', + dataIndex: 'user_mail', + key: 'user_mail', + align:'center', + width:"10%", + className:"color-grey-6", + // sorter: true, + // sortDirections: sortDirections, + // sortOrder: sortedInfo.columnKey === 'user_mail' && sortedInfo.order, + render: (user_mail, record) => { + return 10 ? user_mail : ''} + style={{maxWidth: '160px'}} >{user_mail} + } + } + ]; if (course_groups && course_groups.length) { columns.push({ title: '分班', dataIndex: 'course_group_name', key: 'course_group_name', align:'center', - width:"40%", + width:"25%", className:"color-grey-6", sorter:showSorter, sortDirections: sortDirections, @@ -95,14 +131,36 @@ const buildColumns = (that,isParent) => { const isAdmin = that.props.isAdmin() if (isAdmin) { columns.unshift({ - title: '', - dataIndex: 'check', - key: 'check', - render: (text, item) => { - return - }, - width:"5%" - }) + title: '', + dataIndex: 'check', + key: 'check', + render: (text, item) => { + return + }, + width:"5%" + }) + + columns.push({ + title: '操作', + key: 'action', + width: '18%', + align:'center', + render: (text, record) => { + return ( + + that.onDelete(record)} style={'grey'}>删除学生 + + + ) + }, + }) + } return columns; @@ -242,7 +300,9 @@ class studentsList extends Component{ onChange=()=>{ } - + onChangeRoleSuccess = () => { + this.fetchAll() + } componentDidMount() { this.setState({ isSpin:true @@ -451,11 +511,13 @@ class studentsList extends Component{ } } // 多选 - onDelete = () => { - const len = this.state.checkBoxValues.length - if (len == 0) { - this.props.showNotification('请先从列表选择要删除的学生') - return; + onDelete = (record) => { + if (!record) { + const len = this.state.checkBoxValues.length + if (len == 0) { + this.props.showNotification('请先从列表选择要删除的学生') + return; + } } this.props.confirm({ @@ -465,7 +527,7 @@ class studentsList extends Component{ let id = this.props.match.params.coursesId let url=`/courses/${id}/delete_from_course.json`; axios.post((url), { - students: this.state.checkBoxValues.map(item => {return {course_member_id: item} }), + students: [{course_member_id: record.user_id}] // this.state.checkBoxValues.map(item => {return {course_member_id: item} }), }).then((result)=>{ if (result.data.status == 0) { this.props.showNotification('删除成功') @@ -701,7 +763,7 @@ class studentsList extends Component{
{isAdmin && 已选 {checkBoxValues.length} 个}
- {isAdmin &&
  • 删除
  • } + {/* {isAdmin &&
  • 删除
  • } */} {isAdmin &&
  • 移动到...
      diff --git a/public/react/src/modules/courses/members/teacherList.js b/public/react/src/modules/courses/members/teacherList.js index 86ae7aa0b..72b667300 100644 --- a/public/react/src/modules/courses/members/teacherList.js +++ b/public/react/src/modules/courses/members/teacherList.js @@ -1,5 +1,5 @@ import React,{ Component } from "react"; -import { Input,Checkbox,Table, Divider, Tooltip,Spin, Menu } from "antd"; +import { Input,Checkbox,Table, Divider, Tooltip,Spin, Menu, Popconfirm } from "antd"; import CourseLayoutcomponent from '../common/CourseLayoutComponent' import NoneData from "../coursesPublic/NoneData" @@ -24,6 +24,7 @@ import AddAdminModal from './modal/AddAdminModal' import CourseGroupChooserModal from './modal/CourseGroupChooserModal' import { ROLE_TEACHER_NUM, ROLE_ASSISTANT_NUM } from './common' import CourseGroupChooser from './CourseGroupChooser' +import ChangeRolePop from './ChangeRolePop' const Search = Input.Search; const ROLE_ADMIN = "管理员" @@ -38,6 +39,8 @@ function buildColumns(that) { const isAdminOrTeacher = that.props.isAdminOrTeacher() const { course_groups, filterKey } = that.state const showSorter = filterKey == '1' + const courseId = that.props.match.params.coursesId + const columns = [{ title: '序号', dataIndex: 'name', @@ -117,7 +120,7 @@ function buildColumns(that) { const hasGraduationModule = that.hasGraduationModule() if (hasGraduationModule && showSorter) { columns.push({ - title: '答辩组', + title: '所在答辩组', // width: 90, sorter: showSorter, sortDirections: sortDirections, @@ -141,6 +144,9 @@ function buildColumns(that) { width: 150, align:'center', render: (text, record) => { + const isAdmin = record.role == ROLE_ADMIN + const isTeacher = record.role == ROLE_TEACHER + const isAssitant = record.role == ROLE_TEACHER_ASSISTANT if (record.application_id) { return ( @@ -149,16 +155,43 @@ function buildColumns(that) { that.onAgree(record)} style={{color: '#4CACFF'}}>同意 ) } else { + return ( - - {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 && isAdminOrCreator ? that.showChangeAdminModal(record)}>更换管理员 : '' } + + 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 && isAdminOrCreator ? that.showChangeAdminModal(record)}>更换管理员 : '' } - ) + // + ) } }, @@ -344,6 +377,9 @@ class studentsList extends Component{ console.log(error); }); } + onChangeRoleSuccess = () => { + this.fetchAll() + } fetchAll = async (argPage) => { this.setState({ isSpin:true