|
@@ -54,19 +54,25 @@ export default class extends Page {
|
|
|
return refreshStruct(this, 'exercise', data.one, data.two, {
|
|
|
all: true,
|
|
|
}).then(({ structIds }) => {
|
|
|
- Question.searchStem(
|
|
|
- Object.assign(
|
|
|
- { questionTypes, structIds, module: 'exercise' },
|
|
|
- this.state.search,
|
|
|
- {
|
|
|
- order: Object.keys(data.sortMap)
|
|
|
- .map(key => {
|
|
|
- return `${key} ${data.sortMap[key]}`;
|
|
|
- })
|
|
|
- .join(','),
|
|
|
- },
|
|
|
- ),
|
|
|
- ).then(result => {
|
|
|
+ let handler = null;
|
|
|
+ if (this.state.search.keyword) {
|
|
|
+ handler = Question.searchStem({ keyword: this.state.search.keyword, page: this.state.search.page, size: this.state.search.size });
|
|
|
+ } else {
|
|
|
+ handler = Question.searchStem(
|
|
|
+ Object.assign(
|
|
|
+ { questionTypes, structIds, module: 'exercise' },
|
|
|
+ this.state.search,
|
|
|
+ {
|
|
|
+ order: Object.keys(data.sortMap)
|
|
|
+ .map(key => {
|
|
|
+ return `${key} ${data.sortMap[key]}`;
|
|
|
+ })
|
|
|
+ .join(','),
|
|
|
+ },
|
|
|
+ ),
|
|
|
+ );
|
|
|
+ }
|
|
|
+ handler.then(result => {
|
|
|
this.setState({ list: result.list, total: result.total, page: data.page, searchResult: !!data.keyword });
|
|
|
});
|
|
|
});
|
|
@@ -85,13 +91,13 @@ export default class extends Page {
|
|
|
// this.initData();
|
|
|
}
|
|
|
|
|
|
- onSearch() {
|
|
|
+ onSearch(value) {
|
|
|
const { keyword } = this.state;
|
|
|
- User.addSearch(keyword);
|
|
|
+ User.addSearch(value || keyword);
|
|
|
// this.search({ keyword }, false);
|
|
|
// this.changeQuery({ keyword });
|
|
|
// this.setState({ keyword });
|
|
|
- this.refreshQuery({ keyword });
|
|
|
+ this.refreshQuery({ keyword: value || keyword });
|
|
|
// this.initData();
|
|
|
}
|
|
|
|
|
@@ -149,7 +155,7 @@ export default class extends Page {
|
|
|
onFocus={() => this.setState({ focus: true })}
|
|
|
onBlur={() => this.setState({ focus: false })}
|
|
|
/>
|
|
|
- <Button width={150} onClick={() => this.onSearch()}>
|
|
|
+ <Button width={150} onClick={() => this.onSearch(keyword)}>
|
|
|
<Icon className="m-r-5" type="search" />
|
|
|
搜索题目
|
|
|
</Button>
|
|
@@ -157,8 +163,8 @@ export default class extends Page {
|
|
|
<div hidden={!keyword || searchList.length === 0} className="search-tip-wrapper" onMouseEnter={() => this.setState({ tip: true })} onMouseLeave={() => this.setState({ tip: false })}>
|
|
|
{searchList.map(item => {
|
|
|
return <div className="t-2 t-s-16" onClick={() => {
|
|
|
- this.onChangeSearch(item, true);
|
|
|
- this.onSearch();
|
|
|
+ // this.onChangeSearch(item, true);
|
|
|
+ this.onSearch(item);
|
|
|
}}>{item}</div>;
|
|
|
})}
|
|
|
</div>
|
|
@@ -168,8 +174,8 @@ export default class extends Page {
|
|
|
{searchHistoryList.map((item, index) => {
|
|
|
return (
|
|
|
<div className="t-2 t-s-16" onClick={() => {
|
|
|
- this.onChangeSearch(item, true);
|
|
|
- this.onSearch();
|
|
|
+ // this.onChangeSearch(item, true);
|
|
|
+ this.onSearch(item);
|
|
|
}}>
|
|
|
{item}
|
|
|
<div className="f-r t-4 t-s-12 c-p" onClick={(e) => {
|