subscriber.jsx 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  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. type: this.state.type,
  46. personPortraitUrl: thisdata.personPortraitUrl,//用户头像URL
  47. logoUrl: thisdata.logoUrl,
  48. achievementNum: thisdata.achievementNum, //科技成果数量
  49. demandNum: thisdata.demandNum, //科技需求数量
  50. province: thisdata.province
  51. });
  52. };
  53. };
  54. this.state.pagination.pageNo = data.data.pageNo;
  55. this.state.pagination.total = data.data.totalCount;
  56. this.setState({
  57. dataSource: theArr,
  58. pagination: this.state.pagination
  59. });
  60. }.bind(this),
  61. }).done(function (data) {
  62. if (data.error && data.error.length) {
  63. message.warning(data.error[0].message);
  64. };
  65. this.setState({
  66. loading: false
  67. });
  68. }.bind(this));
  69. },
  70. getInitialState() {
  71. return {
  72. loading: false,
  73. type: 0,
  74. pagination: {
  75. pageNo: 1,
  76. pageSize: 15,
  77. total: 0
  78. },
  79. dataSource: []
  80. };
  81. },
  82. componentWillMount() {
  83. let theFieldArr = [], theProvinceArr = [];
  84. techFieldList.map((item) => {
  85. theFieldArr.push(
  86. <Select.Option key={item.value}>{item.label}</Select.Option>
  87. )
  88. });
  89. provinceList.map((item) => {
  90. theProvinceArr.push(
  91. <Select.Option key={item.id}>{item.name}</Select.Option>
  92. )
  93. });
  94. this.state.fieldFirstOption = theFieldArr;
  95. this.state.provinceOption = theProvinceArr;
  96. this.loadData();
  97. },
  98. fieldFirstChange(e) {
  99. let theArr = [];
  100. techFieldList.map((item) => {
  101. if (item.value == e) {
  102. item.children.map((children) => {
  103. theArr.push(
  104. <Select.Option key={children.value}>{children.label}</Select.Option>
  105. )
  106. });
  107. }
  108. });
  109. this.setState({
  110. fieldSecondOption: theArr,
  111. firstField: e,
  112. secondField: undefined,
  113. thirdField: undefined
  114. })
  115. },
  116. fieldSecondChange(e) {
  117. let theArr = [], _me = this;
  118. techFieldList.map((item) => {
  119. if (item.value == _me.state.firstField) {
  120. item.children.map((children) => {
  121. if (children.value == e) {
  122. children.children.map((third) => {
  123. theArr.push(
  124. <Select.Option key={third.value}>{third.label}</Select.Option>
  125. )
  126. })
  127. }
  128. });
  129. }
  130. });
  131. this.setState({
  132. fieldThirdOption: theArr,
  133. secondField: e,
  134. thirdField: undefined
  135. })
  136. },
  137. provinceChange(e) {
  138. let theArr = [];
  139. provinceList.map((item) => {
  140. if (item.id == e) {
  141. item.cityList.map((city) => {
  142. theArr.push(
  143. <Select.Option key={city.id}>{city.name}</Select.Option>
  144. )
  145. });
  146. }
  147. });
  148. this.setState({
  149. cityOption: theArr,
  150. province: e,
  151. city: undefined,
  152. area: undefined
  153. })
  154. },
  155. cityChange(e) {
  156. let theArr = [], _me = this;
  157. provinceList.map((item) => {
  158. if (item.id == _me.state.province) {
  159. item.cityList.map((city) => {
  160. if (city.id == e) {
  161. city.areaList.map((area) => {
  162. theArr.push(
  163. <Select.Option key={area.id}>{area.name}</Select.Option>
  164. )
  165. });
  166. };
  167. });
  168. };
  169. });
  170. this.setState({
  171. areaOption: theArr,
  172. city: e,
  173. area: undefined
  174. })
  175. },
  176. tableRowClick(record, index) {
  177. this.state.RowData = record;
  178. },
  179. interest(e) {
  180. this.setState({
  181. loading: true
  182. });
  183. $.ajax({
  184. method: "POST",
  185. dataType: "json",
  186. url: globalConfig.context + "/api/user/interest/interestUser",
  187. data: {
  188. toUid: e
  189. }
  190. }).done(function (data) {
  191. if (data.error && data.error.length) {
  192. message.warning(data.error[0].message);
  193. };
  194. this.setState({
  195. loading: false
  196. });
  197. }.bind(this));
  198. },
  199. cancelInterest(e) {
  200. this.setState({
  201. loading: true
  202. });
  203. $.ajax({
  204. method: "POST",
  205. dataType: "json",
  206. url: globalConfig.context + "/api/user/interest/cancelInterest",
  207. data: {
  208. interestId: e
  209. }
  210. }).done(function (data) {
  211. if (data.error && data.error.length) {
  212. message.warning(data.error[0].message);
  213. };
  214. this.setState({
  215. loading: false
  216. });
  217. }.bind(this));
  218. },
  219. render() {
  220. const { pageNo, pageSize, total } = this.state.pagination;
  221. const _me = this;
  222. return (
  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) => { this.setState({ thirdField: e }) }}>
  254. {this.state.fieldThirdOption}
  255. </Select>
  256. <Button type="ghost" style={{ marginLeft: '20px' }}
  257. onClick={() => {
  258. this.setState({
  259. firstField: undefined,
  260. secondField: undefined,
  261. thirdField: undefined
  262. });
  263. this.state.firstField = undefined;
  264. this.state.secondField = undefined;
  265. this.state.thirdField = undefined;
  266. this.loadData();
  267. }}>不限</Button>
  268. </Col>
  269. </Row>
  270. <Row className="search-criteria">
  271. <Col className="search-title" span={2}>
  272. <span>地区</span>
  273. </Col>
  274. <Col className="search-select" span={22}>
  275. <Select style={{ width: 100, marginRight: '10px', marginBottom: '10px' }}
  276. value={this.state.province}
  277. placeholder="请选择省份"
  278. notFoundContent="未获取到省份列表"
  279. showSearch
  280. filterOption={companySearch}
  281. onChange={this.provinceChange}>
  282. {this.state.provinceOption}
  283. </Select>
  284. <Select style={{ width: 160, marginRight: '10px', marginBottom: '10px' }}
  285. value={this.state.city}
  286. placeholder="请选择行业城市"
  287. notFoundContent="未获取到城市列表"
  288. showSearch
  289. filterOption={companySearch}
  290. onChange={this.cityChange}>
  291. {this.state.cityOption}
  292. </Select>
  293. <Select style={{ width: 160, marginRight: '10px', marginBottom: '10px' }}
  294. value={this.state.area}
  295. placeholder="请选择行政区"
  296. notFoundContent="未获取到行政区列表"
  297. showSearch
  298. filterOption={companySearch}
  299. onChange={(e) => { this.setState({ area: e }) }}>
  300. {this.state.areaOption}
  301. </Select>
  302. <Button type="ghost" style={{ marginLeft: '20px' }}
  303. onClick={() => {
  304. this.setState({
  305. province: undefined,
  306. city: undefined,
  307. area: undefined
  308. });
  309. this.state.province = undefined;
  310. this.state.city = undefined;
  311. this.state.area = undefined;
  312. this.loadData();
  313. }}>不限</Button>
  314. </Col>
  315. </Row>
  316. <Row className="search-criteria">
  317. <Col className="search-title" span={2}>
  318. <span>用户类型</span>
  319. </Col>
  320. <Col className="search-select" span={6}>
  321. <Radio.Group defaultValue={0} onChange={(e) => {
  322. this.setState({
  323. type: e.target.value
  324. });
  325. this.state.type = e.target.value;
  326. this.loadData();
  327. }}>
  328. <Radio.Button value={0}>个人</Radio.Button>
  329. <Radio.Button value={1}>组织</Radio.Button>
  330. </Radio.Group>
  331. </Col>
  332. </Row>
  333. <Row className="search-criteria">
  334. <Col className="search-title" span={2}>
  335. <span>用户名</span>
  336. </Col>
  337. <Col className="search-select" span={6}>
  338. <Input style={{ width: 200, marginBottom: '10px' }} value={this.state.searchName} onChange={(e) => { this.setState({ searchName: e.target.value }) }} />
  339. <Button type="primary" style={{ marginLeft: '20px' }}
  340. onClick={() => { this.loadData(); }}>搜索</Button>
  341. </Col>
  342. </Row>
  343. <Spin spinning={this.state.loading}>
  344. <ul className="clearfix">
  345. {this.state.dataSource.map((item) => {
  346. return <li className="user-detail" onClick={() => {
  347. window.open(globalConfig.context + '/user/subscriberDetail.html?rid=' + item.uid + '&type=' + item.type);
  348. }}>
  349. <div className="logo">
  350. <img src={(item.personPortraitUrl || item.logoUrl) ?
  351. (globalConfig.avatarHost + "/upload" + (_me.state.type == 0 ? item.personPortraitUrl : item.logoUrl))
  352. : avatarImg} alt="头像" />
  353. </div>
  354. <div className="name">
  355. {_me.state.type == 0 ? item.username : item.unitName}
  356. </div>
  357. <div className="province">{getProvince(item.province)}</div>
  358. <div className="text">{'需求:' + item.demandNum + '条'}</div>
  359. <div className="text">{'技术成果:' + item.achievementNum + '条'}</div>
  360. </li>
  361. })}
  362. </ul>
  363. <Pagination style={{ float: 'right' }}
  364. onChange={(e) => { this.loadData(e); }}
  365. total={total}
  366. showTotal={() => { return '共' + total + '条数据' }}
  367. current={pageNo}
  368. pageSize={pageSize} />
  369. </Spin>
  370. </div >
  371. )
  372. }
  373. });
  374. export default Content;