subscriberOrg.jsx 16 KB

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