|
|
|
@ -4,7 +4,7 @@
|
|
|
|
|
* @Github:
|
|
|
|
|
* @Date: 2019-11-20 10:35:40
|
|
|
|
|
* @LastEditors : tangjiang
|
|
|
|
|
* @LastEditTime : 2019-12-31 15:17:08
|
|
|
|
|
* @LastEditTime : 2020-01-02 17:42:04
|
|
|
|
|
*/
|
|
|
|
|
import './index.scss';
|
|
|
|
|
// import 'katex/dist/katex.css';
|
|
|
|
@ -61,7 +61,8 @@ class EditTab extends React.Component {
|
|
|
|
|
top: 500,
|
|
|
|
|
bottom: 20,
|
|
|
|
|
offsetTop: 0,
|
|
|
|
|
knowledges: []
|
|
|
|
|
// knowledges: [],
|
|
|
|
|
// coursers: [] // 选中的课程
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -80,12 +81,16 @@ class EditTab extends React.Component {
|
|
|
|
|
this.state.scrollEl.addEventListener('scroll', this.handleScroll, false);
|
|
|
|
|
});
|
|
|
|
|
// 获取题库
|
|
|
|
|
this.props.getQuestion({
|
|
|
|
|
source: 'question'
|
|
|
|
|
});
|
|
|
|
|
// this.props.getQuestion({
|
|
|
|
|
// source: 'question'
|
|
|
|
|
// });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
componentWillUnmount () {
|
|
|
|
|
// componentDidUpdate (nextProp) {
|
|
|
|
|
// console.log(nextProp);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
componentWillUnmount (nextPro) {
|
|
|
|
|
this.state.scrollEl.removeEventListener('scroll', this.handleScroll, false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -131,30 +136,25 @@ class EditTab extends React.Component {
|
|
|
|
|
handleTimeLimitChange = (value) => {
|
|
|
|
|
this.props.validateOjTimeLimit(value);
|
|
|
|
|
}
|
|
|
|
|
// 改变分类
|
|
|
|
|
handleChangeCategory = (value) => {
|
|
|
|
|
// 改变方向
|
|
|
|
|
handleChangeSubDisciplineId = (value) => {
|
|
|
|
|
// 课程下拉值变化时, 同步更新知识点
|
|
|
|
|
const { courseQuestions } = this.props;
|
|
|
|
|
this.setState({
|
|
|
|
|
knowledges: []
|
|
|
|
|
});
|
|
|
|
|
const { courseQuestions, saveKnowledge } = this.props;
|
|
|
|
|
saveKnowledge([]);
|
|
|
|
|
// 获取当前分类下的知识点
|
|
|
|
|
courseQuestions.forEach(item => {
|
|
|
|
|
if (value[0] && item.id === value[0]) {
|
|
|
|
|
item.sub_disciplines && item.sub_disciplines.forEach(c => {
|
|
|
|
|
if (value[1] && c.id === value[1]) {
|
|
|
|
|
this.setState({
|
|
|
|
|
knowledges: [...c.tag_disciplines]
|
|
|
|
|
});
|
|
|
|
|
saveKnowledge(...c.tag_disciplines)
|
|
|
|
|
} else if (!value[1]) {
|
|
|
|
|
this.setState({
|
|
|
|
|
knowledges: []
|
|
|
|
|
});
|
|
|
|
|
saveKnowledge([]);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
this.props.validateOjCategory(value[1] || '');
|
|
|
|
|
// this.props.validateOjCategory(value[1] || '');
|
|
|
|
|
this.props.validateOjSubDisciplineId(value[1] || '');
|
|
|
|
|
}
|
|
|
|
|
// 改变公开程序
|
|
|
|
|
handleChangeOpenOrNot = (value) => {
|
|
|
|
@ -174,9 +174,12 @@ class EditTab extends React.Component {
|
|
|
|
|
deleteTestCase, // 删除测试用例
|
|
|
|
|
testCasesValidate,
|
|
|
|
|
openTestCodeIndex = [],
|
|
|
|
|
courseQuestions
|
|
|
|
|
courseQuestions,
|
|
|
|
|
tag_discipline_id,
|
|
|
|
|
knowledges
|
|
|
|
|
} = this.props;
|
|
|
|
|
const {knowledges} = this.state;
|
|
|
|
|
console.log('+++++++++', knowledges);
|
|
|
|
|
// const {knowledges} = this.state;
|
|
|
|
|
// 表单label
|
|
|
|
|
const myLabel = (name, subTitle, nostar) => {
|
|
|
|
|
if (subTitle) {
|
|
|
|
@ -285,6 +288,7 @@ class EditTab extends React.Component {
|
|
|
|
|
|
|
|
|
|
const renderCourseQuestion = (arrs) => {
|
|
|
|
|
const tempArr = [];
|
|
|
|
|
const sub_id = this.props.ojForm.sub_discipline_id;
|
|
|
|
|
function loop (arrs, tempArr) {
|
|
|
|
|
arrs.forEach(item => {
|
|
|
|
|
const obj = {};
|
|
|
|
@ -300,37 +304,30 @@ class EditTab extends React.Component {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
loop(arrs, tempArr);
|
|
|
|
|
// arrs.forEach(item => {
|
|
|
|
|
// const obj = Object.create(null);
|
|
|
|
|
// obj.value = item.id;
|
|
|
|
|
// obj.label = item.name;
|
|
|
|
|
// if (item.sub_disciplines) {
|
|
|
|
|
// obj.children = [];
|
|
|
|
|
// item.sub_disciplines.forEach(sub => {
|
|
|
|
|
// const subObj = Object.create(null);
|
|
|
|
|
// subObj.value = sub.id;
|
|
|
|
|
// subObj.label = sub.name;
|
|
|
|
|
|
|
|
|
|
// if (sub.tag_disciplines) {
|
|
|
|
|
// subObj.children = [];
|
|
|
|
|
// sub.tag_disciplines.forEach(tag => {
|
|
|
|
|
// const tabObj = Object.create(null);
|
|
|
|
|
// tabObj.value = tag.id;
|
|
|
|
|
// tabObj.label = tag.name;
|
|
|
|
|
// subObj.children.push(tabObj);
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
// obj.children.push(subObj);
|
|
|
|
|
// })
|
|
|
|
|
// }
|
|
|
|
|
// tempArr.push(obj);
|
|
|
|
|
// });
|
|
|
|
|
console.log(tempArr);
|
|
|
|
|
|
|
|
|
|
// 获取选中的下拉值
|
|
|
|
|
let choid_ids = [];
|
|
|
|
|
// let tempKnowledges = [];
|
|
|
|
|
tempArr.forEach(t => {
|
|
|
|
|
// debugger;
|
|
|
|
|
if (sub_id && t.children) {
|
|
|
|
|
t.children.forEach(c => {
|
|
|
|
|
if (c.value === sub_id) {
|
|
|
|
|
choid_ids = [t.value, c.value];
|
|
|
|
|
// tempKnowledges = c.children || [];
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
console.log(choid_ids);
|
|
|
|
|
return (
|
|
|
|
|
<Cascader
|
|
|
|
|
options={tempArr}
|
|
|
|
|
expandTrigger="hover"
|
|
|
|
|
onChange={this.handleChangeCategory}
|
|
|
|
|
value={choid_ids}
|
|
|
|
|
// onChange={this.handleChangeCategory}
|
|
|
|
|
onChange={this.handleChangeSubDisciplineId}
|
|
|
|
|
/>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
@ -342,6 +339,8 @@ class EditTab extends React.Component {
|
|
|
|
|
_result.push(v.id);
|
|
|
|
|
});
|
|
|
|
|
console.log('下拉选择的值:===>>>', _result);
|
|
|
|
|
// 保存选择的知识点
|
|
|
|
|
this.props.saveTagDisciplineId(_result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
@ -361,9 +360,9 @@ class EditTab extends React.Component {
|
|
|
|
|
|
|
|
|
|
<FormItem
|
|
|
|
|
className={`input_area flex_50 flex_50_right`}
|
|
|
|
|
label={<span>{myLabel(jcLabel['category'], '合理的课程分类有利于快速检索')}</span>}
|
|
|
|
|
validateStatus={ojFormValidate.category.validateStatus}
|
|
|
|
|
help={ojFormValidate.category.errMsg}
|
|
|
|
|
label={<span>{myLabel(jcLabel['sub_discipline_id'], '合理的课程分类有利于快速检索')}</span>}
|
|
|
|
|
validateStatus={ojFormValidate.sub_discipline_id.validateStatus}
|
|
|
|
|
help={ojFormValidate.sub_discipline_id.errMsg}
|
|
|
|
|
colon={ false }
|
|
|
|
|
>
|
|
|
|
|
{/* <Select onChange={this.handleChangeCategory} value={`${ojForm.category}`}>
|
|
|
|
@ -384,6 +383,7 @@ class EditTab extends React.Component {
|
|
|
|
|
>
|
|
|
|
|
<KnowLedge
|
|
|
|
|
options={knowledges}
|
|
|
|
|
values={tag_discipline_id}
|
|
|
|
|
onChange={handleKnowledgeChange}
|
|
|
|
|
/>
|
|
|
|
|
</FormItem>
|
|
|
|
@ -480,7 +480,9 @@ const mapStateToProps = (state) => {
|
|
|
|
|
openTestCodeIndex,
|
|
|
|
|
testCasesValidate,
|
|
|
|
|
ojFormValidate,
|
|
|
|
|
courseQuestions
|
|
|
|
|
courseQuestions,
|
|
|
|
|
tag_discipline_id,
|
|
|
|
|
knowledges
|
|
|
|
|
} = ojFormReducer;
|
|
|
|
|
return {
|
|
|
|
|
ojForm,
|
|
|
|
@ -489,7 +491,9 @@ const mapStateToProps = (state) => {
|
|
|
|
|
ojFormValidate,
|
|
|
|
|
position,
|
|
|
|
|
openTestCodeIndex,
|
|
|
|
|
courseQuestions
|
|
|
|
|
courseQuestions,
|
|
|
|
|
tag_discipline_id,
|
|
|
|
|
knowledges
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
@ -502,12 +506,15 @@ const mapDispatchToProps = (dispatch) => ({
|
|
|
|
|
validateOjTimeLimit: (value) => dispatch(actions.validateOjTimeLimit(value)),
|
|
|
|
|
validateOjCategory: (value) => dispatch(actions.validateOjCategory(value)),
|
|
|
|
|
validateOpenOrNot: (value) => dispatch(actions.validateOpenOrNot(value)),
|
|
|
|
|
validateOjSubDisciplineId: (value) => dispatch(actions.validateOjSubDisciplineId(value)),
|
|
|
|
|
saveTagDisciplineId: (value) => dispatch(actions.saveTagDisciplineId(value)),
|
|
|
|
|
// 新增测试用例
|
|
|
|
|
addTestCase: (value) => dispatch(actions.addTestCase(value)),
|
|
|
|
|
// 删除测试用例
|
|
|
|
|
deleteTestCase: (value) => dispatch(actions.deleteTestCase(value)),
|
|
|
|
|
saveKnowledge: (value) => dispatch(actions.saveKnowledge(value))
|
|
|
|
|
// 获取题库
|
|
|
|
|
getQuestion: (params) => dispatch(actions.getQuestion(params))
|
|
|
|
|
// getQuestion: (params) => dispatch(actions.getQuestion(params))
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export default connect(
|
|
|
|
|