diff --git a/public/react/src/modules/courses/busyWork/CommonWorkDetailIndex.js b/public/react/src/modules/courses/busyWork/CommonWorkDetailIndex.js
index 86b17e802..134be31c3 100644
--- a/public/react/src/modules/courses/busyWork/CommonWorkDetailIndex.js
+++ b/public/react/src/modules/courses/busyWork/CommonWorkDetailIndex.js
@@ -4,13 +4,8 @@ import {Link} from 'react-router-dom';
import {BrowserRouter as Router,Route,Switch} from 'react-router-dom';
import Loadable from 'react-loadable';
import Loading from '../../../Loading';
-import { CNotificationHOC } from '../common/CNotificationHOC'
-import { RouteHOC } from './common'
-
-import locale from 'antd/lib/date-picker/locale/zh_CN';
import { WordsBtn, MarkdownToHtml, trigger, queryString, downloadFile } from 'educoder';
import axios from 'axios';
-import Modals from '../../modals/Modals';
import CoursesListType from '../coursesPublic/CoursesListType';
import AccessoryModal from "../coursesPublic/AccessoryModal";
import PublishRightnow from './PublishRightnow'
diff --git a/public/react/src/modules/courses/busyWork/PublishRightnow.js b/public/react/src/modules/courses/busyWork/PublishRightnow.js
index da2054124..ff6a8855d 100644
--- a/public/react/src/modules/courses/busyWork/PublishRightnow.js
+++ b/public/react/src/modules/courses/busyWork/PublishRightnow.js
@@ -1,7 +1,8 @@
import React,{ Component } from "react";
import { Input,Checkbox,Menu,Pagination } from "antd";
-import HomeworkModal from '../coursesPublic/HomeworkModal'
+import HomeworkModal from '../coursesPublic/HomeworkModal';
+import OneSelfOrderModal from "../coursesPublic/OneSelfOrderModal";
import axios from 'axios'
import moment from 'moment'
import { getNextHalfHourOfMoment } from 'educoder'
@@ -51,7 +52,8 @@ class PublishRightnow extends Component{
this.setState({
modalname: isPublish ? "立即发布" : "立即截止",
modaltype:1,
- visible:true,
+ visible:isPublish?false:true,
+ OneSelftype:isPublish?true:false,
Topval: isPublish ? "学生将立即收到作业" : "学生将不能再提交作品",
// Botvalleft: isPublish ? "暂不发布" : "暂不截止",
Botval: this.props.fromListPage ? (isPublish ? "本操作只对“未发布”的分班有效" : "本操作只对“提交中”的分班有效") : '',
@@ -70,6 +72,7 @@ class PublishRightnow extends Component{
modalname:undefined,
modaltype:undefined,
visible:false,
+ OneSelftype:false,
Topval:undefined,
Topvalright:undefined,
Botvalleft:undefined,
@@ -106,18 +109,28 @@ class PublishRightnow extends Component{
this.props.showNotification('请至少选择一个分班');
return;
}
-
+
+ let data={}
+ if(arg_group_ids.length===0){
+ data = {
+ homework_ids: this.props.checkBoxValues,
+ end_time: endtime==="Invalid date"?undefined:endtime,
+ }
+ }else{
+ data={
+ homework_ids: this.props.checkBoxValues,
+ group_ids: group_ids,
+ group_end_times:endtime,
+ detail:true
+ }
+ }
let coursesId=this.props.match.params.coursesId;
const url = `/courses/${coursesId}/homework_commons/${isPublish ? "publish_homework" : "end_homework"}.json`
- axios.post(url, {
- group_ids,
- homework_ids: this.props.checkBoxValues,
- all_check: 0,
- end_time:endtime==="Invalid date"?undefined:endtime
- })
+ axios.post(url, data)
.then((response) => {
if (response.data.status == 0) {
+ this.homeworkhide()
this.props.showNotification(isPublish ? "立即发布成功" : "立即截止成功")
this.props.doWhenSuccess && this.props.doWhenSuccess()
this.setState({ visible : false })
@@ -153,6 +166,7 @@ class PublishRightnow extends Component{
this.showDialog()
this.setState({
course_groups: response.data.course_groups,
+ starttimesend:response.data.end_time===undefined||response.data.end_time===null||response.data.end_time===""?undefined:response.data.end_time,
})
})
.catch(function (error) {
@@ -184,6 +198,7 @@ class PublishRightnow extends Component{
const { showActionButton } = this.props
return(
)
diff --git a/public/react/src/modules/courses/coursesPublic/OneSelfOrderModal.js b/public/react/src/modules/courses/coursesPublic/OneSelfOrderModal.js
index d706bf2ee..87a43ca1b 100644
--- a/public/react/src/modules/courses/coursesPublic/OneSelfOrderModal.js
+++ b/public/react/src/modules/courses/coursesPublic/OneSelfOrderModal.js
@@ -33,52 +33,111 @@ class OneSelfOrderModal extends Component{
super(props);
this.state={
group_ids:[],
- endtime:""
+ endtime:"",
+ course_groups:undefined,
+ Checkboxtype:true
}
}
componentDidMount() {
if(this.props.course_groups!=undefined&&this.props.course_groups.length!=0){
-
- let arr=this.props.course_groups.map(item => item.id);
- this.shixunhomeworkedit(arr);
+ if(this.props.course_groups!=undefined) {
+ let arr = this.props.course_groups.map(item => item.id);
+ let newarr = [];
+ let course_groups = this.props.course_groups;
+ course_groups.map((item, key) => {
+ if (item.end_time === null) {
+ if(this.props.starttimesend===undefined){
+ item.end_time = moment(moment(handleDateString(this.props.staytime)).add(1, 'week')).format("YYYY-MM-DD HH:mm");
+ }else{
+ item.end_time = moment(handleDateString(this.props.starttimesend)).format("YYYY-MM-DD HH:mm");
+ }
+ newarr.push(item)
+ } else {
+ newarr.push(item)
+ }
+ })
+ this.setState({
+ course_groups: newarr
+ })
+ this.shixunhomeworkedit(arr);
+ }
}
if(this.props.starttimes===undefined||this.props.starttimes===""||this.props.starttimes===null){
- this.setState({
- endtime:moment(moment(handleDateString(this.props.staytime)).add(1, 'months')).format("YYYY-MM-DD HH:mm")
- })
+ if(this.props.starttimesend===undefined){
+ this.setState({
+ endtime:moment(moment(handleDateString(this.props.staytime)).add(1, 'week')).format("YYYY-MM-DD HH:mm")
+ })
+ }else{
+ this.setState({
+ endtime:moment(handleDateString(this.props.starttimesend)).format("YYYY-MM-DD HH:mm")
+ })
+ }
+
}else{
- this.setState({
- endtime:moment(handleDateString(this.props.starttimes)).format("YYYY-MM-DD HH:mm")
- })
+ if(this.props.starttimesend===undefined){
+ this.setState({
+ endtime:moment(moment(handleDateString(this.props.staytime)).add(1, 'week')).format("YYYY-MM-DD HH:mm")
+ })
+ }else{
+ this.setState({
+ endtime:moment(handleDateString(this.props.starttimesend)).format("YYYY-MM-DD HH:mm")
+ })
+ }
}
}
componentDidUpdate=(prevProps)=>{
- // if(prevProps.visible!=this.props.visible){
- //
- // if(this.props.course_groups!=undefined){
- // let arr=this.props.course_groups.map(item => item.id);
- // this.shixunhomeworkedit(arr);
- // }
- // }
+
if(prevProps.course_groups!=this.props.course_groups){
- if(this.props.course_groups!=undefined){
- let arr=this.props.course_groups.map(item => item.id);
- this.shixunhomeworkedit(arr);
- }
+ if(this.props.course_groups!=undefined){
+ let arr=this.props.course_groups.map(item => item.id);
+ let newarr=[];
+ let course_groups=this.props.course_groups;
+ course_groups.map((item,key)=>{
+ if(item.end_time===null){
+ if(this.props.starttimesend===undefined){
+ item.end_time = moment(moment(handleDateString(this.props.staytime)).add(1, 'week')).format("YYYY-MM-DD HH:mm");
+ }else{
+ item.end_time = moment(handleDateString(this.props.starttimesend)).format("YYYY-MM-DD HH:mm");
+ }
+ newarr.push(item)
+ }else{
+ newarr.push(item)
+ }
+ })
+ this.setState({
+ course_groups:newarr
+ })
+ this.shixunhomeworkedit(arr);
+ }
}
+
+
if(prevProps.starttimes!=this.props.starttimes){
if(this.props.starttimes===undefined||this.props.starttimes===""||this.props.starttimes===null){
- this.setState({
- endtime:moment(moment(handleDateString(this.props.staytime)).add(1, 'months')).format("YYYY-MM-DD HH:mm")
- })
+ if(this.props.starttimesend===undefined){
+ this.setState({
+ endtime:moment(moment(handleDateString(this.props.staytime)).add(1, 'week')).format("YYYY-MM-DD HH:mm")
+ })
+ }else{
+ this.setState({
+ endtime:moment(handleDateString(this.props.starttimesend)).format("YYYY-MM-DD HH:mm")
+ })
+ }
+
}else{
- this.setState({
- endtime:moment(handleDateString(this.props.starttimes)).format("YYYY-MM-DD HH:mm")
- })
+ if(this.props.starttimesend===undefined){
+ this.setState({
+ endtime:moment(moment(handleDateString(this.props.staytime)).add(1, 'week')).format("YYYY-MM-DD HH:mm")
+ })
+ }else{
+ this.setState({
+ endtime:moment(handleDateString(this.props.starttimesend)).format("YYYY-MM-DD HH:mm")
+ })
+ }
}
}
}
@@ -101,22 +160,38 @@ class OneSelfOrderModal extends Component{
}
+ onChangeTimeendlist=(date, dateString,id)=>{
+ let {course_groups}=this.state;
+ let arr=course_groups;
+
+ arr.map((item,key)=>{
+ if(item.id===id){
+ item.end_time=date===null?"":moment(handleDateString(dateString)).format('YYYY-MM-DD HH:mm')
+ }
+ })
+
+ this.setState({
+ course_groups:arr
+ })
+
+ }
+
propsSaves=(ds,endtime)=>{
+ let {course_groups}=this.state;
- if(ds.length ===0&&endtime === ""){
+ if(this.props.typs=="end"){
this.props.Saves()
}else{
- if(this.props.typs!="end"){
- if(endtime === ""||endtime===undefined||endtime===null){
+ if(this.props.typs!="end"){
+ if(!endtime){
this.setState({
endtimetype:true,
endtimetypevalue:"截止时间不能为空"
})
return
}
-
- if(moment(endtime,"YYYY-MM-DD HH:mm") <= moment(this.props.starttimes,"YYYY-MM-DD HH:mm")){
+ if(moment(endtime,"YYYY-MM-DD HH:mm") <= moment(this.props.starttime,"YYYY-MM-DD HH:mm")){
this.setState({
endtimetype:true,
endtimetypevalue:"必须晚于发布时间"
@@ -124,27 +199,79 @@ class OneSelfOrderModal extends Component{
return
}
}
- this.props.Saves(ds,moment(handleDateString(endtime),"YYYY-MM-DD HH:mm").format("YYYY-MM-DD HH:mm"))
- }
+ let type=false
+ if(course_groups===undefined||course_groups.length===0){
+ this.props.Saves(ds,moment(handleDateString(endtime),"YYYY-MM-DD HH:mm").format("YYYY-MM-DD HH:mm"))
+ }else{
+ let arr=[]
+ ds.map((item,key)=>{
+ course_groups.map((items,key)=>{
+ if(item===items.id){
+ if(!items.end_time){
+ type=true
+ this.setState({
+ endtimetype:true,
+ endtimetypeid:items.id,
+ endtimetypevalue:"截止时间不能为空"
+ })
+ return
+
+ // arr.push(moment(moment(handleDateString(this.props.staytime)).add(1, 'week')).format("YYYY-MM-DD HH:mm"))
+ }else{
+ arr.push(items.end_time)
+ }
+ }
+ })
+ })
+
+ if(type===false){
+ this.props.Saves(ds,arr)
+ }
+ }
+
+
+ }
}
- render(){
- let {group_ids,endtime}=this.state;
- let {course_groups}=this.props;
+ Checkboxtype=(e)=>{
- // console.log(this.props.starttimes)
- // console.log(endtime)
- // console.log(this.props.starttimes)
- // console.log(this.state.endtime)
+ let {course_groups}=this.state;
- // console.log(this.props.starttime,this.props.endtime)
- // TODO course_groups为空时的处理
+ let arr=[];
+ if(e.target.checked==true){
+ course_groups.map((item,key)=>{
+ arr.push(item.id)
+ })
+ }else{
+ arr=[]
+ }
+ this.setState({
+ Checkboxtype:e.target.checked,
+ group_ids:arr
+ })
+ }
- // let endtimelist=this.props.starttimes===undefined||this.props.starttimes===""?"":moment(handleDateString(endtime)).add(1,'months')
+ render(){
+ let {group_ids,endtime,course_groups}=this.state;
+ // console.log(course_groups)
+ // TODO course_groups为空时的处理
return(
+
{
this.props.OneSelftype===true?