import React, { Component } from 'react'; import {Pagination,Spin,Checkbox,Modal} from 'antd'; import moment from 'moment'; import axios from 'axios'; import NoneData from '../../courses/coursesPublic/NoneData' import {getImageUrl} from 'educoder'; import "./usersInfo.css" import Modals from '../../modals/Modals' const dateFormat ="YYYY-MM-DD HH:mm" class InfosBank extends Component{ constructor(props){ super(props); this.state={ category:"common", type:"publicly", page:1, per_page:16, sort_by:"updated_at", CoursesId:undefined, totalCount:undefined, data:undefined, isSpin:false, dialogOpen:false, modalsTopval:undefined, modalsBottomval:undefined, modalSave:undefined } } componentDidMount=()=>{ this.setState({ isSpin:true }) let{category,type,page,sort_by,CoursesId}=this.state; this.getCourses(category,type,page,sort_by,CoursesId); } getCourses=(category,type,page,sort_by,CoursesId)=>{ let url=`/users/${this.props.match.params.username}/question_banks.json`; axios.get((url),{params:{ category, type, page, sort_by, per_page:category && page ==1?17:16, course_list_id:CoursesId }}).then((result)=>{ if(result){ this.setState({ totalCount:result.data.count, data:result.data, isSpin:false }) } }).catch((error)=>{ console.log(error); }) } //切换种类 changeCategory=(cate)=>{ this.setState({ category:cate, page:1, isSpin:true }) let{type,sort_by,CoursesId}=this.state; this.getCourses(cate,type,1,sort_by,CoursesId); } //切换状态 changeType=(type)=>{ this.setState({ type:type, page:1, isSpin:true }) let{category,sort_by,CoursesId}=this.state; this.getCourses(category,type,1,sort_by,CoursesId); } //切换页数 changePage=(page)=>{ this.setState({ page, isSpin:true }) let{category,type,sort_by,CoursesId}=this.state; this.getCourses(category,type,page,sort_by,CoursesId); } // 进入课堂 turnToCourses=(url)=>{ this.props.history.push(url); } // 切换排序方式 changeOrder= (sort)=>{ this.setState({ sort_by:sort, isSpin:true }) let{category,type,page,CoursesId}=this.state; this.getCourses(category,type,page,sort,CoursesId); } changeCourseListId =(CoursesId)=>{ this.setState({ CoursesId, isSpin:true }) let{category,type,sort,page}=this.state; this.getCourses(category,type,page,sort,CoursesId); } //设为公开/删除 setPublic=(index)=>{ this.setState({ dialogOpen:true, modalsTopval:index==1?"您确定要公开吗?":"确定要删除该题吗?", modalsBottomval:index==1?"公开后不能重设为私有":"", modalSave:()=>this.sureOperation(index) }) } // 确定--设为公开/删除 sureOperation=()=>{ } //弹框隐藏 handleDialogClose=()=>{ this.setState({ dialogOpen:false }) } render(){ let{ category, type, page, data, totalCount, sort_by, isSpin, CoursesId, dialogOpen, modalsTopval, modalsBottomval,modalSave } = this.state; let isStudent = this.props.isStudent(); let is_current=this.props.is_current; return(
  • this.changeType("publicly")}>{is_current ? "我":"TA"}的题库
  • this.changeType("personal")}>公共题库
    • this.changeCourseListId()}> 全部
    • { data && data.course_list && data.course_list.map((item,key)=>{ return(
    • this.changeCourseListId(`${item.id}`)}> {item.name}
    • ) }) }

    共参与{totalCount}个题库

  • {sort_by=="updated_at"?"时间最新":sort_by=="name"?"作业名称":"贡献者"}
    • this.changeOrder("updated_at")}>时间最新
    • this.changeOrder("name")}>作业名称
    • this.changeOrder("contributor")}>贡献者
  • { !data || data.question_banks.length==0 && } { data && data.question_banks && data.question_banks.map((item,key)=>{ return(

    {item.name} 发送 { item.is_public ==false ? this.setPublic(1)} className="bank_public color-blue_4C fr mr60">设为公开:"" }

    {item.quotes_count}次引用 {item.solve_count}次答题 {moment(item.updated_at).format('YYYY-MM-DD HH:mm')} this.setPublic(2)}>删除 {item.course_list_name}

    ) }) }
    { totalCount > 15 &&
    }
    ) } } export default InfosBank;