update debug

dev_tpm_ui
tangjiang 5 years ago
parent fa3f779b4d
commit 6364cbd279

Binary file not shown.

@ -34,6 +34,7 @@ const NewOrEditTask = (props) => {
startProgramQuestion, startProgramQuestion,
getUserInfoForNew, getUserInfoForNew,
handleCancelPublish, handleCancelPublish,
validateOjForm,
// updateTestAndValidate, // updateTestAndValidate,
} = props; } = props;
@ -69,14 +70,20 @@ const NewOrEditTask = (props) => {
// 模拟挑战 // 模拟挑战
const imitationChallenge = () => { const imitationChallenge = () => {
// 调用 start 接口, 成功后跳转到模拟页面 // 先调用保存, 再调用 start 接口, 成功后跳转到模拟页面
identifier && startProgramQuestion(identifier, props); // identifier && startProgramQuestion(identifier, props);
identifier && validateOjForm(props, 'challenge', () => {
startProgramQuestion(identifier, props);
});
} }
// 开始挑战 // 开始挑战
const startChallenge = () => { const startChallenge = () => {
// 调用 start 接口, 成功后跳转到开启实战 // 调用 start 接口, 成功后跳转到开启实战
// TODO // TODO
identifier && startProgramQuestion(identifier, props); identifier && validateOjForm(props, 'challenge', () => {
startProgramQuestion(identifier, props);
});
// identifier && startProgramQuestion(identifier, props);
} }
// 取消 // 取消
@ -265,7 +272,8 @@ const mapDispatchToProps = (dispatch) => ({
// 开启模拟挑战 // 开启模拟挑战
startProgramQuestion: (id, props) => dispatch(actions.startProgramQuestion(id, props)), startProgramQuestion: (id, props) => dispatch(actions.startProgramQuestion(id, props)),
// 新建时获取信息 // 新建时获取信息
getUserInfoForNew: () => dispatch(actions.getUserInfoForNew()) getUserInfoForNew: () => dispatch(actions.getUserInfoForNew()),
validateOjForm: (props, type, cb) => dispatch(actions.validateOjForm(props, type, cb))
}); });
export default withRouter(connect( export default withRouter(connect(

@ -4,7 +4,7 @@
* @Github: * @Github:
* @Date: 2019-11-20 10:35:40 * @Date: 2019-11-20 10:35:40
* @LastEditors : tangjiang * @LastEditors : tangjiang
* @LastEditTime : 2019-12-27 10:37:58 * @LastEditTime : 2019-12-27 14:30:55
*/ */
import './index.scss'; import './index.scss';
// import 'katex/dist/katex.css'; // import 'katex/dist/katex.css';
@ -224,9 +224,9 @@ class EditTab extends React.Component {
// 描述信息变化时 // 描述信息变化时
const handleContentChange = (content, quill) => { const handleContentChange = (content, quill) => {
// console.log('描述信息为: ', content); // console.log('描述信息为: ', content);
// if (quill.getText()) const _text = quill.getText();
// console.log('========>>>>>', quill.getText().length); const reg = /^[\s\S]*.*[^\s][\s\S]*$/;
if (quill.getText().length === 1) { if (!reg.test(_text)) {
this.handleChangeDescription(''); this.handleChangeDescription('');
} else { } else {
// 保存获取的描述信息至redux中 // 保存获取的描述信息至redux中

@ -4,7 +4,7 @@
* @Github: * @Github:
* @Date: 2019-11-20 16:35:46 * @Date: 2019-11-20 16:35:46
* @LastEditors : tangjiang * @LastEditors : tangjiang
* @LastEditTime : 2019-12-26 15:45:28 * @LastEditTime : 2019-12-27 14:18:02
*/ */
import types from './actionTypes'; import types from './actionTypes';
import CONST from '../../constants'; import CONST from '../../constants';
@ -17,6 +17,7 @@ import {
import { Base64 } from 'js-base64'; import { Base64 } from 'js-base64';
import { notification } from 'antd'; import { notification } from 'antd';
import { toStore } from 'educoder'; import { toStore } from 'educoder';
// import { startProgramQuestion } from ''
const { jcLabel } = CONST; const { jcLabel } = CONST;
// 表单字段映射 // 表单字段映射
const maps = { const maps = {
@ -99,7 +100,7 @@ const payloadInfo = (key, value, errMsg, validateInfo) => ({
// } // }
// 表单提交验证 // 表单提交验证
export const validateOjForm = (props, type) => { export const validateOjForm = (props, type, cb) => {
return (dispatch, getState) => { return (dispatch, getState) => {
const {ojForm, testCases, identifier, code } = getState().ojFormReducer; const {ojForm, testCases, identifier, code } = getState().ojFormReducer;
// console.log('code', code); // console.log('code', code);
@ -247,44 +248,44 @@ export const validateOjForm = (props, type) => {
paramsObj['identifier'] = identifier; paramsObj['identifier'] = identifier;
} }
// 调用保存或更新 // 先调用保存接口
if (type === 'publish') { fetchPostOjForm(paramsObj).then(res => {
// 提示发布信息 if (res.status === 200) { // 保存成功后,重新跳转至列表页
publishTask(identifier).then(res => {
dispatch({
type: types.PUBLISH_LOADING_STATUS,
payload: false
});
if (res.data.status === 0) { if (res.data.status === 0) {
// message.success('发布成功!'); // 改变按钮loading状态
notification.success({
message: '提示',
description: '发布成功!'
});
// linkToDev(dispatch, props);
// 改变发布状态值 0 => 1
dispatch({ dispatch({
type: types.CHANGE_PUBLISH_VALUE, type: types.SUBMIT_LOADING_STATUS,
payload: 1 payload: false
}); });
} if (type === 'publish') {
}).catch(() => { publishTask(identifier).then(res => {
dispatch({ dispatch({
type: types.PUBLISH_LOADING_STATUS, type: types.PUBLISH_LOADING_STATUS,
payload: false payload: false
}); });
});
} else { if (res.data.status === 0) {
// 调用更新 // message.success('发布成功!');
fetchPostOjForm(paramsObj).then(res => { notification.success({
if (res.status === 200) { // 保存成功后,重新跳转至列表页 message: '提示',
if (res.data.status === 0) { description: '发布成功!'
// 改变按钮loading状态 });
dispatch({ // linkToDev(dispatch, props);
type: types.SUBMIT_LOADING_STATUS, // 改变发布状态值 0 => 1
payload: false dispatch({
type: types.CHANGE_PUBLISH_VALUE,
payload: 1
});
}
}).catch(() => {
dispatch({
type: types.PUBLISH_LOADING_STATUS,
payload: false
});
}); });
} else if (type === 'challenge') {
cb && cb();
} else {
// message.success(paramsObj['submitType'] === 'update' ? '更新成功' : '保存成功'); // message.success(paramsObj['submitType'] === 'update' ? '更新成功' : '保存成功');
notification.success({ notification.success({
message: '提示', message: '提示',
@ -296,17 +297,81 @@ export const validateOjForm = (props, type) => {
type: types.SAVE_OJ_FORM_ID, type: types.SAVE_OJ_FORM_ID,
payload: identifier payload: identifier
}); });
// 保存或更新后调用start接口
// linkToDev(dispatch, props);
} }
}} // 保存或更新后调用start接口
).catch(err => { // linkToDev(dispatch, props);
dispatch({ }
type: types.SUBMIT_LOADING_STATUS, }}
payload: false ).catch(err => {
}); dispatch({
type: types.SUBMIT_LOADING_STATUS,
payload: false
}); });
} dispatch({
type: types.PUBLISH_LOADING_STATUS,
payload: false
});
});
// 调用保存或更新
// if (type === 'publish') {
// // 提示发布信息
// publishTask(identifier).then(res => {
// dispatch({
// type: types.PUBLISH_LOADING_STATUS,
// payload: false
// });
// if (res.data.status === 0) {
// // message.success('发布成功!');
// notification.success({
// message: '提示',
// description: '发布成功!'
// });
// // linkToDev(dispatch, props);
// // 改变发布状态值 0 => 1
// dispatch({
// type: types.CHANGE_PUBLISH_VALUE,
// payload: 1
// });
// }
// }).catch(() => {
// dispatch({
// type: types.PUBLISH_LOADING_STATUS,
// payload: false
// });
// });
// } else {
// // 调用更新
// fetchPostOjForm(paramsObj).then(res => {
// if (res.status === 200) { // 保存成功后,重新跳转至列表页
// if (res.data.status === 0) {
// // 改变按钮loading状态
// dispatch({
// type: types.SUBMIT_LOADING_STATUS,
// payload: false
// });
// // message.success(paramsObj['submitType'] === 'update' ? '更新成功' : '保存成功');
// notification.success({
// message: '提示',
// description: paramsObj['submitType'] === 'update' ? '更新成功' : '保存成功'
// });
// const {identifier} = res.data;
// // 保存成功后的identifier
// identifier && dispatch({
// type: types.SAVE_OJ_FORM_ID,
// payload: identifier
// });
// // 保存或更新后调用start接口
// // linkToDev(dispatch, props);
// }
// }}
// ).catch(err => {
// dispatch({
// type: types.SUBMIT_LOADING_STATUS,
// payload: false
// });
// });
// }
} }
} }
}; };

Loading…
Cancel
Save