subscriber.jsx 16 KB

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