page.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. import React, { Component } from 'react';
  2. import './index.less';
  3. import { Icon } from 'antd';
  4. import Page from '@src/containers/Page';
  5. import Button from '../../../components/Button';
  6. import Tabs from '../../../components/Tabs';
  7. import UserAction from '../../../components/UserAction';
  8. import UserPagination from '../../../components/UserPagination';
  9. export default class extends Page {
  10. initState() {
  11. return {
  12. list: [{}, {}, {}],
  13. searchList: [123, 123, 123],
  14. historyList: [321, 321, 321],
  15. searchValue: '',
  16. search: false,
  17. tab: '1',
  18. filterMap: {},
  19. sortMap: {},
  20. focus: false,
  21. };
  22. }
  23. onTabChange(tab) {
  24. this.setState({ tab });
  25. }
  26. onChangeSearch(value) {
  27. this.setState({ searchValue: value });
  28. }
  29. renderView() {
  30. const { search } = this.state;
  31. return (
  32. <div>
  33. {this.renderSearch()}
  34. {search ? this.renderResult() : this.renderFilter()}
  35. </div>
  36. );
  37. }
  38. renderSearch() {
  39. const { searchList, searchValue, historyList, focus } = this.state;
  40. return (
  41. <div className="search-layout">
  42. <div className="search-wrapper">
  43. <input
  44. value={searchValue}
  45. onChange={e => this.onChangeSearch(e.target.value)}
  46. onFocus={() => this.setState({ focus: true })}
  47. onBlur={() => this.setState({ focus: false })}
  48. />
  49. <Button width={150}>
  50. <Icon className="m-r-5" type="search" />
  51. 搜索题目
  52. </Button>
  53. {focus && (
  54. <div hidden={!searchValue} className="search-tip-wrapper">
  55. {searchList.map(item => {
  56. return <div className="t-2 t-s-16">{item}</div>;
  57. })}
  58. </div>
  59. )}
  60. {focus && (
  61. <div hidden={searchValue} className="search-tip-wrapper">
  62. {historyList.map(item => {
  63. return (
  64. <div className="t-2 t-s-16">
  65. {item}
  66. <div className="f-r t-4 t-s-12 c-p">删除</div>
  67. </div>
  68. );
  69. })}
  70. <div className="all-del t-r">
  71. <span className="t-4 t-s-12 c-p">删除历史</span>
  72. </div>
  73. </div>
  74. )}
  75. </div>
  76. </div>
  77. );
  78. }
  79. renderFilter() {
  80. const { tab, filterMap, sortMap } = this.state;
  81. return (
  82. <div className="filter-layout">
  83. <div className="content">
  84. <Tabs
  85. border
  86. type="division"
  87. theme="theme"
  88. size="small"
  89. space={5}
  90. width={220}
  91. active={tab}
  92. tabs={[{ key: '1', title: 'Verval' }, { key: '2', title: 'Quant' }, { key: '3', title: 'IR' }]}
  93. onChange={key => this.onTabChange(key)}
  94. />
  95. <UserAction
  96. selectList={[
  97. {
  98. key: 'questionType',
  99. placeholder: '题型',
  100. select: [],
  101. },
  102. {
  103. label: '范围',
  104. children: [
  105. {
  106. key: 'rang1',
  107. placeholder: '全部',
  108. select: [],
  109. },
  110. {
  111. placeholder: '全部',
  112. key: 'rang2',
  113. be: 'rang1',
  114. selectMap: {},
  115. },
  116. ],
  117. },
  118. {
  119. right: true,
  120. placeholder: '难度',
  121. key: 'level',
  122. select: [],
  123. },
  124. ]}
  125. sortList={[
  126. { key: '1', label: '全站用时', fixed: true, right: true },
  127. { key: '2', label: '平均正确率', fixed: true, right: true },
  128. { key: '3', label: '收藏人数', fixed: true, right: true },
  129. ]}
  130. filterMap={filterMap}
  131. sortMap={sortMap}
  132. onFilter={value => this.onFilter(value)}
  133. />
  134. {this.renderList()}
  135. <UserPagination />
  136. </div>
  137. </div>
  138. );
  139. }
  140. renderResult() {
  141. return (
  142. <div className="result-layout">
  143. <div className="content">
  144. <div className="m-b-1">
  145. <span className="t-1 t-s-24">搜索结果:</span>
  146. <span className="t-2 t-s-18">共12条</span>
  147. </div>
  148. {this.renderList()}
  149. <UserPagination jump />
  150. </div>
  151. </div>
  152. );
  153. }
  154. renderList() {
  155. const { list } = this.state;
  156. return list.map(item => {
  157. return <SearchItem data={item} />;
  158. });
  159. }
  160. }
  161. class SearchItem extends Component {
  162. render() {
  163. return (
  164. <div className="search-item">
  165. <div className="search-item-head">
  166. <span className="t-15 t-s-16 m-r-1">阅读RC</span>
  167. <span className="t-1 t-s-16">PREP07#124、PREP08#332、PREP07#124、PREP08#332、PREP07#124</span>
  168. <div className="f-r t-15 t-s-14">
  169. <span className="m-r-1">Medium</span>
  170. <span className="m-r-1">用时: 1m 39s</span>
  171. <span className="m-r-1">80% </span>
  172. <span>收藏 20313</span>
  173. </div>
  174. </div>
  175. <div className="t-1 p-20">
  176. Margaret Mead, the best-known anthropologist of the twentieth century, helped shape public opinion on
  177. fundamentally important areas like attitudes toward children and families, along with the relative merits of
  178. competition and cooperation. A. shape public opinion on fundamentally important areas like attitudes toward
  179. children and families, along with
  180. </div>
  181. </div>
  182. );
  183. }
  184. }