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.searchName = theUrl.substring(1, theUrl.length);
  104. this.state.searchName = decodeURIComponent(this.state.searchName);
  105. };
  106. this.loadData();
  107. },
  108. fieldFirstChange(e) {
  109. let theArr = [];
  110. if (e.target.value !== 999) {
  111. theArr.push(
  112. <Radio.Button key={999} value={999}>不限</Radio.Button>
  113. );
  114. techFieldList.map((item) => {
  115. if (item.value == e.target.value) {
  116. item.children.map((children) => {
  117. theArr.push(
  118. <Radio.Button value={children.value} key={children.value}>{children.label}</Radio.Button>
  119. )
  120. });
  121. }
  122. });
  123. this.state.firstField = e.target.value;
  124. } else {
  125. this.state.firstField = null;
  126. };
  127. this.state.secondField = null;
  128. this.state.thirdField = null;
  129. this.setState({
  130. fieldSecondOption: theArr,
  131. fieldThirdOption: []
  132. });
  133. this.loadData();
  134. },
  135. fieldSecondChange(e) {
  136. let theArr = [], _me = this;
  137. if (e.target.value !== 999) {
  138. theArr.push(
  139. <Radio.Button key={999} value={999}>不限</Radio.Button>
  140. );
  141. techFieldList.map((item) => {
  142. if (item.value == _me.state.firstField) {
  143. item.children.map((children) => {
  144. if (children.value == e.target.value) {
  145. children.children.map((third) => {
  146. theArr.push(
  147. <Radio.Button value={third.value} key={third.value}>{third.label}</Radio.Button>
  148. )
  149. })
  150. }
  151. });
  152. }
  153. });
  154. this.state.secondField = e.target.value;
  155. } else {
  156. this.state.secondField = null;
  157. this.state.thirdField = null;
  158. };
  159. this.setState({
  160. fieldThirdOption: theArr
  161. });
  162. this.loadData();
  163. },
  164. tableRowClick(record, index) {
  165. window.open(globalConfig.context + '/user/subscriberDetail.html?rid=' + record.uid + '&type=' + record.type);
  166. },
  167. render() {
  168. const { pageNo, pageSize, total } = this.state.pagination;
  169. const _me = this;
  170. return (
  171. <div className="portal-body">
  172. <div className="portal-content clearfix" >
  173. <Row className="search-criteria">
  174. <Col className="search-title" span={2}>
  175. <span>行业分类</span>
  176. </Col>
  177. <Col className="search-select" span={22}>
  178. <Radio.Group defaultValue={999} onChange={this.fieldFirstChange}>
  179. {this.state.fieldFirstOption}
  180. </Radio.Group>
  181. </Col>
  182. </Row>
  183. {this.state.fieldSecondOption.length > 1 ? <Row className="search-criteria">
  184. <Col className="search-title" span={2}>
  185. <span>行业二级分类</span>
  186. </Col>
  187. <Col className="search-select" span={22}>
  188. <Radio.Group defaultValue={999} onChange={this.fieldSecondChange}>
  189. {this.state.fieldSecondOption}
  190. </Radio.Group>
  191. </Col>
  192. </Row> : <div></div>}
  193. {this.state.fieldThirdOption.length > 1 ? <Row className="search-criteria">
  194. <Col className="search-title" span={2}>
  195. <span>行业三级分类</span>
  196. </Col>
  197. <Col className="search-select" span={22}>
  198. <Radio.Group defaultValue={999} onChange={(e) => {
  199. if (e.target.value !== 999) {
  200. this.state.thirdField = e.target.value;
  201. } else {
  202. this.state.thirdField = null;
  203. }
  204. this.loadData()
  205. }}>
  206. {this.state.fieldThirdOption}
  207. </Radio.Group>
  208. </Col>
  209. </Row> : <div></div>}
  210. <Row className="search-criteria">
  211. <Col className="search-title" span={2}>
  212. <span>行家名称</span>
  213. </Col>
  214. <Col span={6}>
  215. <div className="nav-search" style={{ float: 'none', marginBottom: '10px' }}>
  216. <Input value={this.state.searchName} onChange={(e) => { this.setState({ searchName: e.target.value }); }} />
  217. <Button onClick={() => { this.loadData() }}>
  218. <img src={searchImg} alt="" />
  219. </Button>
  220. </div>
  221. </Col>
  222. </Row>
  223. <Spin spinning={this.state.loading}>
  224. <ul className="clearfix">
  225. {this.state.dataSource.map((item, i) => {
  226. return <li key={i} className="org-detail clearfix" onClick={() => { _me.tableRowClick(item); }}>
  227. <div className="logo">
  228. <img src={item.personPortraitUrl ?
  229. (globalConfig.avatarHost + "/upload" + (item.personPortraitUrl))
  230. : avatarImg} alt="头像" />
  231. </div>
  232. <div className="detail-right">
  233. <div className="name">
  234. {item.username || 'UserName'}
  235. </div>
  236. <div className="text" style={{ fontSize: '14px' }}>
  237. {item.workUnit || '单位'}
  238. </div>
  239. <div className="text" style={{ fontSize: '14px' }}>
  240. {item.position || '职位'}
  241. </div>
  242. <div className="text" style={{ fontSize: '12px' }}>
  243. {getTechField(item.engagedField[0], item.engagedField[1], item.engagedField[2])}
  244. </div>
  245. <div className="detail-text">
  246. <div className="text">
  247. <span style={{ letterSpacing: '27px' }}>需</span>
  248. <span>求: </span>
  249. <span className="text-Number"> {item.demandNum || 0} </span>
  250. <span className="text-unit"> 条</span>
  251. </div>
  252. <div className="text">
  253. <span>技术成果: </span>
  254. <span className="text-Number"> {item.achievementNum || 0} </span>
  255. <span className="text-unit"> 条</span>
  256. </div>
  257. <div className="text">
  258. <span style={{ letterSpacing: '27px' }}>粉</span>
  259. <span>丝: </span>
  260. <span className="text-Number"> {0}</span>
  261. <span className="text-unit"> 位</span>
  262. </div>
  263. </div>
  264. </div>
  265. </li>
  266. })}
  267. </ul>
  268. <Pagination style={{ float: 'right' }}
  269. onChange={(e) => { this.loadData(e); }}
  270. total={total}
  271. showTotal={() => { return '共' + total + '条数据' }}
  272. current={pageNo}
  273. pageSize={pageSize} />
  274. </Spin>
  275. </div>
  276. </div>
  277. )
  278. }
  279. });
  280. export default SubContent;