dev_new_shixunsrepository
tangjiang 5 years ago
parent 298f8ca989
commit 36fd6d98ae

@ -4,10 +4,10 @@
* @Github: * @Github:
* @Date: 2019-12-30 13:51:19 * @Date: 2019-12-30 13:51:19
* @LastEditors : tangjiang * @LastEditors : tangjiang
* @LastEditTime : 2019-12-30 19:21:56 * @LastEditTime : 2019-12-30 20:08:09
*/ */
import './index.scss'; import './index.scss';
import React, { useState } from 'react'; import React, { useState, useEffect } from 'react';
import { Select } from 'antd'; import { Select } from 'antd';
const { Option } = Select; const { Option } = Select;
@ -19,6 +19,10 @@ function KnowLedge (props) {
values = [], // 已选择的下拉项 values = [], // 已选择的下拉项
} = props; } = props;
useEffect(() => {
setSelectOptions(options || []);
}, [props]);
// 显示的下拉项 // 显示的下拉项
const [selectOptions, setSelectOptions] = useState(options); const [selectOptions, setSelectOptions] = useState(options);
// 已选择的下拉项 // 已选择的下拉项
@ -30,7 +34,7 @@ function KnowLedge (props) {
const renderOptions = (options = []) => { const renderOptions = (options = []) => {
console.log('下拉选择: ', options); console.log('下拉选择: ', options);
return options.map((opt, i) => ( return options.map((opt, i) => (
<Option key={`opt_${i}`} value={opt}>{opt}</Option> <Option key={`opt_${i}`} value={`${opt.id}`}>{opt.name}</Option>
)); ));
} }
const handleSelectChange = (value) => { const handleSelectChange = (value) => {
@ -47,6 +51,7 @@ function KnowLedge (props) {
// 渲染下拉列表 // 渲染下拉列表
const renderSelect = (options, values) => { const renderSelect = (options, values) => {
console.log('==========>>>>>>>>', options);
return ( return (
<Select <Select
value={value} value={value}

@ -4,7 +4,7 @@
* @Github: * @Github:
* @Date: 2019-11-20 10:35:40 * @Date: 2019-11-20 10:35:40
* @LastEditors : tangjiang * @LastEditors : tangjiang
* @LastEditTime : 2019-12-30 19:57:46 * @LastEditTime : 2019-12-30 20:09:30
*/ */
import './index.scss'; import './index.scss';
// import 'katex/dist/katex.css'; // import 'katex/dist/katex.css';
@ -139,13 +139,19 @@ class EditTab extends React.Component {
if (value[0] && item.id === value[0]) { if (value[0] && item.id === value[0]) {
item.sub_disciplines && item.sub_disciplines.forEach(c => { item.sub_disciplines && item.sub_disciplines.forEach(c => {
if (value[1] && c.id === value[1]) { if (value[1] && c.id === value[1]) {
// tempArr = c.tag_disciplines || [];
console.log('+++++', c.tag_disciplines);
this.setState({ this.setState({
knowledges: c.tag_disciplines || [] knowledges: [...c.tag_disciplines]
});
} else {
this.setState({
knowledges: []
}); });
} }
}); });
} else {
this.setState({
knowledges: []
});
} }
}); });
} }

Loading…
Cancel
Save