|
|
|
@ -4,7 +4,7 @@
|
|
|
|
|
* @Github:
|
|
|
|
|
* @Date: 2019-11-20 16:35:46
|
|
|
|
|
* @LastEditors : tangjiang
|
|
|
|
|
* @LastEditTime : 2019-12-26 15:45:28
|
|
|
|
|
* @LastEditTime : 2019-12-27 14:18:02
|
|
|
|
|
*/
|
|
|
|
|
import types from './actionTypes';
|
|
|
|
|
import CONST from '../../constants';
|
|
|
|
@ -17,6 +17,7 @@ import {
|
|
|
|
|
import { Base64 } from 'js-base64';
|
|
|
|
|
import { notification } from 'antd';
|
|
|
|
|
import { toStore } from 'educoder';
|
|
|
|
|
// import { startProgramQuestion } from ''
|
|
|
|
|
const { jcLabel } = CONST;
|
|
|
|
|
// 表单字段映射
|
|
|
|
|
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) => {
|
|
|
|
|
const {ojForm, testCases, identifier, code } = getState().ojFormReducer;
|
|
|
|
|
// console.log('code', code);
|
|
|
|
@ -247,9 +248,16 @@ export const validateOjForm = (props, type) => {
|
|
|
|
|
paramsObj['identifier'] = identifier;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 调用保存或更新
|
|
|
|
|
// 先调用保存接口
|
|
|
|
|
fetchPostOjForm(paramsObj).then(res => {
|
|
|
|
|
if (res.status === 200) { // 保存成功后,重新跳转至列表页
|
|
|
|
|
if (res.data.status === 0) {
|
|
|
|
|
// 改变按钮loading状态
|
|
|
|
|
dispatch({
|
|
|
|
|
type: types.SUBMIT_LOADING_STATUS,
|
|
|
|
|
payload: false
|
|
|
|
|
});
|
|
|
|
|
if (type === 'publish') {
|
|
|
|
|
// 提示发布信息
|
|
|
|
|
publishTask(identifier).then(res => {
|
|
|
|
|
dispatch({
|
|
|
|
|
type: types.PUBLISH_LOADING_STATUS,
|
|
|
|
@ -275,16 +283,9 @@ export const validateOjForm = (props, type) => {
|
|
|
|
|
payload: false
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
} else if (type === 'challenge') {
|
|
|
|
|
cb && cb();
|
|
|
|
|
} 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: '提示',
|
|
|
|
@ -296,6 +297,7 @@ export const validateOjForm = (props, type) => {
|
|
|
|
|
type: types.SAVE_OJ_FORM_ID,
|
|
|
|
|
payload: identifier
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
// 保存或更新后,调用start接口
|
|
|
|
|
// linkToDev(dispatch, props);
|
|
|
|
|
}
|
|
|
|
@ -305,8 +307,71 @@ export const validateOjForm = (props, type) => {
|
|
|
|
|
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
|
|
|
|
|
// });
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|