调整立即发布 包括单个立即发布弹窗封装

competitions
杨树明 5 years ago
parent add7207310
commit 69f9390eeb

@ -0,0 +1,295 @@
import React,{ Component } from "react";
import { Modal,Checkbox,DatePicker} from "antd";
import { handleDateString } from 'educoder';
import locale from 'antd/lib/date-picker/locale/zh_CN';
import moment from 'moment';
const CheckboxGroup = Checkbox.Group;
const dateFormat = 'YYYY-MM-DD HH:mm';
function range(start, end) {
const result = [];
for (let i = start; i < end; i++) {
result.push(i);
}
return result;
}
function disabledDateTime() {
return {
// disabledHours: () => range(0, 24).splice(4, 20),
disabledMinutes: () => range(1, 30).concat(range(31, 60)),
// disabledSeconds: () => [55, 56],
};
}
function disabledDate(current) {
return current && current < moment().endOf('day').subtract(1, 'days');
}
class OneSelfOrderModal extends Component{
constructor(props){
super(props);
this.state={
group_ids:[],
endtime:""
}
}
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.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")
})
}else{
this.setState({
endtime:moment(handleDateString(this.props.starttimes)).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(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")
})
}else{
this.setState({
endtime:moment(handleDateString(this.props.starttimes)).format("YYYY-MM-DD HH:mm")
})
}
}
}
//勾选实训
shixunhomeworkedit=(list)=>{
this.setState({
group_ids:list
})
this.props.getcourse_groupslist && this.props.getcourse_groupslist(list)
}
onChangeTimeend= (date, dateString) => {
// console.log('startValue',dateString);
this.setState({
endtime: date===null?"":handleDateString(dateString),
})
}
propsSaves=(ds,endtime)=>{
if(ds.length ===0&&endtime === ""){
this.props.Saves()
}else{
if(this.props.typs!="end"){
if(endtime === ""||endtime===undefined||endtime===null){
this.setState({
endtimetype:true,
endtimetypevalue:"截止时间不能为空"
})
return
}
if(moment(endtime,"YYYY-MM-DD HH:mm") <= moment(this.props.starttimes,"YYYY-MM-DD HH:mm")){
this.setState({
endtimetype:true,
endtimetypevalue:"必须晚于发布时间"
})
return
}
}
this.props.Saves(ds,moment(handleDateString(endtime),"YYYY-MM-DD HH:mm").format("YYYY-MM-DD HH:mm"))
}
}
render(){
let {group_ids,endtime}=this.state;
let {course_groups}=this.props;
// console.log(this.props.starttimes)
// console.log(endtime)
// console.log(this.props.starttimes)
// console.log(this.state.endtime)
// console.log(this.props.starttime,this.props.endtime)
// TODO course_groups为空时的处理
// let endtimelist=this.props.starttimes===undefined||this.props.starttimes===""?"":moment(handleDateString(endtime)).add(1,'months')
return(
<div>
{
this.props.OneSelftype===true?<style>
{
`
body {
overflow: hidden !important;
}
`
}
</style>:""
}
{
this.props.OneSelftype===true? <Modal
keyboard={false}
className={"HomeworkModal"}
title={this.props.modalname}
visible={this.props.OneSelftype}
closable={false}
footer={null}
destroyOnClose={true}
>
<div className="task-popup-content">
{ this.props.usingCheckBeforePost ?
<React.Fragment>
<p className="task-popup-text-center font-16">
<span>发布设置均可修改</span>
<span className={"color-blue underline"} onClick={this.props.onToPublishClick}>
点击修改
</span>
</p>
<p className="task-popup-text-center font-16 mt10">
此设置将对所有分班生效
</p>
</React.Fragment> :
<React.Fragment>
<p className="task-popup-text-center font-16">
{this.props.Topval}
<span className={"color-blue underline"}>{this.props.Topvalright}</span>
</p>
<p className="task-popup-text-center font-16 mt10">
{this.props.Botvalleft===undefined?"":<span className={"colorFF6800"}>"{this.props.Botvalleft}"</span>}
{this.props.Botval}
</p>
</React.Fragment> }
{this.props.starttime===undefined||
this.props.starttime===""?""
: <p className="task-popup-text-center font-16 mt20">
<span className={"font-14 mr20 color979797"}>
<span className={"mr10"}>发布时间:</span>
{this.props.starttime}</span>
<span className={"font-14 color979797"}>
{/*{this.props.endtime}*/}
<span className={"mr10"}>截止时间:</span>
<DatePicker
dropdownClassName="hideDisable"
showTime={{ format: 'HH:mm' }}
disabledTime={disabledDateTime}
disabledDate={disabledDate}
showToday={false}
locale={locale}
format={dateFormat}
placeholder="请选择截止时间"
id={"endTime"}
width={"210px"}
value={endtime===null||endtime===""?"":moment(endtime, dateFormat)}
onChange={this.onChangeTimeend}
className={ this.state.endtimetype===true?"noticeTip":""}
/>
{this.state.endtimetype===true?<div className={"color-red fr mr90 mt5"}>{this.state.endtimetypevalue}</div>:""}
</span>
</p>}
{/* usingCheckBeforePost 为true的时候 全选所有分班 */}
{this.props.modaltype===undefined||this.props.modaltype===2||this.props.modaltype===4
|| !course_groups || course_groups.length == 0
|| this.props.usingCheckBeforePost ?"":<ul className="upload_select_box fl clearfix mt20 mb30"
style={{"overflow-y":"auto",padding:"10px 0px"}}
id="search_not_members_list"
// onScroll={this.contentViewScroll}
>
<style>
{
`
.ant-checkbox-wrapper {
margin-top: 0px;
float: left;
}
`
}
</style>
{/*<Loading visible={hometypepvisible} shape="dot-circle" className="newnext-loading" color='#4AC7FF'>*/}
{/*</Loading>*/}
{ <Checkbox.Group style={{ width: '100%' }} value={group_ids} onChange={this.shixunhomeworkedit}>
{
course_groups.map((item,key)=>{
return(
<div className="clearfix edu-txt-center lineh-40" key={key}>
<li style={{ width: '100%',padding: "0px 10px"}} className={"mb10"}>
<Checkbox
className="task-hide edu-txt-left"
name="shixun_homework[]"
value={item.id}
key={item.id}
>
<span style={{"textAlign":"left","color":"#05101A"}} className="task-hide color-grey-name">{item.name}</span>
</Checkbox>
<DatePicker
dropdownClassName="hideDisable"
showTime={{ format: 'HH:mm' }}
disabledTime={disabledDateTime}
disabledDate={disabledDate}
showToday={false}
locale={locale}
format={dateFormat}
placeholder="请选择截止时间"
id={"endTime"}
width={"210px"}
value={endtime===null||endtime===""?"":moment(endtime, dateFormat)}
onChange={this.onChangeTimeend}
className={ this.state.endtimetype===true?"noticeTip fr":"fr"}
/>
</li>
</div>
)
})
}
</Checkbox.Group>}
</ul>
}
<div className="clearfix mt30 edu-txt-center mb10">
<a className="task-btn color-white mr30" onClick={this.props.Cancel}>{this.props.Cancelname}</a>
<a className="task-btn task-btn-orange" onClick={()=>this.propsSaves(group_ids,this.state.endtime)}>{this.props.Savesname}</a>
</div>
</div>
</Modal>:""}
</div>
)
}
}
export default OneSelfOrderModal;

@ -7,6 +7,7 @@ import Loading from '../../../../Loading';
import {BrowserRouter as Router,Route,Switch} from 'react-router-dom';
import axios from 'axios';
import HomeworkModal from "../../coursesPublic/HomeworkModal";
import OneSelfOrderModal from "../../coursesPublic/OneSelfOrderModal";
import AccessoryModal from "../../coursesPublic/AccessoryModal";
import Associationmodel from '../../coursesPublic/Associationmodel';
import CoursesListType from '../../coursesPublic/CoursesListType';
@ -40,6 +41,7 @@ class GraduationTaskDetail extends Component{
this.state={
modalname:undefined,
visible:false,
OneSelftype:false,
Topval:undefined,
starttime:undefined,
starttimes:undefined,
@ -115,17 +117,20 @@ class GraduationTaskDetail extends Component{
}
//立即发布
publish=()=>{
let {questionslist}=this.state;
let starttime= this.props.getNowFormatDates(1,1);
let endtime=this.props.getNowFormatDates(2,1);
// this.homeworkstart()
this.setState({
modalname:"立即发布",
visible:true,
OneSelftype:true,
Topval:"学生将立即收到毕设任务",
// Botvalleft:"点击修改",
// Botval:`本操作只对"未发布"的分班有效`,
starttime:moment(moment(new Date())).format("YYYY-MM-DD HH:mm") ,
starttimes:this.props.getNowFormatDates(1),
starttimes:questionslist.end_time,
staytime:this.props.getNowFormatDates(1),
typs:"start",
endtime:endtime,
Cancelname:"暂不发布",
@ -176,7 +181,9 @@ class GraduationTaskDetail extends Component{
this.setState({
modalname:"立即截止",
visible:true,
OneSelftype:true,
Topval:"学生将不能再提交作品",
starttime:undefined,
// Botvalleft:"暂不截止",
// Botval:`本操作只对"提交中"的分班有效`,
Cancelname:"暂不截止",
@ -212,6 +219,7 @@ class GraduationTaskDetail extends Component{
Modalstype:false,
Loadtype:false,
visible:false,
OneSelftype:false,
Modulationtype:false,
Allocationtype:false,
Modalstopval:"",
@ -321,11 +329,12 @@ class GraduationTaskDetail extends Component{
{
questionslist &&
<div className={"educontent mb20"}>
<HomeworkModal
<OneSelfOrderModal
staytime={this.state.staytime}
starttimes={this.state.starttimes}
typs={this.state.typs}
modalname={this.state.modalname}
visible={this.state.visible}
OneSelftype={this.state.OneSelftype}
Topval={this.state.Topval}
Topvalright={this.state.Topvalright}
Botvalleft={this.state.Botvalleft}

@ -473,7 +473,7 @@ class GraduationTasks extends Component{
checkAllValue:false
})
this.publishcanner();
debugger
let {search,page,order} = this.state
this.fetchAll(search,page,order);
}

@ -4,6 +4,7 @@ import { WordsBtn,on, off, trigger } from 'educoder';
import {BrowserRouter as Router,Route,Switch,Link} from 'react-router-dom';
import axios from'axios';
import HomeworkModal from "../coursesPublic/HomeworkModal";
import OneSelfOrderModal from "../coursesPublic/OneSelfOrderModal";
import ShixunModal from "../coursesPublic/ShixunModal";
import PathModal from "../coursesPublic/PathModal";
import NewShixunModel from '../coursesPublic/NewShixunModel';
@ -227,10 +228,11 @@ class ShixunHomework extends Component{
addnametab:undefined,
typs:undefined,
starttimes:undefined,
OneSelftype:false
})
this.props.updataleftNavfun()
this.homeworkupdatalist(Coursename,page,order);
this.cancelmodel()
this.homeworkupdatalist(Coursename,page,order);
this.props.updataleftNavfun()
}
@ -272,6 +274,48 @@ class ShixunHomework extends Component{
});
}
//立即发布
homeworkOneSelfstart=()=>{
let selectnum= this.testonSelect();
if(selectnum===true){
this.noSelect();
return
}
let coursesId=this.props.match.params.coursesId;
let url="/courses/"+coursesId+"/all_course_groups.json";
axios.get(url).then((response) => {
if(response.status===200){
let starttime= this.props.getNowFormatDates(1);
let endtime=this.props.getNowFormatDates(2);
this.setState({
modalname:"立即发布",
modaltype:response.data.course_groups===null||response.data.course_groups.length===0?2:1,
OneSelftype:true,
typs:"start",
Topval:"学生将立即收到作业",
// Botvalleft:"暂不发布",
Botval:`本操作只对"未发布"的分班有效`,
starttime:"发布时间:"+moment(moment(new Date())).format("YYYY-MM-DD HH:mm"),
starttimes:starttime,
endtime:"截止时间:"+endtime,
Cancelname:"暂不发布",
Savesname:"立即发布",
Cancel:this.homeworkhide,
Saves:this.homeworkstartend,
course_groups:response.data.course_groups,
})
}
}).catch((error) => {
console.log(error)
});
}
cancelmodels=()=>{
this.setState({
Modalstype:false,
@ -316,10 +360,12 @@ class ShixunHomework extends Component{
})
}
this.props.showNotification(result.data.message)
this.props.updataleftNavfun()
this.homeworkupdatalist(Coursename,page,order);
this.cancelmodel()
this.props.showNotification(result.data.message)
this.props.updataleftNavfun()
}
}).catch((error)=>{
console.log(error);
@ -414,11 +460,11 @@ class ShixunHomework extends Component{
Loadtype:false,
course_groups:[]
})
this.props.showNotification(response.data.message)
this.props.updataleftNavfun()
this.homeworkupdatalist(Coursename,page,order);
this.cancelmodel()
this.props.showNotification(response.data.message)
this.props.updataleftNavfun()
}
})
.catch(function (error) {
@ -722,8 +768,8 @@ class ShixunHomework extends Component{
checkedtype:false,
antIcon:false
})
this.props.showNotification(response.data.message)
this.homeworkupdatalist(Coursename,page,order);
this.props.showNotification(response.data.message)
this.props.updataleftNavfun()
}else{
this.setState({
@ -782,6 +828,7 @@ class ShixunHomework extends Component{
this.setState({
Modalstype:false,
OneSelftype:false,
Loadtype:false,
visible:false,
Modalstopval:"",
@ -834,9 +881,10 @@ class ShixunHomework extends Component{
Loadtype:false,
checkBoxValues:[]
})
this.homeworkupdatalist(Coursename,page,order);
this.props.showNotification(response.data.message)
this.homeworkupdatalist(Coursename,page,order);
}
})
.catch(function (error) {
@ -886,9 +934,10 @@ class ShixunHomework extends Component{
checkBoxValues:[],
checkAllValue:false
})
this.homeworkupdatalist(Coursename,page,order);
this.props.showNotification('已完成')
this.props.updataleftNavfun()
this.homeworkupdatalist(Coursename,page,order);
}
})
}
@ -1022,7 +1071,7 @@ class ShixunHomework extends Component{
loadtype={this.state.Loadtype}
antIcon={this.state.antIcon}
/>:""}
{/*立即发布*/}
{/*批量立即发布*/}
{visible===true?<HomeworkModal
datas={datas}
category_id={this.props.match.params.category_id}
@ -1045,7 +1094,28 @@ class ShixunHomework extends Component{
getcourse_groupslist={(id)=>this.getcourse_groupslist(id)}
/>:""}
{/*{单个立即发布}*/}
{/*<OneSelfOrderModal*/}
{/*OneSelftype={this.state.OneSelftype}*/}
{/*datas={datas}*/}
{/*category_id={this.props.match.params.category_id}*/}
{/*modaltype={modaltype}*/}
{/*modalname={modalname}*/}
{/*Topval={Topval}*/}
{/*Topvalright={Topvalright}*/}
{/*Botvalleft={Botvalleft}*/}
{/*Botval={Botval}*/}
{/*starttime={starttime}*/}
{/*starttimes={this.state.starttimes}*/}
{/*typs={this.state.typs}*/}
{/*endtime={endtime}*/}
{/*Cancelname={Cancelname}*/}
{/*Savesname={Savesname}*/}
{/*Cancel={Cancel}*/}
{/*Saves={Saves}*/}
{/*course_groups={course_groups}*/}
{/*getcourse_groupslist={(id)=>this.getcourse_groupslist(id)}*/}
{/*/>*/}
{shixunmodal===true||shixunpath===true?<style>
{
`
@ -1128,6 +1198,8 @@ class ShixunHomework extends Component{
<Checkbox className="fl" style={{marginTop:'0px'}} checked={checkedtype} onClick={this.funselect}>已选 {checkBoxValues&&checkBoxValues.length} 不支持跨页勾选</Checkbox>
<div className="studentList_operation_ul">
<li className="li_line"><a className="color-grey-9" onClick={this.onDelete}>删除</a></li>
{/*{checkBoxValues&&checkBoxValues.length>1?<li className="li_line"><a className="color-grey-9" onClick={this.homeworkstart}>立即发布</a></li>*/}
{/*:<li className="li_line"><a className="color-grey-9" onClick={this.homeworkOneSelfstart}>单个立即发布</a></li>}*/}
<li className="li_line"><a className="color-grey-9" onClick={this.homeworkstart}>立即发布</a></li>
{/*onClick={this.homeworkstart}*/}
<li className="li_line"><a className="color-grey-9" onClick={this.homeworkends}>立即截止</a></li>

Loading…
Cancel
Save