|
@@ -3,6 +3,7 @@ import './index.less';
|
|
|
import { Icon } from 'antd';
|
|
|
import { Link } from 'react-router-dom';
|
|
|
import Page from '@src/containers/Page';
|
|
|
+import Assets from '@src/components/Assets';
|
|
|
import { getMap, formatPercent, formatSeconds } from '@src/services/Tools';
|
|
|
import Button from '../../../components/Button';
|
|
|
import Tabs from '../../../components/Tabs';
|
|
@@ -49,34 +50,37 @@ export default class extends Page {
|
|
|
data.filterMap.subject = data.subject;
|
|
|
}
|
|
|
this.setState(data);
|
|
|
- refreshQuestionType(this, data.subject, data.questionType, { needSentence: false, allSubject: true, excludeAwa: true })
|
|
|
- .then(({ questionTypes }) => {
|
|
|
- return refreshStruct(this, 'exercise', data.one, data.two, {
|
|
|
- all: true,
|
|
|
- }).then(({ structIds }) => {
|
|
|
- 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 });
|
|
|
+ refreshQuestionType(this, data.subject, data.questionType, {
|
|
|
+ needSentence: false,
|
|
|
+ allSubject: true,
|
|
|
+ excludeAwa: true,
|
|
|
+ }).then(({ questionTypes }) => {
|
|
|
+ return refreshStruct(this, 'exercise', data.one, data.two, {
|
|
|
+ all: true,
|
|
|
+ }).then(({ structIds }) => {
|
|
|
+ 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 });
|
|
|
});
|
|
|
});
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
onRefreshFilter(query) {
|
|
@@ -119,11 +123,10 @@ export default class extends Page {
|
|
|
if (!force) {
|
|
|
this.searchNo += 1;
|
|
|
const no = this.searchNo;
|
|
|
- Question.searchNo({ keyword, module: 'exercise', page: 1, size: 5 })
|
|
|
- .then((result) => {
|
|
|
- if (no !== this.searchNo) return;
|
|
|
- this.setState({ searchList: result.list.map(row => row.title) });
|
|
|
- });
|
|
|
+ Question.searchNo({ keyword, module: 'exercise', page: 1, size: 5 }).then(result => {
|
|
|
+ if (no !== this.searchNo) return;
|
|
|
+ this.setState({ searchList: result.list.map(row => row.title) });
|
|
|
+ });
|
|
|
}
|
|
|
this.setState({ keyword });
|
|
|
}
|
|
@@ -160,33 +163,60 @@ export default class extends Page {
|
|
|
搜索题目
|
|
|
</Button>
|
|
|
{(focus || tip) && (
|
|
|
- <div hidden={!keyword || searchList.length === 0} className="search-tip-wrapper" onMouseEnter={() => this.setState({ tip: true })} onMouseLeave={() => this.setState({ tip: false })}>
|
|
|
+ <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(item);
|
|
|
- }}>{item}</div>;
|
|
|
+ return (
|
|
|
+ <div
|
|
|
+ className="t-2 t-s-16"
|
|
|
+ onClick={() => {
|
|
|
+ // this.onChangeSearch(item, true);
|
|
|
+ this.onSearch(item);
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ {item}
|
|
|
+ </div>
|
|
|
+ );
|
|
|
})}
|
|
|
</div>
|
|
|
)}
|
|
|
{(focus || tip) && (
|
|
|
- <div hidden={keyword || searchHistoryList.length === 0} className="search-tip-wrapper" onMouseEnter={() => this.setState({ tip: true })} onMouseLeave={() => this.setState({ tip: false })}>
|
|
|
+ <div
|
|
|
+ hidden={keyword || searchHistoryList.length === 0}
|
|
|
+ className="search-tip-wrapper"
|
|
|
+ onMouseEnter={() => this.setState({ tip: true })}
|
|
|
+ onMouseLeave={() => this.setState({ tip: false })}
|
|
|
+ >
|
|
|
{searchHistoryList.map((item, index) => {
|
|
|
return (
|
|
|
- <div className="t-2 t-s-16" onClick={() => {
|
|
|
- // this.onChangeSearch(item, true);
|
|
|
- this.onSearch(item);
|
|
|
- }}>
|
|
|
+ <div
|
|
|
+ className="t-2 t-s-16"
|
|
|
+ onClick={() => {
|
|
|
+ // this.onChangeSearch(item, true);
|
|
|
+ this.onSearch(item);
|
|
|
+ }}
|
|
|
+ >
|
|
|
{item}
|
|
|
- <div className="f-r t-4 t-s-12 c-p" onClick={(e) => {
|
|
|
- e.stopPropagation();
|
|
|
- User.removeSearchIndex(index);
|
|
|
- }}>删除</div>
|
|
|
+ <div
|
|
|
+ className="f-r t-4 t-s-12 c-p"
|
|
|
+ onClick={e => {
|
|
|
+ e.stopPropagation();
|
|
|
+ User.removeSearchIndex(index);
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ 删除
|
|
|
+ </div>
|
|
|
</div>
|
|
|
);
|
|
|
})}
|
|
|
<div className="all-del t-r">
|
|
|
- <span className="t-4 t-s-12 c-p" onClick={() => User.clearSearch()}>删除历史</span>
|
|
|
+ <span className="t-4 t-s-12 c-p" onClick={() => User.clearSearch()}>
|
|
|
+ 删除历史
|
|
|
+ </span>
|
|
|
</div>
|
|
|
</div>
|
|
|
)}
|
|
@@ -212,7 +242,11 @@ export default class extends Page {
|
|
|
return (
|
|
|
<div className="filter-layout">
|
|
|
<div className="content">
|
|
|
- <div style={{ right: 0, top: 0 }} className='p-a' hidden={!login}><Link to="/question/search/history"><Icon type="history" /> 浏览历史 ></Link></div>
|
|
|
+ <div style={{ right: 0, top: 0 }} className="p-a" hidden={!login}>
|
|
|
+ <Link to="/question/search/history">
|
|
|
+ <Assets name="history_time" className="m-r-5" /> 浏览历史 >
|
|
|
+ </Link>
|
|
|
+ </div>
|
|
|
<Tabs
|
|
|
border
|
|
|
type="division"
|
|
@@ -266,7 +300,12 @@ export default class extends Page {
|
|
|
/>
|
|
|
{this.renderList()}
|
|
|
{total > 0 && list.length > 0 && (
|
|
|
- <UserPagination total={total} current={page} pageSize={this.state.search.size} onChange={p => this.onChangePage(p)} />
|
|
|
+ <UserPagination
|
|
|
+ total={total}
|
|
|
+ current={page}
|
|
|
+ pageSize={this.state.search.size}
|
|
|
+ onChange={p => this.onChangePage(p)}
|
|
|
+ />
|
|
|
)}
|
|
|
</div>
|
|
|
</div>
|
|
@@ -284,7 +323,12 @@ export default class extends Page {
|
|
|
</div>
|
|
|
{this.renderList()}
|
|
|
{total > 0 && list.length > 0 && (
|
|
|
- <UserPagination total={total} current={page} pageSize={this.state.search.size} onChange={p => this.onChangePage(p)} />
|
|
|
+ <UserPagination
|
|
|
+ total={total}
|
|
|
+ current={page}
|
|
|
+ pageSize={this.state.search.size}
|
|
|
+ onChange={p => this.onChangePage(p)}
|
|
|
+ />
|
|
|
)}
|
|
|
</div>
|
|
|
</div>
|
|
@@ -306,7 +350,9 @@ class SearchItem extends Component {
|
|
|
<div className="search-item">
|
|
|
<div className="search-item-head">
|
|
|
<span className="t-15 t-s-16 m-r-1">{QuestionTypeMap[data.question.questionType]}</span>
|
|
|
- <a className="t-1 t-s-16" href={`/question/detail/${data.id}`} target="_blank" onClick={() => onClick()}>{data.title}</a>
|
|
|
+ <a className="t-1 t-s-16" href={`/question/detail/${data.id}`} target="_blank" onClick={() => onClick()}>
|
|
|
+ {data.title}
|
|
|
+ </a>
|
|
|
<div className="f-r t-15 t-s-14">
|
|
|
<span className="m-r-1">{data.question.difficult}</span>
|
|
|
<span className="m-r-1">用时: {formatSeconds(data.totalTime / data.totalNumer)}</span>
|