From d87af3e29b119910ad8dcc8c327fbe1ef7c4a123 Mon Sep 17 00:00:00 2001 From: tangjiang <465264938@qq.com> Date: Tue, 11 Feb 2020 16:47:21 +0800 Subject: [PATCH] optimize oj knowledge --- .../developer/components/knowledge/index.js | 3 +-- .../modules/developer/newOrEditTask/index.js | 20 +++++++++++-------- .../newOrEditTask/leftpane/editorTab/index.js | 4 ++-- public/react/src/redux/actions/ojForm.js | 4 ++-- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/public/react/src/modules/developer/components/knowledge/index.js b/public/react/src/modules/developer/components/knowledge/index.js index 9598037ab..0a1e00125 100644 --- a/public/react/src/modules/developer/components/knowledge/index.js +++ b/public/react/src/modules/developer/components/knowledge/index.js @@ -4,7 +4,7 @@ * @Github: * @Date: 2019-12-30 13:51:19 * @LastEditors : tangjiang - * @LastEditTime : 2020-01-07 15:46:24 + * @LastEditTime : 2020-02-11 16:34:18 */ import './index.scss'; import React, { useState, useEffect } from 'react'; @@ -22,7 +22,6 @@ function KnowLedge (props) { showAdd, // 显示新增图标 addKnowledge // 调用新增知识点接口 } = props; - useEffect(() => { const _options = []; const _selects = []; diff --git a/public/react/src/modules/developer/newOrEditTask/index.js b/public/react/src/modules/developer/newOrEditTask/index.js index 86dc066b6..565d6af30 100644 --- a/public/react/src/modules/developer/newOrEditTask/index.js +++ b/public/react/src/modules/developer/newOrEditTask/index.js @@ -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 } }; diff --git a/public/react/src/modules/developer/newOrEditTask/leftpane/editorTab/index.js b/public/react/src/modules/developer/newOrEditTask/leftpane/editorTab/index.js index 6fc264663..afa68fb23 100644 --- a/public/react/src/modules/developer/newOrEditTask/leftpane/editorTab/index.js +++ b/public/react/src/modules/developer/newOrEditTask/leftpane/editorTab/index.js @@ -4,7 +4,7 @@ * @Github: * @Date: 2019-11-20 10:35:40 * @LastEditors : tangjiang - * @LastEditTime : 2020-01-10 15:06:23 + * @LastEditTime : 2020-02-11 16:44:57 */ import './index.scss'; // import 'katex/dist/katex.css'; @@ -61,7 +61,7 @@ class EditTab extends React.Component { top: 500, bottom: 20, offsetTop: 0, - showAdd: false + showAdd: props.tag_discipline_id || false // knowledges: [], // coursers: [] // 选中的课程 } diff --git a/public/react/src/redux/actions/ojForm.js b/public/react/src/redux/actions/ojForm.js index 9098dae81..e6fe1309e 100644 --- a/public/react/src/redux/actions/ojForm.js +++ b/public/react/src/redux/actions/ojForm.js @@ -4,7 +4,7 @@ * @Github: * @Date: 2019-11-20 16:35:46 * @LastEditors : tangjiang - * @LastEditTime : 2020-02-10 18:09:17 + * @LastEditTime : 2020-02-11 16:29:32 */ import types from './actionTypes'; import CONST from '../../constants'; @@ -696,7 +696,7 @@ export const getQuestion = (params) => { disciplines.forEach(c => { if (sub_discipline_id && c.sub_disciplines) { c.sub_disciplines.forEach(sub => { - if (+sub.id === sub_discipline_id) { + if (+sub.id === +sub_discipline_id) { temp_knowledges = sub.tag_disciplines || []; } });