|
@@ -5,23 +5,23 @@ import Select from '@src/components/Select';
|
|
|
import { getMap, generateSearch } from '@src/services/Tools';
|
|
|
import QuestionNoList from '../QuestionNoList';
|
|
|
import { Question } from '../../stores/question';
|
|
|
-import { Sentence } from '../../stores/sentence';
|
|
|
+// import { Sentence } from '../../stores/sentence';
|
|
|
|
|
|
class Association extends Component {
|
|
|
constructor(props) {
|
|
|
super(props);
|
|
|
- this.state = { ids: this.props.ids, show: !!props.modal, loading: false, err: '' };
|
|
|
+ this.state = { ids: props.ids, show: !!props.modal, loading: false, err: '' };
|
|
|
this.questionNos = [];
|
|
|
|
|
|
- generateSearch(this.props.field, { mode: 'multiple' }, this, (search) => {
|
|
|
+ generateSearch(props.field, { mode: 'multiple' }, this, (search) => {
|
|
|
return this.searchQuestion(search);
|
|
|
}, (row) => {
|
|
|
return {
|
|
|
title: row.title,
|
|
|
value: row.id,
|
|
|
};
|
|
|
- }, this.props.ids, null);
|
|
|
- this.listQuestion(this.props.ids, 'ids');
|
|
|
+ }, props.ids, null);
|
|
|
+ this.listQuestion(props.ids, 'ids');
|
|
|
}
|
|
|
|
|
|
onConfirm() {
|
|
@@ -51,19 +51,21 @@ class Association extends Component {
|
|
|
if (this.props.onCancel) this.props.onCancel();
|
|
|
}
|
|
|
|
|
|
- listQuestion(values, field = 'ids') {
|
|
|
+ listQuestion(values, ids = 'ids') {
|
|
|
+ const { getFieldDecorator, setFieldsValue } = this.props.form;
|
|
|
+ const { field = 'questionNoIds' } = this.props;
|
|
|
+ getFieldDecorator(field);
|
|
|
+ setFieldsValue({ [field]: values });
|
|
|
if (!values || values.length === 0) {
|
|
|
this.setState({ questionNos: [] });
|
|
|
return;
|
|
|
}
|
|
|
let handler;
|
|
|
switch (this.props.module) {
|
|
|
+ case 'sentence':
|
|
|
case 'exercise':
|
|
|
// 查找练习题目
|
|
|
- handler = Question.listNo({ [field]: values, module: this.props.module });
|
|
|
- break;
|
|
|
- case 'sentence':
|
|
|
- handler = Sentence.listQuestion({ [field]: values });
|
|
|
+ handler = Question.listNo({ [ids]: values, module: this.props.module });
|
|
|
break;
|
|
|
default:
|
|
|
return;
|
|
@@ -79,14 +81,13 @@ class Association extends Component {
|
|
|
|
|
|
searchQuestion(params) {
|
|
|
let handler;
|
|
|
+ params.module = this.props.module;
|
|
|
switch (this.props.module) {
|
|
|
+ case 'sentence':
|
|
|
case 'exercise':
|
|
|
// 查找练习题目
|
|
|
handler = Question.searchNo(params);
|
|
|
break;
|
|
|
- case 'sentence':
|
|
|
- handler = Sentence.searchQuestion(params);
|
|
|
- break;
|
|
|
default:
|
|
|
handler = Promise.reject(new Error('module is error'));
|
|
|
}
|