/* * @Description: 新建或编辑任务 * @Author: tangjiang * @Date: 2019-11-15 16:38:34 * @Last Modified by: tangjiang * @Last Modified time: 2019-11-19 23:23:41 */ import './index.less'; 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 LeftPane from './leftpane'; import RightPane from './rightpane'; import { withRouter } from 'react-router'; import { toStore, CNotificationHOC } 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 { publishLoading, handlePublish, // testCases = [], // ojTestCaseValidate = [], identifier, isPublish, userInfo, submitLoading, changeSubmitLoadingStatus, changePublishLoadingStatus, startProgramQuestion, getUserInfoForNew, handleCancelPublish, validateOjForm, getQuestion, saveSearchParams, setOjInitialValue, courseQuestions // updateTestAndValidate, } = props; // 表单提交 const handleSubmitForm = () => { // 改变loading状态 changeSubmitLoadingStatus(true); // 调用输入表单验证功能 if (props.identifier) { props.handleUpdateOjForm(props); } else { props.handleFormSubmit(props); // 提交表单 } }; useEffect(() => { // 获取用户信息 getUserInfoForNew(); // console.log('获取路由参数: ====', props.match.params); const id = props.match.params.id; // 保存OJForm的id号,指明是编辑还是新增 props.saveOJFormId(id); // 获取地址栏查询参数 const $searchs = window.location.search && window.location.search.substring(1); if ($searchs) { const $params = $searchs.split('&') || []; let obj = Object.create(null); $params.forEach(item => { const keys = item.split('='); obj[keys[0]] = keys[1]; }); // 保存初始值 if (obj['newoj']) { const tags = obj['tag_discipline_id']; const tag_arrs = (tags && tags.split(',').map(tag => +tag)) || []; setOjInitialValue({ difficult: obj['difficult'], sub_discipline_id: obj['sub_discipline_id'], tag_discipline_id: tag_arrs }); } saveSearchParams({searchParams: $searchs, curPage: obj['pages']}); } // 获取课程列表 getQuestion({ source: 'question' }); if (id) { // id号即 identifier // TODO id 存在时, 编辑, 获取 store 中的记录数 props.getOJFormById(id); } else { // 清空store中的测试用例集合 // props.clearOJFormStore(); } return () => { } }, []); // 模拟挑战 const imitationChallenge = () => { // 先调用保存, 再调用 start 接口, 成功后跳转到模拟页面 // identifier && startProgramQuestion(identifier, props); identifier && validateOjForm(props, 'challenge', () => { startProgramQuestion(identifier, props); }); } // 开始挑战 const startChallenge = () => { // 调用 start 接口, 成功后跳转到开启实战 // TODO identifier && validateOjForm(props, 'challenge', () => { startProgramQuestion(identifier, props); }); // identifier && startProgramQuestion(identifier, props); } // 取消 const handleClickCancel = () => { // 清空当前输入值并跳转至列表页 props.clearOJFormStore(); // 清空描述信息 toStore('oj_description', ''); // props.history.push('/problems'); props.history.push(`/question?${props.searchParams}`); } // 发布 const handleClickPublish = () => { // ModalConfirm('提示', (
发布后即可应用到自己管理的课堂
是否确认发布?
发布后即可应用到自己管理的课堂
是否确认发布?
是否确认撤销发布?
), () => { // changePublishLoadingStatus(true); // handleCancelPublish(props, identifier); // }); props.confirm({ title: '提示', content: ((是否确认撤销发布?
)), onOk() { changePublishLoadingStatus(true); handleCancelPublish(props, identifier); } }); } // 取消保存/取消按钮 const renderSaveOrCancel = () => { return ({props.name || ''}
{renderQuit()}