|
|
|
@ -37,7 +37,8 @@ const NewOrEditTask = (props) => {
|
|
|
|
|
validateOjForm,
|
|
|
|
|
getQuestion,
|
|
|
|
|
saveSearchParams,
|
|
|
|
|
setOjInitialValue
|
|
|
|
|
setOjInitialValue,
|
|
|
|
|
courseQuestions
|
|
|
|
|
// updateTestAndValidate,
|
|
|
|
|
} = props;
|
|
|
|
|
|
|
|
|
@ -56,10 +57,6 @@ const NewOrEditTask = (props) => {
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
// 获取用户信息
|
|
|
|
|
getUserInfoForNew();
|
|
|
|
|
// 获取课程列表
|
|
|
|
|
getQuestion({
|
|
|
|
|
source: 'question'
|
|
|
|
|
});
|
|
|
|
|
// console.log('获取路由参数: ====', props.match.params);
|
|
|
|
|
const id = props.match.params.id;
|
|
|
|
|
// 保存OJForm的id号,指明是编辑还是新增
|
|
|
|
@ -75,14 +72,20 @@ const NewOrEditTask = (props) => {
|
|
|
|
|
});
|
|
|
|
|
// 保存初始值
|
|
|
|
|
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: obj['tag_discipline_id'] && obj['tag_discipline_id'].split(',')
|
|
|
|
|
tag_discipline_id: tag_arrs
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
saveSearchParams({searchParams: $searchs, curPage: obj['pages']});
|
|
|
|
|
}
|
|
|
|
|
// 获取课程列表
|
|
|
|
|
getQuestion({
|
|
|
|
|
source: 'question'
|
|
|
|
|
});
|
|
|
|
|
if (id) { // id号即 identifier
|
|
|
|
|
// TODO id 存在时, 编辑, 获取 store 中的记录数
|
|
|
|
|
props.getOJFormById(id);
|
|
|
|
@ -258,7 +261,7 @@ const NewOrEditTask = (props) => {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const mapStateToProps = (state) => {
|
|
|
|
|
const { ojForm, identifier, testCases, isPublish, searchParams } = state.ojFormReducer;
|
|
|
|
|
const { ojForm, identifier, testCases, isPublish, searchParams, courseQuestions } = state.ojFormReducer;
|
|
|
|
|
const { publishLoading, submitLoading } = state.commonReducer;
|
|
|
|
|
const { userInfo } = state.userReducer;
|
|
|
|
|
return {
|
|
|
|
@ -269,7 +272,8 @@ const mapStateToProps = (state) => {
|
|
|
|
|
publishLoading,
|
|
|
|
|
submitLoading,
|
|
|
|
|
userInfo,
|
|
|
|
|
searchParams
|
|
|
|
|
searchParams,
|
|
|
|
|
courseQuestions
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|