|
|
|
@ -2,8 +2,16 @@ import React, { useState, useEffect } from 'react'
|
|
|
|
|
import { trigger } from 'educoder'
|
|
|
|
|
import { Input, Checkbox } from "antd";
|
|
|
|
|
|
|
|
|
|
function CourseGroupChooser({ course_groups, isAdminOrCreator, item, index, arg_course_groups, checkAllValue
|
|
|
|
|
, coursesids, onCheckAllChange, joinCourseGroup }) {
|
|
|
|
|
/**
|
|
|
|
|
arg_course_groups 选中的id数组
|
|
|
|
|
joinCourseGroup 选中时触发 joinCourseGroup(checkedValues, item, index) 传入item:数据对象,index: 数据对象index
|
|
|
|
|
checkAllValue 是否全选
|
|
|
|
|
onCheckAllChange 全选 onCheckAllChange(e, item, index)
|
|
|
|
|
course_groups 所有的group
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
function CourseGroupChooser({ course_groups, isAdminOrCreator = true, item, index, arg_course_groups, checkAllValue, alwaysShow
|
|
|
|
|
, onCheckAllChange, joinCourseGroup }) {
|
|
|
|
|
const [state, setState] = useState({counter: 0})
|
|
|
|
|
const [search, setSearch] = useState('')
|
|
|
|
|
// useEffect(() => {
|
|
|
|
@ -30,8 +38,15 @@ function CourseGroupChooser({ course_groups, isAdminOrCreator, item, index, arg_
|
|
|
|
|
that.state.checkAllArray[index] - checkAllValue
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
console.log('arg_course_groups', arg_course_groups)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const urlStyle = {"lef":"tunset", minWidth: '262px'};
|
|
|
|
|
if (alwaysShow == true) {
|
|
|
|
|
urlStyle.display = 'block'
|
|
|
|
|
}
|
|
|
|
|
return (
|
|
|
|
|
<ul className="drop_down_menu" style={{"lef":"tunset", minWidth: '262px'}}>
|
|
|
|
|
<ul className="drop_down_menu" style={urlStyle}>
|
|
|
|
|
{
|
|
|
|
|
course_groups && course_groups.length > 10?
|
|
|
|
|
(<p className="drop_down_search">
|
|
|
|
@ -41,15 +56,15 @@ function CourseGroupChooser({ course_groups, isAdminOrCreator, item, index, arg_
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
<Checkbox.Group onChange={(checkedValues) => joinCourseGroup(checkedValues, item, index)}
|
|
|
|
|
value={arg_course_groups.map(item => item.id)}
|
|
|
|
|
value={arg_course_groups.length && arg_course_groups[0].id ? arg_course_groups.map(item => item.id): arg_course_groups}
|
|
|
|
|
disabled={!isAdminOrCreator} className="mainGroup"
|
|
|
|
|
>
|
|
|
|
|
{course_groups && course_groups.length > 1 && <li key={'_all' + index} >
|
|
|
|
|
{/* 防止被外面group包裹 */}
|
|
|
|
|
<Checkbox.Group>
|
|
|
|
|
<Checkbox.Group onChange={(e) => onCheckAllChange(e, item, index)} value={[checkAllValue]}>
|
|
|
|
|
<Checkbox
|
|
|
|
|
checked={checkAllValue}
|
|
|
|
|
style={{ marginRight: '6px' }} onClick={(e) => onCheckAllChange(e, item, index)} onChange={() => {}}
|
|
|
|
|
value={true}
|
|
|
|
|
style={{ marginRight: '6px' }} onClick={() => {}}
|
|
|
|
|
>全选</Checkbox>
|
|
|
|
|
</Checkbox.Group>
|
|
|
|
|
</li>}
|
|
|
|
@ -60,9 +75,10 @@ function CourseGroupChooser({ course_groups, isAdminOrCreator, item, index, arg_
|
|
|
|
|
return(
|
|
|
|
|
<li key={item.id} value={item.id} >
|
|
|
|
|
<Checkbox value={item.id}
|
|
|
|
|
id={`check${item.id}`}
|
|
|
|
|
style={{ marginRight: '6px' }}
|
|
|
|
|
></Checkbox>
|
|
|
|
|
{item.name}
|
|
|
|
|
<label for={`check${item.id}`}>{item.name}</label>
|
|
|
|
|
</li>
|
|
|
|
|
)
|
|
|
|
|
})
|
|
|
|
@ -71,7 +87,7 @@ function CourseGroupChooser({ course_groups, isAdminOrCreator, item, index, arg_
|
|
|
|
|
</Checkbox.Group>
|
|
|
|
|
<p className="drop_down_btn">
|
|
|
|
|
<a href="javascript:void(0)" className="color-grey-6"
|
|
|
|
|
onClick={() => trigger('groupAdd', coursesids)}
|
|
|
|
|
onClick={() => trigger('groupAdd')}
|
|
|
|
|
>添加分班...</a>
|
|
|
|
|
</p>
|
|
|
|
|
</ul>
|
|
|
|
|