dev_new_shixunsrepository
tangjiang 5 years ago
parent 983815b9e7
commit a2e80d190c

@ -4,7 +4,7 @@
* @Github:
* @Date: 2019-12-30 13:51:19
* @LastEditors : tangjiang
* @LastEditTime : 2019-12-30 20:08:09
* @LastEditTime : 2019-12-30 20:44:38
*/
import './index.scss';
import React, { useState, useEffect } from 'react';
@ -32,26 +32,35 @@ function KnowLedge (props) {
// 渲染下拉选项
const renderOptions = (options = []) => {
console.log('下拉选择: ', options);
return options.map((opt, i) => (
<Option key={`opt_${i}`} value={`${opt.id}`}>{opt.name}</Option>
));
}
// 过滤下拉列表项
const handleSelectChange = (value) => {
console.log('过滤结果Start=====》》》》》', selectOptions, value);
value = +value.join('');
const tempArr = [...selectValue];
const _result = selectOptions.filter(item => {
if (item === value) {
if (item.id === value && tempArr.findIndex(t => t.id === value) === -1) {
tempArr.push(item);
}
return item !== value;
return item.id !== value;
});
console.log('过滤结果=====》》》》》', _result, selectOptions);
console.log(tempArr)
setSelectValue(tempArr);
setSelectOptions(_result);
}
// 渲染下拉结果
const renderResult = (arrs) => {
return arrs.map(item => (
<div className="knowledge-item" key={`item_$(item.id)`}>
<span className="knowledge-item-txt"></span>
</div>
));
}
// 渲染下拉列表
const renderSelect = (options, values) => {
console.log('==========>>>>>>>>', options);
const renderSelect = (options) => {
return (
<Select
value={value}
@ -67,7 +76,11 @@ function KnowLedge (props) {
return (
<div className="knowledge-select-area">
{ renderSelect(selectOptions, selectValue) }
{ renderSelect(selectOptions) }
{/* 渲染下拉选择项 */}
<div className="knowledge-result">
{ renderResult(selectValue) }
</div>
</div>
);
}

@ -4,7 +4,7 @@
* @Github:
* @Date: 2019-11-20 10:35:40
* @LastEditors : tangjiang
* @LastEditTime : 2019-12-30 20:09:30
* @LastEditTime : 2019-12-30 20:18:20
*/
import './index.scss';
// import 'katex/dist/katex.css';
@ -135,6 +135,9 @@ class EditTab extends React.Component {
handleChangeCategory = (value) => {
// 课程下拉值变化时, 同步更新知识点
const { courseQuestions } = this.props;
this.setState({
knowledges: []
});
courseQuestions.forEach(item => {
if (value[0] && item.id === value[0]) {
item.sub_disciplines && item.sub_disciplines.forEach(c => {
@ -142,16 +145,12 @@ class EditTab extends React.Component {
this.setState({
knowledges: [...c.tag_disciplines]
});
} else {
} else if (!value[1]) {
this.setState({
knowledges: []
});
}
});
} else {
this.setState({
knowledges: []
});
}
});
}

Loading…
Cancel
Save