subscriber.jsx 18 KB

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