subscriber.jsx 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. import React from 'react';
  2. import { Carousel, Icon, message, Row, Col, Select, Radio, Checkbox, Input, InputNumber, Button, Table, Spin, Pagination } from 'antd';
  3. import '../portal.less';
  4. import logoImg from '../../../../image/logo.png';
  5. import searchImg from '../../../../image/search.png';
  6. import slideImg from '../../../../image/slide_img_1.png';
  7. import { techFieldList, getTechField } from '../../DicTechFieldList';
  8. import { provinceList, getProvince } from '../../NewDicProvinceList';
  9. import { companySearch } from '../../tools';
  10. import ajax from 'jquery/src/ajax/xhr.js';
  11. import $ from 'jquery/src/ajax';
  12. import avatarImg from '../../../../image/avatarImg.png';
  13. const SubContent = React.createClass({
  14. loadData(pageNo) {
  15. this.setState({
  16. loading: true
  17. });
  18. $.ajax({
  19. method: "get",
  20. dataType: "json",
  21. url: globalConfig.context + "/portal/search/subscriberList",
  22. data: {
  23. "level": this.state.level, //认证状态 (0--未认证,1--认证)
  24. "type": this.state.type, //用户类型 (0--个人用户,1--组织用户)
  25. "field": this.state.firstField ? ((this.state.firstField || '') + ',' + (this.state.secondField || '') + ',' + (this.state.thirdField || '')) : null,
  26. "province": this.state.province,
  27. "city": this.state.city,
  28. "area": this.state.area,
  29. "name": this.state.searchName,
  30. "pageNo": pageNo || 1,
  31. "pageSize": this.state.pagination.pageSize
  32. },
  33. success: function (data) {
  34. let theArr = [];
  35. if (!data.data || !data.data.list) {
  36. if (data.error && data.error.length) {
  37. message.warning(data.error[0].message);
  38. };
  39. } else {
  40. for (let i = 0; i < data.data.list.length; i++) {
  41. let thisdata = data.data.list[i];
  42. theArr.push({
  43. key: i,
  44. uid: thisdata.uid, //用户ID
  45. identityId: thisdata.identityId, //认证ID (详情接口传入ID)
  46. username: thisdata.username,// 用户名称
  47. unitName: thisdata.unitName,
  48. type: this.state.type,
  49. personPortraitUrl: thisdata.personPortraitUrl,//用户头像URL
  50. logoUrl: thisdata.logoUrl,
  51. achievementNum: thisdata.achievementNum, //科技成果数量
  52. demandNum: thisdata.demandNum, //科技需求数量
  53. province: thisdata.province
  54. });
  55. };
  56. };
  57. this.state.pagination.pageNo = data.data.pageNo;
  58. this.state.pagination.total = data.data.totalCount;
  59. this.setState({
  60. dataSource: theArr,
  61. pagination: this.state.pagination
  62. });
  63. }.bind(this),
  64. }).done(function (data) {
  65. if (data.error && data.error.length) {
  66. message.warning(data.error[0].message);
  67. };
  68. this.setState({
  69. loading: false
  70. });
  71. }.bind(this));
  72. },
  73. getInitialState() {
  74. return {
  75. loading: false,
  76. type: 0,
  77. pagination: {
  78. pageNo: 1,
  79. pageSize: 15,
  80. total: 0
  81. },
  82. dataSource: []
  83. };
  84. },
  85. componentWillMount() {
  86. let theFieldArr = [], theProvinceArr = [];
  87. techFieldList.map((item) => {
  88. theFieldArr.push(
  89. <Select.Option key={item.value}>{item.label}</Select.Option>
  90. )
  91. });
  92. provinceList.map((item) => {
  93. theProvinceArr.push(
  94. <Select.Option key={item.id}>{item.name}</Select.Option>
  95. )
  96. });
  97. this.state.fieldFirstOption = theFieldArr;
  98. this.state.provinceOption = theProvinceArr;
  99. this.loadData();
  100. },
  101. fieldFirstChange(e) {
  102. let theArr = [];
  103. techFieldList.map((item) => {
  104. if (item.value == e) {
  105. item.children.map((children) => {
  106. theArr.push(
  107. <Select.Option key={children.value}>{children.label}</Select.Option>
  108. )
  109. });
  110. }
  111. });
  112. this.state.firstField = e;
  113. this.state.secondField = undefined;
  114. this.state.thirdField = undefined;
  115. this.setState({
  116. fieldSecondOption: theArr,
  117. firstField: e,
  118. secondField: undefined,
  119. thirdField: undefined
  120. });
  121. this.loadData();
  122. },
  123. fieldSecondChange(e) {
  124. let theArr = [], _me = this;
  125. techFieldList.map((item) => {
  126. if (item.value == _me.state.firstField) {
  127. item.children.map((children) => {
  128. if (children.value == e) {
  129. children.children.map((third) => {
  130. theArr.push(
  131. <Select.Option key={third.value}>{third.label}</Select.Option>
  132. )
  133. })
  134. }
  135. });
  136. }
  137. });
  138. this.state.secondField = e;
  139. this.state.thirdField = undefined;
  140. this.setState({
  141. fieldThirdOption: theArr,
  142. secondField: e,
  143. thirdField: undefined
  144. });
  145. this.loadData();
  146. },
  147. provinceChange(e) {
  148. let theArr = [];
  149. provinceList.map((item) => {
  150. if (item.id == e) {
  151. item.cityList.map((city) => {
  152. theArr.push(
  153. <Select.Option key={city.id}>{city.name}</Select.Option>
  154. )
  155. });
  156. }
  157. });
  158. this.state.province = e;
  159. this.state.city = undefined;
  160. this.state.area = undefined;
  161. this.setState({
  162. cityOption: theArr,
  163. province: e,
  164. city: undefined,
  165. area: undefined
  166. });
  167. this.loadData();
  168. },
  169. cityChange(e) {
  170. let theArr = [], _me = this;
  171. provinceList.map((item) => {
  172. if (item.id == _me.state.province) {
  173. item.cityList.map((city) => {
  174. if (city.id == e) {
  175. city.areaList.map((area) => {
  176. theArr.push(
  177. <Select.Option key={area.id}>{area.name}</Select.Option>
  178. )
  179. });
  180. };
  181. });
  182. };
  183. });
  184. this.state.city = e;
  185. this.state.area = undefined;
  186. this.setState({
  187. areaOption: theArr,
  188. city: e,
  189. area: undefined
  190. });
  191. this.loadData();
  192. },
  193. tableRowClick(record, index) {
  194. window.open(globalConfig.context + '/user/subscriberDetail.html?rid=' + record.uid + '&type=' + record.type);
  195. },
  196. render() {
  197. const { pageNo, pageSize, total } = this.state.pagination;
  198. const _me = this;
  199. return (
  200. <div className="portal-body">
  201. <div className="portal-nav clearfix">
  202. <div className="nav-logoBox">
  203. <img src={logoImg} alt="" />
  204. </div>
  205. <ul className="nav-list clearfix">
  206. <li className={this.props.searchType == 'achievement' ? 'active' : ''}><a href={"/portal/search/achievement.html"}>科技成果</a></li>
  207. <li className={this.props.searchType == 'demand' ? 'active' : ''}><a href={"/portal/search/demand.html"}>科技需求</a></li>
  208. <li className={this.props.searchType == 'subscriber' ? 'active' : ''}><a href={"/portal/search/subscriber.html"}>伙伴/行家</a></li>
  209. </ul>
  210. <div className="nav-search">
  211. <Input onChange={(e) => { this.state.searchName = e.target.value; }} />
  212. <Button onClick={() => { this.loadData() }}>
  213. <img src={searchImg} alt="" />
  214. </Button>
  215. </div>
  216. </div>
  217. <Carousel autoplay className="portal-carousel">
  218. <div className="slide-box"><img src={slideImg} alt="" /></div>
  219. <div className="slide-box"><img src={slideImg} alt="" /></div>
  220. <div className="slide-box"><img src={slideImg} alt="" /></div>
  221. <div className="slide-box"><img src={slideImg} alt="" /></div>
  222. </Carousel>
  223. <div className="portal-content clearfix" >
  224. <Row className="search-criteria">
  225. <Col className="search-title" span={2}>
  226. <span>行业分类</span>
  227. </Col>
  228. <Col className="search-select" span={22}>
  229. <Select style={{ width: 160, marginRight: '10px', marginBottom: '10px' }}
  230. value={this.state.firstField}
  231. placeholder="请选择行业一级分类"
  232. notFoundContent="未获取到行业分类"
  233. showSearch
  234. filterOption={companySearch}
  235. onChange={this.fieldFirstChange}>
  236. {this.state.fieldFirstOption}
  237. </Select>
  238. <Select style={{ width: 200, marginRight: '10px', marginBottom: '10px' }}
  239. value={this.state.secondField}
  240. placeholder="请选择行业二级分类"
  241. notFoundContent="未获取到行业分类"
  242. showSearch
  243. filterOption={companySearch}
  244. onChange={this.fieldSecondChange}>
  245. {this.state.fieldSecondOption}
  246. </Select>
  247. <Select style={{ width: 240, marginRight: '10px', marginBottom: '10px' }}
  248. value={this.state.thirdField}
  249. placeholder="请选择行业三级分类"
  250. notFoundContent="未获取到行业分类"
  251. showSearch
  252. filterOption={companySearch}
  253. onChange={(e) => {
  254. this.state.thirdField = e;
  255. this.setState({ thirdField: e });
  256. this.loadData();
  257. }}>
  258. {this.state.fieldThirdOption}
  259. </Select>
  260. <Button type="ghost" style={{ marginLeft: '20px' }}
  261. onClick={() => {
  262. this.setState({
  263. firstField: undefined,
  264. secondField: undefined,
  265. thirdField: undefined
  266. });
  267. this.state.firstField = undefined;
  268. this.state.secondField = undefined;
  269. this.state.thirdField = undefined;
  270. this.loadData();
  271. }}>不限</Button>
  272. </Col>
  273. </Row>
  274. <Row className="search-criteria">
  275. <Col className="search-title" span={2}>
  276. <span>地区</span>
  277. </Col>
  278. <Col className="search-select" span={22}>
  279. <Select style={{ width: 100, marginRight: '10px', marginBottom: '10px' }}
  280. value={this.state.province}
  281. placeholder="请选择省份"
  282. notFoundContent="未获取到省份列表"
  283. showSearch
  284. filterOption={companySearch}
  285. onChange={this.provinceChange}>
  286. {this.state.provinceOption}
  287. </Select>
  288. <Select style={{ width: 160, marginRight: '10px', marginBottom: '10px' }}
  289. value={this.state.city}
  290. placeholder="请选择行业城市"
  291. notFoundContent="未获取到城市列表"
  292. showSearch
  293. filterOption={companySearch}
  294. onChange={this.cityChange}>
  295. {this.state.cityOption}
  296. </Select>
  297. <Select style={{ width: 160, marginRight: '10px', marginBottom: '10px' }}
  298. value={this.state.area}
  299. placeholder="请选择行政区"
  300. notFoundContent="未获取到行政区列表"
  301. showSearch
  302. filterOption={companySearch}
  303. onChange={(e) => {
  304. this.state.area = e;
  305. this.setState({ area: e });
  306. this.loadData();
  307. }}>
  308. {this.state.areaOption}
  309. </Select>
  310. <Button type="ghost" style={{ marginLeft: '20px' }}
  311. onClick={() => {
  312. this.setState({
  313. province: undefined,
  314. city: undefined,
  315. area: undefined
  316. });
  317. this.state.province = undefined;
  318. this.state.city = undefined;
  319. this.state.area = undefined;
  320. this.loadData();
  321. }}>不限</Button>
  322. </Col>
  323. </Row>
  324. <Row className="search-criteria">
  325. <Col className="search-title" span={2}>
  326. <span>用户类型</span>
  327. </Col>
  328. <Col className="search-select" span={6}>
  329. <Radio.Group defaultValue={0} onChange={(e) => {
  330. this.setState({
  331. type: e.target.value
  332. });
  333. this.state.type = e.target.value;
  334. this.loadData();
  335. }}>
  336. <Radio.Button value={0}>个人</Radio.Button>
  337. <Radio.Button value={1}>组织</Radio.Button>
  338. </Radio.Group>
  339. </Col>
  340. </Row>
  341. <Spin spinning={this.state.loading}>
  342. <ul className="clearfix">
  343. {this.state.dataSource.map((item, i) => {
  344. return <li key={i} className="user-detail" onClick={() => { _me.tableRowClick(item); }}>
  345. <div className="logo">
  346. <img src={(item.personPortraitUrl || item.logoUrl) ?
  347. (globalConfig.avatarHost + "/upload" + (_me.state.type == 0 ? item.personPortraitUrl : item.logoUrl))
  348. : avatarImg} alt="头像" />
  349. </div>
  350. <div className="name">
  351. {_me.state.type == 0 ? item.username : item.unitName}
  352. </div>
  353. <div className="province">
  354. <span style={{ letterSpacing: '32px' }}>地</span>
  355. <span>区: </span>
  356. <span className="address"> {getProvince(item.province)}</span>
  357. </div>
  358. <div className="text">
  359. <span style={{ letterSpacing: '32px' }}>需</span>
  360. <span>求: </span>
  361. <span className="text-Number"> {item.demandNum || 0} </span>
  362. <span className="text-unit"> 条</span>
  363. </div>
  364. <div className="text">
  365. <span>技术成果: </span>
  366. <span className="text-Number"> {item.achievementNum || 0} </span>
  367. <span className="text-unit"> 条</span>
  368. </div>
  369. </li>
  370. })}
  371. </ul>
  372. <Pagination style={{ float: 'right' }}
  373. onChange={(e) => { this.loadData(e); }}
  374. total={total}
  375. showTotal={() => { return '共' + total + '条数据' }}
  376. current={pageNo}
  377. pageSize={pageSize} />
  378. </Spin>
  379. </div>
  380. </div>
  381. )
  382. }
  383. });
  384. export default SubContent;