|
|
|
@ -9,7 +9,7 @@ import './index.scss';
|
|
|
|
|
import React, { useEffect } from 'react';
|
|
|
|
|
import { connect } from 'react-redux';
|
|
|
|
|
import SplitPane from 'react-split-pane';// import { Form } from 'antd';
|
|
|
|
|
import { Button } from 'antd';
|
|
|
|
|
import { Button, Modal } from 'antd';
|
|
|
|
|
import LeftPane from './leftpane';
|
|
|
|
|
import RightPane from './rightpane';
|
|
|
|
|
import { withRouter } from 'react-router';
|
|
|
|
@ -17,6 +17,7 @@ import { toStore } from 'educoder';
|
|
|
|
|
import UserInfo from '../components/userInfo';
|
|
|
|
|
// import RightPane from './rightpane/index';
|
|
|
|
|
import actions from '../../../redux/actions';
|
|
|
|
|
import {ModalConfirm} from '../../../common/components/ModalConfirm';
|
|
|
|
|
|
|
|
|
|
const NewOrEditTask = (props) => {
|
|
|
|
|
const {
|
|
|
|
@ -32,17 +33,18 @@ const NewOrEditTask = (props) => {
|
|
|
|
|
changePublishLoadingStatus,
|
|
|
|
|
startProgramQuestion,
|
|
|
|
|
getUserInfoForNew,
|
|
|
|
|
handleCancelPublish,
|
|
|
|
|
// updateTestAndValidate,
|
|
|
|
|
} = props;
|
|
|
|
|
|
|
|
|
|
// 表单提交
|
|
|
|
|
const handleSubmitForm = () => {
|
|
|
|
|
// 改变loading状态
|
|
|
|
|
changeSubmitLoadingStatus(true);
|
|
|
|
|
// 调用输入表单验证功能
|
|
|
|
|
if (props.identifier) {
|
|
|
|
|
props.handleUpdateOjForm(props);
|
|
|
|
|
} else {
|
|
|
|
|
// 改变loading状态
|
|
|
|
|
changeSubmitLoadingStatus(true);
|
|
|
|
|
props.handleFormSubmit(props); // 提交表单
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
@ -66,6 +68,9 @@ const NewOrEditTask = (props) => {
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
// 模拟挑战
|
|
|
|
|
const imitationChallenge = () => {
|
|
|
|
|
}
|
|
|
|
|
// 开始挑战
|
|
|
|
|
const startChallenge = () => {
|
|
|
|
|
// 调用 start 接口, 成功后跳转到模拟页面
|
|
|
|
|
startProgramQuestion(identifier, props);
|
|
|
|
@ -84,9 +89,20 @@ const NewOrEditTask = (props) => {
|
|
|
|
|
|
|
|
|
|
// 发布
|
|
|
|
|
const handleClickPublish = () => {
|
|
|
|
|
// console.log('public has click');
|
|
|
|
|
changePublishLoadingStatus(true);
|
|
|
|
|
handlePublish(props, 'publish');
|
|
|
|
|
ModalConfirm('提示', (<p>发布后即可应用到自己管理的课堂<br /> 是否确认发布?</p>), () => {
|
|
|
|
|
changePublishLoadingStatus(true);
|
|
|
|
|
handlePublish(props, 'publish');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
// 撤销发布
|
|
|
|
|
const handleClickCancelPublish = () => {
|
|
|
|
|
ModalConfirm('提示', (<p>是否确认撤销发布?</p>), () => {
|
|
|
|
|
changePublishLoadingStatus(true);
|
|
|
|
|
handleCancelPublish(props, identifier);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 取消保存/取消按钮
|
|
|
|
@ -107,20 +123,43 @@ const NewOrEditTask = (props) => {
|
|
|
|
|
}
|
|
|
|
|
// 发布/模拟挑战
|
|
|
|
|
const renderPubOrFight = () => {
|
|
|
|
|
const pubButton = isPublish ? '' : (<Button
|
|
|
|
|
type="primary"
|
|
|
|
|
loading={publishLoading}
|
|
|
|
|
onClick={handleClickPublish}
|
|
|
|
|
>立即发布</Button>);
|
|
|
|
|
const pubButton = isPublish
|
|
|
|
|
? (<Button
|
|
|
|
|
type="primary"
|
|
|
|
|
loading={publishLoading}
|
|
|
|
|
onClick={handleClickCancelPublish}
|
|
|
|
|
>撤销发布</Button>)
|
|
|
|
|
: (<Button
|
|
|
|
|
type="primary"
|
|
|
|
|
loading={publishLoading}
|
|
|
|
|
onClick={handleClickPublish}
|
|
|
|
|
>立即发布</Button>);
|
|
|
|
|
// 未发布: 模拟挑战 已发布: 开始挑战
|
|
|
|
|
const challengeBtn = isPublish ? (
|
|
|
|
|
<Button type="primary" onClick={startChallenge}>开始挑战</Button>
|
|
|
|
|
) : (
|
|
|
|
|
<Button type="primary" onClick={imitationChallenge}>模拟挑战</Button>
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// 更新
|
|
|
|
|
// const updateBtn = isPublish
|
|
|
|
|
// ? ''
|
|
|
|
|
// : (
|
|
|
|
|
// <Button
|
|
|
|
|
// type="primary"
|
|
|
|
|
// loading={submitLoading}
|
|
|
|
|
// onClick={handleSubmitForm}
|
|
|
|
|
// >更新</Button>
|
|
|
|
|
// );
|
|
|
|
|
return (
|
|
|
|
|
<React.Fragment>
|
|
|
|
|
<Button
|
|
|
|
|
type="primary"
|
|
|
|
|
loading={submitLoading}
|
|
|
|
|
onClick={handleSubmitForm}
|
|
|
|
|
>更新</Button>
|
|
|
|
|
<Button
|
|
|
|
|
type="primary"
|
|
|
|
|
loading={submitLoading}
|
|
|
|
|
onClick={handleSubmitForm}
|
|
|
|
|
>更新</Button>
|
|
|
|
|
{pubButton}
|
|
|
|
|
<Button type="primary" onClick={startChallenge}>模拟挑战</Button>
|
|
|
|
|
{challengeBtn}
|
|
|
|
|
</React.Fragment>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
@ -142,24 +181,9 @@ const NewOrEditTask = (props) => {
|
|
|
|
|
return (
|
|
|
|
|
<div className={'new_add_task_wrap'}>
|
|
|
|
|
<div className={'task_header'}>
|
|
|
|
|
{/* <Link to="/problems" className={'header_btn'} >
|
|
|
|
|
<Icon type="left" style={{ marginRight: '5px'}}/>后退
|
|
|
|
|
</Link> */}
|
|
|
|
|
<UserInfo userInfo={userInfo}/>
|
|
|
|
|
<p className={'header_title'}>{props.name || ''}</p>
|
|
|
|
|
{ renderQuit() }
|
|
|
|
|
{/* <Link style={{
|
|
|
|
|
position: 'absolute',
|
|
|
|
|
right: '30px',
|
|
|
|
|
top: 0,
|
|
|
|
|
color: '#5091FF'
|
|
|
|
|
}} to="/problems">退出</Link> */}
|
|
|
|
|
{/* <Button
|
|
|
|
|
style={{ display: identifier ? 'none' : 'block'}}
|
|
|
|
|
loading={publishLoading}
|
|
|
|
|
className={`header_btn`}
|
|
|
|
|
type="primary"
|
|
|
|
|
onClick={handleClickPublish}>立即发布</Button> */}
|
|
|
|
|
</div>
|
|
|
|
|
<div className="split-pane-area">
|
|
|
|
|
<SplitPane split="vertical" minSize={350} maxSize={-350} defaultSize="40%">
|
|
|
|
@ -206,6 +230,8 @@ const mapDispatchToProps = (dispatch) => ({
|
|
|
|
|
handleFormSubmit: (props) => dispatch(actions.validateOjForm(props)),
|
|
|
|
|
// 发布表单
|
|
|
|
|
handlePublish: (props, type) => dispatch(actions.validateOjForm(props, type)),
|
|
|
|
|
// 撤销发布
|
|
|
|
|
handleCancelPublish: (props, identifier) => dispatch(actions.handleClickCancelPublish(props, identifier)),
|
|
|
|
|
// 更新OJForm
|
|
|
|
|
handleUpdateOjForm: (props) => dispatch(actions.validateOjForm(props)),
|
|
|
|
|
// 根据id号获取表单信息
|
|
|
|
|