subscriberUser.jsx 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. import React from 'react';
  2. import { Icon, message, Row, Col, Radio, Input, 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 { techFieldList, getTechField } from '../../DicTechFieldList';
  7. import { getProvince } from '../../NewDicProvinceList';
  8. import { companySearch } from '../../tools';
  9. import ajax from 'jquery/src/ajax/xhr.js';
  10. import $ from 'jquery/src/ajax';
  11. import avatarImg from '../../../../image/avatarImg.png';
  12. const SubContent = React.createClass({
  13. loadData(pageNo) {
  14. this.setState({
  15. loading: true
  16. });
  17. $.ajax({
  18. method: "get",
  19. dataType: "json",
  20. url: globalConfig.context + "/portal/search/subscriberList",
  21. data: {
  22. "level": this.state.level, //认证状态 (0--未认证,1--认证)
  23. "type": this.state.type, //用户类型 (0--个人用户,1--组织用户)
  24. "field": this.state.firstField ? ((this.state.firstField || '') + (this.state.secondField ? (',' + this.state.secondField) : '') + (this.state.thirdField ? (',' + this.state.thirdField) : '')) : null,
  25. "province": this.state.province,
  26. "city": this.state.city,
  27. "area": this.state.area,
  28. "name": this.state.searchName,
  29. "pageNo": pageNo || 1,
  30. "pageSize": this.state.pagination.pageSize
  31. },
  32. success: function (data) {
  33. let theArr = [];
  34. if (!data.data || !data.data.list) {
  35. if (data.error && data.error.length) {
  36. message.warning(data.error[0].message);
  37. };
  38. } else {
  39. for (let i = 0; i < data.data.list.length; i++) {
  40. let thisdata = data.data.list[i];
  41. theArr.push({
  42. key: i,
  43. uid: thisdata.uid, //用户ID
  44. identityId: thisdata.identityId, //认证ID (详情接口传入ID)
  45. username: thisdata.username,// 用户名称
  46. unitName: thisdata.unitName,
  47. type: this.state.type,
  48. personPortraitUrl: thisdata.personPortraitUrl,//用户头像URL
  49. logoUrl: thisdata.logoUrl,
  50. achievementNum: thisdata.achievementNum, //科技成果数量
  51. demandNum: thisdata.demandNum, //科技需求数量
  52. province: thisdata.province,
  53. engagedField: thisdata.engagedField ? thisdata.engagedField.split(',') : [],
  54. workUnit: thisdata.workUnit,
  55. position: thisdata.position
  56. });
  57. };
  58. };
  59. this.state.pagination.pageNo = data.data.pageNo;
  60. this.state.pagination.total = data.data.totalCount;
  61. this.setState({
  62. dataSource: theArr,
  63. pagination: this.state.pagination
  64. });
  65. }.bind(this),
  66. }).done(function (data) {
  67. if (data.error && data.error.length) {
  68. message.warning(data.error[0].message);
  69. };
  70. this.setState({
  71. loading: false
  72. });
  73. }.bind(this));
  74. },
  75. getInitialState() {
  76. return {
  77. loading: false,
  78. type: 0,
  79. fieldFirstOption: [],
  80. fieldSecondOption: [],
  81. fieldThirdOption: [],
  82. pagination: {
  83. pageNo: 1,
  84. pageSize: 12,
  85. total: 0
  86. },
  87. dataSource: []
  88. };
  89. },
  90. componentWillMount() {
  91. let theFieldArr = [];
  92. theFieldArr.push(
  93. <Radio.Button key={999} value={999}>不限</Radio.Button>
  94. );
  95. techFieldList.map((item) => {
  96. theFieldArr.push(
  97. <Radio.Button value={item.value} key={item.value}>{item.label}</Radio.Button>
  98. )
  99. });
  100. this.state.fieldFirstOption = theFieldArr;
  101. if (window.location.search) {
  102. let theUrl = window.location.search
  103. this.state.keyword = theUrl.substring(1, theUrl.length);
  104. };
  105. this.loadData();
  106. },
  107. fieldFirstChange(e) {
  108. let theArr = [];
  109. if (e.target.value !== 999) {
  110. theArr.push(
  111. <Radio.Button key={999} value={999}>不限</Radio.Button>
  112. );
  113. techFieldList.map((item) => {
  114. if (item.value == e.target.value) {
  115. item.children.map((children) => {
  116. theArr.push(
  117. <Radio.Button value={children.value} key={children.value}>{children.label}</Radio.Button>
  118. )
  119. });
  120. }
  121. });
  122. this.state.firstField = e.target.value;
  123. } else {
  124. this.state.firstField = null;
  125. };
  126. this.state.secondField = null;
  127. this.state.thirdField = null;
  128. this.setState({
  129. fieldSecondOption: theArr,
  130. fieldThirdOption: []
  131. });
  132. this.loadData();
  133. },
  134. fieldSecondChange(e) {
  135. let theArr = [], _me = this;
  136. if (e.target.value !== 999) {
  137. theArr.push(
  138. <Radio.Button key={999} value={999}>不限</Radio.Button>
  139. );
  140. techFieldList.map((item) => {
  141. if (item.value == _me.state.firstField) {
  142. item.children.map((children) => {
  143. if (children.value == e.target.value) {
  144. children.children.map((third) => {
  145. theArr.push(
  146. <Radio.Button value={third.value} key={third.value}>{third.label}</Radio.Button>
  147. )
  148. })
  149. }
  150. });
  151. }
  152. });
  153. this.state.secondField = e.target.value;
  154. } else {
  155. this.state.secondField = null;
  156. this.state.thirdField = null;
  157. };
  158. this.setState({
  159. fieldThirdOption: theArr
  160. });
  161. this.loadData();
  162. },
  163. tableRowClick(record, index) {
  164. window.open(globalConfig.context + '/user/subscriberDetail.html?rid=' + record.uid + '&type=' + record.type);
  165. },
  166. render() {
  167. const { pageNo, pageSize, total } = this.state.pagination;
  168. const _me = this;
  169. return (
  170. <div className="portal-body">
  171. <div className="portal-content clearfix" >
  172. <Row className="search-criteria">
  173. <Col className="search-title" span={2}>
  174. <span>行业分类</span>
  175. </Col>
  176. <Col className="search-select" span={22}>
  177. <Radio.Group defaultValue={999} onChange={this.fieldFirstChange}>
  178. {this.state.fieldFirstOption}
  179. </Radio.Group>
  180. </Col>
  181. </Row>
  182. {this.state.fieldSecondOption.length > 1 ? <Row className="search-criteria">
  183. <Col className="search-title" span={2}>
  184. <span>行业二级分类</span>
  185. </Col>
  186. <Col className="search-select" span={22}>
  187. <Radio.Group defaultValue={999} onChange={this.fieldSecondChange}>
  188. {this.state.fieldSecondOption}
  189. </Radio.Group>
  190. </Col>
  191. </Row> : <div></div>}
  192. {this.state.fieldThirdOption.length > 1 ? <Row className="search-criteria">
  193. <Col className="search-title" span={2}>
  194. <span>行业三级分类</span>
  195. </Col>
  196. <Col className="search-select" span={22}>
  197. <Radio.Group defaultValue={999} onChange={(e) => {
  198. if (e.target.value !== 999) {
  199. this.state.thirdField = e.target.value;
  200. } else {
  201. this.state.thirdField = null;
  202. }
  203. this.loadData()
  204. }}>
  205. {this.state.fieldThirdOption}
  206. </Radio.Group>
  207. </Col>
  208. </Row> : <div></div>}
  209. <Row className="search-criteria">
  210. <Col className="search-title" span={2}>
  211. <span>行家名称</span>
  212. </Col>
  213. <Col span={6}>
  214. <div className="nav-search" style={{ float: 'none', marginBottom: '10px' }}>
  215. <Input onChange={(e) => { this.state.searchName = e.target.value; }} />
  216. <Button onClick={() => { this.loadData() }}>
  217. <img src={searchImg} alt="" />
  218. </Button>
  219. </div>
  220. </Col>
  221. </Row>
  222. <Spin spinning={this.state.loading}>
  223. <ul className="clearfix">
  224. {this.state.dataSource.map((item, i) => {
  225. return <li key={i} className="org-detail clearfix" onClick={() => { _me.tableRowClick(item); }}>
  226. <div className="logo">
  227. <img src={item.personPortraitUrl ?
  228. (globalConfig.avatarHost + "/upload" + (item.personPortraitUrl))
  229. : avatarImg} alt="头像" />
  230. </div>
  231. <div className="detail-right">
  232. <div className="name">
  233. {item.username || 'UserName'}
  234. </div>
  235. <div className="text" style={{ fontSize: '14px' }}>
  236. {item.workUnit || '单位'}
  237. </div>
  238. <div className="text" style={{ fontSize: '14px' }}>
  239. {item.position || '职位'}
  240. </div>
  241. <div className="text" style={{ fontSize: '12px' }}>
  242. {getTechField(item.engagedField[0], item.engagedField[1], item.engagedField[2])}
  243. </div>
  244. <div className="detail-text">
  245. <div className="text">
  246. <span style={{ letterSpacing: '32px' }}>需</span>
  247. <span>求: </span>
  248. <span className="text-Number"> {item.demandNum || 0} </span>
  249. <span className="text-unit"> 条</span>
  250. </div>
  251. <div className="text">
  252. <span>技术成果: </span>
  253. <span className="text-Number"> {item.achievementNum || 0} </span>
  254. <span className="text-unit"> 条</span>
  255. </div>
  256. <div className="text">
  257. <span style={{ letterSpacing: '32px' }}>粉</span>
  258. <span>丝: </span>
  259. <span className="text-Number"> {0}</span>
  260. <span className="text-unit"> 位</span>
  261. </div>
  262. </div>
  263. </div>
  264. </li>
  265. })}
  266. </ul>
  267. <Pagination style={{ float: 'right' }}
  268. onChange={(e) => { this.loadData(e); }}
  269. total={total}
  270. showTotal={() => { return '共' + total + '条数据' }}
  271. current={pageNo}
  272. pageSize={pageSize} />
  273. </Spin>
  274. </div>
  275. </div>
  276. )
  277. }
  278. });
  279. export default SubContent;