import React,{ Component } from "react"; import { Input,Checkbox,Menu,Pagination,Spin} from "antd"; import CourseLayoutcomponent from '../common/CourseLayoutComponent'; import UseBank from './UseBank' import '../css/members.css' import '../css/busyWork.css' import CoursesListType from '../coursesPublic/CoursesListType' import CommonWorkItem from './CommonWorkItem' import PublishRightnow from './PublishRightnow' import ConnectProject from './ConnectProject' import { WordsBtn, on, off } from 'educoder' import Modals from '../../modals/Modals' import NoneData from "../coursesPublic/NoneData" import Titlesearchsection from '../common/titleSearch/TitleSearchSection'; import { RouteHOC } from './common' import axios from 'axios'; import _ from 'lodash' const Search = Input.Search; const map={1:"普通作业",2:"",3:"分组作业"} const COMMON_WORK = 1 // const COMMON_WORK = 2 class commonWork extends Component{ constructor(props){ super(props); this.state={ modalsType:"", modalsTopval:"", modalsBottomval:"", modalCancel:"", mainList:undefined, selectedKeys: 'all', order:"", page:1, search:"", totalCount:0, checkAll:false, checkBoxValues:[], isSpin:false } } //输入搜索条件 inputStudent=(e)=>{ this.setState({ search:e.target.value, page:1 }) } //搜索查询 searchStudent=()=>{ let {page,search,order}=this.state; this.getList(page,search,order); } openConnectionProject = (work) => { this.refs['connectProject'].openConnectionProject(work) } // 新建 createCommonWork=(type)=>{ this.props.toNewPage(this.props.match.params) } cancelDelClasses=()=>{ this.setState({ modalsType:false, modalsTopval:"", modalsBottomval:"", modalCancel:false }) } sureDelClasses(){ } componentDidUpdate(prevProps, prevState) { if (prevProps.match.path != this.props.match.path) { this.clearSelection() this.setState({ selectedKeys: 'all', order: '' }, () => { this._getList() }) } } _getList = () => { this.setState({ isSpin:true }) let {page,search,order}=this.state; this.getList(page,search,order); } componentDidMount(){ this._getList() on('updateNavSuccess', this.updateNavSuccess) } componentWillUnmount() { off('updateNavSuccess', this.updateNavSuccess) } updateNavSuccess = () => { this._getList() } useBankSuccess = (checkBoxValues, newWorkIdArray) => { this.setState({ page:1, checkBoxValues: newWorkIdArray }, () => { this.refs['publishModalRef'].open() }) let {search, order}=this.state; this.getList(1, search, order); } getList=(page,search,order)=>{ this.setState({ isSpin:true }) let id=this.props.match.params.coursesId; let workType = this.props.getModuleType() let url="/courses/"+id+"/homework_commons.json?type="+workType+"&page="+page; if(order!=""){ url+="&order="+order; } if(search!=""){ url+="&search="+search; } axios.get(encodeURI(url)).then((result)=>{ if(result.status==200){ this.setState({ mainList:result.data, totalCount:result.data.task_count, isSpin:false, ...result.data }) } }).catch((error)=>{ console.log(error); }) } //筛选条件 selectedStatus=(e)=>{ this.clearSelection() this.setState({ order:e.key==="all"?"":e.key, selectedKeys: e.key, page:1, isSpin:true, checkBoxValues:[], checkAll:false }) let {search}=this.state; this.getList(1,search,e.key==="all"?"":e.key); } onPageChange=(pageNumber)=>{ this.setState({ page:pageNumber, checkBoxValues:[] }) let {search,order}=this.state; this.getList(pageNumber,search,order); } // 全选和反选 changeAll=(e)=>{ this.setState({ checkAll: e.target.checked }) const valueId=this.state.mainList.homeworks.map(item=>{ return item.homework_id }) if (e.target.checked) { const concated = this.state.checkBoxValues.concat(valueId); const sortedUniqed = _.uniq(concated) this.setState({ checkBoxValues: sortedUniqed }) } else { this.setState({ checkBoxValues: _.difference(this.state.checkBoxValues, valueId) }) } } onChangeSelect=(checkedValues)=>{ this.setState({ checkBoxValues: checkedValues, checkAll: checkedValues.length == this.state.mainList.homeworks.length }) } onWorkDelete = () => { const { checkBoxValues } = this.state; const len = checkBoxValues.length; if (len == 0) { this.props.showNotification('请先选择要删除的作业') return; } this.props.confirm({ // content: `确认要删除所选的${len}个作业吗?`, content:
{moduleChineseName}