|
|
|
@ -35,7 +35,9 @@ const NewOrEditTask = (props) => {
|
|
|
|
|
getUserInfoForNew,
|
|
|
|
|
handleCancelPublish,
|
|
|
|
|
validateOjForm,
|
|
|
|
|
getQuestion
|
|
|
|
|
getQuestion,
|
|
|
|
|
saveSearchParams,
|
|
|
|
|
setOjInitialValue
|
|
|
|
|
// updateTestAndValidate,
|
|
|
|
|
} = props;
|
|
|
|
|
|
|
|
|
@ -61,7 +63,26 @@ const NewOrEditTask = (props) => {
|
|
|
|
|
// console.log('获取路由参数: ====', props.match.params);
|
|
|
|
|
const id = props.match.params.id;
|
|
|
|
|
// 保存OJForm的id号,指明是编辑还是新增
|
|
|
|
|
props.saveOJFormId(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']) {
|
|
|
|
|
setOjInitialValue({
|
|
|
|
|
difficult: obj['difficult'],
|
|
|
|
|
sub_discipline_id: obj['sub_discipline_id'],
|
|
|
|
|
tag_discipline_id: obj['tag_discipline_id'] && obj['tag_discipline_id'].split(',')
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
saveSearchParams({searchParams: $searchs, curPage: obj['pages']});
|
|
|
|
|
}
|
|
|
|
|
if (id) { // id号即 identifier
|
|
|
|
|
// TODO id 存在时, 编辑, 获取 store 中的记录数
|
|
|
|
|
props.getOJFormById(id);
|
|
|
|
@ -96,7 +117,8 @@ const NewOrEditTask = (props) => {
|
|
|
|
|
props.clearOJFormStore();
|
|
|
|
|
// 清空描述信息
|
|
|
|
|
toStore('oj_description', '');
|
|
|
|
|
props.history.push('/problems');
|
|
|
|
|
// props.history.push('/problems');
|
|
|
|
|
props.history.push(`/question?${props.searchParams}`);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 发布
|
|
|
|
@ -236,7 +258,7 @@ const NewOrEditTask = (props) => {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const mapStateToProps = (state) => {
|
|
|
|
|
const { ojForm, identifier, testCases, isPublish } = state.ojFormReducer;
|
|
|
|
|
const { ojForm, identifier, testCases, isPublish, searchParams } = state.ojFormReducer;
|
|
|
|
|
const { publishLoading, submitLoading } = state.commonReducer;
|
|
|
|
|
const { userInfo } = state.userReducer;
|
|
|
|
|
return {
|
|
|
|
@ -246,7 +268,8 @@ const mapStateToProps = (state) => {
|
|
|
|
|
isPublish, // 是否已发布
|
|
|
|
|
publishLoading,
|
|
|
|
|
submitLoading,
|
|
|
|
|
userInfo
|
|
|
|
|
userInfo,
|
|
|
|
|
searchParams
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
@ -278,7 +301,9 @@ const mapDispatchToProps = (dispatch) => ({
|
|
|
|
|
// 新建时获取信息
|
|
|
|
|
getUserInfoForNew: () => dispatch(actions.getUserInfoForNew()),
|
|
|
|
|
validateOjForm: (props, type, cb) => dispatch(actions.validateOjForm(props, type, cb)),
|
|
|
|
|
getQuestion: (params) => dispatch(actions.getQuestion(params))
|
|
|
|
|
getQuestion: (params) => dispatch(actions.getQuestion(params)),
|
|
|
|
|
saveSearchParams: (params) => dispatch(actions.saveSearchParams(params)),
|
|
|
|
|
setOjInitialValue: (params) => dispatch(actions.setOjInitialValue(params))
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export default withRouter(connect(
|
|
|
|
|