diff --git a/public/react/src/modules/courses/busyWork/NewWork.js b/public/react/src/modules/courses/busyWork/NewWork.js index 1bd79d93e..4bee890d8 100644 --- a/public/react/src/modules/courses/busyWork/NewWork.js +++ b/public/react/src/modules/courses/busyWork/NewWork.js @@ -35,7 +35,7 @@ class NewWork extends Component{ } fetchCourseData = (courseId) => { let newcategory=undefined; - if(this.props.match.path==="/classrooms/:coursesId/common_homework/:workId/:pageType"){ + if(this.props.match.path==="/classrooms/:coursesId/common_homework/:workId/:pageType"||this.props.match.path==="/classrooms/:coursesId/group_homework/:workId/:pageType"){ newcategory=this.props.match.params.workId } const isGroup = this.props.isGroup() @@ -64,7 +64,7 @@ class NewWork extends Component{ } fetchWork = (workId) => { let newcategory=undefined; - if(this.props.match.path==="/classrooms/:coursesId/common_homework/:workId/:pageType"){ + if(this.props.match.path==="/classrooms/:coursesId/common_homework/:workId/:pageType"||this.props.match.path==="/classrooms/:coursesId/group_homework/:workId/:pageType"){ newcategory=this.props.match.params.workId } let url="" @@ -115,7 +115,7 @@ class NewWork extends Component{ doNew = (params) => { const coursesId = this.props.match.params.coursesId const newUrl = `/courses/${coursesId}/homework_commons.json` - if(this.props.match.path==="/classrooms/:coursesId/common_homework/:workId/:pageType"){ + if(this.props.match.path==="/classrooms/:coursesId/common_homework/:workId/:pageType"||this.props.match.path==="/classrooms/:coursesId/group_homework/:workId/:pageType"){ params.category=this.props.match.params.workId } diff --git a/public/react/src/modules/courses/busyWork/common.js b/public/react/src/modules/courses/busyWork/common.js index b413f2c53..f738af2b4 100644 --- a/public/react/src/modules/courses/busyWork/common.js +++ b/public/react/src/modules/courses/busyWork/common.js @@ -31,7 +31,7 @@ export function RouteHOC(options = {}) { // common_homework group_homework // 是否是分组作业 isGroup = () => { - return window.location.pathname.indexOf('group_homeworks') != -1 + return window.location.pathname.indexOf('group_homeworks') != -1||window.location.pathname.indexOf('group_homework') != -1 } getModuleName = (isChinese) => { const isGroup = this.isGroup() @@ -45,6 +45,12 @@ export function RouteHOC(options = {}) { return secondName; } + + if(window.location.pathname.indexOf('group_homework') != -1){ + const secondName ='group_homework'; + return secondName; + } + if(window.location.pathname.indexOf('common_homeworks') != -1){ const secondName ='common_homeworks'; return secondName; diff --git a/public/react/src/modules/courses/busyWork/commonWork.js b/public/react/src/modules/courses/busyWork/commonWork.js index d4b097cec..6a7e3c878 100644 --- a/public/react/src/modules/courses/busyWork/commonWork.js +++ b/public/react/src/modules/courses/busyWork/commonWork.js @@ -35,7 +35,8 @@ class commonWork extends Component{ checkAll:false, checkBoxValues:[], isSpin:false, - category_id:undefined + category_id:undefined, + course_module:[] } } //输入搜索条件 @@ -70,42 +71,34 @@ class commonWork extends Component{ } componentDidUpdate(prevProps, prevState) { - console.log(this.props) - if (prevProps.coursesidtype != this.props.coursesidtype) { - if (this.props.match.path === "/classrooms/:coursesId/common_homeworks/:category_id" || this.props.match.path === "/classrooms/:coursesId/common_homework/:category_id") { - if (this.props.coursesidtype === "node" && this.props.match.path === "/classrooms/:coursesId/common_homeworks/:category_id") { + if (prevProps.coursesidtype != this.props.coursesidtype||prevProps.match.params.category_id!=this.props.match.params.category_id) { + if (this.props.match.path === "/classrooms/:coursesId/common_homeworks/:category_id" || this.props.match.path === "/classrooms/:coursesId/common_homework/:category_id"|| + this.props.match.path === "/classrooms/:coursesId/group_homeworks/:category_id" || this.props.match.path === "/classrooms/:coursesId/group_homework/:category_id" + ) { + + if (this.props.coursesidtype === "node" && this.props.match.path === "/classrooms/:coursesId/common_homeworks/:category_id"|| + this.props.coursesidtype === "node" && this.props.match.path === "/classrooms/:coursesId/group_homeworks/:category_id" + ) { + this.clearSelection() this.setState({selectedKeys: 'all', order: ''}, () => { this._getList() }) } - if (this.props.coursesidtype === "child" && this.props.match.path === "/classrooms/:coursesId/common_homework/:category_id") { + + if (this.props.coursesidtype === "child" && this.props.match.path === "/classrooms/:coursesId/common_homework/:category_id"|| + this.props.coursesidtype === "child" && this.props.match.path === "/classrooms/:coursesId/group_homework/:category_id" + ) { + this.clearSelection() this.setState({selectedKeys: 'all', order: ''}, () => { this._getList(this.props.match.params.category_id) }) } } + } - // - // if(this.props.match.path==="/classrooms/:coursesId/common_homeworks/:category_id"||this.props.match.path==="/classrooms/:coursesId/common_homework/:category_id"){ - // - // - // if(this.props.coursesidtype==="node"&&this.props.match.path==="/classrooms/:coursesId/common_homeworks/:category_id"){ - // this.clearSelection() - // this.setState({ selectedKeys: 'all', order: '' }, () => { - // this._getList() - // }) - // } - // if(this.props.coursesidtype==="child"&&this.props.match.path==="/classrooms/:coursesId/common_homework/:category_id"){ - // this.clearSelection() - // this.setState({ selectedKeys: 'all', order: '' }, () => { - // this._getList(this.props.match.params.category_id) - // }) - // } - // - // } } @@ -118,22 +111,24 @@ class commonWork extends Component{ this.getList(page,search,order,id); } componentDidMount(){ - if(this.props.coursesidtype==="node"){ + + if(this.props.match.path === "/classrooms/:coursesId/common_homeworks/:category_id"||this.props.match.path === "/classrooms/:coursesId/group_homeworks/:category_id"){ this._getList() - }else{ + } + if(this.props.match.path === "/classrooms/:coursesId/common_homework/:category_id"||this.props.match.path === "/classrooms/:coursesId/group_homework/:category_id") { this._getList(this.props.match.params.category_id) } - on('updateNavSuccess', this.updateNavSuccess) } componentWillUnmount() { off('updateNavSuccess', this.updateNavSuccess) } updateNavSuccess = () => { - if(this.props.coursesidtype==="node"){ + if(this.props.match.path === "/classrooms/:coursesId/common_homeworks/:category_id"||this.props.match.path === "/classrooms/:coursesId/group_homeworks/:category_id"){ this._getList() - }else{ + } + if(this.props.match.path === "/classrooms/:coursesId/common_homework/:category_id"||this.props.match.path === "/classrooms/:coursesId/group_homework/:category_id") { this._getList(this.props.match.params.category_id) } } @@ -151,7 +146,6 @@ class commonWork extends Component{ } getList=(page,search,order,category_id)=>{ - console.log(category_id) this.setState({ isSpin:true @@ -177,6 +171,32 @@ class commonWork extends Component{ page:page, ...result.data }) + this.getdatas(result.data.main_category_id) + } + }).catch((error)=>{ + this.setState({ + isSpin:false + }) + }) + } + getdatas=(main_category_id)=>{ + let newcourse_module=[] + + let urls=`/course_modules/${main_category_id}.json` + axios.get(encodeURI(urls)).then((result)=>{ + if(result.status==200){ + + newcourse_module.push({name:result.data.course_module.module_name,id:result.data.course_module.id}) + if(result.data.course_module.course_second_categories.length>0){ + + result.data.course_module.course_second_categories.map((item,key)=>{ + newcourse_module.push(item) + }) + } + + this.setState({ + course_module:newcourse_module + }) } }).catch((error)=>{ this.setState({ @@ -279,7 +299,7 @@ class commonWork extends Component{ } // onSetPublic = () => { - const { checkBoxValues } = this.state; + const { checkBoxValues,category_id } = this.state; const len = checkBoxValues.length; if (len == 0) { this.props.showNotification('请先选择要公开的作业') @@ -374,11 +394,41 @@ class commonWork extends Component{ if(!id){ trigger('addcommon_homeworks', parseInt(this.props.match.params.category_id)) }else{ - let data={id:parseInt(id),name:name} + let data={id:parseInt(id),name:this.state.category_name} trigger('editcommon_homeworks', data) } } + moveTo = (item) => { + const len = this.state.checkBoxValues.length + if (len == 0) { + this.props.showNotification('请先在列表中选择要移动的作业') + return; + } + const checkBoxValues = this.state.checkBoxValues; + const coursesId= this.props.match.params.coursesId; + const category_id=this.state.category_id; + const url = `/courses/${coursesId}/homework_commons/move_to_category.json` + axios.post(url, { + homework_ids: checkBoxValues, + new_category_id: item.id, + category_id:!category_id?undefined:category_id + }) + .then((response) => { + if (response.data.status == 0) { + console.log('--- 成功') + this.props.showNotification('作业移动成功') + this.props.updataleftNavfun() + this.setState({ + checkBoxValues:[] + }) + this.updateNavSuccess() + } + }) + .catch(function (error) { + console.log(error); + }); + } render(){ let { @@ -391,7 +441,7 @@ class commonWork extends Component{ totalCount, checkAll, checkBoxValues, - + course_module, task_count, published_count, unpublished_count, @@ -409,9 +459,8 @@ class commonWork extends Component{ const isGroup = this.props.isGroup() const isAdmin = this.props.isAdmin() + const bid = this.props.match.params.category_id - // <CourseLayoutcomponent {...this.props}> - // </CourseLayoutcomponent> return( <div> @@ -458,7 +507,7 @@ class commonWork extends Component{ { isAdmin && <li className="fr"> <UseBank {...this.props} {...this.state} object_type={isGroup ? "group" : "normal"} useBankSuccess={this.useBankSuccess}></UseBank> </li> } - { isAdmin && <li className="fr mr40"> + { isAdmin && <li className="fr mr30"> <WordsBtn style="blue" className="fr" onClick={()=>this.addDir(category_id)}>{!category_id?"新建目录":"目录重命名"}</WordsBtn> </li> } </React.Fragment> @@ -512,9 +561,33 @@ class commonWork extends Component{ </li> { !!course_public && <li className="li_line"><a href="javascript:void(0)" onClick={this.onSetPublic} className="color-grey-9">设为公开</a></li>} - {this.props.user&&this.props.user.main_site===true?<li><a href="javascript:void(0)" className="color-grey-9" + {this.props.user&&this.props.user.main_site===true?<li class="li_line"><a href="javascript:void(0)" className="color-grey-9" onClick={this.addToBank} >加入题库</a></li>:""} + <li className="li_line drop_down"> + 移动到...<i className="iconfont icon-xiajiantou font-12 ml2"></i> + <ul className="drop_down_menu" + style={{"right":"0px","left":"unset", maxHeight: '318px', overflowY: 'auto', minWidth: '200px'}}> + { course_module && course_module.length > 10 && <p className="drop_down_search"> + <Input placeholder="搜索" value={this.state.dirSearchValue} onChange={(e) => {this.setState({dirSearchValue: e.target.value})}}/> + </p> } + { + course_module && course_module.filter((item)=> { + return item.id != bid && (!this.state.dirSearchValue || item.name.indexOf(this.state.dirSearchValue) != -1) + }).map( (item, index) => { + return <li key={`i_${index}`} onClick={() => this.moveTo(item)} title={item.name}>{item.name}</li> + }) + } + { isAdmin && + <p className="drop_down_btn"> + <a href="javascript:void(0)" className="color-grey-6" + onClick={()=>this.addDir(category_id)} + >新建目录...</a> + </p> + } + {/* <p className="drop_down_btn"><a href="javascript:void(0)" className="color-grey-6">添加分班...</a></p> */} + </ul> + </li> </div> {/* 设为公开 */} <Modals